@qti-components/test 2.0.0-next.8 → 2.0.0-next.9

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.
Files changed (28) hide show
  1. package/dist/components/qti-test/getting-started.fixtures.d.ts +6 -0
  2. package/dist/components/qti-test/getting-started.fixtures.js +7 -0
  3. package/dist/components/qti-test/getting-started.fixtures.js.map +1 -0
  4. package/dist/components/styles.d.ts +8 -1
  5. package/dist/components/styles.js +63 -14
  6. package/dist/components/styles.js.map +1 -1
  7. package/dist/components/test-bookmark/test-bookmark.js +7 -2
  8. package/dist/components/test-bookmark/test-bookmark.js.map +1 -1
  9. package/dist/components/test-check-item/test-check-item.js +7 -2
  10. package/dist/components/test-check-item/test-check-item.js.map +1 -1
  11. package/dist/components/test-end-attempt/test-end-attempt.js +7 -2
  12. package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
  13. package/dist/components/test-item-link/test-item-link.js +7 -2
  14. package/dist/components/test-item-link/test-item-link.js.map +1 -1
  15. package/dist/components/test-next/test-next.js +8 -2
  16. package/dist/components/test-next/test-next.js.map +1 -1
  17. package/dist/components/test-prev/test-prev.js +7 -2
  18. package/dist/components/test-prev/test-prev.js.map +1 -1
  19. package/dist/components/test-section-link/test-section-link.js +7 -2
  20. package/dist/components/test-section-link/test-section-link.js.map +1 -1
  21. package/dist/components/test-stamp/test-stamp.d.ts +3 -2
  22. package/dist/components/test-stamp/test-stamp.js +3 -2
  23. package/dist/components/test-stamp/test-stamp.js.map +1 -1
  24. package/dist/components/test-submit/test-submit.js +7 -2
  25. package/dist/components/test-submit/test-submit.js.map +1 -1
  26. package/dist/tts/test-item-to-speech.js +22 -7
  27. package/dist/tts/test-item-to-speech.js.map +1 -1
  28. package/package.json +3 -3
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,
3
+ * named after the page; a docs page or story that needs a test of its own gets a folder of its own
4
+ * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.
5
+ */
6
+ export declare const GETTING_STARTED_TEST = "/assets/docs/getting-started/assessment.xml";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,
3
+ * named after the page; a docs page or story that needs a test of its own gets a folder of its own
4
+ * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.
5
+ */
6
+ export const GETTING_STARTED_TEST = '/assets/docs/getting-started/assessment.xml';
7
+ //# sourceMappingURL=getting-started.fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getting-started.fixtures.js","sourceRoot":"","sources":["../../../src/components/qti-test/getting-started.fixtures.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,6CAA6C,CAAC","sourcesContent":["/**\n * The test behind the Getting started page. Its files live in `public/assets/docs/getting-started/`,\n * named after the page; a docs page or story that needs a test of its own gets a folder of its own\n * under `public/assets/docs/` and a `*.fixtures.ts` next to it, so the file and its user stay together.\n */\nexport const GETTING_STARTED_TEST = '/assets/docs/getting-started/assessment.xml';\n"]}
@@ -1,7 +1,14 @@
1
1
  export declare const form: import("lit").CSSResult;
2
2
  export declare const btn: import("lit").CSSResult;
3
- /** Hover and keyboard focus; paint only, so the box never moves. */
3
+ /** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
4
+ export declare const btnPrimary: import("lit").CSSResult;
5
+ /** Hover; paint only, so the box never moves. */
4
6
  export declare const btnInteractive: import("lit").CSSResult;
7
+ export declare const btnPrimaryInteractive: import("lit").CSSResult;
8
+ /** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */
9
+ export declare const btnActive: import("lit").CSSResult;
10
+ export declare const btnPrimaryActive: import("lit").CSSResult;
11
+ /** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */
5
12
  export declare const focusRing: import("lit").CSSResult;
6
13
  export declare const dis: import("lit").CSSResult;
7
14
  export declare const ind: import("lit").CSSResult;
@@ -3,11 +3,31 @@ import { css } from 'lit';
3
3
  /*
4
4
  * The resting look of the test controls (next, prev, item/section links, TTS buttons).
5
5
  *
6
- * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test
7
- * chrome along with the items; every token has a literal fallback equal to the theme's own
8
- * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot
9
- * in front of each token repaints the test controls alone.
6
+ * Two looks, both plain: a neutral one (the page's surface, the theme's border, the surrounding text
7
+ * colour) and a filled one that `test-next` wears, in the theme's neutral colour with its content
8
+ * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host
9
+ * repaints them.
10
+ *
11
+ * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme), with a CSS system colour behind
12
+ * it for a page that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the
13
+ * controls stay legible in dark mode without the theme too. Hover and press mix the content colour
14
+ * into the fill, by --qti-hover-mix and --qti-active-mix.
15
+ *
16
+ * Paint comes from the `--test-button-*` slots, which repaint the test controls alone, and never
17
+ * from the shared `--qti-component-*` tokens: those also paint the items' own borders, and a change
18
+ * to how a button looks must not move an interaction.
19
+ *
20
+ * --test-button-background-color, --test-button-color, --test-button-border-color,
21
+ * --test-button-hover-background-color, --test-button-active-background-color
22
+ * the neutral look, and the filled look's slots
23
+ * --test-button-primary-background-color, --test-button-primary-color,
24
+ * --test-button-primary-hover-background-color, --test-button-primary-active-background-color
25
+ * the filled look only
10
26
  */
27
+ const surface = css `var(--qti-color-base-100, var(--cito-color-base-100, Canvas))`;
28
+ const content = css `var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;
29
+ const neutral = css `var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;
30
+ const neutralContent = css `var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;
11
31
  export const form = css `
12
32
  display: inline-flex;
13
33
  align-items: center;
@@ -20,22 +40,51 @@ export const form = css `
20
40
  line-height: 1.25;
21
41
  cursor: pointer;
22
42
  user-select: none;
23
- border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));
43
+ border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));
24
44
  `;
25
45
  export const btn = css `
26
46
  ${form};
27
- background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));
28
- color: var(--test-button-color, var(--qti-component-color, inherit));
29
- border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)
30
- var(--test-button-border-color, var(--qti-component-border-color, #0175aa));
47
+ background-color: var(--test-button-background-color, ${surface});
48
+ color: var(--test-button-color, inherit);
49
+ border: var(--qti-border-width, var(--cito-border-width, 1px)) solid
50
+ var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));
51
+ `;
52
+ /** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */
53
+ export const btnPrimary = css `
54
+ background-color: var(--test-button-primary-background-color, ${neutral});
55
+ color: var(--test-button-primary-color, ${neutralContent});
56
+ border-color: var(--test-button-primary-background-color, ${neutral});
31
57
  `;
32
- /** Hover and keyboard focus; paint only, so the box never moves. */
58
+ /** Hover; paint only, so the box never moves. */
33
59
  export const btnInteractive = css `
34
- background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));
60
+ background-color: var(
61
+ --test-button-hover-background-color,
62
+ color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))
63
+ );
64
+ `;
65
+ export const btnPrimaryInteractive = css `
66
+ background-color: var(
67
+ --test-button-primary-hover-background-color,
68
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
69
+ );
70
+ `;
71
+ /** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */
72
+ export const btnActive = css `
73
+ background-color: var(
74
+ --test-button-active-background-color,
75
+ color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))
76
+ );
77
+ `;
78
+ export const btnPrimaryActive = css `
79
+ background-color: var(
80
+ --test-button-primary-active-background-color,
81
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
82
+ );
35
83
  `;
84
+ /** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */
36
85
  export const focusRing = css `
37
- outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);
38
- outline-offset: 2px;
86
+ outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);
87
+ outline-offset: var(--qti-focus-offset, 2px);
39
88
  `;
40
89
  export const dis = css `
41
90
  cursor: not-allowed;
@@ -43,6 +92,6 @@ export const dis = css `
43
92
  `;
44
93
  export const ind = css `
45
94
  ${form};
