@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.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +15 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1724,11 +1724,13 @@ function followReadActions({
|
|
|
1724
1724
|
readonly,
|
|
1725
1725
|
stage,
|
|
1726
1726
|
grade,
|
|
1727
|
+
attemptsLeft,
|
|
1727
1728
|
labels,
|
|
1728
1729
|
onNext
|
|
1729
1730
|
}) {
|
|
1730
1731
|
if (readonly) return onNext ? [{ key: "next", label: labels.next, onClick: onNext }] : [];
|
|
1731
|
-
|
|
1732
|
+
const finished = stage === "result" && grade && grade !== "noise" || attemptsLeft === 0;
|
|
1733
|
+
if (finished) {
|
|
1732
1734
|
return [{ key: "next", label: labels.next, onClick: onNext }];
|
|
1733
1735
|
}
|
|
1734
1736
|
return [];
|
|
@@ -2166,7 +2168,7 @@ function detailHint({
|
|
|
2166
2168
|
if (readonly) return mode === "lookup" ? labels.submitted : void 0;
|
|
2167
2169
|
if (noise) return labels.noiseHint;
|
|
2168
2170
|
if (grade === "again") return labels.againHint;
|
|
2169
|
-
if (
|
|
2171
|
+
if (attemptsLeft === 0) {
|
|
2170
2172
|
return `${maxAttempts} \u6B21${labels.attemptsUsedUp} \xB7 \u53D6\u6700\u540E\u4E00\u6B21\u6709\u6548\u5206`;
|
|
2171
2173
|
}
|
|
2172
2174
|
if (stage === "result") return labels.submitted;
|
|
@@ -2327,7 +2329,8 @@ function useFollowRead({
|
|
|
2327
2329
|
sound,
|
|
2328
2330
|
demoState,
|
|
2329
2331
|
onScore,
|
|
2330
|
-
onRecordingChange
|
|
2332
|
+
onRecordingChange,
|
|
2333
|
+
initialAttempts
|
|
2331
2334
|
}) {
|
|
2332
2335
|
var _a, _b, _c, _d, _e, _f;
|
|
2333
2336
|
const labels = useQuestLabels();
|
|
@@ -2337,9 +2340,10 @@ function useFollowRead({
|
|
|
2337
2340
|
const preset = readonly ? void 0 : demoState;
|
|
2338
2341
|
const presetGrade = preset === "noise" ? "noise" : preset === "limit" ? "great" : preset === "perfect" || preset === "great" || preset === "nobad" || preset === "again" ? preset : null;
|
|
2339
2342
|
const initialStage = presetGrade ? "result" : "ready";
|
|
2340
|
-
const
|
|
2343
|
+
const demoAttempts = preset === "limit" ? maxAttempts : presetGrade && preset !== "again" ? 1 : 0;
|
|
2344
|
+
const restoredAttempts = initialAttempts == null ? demoAttempts : Math.min(maxAttempts, Math.max(0, Math.trunc(initialAttempts)));
|
|
2341
2345
|
const [stage, setStageState] = (0, import_react14.useState)(initialStage);
|
|
2342
|
-
const [attemptsUsed, setAttemptsUsed] = (0, import_react14.useState)(
|
|
2346
|
+
const [attemptsUsed, setAttemptsUsed] = (0, import_react14.useState)(restoredAttempts);
|
|
2343
2347
|
const [grade, setGrade] = (0, import_react14.useState)(presetGrade);
|
|
2344
2348
|
const [noise, setNoise] = (0, import_react14.useState)(preset === "noise");
|
|
2345
2349
|
const stageRef = (0, import_react14.useRef)(initialStage);
|
|
@@ -2438,7 +2442,8 @@ function FollowRead({
|
|
|
2438
2442
|
className,
|
|
2439
2443
|
demoState,
|
|
2440
2444
|
onScore,
|
|
2441
|
-
onRecordingChange
|
|
2445
|
+
onRecordingChange,
|
|
2446
|
+
initialAttempts
|
|
2442
2447
|
}) {
|
|
2443
2448
|
const model = useFollowRead({
|
|
2444
2449
|
data,
|
|
@@ -2447,12 +2452,14 @@ function FollowRead({
|
|
|
2447
2452
|
sound,
|
|
2448
2453
|
demoState,
|
|
2449
2454
|
onScore,
|
|
2450
|
-
onRecordingChange
|
|
2455
|
+
onRecordingChange,
|
|
2456
|
+
initialAttempts
|
|
2451
2457
|
});
|
|
2452
2458
|
const actions = followReadActions({
|
|
2453
2459
|
readonly: model.readonly,
|
|
2454
2460
|
stage: model.stage,
|
|
2455
2461
|
grade: model.grade,
|
|
2462
|
+
attemptsLeft: model.attemptsLeft,
|
|
2456
2463
|
labels: model.labels,
|
|
2457
2464
|
onNext
|
|
2458
2465
|
});
|
|
@@ -7007,7 +7014,7 @@ function BlankInput2({
|
|
|
7007
7014
|
}
|
|
7008
7015
|
|
|
7009
7016
|
// src/index.tsx
|
|
7010
|
-
var version = "1.0.
|
|
7017
|
+
var version = "1.0.8";
|
|
7011
7018
|
var questkit = {
|
|
7012
7019
|
version,
|
|
7013
7020
|
QuestShell,
|