@qaiddev/quests-embed 1.6.0 → 1.7.0

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 CHANGED
@@ -252,7 +252,7 @@ For programmatic embedding — e.g. launching a quest from another widget — th
252
252
 
253
253
  | Option | Type | Default | Description |
254
254
  |--------|------|---------|-------------|
255
- | `metadata` | `Record<string, unknown>` | — | Extra key/value pairs sent verbatim in the create-response `POST` body. The server decides which keys it persists; unknown keys are ignored. Used, for example, by `@qaiddev/thumbs-embed` to pass `{ feedbackId }` so the QAid backend joins the quest answers to the feedback record. |
255
+ | `metadata` | `Record<string, unknown>` or a `Promise` of one | — | Extra key/value pairs sent verbatim in the create-response `POST` body. The server decides which keys it persists; unknown keys are ignored. Used, for example, by `@qaiddev/thumbs-embed` to pass `{ feedbackId }` so the QAid backend joins the quest answers to the feedback record. A promise lets you open the quest before you have the ids: the form shows at once and only the create-response call waits for it. Check `QaidQuests.supports.asyncMetadata` first if you load the widget at runtime. |
256
256
  | `onComplete` | `(answers) => void` | — | Called once when the quest is completed and the server accepted the submit (just after the thank-you screen renders), with a copy of the submitted answers — answers to questions hidden by `visibleIf` are left out. Not called while the submit is failing. Fires in both modal and inline modes. |
257
257
  | `onClose` | `() => void` | — | Called once when the embed is torn down — visitor close, host `destroy()`, or teardown after completion. Lets a host that launched the quest drop its reference. |
258
258
 
package/dist/embed.d.ts CHANGED
@@ -10,6 +10,13 @@ import type { Answers, Questionnaire, QuestsConfig } from "./types";
10
10
  */
11
11
  export declare function randomId(): string;
12
12
  export declare class QaidQuests {
13
+ /**
14
+ * What this build accepts, for hosts that load it at runtime and may get
15
+ * an older copy. asyncMetadata: `metadata` may be a promise.
16
+ */
17
+ static readonly supports: {
18
+ readonly asyncMetadata: true;
19
+ };
13
20
  private config;
14
21
  private questionnaire;
15
22
  private inlineQuestionnaire;
@@ -45,6 +52,7 @@ export declare class QaidQuests {
45
52
  private scrollCueEl;
46
53
  private overflow;
47
54
  private footerEl;
55
+ private primaryBtn;
48
56
  private savingEl;
49
57
  private backdropEl;
50
58
  private currentInput;
@@ -96,6 +104,15 @@ export declare class QaidQuests {
96
104
  private advance;
97
105
  private back;
98
106
  private recomputeVisible;
107
+ /**
108
+ * Label the step's primary button for what pressing it will do: "Submit"
109
+ * when no question after this one is visible under the current answers,
110
+ * "Next" otherwise. Uses the same test as `advance()`, so the two cannot
111
+ * disagree. Called on draw AND on every answer, because an answer can
112
+ * reveal a follow-up (Submit → Next) or hide the last one (Next → Submit).
113
+ * Edits the one button in place — no redraw, so focus and typed text stay.
114
+ */
115
+ private syncPrimaryLabel;
99
116
  private handleAnswerChange;
100
117
  private flushPendingSave;
101
118
  private saveAnswer;