@mathscan/math-exercise-engine 1.1.9 → 1.1.10
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 +74 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -52
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +34 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15243,19 +15243,21 @@ const DragOptions = ({
|
|
|
15243
15243
|
options,
|
|
15244
15244
|
onOptionClick
|
|
15245
15245
|
}) => {
|
|
15246
|
-
|
|
15247
|
-
|
|
15248
|
-
|
|
15249
|
-
|
|
15250
|
-
|
|
15251
|
-
|
|
15252
|
-
|
|
15253
|
-
|
|
15254
|
-
|
|
15255
|
-
|
|
15256
|
-
|
|
15257
|
-
|
|
15258
|
-
|
|
15246
|
+
const [shuffledOptions] = useState(
|
|
15247
|
+
() => lodashExports.shuffle(options.map((option, idx) => ({
|
|
15248
|
+
optionId: `drag-option-${idx}`,
|
|
15249
|
+
value: String(option)
|
|
15250
|
+
})))
|
|
15251
|
+
);
|
|
15252
|
+
return /* @__PURE__ */ jsx(PillBackground, { children: /* @__PURE__ */ jsx("div", { className: "drag-options", children: shuffledOptions.map(({ optionId, value }) => /* @__PURE__ */ jsx(
|
|
15253
|
+
SingleDragOption,
|
|
15254
|
+
{
|
|
15255
|
+
optionId,
|
|
15256
|
+
value,
|
|
15257
|
+
onOptionClick
|
|
15258
|
+
},
|
|
15259
|
+
optionId
|
|
15260
|
+
)) }) });
|
|
15259
15261
|
};
|
|
15260
15262
|
const InlineDragOption = ({
|
|
15261
15263
|
widgetId,
|
|
@@ -15839,7 +15841,8 @@ const RadioOptions = ({
|
|
|
15839
15841
|
onChange
|
|
15840
15842
|
}) => {
|
|
15841
15843
|
const playSound = useSound();
|
|
15842
|
-
|
|
15844
|
+
const [shuffledOptions] = useState(() => lodashExports.shuffle(options));
|
|
15845
|
+
return /* @__PURE__ */ jsx("div", { className: "radio-options", children: shuffledOptions.map((option, idx) => {
|
|
15843
15846
|
const isSelected = value === option;
|
|
15844
15847
|
const statusClass = isSelected && validationStatus ? ` widget--${validationStatus}` : "";
|
|
15845
15848
|
return /* @__PURE__ */ jsx(
|
|
@@ -17418,6 +17421,11 @@ function getArrowArcLayouts(arrows, min, max) {
|
|
|
17418
17421
|
}
|
|
17419
17422
|
return sorted.sort((a, b) => a.index - b.index);
|
|
17420
17423
|
}
|
|
17424
|
+
function getArrowArcsRowHeight(layouts) {
|
|
17425
|
+
if (layouts.length === 0) return 0;
|
|
17426
|
+
const levelCount = Math.max(...layouts.map((layout) => layout.level)) + 1;
|
|
17427
|
+
return levelCount * ARROW_ARC_LEVEL_HEIGHT;
|
|
17428
|
+
}
|
|
17421
17429
|
function useElementWidth() {
|
|
17422
17430
|
const ref = useRef(null);
|
|
17423
17431
|
const [width, setWidth] = useState(0);
|
|
@@ -17518,9 +17526,8 @@ const ArrowArc = ({
|
|
|
17518
17526
|
);
|
|
17519
17527
|
};
|
|
17520
17528
|
const ArrowArcsRow = ({
|
|
17521
|
-
|
|
17522
|
-
|
|
17523
|
-
max,
|
|
17529
|
+
layouts,
|
|
17530
|
+
rowHeight,
|
|
17524
17531
|
widgets,
|
|
17525
17532
|
values,
|
|
17526
17533
|
droppedInputs,
|
|
@@ -17528,14 +17535,12 @@ const ArrowArcsRow = ({
|
|
|
17528
17535
|
onChange,
|
|
17529
17536
|
onInputFocus
|
|
17530
17537
|
}) => {
|
|
17531
|
-
const layouts = useMemo(() => getArrowArcLayouts(arrows, min, max), [arrows, min, max]);
|
|
17532
17538
|
if (layouts.length === 0) return null;
|
|
17533
|
-
const levelCount = Math.max(...layouts.map((layout) => layout.level)) + 1;
|
|
17534
17539
|
return /* @__PURE__ */ jsx(
|
|
17535
17540
|
"div",
|
|
17536
17541
|
{
|
|
17537
17542
|
className: "number-line-arrow-arcs-row",
|
|
17538
|
-
style: { height: `${
|
|
17543
|
+
style: { height: `${rowHeight}px` },
|
|
17539
17544
|
children: layouts.map((layout) => /* @__PURE__ */ jsx(
|
|
17540
17545
|
ArrowArc,
|
|
17541
17546
|
{
|
|
@@ -17726,6 +17731,15 @@ const NumberLineRenderer = ({
|
|
|
17726
17731
|
[visiblePositions]
|
|
17727
17732
|
);
|
|
17728
17733
|
const { positionContentHeight, getPositionContentRef } = useMeasuredPositionContentHeight(visiblePositionIds);
|
|
17734
|
+
const arrowArcLayouts = useMemo(
|
|
17735
|
+
() => getArrowArcLayouts(arrows, min, max),
|
|
17736
|
+
[arrows, min, max]
|
|
17737
|
+
);
|
|
17738
|
+
const arrowArcsRowHeight = useMemo(
|
|
17739
|
+
() => getArrowArcsRowHeight(arrowArcLayouts),
|
|
17740
|
+
[arrowArcLayouts]
|
|
17741
|
+
);
|
|
17742
|
+
const hasOverlayRow = arrowArcsRowHeight > 0 || visiblePositions.length > 0;
|
|
17729
17743
|
const nlValidationStatus = useMemo(() => {
|
|
17730
17744
|
if (!validationDetails || counter === void 0) return null;
|
|
17731
17745
|
if (counter.answer === void 0) return null;
|
|
@@ -17755,40 +17769,48 @@ const NumberLineRenderer = ({
|
|
|
17755
17769
|
role: "group",
|
|
17756
17770
|
"aria-label": `Number line from ${min} to ${max}`,
|
|
17757
17771
|
children: [
|
|
17758
|
-
|
|
17772
|
+
hasOverlayRow && /* @__PURE__ */ jsxs(
|
|
17759
17773
|
"div",
|
|
17760
17774
|
{
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17779
|
-
|
|
17780
|
-
|
|
17781
|
-
|
|
17782
|
-
|
|
17783
|
-
|
|
17784
|
-
|
|
17785
|
-
|
|
17786
|
-
|
|
17787
|
-
|
|
17788
|
-
|
|
17789
|
-
|
|
17790
|
-
|
|
17791
|
-
|
|
17775
|
+
className: "number-line-overlays-row",
|
|
17776
|
+
style: { "--nl-arrow-arcs-row-height": `${arrowArcsRowHeight}px` },
|
|
17777
|
+
children: [
|
|
17778
|
+
/* @__PURE__ */ jsx(
|
|
17779
|
+
ArrowArcsRow,
|
|
17780
|
+
{
|
|
17781
|
+
layouts: arrowArcLayouts,
|
|
17782
|
+
rowHeight: arrowArcsRowHeight,
|
|
17783
|
+
widgets,
|
|
17784
|
+
values,
|
|
17785
|
+
droppedInputs,
|
|
17786
|
+
validationDetails,
|
|
17787
|
+
onChange,
|
|
17788
|
+
onInputFocus
|
|
17789
|
+
}
|
|
17790
|
+
),
|
|
17791
|
+
visiblePositions.length > 0 && /* @__PURE__ */ jsx("div", { className: "number-line-content-row", children: visiblePositions.map((pos) => /* @__PURE__ */ jsx(
|
|
17792
|
+
"div",
|
|
17793
|
+
{
|
|
17794
|
+
ref: getPositionContentRef(pos.id),
|
|
17795
|
+
className: "number-line-position-content",
|
|
17796
|
+
style: { left: `${toPercent(pos.value, min, max)}%` },
|
|
17797
|
+
children: pos.content.map((subItem) => /* @__PURE__ */ jsx(
|
|
17798
|
+
LayoutRenderer,
|
|
17799
|
+
{
|
|
17800
|
+
item: subItem,
|
|
17801
|
+
widgets,
|
|
17802
|
+
values,
|
|
17803
|
+
droppedInputs,
|
|
17804
|
+
validationDetails,
|
|
17805
|
+
onChange,
|
|
17806
|
+
onInputFocus
|
|
17807
|
+
},
|
|
17808
|
+
subItem.id
|
|
17809
|
+
))
|
|
17810
|
+
},
|
|
17811
|
+
pos.id
|
|
17812
|
+
)) })
|
|
17813
|
+
]
|
|
17792
17814
|
}
|
|
17793
17815
|
),
|
|
17794
17816
|
isAxisDragMode ? /* @__PURE__ */ jsx(
|