@jswork/react-questkit 1.0.5 → 1.0.7

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.cjs CHANGED
@@ -2327,7 +2327,8 @@ function useFollowRead({
2327
2327
  sound,
2328
2328
  demoState,
2329
2329
  onScore,
2330
- onRecordingChange
2330
+ onRecordingChange,
2331
+ initialAttempts
2331
2332
  }) {
2332
2333
  var _a, _b, _c, _d, _e, _f;
2333
2334
  const labels = useQuestLabels();
@@ -2337,9 +2338,10 @@ function useFollowRead({
2337
2338
  const preset = readonly ? void 0 : demoState;
2338
2339
  const presetGrade = preset === "noise" ? "noise" : preset === "limit" ? "great" : preset === "perfect" || preset === "great" || preset === "nobad" || preset === "again" ? preset : null;
2339
2340
  const initialStage = presetGrade ? "result" : "ready";
2340
- const initialAttempts = preset === "limit" ? maxAttempts : presetGrade && preset !== "again" ? 1 : 0;
2341
+ const demoAttempts = preset === "limit" ? maxAttempts : presetGrade && preset !== "again" ? 1 : 0;
2342
+ const restoredAttempts = initialAttempts == null ? demoAttempts : Math.min(maxAttempts, Math.max(0, Math.trunc(initialAttempts)));
2341
2343
  const [stage, setStageState] = (0, import_react14.useState)(initialStage);
2342
- const [attemptsUsed, setAttemptsUsed] = (0, import_react14.useState)(initialAttempts);
2344
+ const [attemptsUsed, setAttemptsUsed] = (0, import_react14.useState)(restoredAttempts);
2343
2345
  const [grade, setGrade] = (0, import_react14.useState)(presetGrade);
2344
2346
  const [noise, setNoise] = (0, import_react14.useState)(preset === "noise");
2345
2347
  const stageRef = (0, import_react14.useRef)(initialStage);
@@ -2438,7 +2440,8 @@ function FollowRead({
2438
2440
  className,
2439
2441
  demoState,
2440
2442
  onScore,
2441
- onRecordingChange
2443
+ onRecordingChange,
2444
+ initialAttempts
2442
2445
  }) {
2443
2446
  const model = useFollowRead({
2444
2447
  data,
@@ -2447,7 +2450,8 @@ function FollowRead({
2447
2450
  sound,
2448
2451
  demoState,
2449
2452
  onScore,
2450
- onRecordingChange
2453
+ onRecordingChange,
2454
+ initialAttempts
2451
2455
  });
2452
2456
  const actions = followReadActions({
2453
2457
  readonly: model.readonly,
@@ -7007,7 +7011,7 @@ function BlankInput2({
7007
7011
  }
7008
7012
 
7009
7013
  // src/index.tsx
7010
- var version = "1.0.5";
7014
+ var version = "1.0.7";
7011
7015
  var questkit = {
7012
7016
  version,
7013
7017
  QuestShell,