@qaiddev/quests-embed 1.5.0 → 1.5.3
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 +12 -6
- package/dist/embed.d.ts +24 -0
- package/dist/index.d.ts +1 -1
- package/dist/qaid-quests.js +308 -206
- package/dist/qaid-quests.js.map +1 -1
- package/dist/qaid-quests.umd.cjs +3 -3
- package/dist/qaid-quests.umd.cjs.map +1 -1
- package/dist/types.d.ts +20 -6
- package/dist/visibility.d.ts +16 -4
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Composition: `allOf` / `anyOf` accept arrays of nested rules.
|
|
11
11
|
* Atom forms target a single prior question via `questionId`.
|
|
12
|
+
*
|
|
13
|
+
* A question that is itself hidden counts as unanswered, whatever the
|
|
14
|
+
* visitor typed into it before it was hidden, so follow-ups chained on
|
|
15
|
+
* it hide too.
|
|
12
16
|
*/
|
|
13
17
|
export type VisibilityRule = {
|
|
14
18
|
allOf: VisibilityRule[];
|
|
@@ -191,9 +195,14 @@ export interface QuestsConfig {
|
|
|
191
195
|
fontSize?: number;
|
|
192
196
|
/** Custom CSS injected into the shadow root for theming */
|
|
193
197
|
css?: string;
|
|
194
|
-
/**
|
|
198
|
+
/**
|
|
199
|
+
* When true, picking an option on a single-choice multiple-choice
|
|
200
|
+
* question advances to the next step. No other question type
|
|
201
|
+
* auto-advances (multi-select, text, currency, range and date all wait
|
|
202
|
+
* for Next / Enter). Default: false
|
|
203
|
+
*/
|
|
195
204
|
autoAdvance?: boolean;
|
|
196
|
-
/** Debounce in ms for autosave on text/currency. Default: 500 */
|
|
205
|
+
/** Debounce in ms for autosave on text/currency/range. Default: 500 */
|
|
197
206
|
saveDebounceMs?: number;
|
|
198
207
|
/** Auto-focus the input on each step. Default: true. Set false in preview/embedded contexts that shouldn't steal focus. */
|
|
199
208
|
autoFocus?: boolean;
|
|
@@ -264,9 +273,11 @@ export interface QuestsConfig {
|
|
|
264
273
|
*/
|
|
265
274
|
metadata?: Record<string, unknown>;
|
|
266
275
|
/**
|
|
267
|
-
* Called once when the quest is completed and
|
|
268
|
-
* the final "thank you" screen renders). Receives
|
|
269
|
-
*
|
|
276
|
+
* Called once when the quest is completed and the server accepted the
|
|
277
|
+
* submit (right after the final "thank you" screen renders). Receives
|
|
278
|
+
* a copy of the submitted answers — answers to questions hidden by
|
|
279
|
+
* `visibleIf` are left out. Not called while the submit is failing.
|
|
280
|
+
* Fired in both modal and inline modes.
|
|
270
281
|
*/
|
|
271
282
|
onComplete?: (answers: Answers) => void;
|
|
272
283
|
/**
|
|
@@ -339,7 +350,10 @@ export interface UpdateAnswerPayload {
|
|
|
339
350
|
questionId: string;
|
|
340
351
|
value: AnswerValue;
|
|
341
352
|
}
|
|
342
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* Sent when the form is submitted. `answers` holds only the questions
|
|
355
|
+
* visible at submit time; a hidden question's answer is left out.
|
|
356
|
+
*/
|
|
343
357
|
export interface SubmitPayload {
|
|
344
358
|
answers: Answers;
|
|
345
359
|
}
|
package/dist/visibility.d.ts
CHANGED
|
@@ -5,11 +5,23 @@
|
|
|
5
5
|
* to those whose `visibleIf` predicate currently evaluates to true. A
|
|
6
6
|
* question with no `visibleIf` is always visible.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Visibility resolves in question order. A predicate only sees the
|
|
9
|
+
* answers of questions that are themselves visible at that point, so a
|
|
10
|
+
* hidden question reads as unanswered — even if the visitor answered it
|
|
11
|
+
* before it was hidden — and a chain of follow-ups collapses behind it.
|
|
12
|
+
* The same rule makes a reference to a LATER question (which the
|
|
13
|
+
* dashboard validator rejects anyway) read as unanswered.
|
|
14
|
+
*
|
|
15
|
+
* Predicates never throw — a predicate referencing an unknown
|
|
16
|
+
* questionId resolves as if that question is unanswered.
|
|
12
17
|
*/
|
|
13
18
|
import type { Answers, Question, Questionnaire, VisibilityRule } from "./types";
|
|
14
19
|
export declare function getVisibleQuestions(q: Questionnaire, answers: Answers): Question[];
|
|
20
|
+
/**
|
|
21
|
+
* The subset of `answers` that belongs to currently visible questions —
|
|
22
|
+
* what the embed submits. An answer given to a question that was later
|
|
23
|
+
* hidden (the visitor went back and changed the gating answer) is left
|
|
24
|
+
* out, as are answers keyed by ids the questionnaire has no question for.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getVisibleAnswers(q: Questionnaire, answers: Answers): Answers;
|
|
15
27
|
export declare function evaluateRule(rule: VisibilityRule, answers: Answers): boolean;
|