46
- border: 1px solid gray;
95
+ border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);
47
96
  `;
48
97
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAatB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;;;;CAKP,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;CAEhC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;;;CAGrB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;CAEP,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Paint reads the qti-theme tokens, so a theme or brand that re-values them repaints the test\n * chrome along with the items; every token has a literal fallback equal to the theme's own\n * default, so the controls look the same without qti-theme loaded. A `--test-button-*` slot\n * in front of each token repaints the test controls alone.\n */\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-component-border-radius, 0.2rem));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, var(--qti-component-background-color, #fff));\n color: var(--test-button-color, var(--qti-component-color, inherit));\n border: var(--qti-component-border-width, 1px) var(--qti-component-border-style, solid)\n var(--test-button-border-color, var(--qti-component-border-color, #0175aa));\n`;\n\n/** Hover and keyboard focus; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(--test-button-hover-background-color, var(--qti-bg-active, #f2f8fb));\n`;\n\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, #007ac3);\n outline-offset: 2px;\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: 1px solid gray;\n`;\n"]}
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/components/styles.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,OAAO,GAAG,GAAG,CAAA,+DAA+D,CAAC;AACnF,MAAM,OAAO,GAAG,GAAG,CAAA,2EAA2E,CAAC;AAC/F,MAAM,OAAO,GAAG,GAAG,CAAA,iEAAiE,CAAC;AACrF,MAAM,cAAc,GAAG,GAAG,CAAA,6EAA6E,CAAC;AAExG,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAA;;;;;;;;;;;;;CAatB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;0DACkD,OAAO;;;kFAGiB,OAAO,SAAS,OAAO;CACxG,CAAC;AAEF,+GAA+G;AAC/G,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAAA;kEACqC,OAAO;4CAC7B,cAAc;8DACI,OAAO;CACpE,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;0BAGP,OAAO,KAAK,OAAO;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;;;0BAGd,OAAO,KAAK,cAAc;;CAEnD,CAAC;AAEF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;0BAGF,OAAO,KAAK,OAAO;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAA;;;0BAGT,OAAO,KAAK,cAAc;;CAEnD,CAAC;AAEF,6FAA6F;AAC7F,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAA;;;CAG3B,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;;;CAGrB,CAAC;AAEF,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;IAClB,IAAI;;CAEP,CAAC","sourcesContent":["// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css } from 'lit';\n\n/*\n * The resting look of the test controls (next, prev, item/section links, TTS buttons).\n *\n * Two looks, both plain: a neutral one (the page's surface, the theme's border, the surrounding text\n * colour) and a filled one that `test-next` wears, in the theme's neutral colour with its content\n * colour on top. No shadow, no glow, no transition, so the controls read as unbranded until a host\n * repaints them.\n *\n * Every colour is the theme's tier 1 (CONTRACT.md §8 in qti-theme), with a CSS system colour behind\n * it for a page that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the\n * controls stay legible in dark mode without the theme too. Hover and press mix the content colour\n * into the fill, by --qti-hover-mix and --qti-active-mix.\n *\n * Paint comes from the `--test-button-*` slots, which repaint the test controls alone, and never\n * from the shared `--qti-component-*` tokens: those also paint the items' own borders, and a change\n * to how a button looks must not move an interaction.\n *\n * --test-button-background-color, --test-button-color, --test-button-border-color,\n * --test-button-hover-background-color, --test-button-active-background-color\n * the neutral look, and the filled look's slots\n * --test-button-primary-background-color, --test-button-primary-color,\n * --test-button-primary-hover-background-color, --test-button-primary-active-background-color\n * the filled look only\n */\n\nconst surface = css`var(--qti-color-base-100, var(--cito-color-base-100, Canvas))`;\nconst content = css`var(--qti-color-base-content, var(--cito-color-base-content, CanvasText))`;\nconst neutral = css`var(--qti-color-neutral, var(--cito-color-neutral, CanvasText))`;\nconst neutralContent = css`var(--qti-color-neutral-content, var(--cito-color-neutral-content, Canvas))`;\n\nexport const form = css`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--test-button-size, 2.25rem);\n padding: 0 0.875rem;\n font: inherit;\n line-height: 1.25;\n cursor: pointer;\n user-select: none;\n border-radius: var(--test-button-border-radius, var(--qti-radius-field, var(--cito-radius-field, 0.2rem)));\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--test-button-background-color, ${surface});\n color: var(--test-button-color, inherit);\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid\n var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})));\n`;\n\n/** The filled look: the neutral colour, its content colour on top. Same box as `btn`, so the two sit level. */\nexport const btnPrimary = css`\n background-color: var(--test-button-primary-background-color, ${neutral});\n color: var(--test-button-primary-color, ${neutralContent});\n border-color: var(--test-button-primary-background-color, ${neutral});\n`;\n\n/** Hover; paint only, so the box never moves. */\nexport const btnInteractive = css`\n background-color: var(\n --test-button-hover-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%))\n );\n`;\n\nexport const btnPrimaryInteractive = css`\n background-color: var(\n --test-button-primary-hover-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))\n );\n`;\n\n/** Pressed: the same mix, twice as far. Paint only, so a click never moves the button. */\nexport const btnActive = css`\n background-color: var(\n --test-button-active-background-color,\n color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%))\n );\n`;\n\nexport const btnPrimaryActive = css`\n background-color: var(\n --test-button-primary-active-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))\n );\n`;\n\n/** The theme's one focus ring (qti-theme `@mixin foc`), so a page shows one kind of ring. */\nexport const focusRing = css`\n outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);\n outline-offset: var(--qti-focus-offset, 2px);\n`;\n\nexport const dis = css`\n cursor: not-allowed;\n opacity: 0.45;\n`;\n\nexport const ind = css`\n ${form};\n border: var(--qti-border-width, var(--cito-border-width, 1px)) solid var(--qti-border-color, GrayText);\n`;\n"]}
@@ -46,8 +46,13 @@ export class TestBookmark extends LitElement {
46
46
  :host {
47
47
  ${styles.btn};
48
48
  }
49
- :host(:hover:not([disabled])) {
50
- ${styles.btnInteractive};
49
+ @media (hover: hover) and (pointer: fine) {
50
+ :host(:hover:not([disabled])) {
51
+ ${styles.btnInteractive};
52
+ }
53
+ }
54
+ :host(:active:not([disabled])) {
55
+ ${styles.btnActive};
51
56
  }
52
57
  :host {
53
58
  display: inline-flex;
@@ -1 +1 @@
1
- {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO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nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host {\n display: inline-flex;\n align-items: center;\n gap: 0.4em;\n }\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
1
+ {"version":3,"file":"test-bookmark.js","sourceRoot":"","sources":["../../../src/components/test-bookmark/test-bookmark.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAWjD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAqD,EAAY,EAAE,CACjG,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,CAAC;AAE1C,2HAA2H;AAC3H,MAAM,SAAS,GAAG,CAAC,OAAgB,EAAsB,EAAE;IACzD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC3D,IAAI,OAAO;QAAE,OAAO,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,SAAS,CAAC;IACpE,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IACnC,OAAO,IAAI,YAAY,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;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ACb,OAAO,IAAI,CAAA,qGAAqG,CAAC;IACnH,CAAC;;AApGS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;qDACa;AAEf;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAe;AAEC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gDAAoB;AAEnB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CAAkB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { consume } from '@lit/context';\nimport { property } from 'lit/decorators.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\nimport { pluginState } from '../../plugin-state';\n\nimport type { ComputedContext } from '@qti-components/base';\n\ndeclare module '../../types/qti-test-state' {\n interface QtiTestPluginState {\n /** Item-ref identifiers the candidate marked to come back to, in the order they were marked. */\n bookmarks: string[];\n }\n}\n\n/** The item-ref identifiers bookmarked so far. For a host's own navigation: mark these. */\nexport const bookmarkedItems = (context: Pick<ComputedContext, 'plugins'> | undefined): string[] =>\n pluginState(context, 'bookmarks') ?? [];\n\n/** The identifier of the item-ref an element is stamped into (`<template item-ref>`), looking out through shadow roots. */\nconst itemRefOf = (element: Element): string | undefined => {\n const itemRef = element.closest('qti-assessment-item-ref');\n if (itemRef) return itemRef.getAttribute('identifier') ?? undefined;\n const root = element.getRootNode();\n return root instanceof ShadowRoot ? itemRefOf(root.host) : undefined;\n};\n\n/**\n * A toggle that marks the item on screen to come back to. The marks live in the test's state under\n * `bookmarks` (`session.plugins.bookmarks`), so a host that stores `state` stores them, and a\n * reloaded test shows them again.\n *\n * Put it inside `<test-navigation>`, either in the toolbar, where it marks the item on screen, or in\n * the `<template item-ref>`, where each item gets its own and it marks that item. It is a button\n * (`role=\"button\"`, `aria-pressed`) and reflects `bookmarked` on the host for styling; its content is\n * the label. In the toolbar it is `disabled` while no item is on screen. A host's own navigation reads\n * the marks with `bookmarkedItems(computedContext)`.\n *\n * Give it an `item` (an item-ref identifier) to mark that item instead, wherever the button sits: in a\n * stamp template that lists the items of a section, `<test-bookmark item=\"{{ item.identifier }}\">`\n * puts a button next to each one.\n *\n * @slot - The label.\n * @attr item - The item-ref identifier this button marks; without it, the item it is stamped into, or else the one on screen.\n * @attr bookmarked - Reflected: the item on screen is bookmarked.\n * @attr disabled - Reflected: there is no item on screen.\n */\nexport class TestBookmark extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext?: ComputedContext;\n\n @property({ reflect: true }) item?: string;\n\n @property({ type: Boolean, reflect: true }) bookmarked = false;\n\n @property({ type: Boolean, reflect: true }) disabled = false;\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host {\n display: inline-flex;\n align-items: center;\n gap: 0.4em;\n }\n svg {\n width: 1.1em;\n height: 1.1em;\n flex: none;\n fill: none;\n stroke: currentColor;\n stroke-width: 2;\n stroke-linejoin: round;\n }\n :host([bookmarked]) {\n color: var(--qti-bookmark-color, #b45309);\n }\n :host([bookmarked]) svg {\n fill: currentColor;\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#toggle());\n this.addEventListener('keydown', event => {\n if (event.key !== 'Enter' && event.key !== ' ') return;\n event.preventDefault();\n this.#toggle();\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n if (!this.hasAttribute('role')) this.setAttribute('role', 'button');\n if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', '0');\n }\n\n /** The item this button marks: its own, or else the one on screen. */\n get #activeItem(): string | undefined {\n return (\n this.item ||\n (itemRefOf(this) ??\n this.computedContext?.testParts\n ?.flatMap(part => part.sections.flatMap(section => section.items))\n .find(item => item.active)?.identifier)\n );\n }\n\n protected override willUpdate(): void {\n const active = this.#activeItem;\n this.disabled = !active;\n this.bookmarked = !!active && bookmarkedItems(this.computedContext).includes(active);\n }\n\n protected override updated(): void {\n this.setAttribute('aria-pressed', String(this.bookmarked));\n this.setAttribute('aria-disabled', String(this.disabled));\n }\n\n #toggle(): void {\n const active = this.#activeItem;\n if (!active) return;\n const marked = bookmarkedItems(this.computedContext);\n const next = marked.includes(active) ? marked.filter(id => id !== active) : [...marked, active];\n // An empty list removes the entry, so a test nobody bookmarked keeps no trace in the state.\n dispatchPublic(this, 'cito-test-update-plugin-state', {\n plugin: 'bookmarks',\n value: next.length > 0 ? next : null\n });\n }\n\n override render() {\n return html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M6 3h12v18l-6-4.5L6 21z\" /></svg><slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-bookmark': TestBookmark;\n }\n}\n"]}
@@ -20,8 +20,13 @@ export class TestCheckItem extends LitElement {
20
20
  :host {
21
21
  ${styles.btn};
22
22
  }
23
- :host(:hover:not([disabled])) {
24
- ${styles.btnInteractive};
23
+ @media (hover: hover) and (pointer: fine) {
24
+ :host(:hover:not([disabled])) {
25
+ ${styles.btnInteractive};
26
+ }
27
+ }
28
+ :host(:active:not([disabled])) {
29
+ ${styles.btnActive};
25
30
  }
26
31
  :host(:focus-visible) {
27
32
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAEF;QACE,KAAK,EAAE,CAAC;QAlBkB,SAAI,GAAS,QAAQ,CAAC;QAmBhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA3B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
1
+ {"version":3,"file":"test-check-item.js","sourceRoot":"","sources":["../../../src/components/test-check-item/test-check-item.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;GAMG;AACH,MAAM,OAAO,aAAc,SAAQ,UAAU;aAG3B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAEF;QACE,KAAK,EAAE,CAAC;QAvBkB,SAAI,GAAS,QAAQ,CAAC;QAwBhD,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAClC,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,EAAE,CAAC,CAAC;YAClD,cAAc,CAAC,IAAI,EAAE,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,CAAC,CAAC,CAAC;IACL,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAhC2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CAAuB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { View } from '@qti-components/base';\n\n/**\n * Ends the attempt on the current item and switches the test to `view` (default `scorer`), which\n * reveals the `[view]` content for that view, such as a scorer's rubric. The view stays until\n * something switches it back (`test-view-toggle`).\n *\n * @attr view - The view to switch to after the attempt ended.\n */\nexport class TestCheckItem extends LitElement {\n @property({ type: String }) view: View = 'scorer';\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n dispatchPublic(this, 'cito-test-switch-view', this.view);\n });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-check-item': TestCheckItem;\n }\n}\n"]}
@@ -21,8 +21,13 @@ export class TestEndAttempt extends LitElement {
21
21
  :host {
22
22
  ${styles.btn};
23
23
  }
24
- :host(:hover:not([disabled])) {
25
- ${styles.btnInteractive};
24
+ @media (hover: hover) and (pointer: fine) {
25
+ :host(:hover:not([disabled])) {
26
+ ${styles.btnInteractive};
27
+ }
28
+ }
29
+ :host(:active:not([disabled])) {
30
+ ${styles.btnActive};
26
31
  }
27
32
  :host(:focus-visible) {
28
33
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EA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;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAtFS;IAFT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACtD,QAAQ,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;uDACY;AAGpC;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // An adaptive item ends itself: once its response processing set completionStatus\n // to 'completed', there is no next attempt.\n if (activeItem.adaptive && activeItem.completionStatus === 'completed') {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
1
+ {"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD,MAAM,OAAO,cAAe,SAAQ,UAAU;IAS5C,wBAAw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EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;yDACjC;AAGjC;IADC,KAAK,CAAC,iBAAiB,CAAC;8DAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext } from '@qti-components/base';\n\nexport class TestEndAttempt extends LitElement {\n @consume({ context: computedContext, subscribe: true })\n @property({ attribute: false })\n protected computedContext: ComputedContext;\n\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = false;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) {\n dispatchPublic(this, 'cito-test-end-attempt', {});\n }\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const sectionItems = testPart.sections.flatMap(section => section.items);\n const itemIndex = sectionItems.findIndex(item => item.active);\n const activeItem = sectionItems[itemIndex];\n\n if (!activeItem) {\n this._internalDisabled = false;\n return;\n }\n\n const maxAttempts = activeItem.maxAttempts ?? 1;\n const numAttempts = activeItem.numAttempts || 0;\n\n // For non-adaptive items, the last ended attempt already reached the optimal\n // outcome — nothing to improve, so disable even when attempts remain. Adaptive\n // items keep iterating, so they're exempt (same as the max-attempts guard).\n if (!activeItem.adaptive && activeItem.optimal) {\n this._internalDisabled = true;\n return;\n }\n\n // An adaptive item ends itself: once its response processing set completionStatus\n // to 'completed', there is no next attempt.\n if (activeItem.adaptive && activeItem.completionStatus === 'completed') {\n this._internalDisabled = true;\n return;\n }\n\n // For non-adaptive items, disable when max attempts have been reached\n if (!activeItem.adaptive && maxAttempts > 0 && numAttempts >= maxAttempts) {\n this._internalDisabled = true;\n return;\n }\n\n if (activeItem.allowSkipping === false) {\n this._internalDisabled = activeItem.valid === false || activeItem.isDefaultResponse;\n } else {\n this._internalDisabled = false;\n }\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-end-attempt': TestEndAttempt;\n }\n}\n"]}
@@ -13,8 +13,13 @@ export class TestItemLink extends LitElement {
13
13
  :host {
14
14
  ${styles.btn};
15
15
  }
16
- :host(:hover:not([disabled])) {
17
- ${styles.btnInteractive};
16
+ @media (hover: hover) and (pointer: fine) {
17
+ :host(:hover:not([disabled])) {
18
+ ${styles.btnInteractive};
19
+ }
20
+ }
21
+ :host(:active:not([disabled])) {
22
+ ${styles.btnActive};
18
23
  }
19
24
  :host(:focus-visible) {
20
25
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
1
+ {"version":3,"file":"test-item-link.js","sourceRoot":"","sources":["../../../src/components/test-item-link/test-item-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAKF;QACE,KAAK,EAAE,CAAC;QAHF,WAAM,GAAW,IAAI,CAAC;QAI5B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACvE,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;4CACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestItemLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'item-id' })\n private itemId: string = null;\n\n constructor() {\n super();\n this.addEventListener('click', () => this._requestItem(this.itemId));\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-link': TestItemLink;\n }\n}\n"]}
@@ -31,9 +31,15 @@ export class TestNext extends LitElement {
31
31
  static { this.styles = css `
32
32
  :host {
33
33
  ${styles.btn};
34
+ ${styles.btnPrimary};
34
35
  }
35
- :host(:hover:not([disabled])) {
36
- ${styles.btnInteractive};
36
+ @media (hover: hover) and (pointer: fine) {
37
+ :host(:hover:not([disabled])) {
38
+ ${styles.btnPrimaryInteractive};
39
+ }
40
+ }
41
+ :host(:active:not([disabled])) {
42
+ ${styles.btnPrimaryActive};
37
43
  }
38
44
  :host(:focus-visible) {
39
45
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAA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;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AAtFM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGtB;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACZ;AAM3C;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const activeSection = testPart.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart.navigationMode;\n const submissionMode = activeSection?.submissionMode || testPart.submissionMode;\n const activeItem = this.sectionItems[this.itemIndex];\n\n const isLinearIndividual = navigationMode === 'linear' && submissionMode === 'individual';\n\n // In linear individual mode the candidate may only advance once they are\n // \"done\" with the active item: they reached the optimal outcome (best score),\n // exhausted maxAttempts, or the item has no judgeable optimal value. `done` is\n // computed centrally in test-navigation (#isItemDone), so this Next gate\n // matches the exact rule that decides an item is resolved.\n this._internalDisabled =\n !this.computedContext ||\n this.itemIndex < 0 ||\n this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 ||\n (isLinearIndividual && !activeItem?.done);\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"]}
1
+ {"version":3,"file":"test-next.js","sourceRoot":"","sources":["../../../src/components/test-next/test-next.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,E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AS,GAAG,CAAC;gBAClB,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;gBACtD,CAAC,kBAAkB,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AA5FM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGtB;IADT,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACZ;AAM3C;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the next test item.\n *\n * @remarks\n * This element provides functionality for navigating to the next test item.\n *\n * @example\n * ```html\n * <test-next></test-next>\n * ```\n */\n\nexport class TestNext extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n protected computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n ${styles.btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnPrimaryActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n #internals: ElementInternals;\n\n constructor() {\n super();\n\n this.#internals = this.attachInternals();\n this.#internals.role = 'button';\n this.#internals.ariaLabel = 'Next item';\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex + 1].identifier);\n });\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.checkDisabled();\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n const activeSection = testPart.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart.navigationMode;\n const submissionMode = activeSection?.submissionMode || testPart.submissionMode;\n const activeItem = this.sectionItems[this.itemIndex];\n\n const isLinearIndividual = navigationMode === 'linear' && submissionMode === 'individual';\n\n // In linear individual mode the candidate may only advance once they are\n // \"done\" with the active item: they reached the optimal outcome (best score),\n // exhausted maxAttempts, or the item has no judgeable optimal value. `done` is\n // computed centrally in test-navigation (#isItemDone), so this Next gate\n // matches the exact rule that decides an item is resolved.\n this._internalDisabled =\n !this.computedContext ||\n this.itemIndex < 0 ||\n this.itemIndex >= (this.sectionItems?.length ?? 0) - 1 ||\n (isLinearIndividual && !activeItem?.done);\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-next': TestNext;\n }\n}\n"]}
@@ -32,8 +32,13 @@ export class TestPrev extends LitElement {
32
32
  :host {
33
33
  ${styles.btn};
34
34
  }
35
- :host(:hover:not([disabled])) {
36
- ${styles.btnInteractive};
35
+ @media (hover: hover) and (pointer: fine) {
36
+ :host(:hover:not([disabled])) {
37
+ ${styles.btnInteractive};
38
+ }
39
+ }
40
+ :host(:active:not([disabled])) {
41
+ ${styles.btnActive};
37
42
  }
38
43
  :host(:focus-visible) {
39
44
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;;;;;;;;;GAUG;AAEH,MAAM,OAAO,QAAS,SAAQ,UAAU;IAWtC,wBAAwB,CAAC,SAA0B,EAAE,QAAyB;QAC5E,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;aAEe,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAEF;QACE,KAAK,EA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BAAiB;YACpB,cAAc,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC;IAC1G,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AA/DM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGxB;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACd;AAMzC;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const activeSection = testPart?.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || 'nonlinear';\n\n this._internalDisabled =\n navigationMode === 'linear' || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n"]}
1
+ {"version":3,"file":"test-prev.js","sourceRoot":"","sources":["../../../src/components/test-prev/test-prev.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;A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AI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAED,aAAa;QACX,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnF,MAAM,aAAa,GAAG,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAC7D,MAAM,cAAc,GAAG,aAAa,EAAE,cAAc,IAAI,QAAQ,EAAE,cAAc,IAAI,WAAW,CAAC;QAEhG,IAAI,CAAC,iBAAiB;YACpB,cAAc,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC;IAC1G,CAAC;IAES,YAAY,CAAC,UAAkB;QACvC,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;;AApEM;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC;mDAClC;AAGxB;IADP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;iDACd;AAMzC;IADC,KAAK,CAAC,iBAAiB,CAAC;wDAKxB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { consume } from '@lit/context';\n\nimport { watch } from '@qti-components/utilities';\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nimport type { ComputedContext, ComputedItem } from '@qti-components/base';\n\n/**\n * Represents a custom element for navigating to the previous test item.\n *\n * @remarks\n * This element provides functionality for navigating to the previous test item.\n *\n * @example\n * ```html\n * <test-prev></test-prev>\n * ```\n */\n\nexport class TestPrev extends LitElement {\n @property({ type: Boolean, reflect: true, attribute: 'disabled' })\n public _internalDisabled = true;\n\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n sectionItems: ComputedItem[];\n itemIndex: number;\n\n @watch('computedContext')\n _handleTestElementChange(_oldValue: ComputedContext, newValue: ComputedContext) {\n if (newValue) {\n this.requestUpdate();\n }\n }\n\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n\n this.addEventListener('click', e => {\n e.preventDefault();\n if (!this._internalDisabled) this._requestItem(this.sectionItems[this.itemIndex - 1].identifier);\n });\n }\n\n override willUpdate(_changedProperties: Map<string | number | symbol, unknown>) {\n if (!this.computedContext) return;\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n if (!testPart) return;\n this.sectionItems = testPart.sections.flatMap(section => section.items);\n this.itemIndex = this.sectionItems.findIndex(item => item.active);\n this.checkDisabled();\n }\n\n checkDisabled() {\n const testPart = this.computedContext?.testParts.find(testPart => testPart.active);\n const activeSection = testPart?.sections.find(s => s.active);\n const navigationMode = activeSection?.navigationMode || testPart?.navigationMode || 'nonlinear';\n\n this._internalDisabled =\n navigationMode === 'linear' || !this.computedContext || this.itemIndex === 0 || this.itemIndex === -1;\n }\n\n protected _requestItem(identifier: string): void {\n dispatchPublic(this, 'cito-test-navigate', { type: 'item', id: identifier });\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-prev': TestPrev;\n }\n}\n"]}
@@ -13,8 +13,13 @@ export class TestSectionLink extends LitElement {
13
13
  :host {
14
14
  ${styles.btn};
15
15
  }
16
- :host(:hover:not([disabled])) {
17
- ${styles.btnInteractive};
16
+ @media (hover: hover) and (pointer: fine) {
17
+ :host(:hover:not([disabled])) {
18
+ ${styles.btnInteractive};
19
+ }
20
+ }
21
+ :host(:active:not([disabled])) {
22
+ ${styles.btnActive};
18
23
  }
19
24
  :host(:focus-visible) {
20
25
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../../src/components/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAbqB,CAapB;IAKF,YAAY,CAAC,UAAkB;QAC7B,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAPF,cAAS,GAAW,IAAI,CAAC;QAQ/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'cito-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
1
+ {"version":3,"file":"test-section-link.js","sourceRoot":"","sources":["../../../src/components/test-section-link/test-section-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,UAAU;aAC7B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,AAlBqB,CAkBpB;IAKF,YAAY,CAAC,UAAkB;QAC7B,cAAc,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;QACE,KAAK,EAAE,CAAC;QAPF,cAAS,GAAW,IAAI,CAAC;QAQ/B,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAbO;IADP,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;kDACnB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\nexport class TestSectionLink extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n @property({ type: String, attribute: 'section-id' })\n private sectionId: string = null;\n\n #requestItem(identifier: string) {\n dispatchPublic(this, 'cito-test-navigate', { type: 'section', id: identifier });\n }\n\n constructor() {\n super();\n this.addEventListener('click', () => this.#requestItem(this.sectionId));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-section-link': TestSectionLink;\n }\n}\n"]}
@@ -2,8 +2,9 @@ import { LitElement } from 'lit';
2
2
  import type { PropertyValues } from 'lit';
3
3
  import type { TemplateFunction } from '@heximal/templates';
4
4
  /**
5
- * A custom web component that renders a test stamp using the Lit framework.
6
- * This component is deprecated and will be removed in the future.
5
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
6
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
7
+ * can show progress or numbered navigation without writing a component.
7
8
  * @customElement
8
9
  * @extends {LitElement}
9
10
  */
@@ -10,8 +10,9 @@ import { prepareTemplate } from '@heximal/templates';
10
10
  import { consume } from '@lit/context';
11
11
  import { computedContext } from '@qti-components/base';
12
12
  /**
13
- * A custom web component that renders a test stamp using the Lit framework.
14
- * This component is deprecated and will be removed in the future.
13
+ * The stamp plugin: renders its `<template>` child with the state of the test (`test`,
14
+ * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player
15
+ * can show progress or numbered navigation without writing a component.
15
16
  * @customElement
16
17
  * @extends {LitElement}
17
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"test-stamp.js","sourceRoot":"","sources":["../../../src/components/test-stamp/test-stamp.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD;;;;;GAKG;AAEH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAAzC;;QACE;;;WAGG;QAEI,UAAK,GAAG,KAAK,CAAC;QAOb,iBAAY,GAMhB;YACF,IAAI,EAAE,WAAW;YACjB,UAAU,EAAE,EAAE;YACd,aAAa,EAAE;gBACb,KAAK,EAAE,EAAE;aACV;YACD,cAAc,EAAE;gBACd,KAAK,EAAE,EAAE;gBACT,QAAQ,EAAE,EAAE;aACb;YACD,IAAI,EAAE,EAAE;SACT,CAAC;IAmEJ,CAAC;IA/DoB,gBAAgB;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IAEQ,iBAAiB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,EAAE,CAAC;wCACtB;AAIb;IAFP,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDACd;AAGjC;IADP,KAAK,EAAE;+CAkBN","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * A custom web component that renders a test stamp using the Lit framework.\n * This component is deprecated and will be removed in the future.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n // In `navigate=\"section\"` the test shows a section, not one item, so there may be no active item.\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = {\n ...activeSection,\n items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)\n };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"]}
1
+ {"version":3,"file":"test-stamp.js","sourceRoot":"","sources":["../../../src/components/test-stamp/test-stamp.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAOvD;;;;;;GAMG;AAEH,MAAM,OAAO,SAAU,SAAQ,UAAU;IAAzC;;QACE;;;WAGG;QAEI,UAAK,GAAG,KAAK,CAAC;QAOb,iBAAY,GAMhB;YACF,IAAI,EAAE,WAAW;YACjB,U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BAAgB,CAAC,CAAC,CAAC,OAAO;MACjH,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACrE,CAAC;CACF;AA3FQ;IADN,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCACtB;AAIb;IAFP,KAAK,EAAE;IACP,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;kDACd;AAGjC;IADP,KAAK,EAAE;+CAkBN","sourcesContent":["import { html, LitElement, nothing } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { prepareTemplate } from '@heximal/templates';\nimport { consume } from '@lit/context';\n\nimport { computedContext } from '@qti-components/base';\n\nimport type { View } from '@qti-components/base';\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { TemplateFunction } from '@heximal/templates';\n\n/**\n * The stamp plugin: renders its `<template>` child with the state of the test (`test`,\n * `activeTestpart`, `activeSection`, `activeItem`, `view`), again on every change, so a player\n * can show progress or numbered navigation without writing a component.\n * @customElement\n * @extends {LitElement}\n */\n\nexport class TestStamp extends LitElement {\n /**\n * Indicates whether the component is in debug mode.\n * When set to `true`, the available objects and properties (i.e.: stampContext) is displayed.\n */\n @property({ type: Boolean, reflect: true })\n public debug = false;\n\n @state()\n @consume({ context: computedContext, subscribe: true })\n private computedContext: ComputedContext;\n\n @state()\n private stampContext: {\n view?: View;\n test?: unknown;\n activeTestpart?: unknown;\n activeSection?: unknown;\n activeItem?: unknown;\n } = {\n view: 'candidate',\n activeItem: {},\n activeSection: {\n items: []\n },\n activeTestpart: {\n items: [],\n sections: []\n },\n test: {}\n };\n\n myTemplate: TemplateFunction;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n return this;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const templateElement = this.querySelector<HTMLTemplateElement>('template');\n if (!templateElement) {\n this.myTemplate = null;\n return;\n }\n this.myTemplate = prepareTemplate(templateElement);\n }\n\n protected override willUpdate(_changedProperties: PropertyValues): void {\n if (!this.computedContext) {\n return;\n }\n const activeTestPart = this.computedContext.testParts.find(testPart => testPart.active);\n const activeSection = activeTestPart?.sections.find(section => section.active);\n const activeItem = activeSection?.items.find(item => item.active);\n // In `navigate=\"section\"` the test shows a section, not one item, so there may be no active item.\n const { variables, ...augmentedItem } = activeItem || {};\n\n if (!activeTestPart) {\n return;\n }\n\n const augmentedTestPart = {\n ...activeTestPart,\n items: activeTestPart.sections.flatMap(section => section.items.map(({ variables, ...rest }) => rest)),\n sections: activeTestPart.sections.map(section => ({\n ...section,\n items: section.items.map(({ variables, ...rest }) => rest)\n }))\n };\n\n const augmentedSection = {\n ...activeSection,\n items: (activeSection?.items ?? []).map(({ variables, ...rest }) => rest)\n };\n const { testParts, ...activeTest } = this.computedContext;\n\n this.stampContext = {\n view: this.computedContext.view,\n activeItem: augmentedItem,\n activeSection: augmentedSection,\n activeTestpart: augmentedTestPart,\n test: activeTest\n };\n this.dispatchEvent(\n new CustomEvent('qti-stamp-context-updated', {\n detail: this.stampContext,\n bubbles: true\n })\n );\n }\n\n override render() {\n // if (!this.stampContext) return nothing;\n return html` ${this.debug ? html`<small><pre>${JSON.stringify(this.stampContext, null, 2)}</pre></small>` : nothing}\n ${this.myTemplate ? this.myTemplate(this.stampContext) : nothing}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-stamp': TestStamp;\n }\n}\n"]}
@@ -11,8 +11,13 @@ export class TestSubmit extends LitElement {
11
11
  :host {
12
12
  ${styles.btn};
13
13
  }
14
- :host(:hover:not([disabled])) {
15
- ${styles.btnInteractive};
14
+ @media (hover: hover) and (pointer: fine) {
15
+ :host(:hover:not([disabled])) {
16
+ ${styles.btnInteractive};
17
+ }
18
+ }
19
+ :host(:active:not([disabled])) {
20
+ ${styles.btnActive};
16
21
  }
17
22
  :host(:focus-visible) {
18
23
  ${styles.focusRing};
@@ -1 +1 @@
1
- {"version":3,"file":"test-submit.js","sourceRoot":"","sources":["../../../src/components/test-submit/test-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;aACxB,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,cAAc;;;QAGrB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\n/**\n * Scores the test: on click the test resets its outcomes to their declared defaults, runs its\n * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.\n * The host decides where it sits, for example on the last item or in a review view.\n */\nexport class TestSubmit extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-submit': TestSubmit;\n }\n}\n"]}
1
+ {"version":3,"file":"test-submit.js","sourceRoot":"","sources":["../../../src/components/test-submit/test-submit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;aACxB,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;;UAIR,MAAM,CAAC,cAAc;;;;QAIvB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,SAAS;;;QAGhB,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC","sourcesContent":["import { css, html, LitElement } from 'lit';\n\nimport * as styles from '../styles';\nimport { dispatchPublic } from '../../public-events';\n\n/**\n * Scores the test: on click the test resets its outcomes to their declared defaults, runs its\n * outcome processing and dispatches `cito-test-submitted`, after which the host reads the outcomes.\n * The host decides where it sits, for example on the last item or in a review view.\n */\nexport class TestSubmit extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) {\n ${styles.btnInteractive};\n }\n }\n :host(:active:not([disabled])) {\n ${styles.btnActive};\n }\n :host(:focus-visible) {\n ${styles.focusRing};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => dispatchPublic(this, 'cito-test-submit', {}));\n }\n\n override render() {\n return html` <slot></slot> `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-submit': TestSubmit;\n }\n}\n"]}
@@ -13,14 +13,24 @@ import * as styles from '../components/styles';
13
13
  // ─── CSS Custom Highlight ─────────────────────────────────────────────────────
14
14
  const HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element
15
15
  const HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech
16
- // Shared across all instances — added to whichever shadow root needs it
16
+ // Shared across all instances — added to whichever shadow root needs it. The two highlights are
17
+ // tints of the theme's info (the element being read) and warning (the word being spoken) colours,
18
+ // see-through so the text and its own background stay visible. Without the theme they fall back to
19
+ // the system Highlight and Mark colours. A host repaints them with --test-tts-element-highlight and
20
+ // --test-tts-word-highlight.
17
21
  let highlightSheet = null;
18
22
  function getHighlightSheet() {
19
23
  if (!highlightSheet) {
20
24
  highlightSheet = new CSSStyleSheet();
21
25
  highlightSheet.replaceSync(`
22
- ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }
23
- ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }
26
+ ::highlight(${HIGHLIGHT_ELEMENT}) {
27
+ background-color: var(--test-tts-element-highlight, color-mix(in oklab, var(--qti-color-info, var(--cito-color-info, Highlight)) 15%, transparent));
28
+ color: inherit;
29
+ }
30
+ ::highlight(${HIGHLIGHT_WORD}) {
31
+ background-color: var(--test-tts-word-highlight, color-mix(in oklab, var(--qti-color-warning, var(--cito-color-warning, Mark)) 55%, transparent));
32
+ color: inherit;
33
+ }
24
34
  `);
25
35
  }
26
36
  return highlightSheet;
@@ -65,8 +75,13 @@ class TtsButtonBase extends LitElement {
65
75
  page as tall as the scrolled content. */
66
76
  position: relative;
67
77
  }
68
- button:hover:not(:disabled) {
69
- ${styles.btnInteractive};
78
+ @media (hover: hover) and (pointer: fine) {
79
+ button:hover:not(:disabled) {
80
+ ${styles.btnInteractive};
81
+ }
82
+ }
83
+ button:active:not(:disabled) {
84
+ ${styles.btnActive};
70
85
  }
71
86
  button:focus-visible {
72
87
  ${styles.focusRing};
@@ -76,8 +91,8 @@ class TtsButtonBase extends LitElement {
76
91
  }
77
92
  button[aria-pressed='true'],
78
93
  button[aria-pressed='true']:hover {
79
- background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));
80
- color: var(--test-button-selected-color, var(--qti-selected-color, #fff));
94
+ background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, Highlight));
95
+ color: var(--test-button-selected-color, var(--qti-selected-color, HighlightText));
81
96
  }
82
97
  svg,
83
98
  ::slotted(svg) {
@@ -1 +1 @@
1
- {"version":3,"file":"test-item-to-speech.js","sourceRoot":"","sources":["../../src/tts/test-item-to-speech.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAO/C,iFAAiF;AAEjF,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,oCAAoC;AAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,8BAA8B;AAEjE,wEAAwE;AACxE,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD,SAAS,iBAAiB;IACxB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC;QACrC,cAAc,CAAC,WAAW,CAAC;oBACX,iBAAiB;oBACjB,cAAc;KAC7B,CAAC,CAAC;IACL,CAAC;IACD,OAA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GM,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;uBACnB,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;iBAC3C,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE;;gBAE9B,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,gBAAgB,CAAC;;KAE9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { html, LitElement, css } from 'lit';\nimport { consume, provide, createContext } from '@lit/context';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../components/styles';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\n\n// ─── CSS Custom Highlight ─────────────────────────────────────────────────────\n\nconst HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element\nconst HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech\n\n// Shared across all instances — added to whichever shadow root needs it\nlet highlightSheet: CSSStyleSheet | null = null;\n\nfunction getHighlightSheet(): CSSStyleSheet {\n if (!highlightSheet) {\n highlightSheet = new CSSStyleSheet();\n highlightSheet.replaceSync(`\n ::highlight(${HIGHLIGHT_ELEMENT}) { background-color: #dbeafe; color: inherit; }\n ::highlight(${HIGHLIGHT_WORD}) { background-color: #ffe066; color: inherit; }\n `);\n }\n return highlightSheet;\n}\n\ntype SpeechState = 'idle' | 'playing' | 'paused';\n\n// ─── TTS Context ──────────────────────────────────────────────────────────────\n\nexport interface TtsContext {\n state: SpeechState;\n /** True while every reading element is highlighted and a click on one starts reading there. */\n picking: boolean;\n /** Index of the currently highlighted reading element (0-based). */\n currentElementIndex: number;\n /** Total number of navigable reading elements in the current item. */\n elementCount: number;\n play(): void;\n pause(): void;\n resume(): void;\n stop(): void;\n prevElement(): void;\n nextElement(): void;\n /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */\n togglePick(): void;\n}\n\nexport { SpeechState };\nexport const ttsContext = createContext<TtsContext>(Symbol('tts-context'));\n\n// ─── Icons ────────────────────────────────────────────────────────────────────\n\n// Plain geometric glyphs on a 24-unit grid, painted in currentColor. SVG rather than text so\n// every button gets the same box: text glyphs (◀◀ ▶ ⏸ ■ ☞) differ in width, and some fall back\n// to an emoji font with different line metrics.\nconst ICONS = {\n play: 'M8 5v14l11-7z',\n pause: 'M6 5h4v14H6zM14 5h4v14h-4z',\n stop: 'M6 6h12v12H6z',\n prev: 'M6 5h2v14H6zM20 5v14L9 12z',\n next: 'M16 5h2v14h-2zM4 5v14l11-7z',\n pick: 'M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z'\n} as const;\n\n/** Default button content: the icon, plus a visually hidden label as the accessible name. */\nconst iconContent = (icon: keyof typeof ICONS, label: string) => {\n const svg = html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"${ICONS[icon]}\"></path>\n </svg>`;\n return html`${svg}<span class=\"label\">${label}</span>`;\n};\n\n// ─── Shared base for child button elements ────────────────────────────────────\n\n/**\n * Base class shared by all TTS control elements. Consumes `ttsContext` and\n * mirrors the current speech state onto CSS custom states so each child can\n * be styled with `:state(playing)`, `:state(paused)`, `:state(idle)`.\n */\nabstract class TtsButtonBase extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n }\n button {\n ${styles.btn};\n min-inline-size: var(--test-button-size, 2.25rem);\n padding-inline: 0.5rem;\n /* Containing block for the visually hidden .label. Without it the label is placed against\n the nearest positioned ancestor, which can sit outside a scroll container and make the\n page as tall as the scrolled content. */\n position: relative;\n }\n button:hover:not(:disabled) {\n ${styles.btnInteractive};\n }\n button:focus-visible {\n ${styles.focusRing};\n }\n button:disabled {\n ${styles.dis};\n }\n button[aria-pressed='true'],\n button[aria-pressed='true']:hover {\n background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, #0175aa));\n color: var(--test-button-selected-color, var(--qti-selected-color, #fff));\n }\n svg,\n ::slotted(svg) {\n flex: none;\n inline-size: var(--test-tts-icon-size, 1.125rem);\n block-size: var(--test-tts-icon-size, 1.125rem);\n }\n svg {\n fill: currentColor;\n }\n /* The default content is icon-only; this keeps the button's accessible name. */\n .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `;\n\n /**\n * Accessible name of the button. Without it the default icon carries an English name, and\n * slotted content names the button by its text; set it when you slot an icon of your own,\n * which has no text to be named by.\n */\n @property({ type: String }) label?: string;\n\n #internals = this.attachInternals();\n\n @consume({ context: ttsContext, subscribe: true })\n protected _tts?: TtsContext;\n\n #mirroredState: SpeechState | undefined;\n #mirroredPicking = false;\n\n override updated(_changed: PropertyValues) {\n // `_tts` is a context field, not a reactive property, so it never shows up in `changed`:\n // compare against what was last mirrored instead.\n const state = this._tts?.state;\n const picking = this._tts?.picking ?? false;\n if (state === this.#mirroredState && picking === this.#mirroredPicking) return;\n this.#mirroredState = state;\n this.#mirroredPicking = picking;\n this.#internals.states.clear();\n if (state) this.#internals.states.add(state);\n if (picking) this.#internals.states.add('picking');\n }\n}\n\n// ─── Controller element ───────────────────────────────────────────────────────\n\n/**\n * `<test-item-to-speech>` is the controller and context provider. It manages\n * speech synthesis, word highlighting, and item element lookup. Compose your\n * own player by placing control elements as children.\n *\n * @example\n * ```html\n * <test-item-to-speech language=\"nl-NL\">\n * <test-tts-play></test-tts-play>\n * <test-tts-prev></test-tts-prev>\n * <test-tts-next></test-tts-next>\n * <test-tts-stop></test-tts-stop>\n * </test-item-to-speech>\n * ```\n *\n * The controller lays its controls out as a wrapping row; each control draws an icon button,\n * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a\n * control with a slotted icon a `label`, since an icon has no text to name the button by. Buttons read the qti-theme tokens (with the theme's\n * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.\n *\n * ### Language resolution\n *\n * Each reading element is spoken in the language of the nearest `lang` attribute:\n *\n * 1. `lang` (or `xml:lang`) on the element itself\n * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across\n * shadow roots, anything wrapping the test\n * 3. `lang` on the document's `<html>` element\n * 4. the `language` attribute on `<test-item-to-speech>`\n *\n * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with\n * `xml:lang=\"en-GB\"` on a `<p>` or on the item root is honoured without further work.\n *\n * ### What is read\n *\n * Decided once per connect, by where the player is placed. The first rule that matches wins:\n *\n * 1. **Next to a stimulus placeholder** — the player shares its parent with a\n * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the\n * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the\n * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation\n * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts\n * over on the new content.\n * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked\n * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes\n * on one container; the player reads the readable elements inside it. Navigation is ignored.\n * The reading list is rebuilt when the player starts from the top, and when an element in it\n * has left the page — so a re-render of the content never interrupts speech.\n * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,\n * so every item gets a player of its own: the player reads that item, and only that item.\n * The navigation cursor is ignored; speech stops when the player leaves the page with its item.\n * 4. **Anywhere else inside `<test-navigation>`** — e.g. a toolbar: the player follows the\n * navigation cursor and reads the active item of the computed context. Navigating stops\n * speech and starts the next item from the top.\n *\n * ```html\n * <!-- 1. a player for the shared reading text -->\n * <aside>\n * <test-item-to-speech>…</test-item-to-speech>\n * <div data-stimulus-idref=\"Stimulus1\"></div>\n * </aside>\n *\n * <!-- 2. a player for any other HTML -->\n * <div>\n * <test-item-to-speech>…</test-item-to-speech>\n * <section data-tts-content lang=\"nl-NL\">…</section>\n * </div>\n *\n * <!-- 3. one player per item -->\n * <qti-test>\n * <template item-ref>\n * <test-item-to-speech>…</test-item-to-speech>\n * {{ xmlDoc }}\n * </template>\n * …\n * </qti-test>\n *\n * <!-- 4. one player in the toolbar, following navigation -->\n * <test-navigation>\n * <header><test-item-to-speech>…</test-item-to-speech></header>\n * <test-container test-url=\"…\"></test-container>\n * </test-navigation>\n * ```\n *\n * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the\n * player on the fresh content. An item player reads the item body as rendered: a stimulus\n * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player\n * can speak at a time; starting one stops any other.\n *\n * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,\n * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)\n * or inside `aria-hidden=\"true\"`.\n *\n * ### Starting somewhere in the middle\n *\n * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue\n * cursor highlight, and the first click on one of them leaves pick mode and starts reading\n * from that element. Pressing the button again leaves pick mode without reading.\n *\n * @cssstate idle - No speech active\n * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click\n * @cssstate playing - Speech is playing\n * @cssstate paused - Speech is paused\n */\n\nexport class TestItemToSpeech extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--test-tts-gap, 0.25rem);\n }\n `;\n\n /** Fallback language when neither the item content nor the document declares one. */\n @property({ type: String }) language = 'nl-NL';\n\n /**\n * The test as `test-navigation` computes it: which item is active, and where it is rendered\n * (`itemElement`). Updated on navigation and whenever an item is rendered.\n */\n @consume({ context: computedContext, subscribe: true })\n protected _computedContext?: ComputedContext;\n\n @state()\n @provide({ context: ttsContext })\n _ttsContext!: TtsContext;\n\n #internals = this.attachInternals();\n\n // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The\n // placeholder itself is looked up on every use — a host may swap the element.\n #stimulusMode = false;\n // Stimulus mode: resets the player when the stimulus content next to it is replaced.\n #stimulusObserver: MutationObserver | null = null;\n // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.\n // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).\n #contentMode = false;\n // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.\n #itemRef: QtiAssessmentItemRef | null = null;\n // Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's\n // navigation request is heard.\n #eventHost: EventTarget | null = null;\n #boundHandleItemConnected = this.#handleItemConnected.bind(this);\n #boundHandleNavigation = () => this.#stop();\n\n // Cursor mode: the previous navigation position, to detect moving to another item or section.\n #prevNavItemRefId: string | null | undefined = undefined;\n #prevNavSectionId: string | null | undefined = undefined;\n\n // Current set of block-level reading elements for the item, and the root they were collected from\n #readingElements: Element[] | null = null;\n #readingRoot: Element | null = null;\n #currentElementIndex = 0;\n\n // Text nodes of the element currently being spoken (for word-boundary highlight)\n #textNodes: Text[] = [];\n\n // The utterance this player is speaking; lets the error handler tell \"our speech was\n // cancelled by another player\" apart from a cancel we issued ourselves.\n #currentUtterance: SpeechSynthesisUtterance | null = null;\n\n // Pick mode: all elements highlighted, a click on one starts reading from there.\n #picking = false;\n #pickRoot: EventTarget | null = null;\n #boundHandlePickClick = this.#handlePickClick.bind(this);\n\n // Set when the last element has been read: the cursor stays on it (so prev still works),\n // but the next play starts the item over instead of repeating that last element.\n #finished = false;\n\n // Two separate CSS Highlight objects\n #elementHighlight = new Highlight(); // whole-element cursor\n #wordHighlight = new Highlight(); // current word during speech\n\n constructor() {\n super();\n this._ttsContext = {\n state: 'idle',\n currentElementIndex: 0,\n elementCount: 0,\n play: () => this.#playSpeech(),\n pause: () => this.#pause(),\n resume: () => this.#resume(),\n stop: () => {\n this.#stopPicking();\n this.#stop();\n },\n prevElement: () => this.#prevElement(),\n nextElement: () => this.#nextElement(),\n togglePick: () => this.#togglePick(),\n picking: false\n };\n }\n\n // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the\n // render already under way instead of scheduling a second one (Lit's change-in-update).\n override willUpdate(changed: PropertyValues) {\n super.willUpdate(changed);\n // Stimulus, content and item-ref mode: the navigation cursor does not change what this player reads.\n if (this.#stimulusMode || this.#contentMode || this.#itemRef) return;\n // Cursor mode: moving to another item or section stops speech and starts over (ignore the\n // initial undefined → value transition). Section navigation leaves no item active, so it\n // needs its own check.\n const { item, section } = this.#activePosition();\n const itemChanged = this.#prevNavItemRefId !== undefined && this.#prevNavItemRefId !== item;\n const sectionChanged = this.#prevNavSectionId !== undefined && this.#prevNavSectionId !== section;\n // The same item rendered again (e.g. linking to the item already shown): the elements\n // collected earlier are detached. The context updates when an item renders, so check here.\n const rerendered =\n this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();\n if (itemChanged || sectionChanged || rerendered) this.#resetReadingPosition();\n this.#prevNavItemRefId = item;\n this.#prevNavSectionId = section;\n }\n\n /** Stop speech and forget the collected reading elements, so the next play starts afresh. */\n #resetReadingPosition() {\n this.#stopPicking();\n this.#stop();\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#setSpeechState('idle');\n // NOTE: #ensureHighlightStyles() is called lazily on first highlight use\n // because the item to read may not be in the DOM yet at this point.\n this.#stimulusMode = this.#stimulusPlaceholder() !== null;\n if (this.#stimulusMode) {\n // Stimulus mode: neither items nor navigation decide what is read, only the content of the\n // placeholder. qti-components replaces it whenever it loads a stimulus (innerHTML, then\n // append), so watch the parent — that also catches a host swapping the placeholder itself.\n this.#stimulusObserver = new MutationObserver(records => {\n if (records.some(record => !this.contains(record.target))) this.#handleStimulusReplaced();\n });\n this.#stimulusObserver.observe(this.parentElement!, { childList: true, subtree: true });\n return;\n }\n // Content mode: plain HTML next to the player. Nothing to listen for: what is read only\n // depends on that element, and the reading list is rebuilt when it goes stale.\n this.#contentMode = this.#contentElement() !== null;\n if (this.#contentMode) return;\n this.#itemRef = this.closest<QtiAssessmentItemRef>('qti-assessment-item-ref');\n if (this.#itemRef) {\n // Item-ref mode: qti-assessment-item-connected (bubbles+composed) passes our own item-ref\n // when our item renders again.\n this.#eventHost = this.#itemRef;\n this.#eventHost.addEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n } else {\n // Cursor mode: cito-test-navigate fires synchronously on prev/next — stop right away\n // instead of waiting for the new position to arrive through the computed context.\n this.#eventHost = this.closest('test-navigation') ?? (this.getRootNode() as EventTarget);\n this.#eventHost.addEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost.addEventListener('qti-request-navigation', this.#boundHandleNavigation); // deprecated name, still sent by hosts\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // Only silence the synthesizer if it is speaking for this player.\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#eventHost?.removeEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n this.#eventHost?.removeEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost?.removeEventListener('qti-request-navigation', this.#boundHandleNavigation);\n this.#eventHost = null;\n this.#itemRef = null;\n this.#stimulusObserver?.disconnect();\n this.#stimulusObserver = null;\n this.#stimulusMode = false;\n this.#contentMode = false;\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */\n #handleItemConnected() {\n if (this.#readingElements !== null) this.#resetReadingPosition();\n }\n\n /** Cursor mode: the active item and section, from the computed context. */\n #activePosition(): { item: string | null; section: string | null } {\n for (const part of this._computedContext?.testParts ?? []) {\n for (const section of part.sections) {\n if (!section.active) continue;\n return { item: section.items.find(item => item.active)?.identifier ?? null, section: section.identifier };\n }\n }\n return { item: null, section: null };\n }\n\n /**\n * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was\n * collected, so the next play reads the new content from the top. Unlike\n * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading\n * while an item player on the same page is speaking.\n */\n #handleStimulusReplaced() {\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n /**\n * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or\n * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because\n * loading replaces the placeholder's content.\n */\n #stimulusPlaceholder(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-stimulus-idref]') ?? null;\n }\n\n /**\n * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.\n * The marker goes on one container; the player finds the readable elements inside it.\n */\n #contentElement(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-tts-content]') ?? null;\n }\n\n /**\n * The element whose text is read: the stimulus body next to the player (stimulus mode), the\n * marked content next to it (content mode), or the item body of the item to read.\n */\n #resolveReadingRoot(): Element | null {\n if (this.#stimulusMode) return this.#stimulusPlaceholder()?.querySelector('qti-stimulus-body') ?? null;\n if (this.#contentMode) return this.#contentElement();\n return this.#resolveItem()?.querySelector('qti-item-body') ?? null;\n }\n\n /**\n * The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test\n * looks the active one up in its own items (`computedContext.itemElement`), so a page with\n * several tests showing the same item still reads the right one.\n */\n #resolveItem(): QtiAssessmentItem | null {\n if (this.#itemRef) return this.#itemRef.assessmentItem;\n const { item } = this.#activePosition();\n return item ? ((this._computedContext?.itemElement?.(item) as QtiAssessmentItem | null) ?? null) : null;\n }\n\n /** Update speech state on both the context (notifies children) and the host's CSS custom states. */\n #setSpeechState(state: SpeechState) {\n this._ttsContext = { ...this._ttsContext, state };\n this.#internals.states.delete('idle');\n this.#internals.states.delete('playing');\n this.#internals.states.delete('paused');\n this.#internals.states.add(state);\n }\n\n /** Push currentElementIndex and elementCount into context so children can react. */\n #updateContext() {\n this._ttsContext = {\n ...this._ttsContext,\n currentElementIndex: this.#currentElementIndex,\n elementCount: this.#getReadingElements().length\n };\n }\n\n /**\n * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on\n * first call), filtered live for visibility on every call. Feedback and other\n * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a\n * CSS custom state reveals it) is excluded while hidden and picked up again once shown,\n * without needing to re-collect the candidate set.\n */\n #getReadingElements(): Element[] {\n // Content mode has no events or observer telling it the content changed (a framework like\n // React re-renders it at will). Rebuild the list once an element in it has left the page;\n // text changed inside an element needs nothing, it is read when that element is spoken.\n if (this.#contentMode && this.#readingElements?.some(el => !el.isConnected)) {\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n }\n if (this.#readingElements === null) {\n const root = this.#resolveReadingRoot();\n // Leave the cache empty (rather than `[]`) while the item or stimulus has not rendered yet,\n // so the next call retries instead of getting stuck on an empty result forever.\n if (!root) return [];\n this.#readingRoot = root;\n\n // Collect block-level elements (and QTI prompt / choice elements) that contain readable text.\n // Keep only the innermost matches so `<li><p>…</p></li>` is not read twice. Content hidden\n // from assistive technology (`aria-hidden=\"true\"`, e.g. decorative icons) is not read either.\n const selector =\n 'p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice';\n this.#readingElements = Array.from(root.querySelectorAll(selector)).filter(\n el =>\n (el.textContent ?? '').trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden=\"true\"]')\n );\n }\n\n return this.#readingElements.filter(el => this.#isVisible(el));\n }\n\n /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */\n #isVisible(element: Element): boolean {\n if (typeof element.checkVisibility === 'function') {\n return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });\n }\n // Older Safari (< 17.4) fallback: display:none leaves no client rects. Doesn't catch\n // visibility:hidden, which still occupies layout, but display:none is what QTI feedback\n // elements actually use (see qti-feedback-block/qti-feedback-inline default styles).\n return element.getClientRects().length > 0;\n }\n\n /**\n * Resolve the speech language for a reading element.\n * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.\n * Empty `lang=\"\"` is treated as absent.\n */\n #resolveLang(element: Element): string {\n let node: Element | null = element;\n while (node) {\n const lang = node.getAttribute('lang') || node.getAttribute('xml:lang');\n if (lang?.trim()) return lang.trim();\n node = node.parentElement ?? (node.getRootNode() as ShadowRoot).host ?? null;\n }\n const documentLang = document.documentElement.getAttribute('lang');\n if (documentLang?.trim()) return documentLang.trim();\n return this.language;\n }\n\n #playSpeech() {\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stopPicking();\n // speechSynthesis is one global queue: another player mid-sentence would otherwise\n // finish first and this one would silently wait its turn.\n speechSynthesis.cancel();\n if (this.#finished) {\n this.#finished = false;\n this.#currentElementIndex = 0;\n }\n // Content mode: starting from the top rebuilds the list, so elements the page added since\n // the last read (a framework re-render) are included.\n if (this.#contentMode && this.#currentElementIndex === 0) this.#readingElements = null;\n this.#speakElement(this.#currentElementIndex);\n }\n\n /** Speak the element at the given index, then auto-advance when it ends. */\n #speakElement(index: number) {\n const elements = this.#getReadingElements();\n\n if (index >= elements.length) {\n // Finished all elements — stay on the last element so the user can walk back with prev\n this.#clearWordHighlight();\n this.#currentElementIndex = elements.length - 1;\n if (elements.length > 0) this.#highlightElement(elements[this.#currentElementIndex]);\n this.#finished = true;\n this.#setSpeechState('idle');\n this.#updateContext();\n return;\n }\n\n this.#currentElementIndex = index;\n this.#finished = false;\n this.#updateContext();\n\n const element = elements[index];\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(element);\n\n // Collect text nodes of this element for word-boundary mapping\n this.#textNodes = this.#collectTextNodes(element);\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n\n if (!text.trim()) {\n // Skip blank element and move to next\n this.#speakElement(index + 1);\n return;\n }\n\n const utterance = new SpeechSynthesisUtterance(text);\n utterance.lang = this.#resolveLang(element);\n utterance.rate = 1;\n\n utterance.onboundary = (event: SpeechSynthesisEvent) => {\n if (event.name !== 'word') return;\n this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);\n };\n\n utterance.onend = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearWordHighlight();\n this.#speakElement(this.#currentElementIndex + 1);\n };\n\n // Fires when speech is cancelled from outside this player (another player starting,\n // or the browser); a cancel we issued ourselves has already cleared #currentUtterance.\n utterance.onerror = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n };\n\n this.#currentUtterance = utterance;\n speechSynthesis.speak(utterance);\n this.#setSpeechState('playing');\n }\n\n #pause() {\n speechSynthesis.pause();\n this.#setSpeechState('paused');\n }\n\n #resume() {\n speechSynthesis.resume();\n this.#setSpeechState('playing');\n }\n\n #stop() {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n }\n\n // ─── Pick mode ────────────────────────────────────────────────────────────\n\n #togglePick() {\n if (this.#picking) this.#stopPicking();\n else this.#startPicking();\n }\n\n /** Highlight every reading element and wait for a click on one of them. */\n #startPicking() {\n // Content mode: pick from the page as it is now, like starting from the top does.\n if (this.#contentMode) this.#readingElements = null;\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stop();\n this.#picking = true;\n this.#internals.states.add('picking');\n this.#highlightElements(elements);\n // Listen on the item's root so the click is seen before any interaction handles it — in\n // pick mode a click on a choice picks the sentence, it does not answer the question.\n this.#pickRoot = elements[0].getRootNode();\n this.#pickRoot.addEventListener('click', this.#boundHandlePickClick, true);\n this._ttsContext = { ...this._ttsContext, picking: true };\n }\n\n #stopPicking() {\n if (!this.#picking) return;\n this.#picking = false;\n this.#internals.states.delete('picking');\n this.#pickRoot?.removeEventListener('click', this.#boundHandlePickClick, true);\n this.#pickRoot = null;\n this.#clearAllHighlights();\n this._ttsContext = { ...this._ttsContext, picking: false };\n }\n\n #handlePickClick(event: Event) {\n const elements = this.#getReadingElements();\n const path = event.composedPath();\n let index = elements.findIndex(el => path.includes(el));\n if (index < 0) {\n // Not on the text itself. A click on the choice or list item around it (its radio button,\n // the padding) still means \"this one\": take the first reading element inside it.\n const container = path.find(\n (node): node is Element => node instanceof Element && node.matches('qti-simple-choice, li, qti-prompt')\n );\n if (container) index = elements.findIndex(el => container.contains(el));\n }\n if (index < 0) return; // not on a highlighted element — stay in pick mode\n event.preventDefault();\n event.stopPropagation();\n this.#stopPicking();\n speechSynthesis.cancel();\n this.#speakElement(index);\n }\n\n #prevElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n #nextElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n /** Walk text nodes without crossing shadow DOM boundaries. */\n #collectTextNodes(root: Element): Text[] {\n const nodes: Text[] = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n let node: Node | null;\n while ((node = walker.nextNode())) {\n // Text hidden from assistive technology inside a read element — a decorative icon in a\n // list item — is not spoken either. Skipped here, so speech and word highlight agree.\n if ((node.textContent ?? '').length > 0 && !node.parentElement?.closest('[aria-hidden=\"true\"]')) {\n nodes.push(node as Text);\n }\n }\n return nodes;\n }\n\n /** Highlight the whole element as the navigation cursor (blue). */\n #highlightElement(element: Element) {\n this.#highlightElements([element]);\n }\n\n /** Put the blue cursor highlight on several elements at once (pick mode). */\n #highlightElements(elements: Element[]) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#elementHighlight.clear();\n for (const element of elements) {\n const range = new Range();\n range.selectNodeContents(element);\n this.#elementHighlight.add(range);\n }\n CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);\n }\n\n /** Highlight the current word within #textNodes (yellow, during speech). */\n #updateWordHighlight(charIndex: number, charLength: number) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#wordHighlight.clear();\n\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));\n let offset = 0;\n let startNode: Text | null = null;\n let startOffset = 0;\n let endNode: Text | null = null;\n let endOffset = 0;\n\n for (const node of this.#textNodes) {\n const len = node.textContent?.length ?? 0;\n if (!startNode && offset + len > charIndex) {\n startNode = node;\n startOffset = charIndex - offset;\n }\n if (startNode && offset + len >= endIndex) {\n endNode = node;\n endOffset = endIndex - offset;\n break;\n }\n offset += len;\n }\n\n if (startNode && endNode) {\n const range = new Range();\n range.setStart(startNode, startOffset);\n range.setEnd(endNode, endOffset);\n this.#wordHighlight.add(range);\n CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);\n }\n }\n\n #clearWordHighlight() {\n if (!('highlights' in CSS)) return;\n this.#wordHighlight.clear();\n // The registry is shared by every player on the page: only drop the entry if it is ours.\n if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight) CSS.highlights.delete(HIGHLIGHT_WORD);\n }\n\n #clearAllHighlights() {\n if (!('highlights' in CSS)) return;\n this.#clearWordHighlight();\n this.#elementHighlight.clear();\n if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight) CSS.highlights.delete(HIGHLIGHT_ELEMENT);\n }\n\n /** Fallback word-length when charLength is 0. */\n #wordLengthAt(charIndex: number, text: string): number {\n const right = text.slice(charIndex).search(/\\s/);\n return right < 0 ? text.length - charIndex : right;\n }\n\n /**\n * Add ::highlight() rules both to the shadow root the highlighted text lives in and to the\n * document (safety net — spec allows document rules to apply across shadow DOM). Called lazily\n * on first highlight use, once the reading elements have been collected.\n */\n #ensureHighlightStyles() {\n if (!('highlights' in CSS)) return;\n const sheet = getHighlightSheet();\n\n // 1. Document-level rule — applies broadly regardless of shadow DOM depth\n if (!document.adoptedStyleSheets.includes(sheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n }\n\n // 2. Shadow roots the highlighted text may live in: the item's (e.g. test-container's), and\n // the player's own root when the player itself sits inside a shadow tree (e.g. built into\n // an item card).\n const roots = new Set<ShadowRoot>();\n const ownRoot = this.getRootNode();\n if (ownRoot instanceof ShadowRoot) roots.add(ownRoot);\n const itemRoot = this.#readingElements?.[0]?.getRootNode();\n if (itemRoot instanceof ShadowRoot) roots.add(itemRoot);\n for (const root of roots) {\n if (!root.adoptedStyleSheets.includes(sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n }\n }\n }\n}\n\n// ─── Child control elements ───────────────────────────────────────────────────\n\n/**\n * Play/pause/resume toggle button — always enabled, cycles through states.\n * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and\n * `pause-label` name the button in each state (set them when the slotted content is an icon).\n *\n * @example\n * ```html\n * <test-tts-play>\n * <span slot=\"play\">Voorlezen</span>\n * <span slot=\"pause\">Pauzeren</span>\n * </test-tts-play>\n * ```\n *\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPlay extends TtsButtonBase {\n /** Accessible name of the button while speech is playing; see `label`. */\n @property({ type: String, attribute: 'pause-label' }) pauseLabel?: string;\n\n #toggle() {\n if (!this._tts) return;\n if (this._tts.state === 'idle') this._tts.play();\n else if (this._tts.state === 'playing') this._tts.pause();\n else this._tts.resume();\n }\n\n override render() {\n const playing = this._tts?.state === 'playing';\n return html`\n <button part=\"button\" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>\n ${playing\n ? html`<slot name=\"pause\">${iconContent('pause', this.pauseLabel ?? 'Pause')}</slot>`\n : html`<slot name=\"play\">${iconContent('play', this.label ?? 'Play')}</slot>`}\n </button>\n `;\n }\n}\n\n/**\n * Pause button — enabled only when playing.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPause extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'playing'}\n @click=${() => this._tts?.pause()}\n >\n <slot>${iconContent('pause', this.label ?? 'Pause')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Resume button — enabled only when paused.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsResume extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'paused'}\n @click=${() => this._tts?.resume()}\n >\n <slot>${iconContent('play', this.label ?? 'Resume')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsStop extends TtsButtonBase {\n override render() {\n const idle = this._tts?.state === 'idle' && !this._tts?.picking;\n return html`\n <button part=\"button\" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>\n <slot>${iconContent('stop', this.label ?? 'Stop')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Prev-element button — moves cursor to the previous reading element and pauses.\n * Disabled at the first element. Reading elements are collected lazily, so an element count\n * of 0 means \"not looked yet\" rather than \"nothing to read\": the button stays enabled and the\n * first click collects them.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPrev extends TtsButtonBase {\n override render() {\n const collected = (this._tts?.elementCount ?? 0) > 0;\n const atStart = (this._tts?.currentElementIndex ?? 0) === 0;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${collected && atStart}\n @click=${() => this._tts?.prevElement()}\n >\n <slot>${iconContent('prev', this.label ?? 'Previous sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Next-element button — moves cursor to the next reading element and pauses.\n * Disabled at the last element; enabled while the elements have not been collected yet\n * (see `TestTtsPrev`).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsNext extends TtsButtonBase {\n override render() {\n const count = this._tts?.elementCount ?? 0;\n const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${atEnd}\n @click=${() => this._tts?.nextElement()}\n >\n <slot>${iconContent('next', this.label ?? 'Next sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Pick button — toggles pick mode on the controller: every reading element is highlighted and\n * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.\n * @cssstate idle / playing / paused\n * @cssstate picking\n * @csspart button\n */\n\nexport class TestTtsPick extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n aria-pressed=${this._tts?.picking ? 'true' : 'false'}\n @click=${() => this._tts?.togglePick()}\n >\n <slot>${iconContent('pick', this.label ?? 'Read from here')}</slot>\n </button>\n `;\n }\n}\n\n// ─── Global type declarations ─────────────────────────────────────────────────\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-to-speech': TestItemToSpeech;\n 'test-tts-play': TestTtsPlay;\n 'test-tts-pause': TestTtsPause;\n 'test-tts-resume': TestTtsResume;\n 'test-tts-stop': TestTtsStop;\n 'test-tts-prev': TestTtsPrev;\n 'test-tts-next': TestTtsNext;\n 'test-tts-pick': TestTtsPick;\n }\n}\n"]}
1
+ {"version":3,"file":"test-item-to-speech.js","sourceRoot":"","sources":["../../src/tts/test-item-to-speech.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAO/C,iFAAiF;AAEjF,MAAM,iBAAiB,GAAG,aAAa,CAAC,CAAC,oCAAoC;AAC7E,MAAM,cAAc,GAAG,UAAU,CAAC,CAAC,8BAA8B;AAEjE,gGAAgG;AAChG,kGAAkG;AAClG,mGAAmG;AACnG,oGAAoG;AACpG,6BAA6B;AAC7B,IAAI,cAAc,GAAyB,IAAI,CAAC;AAEhD,SAAS,iBAAiB;IACxB,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC;QACrC,cAAc,CAAC,WAAW,CAAC;oBACX,iBAAiB;;;;oBAIjB,cAAc;;;;KAI7B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,cAAc,CAAC;AACxB,CAAC;AAyBD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAa,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;AAE3E,iFAAiF;AAEjF,6FAA6F;AAC7F,+FAA+F;AAC/F,gDAAgD;AAChD,MAAM,KAAK,GAAG;IAC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EAAE,UAAU,EAAE;;gBAE9B,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,gBAAgB,CAAC;;KAE9D,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { html, LitElement, css } from 'lit';\nimport { consume, provide, createContext } from '@lit/context';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nimport { computedContext } from '@qti-components/base';\n\nimport * as styles from '../components/styles';\n\nimport type { PropertyValues } from 'lit';\nimport type { ComputedContext } from '@qti-components/base';\nimport type { QtiAssessmentItem } from '@qti-components/elements';\nimport type { QtiAssessmentItemRef } from '../components/qti-assessment-item-ref/qti-assessment-item-ref';\n\n// ─── CSS Custom Highlight ─────────────────────────────────────────────────────\n\nconst HIGHLIGHT_ELEMENT = 'tts-element'; // navigation cursor — whole element\nconst HIGHLIGHT_WORD = 'tts-word'; // word boundary during speech\n\n// Shared across all instances — added to whichever shadow root needs it. The two highlights are\n// tints of the theme's info (the element being read) and warning (the word being spoken) colours,\n// see-through so the text and its own background stay visible. Without the theme they fall back to\n// the system Highlight and Mark colours. A host repaints them with --test-tts-element-highlight and\n// --test-tts-word-highlight.\nlet highlightSheet: CSSStyleSheet | null = null;\n\nfunction getHighlightSheet(): CSSStyleSheet {\n if (!highlightSheet) {\n highlightSheet = new CSSStyleSheet();\n highlightSheet.replaceSync(`\n ::highlight(${HIGHLIGHT_ELEMENT}) {\n background-color: var(--test-tts-element-highlight, color-mix(in oklab, var(--qti-color-info, var(--cito-color-info, Highlight)) 15%, transparent));\n color: inherit;\n }\n ::highlight(${HIGHLIGHT_WORD}) {\n background-color: var(--test-tts-word-highlight, color-mix(in oklab, var(--qti-color-warning, var(--cito-color-warning, Mark)) 55%, transparent));\n color: inherit;\n }\n `);\n }\n return highlightSheet;\n}\n\ntype SpeechState = 'idle' | 'playing' | 'paused';\n\n// ─── TTS Context ──────────────────────────────────────────────────────────────\n\nexport interface TtsContext {\n state: SpeechState;\n /** True while every reading element is highlighted and a click on one starts reading there. */\n picking: boolean;\n /** Index of the currently highlighted reading element (0-based). */\n currentElementIndex: number;\n /** Total number of navigable reading elements in the current item. */\n elementCount: number;\n play(): void;\n pause(): void;\n resume(): void;\n stop(): void;\n prevElement(): void;\n nextElement(): void;\n /** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */\n togglePick(): void;\n}\n\nexport { SpeechState };\nexport const ttsContext = createContext<TtsContext>(Symbol('tts-context'));\n\n// ─── Icons ────────────────────────────────────────────────────────────────────\n\n// Plain geometric glyphs on a 24-unit grid, painted in currentColor. SVG rather than text so\n// every button gets the same box: text glyphs (◀◀ ▶ ⏸ ■ ☞) differ in width, and some fall back\n// to an emoji font with different line metrics.\nconst ICONS = {\n play: 'M8 5v14l11-7z',\n pause: 'M6 5h4v14H6zM14 5h4v14h-4z',\n stop: 'M6 6h12v12H6z',\n prev: 'M6 5h2v14H6zM20 5v14L9 12z',\n next: 'M16 5h2v14h-2zM4 5v14l11-7z',\n pick: 'M5 3l13 7-5.5 1.6 3.4 6.6-2.4 1.3-3.4-6.7L6 17z'\n} as const;\n\n/** Default button content: the icon, plus a visually hidden label as the accessible name. */\nconst iconContent = (icon: keyof typeof ICONS, label: string) => {\n const svg = html`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n <path d=\"${ICONS[icon]}\"></path>\n </svg>`;\n return html`${svg}<span class=\"label\">${label}</span>`;\n};\n\n// ─── Shared base for child button elements ────────────────────────────────────\n\n/**\n * Base class shared by all TTS control elements. Consumes `ttsContext` and\n * mirrors the current speech state onto CSS custom states so each child can\n * be styled with `:state(playing)`, `:state(paused)`, `:state(idle)`.\n */\nabstract class TtsButtonBase extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n }\n button {\n ${styles.btn};\n min-inline-size: var(--test-button-size, 2.25rem);\n padding-inline: 0.5rem;\n /* Containing block for the visually hidden .label. Without it the label is placed against\n the nearest positioned ancestor, which can sit outside a scroll container and make the\n page as tall as the scrolled content. */\n position: relative;\n }\n @media (hover: hover) and (pointer: fine) {\n button:hover:not(:disabled) {\n ${styles.btnInteractive};\n }\n }\n button:active:not(:disabled) {\n ${styles.btnActive};\n }\n button:focus-visible {\n ${styles.focusRing};\n }\n button:disabled {\n ${styles.dis};\n }\n button[aria-pressed='true'],\n button[aria-pressed='true']:hover {\n background-color: var(--test-button-selected-background-color, var(--qti-selected-bg, Highlight));\n color: var(--test-button-selected-color, var(--qti-selected-color, HighlightText));\n }\n svg,\n ::slotted(svg) {\n flex: none;\n inline-size: var(--test-tts-icon-size, 1.125rem);\n block-size: var(--test-tts-icon-size, 1.125rem);\n }\n svg {\n fill: currentColor;\n }\n /* The default content is icon-only; this keeps the button's accessible name. */\n .label {\n position: absolute;\n inline-size: 1px;\n block-size: 1px;\n overflow: hidden;\n clip-path: inset(50%);\n white-space: nowrap;\n }\n `;\n\n /**\n * Accessible name of the button. Without it the default icon carries an English name, and\n * slotted content names the button by its text; set it when you slot an icon of your own,\n * which has no text to be named by.\n */\n @property({ type: String }) label?: string;\n\n #internals = this.attachInternals();\n\n @consume({ context: ttsContext, subscribe: true })\n protected _tts?: TtsContext;\n\n #mirroredState: SpeechState | undefined;\n #mirroredPicking = false;\n\n override updated(_changed: PropertyValues) {\n // `_tts` is a context field, not a reactive property, so it never shows up in `changed`:\n // compare against what was last mirrored instead.\n const state = this._tts?.state;\n const picking = this._tts?.picking ?? false;\n if (state === this.#mirroredState && picking === this.#mirroredPicking) return;\n this.#mirroredState = state;\n this.#mirroredPicking = picking;\n this.#internals.states.clear();\n if (state) this.#internals.states.add(state);\n if (picking) this.#internals.states.add('picking');\n }\n}\n\n// ─── Controller element ───────────────────────────────────────────────────────\n\n/**\n * `<test-item-to-speech>` is the controller and context provider. It manages\n * speech synthesis, word highlighting, and item element lookup. Compose your\n * own player by placing control elements as children.\n *\n * @example\n * ```html\n * <test-item-to-speech language=\"nl-NL\">\n * <test-tts-play></test-tts-play>\n * <test-tts-prev></test-tts-prev>\n * <test-tts-next></test-tts-next>\n * <test-tts-stop></test-tts-stop>\n * </test-item-to-speech>\n * ```\n *\n * The controller lays its controls out as a wrapping row; each control draws an icon button,\n * and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a\n * control with a slotted icon a `label`, since an icon has no text to name the button by. Buttons read the qti-theme tokens (with the theme's\n * defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.\n *\n * ### Language resolution\n *\n * Each reading element is spoken in the language of the nearest `lang` attribute:\n *\n * 1. `lang` (or `xml:lang`) on the element itself\n * 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across\n * shadow roots, anything wrapping the test\n * 3. `lang` on the document's `<html>` element\n * 4. the `language` attribute on `<test-item-to-speech>`\n *\n * The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with\n * `xml:lang=\"en-GB\"` on a `<p>` or on the item root is honoured without further work.\n *\n * ### What is read\n *\n * Decided once per connect, by where the player is placed. The first rule that matches wins:\n *\n * 1. **Next to a stimulus placeholder** — the player shares its parent with a\n * `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the\n * player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the\n * placeholder: loading a stimulus replaces the placeholder's content. Items and navigation\n * are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts\n * over on the new content.\n * 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked\n * `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes\n * on one container; the player reads the readable elements inside it. Navigation is ignored.\n * The reading list is rebuilt when the player starts from the top, and when an element in it\n * has left the page — so a re-render of the content never interrupts speech.\n * 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,\n * so every item gets a player of its own: the player reads that item, and only that item.\n * The navigation cursor is ignored; speech stops when the player leaves the page with its item.\n * 4. **Anywhere else inside `<test-navigation>`** — e.g. a toolbar: the player follows the\n * navigation cursor and reads the active item of the computed context. Navigating stops\n * speech and starts the next item from the top.\n *\n * ```html\n * <!-- 1. a player for the shared reading text -->\n * <aside>\n * <test-item-to-speech>…</test-item-to-speech>\n * <div data-stimulus-idref=\"Stimulus1\"></div>\n * </aside>\n *\n * <!-- 2. a player for any other HTML -->\n * <div>\n * <test-item-to-speech>…</test-item-to-speech>\n * <section data-tts-content lang=\"nl-NL\">…</section>\n * </div>\n *\n * <!-- 3. one player per item -->\n * <qti-test>\n * <template item-ref>\n * <test-item-to-speech>…</test-item-to-speech>\n * {{ xmlDoc }}\n * </template>\n * …\n * </qti-test>\n *\n * <!-- 4. one player in the toolbar, following navigation -->\n * <test-navigation>\n * <header><test-item-to-speech>…</test-item-to-speech></header>\n * <test-container test-url=\"…\"></test-container>\n * </test-navigation>\n * ```\n *\n * In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the\n * player on the fresh content. An item player reads the item body as rendered: a stimulus\n * placed inside the item is read with it, one placed outside (mode 1) is not. Only one player\n * can speak at a time; starting one stops any other.\n *\n * Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,\n * `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)\n * or inside `aria-hidden=\"true\"`.\n *\n * ### Starting somewhere in the middle\n *\n * `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue\n * cursor highlight, and the first click on one of them leaves pick mode and starts reading\n * from that element. Pressing the button again leaves pick mode without reading.\n *\n * @cssstate idle - No speech active\n * @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click\n * @cssstate playing - Speech is playing\n * @cssstate paused - Speech is paused\n */\n\nexport class TestItemToSpeech extends LitElement {\n static override styles = css`\n :host {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--test-tts-gap, 0.25rem);\n }\n `;\n\n /** Fallback language when neither the item content nor the document declares one. */\n @property({ type: String }) language = 'nl-NL';\n\n /**\n * The test as `test-navigation` computes it: which item is active, and where it is rendered\n * (`itemElement`). Updated on navigation and whenever an item is rendered.\n */\n @consume({ context: computedContext, subscribe: true })\n protected _computedContext?: ComputedContext;\n\n @state()\n @provide({ context: ttsContext })\n _ttsContext!: TtsContext;\n\n #internals = this.attachInternals();\n\n // Stimulus mode: set on connect when a stimulus placeholder sits next to the player. The\n // placeholder itself is looked up on every use — a host may swap the element.\n #stimulusMode = false;\n // Stimulus mode: resets the player when the stimulus content next to it is replaced.\n #stimulusObserver: MutationObserver | null = null;\n // Content mode: set on connect when a `[data-tts-content]` element sits next to the player.\n // Any HTML, not QTI. No observer: the reading list is rebuilt on demand (#getReadingElements).\n #contentMode = false;\n // Item-ref mode: the item-ref this player sits in, resolved on connect. Null means cursor mode.\n #itemRef: QtiAssessmentItemRef | null = null;\n // Item-ref mode: our item-ref, for its item-connected event. Cursor mode: where prev/next's\n // navigation request is heard.\n #eventHost: EventTarget | null = null;\n #boundHandleItemConnected = this.#handleItemConnected.bind(this);\n #boundHandleNavigation = () => this.#stop();\n\n // Cursor mode: the previous navigation position, to detect moving to another item or section.\n #prevNavItemRefId: string | null | undefined = undefined;\n #prevNavSectionId: string | null | undefined = undefined;\n\n // Current set of block-level reading elements for the item, and the root they were collected from\n #readingElements: Element[] | null = null;\n #readingRoot: Element | null = null;\n #currentElementIndex = 0;\n\n // Text nodes of the element currently being spoken (for word-boundary highlight)\n #textNodes: Text[] = [];\n\n // The utterance this player is speaking; lets the error handler tell \"our speech was\n // cancelled by another player\" apart from a cancel we issued ourselves.\n #currentUtterance: SpeechSynthesisUtterance | null = null;\n\n // Pick mode: all elements highlighted, a click on one starts reading from there.\n #picking = false;\n #pickRoot: EventTarget | null = null;\n #boundHandlePickClick = this.#handlePickClick.bind(this);\n\n // Set when the last element has been read: the cursor stays on it (so prev still works),\n // but the next play starts the item over instead of repeating that last element.\n #finished = false;\n\n // Two separate CSS Highlight objects\n #elementHighlight = new Highlight(); // whole-element cursor\n #wordHighlight = new Highlight(); // current word during speech\n\n constructor() {\n super();\n this._ttsContext = {\n state: 'idle',\n currentElementIndex: 0,\n elementCount: 0,\n play: () => this.#playSpeech(),\n pause: () => this.#pause(),\n resume: () => this.#resume(),\n stop: () => {\n this.#stopPicking();\n this.#stop();\n },\n prevElement: () => this.#prevElement(),\n nextElement: () => this.#nextElement(),\n togglePick: () => this.#togglePick(),\n picking: false\n };\n }\n\n // willUpdate, not updated: resetting writes _ttsContext, and state set here goes into the\n // render already under way instead of scheduling a second one (Lit's change-in-update).\n override willUpdate(changed: PropertyValues) {\n super.willUpdate(changed);\n // Stimulus, content and item-ref mode: the navigation cursor does not change what this player reads.\n if (this.#stimulusMode || this.#contentMode || this.#itemRef) return;\n // Cursor mode: moving to another item or section stops speech and starts over (ignore the\n // initial undefined → value transition). Section navigation leaves no item active, so it\n // needs its own check.\n const { item, section } = this.#activePosition();\n const itemChanged = this.#prevNavItemRefId !== undefined && this.#prevNavItemRefId !== item;\n const sectionChanged = this.#prevNavSectionId !== undefined && this.#prevNavSectionId !== section;\n // The same item rendered again (e.g. linking to the item already shown): the elements\n // collected earlier are detached. The context updates when an item renders, so check here.\n const rerendered =\n this.#readingElements !== null && this.#readingRoot !== null && this.#readingRoot !== this.#resolveReadingRoot();\n if (itemChanged || sectionChanged || rerendered) this.#resetReadingPosition();\n this.#prevNavItemRefId = item;\n this.#prevNavSectionId = section;\n }\n\n /** Stop speech and forget the collected reading elements, so the next play starts afresh. */\n #resetReadingPosition() {\n this.#stopPicking();\n this.#stop();\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n override connectedCallback() {\n super.connectedCallback();\n this.#setSpeechState('idle');\n // NOTE: #ensureHighlightStyles() is called lazily on first highlight use\n // because the item to read may not be in the DOM yet at this point.\n this.#stimulusMode = this.#stimulusPlaceholder() !== null;\n if (this.#stimulusMode) {\n // Stimulus mode: neither items nor navigation decide what is read, only the content of the\n // placeholder. qti-components replaces it whenever it loads a stimulus (innerHTML, then\n // append), so watch the parent — that also catches a host swapping the placeholder itself.\n this.#stimulusObserver = new MutationObserver(records => {\n if (records.some(record => !this.contains(record.target))) this.#handleStimulusReplaced();\n });\n this.#stimulusObserver.observe(this.parentElement!, { childList: true, subtree: true });\n return;\n }\n // Content mode: plain HTML next to the player. Nothing to listen for: what is read only\n // depends on that element, and the reading list is rebuilt when it goes stale.\n this.#contentMode = this.#contentElement() !== null;\n if (this.#contentMode) return;\n this.#itemRef = this.closest<QtiAssessmentItemRef>('qti-assessment-item-ref');\n if (this.#itemRef) {\n // Item-ref mode: qti-assessment-item-connected (bubbles+composed) passes our own item-ref\n // when our item renders again.\n this.#eventHost = this.#itemRef;\n this.#eventHost.addEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n } else {\n // Cursor mode: cito-test-navigate fires synchronously on prev/next — stop right away\n // instead of waiting for the new position to arrive through the computed context.\n this.#eventHost = this.closest('test-navigation') ?? (this.getRootNode() as EventTarget);\n this.#eventHost.addEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost.addEventListener('qti-request-navigation', this.#boundHandleNavigation); // deprecated name, still sent by hosts\n }\n }\n\n override disconnectedCallback() {\n super.disconnectedCallback();\n // Only silence the synthesizer if it is speaking for this player.\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#eventHost?.removeEventListener('qti-assessment-item-connected', this.#boundHandleItemConnected);\n this.#eventHost?.removeEventListener('cito-test-navigate', this.#boundHandleNavigation);\n this.#eventHost?.removeEventListener('qti-request-navigation', this.#boundHandleNavigation);\n this.#eventHost = null;\n this.#itemRef = null;\n this.#stimulusObserver?.disconnect();\n this.#stimulusObserver = null;\n this.#stimulusMode = false;\n this.#contentMode = false;\n }\n\n override render() {\n return html`<slot></slot>`;\n }\n\n /** Item-ref mode: our item rendered again, so the elements collected earlier are detached. */\n #handleItemConnected() {\n if (this.#readingElements !== null) this.#resetReadingPosition();\n }\n\n /** Cursor mode: the active item and section, from the computed context. */\n #activePosition(): { item: string | null; section: string | null } {\n for (const part of this._computedContext?.testParts ?? []) {\n for (const section of part.sections) {\n if (!section.active) continue;\n return { item: section.items.find(item => item.active)?.identifier ?? null, section: section.identifier };\n }\n }\n return { item: null, section: null };\n }\n\n /**\n * Stimulus mode: the stimulus next to the player was (re)loaded or swapped. Forget what was\n * collected, so the next play reads the new content from the top. Unlike\n * #resetReadingPosition this only cancels speech that is ours: a stimulus can finish loading\n * while an item player on the same page is speaking.\n */\n #handleStimulusReplaced() {\n if (this.#currentUtterance) {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n }\n this.#stopPicking();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n this.#updateContext();\n }\n\n /**\n * Stimulus mode: the `[data-stimulus-idref]` placeholder that shares this player's parent, or\n * null. A placeholder holds the stimulus once loaded; the player cannot sit inside it, because\n * loading replaces the placeholder's content.\n */\n #stimulusPlaceholder(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-stimulus-idref]') ?? null;\n }\n\n /**\n * Content mode: the `[data-tts-content]` element that shares this player's parent, or null.\n * The marker goes on one container; the player finds the readable elements inside it.\n */\n #contentElement(): Element | null {\n return this.parentElement?.querySelector(':scope > [data-tts-content]') ?? null;\n }\n\n /**\n * The element whose text is read: the stimulus body next to the player (stimulus mode), the\n * marked content next to it (content mode), or the item body of the item to read.\n */\n #resolveReadingRoot(): Element | null {\n if (this.#stimulusMode) return this.#stimulusPlaceholder()?.querySelector('qti-stimulus-body') ?? null;\n if (this.#contentMode) return this.#contentElement();\n return this.#resolveItem()?.querySelector('qti-item-body') ?? null;\n }\n\n /**\n * The item to read: our item-ref's (item-ref mode), or the active one (cursor mode). The test\n * looks the active one up in its own items (`computedContext.itemElement`), so a page with\n * several tests showing the same item still reads the right one.\n */\n #resolveItem(): QtiAssessmentItem | null {\n if (this.#itemRef) return this.#itemRef.assessmentItem;\n const { item } = this.#activePosition();\n return item ? ((this._computedContext?.itemElement?.(item) as QtiAssessmentItem | null) ?? null) : null;\n }\n\n /** Update speech state on both the context (notifies children) and the host's CSS custom states. */\n #setSpeechState(state: SpeechState) {\n this._ttsContext = { ...this._ttsContext, state };\n this.#internals.states.delete('idle');\n this.#internals.states.delete('playing');\n this.#internals.states.delete('paused');\n this.#internals.states.add(state);\n }\n\n /** Push currentElementIndex and elementCount into context so children can react. */\n #updateContext() {\n this._ttsContext = {\n ...this._ttsContext,\n currentElementIndex: this.#currentElementIndex,\n elementCount: this.#getReadingElements().length\n };\n }\n\n /**\n * Return the currently readable elements: cached candidates for the item or stimulus (collected lazily on\n * first call), filtered live for visibility on every call. Feedback and other\n * conditionally-shown content (e.g. `qti-feedback-block`, which is `display: none` until a\n * CSS custom state reveals it) is excluded while hidden and picked up again once shown,\n * without needing to re-collect the candidate set.\n */\n #getReadingElements(): Element[] {\n // Content mode has no events or observer telling it the content changed (a framework like\n // React re-renders it at will). Rebuild the list once an element in it has left the page;\n // text changed inside an element needs nothing, it is read when that element is spoken.\n if (this.#contentMode && this.#readingElements?.some(el => !el.isConnected)) {\n this.#readingElements = null;\n this.#currentElementIndex = 0;\n this.#finished = false;\n }\n if (this.#readingElements === null) {\n const root = this.#resolveReadingRoot();\n // Leave the cache empty (rather than `[]`) while the item or stimulus has not rendered yet,\n // so the next call retries instead of getting stuck on an empty result forever.\n if (!root) return [];\n this.#readingRoot = root;\n\n // Collect block-level elements (and QTI prompt / choice elements) that contain readable text.\n // Keep only the innermost matches so `<li><p>…</p></li>` is not read twice. Content hidden\n // from assistive technology (`aria-hidden=\"true\"`, e.g. decorative icons) is not read either.\n const selector =\n 'p, h1, h2, h3, h4, h5, h6, li, dt, dd, th, td, caption, blockquote, figcaption, qti-prompt, qti-simple-choice';\n this.#readingElements = Array.from(root.querySelectorAll(selector)).filter(\n el =>\n (el.textContent ?? '').trim().length > 0 && !el.querySelector(selector) && !el.closest('[aria-hidden=\"true\"]')\n );\n }\n\n return this.#readingElements.filter(el => this.#isVisible(el));\n }\n\n /** True when an element is actually rendered — not `display: none` (itself or an ancestor). */\n #isVisible(element: Element): boolean {\n if (typeof element.checkVisibility === 'function') {\n return element.checkVisibility({ checkOpacity: false, checkVisibilityCSS: true });\n }\n // Older Safari (< 17.4) fallback: display:none leaves no client rects. Doesn't catch\n // visibility:hidden, which still occupies layout, but display:none is what QTI feedback\n // elements actually use (see qti-feedback-block/qti-feedback-inline default styles).\n return element.getClientRects().length > 0;\n }\n\n /**\n * Resolve the speech language for a reading element.\n * Element `lang` → closest ancestor `lang` (crossing shadow hosts) → `<html lang>` → `language` attribute.\n * Empty `lang=\"\"` is treated as absent.\n */\n #resolveLang(element: Element): string {\n let node: Element | null = element;\n while (node) {\n const lang = node.getAttribute('lang') || node.getAttribute('xml:lang');\n if (lang?.trim()) return lang.trim();\n node = node.parentElement ?? (node.getRootNode() as ShadowRoot).host ?? null;\n }\n const documentLang = document.documentElement.getAttribute('lang');\n if (documentLang?.trim()) return documentLang.trim();\n return this.language;\n }\n\n #playSpeech() {\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stopPicking();\n // speechSynthesis is one global queue: another player mid-sentence would otherwise\n // finish first and this one would silently wait its turn.\n speechSynthesis.cancel();\n if (this.#finished) {\n this.#finished = false;\n this.#currentElementIndex = 0;\n }\n // Content mode: starting from the top rebuilds the list, so elements the page added since\n // the last read (a framework re-render) are included.\n if (this.#contentMode && this.#currentElementIndex === 0) this.#readingElements = null;\n this.#speakElement(this.#currentElementIndex);\n }\n\n /** Speak the element at the given index, then auto-advance when it ends. */\n #speakElement(index: number) {\n const elements = this.#getReadingElements();\n\n if (index >= elements.length) {\n // Finished all elements — stay on the last element so the user can walk back with prev\n this.#clearWordHighlight();\n this.#currentElementIndex = elements.length - 1;\n if (elements.length > 0) this.#highlightElement(elements[this.#currentElementIndex]);\n this.#finished = true;\n this.#setSpeechState('idle');\n this.#updateContext();\n return;\n }\n\n this.#currentElementIndex = index;\n this.#finished = false;\n this.#updateContext();\n\n const element = elements[index];\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(element);\n\n // Collect text nodes of this element for word-boundary mapping\n this.#textNodes = this.#collectTextNodes(element);\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n\n if (!text.trim()) {\n // Skip blank element and move to next\n this.#speakElement(index + 1);\n return;\n }\n\n const utterance = new SpeechSynthesisUtterance(text);\n utterance.lang = this.#resolveLang(element);\n utterance.rate = 1;\n\n utterance.onboundary = (event: SpeechSynthesisEvent) => {\n if (event.name !== 'word') return;\n this.#updateWordHighlight(event.charIndex, event.charLength ?? 0);\n };\n\n utterance.onend = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearWordHighlight();\n this.#speakElement(this.#currentElementIndex + 1);\n };\n\n // Fires when speech is cancelled from outside this player (another player starting,\n // or the browser); a cancel we issued ourselves has already cleared #currentUtterance.\n utterance.onerror = () => {\n if (this.#currentUtterance !== utterance) return;\n this.#currentUtterance = null;\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n };\n\n this.#currentUtterance = utterance;\n speechSynthesis.speak(utterance);\n this.#setSpeechState('playing');\n }\n\n #pause() {\n speechSynthesis.pause();\n this.#setSpeechState('paused');\n }\n\n #resume() {\n speechSynthesis.resume();\n this.#setSpeechState('playing');\n }\n\n #stop() {\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearAllHighlights();\n this.#setSpeechState('idle');\n }\n\n // ─── Pick mode ────────────────────────────────────────────────────────────\n\n #togglePick() {\n if (this.#picking) this.#stopPicking();\n else this.#startPicking();\n }\n\n /** Highlight every reading element and wait for a click on one of them. */\n #startPicking() {\n // Content mode: pick from the page as it is now, like starting from the top does.\n if (this.#contentMode) this.#readingElements = null;\n const elements = this.#getReadingElements();\n if (!elements.length) {\n console.warn('test-item-to-speech: no readable elements found');\n return;\n }\n this.#stop();\n this.#picking = true;\n this.#internals.states.add('picking');\n this.#highlightElements(elements);\n // Listen on the item's root so the click is seen before any interaction handles it — in\n // pick mode a click on a choice picks the sentence, it does not answer the question.\n this.#pickRoot = elements[0].getRootNode();\n this.#pickRoot.addEventListener('click', this.#boundHandlePickClick, true);\n this._ttsContext = { ...this._ttsContext, picking: true };\n }\n\n #stopPicking() {\n if (!this.#picking) return;\n this.#picking = false;\n this.#internals.states.delete('picking');\n this.#pickRoot?.removeEventListener('click', this.#boundHandlePickClick, true);\n this.#pickRoot = null;\n this.#clearAllHighlights();\n this._ttsContext = { ...this._ttsContext, picking: false };\n }\n\n #handlePickClick(event: Event) {\n const elements = this.#getReadingElements();\n const path = event.composedPath();\n let index = elements.findIndex(el => path.includes(el));\n if (index < 0) {\n // Not on the text itself. A click on the choice or list item around it (its radio button,\n // the padding) still means \"this one\": take the first reading element inside it.\n const container = path.find(\n (node): node is Element => node instanceof Element && node.matches('qti-simple-choice, li, qti-prompt')\n );\n if (container) index = elements.findIndex(el => container.contains(el));\n }\n if (index < 0) return; // not on a highlighted element — stay in pick mode\n event.preventDefault();\n event.stopPropagation();\n this.#stopPicking();\n speechSynthesis.cancel();\n this.#speakElement(index);\n }\n\n #prevElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.max(0, this.#currentElementIndex - 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n #nextElement() {\n const elements = this.#getReadingElements();\n if (!elements.length) return;\n this.#currentUtterance = null;\n speechSynthesis.cancel();\n this.#clearWordHighlight();\n this.#currentElementIndex = Math.min(elements.length - 1, this.#currentElementIndex + 1);\n this.#finished = false;\n this.#updateContext();\n const el = elements[this.#currentElementIndex];\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n this.#highlightElement(el);\n this.#setSpeechState('idle');\n }\n\n /** Walk text nodes without crossing shadow DOM boundaries. */\n #collectTextNodes(root: Element): Text[] {\n const nodes: Text[] = [];\n const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);\n let node: Node | null;\n while ((node = walker.nextNode())) {\n // Text hidden from assistive technology inside a read element — a decorative icon in a\n // list item — is not spoken either. Skipped here, so speech and word highlight agree.\n if ((node.textContent ?? '').length > 0 && !node.parentElement?.closest('[aria-hidden=\"true\"]')) {\n nodes.push(node as Text);\n }\n }\n return nodes;\n }\n\n /** Highlight the whole element as the navigation cursor (blue). */\n #highlightElement(element: Element) {\n this.#highlightElements([element]);\n }\n\n /** Put the blue cursor highlight on several elements at once (pick mode). */\n #highlightElements(elements: Element[]) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#elementHighlight.clear();\n for (const element of elements) {\n const range = new Range();\n range.selectNodeContents(element);\n this.#elementHighlight.add(range);\n }\n CSS.highlights.set(HIGHLIGHT_ELEMENT, this.#elementHighlight);\n }\n\n /** Highlight the current word within #textNodes (yellow, during speech). */\n #updateWordHighlight(charIndex: number, charLength: number) {\n if (!('highlights' in CSS)) return;\n this.#ensureHighlightStyles();\n this.#wordHighlight.clear();\n\n const text = this.#textNodes.map(n => n.textContent ?? '').join('');\n const endIndex = charIndex + (charLength > 0 ? charLength : this.#wordLengthAt(charIndex, text));\n let offset = 0;\n let startNode: Text | null = null;\n let startOffset = 0;\n let endNode: Text | null = null;\n let endOffset = 0;\n\n for (const node of this.#textNodes) {\n const len = node.textContent?.length ?? 0;\n if (!startNode && offset + len > charIndex) {\n startNode = node;\n startOffset = charIndex - offset;\n }\n if (startNode && offset + len >= endIndex) {\n endNode = node;\n endOffset = endIndex - offset;\n break;\n }\n offset += len;\n }\n\n if (startNode && endNode) {\n const range = new Range();\n range.setStart(startNode, startOffset);\n range.setEnd(endNode, endOffset);\n this.#wordHighlight.add(range);\n CSS.highlights.set(HIGHLIGHT_WORD, this.#wordHighlight);\n }\n }\n\n #clearWordHighlight() {\n if (!('highlights' in CSS)) return;\n this.#wordHighlight.clear();\n // The registry is shared by every player on the page: only drop the entry if it is ours.\n if (CSS.highlights.get(HIGHLIGHT_WORD) === this.#wordHighlight) CSS.highlights.delete(HIGHLIGHT_WORD);\n }\n\n #clearAllHighlights() {\n if (!('highlights' in CSS)) return;\n this.#clearWordHighlight();\n this.#elementHighlight.clear();\n if (CSS.highlights.get(HIGHLIGHT_ELEMENT) === this.#elementHighlight) CSS.highlights.delete(HIGHLIGHT_ELEMENT);\n }\n\n /** Fallback word-length when charLength is 0. */\n #wordLengthAt(charIndex: number, text: string): number {\n const right = text.slice(charIndex).search(/\\s/);\n return right < 0 ? text.length - charIndex : right;\n }\n\n /**\n * Add ::highlight() rules both to the shadow root the highlighted text lives in and to the\n * document (safety net — spec allows document rules to apply across shadow DOM). Called lazily\n * on first highlight use, once the reading elements have been collected.\n */\n #ensureHighlightStyles() {\n if (!('highlights' in CSS)) return;\n const sheet = getHighlightSheet();\n\n // 1. Document-level rule — applies broadly regardless of shadow DOM depth\n if (!document.adoptedStyleSheets.includes(sheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n }\n\n // 2. Shadow roots the highlighted text may live in: the item's (e.g. test-container's), and\n // the player's own root when the player itself sits inside a shadow tree (e.g. built into\n // an item card).\n const roots = new Set<ShadowRoot>();\n const ownRoot = this.getRootNode();\n if (ownRoot instanceof ShadowRoot) roots.add(ownRoot);\n const itemRoot = this.#readingElements?.[0]?.getRootNode();\n if (itemRoot instanceof ShadowRoot) roots.add(itemRoot);\n for (const root of roots) {\n if (!root.adoptedStyleSheets.includes(sheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];\n }\n }\n }\n}\n\n// ─── Child control elements ───────────────────────────────────────────────────\n\n/**\n * Play/pause/resume toggle button — always enabled, cycles through states.\n * Use named slots `play` and `pause` to customise the icons/labels independently; `label` and\n * `pause-label` name the button in each state (set them when the slotted content is an icon).\n *\n * @example\n * ```html\n * <test-tts-play>\n * <span slot=\"play\">Voorlezen</span>\n * <span slot=\"pause\">Pauzeren</span>\n * </test-tts-play>\n * ```\n *\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPlay extends TtsButtonBase {\n /** Accessible name of the button while speech is playing; see `label`. */\n @property({ type: String, attribute: 'pause-label' }) pauseLabel?: string;\n\n #toggle() {\n if (!this._tts) return;\n if (this._tts.state === 'idle') this._tts.play();\n else if (this._tts.state === 'playing') this._tts.pause();\n else this._tts.resume();\n }\n\n override render() {\n const playing = this._tts?.state === 'playing';\n return html`\n <button part=\"button\" aria-label=${ifDefined(playing ? this.pauseLabel : this.label)} @click=${this.#toggle}>\n ${playing\n ? html`<slot name=\"pause\">${iconContent('pause', this.pauseLabel ?? 'Pause')}</slot>`\n : html`<slot name=\"play\">${iconContent('play', this.label ?? 'Play')}</slot>`}\n </button>\n `;\n }\n}\n\n/**\n * Pause button — enabled only when playing.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPause extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'playing'}\n @click=${() => this._tts?.pause()}\n >\n <slot>${iconContent('pause', this.label ?? 'Pause')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Resume button — enabled only when paused.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsResume extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${this._tts?.state !== 'paused'}\n @click=${() => this._tts?.resume()}\n >\n <slot>${iconContent('play', this.label ?? 'Resume')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsStop extends TtsButtonBase {\n override render() {\n const idle = this._tts?.state === 'idle' && !this._tts?.picking;\n return html`\n <button part=\"button\" aria-label=${ifDefined(this.label)} ?disabled=${idle} @click=${() => this._tts?.stop()}>\n <slot>${iconContent('stop', this.label ?? 'Stop')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Prev-element button — moves cursor to the previous reading element and pauses.\n * Disabled at the first element. Reading elements are collected lazily, so an element count\n * of 0 means \"not looked yet\" rather than \"nothing to read\": the button stays enabled and the\n * first click collects them.\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsPrev extends TtsButtonBase {\n override render() {\n const collected = (this._tts?.elementCount ?? 0) > 0;\n const atStart = (this._tts?.currentElementIndex ?? 0) === 0;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${collected && atStart}\n @click=${() => this._tts?.prevElement()}\n >\n <slot>${iconContent('prev', this.label ?? 'Previous sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Next-element button — moves cursor to the next reading element and pauses.\n * Disabled at the last element; enabled while the elements have not been collected yet\n * (see `TestTtsPrev`).\n * @cssstate idle / playing / paused\n * @csspart button\n */\n\nexport class TestTtsNext extends TtsButtonBase {\n override render() {\n const count = this._tts?.elementCount ?? 0;\n const atEnd = count > 0 && (this._tts?.currentElementIndex ?? 0) >= count - 1;\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n ?disabled=${atEnd}\n @click=${() => this._tts?.nextElement()}\n >\n <slot>${iconContent('next', this.label ?? 'Next sentence')}</slot>\n </button>\n `;\n }\n}\n\n/**\n * Pick button — toggles pick mode on the controller: every reading element is highlighted and\n * a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.\n * @cssstate idle / playing / paused\n * @cssstate picking\n * @csspart button\n */\n\nexport class TestTtsPick extends TtsButtonBase {\n override render() {\n return html`\n <button\n part=\"button\"\n aria-label=${ifDefined(this.label)}\n aria-pressed=${this._tts?.picking ? 'true' : 'false'}\n @click=${() => this._tts?.togglePick()}\n >\n <slot>${iconContent('pick', this.label ?? 'Read from here')}</slot>\n </button>\n `;\n }\n}\n\n// ─── Global type declarations ─────────────────────────────────────────────────\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-item-to-speech': TestItemToSpeech;\n 'test-tts-play': TestTtsPlay;\n 'test-tts-pause': TestTtsPause;\n 'test-tts-resume': TestTtsResume;\n 'test-tts-stop': TestTtsStop;\n 'test-tts-prev': TestTtsPrev;\n 'test-tts-next': TestTtsNext;\n 'test-tts-pick': TestTtsPick;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@qti-components/test",
3
3
  "description": "QTI test utilities",
4
- "version": "2.0.0-next.8",
4
+ "version": "2.0.0-next.9",
5
5
  "author": "",
6
6
  "dependencies": {
7
7
  "@heximal/templates": "^0.1.5",
8
8
  "@qti-components/base": "^2.5.0-next.2",
9
9
  "@qti-components/elements": "^1.10.0-next.3",
10
- "@qti-components/interactions": "^1.10.5-next.3",
10
+ "@qti-components/interactions": "^1.10.5-next.4",
11
11
  "@qti-components/processing": "^1.6.1-next.2",
12
- "@qti-components/theme": "^2.3.0-next.1",
12
+ "@qti-components/theme": "^2.3.0-next.2",
13
13
  "@qti-components/transformers": "^1.7.3",
14
14
  "@qti-components/utilities": "^1.3.3"
15
15
  },