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