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.
- package/dist/index.js +75 -40
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +75 -40
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31226,7 +31226,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31226
31226
|
}, {
|
|
31227
31227
|
label: "STRAIN",
|
|
31228
31228
|
value: studentPressure.strainStudent,
|
|
31229
|
-
tooltip: "
|
|
31229
|
+
tooltip: "Still in control but starting to feel the pressure."
|
|
31230
31230
|
}, {
|
|
31231
31231
|
label: "OVERWHELMED",
|
|
31232
31232
|
value: studentPressure.burnoutStudent,
|
|
@@ -31238,8 +31238,8 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31238
31238
|
tooltipVisible = _useState[0],
|
|
31239
31239
|
setTooltipVisible = _useState[1];
|
|
31240
31240
|
|
|
31241
|
-
var _useState2 = React.useState(
|
|
31242
|
-
|
|
31241
|
+
var _useState2 = React.useState(""),
|
|
31242
|
+
infoTooltip = _useState2[0],
|
|
31243
31243
|
setInfoTooltip = _useState2[1];
|
|
31244
31244
|
|
|
31245
31245
|
var _useState3 = React.useState(0),
|
|
@@ -31265,7 +31265,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31265
31265
|
dummyElement.style.whiteSpace = "wrap";
|
|
31266
31266
|
dummyElement.style.fontSize = fontSize;
|
|
31267
31267
|
dummyElement.style.width = "162px";
|
|
31268
|
-
dummyElement.style.padding = "5px 5px 5px
|
|
31268
|
+
dummyElement.style.padding = "5px 5px 5px 8px";
|
|
31269
31269
|
dummyElement.innerHTML = text;
|
|
31270
31270
|
document.body.appendChild(dummyElement);
|
|
31271
31271
|
var height = dummyElement.offsetHeight;
|
|
@@ -31273,24 +31273,38 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31273
31273
|
return height;
|
|
31274
31274
|
};
|
|
31275
31275
|
|
|
31276
|
+
var getWidthFromText = function getWidthFromText(text, fontSize, fontWeight) {
|
|
31277
|
+
var dummyElement = document.createElement("span");
|
|
31278
|
+
dummyElement.style.visibility = "hidden";
|
|
31279
|
+
dummyElement.style.position = "absolute";
|
|
31280
|
+
dummyElement.style.whiteSpace = "nowrap";
|
|
31281
|
+
dummyElement.style.fontSize = fontSize;
|
|
31282
|
+
dummyElement.style.fontWeight = fontWeight;
|
|
31283
|
+
dummyElement.innerHTML = text;
|
|
31284
|
+
document.body.appendChild(dummyElement);
|
|
31285
|
+
var width = dummyElement.offsetWidth;
|
|
31286
|
+
document.body.removeChild(dummyElement);
|
|
31287
|
+
return width;
|
|
31288
|
+
};
|
|
31289
|
+
|
|
31276
31290
|
var handleDotHover = function handleDotHover(students, x, y, label, color) {
|
|
31277
31291
|
setTooltipStudents(Array.from(new Set(students)));
|
|
31278
|
-
setTooltipX(isMobileScreen && label ==
|
|
31292
|
+
setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 45 : x);
|
|
31279
31293
|
setTooltipY(y);
|
|
31280
31294
|
setTooltipVisible(label);
|
|
31281
31295
|
setColorTooltip(color);
|
|
31282
31296
|
};
|
|
31283
31297
|
|
|
31284
|
-
var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip) {
|
|
31285
|
-
setTooltipVisible(
|
|
31286
|
-
setInfoTooltip(
|
|
31287
|
-
setTooltipX(x);
|
|
31298
|
+
var handleEnterInfoIcon = function handleEnterInfoIcon(x, y, tip, label) {
|
|
31299
|
+
setTooltipVisible(label);
|
|
31300
|
+
setInfoTooltip(tip);
|
|
31301
|
+
setTooltipX(isMobileScreen && label == data[data.length - 1].label ? x - 15 : x);
|
|
31288
31302
|
setTooltipY(y);
|
|
31289
31303
|
};
|
|
31290
31304
|
|
|
31291
31305
|
var handleLeaveInfoIcon = function handleLeaveInfoIcon() {
|
|
31292
31306
|
setTooltipVisible("");
|
|
31293
|
-
setInfoTooltip(
|
|
31307
|
+
setInfoTooltip("");
|
|
31294
31308
|
};
|
|
31295
31309
|
|
|
31296
31310
|
var handleDotLeave = function handleDotLeave() {
|
|
@@ -31366,7 +31380,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31366
31380
|
var circleY = !isMobileScreen ? chartHeight - 30 : chartHeight - 24;
|
|
31367
31381
|
|
|
31368
31382
|
var _loop = function _loop(i) {
|
|
31369
|
-
var _data3,
|
|
31383
|
+
var _data3, _data4, _data5, _data5$value, _data5$value$length, _data8, _data9;
|
|
31370
31384
|
|
|
31371
31385
|
var circleX = circleSpacing * i + alignment;
|
|
31372
31386
|
var radius = !isMobileScreen ? 15 : 12;
|
|
@@ -31375,12 +31389,17 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31375
31389
|
circle.setAttribute("cy", "" + circleY);
|
|
31376
31390
|
circle.setAttribute("r", "" + radius);
|
|
31377
31391
|
circle.setAttribute("fill", colors[i - 1]);
|
|
31392
|
+
circle.style.cursor = "pointer";
|
|
31378
31393
|
circle.addEventListener("mouseenter", function () {
|
|
31379
31394
|
var _data, _data2;
|
|
31380
31395
|
|
|
31381
31396
|
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]);
|
|
31382
31397
|
});
|
|
31383
|
-
|
|
31398
|
+
var lineHeight = 20;
|
|
31399
|
+
var tooltipHeight = ((_data3 = data[i - 1]) === null || _data3 === void 0 ? void 0 : _data3.value.length) * lineHeight * 6;
|
|
31400
|
+
var widthLabel = getWidthFromText((_data4 = data[i - 1]) === null || _data4 === void 0 ? void 0 : _data4.label, "9px", "bold");
|
|
31401
|
+
var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
|
|
31402
|
+
if (isScrollStudents) circle.addEventListener("click", handleDotLeave);else circle.addEventListener("mouseleave", handleDotLeave);
|
|
31384
31403
|
svg.appendChild(circle);
|
|
31385
31404
|
var text = document.createElementNS("http://www.w3.org/2000/svg", "text");
|
|
31386
31405
|
text.setAttribute("x", "" + circleX);
|
|
@@ -31390,15 +31409,17 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31390
31409
|
text.setAttribute("text-anchor", "middle");
|
|
31391
31410
|
text.setAttribute("dominant-baseline", "middle");
|
|
31392
31411
|
text.setAttribute("style", "cursor: default");
|
|
31393
|
-
text.textContent = (
|
|
31412
|
+
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();
|
|
31413
|
+
text.style.cursor = "pointer";
|
|
31394
31414
|
text.addEventListener("mouseenter", function () {
|
|
31395
|
-
var
|
|
31415
|
+
var _data6, _data7;
|
|
31396
31416
|
|
|
31397
|
-
handleDotHover((
|
|
31417
|
+
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]);
|
|
31398
31418
|
});
|
|
31419
|
+
if (isScrollStudents) text.addEventListener("click", handleDotLeave);else text.addEventListener("mouseleave", handleDotLeave);
|
|
31399
31420
|
svg.appendChild(text);
|
|
31400
|
-
var label = (
|
|
31401
|
-
var tooltip = (
|
|
31421
|
+
var label = (_data8 = data[i - 1]) === null || _data8 === void 0 ? void 0 : _data8.label;
|
|
31422
|
+
var tooltip = (_data9 = data[i - 1]) === null || _data9 === void 0 ? void 0 : _data9.tooltip;
|
|
31402
31423
|
var infoIconContainer = document.createElementNS("http://www.w3.org/2000/svg", "foreignObject");
|
|
31403
31424
|
var infoIcon = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
31404
31425
|
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>";
|
|
@@ -31424,13 +31445,14 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31424
31445
|
|
|
31425
31446
|
labelText.textContent = label;
|
|
31426
31447
|
svg.appendChild(labelText);
|
|
31427
|
-
|
|
31428
|
-
|
|
31448
|
+
var infoX = isMobileScreen ? circleX - 8 : circleX + 8 + labelText.getBoundingClientRect().width / 2;
|
|
31449
|
+
var infoY = isMobileScreen ? circleY - radius - 32 - labelText.getBoundingClientRect().height : circleY - radius - 20 - labelText.getBoundingClientRect().height / 2;
|
|
31450
|
+
infoIconContainer.setAttribute("x", "" + infoX);
|
|
31451
|
+
infoIconContainer.setAttribute("y", "" + infoY);
|
|
31429
31452
|
infoIconContainer.addEventListener("mouseenter", function () {
|
|
31430
|
-
return handleEnterInfoIcon(
|
|
31453
|
+
return handleEnterInfoIcon(infoX, infoY + 4, tooltip, label);
|
|
31431
31454
|
});
|
|
31432
31455
|
infoIconContainer.addEventListener("mouseleave", handleLeaveInfoIcon);
|
|
31433
|
-
labelText.getBoundingClientRect();
|
|
31434
31456
|
svg.appendChild(infoIconContainer);
|
|
31435
31457
|
};
|
|
31436
31458
|
|
|
@@ -31449,29 +31471,42 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31449
31471
|
}
|
|
31450
31472
|
};
|
|
31451
31473
|
|
|
31452
|
-
|
|
31453
|
-
svg.firstChild
|
|
31454
|
-
|
|
31474
|
+
try {
|
|
31475
|
+
while (svg.firstChild) {
|
|
31476
|
+
while (svg.firstChild.firstChild) {
|
|
31477
|
+
svg.firstChild.firstChild.remove();
|
|
31478
|
+
}
|
|
31479
|
+
|
|
31480
|
+
svg.firstChild.remove();
|
|
31481
|
+
}
|
|
31455
31482
|
|
|
31456
|
-
|
|
31483
|
+
drawChart();
|
|
31484
|
+
} catch (err) {
|
|
31485
|
+
console.log("err: ", err);
|
|
31486
|
+
}
|
|
31457
31487
|
}
|
|
31458
|
-
}, [chartWidth, studentPressure]);
|
|
31488
|
+
}, [chartWidth, chartHeight, JSON.stringify(studentPressure)]);
|
|
31489
|
+
var widthLabel = React.useMemo(function () {
|
|
31490
|
+
if (!!tooltipVisible) return getWidthFromText(tooltipVisible, "9px", "bold");
|
|
31491
|
+
return 0;
|
|
31492
|
+
}, [tooltipVisible]);
|
|
31459
31493
|
var lineHeight = 20;
|
|
31460
|
-
var tooltipHeight = tooltipStudents.length * lineHeight;
|
|
31461
|
-
var
|
|
31494
|
+
var tooltipHeight = tooltipStudents.length * lineHeight * 6;
|
|
31495
|
+
var isScrollStudents = tooltipHeight + 30 > chartHeight - 100 - (isMobileScreen ? widthLabel : 0);
|
|
31496
|
+
var maxHeightTooltip = isScrollStudents ? chartHeight - 100 - (isMobileScreen ? widthLabel : 0) : tooltipHeight + 30;
|
|
31462
31497
|
var heightInfoTooltip = React.useMemo(function () {
|
|
31463
|
-
if (
|
|
31498
|
+
if (!!infoTooltip && !!tooltipVisible) return getHeightFromText(infoTooltip, "12px");
|
|
31464
31499
|
return 0;
|
|
31465
|
-
}, [
|
|
31500
|
+
}, [infoTooltip, tooltipVisible]);
|
|
31466
31501
|
return React__default.createElement("svg", {
|
|
31467
31502
|
ref: svgRef,
|
|
31468
31503
|
width: chartWidth,
|
|
31469
31504
|
height: chartHeight + 50
|
|
31470
31505
|
}, !!tooltipVisible && React__default.createElement("g", {
|
|
31471
|
-
transform: "translate(" + (
|
|
31506
|
+
transform: "translate(" + (infoTooltip ? tooltipX - 81 : tooltipX - 100) + "," + Math.max(0, infoTooltip ? tooltipY - heightInfoTooltip - 30 : isMobileScreen ? tooltipY - tooltipHeight - 100 - widthLabel : tooltipY - tooltipHeight - 100) + ")"
|
|
31472
31507
|
}, React__default.createElement("rect", {
|
|
31473
|
-
width:
|
|
31474
|
-
height:
|
|
31508
|
+
width: infoTooltip ? 162 : 200,
|
|
31509
|
+
height: infoTooltip ? heightInfoTooltip + 10 : maxHeightTooltip + 10,
|
|
31475
31510
|
fill: "rgba(36, 36, 36, 0.8)",
|
|
31476
31511
|
rx: "5"
|
|
31477
31512
|
}), React__default.createElement("text", {
|
|
@@ -31480,10 +31515,10 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31480
31515
|
fill: "#fff",
|
|
31481
31516
|
fontSize: "12px",
|
|
31482
31517
|
textAnchor: "start"
|
|
31483
|
-
}, !
|
|
31518
|
+
}, !infoTooltip && tooltipStudents.length + " students are " + tooltipVisible), !!infoTooltip && React__default.createElement("foreignObject", {
|
|
31484
31519
|
x: "0",
|
|
31485
31520
|
y: "10",
|
|
31486
|
-
width:
|
|
31521
|
+
width: infoTooltip ? 162 : 200,
|
|
31487
31522
|
height: heightInfoTooltip
|
|
31488
31523
|
}, React__default.createElement("div", {
|
|
31489
31524
|
style: {
|
|
@@ -31491,7 +31526,7 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31491
31526
|
color: "#fff",
|
|
31492
31527
|
fontSize: "12px"
|
|
31493
31528
|
}
|
|
31494
|
-
},
|
|
31529
|
+
}, infoTooltip)), !infoTooltip && React__default.createElement("foreignObject", {
|
|
31495
31530
|
x: "0",
|
|
31496
31531
|
y: "30",
|
|
31497
31532
|
width: "200",
|
|
@@ -31499,12 +31534,12 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31499
31534
|
}, React__default.createElement("div", {
|
|
31500
31535
|
style: {
|
|
31501
31536
|
overflowY: "auto",
|
|
31502
|
-
maxHeight: maxHeightTooltip - 20 + "px",
|
|
31537
|
+
maxHeight: (isScrollStudents ? maxHeightTooltip - 30 : maxHeightTooltip - 20) + "px",
|
|
31503
31538
|
padding: "5px 5px 5px 10px",
|
|
31504
31539
|
color: "#fff",
|
|
31505
31540
|
fontSize: "12px"
|
|
31506
31541
|
}
|
|
31507
|
-
}, tooltipStudents.map(function (label, index) {
|
|
31542
|
+
}, [].concat(tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents, tooltipStudents).map(function (label, index) {
|
|
31508
31543
|
return React__default.createElement("div", {
|
|
31509
31544
|
key: index
|
|
31510
31545
|
}, React__default.createElement("span", {
|
|
@@ -31518,8 +31553,8 @@ var StudentPressureChart = function StudentPressureChart(_ref) {
|
|
|
31518
31553
|
}
|
|
31519
31554
|
}), React__default.createElement("span", null, label));
|
|
31520
31555
|
}))), React__default.createElement("foreignObject", {
|
|
31521
|
-
y:
|
|
31522
|
-
x:
|
|
31556
|
+
y: infoTooltip ? heightInfoTooltip + 10 : Math.min(tooltipHeight + 40, maxHeightTooltip + 10),
|
|
31557
|
+
x: infoTooltip ? isMobileScreen && tooltipVisible === data[data.length - 1].label ? 99 : 84 : isMobileScreen && tooltipVisible === "OVERWHELMED" ? 139 : 94,
|
|
31523
31558
|
width: 10,
|
|
31524
31559
|
height: 10
|
|
31525
31560
|
}, React__default.createElement("div", {
|