@qaiddev/quests-embed 1.5.3 → 1.6.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 +28 -8
- package/dist/bootstrap.d.ts +20 -0
- package/dist/qaid-quests.js +190 -124
- 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/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,7 +248,7 @@ We offer a Free Plan that hosts both the endpoint and a dashboard for managing y
|
|
|
248
248
|
|
|
249
249
|
### Host integration
|
|
250
250
|
|
|
251
|
-
For programmatic embedding — e.g. launching a quest from another widget — these hooks let the host pass correlation data in and react to the quest's lifecycle.
|
|
251
|
+
For programmatic embedding — e.g. launching a quest from another widget — these hooks let the host pass correlation data in and react to the quest's lifecycle. `metadata` can also be set on the `<script>` tag as `data-metadata`; the two callbacks are functions, so they need you to construct `QaidQuests` yourself.
|
|
252
252
|
|
|
253
253
|
| Option | Type | Default | Description |
|
|
254
254
|
|--------|------|---------|-------------|
|
|
@@ -297,25 +297,45 @@ Colors accept hex (`#ABC`, `#AABBCC`) or `rgb(r, g, b)` format. The text color u
|
|
|
297
297
|
|
|
298
298
|
## Script Tag Data Attributes
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
Every config option except the two callbacks (`onComplete`, `onClose`) has a `data-*` attribute, so the script tag alone can set anything else. If a JSON config block is also on the page, the block wins and the attributes are not read.
|
|
301
|
+
|
|
302
|
+
Object options take JSON. In HTML, wrap the value in single quotes so the JSON's double quotes survive: `data-metadata='{"feedbackId":"clx1"}'`.
|
|
301
303
|
|
|
302
304
|
| Attribute | Maps To |
|
|
303
305
|
|-----------|---------|
|
|
304
|
-
| `data-endpoint` | `endpoint` |
|
|
305
|
-
| `data-config-url` | `configUrl` |
|
|
306
|
+
| `data-endpoint` | `endpoint` (required) |
|
|
306
307
|
| `data-api-key` | `apiKey` |
|
|
308
|
+
| `data-questionnaire` | `questionnaire`: the questionnaire as JSON, with a `questions` array. Starts the quest without `data-config-url` |
|
|
309
|
+
| `data-config-url` | `configUrl` |
|
|
307
310
|
| `data-container` | `container` |
|
|
308
311
|
| `data-zindex` | `zIndex` |
|
|
309
|
-
| `data-
|
|
310
|
-
| `data-
|
|
311
|
-
| `data-
|
|
312
|
+
| `data-accent-color` | `colors.accent` |
|
|
313
|
+
| `data-error-color` | `colors.error` |
|
|
314
|
+
| `data-focus-color` | `colors.focus` |
|
|
315
|
+
| `data-positive-color` | `colors.positive` (deprecated alias for `colors.accent`) |
|
|
316
|
+
| `data-negative-color` | `colors.negative` (deprecated alias for `colors.error`) |
|
|
317
|
+
| `data-marker-color` | `colors.marker` (deprecated alias for `colors.focus`) |
|
|
312
318
|
| `data-modal-width` | `modalWidth` |
|
|
313
319
|
| `data-backdrop-opacity` | `backdropOpacity` |
|
|
314
320
|
| `data-font-family` | `fontFamily` |
|
|
315
321
|
| `data-font-size` | `fontSize` |
|
|
322
|
+
| `data-css` | `css` (wins over `data-css-selector`) |
|
|
323
|
+
| `data-css-selector` | `css`, taken from the `textContent` of the element this selector matches |
|
|
316
324
|
| `data-auto-advance` | `autoAdvance` (`"true"` to enable) |
|
|
317
325
|
| `data-save-debounce-ms` | `saveDebounceMs` |
|
|
318
|
-
| `data-
|
|
326
|
+
| `data-auto-focus` | `autoFocus` (`"true"` or `"false"`) |
|
|
327
|
+
| `data-animate` | `animate` (`"true"` or `"false"`) |
|
|
328
|
+
| `data-progress-position` | `progressPosition` (`"top"` or `"bottom"`) |
|
|
329
|
+
| `data-theme` | `theme` (`"light"`, `"dark"` or `"auto"`) |
|
|
330
|
+
| `data-unstyled` | `unstyled` (`"true"` to enable) |
|
|
331
|
+
| `data-preset` | `preset` (`"default"`, `"minimal"`, `"pill"` or `"dense"`) |
|
|
332
|
+
| `data-theme-url` | `themeUrl` |
|
|
333
|
+
| `data-theme-document` | `themeDocument`, as a JSON object |
|
|
334
|
+
| `data-metadata` | `metadata`, as a JSON object |
|
|
335
|
+
|
|
336
|
+
`onComplete` and `onClose` are functions, so they can only be passed from code (`new QaidQuests({ ... })`).
|
|
337
|
+
|
|
338
|
+
A value the embed can't use (malformed JSON, a questionnaire with no `questions` array, `data-auto-focus="yes"`, an unknown `data-progress-position`) is ignored with one `console.warn` naming the attribute, and the default stays.
|
|
319
339
|
|
|
320
340
|
## Modal vs. Inline
|
|
321
341
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading config from the page for the script-tag install: the JSON config
|
|
3
|
+
* block and the embed's own `data-*` attributes.
|
|
4
|
+
*
|
|
5
|
+
* Kept out of `index.ts` so it can be tested: `index.ts` runs auto-init as a
|
|
6
|
+
* side effect of being imported and is excluded from coverage. Not re-exported
|
|
7
|
+
* from `index.ts`, so none of this is public API.
|
|
8
|
+
*/
|
|
9
|
+
import type { QuestsConfig } from "./types";
|
|
10
|
+
/**
|
|
11
|
+
* Config from `<script type="application/json" data-quests-config>`.
|
|
12
|
+
* When present and valid it wins outright; the attributes are not read.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseJsonConfig(): Partial<QuestsConfig> | null;
|
|
15
|
+
/**
|
|
16
|
+
* Config from the embed's own `data-*` attributes. Every option that can be
|
|
17
|
+
* written as text has one; only the `onComplete` / `onClose` callbacks need
|
|
18
|
+
* code.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseDataAttributes(script: HTMLScriptElement): Partial<QuestsConfig> | null;
|