@jswork/react-questkit 0.0.0-stage → 1.0.2
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/README.md +32 -2
- package/dist/index.cjs +6798 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +777 -0
- package/dist/index.d.ts +779 -0
- package/dist/index.mjs +6728 -0
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +2 -0
- package/package.json +64 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, RefObject, ReactElement, MouseEvent } from 'react';
|
|
3
|
+
import classnames from 'classnames';
|
|
4
|
+
|
|
5
|
+
type SoundName = 'click' | 'tick' | 'correct' | 'wrong' | 'perfect' | 'great' | 'nobad' | 'again' | 'finish';
|
|
6
|
+
declare function playSound(name: SoundName): void;
|
|
7
|
+
declare function setSoundEnabled(enabled: boolean): void;
|
|
8
|
+
declare function isSoundEnabled(): boolean;
|
|
9
|
+
declare const questSfx: {
|
|
10
|
+
play: typeof playSound;
|
|
11
|
+
setEnabled: typeof setSoundEnabled;
|
|
12
|
+
isEnabled: typeof isSoundEnabled;
|
|
13
|
+
click: () => void;
|
|
14
|
+
tick: () => void;
|
|
15
|
+
correct: () => void;
|
|
16
|
+
wrong: () => void;
|
|
17
|
+
perfect: () => void;
|
|
18
|
+
great: () => void;
|
|
19
|
+
nobad: () => void;
|
|
20
|
+
again: () => void;
|
|
21
|
+
finish: () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** 答题 / 查阅(已提交回看) / 预览(课件端教师视角) */
|
|
25
|
+
type QuestMode = 'answer' | 'lookup' | 'preview';
|
|
26
|
+
/** 判题阶段:未答、首错重试、答对、二错锁定 */
|
|
27
|
+
type JudgePhase = 'idle' | 'retry' | 'correct' | 'locked';
|
|
28
|
+
/** 口语评分档位 */
|
|
29
|
+
type QuestGrade = 'perfect' | 'great' | 'nobad' | 'again';
|
|
30
|
+
/** 口语评分结果(noise = 音质不合格,不出分不扣次数) */
|
|
31
|
+
type OralGrade = QuestGrade | 'noise';
|
|
32
|
+
interface JudgeState {
|
|
33
|
+
phase: JudgePhase;
|
|
34
|
+
attempts: number;
|
|
35
|
+
}
|
|
36
|
+
interface QuestResult {
|
|
37
|
+
correct: boolean;
|
|
38
|
+
attempts: number;
|
|
39
|
+
/** 题型原始作答,便于业务上报 */
|
|
40
|
+
answer: unknown;
|
|
41
|
+
}
|
|
42
|
+
type AudioSource = string;
|
|
43
|
+
type ImageSource = string;
|
|
44
|
+
type PosterSource = string;
|
|
45
|
+
/** 内置矢量插画名 */
|
|
46
|
+
type ArtName = 'kid' | 'balloon' | 'apple' | 'coffee' | 'cat' | 'books' | 'headphones' | 'screen' | 'trophy' | 'speech';
|
|
47
|
+
/** 文本朗读适配器,默认走 SpeechSynthesis */
|
|
48
|
+
type SpeakText = (text: string, opts?: {
|
|
49
|
+
lang?: string;
|
|
50
|
+
rate?: number;
|
|
51
|
+
}) => Promise<void>;
|
|
52
|
+
interface QuestCommonProps {
|
|
53
|
+
/** 默认 'answer' */
|
|
54
|
+
mode?: QuestMode;
|
|
55
|
+
index?: number;
|
|
56
|
+
total?: number;
|
|
57
|
+
title?: ReactNode;
|
|
58
|
+
/** 后台配置的说明文案,支持 <b> 标蓝;留空整行不渲染 */
|
|
59
|
+
instruction?: ReactNode;
|
|
60
|
+
onBack?: () => void;
|
|
61
|
+
onPrev?: () => void;
|
|
62
|
+
onNext?: () => void;
|
|
63
|
+
onSubmit?: (result: QuestResult) => void;
|
|
64
|
+
/** 默认 true */
|
|
65
|
+
sound?: boolean;
|
|
66
|
+
/** 演示直达:0 未答 / 1 首错 / 2 二错 */
|
|
67
|
+
demoAttempt?: 0 | 1 | 2;
|
|
68
|
+
className?: string;
|
|
69
|
+
}
|
|
70
|
+
interface QuestOptionData {
|
|
71
|
+
text: ReactNode;
|
|
72
|
+
sub?: ReactNode;
|
|
73
|
+
audio?: AudioSource;
|
|
74
|
+
image?: ImageSource;
|
|
75
|
+
speak?: boolean;
|
|
76
|
+
}
|
|
77
|
+
interface SingleChoiceData {
|
|
78
|
+
stem: ReactNode;
|
|
79
|
+
stemAudio?: AudioSource;
|
|
80
|
+
stemImage?: ImageSource;
|
|
81
|
+
options: QuestOptionData[];
|
|
82
|
+
answer: number;
|
|
83
|
+
analysis?: ReactNode;
|
|
84
|
+
/** 二错展示的答案文案,默认 `${A}. ${text}` */
|
|
85
|
+
answerLabel?: ReactNode;
|
|
86
|
+
}
|
|
87
|
+
interface FollowReadWordData {
|
|
88
|
+
text: string;
|
|
89
|
+
phonetic?: string;
|
|
90
|
+
partOfSpeech?: string;
|
|
91
|
+
meaning?: string;
|
|
92
|
+
}
|
|
93
|
+
interface FollowReadSentenceData {
|
|
94
|
+
words: string[];
|
|
95
|
+
translation?: ReactNode;
|
|
96
|
+
}
|
|
97
|
+
interface FollowReadData {
|
|
98
|
+
kind: 'word' | 'sentence';
|
|
99
|
+
word?: FollowReadWordData;
|
|
100
|
+
sentence?: FollowReadSentenceData;
|
|
101
|
+
art?: ArtName;
|
|
102
|
+
/** 默认 50 秒 */
|
|
103
|
+
maxSeconds?: number;
|
|
104
|
+
/** 默认 5 次 */
|
|
105
|
+
maxAttempts?: number;
|
|
106
|
+
}
|
|
107
|
+
type FollowReadDemoState = 'perfect' | 'great' | 'nobad' | 'again' | 'noise' | 'limit' | 'fail';
|
|
108
|
+
interface FollowReadExtraProps {
|
|
109
|
+
/** 演示用:直接进入对应判分/异常态 */
|
|
110
|
+
demoState?: FollowReadDemoState;
|
|
111
|
+
onScore?: (payload: {
|
|
112
|
+
kind: 'word' | 'sentence';
|
|
113
|
+
text: string;
|
|
114
|
+
audio: Blob | null;
|
|
115
|
+
}) => OralGrade | Promise<OralGrade>;
|
|
116
|
+
onRecordingChange?: (recording: boolean) => void;
|
|
117
|
+
}
|
|
118
|
+
/** 连线节点类型;同一侧所有节点必须一致 */
|
|
119
|
+
type LinkMatchNodeKind = 'text' | 'image' | 'audio';
|
|
120
|
+
interface LinkMatchSideItem {
|
|
121
|
+
/** 文本内容;图片侧可作为 alt 兜底,音频侧可用于朗读 */
|
|
122
|
+
text?: ReactNode;
|
|
123
|
+
phonetic?: ReactNode;
|
|
124
|
+
/** 图片地址,kind=image 时优先渲染 */
|
|
125
|
+
image?: ImageSource;
|
|
126
|
+
/** 图片加载失败时的替代文案 */
|
|
127
|
+
imageAlt?: string;
|
|
128
|
+
/** 使用内置矢量插画作为图片 */
|
|
129
|
+
art?: ArtName;
|
|
130
|
+
audio?: AudioSource;
|
|
131
|
+
speak?: boolean;
|
|
132
|
+
/** 无 text 时用于语音合成的朗读文本 */
|
|
133
|
+
spokenText?: string;
|
|
134
|
+
}
|
|
135
|
+
interface LinkMatchData {
|
|
136
|
+
left: LinkMatchSideItem[];
|
|
137
|
+
right: LinkMatchSideItem[];
|
|
138
|
+
/** 左侧节点类型,默认按首项推断;同侧不可混用 */
|
|
139
|
+
leftKind?: LinkMatchNodeKind;
|
|
140
|
+
/** 右侧节点类型,默认按首项推断;同侧不可混用 */
|
|
141
|
+
rightKind?: LinkMatchNodeKind;
|
|
142
|
+
/** 左 i ↔ 右 j */
|
|
143
|
+
pairs: Array<[number, number]>;
|
|
144
|
+
hint?: ReactNode;
|
|
145
|
+
answerText?: ReactNode;
|
|
146
|
+
analysis?: ReactNode;
|
|
147
|
+
}
|
|
148
|
+
interface RearrangeData {
|
|
149
|
+
kind: 'word' | 'sentence';
|
|
150
|
+
/** word 用字符串,sentence 用词数组 */
|
|
151
|
+
target: string | string[];
|
|
152
|
+
/** word:已给出的字母位置 */
|
|
153
|
+
holders?: number[];
|
|
154
|
+
/** sentence:其他可接受词序 */
|
|
155
|
+
alternatives?: string[][];
|
|
156
|
+
hint?: ReactNode;
|
|
157
|
+
analysis?: ReactNode;
|
|
158
|
+
}
|
|
159
|
+
interface ClassifyData {
|
|
160
|
+
categories: Array<{
|
|
161
|
+
label: ReactNode;
|
|
162
|
+
sub?: ReactNode;
|
|
163
|
+
}>;
|
|
164
|
+
items: Array<{
|
|
165
|
+
text: ReactNode;
|
|
166
|
+
category: number;
|
|
167
|
+
}>;
|
|
168
|
+
answerText?: ReactNode;
|
|
169
|
+
analysis?: ReactNode;
|
|
170
|
+
}
|
|
171
|
+
interface RewriteData {
|
|
172
|
+
stem: ReactNode;
|
|
173
|
+
prompt?: ReactNode;
|
|
174
|
+
/** 可接受答案列表 */
|
|
175
|
+
answers: string[];
|
|
176
|
+
analysis?: ReactNode;
|
|
177
|
+
placeholder?: string;
|
|
178
|
+
/** 默认 3 行 */
|
|
179
|
+
minRows?: number;
|
|
180
|
+
}
|
|
181
|
+
interface FillBlankSlot {
|
|
182
|
+
answers: string[];
|
|
183
|
+
placeholder?: string;
|
|
184
|
+
}
|
|
185
|
+
interface FillBlankData {
|
|
186
|
+
/** n + 1 段文本 */
|
|
187
|
+
segments: string[];
|
|
188
|
+
blanks: FillBlankSlot[];
|
|
189
|
+
translation?: ReactNode;
|
|
190
|
+
analysis?: ReactNode;
|
|
191
|
+
}
|
|
192
|
+
interface WordSelectData {
|
|
193
|
+
segments: string[];
|
|
194
|
+
blanks: Array<{
|
|
195
|
+
answer: string;
|
|
196
|
+
}>;
|
|
197
|
+
/** 含干扰项 */
|
|
198
|
+
bank: string[];
|
|
199
|
+
translation?: ReactNode;
|
|
200
|
+
/** 默认 'sequence' */
|
|
201
|
+
interaction?: 'sequence' | 'slot-first';
|
|
202
|
+
analysis?: ReactNode;
|
|
203
|
+
}
|
|
204
|
+
interface SortSentencesData {
|
|
205
|
+
order: string[];
|
|
206
|
+
/** 打乱后的句子 */
|
|
207
|
+
bank: string[];
|
|
208
|
+
analysis?: ReactNode;
|
|
209
|
+
}
|
|
210
|
+
interface ClozeData {
|
|
211
|
+
segments: string[];
|
|
212
|
+
gaps: Array<{
|
|
213
|
+
answer: string;
|
|
214
|
+
}>;
|
|
215
|
+
/** 每空一组选项 */
|
|
216
|
+
options: string[][];
|
|
217
|
+
translation?: ReactNode;
|
|
218
|
+
analysis?: ReactNode;
|
|
219
|
+
}
|
|
220
|
+
interface ReadingQuestionData {
|
|
221
|
+
stem: ReactNode;
|
|
222
|
+
options: string[];
|
|
223
|
+
answer: number;
|
|
224
|
+
}
|
|
225
|
+
interface ReadingData {
|
|
226
|
+
title: ReactNode;
|
|
227
|
+
passage: ReactNode;
|
|
228
|
+
questions: ReadingQuestionData[];
|
|
229
|
+
collapsible?: boolean;
|
|
230
|
+
defaultCollapsed?: boolean;
|
|
231
|
+
analysis?: ReactNode;
|
|
232
|
+
answerText?: ReactNode;
|
|
233
|
+
}
|
|
234
|
+
interface ListenTaskData {
|
|
235
|
+
title: ReactNode;
|
|
236
|
+
subtitle?: ReactNode;
|
|
237
|
+
badge?: ReactNode;
|
|
238
|
+
cover?: ArtName | ImageSource;
|
|
239
|
+
audio?: AudioSource;
|
|
240
|
+
/** 秒 */
|
|
241
|
+
duration: number;
|
|
242
|
+
stats?: Array<{
|
|
243
|
+
label: ReactNode;
|
|
244
|
+
value: ReactNode;
|
|
245
|
+
}>;
|
|
246
|
+
}
|
|
247
|
+
interface VideoTaskItem {
|
|
248
|
+
title: ReactNode;
|
|
249
|
+
src?: string;
|
|
250
|
+
poster?: PosterSource;
|
|
251
|
+
duration: number;
|
|
252
|
+
}
|
|
253
|
+
interface VideoTaskData {
|
|
254
|
+
videos: VideoTaskItem[];
|
|
255
|
+
stats?: Array<{
|
|
256
|
+
label: ReactNode;
|
|
257
|
+
value: ReactNode;
|
|
258
|
+
}>;
|
|
259
|
+
finishTitle?: ReactNode;
|
|
260
|
+
}
|
|
261
|
+
interface QuestLabels {
|
|
262
|
+
submit: string;
|
|
263
|
+
submitCount: string;
|
|
264
|
+
retry: string;
|
|
265
|
+
next: string;
|
|
266
|
+
prev: string;
|
|
267
|
+
back: string;
|
|
268
|
+
answer: string;
|
|
269
|
+
analysis: string;
|
|
270
|
+
correctAll: string;
|
|
271
|
+
wrongAnswer: string;
|
|
272
|
+
tapToRead: string;
|
|
273
|
+
readAloud: string;
|
|
274
|
+
recording: string;
|
|
275
|
+
scoring: string;
|
|
276
|
+
releaseToSend: string;
|
|
277
|
+
holdToRecord: string;
|
|
278
|
+
tapToFollow: string;
|
|
279
|
+
recordingHint: string;
|
|
280
|
+
rescore: string;
|
|
281
|
+
submitted: string;
|
|
282
|
+
noiseHint: string;
|
|
283
|
+
againHint: string;
|
|
284
|
+
attemptsLeft: string;
|
|
285
|
+
attemptsUsedUp: string;
|
|
286
|
+
play: string;
|
|
287
|
+
pause: string;
|
|
288
|
+
replay: string;
|
|
289
|
+
loop: string;
|
|
290
|
+
speed: string;
|
|
291
|
+
finish: string;
|
|
292
|
+
submitAndStats: string;
|
|
293
|
+
effectivePlay: string;
|
|
294
|
+
totalTime: string;
|
|
295
|
+
reading: string;
|
|
296
|
+
expand: string;
|
|
297
|
+
collapse: string;
|
|
298
|
+
notAnswered: string;
|
|
299
|
+
fullscreen: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface UseJudgeOptions {
|
|
303
|
+
/** 基于当前作答判定是否正确;组件内部实现 */
|
|
304
|
+
evaluate: () => boolean;
|
|
305
|
+
/** 首错归约:移除错误项、保留正确项 */
|
|
306
|
+
onFirstWrong?: () => void;
|
|
307
|
+
/** 每次判定后回调,供组件展示反馈 */
|
|
308
|
+
onSettled?: (state: JudgeState, correct: boolean) => void;
|
|
309
|
+
/** 默认 true */
|
|
310
|
+
sound?: boolean;
|
|
311
|
+
/** 演示直达:0 未答 / 1 首错 / 2 二错 */
|
|
312
|
+
demoAttempt?: 0 | 1 | 2;
|
|
313
|
+
}
|
|
314
|
+
interface UseJudgeResult {
|
|
315
|
+
state: JudgeState;
|
|
316
|
+
phase: JudgeState['phase'];
|
|
317
|
+
attempts: number;
|
|
318
|
+
/** 提交判定,返回最新状态;非可答阶段直接原样返回 */
|
|
319
|
+
submit: () => JudgeState;
|
|
320
|
+
/** 首错后「重试一次」:回到可作答,判定次数保留 */
|
|
321
|
+
retry: () => JudgeState;
|
|
322
|
+
/** 完全重置(切题/重新开始) */
|
|
323
|
+
reset: () => JudgeState;
|
|
324
|
+
}
|
|
325
|
+
declare function useJudge(options: UseJudgeOptions): UseJudgeResult;
|
|
326
|
+
|
|
327
|
+
type InstructionVariant = 'card' | 'plain';
|
|
328
|
+
interface InstructionProps {
|
|
329
|
+
children?: ReactNode;
|
|
330
|
+
/** 是否显示前置信息图标;纯文本变体默认不显示 */
|
|
331
|
+
icon?: boolean;
|
|
332
|
+
/** 胶囊提示条或纯文本说明 */
|
|
333
|
+
variant?: InstructionVariant;
|
|
334
|
+
className?: string;
|
|
335
|
+
}
|
|
336
|
+
/** 空值整行不渲染;支持 <b> / <u> 行内标记 */
|
|
337
|
+
declare function Instruction({ children, icon, variant, className }: InstructionProps): react.JSX.Element | null;
|
|
338
|
+
|
|
339
|
+
interface QuestShellProps {
|
|
340
|
+
mode?: QuestMode;
|
|
341
|
+
title?: ReactNode;
|
|
342
|
+
index?: number;
|
|
343
|
+
total?: number;
|
|
344
|
+
instruction?: ReactNode;
|
|
345
|
+
/** 说明条外观,默认胶囊提示条 */
|
|
346
|
+
instructionVariant?: InstructionVariant;
|
|
347
|
+
onBack?: () => void;
|
|
348
|
+
footer?: ReactNode;
|
|
349
|
+
/** 反馈卡绝对定位在操作栏上方 */
|
|
350
|
+
feedback?: ReactNode;
|
|
351
|
+
dataQuest?: string;
|
|
352
|
+
className?: string;
|
|
353
|
+
children?: ReactNode;
|
|
354
|
+
}
|
|
355
|
+
declare function QuestShell({ mode, index, total, instruction, instructionVariant, footer, feedback, dataQuest, className, children }: QuestShellProps): react.JSX.Element;
|
|
356
|
+
|
|
357
|
+
type OptionState = 'default' | 'selected' | 'correct' | 'wrong' | 'disabled' | 'faded';
|
|
358
|
+
interface OptionItemProps {
|
|
359
|
+
label: ReactNode;
|
|
360
|
+
children?: ReactNode;
|
|
361
|
+
sub?: ReactNode;
|
|
362
|
+
state?: OptionState;
|
|
363
|
+
disabled?: boolean;
|
|
364
|
+
onClick?: () => void;
|
|
365
|
+
/** 图片选项时纵向排布 */
|
|
366
|
+
layout?: 'row' | 'grid';
|
|
367
|
+
/** 选项配图等媒体(直接渲染,非交互) */
|
|
368
|
+
media?: ReactNode;
|
|
369
|
+
/** 是否显示朗读角标 */
|
|
370
|
+
audioIndicator?: boolean;
|
|
371
|
+
className?: string;
|
|
372
|
+
}
|
|
373
|
+
declare function OptionItem({ label, children, sub, state, disabled, onClick, layout, media, audioIndicator, className, }: OptionItemProps): react.JSX.Element;
|
|
374
|
+
|
|
375
|
+
type FeedbackTone = 'ok' | 'bad' | 'warn';
|
|
376
|
+
interface FeedbackSheetProps {
|
|
377
|
+
tone?: FeedbackTone;
|
|
378
|
+
title: ReactNode;
|
|
379
|
+
detail?: ReactNode;
|
|
380
|
+
answer?: ReactNode;
|
|
381
|
+
analysis?: ReactNode;
|
|
382
|
+
/** 口语结果的星级 */
|
|
383
|
+
stars?: number;
|
|
384
|
+
answerLabel?: ReactNode;
|
|
385
|
+
analysisLabel?: ReactNode;
|
|
386
|
+
className?: string;
|
|
387
|
+
}
|
|
388
|
+
declare function FeedbackSheet({ tone, title, detail, answer, analysis, stars, answerLabel, analysisLabel, className, }: FeedbackSheetProps): react.JSX.Element;
|
|
389
|
+
|
|
390
|
+
interface ProgressProps {
|
|
391
|
+
/** 当前进度值,通常为题目序号 */
|
|
392
|
+
value: number;
|
|
393
|
+
/** 进度总量,通常为题目总数 */
|
|
394
|
+
total: number;
|
|
395
|
+
/** 是否显示左侧的 5/6 数值,默认显示 */
|
|
396
|
+
showValue?: boolean;
|
|
397
|
+
/** 进度条的辅助描述 */
|
|
398
|
+
ariaLabel?: string;
|
|
399
|
+
className?: string;
|
|
400
|
+
}
|
|
401
|
+
/** 独立答题进度条:左侧题号,右侧渐变轨道 */
|
|
402
|
+
declare function Progress({ value, total, showValue, ariaLabel, className }: ProgressProps): react.JSX.Element;
|
|
403
|
+
|
|
404
|
+
interface SegmentedOption {
|
|
405
|
+
value: string;
|
|
406
|
+
label: ReactNode;
|
|
407
|
+
ariaLabel?: string;
|
|
408
|
+
disabled?: boolean;
|
|
409
|
+
}
|
|
410
|
+
interface SegmentedControlProps {
|
|
411
|
+
options: SegmentedOption[];
|
|
412
|
+
value: string;
|
|
413
|
+
onChange?: (value: string) => void;
|
|
414
|
+
ariaLabel?: string;
|
|
415
|
+
disabled?: boolean;
|
|
416
|
+
className?: string;
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* 分段选择器。蓝色选中块使用真实尺寸测量后在选项间滑动,
|
|
420
|
+
* 因此不同文字宽度、字体加载和容器缩放时也能保持对齐。
|
|
421
|
+
*/
|
|
422
|
+
declare function SegmentedControl({ options, value, onChange, ariaLabel, disabled, className, }: SegmentedControlProps): react.JSX.Element;
|
|
423
|
+
|
|
424
|
+
interface SingleChoiceProps extends QuestCommonProps {
|
|
425
|
+
data: SingleChoiceData;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
declare function SingleChoice({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SingleChoiceProps): react.JSX.Element;
|
|
429
|
+
|
|
430
|
+
interface FollowReadProps extends QuestCommonProps, FollowReadExtraProps {
|
|
431
|
+
data: FollowReadData;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
declare function FollowRead({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, className, demoState, onScore, onRecordingChange, }: FollowReadProps): react.JSX.Element;
|
|
435
|
+
|
|
436
|
+
interface LinkMatchProps extends QuestCommonProps {
|
|
437
|
+
data: LinkMatchData;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
declare function LinkMatch({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: LinkMatchProps): react.JSX.Element;
|
|
441
|
+
|
|
442
|
+
interface RearrangeProps extends QuestCommonProps {
|
|
443
|
+
data: RearrangeData;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
declare function Rearrange({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: RearrangeProps): react.JSX.Element;
|
|
447
|
+
|
|
448
|
+
interface ClassifyProps extends QuestCommonProps {
|
|
449
|
+
data: ClassifyData;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare function Classify({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: ClassifyProps): react.JSX.Element;
|
|
453
|
+
|
|
454
|
+
interface RewriteProps extends QuestCommonProps {
|
|
455
|
+
data: RewriteData;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
declare function Rewrite({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: RewriteProps): react.JSX.Element;
|
|
459
|
+
|
|
460
|
+
interface FillBlankProps extends QuestCommonProps {
|
|
461
|
+
data: FillBlankData;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
declare function FillBlank({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: FillBlankProps): react.JSX.Element;
|
|
465
|
+
|
|
466
|
+
interface WordSelectProps extends QuestCommonProps {
|
|
467
|
+
data: WordSelectData;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
declare function WordSelect({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: WordSelectProps): react.JSX.Element;
|
|
471
|
+
|
|
472
|
+
interface SortSentencesProps extends QuestCommonProps {
|
|
473
|
+
data: SortSentencesData;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
declare function SortSentences({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: SortSentencesProps): react.JSX.Element;
|
|
477
|
+
|
|
478
|
+
interface ClozeProps extends QuestCommonProps {
|
|
479
|
+
data: ClozeData;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare function Cloze({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: ClozeProps): react.JSX.Element;
|
|
483
|
+
|
|
484
|
+
interface ReadingComprehensionProps extends QuestCommonProps {
|
|
485
|
+
data: ReadingData;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
declare function ReadingComprehension({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, sound, demoAttempt, className, }: ReadingComprehensionProps): react.JSX.Element;
|
|
489
|
+
|
|
490
|
+
interface ListenTaskProps extends QuestCommonProps {
|
|
491
|
+
data: ListenTaskData;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
declare function ListenTask({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, className, }: ListenTaskProps): react.JSX.Element;
|
|
495
|
+
|
|
496
|
+
interface VideoTaskProps extends QuestCommonProps {
|
|
497
|
+
data: VideoTaskData;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
declare function VideoTask({ data, mode, index, total, title, instruction, onBack, onPrev, onNext, onSubmit, className, }: VideoTaskProps): react.JSX.Element;
|
|
501
|
+
|
|
502
|
+
declare const defaultQuestLabels: QuestLabels;
|
|
503
|
+
interface QuestConfig {
|
|
504
|
+
/** 默认音效开关 */
|
|
505
|
+
sound?: boolean;
|
|
506
|
+
/** 文案覆盖,按 key 合并 */
|
|
507
|
+
labels?: Partial<QuestLabels>;
|
|
508
|
+
/** 文本朗读适配器,默认 SpeechSynthesis */
|
|
509
|
+
speakText?: SpeakText;
|
|
510
|
+
}
|
|
511
|
+
interface QuestConfigProviderProps {
|
|
512
|
+
config?: QuestConfig;
|
|
513
|
+
children?: ReactNode;
|
|
514
|
+
}
|
|
515
|
+
declare function QuestConfigProvider({ config, children, }: QuestConfigProviderProps): react.JSX.Element;
|
|
516
|
+
declare function useQuestConfig(): QuestConfig;
|
|
517
|
+
/** 合并默认文案与 Provider 覆盖 */
|
|
518
|
+
declare function useQuestLabels(override?: Partial<QuestLabels>): QuestLabels;
|
|
519
|
+
|
|
520
|
+
interface MediaProgressOptions {
|
|
521
|
+
/** 总时长,秒 */
|
|
522
|
+
duration: number;
|
|
523
|
+
/** 真实媒体资源;缺省时使用内部演示时钟 */
|
|
524
|
+
src?: string;
|
|
525
|
+
/** 完成阈值,默认 0.9 */
|
|
526
|
+
threshold?: number;
|
|
527
|
+
/** 初始倍速,默认 1 */
|
|
528
|
+
speed?: number;
|
|
529
|
+
}
|
|
530
|
+
interface MediaProgressApi {
|
|
531
|
+
position: number;
|
|
532
|
+
credited: number;
|
|
533
|
+
ratio: number;
|
|
534
|
+
completed: boolean;
|
|
535
|
+
finished: boolean;
|
|
536
|
+
playing: boolean;
|
|
537
|
+
speed: number;
|
|
538
|
+
loop: boolean;
|
|
539
|
+
timeOnTask: number;
|
|
540
|
+
/** 真实媒体元素的 ref(无 src 时为 null) */
|
|
541
|
+
mediaRef: RefObject<HTMLMediaElement | null>;
|
|
542
|
+
play: () => void;
|
|
543
|
+
pause: () => void;
|
|
544
|
+
toggle: () => void;
|
|
545
|
+
seek: (seconds: number) => void;
|
|
546
|
+
setSpeed: (speed: number) => void;
|
|
547
|
+
setLoop: (loop: boolean) => void;
|
|
548
|
+
reset: () => void;
|
|
549
|
+
}
|
|
550
|
+
declare function formatTime(seconds: number): string;
|
|
551
|
+
/**
|
|
552
|
+
* 有效进度时钟:
|
|
553
|
+
* - 只有正常推进的播放时间计入 credited
|
|
554
|
+
* - 拖拽/跳转只改 position
|
|
555
|
+
* - 倍速按 Δt × speed 计入
|
|
556
|
+
* - 循环播放继续累计,封顶 duration
|
|
557
|
+
*/
|
|
558
|
+
declare function useMediaProgress({ duration, src, threshold, speed: initialSpeed, }: MediaProgressOptions): MediaProgressApi;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* 统一复用 classnames 的合并规则:
|
|
562
|
+
* 支持字符串、数字、布尔、数组、对象(truthy 值保留 key)。
|
|
563
|
+
*/
|
|
564
|
+
type ClassValue = Parameters<typeof classnames>[number];
|
|
565
|
+
declare function classNames(...values: ClassValue[]): string;
|
|
566
|
+
|
|
567
|
+
interface ArtProps {
|
|
568
|
+
name: ArtName;
|
|
569
|
+
className?: string;
|
|
570
|
+
size?: number;
|
|
571
|
+
}
|
|
572
|
+
declare function Art({ name, className, size }: ArtProps): ReactElement;
|
|
573
|
+
|
|
574
|
+
interface QuestAction {
|
|
575
|
+
key: string;
|
|
576
|
+
label: ReactNode;
|
|
577
|
+
onClick?: () => void;
|
|
578
|
+
variant?: 'primary' | 'ghost';
|
|
579
|
+
disabled?: boolean;
|
|
580
|
+
icon?: ReactNode;
|
|
581
|
+
ariaLabel?: string;
|
|
582
|
+
}
|
|
583
|
+
interface ActionBarProps {
|
|
584
|
+
actions: QuestAction[];
|
|
585
|
+
/** 当前页面进度,1-based;默认 1 */
|
|
586
|
+
index?: number;
|
|
587
|
+
/** 上一题回调;传入后进入自动上一题模式 */
|
|
588
|
+
onPrev?: () => void;
|
|
589
|
+
className?: string;
|
|
590
|
+
}
|
|
591
|
+
declare function ActionBar({ actions, index, onPrev, className }: ActionBarProps): react.JSX.Element | null;
|
|
592
|
+
|
|
593
|
+
interface AudioBarProps {
|
|
594
|
+
src?: string;
|
|
595
|
+
/** 演示时钟时长,默认 3 秒 */
|
|
596
|
+
duration?: number;
|
|
597
|
+
label?: ReactNode;
|
|
598
|
+
playing?: boolean;
|
|
599
|
+
onToggle?: () => void;
|
|
600
|
+
onPlayingChange?: (playing: boolean) => void;
|
|
601
|
+
compact?: boolean;
|
|
602
|
+
className?: string;
|
|
603
|
+
}
|
|
604
|
+
declare function AudioBar({ src, duration, label, playing, onToggle, onPlayingChange, compact, className, }: AudioBarProps): react.JSX.Element;
|
|
605
|
+
|
|
606
|
+
type BlankState = 'default' | 'correct' | 'wrong' | 'locked';
|
|
607
|
+
interface BlankInputProps {
|
|
608
|
+
value: string;
|
|
609
|
+
onChange?: (value: string) => void;
|
|
610
|
+
state?: BlankState;
|
|
611
|
+
placeholder?: string;
|
|
612
|
+
disabled?: boolean;
|
|
613
|
+
ariaLabel?: string;
|
|
614
|
+
onFocus?: () => void;
|
|
615
|
+
className?: string;
|
|
616
|
+
/** 最小宽度,字符数 */
|
|
617
|
+
minCh?: number;
|
|
618
|
+
}
|
|
619
|
+
declare function BlankInput({ value, onChange, state, placeholder, disabled, ariaLabel, onFocus, className, minCh, }: BlankInputProps): react.JSX.Element;
|
|
620
|
+
|
|
621
|
+
interface CardProps {
|
|
622
|
+
children?: ReactNode;
|
|
623
|
+
/** 无内边距容器 */
|
|
624
|
+
flush?: boolean;
|
|
625
|
+
/** 浅蓝底色 */
|
|
626
|
+
tint?: boolean;
|
|
627
|
+
className?: string;
|
|
628
|
+
}
|
|
629
|
+
declare function Card({ children, flush, tint, className }: CardProps): react.JSX.Element;
|
|
630
|
+
|
|
631
|
+
type CelebrationGrade = 'perfect' | 'great' | 'nobad' | 'again';
|
|
632
|
+
interface CelebrationProps {
|
|
633
|
+
grade: CelebrationGrade;
|
|
634
|
+
/** 覆盖默认标题 */
|
|
635
|
+
title?: ReactNode;
|
|
636
|
+
/** 覆盖默认绶带文案 */
|
|
637
|
+
ribbon?: ReactNode;
|
|
638
|
+
note?: ReactNode;
|
|
639
|
+
confetti?: boolean;
|
|
640
|
+
/** 自动消失时长(毫秒),不传则常驻 */
|
|
641
|
+
autoHideMs?: number;
|
|
642
|
+
className?: string;
|
|
643
|
+
}
|
|
644
|
+
declare function Celebration({ grade, title, ribbon, note, confetti, autoHideMs, className }: CelebrationProps): react.JSX.Element | null;
|
|
645
|
+
|
|
646
|
+
type PictureState = 'default' | 'loading' | 'fail' | 'ok';
|
|
647
|
+
interface PictureBoxProps {
|
|
648
|
+
src?: string;
|
|
649
|
+
alt?: string;
|
|
650
|
+
/** 无图或加载中使用的内置插画 */
|
|
651
|
+
art?: ArtName;
|
|
652
|
+
state?: PictureState;
|
|
653
|
+
caption?: ReactNode;
|
|
654
|
+
onRetry?: () => void;
|
|
655
|
+
ratio?: string;
|
|
656
|
+
className?: string;
|
|
657
|
+
}
|
|
658
|
+
declare function PictureBox({ src, alt, art, state, caption, onRetry, ratio, className, }: PictureBoxProps): react.JSX.Element;
|
|
659
|
+
|
|
660
|
+
type RecordState = 'idle' | 'recording' | 'scoring' | 'done';
|
|
661
|
+
type RecordHintTone = 'default' | 'done' | 'bad';
|
|
662
|
+
interface RecordClusterProps {
|
|
663
|
+
state?: RecordState;
|
|
664
|
+
seconds?: number;
|
|
665
|
+
maxSeconds?: number;
|
|
666
|
+
onRecordStart?: () => void;
|
|
667
|
+
onRecordEnd?: () => void;
|
|
668
|
+
onPlayMine?: () => void | Promise<void>;
|
|
669
|
+
onPlayDemo?: () => void | Promise<void>;
|
|
670
|
+
disabled?: boolean;
|
|
671
|
+
/** 麦克风下方的主提示 */
|
|
672
|
+
hint?: ReactNode;
|
|
673
|
+
/** 主提示下方的辅助说明 */
|
|
674
|
+
detail?: ReactNode;
|
|
675
|
+
hintTone?: RecordHintTone;
|
|
676
|
+
detailTone?: 'default' | 'bad';
|
|
677
|
+
className?: string;
|
|
678
|
+
}
|
|
679
|
+
declare function RecordCluster({ state, seconds, maxSeconds, onRecordStart, onRecordEnd, onPlayMine, onPlayDemo, disabled, hint, detail, hintTone, detailTone, className, }: RecordClusterProps): react.JSX.Element;
|
|
680
|
+
|
|
681
|
+
interface StarRatingProps {
|
|
682
|
+
/** 0 - 3 颗星 */
|
|
683
|
+
value: number;
|
|
684
|
+
size?: number;
|
|
685
|
+
animate?: boolean;
|
|
686
|
+
className?: string;
|
|
687
|
+
label?: string;
|
|
688
|
+
}
|
|
689
|
+
declare function StarRating({ value, size, animate, className, label, }: StarRatingProps): react.JSX.Element;
|
|
690
|
+
|
|
691
|
+
type ToastAlign = 'left' | 'center' | 'right';
|
|
692
|
+
interface ToastOptions {
|
|
693
|
+
/** 水平对齐,默认居中 */
|
|
694
|
+
align?: ToastAlign;
|
|
695
|
+
}
|
|
696
|
+
interface ToastPayload {
|
|
697
|
+
message: ReactNode;
|
|
698
|
+
align: ToastAlign;
|
|
699
|
+
}
|
|
700
|
+
interface ToastApi {
|
|
701
|
+
show: (message: ReactNode, options?: ToastOptions) => void;
|
|
702
|
+
}
|
|
703
|
+
declare function useQuestToast(): ToastApi;
|
|
704
|
+
interface ToastController {
|
|
705
|
+
toast: ToastPayload | null;
|
|
706
|
+
show: (message: ReactNode, options?: ToastOptions) => void;
|
|
707
|
+
api: ToastApi;
|
|
708
|
+
}
|
|
709
|
+
/** 壳层内的轻提示状态:2.4s 自动消失,重复触发重置计时 */
|
|
710
|
+
declare function useToastController(): ToastController;
|
|
711
|
+
interface ToastProps {
|
|
712
|
+
children?: ReactNode;
|
|
713
|
+
align?: ToastAlign;
|
|
714
|
+
className?: string;
|
|
715
|
+
}
|
|
716
|
+
declare function Toast({ children, align, className }: ToastProps): react.JSX.Element | null;
|
|
717
|
+
interface QuestToastProviderProps {
|
|
718
|
+
api: ToastApi;
|
|
719
|
+
children?: ReactNode;
|
|
720
|
+
}
|
|
721
|
+
declare function QuestToastProvider({ api, children }: QuestToastProviderProps): react.JSX.Element;
|
|
722
|
+
|
|
723
|
+
type WordChipState = 'default' | 'used' | 'selected' | 'correct' | 'wrong';
|
|
724
|
+
type WordChipVariant = 'placed' | 'bank' | 'word' | 'letter';
|
|
725
|
+
interface WordChipProps {
|
|
726
|
+
children?: ReactNode;
|
|
727
|
+
onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
728
|
+
state?: WordChipState;
|
|
729
|
+
variant?: WordChipVariant;
|
|
730
|
+
/** 词块右侧显示移除图标 */
|
|
731
|
+
removable?: boolean;
|
|
732
|
+
disabled?: boolean;
|
|
733
|
+
className?: string;
|
|
734
|
+
ariaLabel?: string;
|
|
735
|
+
}
|
|
736
|
+
declare function WordChip({ children, onClick, state, variant, removable, disabled, className, ariaLabel, }: WordChipProps): react.JSX.Element;
|
|
737
|
+
|
|
738
|
+
declare const version: string;
|
|
739
|
+
declare const questkit: {
|
|
740
|
+
version: string;
|
|
741
|
+
QuestShell: typeof QuestShell;
|
|
742
|
+
OptionItem: typeof OptionItem;
|
|
743
|
+
FeedbackSheet: typeof FeedbackSheet;
|
|
744
|
+
Instruction: typeof Instruction;
|
|
745
|
+
Progress: typeof Progress;
|
|
746
|
+
SegmentedControl: typeof SegmentedControl;
|
|
747
|
+
SingleChoice: typeof SingleChoice;
|
|
748
|
+
FollowRead: typeof FollowRead;
|
|
749
|
+
LinkMatch: typeof LinkMatch;
|
|
750
|
+
Rearrange: typeof Rearrange;
|
|
751
|
+
Classify: typeof Classify;
|
|
752
|
+
Rewrite: typeof Rewrite;
|
|
753
|
+
FillBlank: typeof FillBlank;
|
|
754
|
+
WordSelect: typeof WordSelect;
|
|
755
|
+
SortSentences: typeof SortSentences;
|
|
756
|
+
Cloze: typeof Cloze;
|
|
757
|
+
ReadingComprehension: typeof ReadingComprehension;
|
|
758
|
+
ListenTask: typeof ListenTask;
|
|
759
|
+
VideoTask: typeof VideoTask;
|
|
760
|
+
useJudge: typeof useJudge;
|
|
761
|
+
questSfx: {
|
|
762
|
+
play: typeof playSound;
|
|
763
|
+
setEnabled: typeof setSoundEnabled;
|
|
764
|
+
isEnabled: typeof isSoundEnabled;
|
|
765
|
+
click: () => void;
|
|
766
|
+
tick: () => void;
|
|
767
|
+
correct: () => void;
|
|
768
|
+
wrong: () => void;
|
|
769
|
+
perfect: () => void;
|
|
770
|
+
great: () => void;
|
|
771
|
+
nobad: () => void;
|
|
772
|
+
again: () => void;
|
|
773
|
+
finish: () => void;
|
|
774
|
+
};
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
export { ActionBar, type ActionBarProps, Art, type ArtName, AudioBar, type AudioBarProps, type AudioSource, BlankInput, type BlankInputProps, type BlankState, Card, type CardProps, Celebration, type CelebrationGrade, type CelebrationProps, Classify, type ClassifyData, type ClassifyProps, Cloze, type ClozeData, type ClozeProps, FeedbackSheet, type FeedbackSheetProps, FillBlank, type FillBlankData, type FillBlankProps, type FillBlankSlot, FollowRead, type FollowReadData, type FollowReadDemoState, type FollowReadExtraProps, type FollowReadProps, type FollowReadSentenceData, type FollowReadWordData, type ImageSource, Instruction, type InstructionProps, type InstructionVariant, type JudgePhase, type JudgeState, LinkMatch, type LinkMatchData, type LinkMatchNodeKind, type LinkMatchProps, type LinkMatchSideItem, ListenTask, type ListenTaskData, type ListenTaskProps, type MediaProgressApi, type MediaProgressOptions, OptionItem, type OralGrade, PictureBox, type PictureBoxProps, type PictureState, type PosterSource, Progress, type ProgressProps, type QuestAction, type QuestCommonProps, type QuestConfig, QuestConfigProvider, type QuestGrade, type QuestLabels, type QuestMode, type QuestOptionData, type QuestCommonProps as QuestProps, QuestConfigProvider as QuestProvider, type QuestResult, QuestShell, type QuestShellProps, type QuestResult as QuestSubmitResult, QuestToastProvider, type QuestToastProviderProps, ReadingComprehension, type ReadingComprehensionProps, type ReadingData, type ReadingQuestionData, Rearrange, type RearrangeData, type RearrangeProps, RecordCluster, type RecordClusterProps, type RecordHintTone, type RecordState, Rewrite, type RewriteData, type RewriteProps, SegmentedControl, type SegmentedControlProps, type SegmentedOption, SingleChoice, type SingleChoiceData, type SingleChoiceProps, SortSentences, type SortSentencesData, type SortSentencesProps, type SpeakText, StarRating, type StarRatingProps, Toast, type ToastAlign, type ToastApi, type ToastController, type ToastOptions, type ToastPayload, type ToastProps, type UseJudgeOptions, type UseJudgeResult, VideoTask, type VideoTaskData, type VideoTaskItem, type VideoTaskProps, WordChip, type WordChipProps, type WordChipState, type WordChipVariant, WordSelect, type WordSelectData, type WordSelectProps, classNames, questkit as default, defaultQuestLabels, formatTime, questSfx, useJudge, useMediaProgress, useQuestConfig, useQuestLabels, useQuestToast, useToastController, version };
|