@jswork/react-questkit 1.0.6 → 1.0.8

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.d.mts CHANGED
@@ -479,9 +479,11 @@ declare function SingleChoice({ data, mode, index, total, title, instruction, on
479
479
 
480
480
  interface FollowReadProps extends QuestCommonProps, FollowReadExtraProps {
481
481
  data: FollowReadData;
482
+ /** 已用录音次数回填(0~maxAttempts),用于断点续做时对齐服务端累计重录次数。 */
483
+ initialAttempts?: number;
482
484
  }
483
485
 
484
- declare function FollowRead({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, className, demoState, onScore, onRecordingChange, }: FollowReadProps): react.JSX.Element;
486
+ declare function FollowRead({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, className, demoState, onScore, onRecordingChange, initialAttempts, }: FollowReadProps): react.JSX.Element;
485
487
 
486
488
  interface LinkMatchProps extends QuestCommonProps {
487
489
  data: LinkMatchData;
package/dist/index.d.ts CHANGED
@@ -479,9 +479,11 @@ declare function SingleChoice({ data, mode, index, total, title, instruction, on
479
479
 
480
480
  interface FollowReadProps extends QuestCommonProps, FollowReadExtraProps {
481
481
  data: FollowReadData;
482
+ /** 已用录音次数回填(0~maxAttempts),用于断点续做时对齐服务端累计重录次数。 */
483
+ initialAttempts?: number;
482
484
  }
483
485
 
484
- declare function FollowRead({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, className, demoState, onScore, onRecordingChange, }: FollowReadProps): react.JSX.Element;
486
+ declare function FollowRead({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, className, demoState, onScore, onRecordingChange, initialAttempts, }: FollowReadProps): react.JSX.Element;
485
487
 
486
488
  interface LinkMatchProps extends QuestCommonProps {
487
489
  data: LinkMatchData;
package/dist/index.mjs CHANGED
@@ -1654,11 +1654,13 @@ function followReadActions({
1654
1654
  readonly,
1655
1655
  stage,
1656
1656
  grade,
1657
+ attemptsLeft,
1657
1658
  labels,
1658
1659
  onNext
1659
1660
  }) {
1660
1661
  if (readonly) return onNext ? [{ key: "next", label: labels.next, onClick: onNext }] : [];
1661
- if (stage === "result" && grade && grade !== "noise") {
1662
+ const finished = stage === "result" && grade && grade !== "noise" || attemptsLeft === 0;
1663
+ if (finished) {
1662
1664
  return [{ key: "next", label: labels.next, onClick: onNext }];
1663
1665
  }
1664
1666
  return [];
@@ -2096,7 +2098,7 @@ function detailHint({
2096
2098
  if (readonly) return mode === "lookup" ? labels.submitted : void 0;
2097
2099
  if (noise) return labels.noiseHint;
2098
2100
  if (grade === "again") return labels.againHint;
2099
- if (stage === "result" && attemptsLeft === 0) {
2101
+ if (attemptsLeft === 0) {
2100
2102
  return `${maxAttempts} \u6B21${labels.attemptsUsedUp} \xB7 \u53D6\u6700\u540E\u4E00\u6B21\u6709\u6548\u5206`;
2101
2103
  }
2102
2104
  if (stage === "result") return labels.submitted;
@@ -2257,7 +2259,8 @@ function useFollowRead({
2257
2259
  sound,
2258
2260
  demoState,
2259
2261
  onScore,
2260
- onRecordingChange
2262
+ onRecordingChange,
2263
+ initialAttempts
2261
2264
  }) {
2262
2265
  var _a, _b, _c, _d, _e, _f;
2263
2266
  const labels = useQuestLabels();
@@ -2267,9 +2270,10 @@ function useFollowRead({
2267
2270
  const preset = readonly ? void 0 : demoState;
2268
2271
  const presetGrade = preset === "noise" ? "noise" : preset === "limit" ? "great" : preset === "perfect" || preset === "great" || preset === "nobad" || preset === "again" ? preset : null;
2269
2272
  const initialStage = presetGrade ? "result" : "ready";
2270
- const initialAttempts = preset === "limit" ? maxAttempts : presetGrade && preset !== "again" ? 1 : 0;
2273
+ const demoAttempts = preset === "limit" ? maxAttempts : presetGrade && preset !== "again" ? 1 : 0;
2274
+ const restoredAttempts = initialAttempts == null ? demoAttempts : Math.min(maxAttempts, Math.max(0, Math.trunc(initialAttempts)));
2271
2275
  const [stage, setStageState] = useState11(initialStage);
2272
- const [attemptsUsed, setAttemptsUsed] = useState11(initialAttempts);
2276
+ const [attemptsUsed, setAttemptsUsed] = useState11(restoredAttempts);
2273
2277
  const [grade, setGrade] = useState11(presetGrade);
2274
2278
  const [noise, setNoise] = useState11(preset === "noise");
2275
2279
  const stageRef = useRef8(initialStage);
@@ -2368,7 +2372,8 @@ function FollowRead({
2368
2372
  className,
2369
2373
  demoState,
2370
2374
  onScore,
2371
- onRecordingChange
2375
+ onRecordingChange,
2376
+ initialAttempts
2372
2377
  }) {
2373
2378
  const model = useFollowRead({
2374
2379
  data,
@@ -2377,12 +2382,14 @@ function FollowRead({
2377
2382
  sound,
2378
2383
  demoState,
2379
2384
  onScore,
2380
- onRecordingChange
2385
+ onRecordingChange,
2386
+ initialAttempts
2381
2387
  });
2382
2388
  const actions = followReadActions({
2383
2389
  readonly: model.readonly,
2384
2390
  stage: model.stage,
2385
2391
  grade: model.grade,
2392
+ attemptsLeft: model.attemptsLeft,
2386
2393
  labels: model.labels,
2387
2394
  onNext
2388
2395
  });
@@ -6937,7 +6944,7 @@ function BlankInput2({
6937
6944
  }
6938
6945
 
6939
6946
  // src/index.tsx
6940
- var version = "1.0.6";
6947
+ var version = "1.0.8";
6941
6948
  var questkit = {
6942
6949
  version,
6943
6950
  QuestShell,