@molecule/app-quiz-card-angular 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +439 -2
- package/dist/index.d.ts +56 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -0
- package/dist/quiz-card.component.d.ts +192 -0
- package/dist/quiz-card.component.d.ts.map +1 -0
- package/dist/quiz-card.component.js +496 -0
- package/dist/quiz-card.component.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/dist/types.js.map +1 -0
- package/package.json +69 -4
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuizCard component (React parity).
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
7
|
+
import { Component, ElementRef, inject, Renderer2, signal, TemplateRef, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
10
|
+
import { Button, hasNodes, SlotWrapper } from '@molecule/app-ui-angular';
|
|
11
|
+
import * as i0 from "@angular/core";
|
|
12
|
+
const _c0 = ["stack"];
|
|
13
|
+
const _c1 = ["header"];
|
|
14
|
+
const _c2 = ["progressEl"];
|
|
15
|
+
const _c3 = ["explanationEl"];
|
|
16
|
+
const _c4 = [[["", "slot", "progress"]], [["", "slot", "timer"]], [["", "slot", "question"]], [["", "slot", "explanation"]]];
|
|
17
|
+
const _c5 = ["[slot=progress]", "[slot=timer]", "[slot=question]", "[slot=explanation]"];
|
|
18
|
+
const _forTrack0 = ($index, $item) => $item.id;
|
|
19
|
+
function QuizCard_Conditional_6_Template(rf, ctx) { if (rf & 1) {
|
|
20
|
+
i0.ɵɵelementContainerStart(0);
|
|
21
|
+
i0.ɵɵtext(1);
|
|
22
|
+
i0.ɵɵelementContainerEnd();
|
|
23
|
+
} if (rf & 2) {
|
|
24
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
25
|
+
i0.ɵɵadvance();
|
|
26
|
+
i0.ɵɵtextInterpolate(ctx_r0.progress);
|
|
27
|
+
} }
|
|
28
|
+
function QuizCard_Conditional_9_Template(rf, ctx) { if (rf & 1) {
|
|
29
|
+
i0.ɵɵelementContainerStart(0);
|
|
30
|
+
i0.ɵɵtext(1);
|
|
31
|
+
i0.ɵɵelementContainerEnd();
|
|
32
|
+
} if (rf & 2) {
|
|
33
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
34
|
+
i0.ɵɵadvance();
|
|
35
|
+
i0.ɵɵtextInterpolate(ctx_r0.timer);
|
|
36
|
+
} }
|
|
37
|
+
function QuizCard_Conditional_13_Template(rf, ctx) { if (rf & 1) {
|
|
38
|
+
i0.ɵɵelementContainerStart(0);
|
|
39
|
+
i0.ɵɵtext(1);
|
|
40
|
+
i0.ɵɵelementContainerEnd();
|
|
41
|
+
} if (rf & 2) {
|
|
42
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
43
|
+
i0.ɵɵadvance();
|
|
44
|
+
i0.ɵɵtextInterpolate(ctx_r0.question);
|
|
45
|
+
} }
|
|
46
|
+
function QuizCard_For_18_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
47
|
+
i0.ɵɵelementContainerStart(0);
|
|
48
|
+
i0.ɵɵtext(1);
|
|
49
|
+
i0.ɵɵelementContainerEnd();
|
|
50
|
+
} if (rf & 2) {
|
|
51
|
+
const option_r3 = i0.ɵɵnextContext().$implicit;
|
|
52
|
+
i0.ɵɵadvance();
|
|
53
|
+
i0.ɵɵtextInterpolate(option_r3.label);
|
|
54
|
+
} }
|
|
55
|
+
function QuizCard_For_18_Conditional_3_Template(rf, ctx) { if (rf & 1) {
|
|
56
|
+
i0.ɵɵelementContainer(0, 4);
|
|
57
|
+
} if (rf & 2) {
|
|
58
|
+
const option_r3 = i0.ɵɵnextContext().$implicit;
|
|
59
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
60
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.templateOf(option_r3.label));
|
|
61
|
+
} }
|
|
62
|
+
function QuizCard_For_18_Conditional_4_Template(rf, ctx) { if (rf & 1) {
|
|
63
|
+
i0.ɵɵelementStart(0, "span", 8);
|
|
64
|
+
i0.ɵɵtext(1, "\u2713");
|
|
65
|
+
i0.ɵɵelementEnd();
|
|
66
|
+
} }
|
|
67
|
+
function QuizCard_For_18_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
68
|
+
i0.ɵɵelementStart(0, "span", 8);
|
|
69
|
+
i0.ɵɵtext(1, "\u00D7");
|
|
70
|
+
i0.ɵɵelementEnd();
|
|
71
|
+
} }
|
|
72
|
+
function QuizCard_For_18_Template(rf, ctx) { if (rf & 1) {
|
|
73
|
+
const _r2 = i0.ɵɵgetCurrentView();
|
|
74
|
+
i0.ɵɵelementStart(0, "button", 7);
|
|
75
|
+
i0.ɵɵlistener("click", function QuizCard_For_18_Template_button_click_0_listener() { const option_r3 = i0.ɵɵrestoreView(_r2).$implicit; const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.select(option_r3)); });
|
|
76
|
+
i0.ɵɵelementStart(1, "span");
|
|
77
|
+
i0.ɵɵconditionalCreate(2, QuizCard_For_18_Conditional_2_Template, 2, 1, "ng-container")(3, QuizCard_For_18_Conditional_3_Template, 1, 1, "ng-container", 4);
|
|
78
|
+
i0.ɵɵelementEnd();
|
|
79
|
+
i0.ɵɵconditionalCreate(4, QuizCard_For_18_Conditional_4_Template, 2, 0, "span", 8);
|
|
80
|
+
i0.ɵɵconditionalCreate(5, QuizCard_For_18_Conditional_5_Template, 2, 0, "span", 8);
|
|
81
|
+
i0.ɵɵelementEnd();
|
|
82
|
+
} if (rf & 2) {
|
|
83
|
+
const option_r3 = ctx.$implicit;
|
|
84
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
85
|
+
i0.ɵɵstyleMap(ctx_r0.optionStyle(option_r3));
|
|
86
|
+
i0.ɵɵclassMap(ctx_r0.optionClasses(option_r3));
|
|
87
|
+
i0.ɵɵproperty("disabled", ctx_r0.submitted());
|
|
88
|
+
i0.ɵɵattribute("aria-pressed", ctx_r0.isSelected(option_r3) ? "true" : "false")("data-correct", ctx_r0.isCorrect(option_r3) ? "true" : null)("data-wrong", ctx_r0.isWrong(option_r3) ? "true" : null);
|
|
89
|
+
i0.ɵɵadvance(2);
|
|
90
|
+
i0.ɵɵconditional(ctx_r0.isText(option_r3.label) ? 2 : 3);
|
|
91
|
+
i0.ɵɵadvance(2);
|
|
92
|
+
i0.ɵɵconditional(ctx_r0.isCorrect(option_r3) ? 4 : -1);
|
|
93
|
+
i0.ɵɵadvance();
|
|
94
|
+
i0.ɵɵconditional(ctx_r0.isWrong(option_r3) ? 5 : -1);
|
|
95
|
+
} }
|
|
96
|
+
function QuizCard_Conditional_19_Template(rf, ctx) { if (rf & 1) {
|
|
97
|
+
const _r4 = i0.ɵɵgetCurrentView();
|
|
98
|
+
i0.ɵɵelementStart(0, "button", 9);
|
|
99
|
+
i0.ɵɵlistener("click", function QuizCard_Conditional_19_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r4); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.submit()); });
|
|
100
|
+
i0.ɵɵtext(1);
|
|
101
|
+
i0.ɵɵelementEnd();
|
|
102
|
+
} if (rf & 2) {
|
|
103
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
104
|
+
i0.ɵɵproperty("variant", "solid")("color", "primary")("disabled", !ctx_r0.selected());
|
|
105
|
+
i0.ɵɵadvance();
|
|
106
|
+
i0.ɵɵtextInterpolate(ctx_r0.submitLabel());
|
|
107
|
+
} }
|
|
108
|
+
function QuizCard_Conditional_22_Template(rf, ctx) { if (rf & 1) {
|
|
109
|
+
i0.ɵɵelementContainerStart(0);
|
|
110
|
+
i0.ɵɵtext(1);
|
|
111
|
+
i0.ɵɵelementContainerEnd();
|
|
112
|
+
} if (rf & 2) {
|
|
113
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
114
|
+
i0.ɵɵadvance();
|
|
115
|
+
i0.ɵɵtextInterpolate(ctx_r0.explanation);
|
|
116
|
+
} }
|
|
117
|
+
/**
|
|
118
|
+
* QuizCard component.
|
|
119
|
+
*
|
|
120
|
+
* Single quiz question card with multiple-choice options. The host IS React's
|
|
121
|
+
* root `<div>` (`div[mol-quiz-card]`), carrying the `Card` classes exactly as
|
|
122
|
+
* React's `Card` does. Tracks its own submit state and reveals
|
|
123
|
+
* correct/incorrect when `correctId` is provided.
|
|
124
|
+
*
|
|
125
|
+
* The node-valued `question`, `progress`, `timer` and `explanation` props
|
|
126
|
+
* arrive as projected content (`[slot=question]`, `[slot=progress]`,
|
|
127
|
+
* `[slot=timer]`, `[slot=explanation]`), as embedded templates, or as plain
|
|
128
|
+
* string inputs. A wrapper React would not render at all (the progress span,
|
|
129
|
+
* the explanation paragraph) is detached from the DOM, keeping its capture
|
|
130
|
+
* point for the projected nodes.
|
|
131
|
+
*/
|
|
132
|
+
export class QuizCard {
|
|
133
|
+
/** The question text — a string input, or `[slot=question]` projected content. */
|
|
134
|
+
question;
|
|
135
|
+
/** The answer options, rendered in order and keyed by `id`. */
|
|
136
|
+
options = [];
|
|
137
|
+
/** Id of the correct option — when provided, submit reveals correct/incorrect. */
|
|
138
|
+
correctId;
|
|
139
|
+
/** Called when the user submits an answer. */
|
|
140
|
+
onAnswer;
|
|
141
|
+
/** Progress display — a string input, a template, or `[slot=progress]` content. */
|
|
142
|
+
progress;
|
|
143
|
+
/** Optional countdown / timer — a string input, a template, or `[slot=timer]` content. */
|
|
144
|
+
timer;
|
|
145
|
+
/** Explanation shown after submit — a string input, a template, or `[slot=explanation]` content. */
|
|
146
|
+
explanation;
|
|
147
|
+
/** Extra classes on the card. */
|
|
148
|
+
className;
|
|
149
|
+
/** The inner stack (the parent of the explanation paragraph). */
|
|
150
|
+
stack;
|
|
151
|
+
/** The header (the parent of the progress span). */
|
|
152
|
+
header;
|
|
153
|
+
/** The progress span (always in the template; detached when empty). */
|
|
154
|
+
progressEl;
|
|
155
|
+
/** The explanation paragraph (always in the template; detached when React renders none). */
|
|
156
|
+
explanationEl;
|
|
157
|
+
/** The i18n provider above the card (the submit label). */
|
|
158
|
+
i18n = useTranslation();
|
|
159
|
+
/** The selected option id. */
|
|
160
|
+
selectedState = signal(null, /* @ts-ignore */
|
|
161
|
+
...(ngDevMode ? [{ debugName: "selectedState" }] : /* istanbul ignore next */ []));
|
|
162
|
+
/** Whether the answer was submitted (the card is single-shot). */
|
|
163
|
+
submittedState = signal(false, /* @ts-ignore */
|
|
164
|
+
...(ngDevMode ? [{ debugName: "submittedState" }] : /* istanbul ignore next */ []));
|
|
165
|
+
/** Detaches and re-attaches the wrappers React renders conditionally. */
|
|
166
|
+
sync = new SlotWrapper(inject(ElementRef), inject(Renderer2));
|
|
167
|
+
/** Whether a `[slot=progress]` projection landed. */
|
|
168
|
+
progressProjected = false;
|
|
169
|
+
/** Whether a `[slot=explanation]` projection landed. */
|
|
170
|
+
explanationProjected = false;
|
|
171
|
+
/** Whether the view queries have been read (nothing is withdrawn before). */
|
|
172
|
+
viewReady = false;
|
|
173
|
+
/**
|
|
174
|
+
* The current class map.
|
|
175
|
+
* @returns The UIClassMap.
|
|
176
|
+
*/
|
|
177
|
+
cm() {
|
|
178
|
+
return getClassMap();
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Computes the card class list — React's `Card` with the default `elevated`
|
|
182
|
+
* variant and `md` padding, plus `className`.
|
|
183
|
+
* @returns The class string.
|
|
184
|
+
*/
|
|
185
|
+
cardClasses() {
|
|
186
|
+
const cm = this.cm();
|
|
187
|
+
return cm.cn(cm.card({ variant: 'elevated' }), cm.cardPadding('md'), this.className);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* The outer stack class list.
|
|
191
|
+
* @returns The class string.
|
|
192
|
+
*/
|
|
193
|
+
stackClasses() {
|
|
194
|
+
return this.cm().stack(4);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The header class list.
|
|
198
|
+
* @returns The class string.
|
|
199
|
+
*/
|
|
200
|
+
headerClasses() {
|
|
201
|
+
return this.cm().flex({ justify: 'between', align: 'center', gap: 'sm' });
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The progress row class list.
|
|
205
|
+
* @returns The class string.
|
|
206
|
+
*/
|
|
207
|
+
progressClasses() {
|
|
208
|
+
const cm = this.cm();
|
|
209
|
+
return cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'));
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The question class list.
|
|
213
|
+
* @returns The class string.
|
|
214
|
+
*/
|
|
215
|
+
questionClasses() {
|
|
216
|
+
const cm = this.cm();
|
|
217
|
+
return cm.cn(cm.textSize('lg'), cm.fontWeight('bold'));
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The options container class list.
|
|
221
|
+
* @returns The class string.
|
|
222
|
+
*/
|
|
223
|
+
optionsClasses() {
|
|
224
|
+
return this.cm().stack(2);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The explanation class list.
|
|
228
|
+
* @returns The class string.
|
|
229
|
+
*/
|
|
230
|
+
explanationClasses() {
|
|
231
|
+
return this.cm().textSize('sm');
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* One answer button's class list (React's weight switch on selection).
|
|
235
|
+
* @param option - The option rendered.
|
|
236
|
+
* @returns The class string.
|
|
237
|
+
*/
|
|
238
|
+
optionClasses(option) {
|
|
239
|
+
const cm = this.cm();
|
|
240
|
+
return cm.cn(cm.flex({ align: 'center', gap: 'sm' }), cm.sp('px', 3), cm.sp('py', 2), cm.textSize('sm'), cm.cursorPointer, cm.touchTargetCompact, this.isSelected(option) ? cm.fontWeight('semibold') : cm.fontWeight('medium'));
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* One answer button's inline style — React's verdict colours and touch
|
|
244
|
+
* radius, exactly (no background declared unless a verdict shows).
|
|
245
|
+
* @param option - The option rendered.
|
|
246
|
+
* @returns The CSS text.
|
|
247
|
+
*/
|
|
248
|
+
optionStyle(option) {
|
|
249
|
+
const success = 'var(--mol-color-success, #22c55e)';
|
|
250
|
+
const error = 'var(--mol-color-error, #ef4444)';
|
|
251
|
+
const correct = this.isCorrect(option);
|
|
252
|
+
const wrong = this.isWrong(option);
|
|
253
|
+
const border = correct
|
|
254
|
+
? success
|
|
255
|
+
: wrong
|
|
256
|
+
? error
|
|
257
|
+
: this.isSelected(option)
|
|
258
|
+
? 'currentColor'
|
|
259
|
+
: 'var(--mol-color-border, rgba(128,128,128,0.35))';
|
|
260
|
+
const background = correct
|
|
261
|
+
? `; background: color-mix(in srgb, ${success} 12%, transparent)`
|
|
262
|
+
: wrong
|
|
263
|
+
? `; background: color-mix(in srgb, ${error} 12%, transparent)`
|
|
264
|
+
: '';
|
|
265
|
+
return `border-radius: 8px; border: 1px solid ${border}${background}`;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Whether an option is the current selection.
|
|
269
|
+
* @param option - The option rendered.
|
|
270
|
+
* @returns True when selected.
|
|
271
|
+
*/
|
|
272
|
+
isSelected(option) {
|
|
273
|
+
return option.id === this.selectedState();
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* React's `isCorrect`: the verdict shows only after submit, when a correct
|
|
277
|
+
* id is set and this option is it.
|
|
278
|
+
* @param option - The option rendered.
|
|
279
|
+
* @returns True when the option is the revealed correct answer.
|
|
280
|
+
*/
|
|
281
|
+
isCorrect(option) {
|
|
282
|
+
return this.submittedState() && !!this.correctId && option.id === this.correctId;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* React's `isWrong`: the selected option after submit is not the correct one.
|
|
286
|
+
* @param option - The option rendered.
|
|
287
|
+
* @returns True when the option is the revealed wrong answer.
|
|
288
|
+
*/
|
|
289
|
+
isWrong(option) {
|
|
290
|
+
return (this.submittedState() &&
|
|
291
|
+
!!this.correctId &&
|
|
292
|
+
this.isSelected(option) &&
|
|
293
|
+
option.id !== this.correctId);
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Whether the answer was submitted.
|
|
297
|
+
* @returns True after submit.
|
|
298
|
+
*/
|
|
299
|
+
submitted() {
|
|
300
|
+
return this.submittedState();
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The selected option id, if any.
|
|
304
|
+
* @returns The id, or null.
|
|
305
|
+
*/
|
|
306
|
+
selected() {
|
|
307
|
+
return this.selectedState();
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Whether a value is plain text (React renders it as text, not as nodes).
|
|
311
|
+
* @param value - A label, question or slot value.
|
|
312
|
+
* @returns True when the value is a string.
|
|
313
|
+
*/
|
|
314
|
+
isText(value) {
|
|
315
|
+
return typeof value === 'string';
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Narrows a value to an embedded template.
|
|
319
|
+
* @param value - A label, question or slot value.
|
|
320
|
+
* @returns The template, or null.
|
|
321
|
+
*/
|
|
322
|
+
templateOf(value) {
|
|
323
|
+
return value instanceof TemplateRef ? value : null;
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Whether the progress row renders at all — React's `{progress && …}`.
|
|
327
|
+
* @returns True when a text, template or projected progress row exists.
|
|
328
|
+
*/
|
|
329
|
+
hasProgress() {
|
|
330
|
+
return ((typeof this.progress === 'string' && this.progress.length > 0) ||
|
|
331
|
+
this.templateOf(this.progress) !== null ||
|
|
332
|
+
this.progressProjected);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Whether the explanation renders — React's `explanation && <p>`.
|
|
336
|
+
* @returns True when a text, template or projected explanation exists.
|
|
337
|
+
*/
|
|
338
|
+
hasExplanation() {
|
|
339
|
+
return ((typeof this.explanation === 'string' && this.explanation.length > 0) ||
|
|
340
|
+
this.templateOf(this.explanation) !== null ||
|
|
341
|
+
this.explanationProjected);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* The submit button's label.
|
|
345
|
+
* @returns The translated text.
|
|
346
|
+
*/
|
|
347
|
+
submitLabel() {
|
|
348
|
+
return this.i18n.t('quizCard.submit', {}, { defaultValue: 'Submit answer' });
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Selects an option (React ignores the click after submit).
|
|
352
|
+
* @param option - The clicked option.
|
|
353
|
+
*/
|
|
354
|
+
select(option) {
|
|
355
|
+
if (!this.submittedState())
|
|
356
|
+
this.selectedState.set(option.id);
|
|
357
|
+
}
|
|
358
|
+
/** Validates the selection and fires onAnswer with the correctness flag. */
|
|
359
|
+
submit() {
|
|
360
|
+
const optionId = this.selectedState();
|
|
361
|
+
if (!optionId || this.submittedState())
|
|
362
|
+
return;
|
|
363
|
+
this.submittedState.set(true);
|
|
364
|
+
this.onAnswer?.(optionId, this.correctId ? optionId === this.correctId : undefined);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Reads whether the progress and explanation rows were projected, then
|
|
368
|
+
* withdraws each wrapper React would not render. View queries resolve only
|
|
369
|
+
* at view init.
|
|
370
|
+
*/
|
|
371
|
+
ngAfterViewInit() {
|
|
372
|
+
this.progressProjected = hasNodes(this.progressEl?.nativeElement);
|
|
373
|
+
this.explanationProjected = hasNodes(this.explanationEl?.nativeElement);
|
|
374
|
+
this.viewReady = true;
|
|
375
|
+
this.syncWrappers();
|
|
376
|
+
}
|
|
377
|
+
/** Re-reconciles the withdrawable wrappers when the state changes. */
|
|
378
|
+
ngDoCheck() {
|
|
379
|
+
if (this.viewReady)
|
|
380
|
+
this.syncWrappers();
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Applies React's conditions: the progress span renders only while progress
|
|
384
|
+
* is truthy, the explanation paragraph only after submit with one present.
|
|
385
|
+
*/
|
|
386
|
+
syncWrappers() {
|
|
387
|
+
this.sync.sync(this.progressEl?.nativeElement, this.hasProgress(), this.header?.nativeElement);
|
|
388
|
+
this.sync.sync(this.explanationEl?.nativeElement, this.submittedState() && this.hasExplanation(), this.stack?.nativeElement);
|
|
389
|
+
}
|
|
390
|
+
static ɵfac = function QuizCard_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || QuizCard)(); };
|
|
391
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: QuizCard, selectors: [["div", "mol-quiz-card", ""]], viewQuery: function QuizCard_Query(rf, ctx) { if (rf & 1) {
|
|
392
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5)(_c2, 5)(_c3, 5);
|
|
393
|
+
} if (rf & 2) {
|
|
394
|
+
let _t;
|
|
395
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.stack = _t.first);
|
|
396
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.header = _t.first);
|
|
397
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.progressEl = _t.first);
|
|
398
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.explanationEl = _t.first);
|
|
399
|
+
} }, hostVars: 2, hostBindings: function QuizCard_HostBindings(rf, ctx) { if (rf & 2) {
|
|
400
|
+
i0.ɵɵclassMap(ctx.cardClasses());
|
|
401
|
+
} }, inputs: { question: "question", options: "options", correctId: "correctId", onAnswer: "onAnswer", progress: "progress", timer: "timer", explanation: "explanation", className: "className" }, ngContentSelectors: _c5, decls: 25, vars: 21, consts: [["stack", ""], ["header", ""], ["progressEl", ""], ["explanationEl", ""], [3, "ngTemplateOutlet"], ["type", "button", "data-mol-id", "quiz-card-option", 3, "disabled", "class", "style"], ["mol-button", "", 3, "variant", "color", "disabled"], ["type", "button", "data-mol-id", "quiz-card-option", 3, "click", "disabled"], ["aria-hidden", "true"], ["mol-button", "", 3, "click", "variant", "color", "disabled"]], template: function QuizCard_Template(rf, ctx) { if (rf & 1) {
|
|
402
|
+
i0.ɵɵprojectionDef(_c4);
|
|
403
|
+
i0.ɵɵelementStart(0, "div", null, 0)(2, "header", null, 1)(4, "span", null, 2);
|
|
404
|
+
i0.ɵɵconditionalCreate(6, QuizCard_Conditional_6_Template, 2, 1, "ng-container");
|
|
405
|
+
i0.ɵɵelementContainer(7, 4);
|
|
406
|
+
i0.ɵɵprojection(8);
|
|
407
|
+
i0.ɵɵelementEnd();
|
|
408
|
+
i0.ɵɵconditionalCreate(9, QuizCard_Conditional_9_Template, 2, 1, "ng-container");
|
|
409
|
+
i0.ɵɵelementContainer(10, 4);
|
|
410
|
+
i0.ɵɵprojection(11, 1);
|
|
411
|
+
i0.ɵɵelementEnd();
|
|
412
|
+
i0.ɵɵelementStart(12, "h2");
|
|
413
|
+
i0.ɵɵconditionalCreate(13, QuizCard_Conditional_13_Template, 2, 1, "ng-container");
|
|
414
|
+
i0.ɵɵelementContainer(14, 4);
|
|
415
|
+
i0.ɵɵprojection(15, 2);
|
|
416
|
+
i0.ɵɵelementEnd();
|
|
417
|
+
i0.ɵɵelementStart(16, "div");
|
|
418
|
+
i0.ɵɵrepeaterCreate(17, QuizCard_For_18_Template, 6, 11, "button", 5, _forTrack0);
|
|
419
|
+
i0.ɵɵelementEnd();
|
|
420
|
+
i0.ɵɵconditionalCreate(19, QuizCard_Conditional_19_Template, 2, 4, "button", 6);
|
|
421
|
+
i0.ɵɵelementStart(20, "p", null, 3);
|
|
422
|
+
i0.ɵɵconditionalCreate(22, QuizCard_Conditional_22_Template, 2, 1, "ng-container");
|
|
423
|
+
i0.ɵɵelementContainer(23, 4);
|
|
424
|
+
i0.ɵɵprojection(24, 3);
|
|
425
|
+
i0.ɵɵelementEnd()();
|
|
426
|
+
} if (rf & 2) {
|
|
427
|
+
i0.ɵɵclassMap(ctx.stackClasses());
|
|
428
|
+
i0.ɵɵadvance(2);
|
|
429
|
+
i0.ɵɵclassMap(ctx.headerClasses());
|
|
430
|
+
i0.ɵɵadvance(2);
|
|
431
|
+
i0.ɵɵclassMap(ctx.progressClasses());
|
|
432
|
+
i0.ɵɵadvance(2);
|
|
433
|
+
i0.ɵɵconditional(ctx.isText(ctx.progress) ? 6 : -1);
|
|
434
|
+
i0.ɵɵadvance();
|
|
435
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx.templateOf(ctx.progress));
|
|
436
|
+
i0.ɵɵadvance(2);
|
|
437
|
+
i0.ɵɵconditional(ctx.isText(ctx.timer) ? 9 : -1);
|
|
438
|
+
i0.ɵɵadvance();
|
|
439
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx.templateOf(ctx.timer));
|
|
440
|
+
i0.ɵɵadvance(2);
|
|
441
|
+
i0.ɵɵclassMap(ctx.questionClasses());
|
|
442
|
+
i0.ɵɵadvance();
|
|
443
|
+
i0.ɵɵconditional(ctx.isText(ctx.question) ? 13 : -1);
|
|
444
|
+
i0.ɵɵadvance();
|
|
445
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx.templateOf(ctx.question));
|
|
446
|
+
i0.ɵɵadvance(2);
|
|
447
|
+
i0.ɵɵclassMap(ctx.optionsClasses());
|
|
448
|
+
i0.ɵɵadvance();
|
|
449
|
+
i0.ɵɵrepeater(ctx.options);
|
|
450
|
+
i0.ɵɵadvance(2);
|
|
451
|
+
i0.ɵɵconditional(!ctx.submitted() ? 19 : -1);
|
|
452
|
+
i0.ɵɵadvance();
|
|
453
|
+
i0.ɵɵclassMap(ctx.explanationClasses());
|
|
454
|
+
i0.ɵɵadvance(2);
|
|
455
|
+
i0.ɵɵconditional(ctx.isText(ctx.explanation) ? 22 : -1);
|
|
456
|
+
i0.ɵɵadvance();
|
|
457
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx.templateOf(ctx.explanation));
|
|
458
|
+
} }, dependencies: [Button, NgTemplateOutlet], encapsulation: 2 });
|
|
459
|
+
}
|
|
460
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(QuizCard, [{
|
|
461
|
+
type: Component,
|
|
462
|
+
args: [{
|
|
463
|
+
selector: 'div[mol-quiz-card]',
|
|
464
|
+
standalone: true,
|
|
465
|
+
imports: [Button, NgTemplateOutlet],
|
|
466
|
+
inputs: [
|
|
467
|
+
'question',
|
|
468
|
+
'options',
|
|
469
|
+
'correctId',
|
|
470
|
+
'onAnswer',
|
|
471
|
+
'progress',
|
|
472
|
+
'timer',
|
|
473
|
+
'explanation',
|
|
474
|
+
'className',
|
|
475
|
+
],
|
|
476
|
+
host: {
|
|
477
|
+
'[class]': 'cardClasses()',
|
|
478
|
+
},
|
|
479
|
+
// prettier-ignore
|
|
480
|
+
template: `<div #stack [class]="stackClasses()"><header #header [class]="headerClasses()"><span #progressEl [class]="progressClasses()">@if (isText(progress)) {<ng-container>{{ progress }}</ng-container>}<ng-container [ngTemplateOutlet]="templateOf(progress)"></ng-container><ng-content select="[slot=progress]"></ng-content></span>@if (isText(timer)) {<ng-container>{{ timer }}</ng-container>}<ng-container [ngTemplateOutlet]="templateOf(timer)"></ng-container><ng-content select="[slot=timer]"></ng-content></header><h2 [class]="questionClasses()">@if (isText(question)) {<ng-container>{{ question }}</ng-container>}<ng-container [ngTemplateOutlet]="templateOf(question)"></ng-container><ng-content select="[slot=question]"></ng-content></h2><div [class]="optionsClasses()">@for (option of options; track option.id) {<button type="button" (click)="select(option)" [disabled]="submitted()" [attr.aria-pressed]="isSelected(option) ? 'true' : 'false'" data-mol-id="quiz-card-option" [attr.data-correct]="isCorrect(option) ? 'true' : null" [attr.data-wrong]="isWrong(option) ? 'true' : null" [class]="optionClasses(option)" [style]="optionStyle(option)"><span>@if (isText(option.label)) {<ng-container>{{ option.label }}</ng-container>}@else {<ng-container [ngTemplateOutlet]="templateOf(option.label)"></ng-container>}</span>@if (isCorrect(option)) {<span aria-hidden="true">✓</span>}@if (isWrong(option)) {<span aria-hidden="true">×</span>}</button>}</div>@if (!submitted()) {<button mol-button [variant]="'solid'" [color]="'primary'" (click)="submit()" [disabled]="!selected()">{{ submitLabel() }}</button>}<p #explanationEl [class]="explanationClasses()">@if (isText(explanation)) {<ng-container>{{ explanation }}</ng-container>}<ng-container [ngTemplateOutlet]="templateOf(explanation)"></ng-container><ng-content select="[slot=explanation]"></ng-content></p></div>`,
|
|
481
|
+
}]
|
|
482
|
+
}], null, { stack: [{
|
|
483
|
+
type: ViewChild,
|
|
484
|
+
args: ['stack']
|
|
485
|
+
}], header: [{
|
|
486
|
+
type: ViewChild,
|
|
487
|
+
args: ['header']
|
|
488
|
+
}], progressEl: [{
|
|
489
|
+
type: ViewChild,
|
|
490
|
+
args: ['progressEl']
|
|
491
|
+
}], explanationEl: [{
|
|
492
|
+
type: ViewChild,
|
|
493
|
+
args: ['explanationEl']
|
|
494
|
+
}] }); })();
|
|
495
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(QuizCard, { className: "QuizCard", filePath: "quiz-card.component.ts", lineNumber: 62 }); })();
|
|
496
|
+
//# sourceMappingURL=quiz-card.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quiz-card.component.js","sourceRoot":"","sources":["../src/quiz-card.component.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAEL,SAAS,EAET,UAAU,EACV,MAAM,EACN,SAAS,EACT,MAAM,EACN,WAAW,EACX,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;;;;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BAAC,YAAY;;kBAEtB,SAAS;mBAAC,eAAe;;kFAzBf,QAAQ"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types of `@molecule/app-quiz-card-angular` — the Angular counterpart of
|
|
3
|
+
* `@molecule/app-quiz-card-react`, same props and DOM.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A single selectable answer option in a quiz question.
|
|
9
|
+
*
|
|
10
|
+
* `label` is a string (rendered as text) or an embedded template (a node
|
|
11
|
+
* input cannot travel through an Angular input, so callers pass nodes as
|
|
12
|
+
* templates where the framework supplies them).
|
|
13
|
+
*/
|
|
14
|
+
export interface QuizOption {
|
|
15
|
+
/** The option's identifier, used for selection and as the rendered key. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The option's label: a plain string, or a template rendering the nodes. */
|
|
18
|
+
label: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Props accepted by {@link QuizCard} — the same props
|
|
22
|
+
* `@molecule/app-quiz-card-react` accepts. Node props (`question`, `progress`,
|
|
23
|
+
* `timer`, `explanation`) are projected content in Angular (an input cannot
|
|
24
|
+
* carry a node), so they are typed `unknown`: pass them as
|
|
25
|
+
* `[slot=question]` / `[slot=progress]` / `[slot=timer]` /
|
|
26
|
+
* `[slot=explanation]` content, or as plain strings.
|
|
27
|
+
*/
|
|
28
|
+
export interface QuizCardProps {
|
|
29
|
+
/** The question text, projected as `[slot=question]` content or a string. */
|
|
30
|
+
question?: unknown;
|
|
31
|
+
/** Answer options. */
|
|
32
|
+
options: QuizOption[];
|
|
33
|
+
/** Id of the correct option — when provided, the component reveals correct/incorrect on submit. */
|
|
34
|
+
correctId?: string;
|
|
35
|
+
/** Called when the user submits an answer. */
|
|
36
|
+
onAnswer?: (optionId: string, correct?: boolean) => void;
|
|
37
|
+
/** Progress display — e.g. `2 / 10` — projected as `[slot=progress]` content or a string. */
|
|
38
|
+
progress?: unknown;
|
|
39
|
+
/** Optional countdown / timer node, projected as `[slot=timer]` content or a string. */
|
|
40
|
+
timer?: unknown;
|
|
41
|
+
/** Explanation shown after submit, projected as `[slot=explanation]` content or a string. */
|
|
42
|
+
explanation?: unknown;
|
|
43
|
+
/** Extra classes. */
|
|
44
|
+
className?: string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,EAAE,EAAE,MAAM,CAAA;IACV,6EAA6E;IAC7E,KAAK,EAAE,OAAO,CAAA;CACf;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sBAAsB;IACtB,OAAO,EAAE,UAAU,EAAE,CAAA;IACrB,mGAAmG;IACnG,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IACxD,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wFAAwF;IACxF,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,6FAA6F;IAC7F,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,71 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-quiz-card-angular",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1-stage",
|
|
4
|
+
"description": "Question card with multiple-choice options, progress, optional timer, correct/incorrect feedback",
|
|
5
|
+
"homepage": "https://www.molecule.dev/packages/app-quiz-card-angular",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "ngc",
|
|
21
|
+
"dev": "ngc --watch",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"molecule",
|
|
27
|
+
"quiz-card",
|
|
28
|
+
"angular"
|
|
29
|
+
],
|
|
30
|
+
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
35
|
+
"directory": "packages/app/features/quiz-card-angular"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=20"
|
|
39
|
+
},
|
|
40
|
+
"bugs": "https://github.com/molecule-dev/molecule/issues",
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@angular/common": "^22.0.0",
|
|
46
|
+
"@angular/core": "^22.0.0",
|
|
47
|
+
"@angular/platform-browser": "^22.0.0",
|
|
48
|
+
"@molecule/app-angular": "^3.5.0",
|
|
49
|
+
"@molecule/app-ui": "^1.0.1",
|
|
50
|
+
"@molecule/app-ui-angular": "^1.1.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@angular/common": "22.2.3",
|
|
54
|
+
"@angular/compiler": "22.2.3",
|
|
55
|
+
"@angular/compiler-cli": "22.2.3",
|
|
56
|
+
"@angular/core": "22.2.3",
|
|
57
|
+
"@angular/platform-browser": "22.2.3",
|
|
58
|
+
"@molecule/app-angular": "3.6.0",
|
|
59
|
+
"@molecule/app-framework-conformance": "0.0.0",
|
|
60
|
+
"@molecule/app-i18n": "1.2.1",
|
|
61
|
+
"@molecule/app-icons": "1.0.4",
|
|
62
|
+
"@molecule/app-ui": "1.3.11",
|
|
63
|
+
"@molecule/app-ui-angular": "1.1.2",
|
|
64
|
+
"@types/node": "26.6.5",
|
|
65
|
+
"jsdom": "30.1.3",
|
|
66
|
+
"rxjs": "7.8.2",
|
|
67
|
+
"typescript": "6.0.3",
|
|
68
|
+
"vitest": "4.1.12",
|
|
69
|
+
"zone.js": "0.16.3"
|
|
70
|
+
}
|
|
71
|
+
}
|