@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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Angular quiz / multiple-choice question card — the counterpart of
3
+ * `@molecule/app-quiz-card-react`: the same props and the same DOM for the
4
+ * same input.
5
+ *
6
+ * Exports `<QuizCard>` and the `QuizOption` type.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import { Component } from '@angular/core'
11
+ * import { QuizCard } from '@molecule/app-quiz-card-angular'
12
+ *
13
+ * @Component({
14
+ * selector: 'app-question',
15
+ * standalone: true,
16
+ * imports: [QuizCard],
17
+ * template: `
18
+ * <div mol-quiz-card [progress]="'1 / 10'" [correctId]="'b'" [onAnswer]="onAnswer">
19
+ * <span slot="question">What is the capital of France?</span>
20
+ * <span slot="explanation">Paris has been the capital of France since 987 AD.</span>
21
+ * </div>
22
+ * `,
23
+ * })
24
+ * export class Question {
25
+ * options = [
26
+ * { id: 'a', label: 'London' },
27
+ * { id: 'b', label: 'Paris' },
28
+ * { id: 'c', label: 'Berlin' },
29
+ * ]
30
+ *
31
+ * onAnswer(id: string, correct?: boolean): void {
32
+ * console.log(id, correct)
33
+ * }
34
+ * }
35
+ * ```
36
+ *
37
+ * @remarks
38
+ * Companion locale bond: `@molecule/app-locales-quiz-card` (`quizCard.submit`).
39
+ * The card is single-shot: after submit the options lock and the explanation
40
+ * replaces the button — there is no reset prop, so advance quizzes by
41
+ * remounting with a fresh `key` per question. Without `correctId` no
42
+ * correct/incorrect state is revealed and `onAnswer`'s second argument is
43
+ * `undefined`. Requires the app-angular i18n provider and a wired ClassMap
44
+ * bond.
45
+ *
46
+ * The host element is the card surface itself (`div[mol-quiz-card]`), carrying
47
+ * the `Card` classes React renders. The node-valued `question`, `progress`,
48
+ * `timer` and `explanation` props are projected content
49
+ * (`[slot=question]`, `[slot=progress]`, `[slot=timer]`,
50
+ * `[slot=explanation]`) or plain strings.
51
+ *
52
+ * @module
53
+ */
54
+ export * from './quiz-card.component.js';
55
+ export * from './types.js';
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,cAAc,0BAA0B,CAAA;AACxC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,192 @@
1
+ import { type AfterViewInit, type DoCheck, TemplateRef } from '@angular/core';
2
+ import type { UIClassMap } from '@molecule/app-ui';
3
+ import type { QuizOption } from './types.js';
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * QuizCard component.
7
+ *
8
+ * Single quiz question card with multiple-choice options. The host IS React's
9
+ * root `<div>` (`div[mol-quiz-card]`), carrying the `Card` classes exactly as
10
+ * React's `Card` does. Tracks its own submit state and reveals
11
+ * correct/incorrect when `correctId` is provided.
12
+ *
13
+ * The node-valued `question`, `progress`, `timer` and `explanation` props
14
+ * arrive as projected content (`[slot=question]`, `[slot=progress]`,
15
+ * `[slot=timer]`, `[slot=explanation]`), as embedded templates, or as plain
16
+ * string inputs. A wrapper React would not render at all (the progress span,
17
+ * the explanation paragraph) is detached from the DOM, keeping its capture
18
+ * point for the projected nodes.
19
+ */
20
+ export declare class QuizCard implements AfterViewInit, DoCheck {
21
+ /** The question text — a string input, or `[slot=question]` projected content. */
22
+ question?: unknown;
23
+ /** The answer options, rendered in order and keyed by `id`. */
24
+ options: QuizOption[];
25
+ /** Id of the correct option — when provided, submit reveals correct/incorrect. */
26
+ correctId?: string;
27
+ /** Called when the user submits an answer. */
28
+ onAnswer?: (optionId: string, correct?: boolean) => void;
29
+ /** Progress display — a string input, a template, or `[slot=progress]` content. */
30
+ progress?: unknown;
31
+ /** Optional countdown / timer — a string input, a template, or `[slot=timer]` content. */
32
+ timer?: unknown;
33
+ /** Explanation shown after submit — a string input, a template, or `[slot=explanation]` content. */
34
+ explanation?: unknown;
35
+ /** Extra classes on the card. */
36
+ className?: string;
37
+ /** The inner stack (the parent of the explanation paragraph). */
38
+ private stack?;
39
+ /** The header (the parent of the progress span). */
40
+ private header?;
41
+ /** The progress span (always in the template; detached when empty). */
42
+ private progressEl?;
43
+ /** The explanation paragraph (always in the template; detached when React renders none). */
44
+ private explanationEl?;
45
+ /** The i18n provider above the card (the submit label). */
46
+ private readonly i18n;
47
+ /** The selected option id. */
48
+ private readonly selectedState;
49
+ /** Whether the answer was submitted (the card is single-shot). */
50
+ private readonly submittedState;
51
+ /** Detaches and re-attaches the wrappers React renders conditionally. */
52
+ private readonly sync;
53
+ /** Whether a `[slot=progress]` projection landed. */
54
+ private progressProjected;
55
+ /** Whether a `[slot=explanation]` projection landed. */
56
+ private explanationProjected;
57
+ /** Whether the view queries have been read (nothing is withdrawn before). */
58
+ private viewReady;
59
+ /**
60
+ * The current class map.
61
+ * @returns The UIClassMap.
62
+ */
63
+ cm(): UIClassMap;
64
+ /**
65
+ * Computes the card class list — React's `Card` with the default `elevated`
66
+ * variant and `md` padding, plus `className`.
67
+ * @returns The class string.
68
+ */
69
+ cardClasses(): string;
70
+ /**
71
+ * The outer stack class list.
72
+ * @returns The class string.
73
+ */
74
+ stackClasses(): string;
75
+ /**
76
+ * The header class list.
77
+ * @returns The class string.
78
+ */
79
+ headerClasses(): string;
80
+ /**
81
+ * The progress row class list.
82
+ * @returns The class string.
83
+ */
84
+ progressClasses(): string;
85
+ /**
86
+ * The question class list.
87
+ * @returns The class string.
88
+ */
89
+ questionClasses(): string;
90
+ /**
91
+ * The options container class list.
92
+ * @returns The class string.
93
+ */
94
+ optionsClasses(): string;
95
+ /**
96
+ * The explanation class list.
97
+ * @returns The class string.
98
+ */
99
+ explanationClasses(): string;
100
+ /**
101
+ * One answer button's class list (React's weight switch on selection).
102
+ * @param option - The option rendered.
103
+ * @returns The class string.
104
+ */
105
+ optionClasses(option: QuizOption): string;
106
+ /**
107
+ * One answer button's inline style — React's verdict colours and touch
108
+ * radius, exactly (no background declared unless a verdict shows).
109
+ * @param option - The option rendered.
110
+ * @returns The CSS text.
111
+ */
112
+ optionStyle(option: QuizOption): string;
113
+ /**
114
+ * Whether an option is the current selection.
115
+ * @param option - The option rendered.
116
+ * @returns True when selected.
117
+ */
118
+ isSelected(option: QuizOption): boolean;
119
+ /**
120
+ * React's `isCorrect`: the verdict shows only after submit, when a correct
121
+ * id is set and this option is it.
122
+ * @param option - The option rendered.
123
+ * @returns True when the option is the revealed correct answer.
124
+ */
125
+ isCorrect(option: QuizOption): boolean;
126
+ /**
127
+ * React's `isWrong`: the selected option after submit is not the correct one.
128
+ * @param option - The option rendered.
129
+ * @returns True when the option is the revealed wrong answer.
130
+ */
131
+ isWrong(option: QuizOption): boolean;
132
+ /**
133
+ * Whether the answer was submitted.
134
+ * @returns True after submit.
135
+ */
136
+ submitted(): boolean;
137
+ /**
138
+ * The selected option id, if any.
139
+ * @returns The id, or null.
140
+ */
141
+ selected(): string | null;
142
+ /**
143
+ * Whether a value is plain text (React renders it as text, not as nodes).
144
+ * @param value - A label, question or slot value.
145
+ * @returns True when the value is a string.
146
+ */
147
+ isText(value: unknown): value is string;
148
+ /**
149
+ * Narrows a value to an embedded template.
150
+ * @param value - A label, question or slot value.
151
+ * @returns The template, or null.
152
+ */
153
+ templateOf(value: unknown): TemplateRef<unknown> | null;
154
+ /**
155
+ * Whether the progress row renders at all — React's `{progress && …}`.
156
+ * @returns True when a text, template or projected progress row exists.
157
+ */
158
+ hasProgress(): boolean;
159
+ /**
160
+ * Whether the explanation renders — React's `explanation && <p>`.
161
+ * @returns True when a text, template or projected explanation exists.
162
+ */
163
+ hasExplanation(): boolean;
164
+ /**
165
+ * The submit button's label.
166
+ * @returns The translated text.
167
+ */
168
+ submitLabel(): string;
169
+ /**
170
+ * Selects an option (React ignores the click after submit).
171
+ * @param option - The clicked option.
172
+ */
173
+ select(option: QuizOption): void;
174
+ /** Validates the selection and fires onAnswer with the correctness flag. */
175
+ submit(): void;
176
+ /**
177
+ * Reads whether the progress and explanation rows were projected, then
178
+ * withdraws each wrapper React would not render. View queries resolve only
179
+ * at view init.
180
+ */
181
+ ngAfterViewInit(): void;
182
+ /** Re-reconciles the withdrawable wrappers when the state changes. */
183
+ ngDoCheck(): void;
184
+ /**
185
+ * Applies React's conditions: the progress span renders only while progress
186
+ * is truthy, the explanation paragraph only after submit with one present.
187
+ */
188
+ private syncWrappers;
189
+ static ɵfac: i0.ɵɵFactoryDeclaration<QuizCard, never>;
190
+ static ɵcmp: i0.ɵɵComponentDeclaration<QuizCard, "div[mol-quiz-card]", never, { "question": { "alias": "question"; "required": false; }; "options": { "alias": "options"; "required": false; }; "correctId": { "alias": "correctId"; "required": false; }; "onAnswer": { "alias": "onAnswer"; "required": false; }; "progress": { "alias": "progress"; "required": false; }; "timer": { "alias": "timer"; "required": false; }; "explanation": { "alias": "explanation"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, ["[slot=progress]", "[slot=timer]", "[slot=question]", "[slot=explanation]"], true, never>;
191
+ }
192
+ //# sourceMappingURL=quiz-card.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quiz-card.component.d.ts","sourceRoot":"","sources":["../src/quiz-card.component.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,OAAO,EAKZ,WAAW,EAEZ,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAIlD,OAAO,KAAK,EAAE,UAAU,EAAE,MAA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