@qti-components/test 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.d.ts +12 -0
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +55 -28
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
- package/dist/components/qti-test/qti-test.d.ts +16 -2
- package/dist/components/qti-test/qti-test.js +33 -6
- package/dist/components/qti-test/qti-test.js.map +1 -1
- package/dist/components/styles.d.ts +3 -0
- package/dist/components/styles.js +29 -4
- package/dist/components/styles.js.map +1 -1
- package/dist/components/test-check-item/test-check-item.d.ts +2 -0
- package/dist/components/test-check-item/test-check-item.js +20 -2
- package/dist/components/test-check-item/test-check-item.js.map +1 -1
- package/dist/components/test-container/test-container.d.ts +3 -0
- package/dist/components/test-container/test-container.js +5 -1
- package/dist/components/test-container/test-container.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.js +6 -0
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-item-link/test-item-link.js +6 -0
- package/dist/components/test-item-link/test-item-link.js.map +1 -1
- package/dist/components/test-item-to-speech/test-item-to-speech.d.ts +128 -11
- package/dist/components/test-item-to-speech/test-item-to-speech.js +652 -103
- package/dist/components/test-item-to-speech/test-item-to-speech.js.map +1 -1
- package/dist/components/test-navigation/test-navigation.d.ts +9 -1
- package/dist/components/test-navigation/test-navigation.js +62 -17
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-next/test-next.js +6 -0
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-prev/test-prev.js +6 -0
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/components/test-scoring-buttons/test-scoring-buttons.d.ts +1 -1
- package/dist/components/test-section-link/test-section-link.js +6 -0
- package/dist/components/test-section-link/test-section-link.js.map +1 -1
- package/dist/elements.d.ts +5 -2
- package/dist/elements.js +3 -2
- package/dist/elements.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/test-host.context.d.ts +24 -0
- package/dist/internal/test-host.context.js +3 -0
- package/dist/internal/test-host.context.js.map +1 -0
- package/dist/mixins/index.d.ts +1 -0
- package/dist/mixins/index.js +1 -0
- package/dist/mixins/index.js.map +1 -1
- package/dist/mixins/test-base.d.ts +7 -2
- package/dist/mixins/test-base.js +53 -19
- package/dist/mixins/test-base.js.map +1 -1
- package/dist/mixins/test-navigation.mixin.d.ts +3 -4
- package/dist/mixins/test-navigation.mixin.js +11 -12
- package/dist/mixins/test-navigation.mixin.js.map +1 -1
- package/dist/mixins/test-processing.mixin.js +3 -1
- package/dist/mixins/test-processing.mixin.js.map +1 -1
- package/dist/mixins/test-state.mixin.d.ts +33 -0
- package/dist/mixins/test-state.mixin.js +130 -0
- package/dist/mixins/test-state.mixin.js.map +1 -0
- package/dist/types/iqti-test.d.ts +8 -5
- package/dist/types/iqti-test.js.map +1 -1
- package/dist/types/qti-test-state.d.ts +45 -0
- package/dist/types/qti-test-state.js +2 -0
- package/dist/types/qti-test-state.js.map +1 -0
- package/package.json +3 -3
|
@@ -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,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;AAIpC,MAAM,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IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QAED,IAAI,UAAU,CAAC,aAAa,KAAK,KAAK,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,KAAK,KAAK,IAAI,UAAU,CAAC,iBAAiB,CAAC;QACtF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACjC,CAAC;IACH,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AA/ES;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';\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 this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true }));\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 // 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"]}
|
|
@@ -12,6 +12,12 @@ export class TestItemLink extends LitElement {
|
|
|
12
12
|
:host {
|
|
13
13
|
${styles.btn};
|
|
14
14
|
}
|
|
15
|
+
:host(:hover:not([disabled])) {
|
|
16
|
+
${styles.btnInteractive};
|
|
17
|
+
}
|
|
18
|
+
:host(:focus-visible) {
|
|
19
|
+
${styles.focusRing};
|
|
20
|
+
}
|
|
15
21
|
:host([disabled]) {
|
|
16
22
|
${styles.dis};
|
|
17
23
|
}
|
|
@@ -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;AAEpC,MAAM,OAAO,YAAa,SAAQ,UAAU;aAC1B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,GAAG;;GAEf,
|
|
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;AAEpC,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,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,wBAAwB,EAAE;YACxC,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE,IAAI;YACb,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,EAAE,EAAE,UAAU;aACf;SACF,CAAC,CACH,CAAC;IACJ,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,iBAAiB,CAAC;IAC/B,CAAC;;AAtBO;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';\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 this.dispatchEvent(\n new CustomEvent('qti-request-navigation', {\n composed: true,\n bubbles: true,\n detail: {\n type: 'item',\n id: identifier\n }\n })\n );\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,9 +1,12 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
2
|
import type { PropertyValues } from 'lit';
|
|
3
3
|
import type { SessionContext } from '@qti-components/base';
|
|
4
|
+
import type { TestHost } from '../../internal/test-host.context';
|
|
4
5
|
type SpeechState = 'idle' | 'playing' | 'paused';
|
|
5
6
|
export interface TtsContext {
|
|
6
7
|
state: SpeechState;
|
|
8
|
+
/** True while every reading element is highlighted and a click on one starts reading there. */
|
|
9
|
+
picking: boolean;
|
|
7
10
|
/** Index of the currently highlighted reading element (0-based). */
|
|
8
11
|
currentElementIndex: number;
|
|
9
12
|
/** Total number of navigable reading elements in the current item. */
|
|
@@ -14,6 +17,8 @@ export interface TtsContext {
|
|
|
14
17
|
stop(): void;
|
|
15
18
|
prevElement(): void;
|
|
16
19
|
nextElement(): void;
|
|
20
|
+
/** Toggle pick mode: highlight all reading elements, then read from the one that is clicked. */
|
|
21
|
+
togglePick(): void;
|
|
17
22
|
}
|
|
18
23
|
export { SpeechState };
|
|
19
24
|
export declare const ttsContext: {
|
|
@@ -27,8 +32,14 @@ export declare const ttsContext: {
|
|
|
27
32
|
declare abstract class TtsButtonBase extends LitElement {
|
|
28
33
|
#private;
|
|
29
34
|
static styles: import("lit").CSSResult;
|
|
35
|
+
/**
|
|
36
|
+
* Accessible name of the button. Without it the default icon carries an English name, and
|
|
37
|
+
* slotted content names the button by its text; set it when you slot an icon of your own,
|
|
38
|
+
* which has no text to be named by.
|
|
39
|
+
*/
|
|
40
|
+
label?: string;
|
|
30
41
|
protected _tts?: TtsContext;
|
|
31
|
-
updated(
|
|
42
|
+
updated(_changed: PropertyValues): void;
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
34
45
|
* `<test-item-to-speech>` is the controller and context provider. It manages
|
|
@@ -39,37 +50,127 @@ declare abstract class TtsButtonBase extends LitElement {
|
|
|
39
50
|
* ```html
|
|
40
51
|
* <test-item-to-speech language="nl-NL">
|
|
41
52
|
* <test-tts-play></test-tts-play>
|
|
42
|
-
* <test-tts-prev
|
|
43
|
-
* <test-tts-next
|
|
44
|
-
* <test-tts-stop
|
|
53
|
+
* <test-tts-prev></test-tts-prev>
|
|
54
|
+
* <test-tts-next></test-tts-next>
|
|
55
|
+
* <test-tts-stop></test-tts-stop>
|
|
45
56
|
* </test-item-to-speech>
|
|
46
57
|
* ```
|
|
47
58
|
*
|
|
59
|
+
* The controller lays its controls out as a wrapping row; each control draws an icon button,
|
|
60
|
+
* and slotted content replaces the icon — a slotted `<svg>` is sized like the default one. Give a
|
|
61
|
+
* 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
|
|
62
|
+
* defaults as fallbacks) and can be sized with `--test-button-size` and `--test-tts-icon-size`.
|
|
63
|
+
*
|
|
64
|
+
* ### Language resolution
|
|
65
|
+
*
|
|
66
|
+
* Each reading element is spoken in the language of the nearest `lang` attribute:
|
|
67
|
+
*
|
|
68
|
+
* 1. `lang` (or `xml:lang`) on the element itself
|
|
69
|
+
* 2. `lang` on the closest ancestor — including `<qti-assessment-item xml:lang>` and, across
|
|
70
|
+
* shadow roots, anything wrapping the test
|
|
71
|
+
* 3. `lang` on the document's `<html>` element
|
|
72
|
+
* 4. the `language` attribute on `<test-item-to-speech>`
|
|
73
|
+
*
|
|
74
|
+
* The transformer copies `xml:lang` over as a plain `lang` attribute, so QTI authored with
|
|
75
|
+
* `xml:lang="en-GB"` on a `<p>` or on the item root is honoured without further work.
|
|
76
|
+
*
|
|
77
|
+
* ### What is read
|
|
78
|
+
*
|
|
79
|
+
* Decided once per connect, by where the player is placed. The first rule that matches wins:
|
|
80
|
+
*
|
|
81
|
+
* 1. **Next to a stimulus placeholder** — the player shares its parent with a
|
|
82
|
+
* `[data-stimulus-idref]` element, e.g. in a reading-text panel beside the questions: the
|
|
83
|
+
* player reads that stimulus (its `qti-stimulus-body`), and only that. Not inside the
|
|
84
|
+
* placeholder: loading a stimulus replaces the placeholder's content. Items and navigation
|
|
85
|
+
* are ignored; when the stimulus is (re)loaded or the placeholder swapped, the player starts
|
|
86
|
+
* over on the new content.
|
|
87
|
+
* 2. **Next to `[data-tts-content]`** — the player shares its parent with an element marked
|
|
88
|
+
* `data-tts-content`: any HTML, not QTI, e.g. a start screen rendered by React. The marker goes
|
|
89
|
+
* on one container; the player reads the readable elements inside it. Navigation is ignored.
|
|
90
|
+
* The reading list is rebuilt when the player starts from the top, and when an element in it
|
|
91
|
+
* has left the page — so a re-render of the content never interrupts speech.
|
|
92
|
+
* 3. **Inside a `qti-assessment-item-ref`** — e.g. in a `<template item-ref>` on `<qti-test>`,
|
|
93
|
+
* so every item gets a player of its own: the player reads that item, and only that item.
|
|
94
|
+
* The navigation cursor is ignored; speech stops when the player leaves the page with its item.
|
|
95
|
+
* 4. **Anywhere else** — a toolbar in the page chrome: the player follows the navigation cursor
|
|
96
|
+
* and reads the item `navItemRefId` (session context) points at, found in any
|
|
97
|
+
* `test-container` reachable from the player. Navigating stops speech and starts the next
|
|
98
|
+
* item from the top.
|
|
99
|
+
*
|
|
100
|
+
* ```html
|
|
101
|
+
* <!-- 1. a player for the shared reading text -->
|
|
102
|
+
* <aside>
|
|
103
|
+
* <test-item-to-speech>…</test-item-to-speech>
|
|
104
|
+
* <div data-stimulus-idref="Stimulus1"></div>
|
|
105
|
+
* </aside>
|
|
106
|
+
*
|
|
107
|
+
* <!-- 2. a player for any other HTML -->
|
|
108
|
+
* <div>
|
|
109
|
+
* <test-item-to-speech>…</test-item-to-speech>
|
|
110
|
+
* <section data-tts-content lang="nl-NL">…</section>
|
|
111
|
+
* </div>
|
|
112
|
+
*
|
|
113
|
+
* <!-- 3. one player per item -->
|
|
114
|
+
* <qti-test>
|
|
115
|
+
* <template item-ref>
|
|
116
|
+
* <test-item-to-speech>…</test-item-to-speech>
|
|
117
|
+
* {{ xmlDoc }}
|
|
118
|
+
* </template>
|
|
119
|
+
* …
|
|
120
|
+
* </qti-test>
|
|
121
|
+
*
|
|
122
|
+
* <!-- 4. one player in the toolbar, following navigation -->
|
|
123
|
+
* <test-navigation>
|
|
124
|
+
* <header><test-item-to-speech>…</test-item-to-speech></header>
|
|
125
|
+
* <test-container test-url="…"></test-container>
|
|
126
|
+
* </test-navigation>
|
|
127
|
+
* ```
|
|
128
|
+
*
|
|
129
|
+
* In modes 3 and 4 the item re-rendering (navigating to the item already shown) restarts the
|
|
130
|
+
* player on the fresh content. An item player reads the item body as rendered: a stimulus
|
|
131
|
+
* placed inside the item is read with it, one placed outside (mode 1) is not. Only one player
|
|
132
|
+
* can speak at a time; starting one stops any other.
|
|
133
|
+
*
|
|
134
|
+
* Read are `p`, `h1`–`h6`, `li`, `dt`, `dd`, `th`, `td`, `caption`, `blockquote`, `figcaption`,
|
|
135
|
+
* `qti-prompt` and `qti-simple-choice` — the innermost match only — unless hidden (`display: none`)
|
|
136
|
+
* or inside `aria-hidden="true"`.
|
|
137
|
+
*
|
|
138
|
+
* ### Starting somewhere in the middle
|
|
139
|
+
*
|
|
140
|
+
* `<test-tts-pick>` switches the player into pick mode: every reading element gets the blue
|
|
141
|
+
* cursor highlight, and the first click on one of them leaves pick mode and starts reading
|
|
142
|
+
* from that element. Pressing the button again leaves pick mode without reading.
|
|
143
|
+
*
|
|
48
144
|
* @cssstate idle - No speech active
|
|
145
|
+
* @cssstate picking - Pick mode: all reading elements highlighted, waiting for a click
|
|
49
146
|
* @cssstate playing - Speech is playing
|
|
50
147
|
* @cssstate paused - Speech is paused
|
|
51
148
|
*/
|
|
52
149
|
export declare class TestItemToSpeech extends LitElement {
|
|
53
150
|
#private;
|
|
151
|
+
static styles: import("lit").CSSResult;
|
|
152
|
+
/** Fallback language when neither the item content nor the document declares one. */
|
|
54
153
|
language: string;
|
|
55
154
|
protected _sessionContext?: SessionContext;
|
|
155
|
+
/** The `qti-test` this player is in, across shadow roots. */
|
|
156
|
+
protected testHost?: TestHost;
|
|
56
157
|
_ttsContext: TtsContext;
|
|
57
158
|
constructor();
|
|
58
159
|
willUpdate(changed: PropertyValues): void;
|
|
59
|
-
updated(_changed: PropertyValues): void;
|
|
60
160
|
connectedCallback(): void;
|
|
61
161
|
disconnectedCallback(): void;
|
|
62
162
|
render(): import("lit").TemplateResult<1>;
|
|
63
163
|
}
|
|
64
164
|
/**
|
|
65
165
|
* Play/pause/resume toggle button — always enabled, cycles through states.
|
|
66
|
-
* Use named slots `play` and `pause` to customise the icons/labels independently
|
|
166
|
+
* Use named slots `play` and `pause` to customise the icons/labels independently; `label` and
|
|
167
|
+
* `pause-label` name the button in each state (set them when the slotted content is an icon).
|
|
67
168
|
*
|
|
68
169
|
* @example
|
|
69
170
|
* ```html
|
|
70
171
|
* <test-tts-play>
|
|
71
|
-
* <span slot="play"
|
|
72
|
-
* <span slot="pause"
|
|
172
|
+
* <span slot="play">Voorlezen</span>
|
|
173
|
+
* <span slot="pause">Pauzeren</span>
|
|
73
174
|
* </test-tts-play>
|
|
74
175
|
* ```
|
|
75
176
|
*
|
|
@@ -78,6 +179,8 @@ export declare class TestItemToSpeech extends LitElement {
|
|
|
78
179
|
*/
|
|
79
180
|
export declare class TestTtsPlay extends TtsButtonBase {
|
|
80
181
|
#private;
|
|
182
|
+
/** Accessible name of the button while speech is playing; see `label`. */
|
|
183
|
+
pauseLabel?: string;
|
|
81
184
|
render(): import("lit").TemplateResult<1>;
|
|
82
185
|
}
|
|
83
186
|
/**
|
|
@@ -97,7 +200,7 @@ export declare class TestTtsResume extends TtsButtonBase {
|
|
|
97
200
|
render(): import("lit").TemplateResult<1>;
|
|
98
201
|
}
|
|
99
202
|
/**
|
|
100
|
-
* Stop button — enabled when playing or
|
|
203
|
+
* Stop button — enabled when playing, paused, or in pick mode (where it leaves pick mode).
|
|
101
204
|
* @cssstate idle / playing / paused
|
|
102
205
|
* @csspart button
|
|
103
206
|
*/
|
|
@@ -106,7 +209,9 @@ export declare class TestTtsStop extends TtsButtonBase {
|
|
|
106
209
|
}
|
|
107
210
|
/**
|
|
108
211
|
* Prev-element button — moves cursor to the previous reading element and pauses.
|
|
109
|
-
* Disabled at the first element
|
|
212
|
+
* Disabled at the first element. Reading elements are collected lazily, so an element count
|
|
213
|
+
* of 0 means "not looked yet" rather than "nothing to read": the button stays enabled and the
|
|
214
|
+
* first click collects them.
|
|
110
215
|
* @cssstate idle / playing / paused
|
|
111
216
|
* @csspart button
|
|
112
217
|
*/
|
|
@@ -115,13 +220,24 @@ export declare class TestTtsPrev extends TtsButtonBase {
|
|
|
115
220
|
}
|
|
116
221
|
/**
|
|
117
222
|
* Next-element button — moves cursor to the next reading element and pauses.
|
|
118
|
-
* Disabled at the last element
|
|
223
|
+
* Disabled at the last element; enabled while the elements have not been collected yet
|
|
224
|
+
* (see `TestTtsPrev`).
|
|
119
225
|
* @cssstate idle / playing / paused
|
|
120
226
|
* @csspart button
|
|
121
227
|
*/
|
|
122
228
|
export declare class TestTtsNext extends TtsButtonBase {
|
|
123
229
|
render(): import("lit").TemplateResult<1>;
|
|
124
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* Pick button — toggles pick mode on the controller: every reading element is highlighted and
|
|
233
|
+
* a click on one of them starts reading from there. Reflects the mode as `:state(picking)`.
|
|
234
|
+
* @cssstate idle / playing / paused
|
|
235
|
+
* @cssstate picking
|
|
236
|
+
* @csspart button
|
|
237
|
+
*/
|
|
238
|
+
export declare class TestTtsPick extends TtsButtonBase {
|
|
239
|
+
render(): import("lit").TemplateResult<1>;
|
|
240
|
+
}
|
|
125
241
|
declare global {
|
|
126
242
|
interface HTMLElementTagNameMap {
|
|
127
243
|
'test-item-to-speech': TestItemToSpeech;
|
|
@@ -131,5 +247,6 @@ declare global {
|
|
|
131
247
|
'test-tts-stop': TestTtsStop;
|
|
132
248
|
'test-tts-prev': TestTtsPrev;
|
|
133
249
|
'test-tts-next': TestTtsNext;
|
|
250
|
+
'test-tts-pick': TestTtsPick;
|
|
134
251
|
}
|
|
135
252
|
}
|