@qti-components/test 1.5.1 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js +0 -3
- package/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js.map +1 -1
- package/dist/components/qti-assessment-section/qti-assessment-section.js +0 -3
- package/dist/components/qti-assessment-section/qti-assessment-section.js.map +1 -1
- package/dist/components/qti-assessment-test/qti-assessment-test.js +3 -7
- package/dist/components/qti-assessment-test/qti-assessment-test.js.map +1 -1
- package/dist/components/qti-outcome-processing/qti-outcome-processing.js +2 -13
- package/dist/components/qti-outcome-processing/qti-outcome-processing.js.map +1 -1
- package/dist/components/qti-test/qti-test.d.ts +3 -1
- package/dist/components/qti-test/qti-test.js +3 -7
- package/dist/components/qti-test/qti-test.js.map +1 -1
- package/dist/components/qti-test-feedback/qti-test-feedback.d.ts +1 -1
- package/dist/components/qti-test-feedback/qti-test-feedback.js +3 -14
- package/dist/components/qti-test-feedback/qti-test-feedback.js.map +1 -1
- package/dist/components/qti-test-part/qti-test-part.js +3 -10
- package/dist/components/qti-test-part/qti-test-part.js.map +1 -1
- package/dist/components/qti-test-variables/qti-test-variables.js +0 -1
- package/dist/components/qti-test-variables/qti-test-variables.js.map +1 -1
- package/dist/components/test-check-item/test-check-item.js +2 -17
- 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 +26 -10
- package/dist/components/test-container/test-container.js.map +1 -1
- package/dist/components/test-end-attempt/test-end-attempt.js +2 -13
- package/dist/components/test-end-attempt/test-end-attempt.js.map +1 -1
- package/dist/components/test-item-link/test-item-link.js +3 -7
- 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 +135 -0
- package/dist/components/test-item-to-speech/test-item-to-speech.js +513 -0
- package/dist/components/test-item-to-speech/test-item-to-speech.js.map +1 -0
- package/dist/components/test-navigation/test-navigation.d.ts +8 -3
- package/dist/components/test-navigation/test-navigation.js +9 -33
- package/dist/components/test-navigation/test-navigation.js.map +1 -1
- package/dist/components/test-next/test-next.js +3 -7
- package/dist/components/test-next/test-next.js.map +1 -1
- package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js +2 -7
- package/dist/components/test-paging-buttons-stamp/test-paging-buttons-stamp.js.map +1 -1
- package/dist/components/test-prev/test-prev.d.ts +1 -1
- package/dist/components/test-prev/test-prev.js +3 -7
- package/dist/components/test-prev/test-prev.js.map +1 -1
- package/dist/components/test-print-context/test-print-context.js +3 -7
- package/dist/components/test-print-context/test-print-context.js.map +1 -1
- package/dist/components/test-print-item-variables/test-print-item-variables.js +2 -7
- package/dist/components/test-print-item-variables/test-print-item-variables.js.map +1 -1
- package/dist/components/test-scoring-buttons/test-scoring-buttons.js +3 -7
- package/dist/components/test-scoring-buttons/test-scoring-buttons.js.map +1 -1
- package/dist/components/test-scoring-feedback/test-scoring-feedback.js +3 -7
- package/dist/components/test-scoring-feedback/test-scoring-feedback.js.map +1 -1
- package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js +2 -7
- package/dist/components/test-section-buttons-stamp/test-section-buttons-stamp.js.map +1 -1
- package/dist/components/test-section-link/test-section-link.js +3 -7
- package/dist/components/test-section-link/test-section-link.js.map +1 -1
- package/dist/components/test-stamp/test-stamp.js +3 -7
- package/dist/components/test-stamp/test-stamp.js.map +1 -1
- package/dist/components/test-view-toggle/test-view-toggle.js +2 -7
- package/dist/components/test-view-toggle/test-view-toggle.js.map +1 -1
- package/dist/components/test-view-toggle/test-view.js +7 -12
- package/dist/components/test-view-toggle/test-view.js.map +1 -1
- package/dist/elements.d.ts +124 -0
- package/dist/elements.js +62 -0
- package/dist/elements.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mixins/test-navigation.mixin.js +8 -2
- package/dist/mixins/test-navigation.mixin.js.map +1 -1
- package/dist/mixins/test-view.mixin.d.ts +3 -0
- package/dist/mixins/test-view.mixin.js +5 -4
- package/dist/mixins/test-view.mixin.js.map +1 -1
- package/dist/register.d.ts +1 -0
- package/dist/register.js +7 -0
- package/dist/register.js.map +1 -0
- package/dist/types/iqti-test.d.ts +2 -1
- package/dist/types/iqti-test.js.map +1 -1
- package/package.json +24 -7
- package/dist/components/test-show-correct-response/test-show-correct-response.d.ts +0 -22
- package/dist/components/test-show-correct-response/test-show-correct-response.js +0 -91
- package/dist/components/test-show-correct-response/test-show-correct-response.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-container.js","sourceRoot":"","sources":["../../../src/components/test-container/test-container.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"test-container.js","sourceRoot":"","sources":["../../../src/components/test-container/test-container.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,uDAAuD;AACvD,OAAO,OAAO,MAAM,2CAA2C,CAAC;AAIhE;;;;;;;;;;;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,EAAE,IAAI,EAAE,CAAC;wDAuBhD;AAGS;IADT,KAAK,CAAC,SAAS,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC;wDAYhD","sourcesContent":["import { consume } from '@lit/context';\nimport { LitElement, html } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { until } from 'lit/directives/until.js';\n\nimport { qtiContext } from '@qti-components/base';\nimport { watch } from '@qti-components/utilities';\nimport { qtiTransformTest } from '@qti-components/transformers';\n\n// eslint-disable-next-line import/no-relative-packages\nimport itemCss from '../../../../qti-theme/src/item.css?inline';\n\nimport type { QtiContext } from '@qti-components/base';\n\n/**\n * `<test-container>` is a custom element designed for hosting the qti-assessment-item.\n * The `qti-assessment-test` will be placed inside the shadow DOM of this element.\n * The element loads the test from the provided URL and renders it inside the shadow DOM.\n *\n * ```html\n * <qti-test>\n * <test-navigation>\n * <test-container class=\"m-4 bg-white\" test-url=\"./path/to/assessmenttest.xml\"></test-container>\n * </test-navigation>\n * </qti-test>\n * ```\n */\n\nexport class TestContainer extends LitElement {\n /** Scoped registry used by the test shadow root. Must be set before connection. */\n @property({ attribute: false })\n customElementRegistry: CustomElementRegistry | null = null;\n\n /** URL of the item to load */\n @property({ type: String, attribute: 'test-url' })\n testURL: string = null;\n\n /** A parsed HTML document */\n @state()\n testDoc: DocumentFragment = null;\n\n /** The raw XML string */\n @state()\n testXML: string = null;\n\n @state()\n @consume({ context: qtiContext, subscribe: true })\n protected qtiContext: QtiContext = {\n QTI_CONTEXT: { testIdentifier: '', candidateIdentifier: '', environmentIdentifier: 'default' }\n };\n\n /** Template content if provided */\n #templateContent: unknown = null;\n #resolvedCustomElementRegistry: CustomElementRegistry | null = null;\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const registry = this.customElementRegistry;\n\n this.#resolvedCustomElementRegistry = registry;\n\n return (\n this.shadowRoot ??\n this.attachShadow({\n ...(this.constructor as typeof TestContainer).shadowRootOptions,\n ...(registry ? { customElementRegistry: registry } : {})\n })\n );\n }\n\n /** Callback function to transform the test after loading */\n // @property({ type: Function }) postLoadTestTransformCallback: PostLoadTestTransformCallback | null = null;\n\n @watch('testURL', { waitUntilFirstUpdate: true })\n protected async handleTestURLChange() {\n if (!this.testURL) return;\n try {\n const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;\n let api = (await qtiTransformTest().load(this.testURL)).shuffleOrdering(explicitSeed);\n // Apply external transformation if provided\n const qtiTest = this.closest('qti-test') as any; // Type assertion to access mixin properties\n if (qtiTest?.postLoadTestTransformCallback) {\n // Create a temporary document to get the test element reference\n const tempDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n const testElement = tempDoc.querySelector('qti-assessment-test') as any;\n\n if (testElement) {\n // Apply the callback with the test element\n api = await qtiTest.postLoadTestTransformCallback(api, testElement);\n }\n }\n\n this.testDoc = api.htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n } catch (error) {\n console.error('Error loading or parsing XML:', error);\n }\n }\n\n @watch('testXML', { waitUntilFirstUpdate: true })\n protected handleTestXMLChange() {\n if (!this.testXML) return;\n try {\n const explicitSeed = this.qtiContext?.QTI_CONTEXT?.seed;\n this.testDoc = qtiTransformTest()\n .parse(this.testXML)\n .shuffleOrdering(explicitSeed)\n .htmlDoc(this.#resolvedCustomElementRegistry ?? undefined);\n } catch (error) {\n console.error('Error parsing XML:', error);\n }\n }\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n this.#initializeTemplateContent();\n this.#applyStyles();\n if (this.testURL) {\n this.handleTestURLChange();\n }\n if (this.testXML) {\n this.handleTestXMLChange();\n }\n }\n\n #initializeTemplateContent() {\n const template = this.querySelector('template') as HTMLTemplateElement;\n this.#templateContent = template ? template.content : html``;\n }\n\n #applyStyles() {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(itemCss);\n this.shadowRoot.adoptedStyleSheets = [sheet];\n }\n\n override render() {\n return html`\n ${this.#templateContent}\n <slot></slot>\n ${until(this.testDoc, html`<span>Loading...</span>`)}\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'test-container': TestContainer;\n }\n}\n"]}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
1
|
import { css, html, LitElement } from 'lit';
|
|
8
|
-
import { customElement } from 'lit/decorators.js';
|
|
9
2
|
import * as styles from '../styles';
|
|
10
|
-
|
|
3
|
+
export class TestEndAttempt extends LitElement {
|
|
11
4
|
static { this.styles = css `
|
|
12
5
|
:host {
|
|
13
6
|
${styles.btn};
|
|
@@ -23,9 +16,5 @@ let TestEndAttempt = class TestEndAttempt extends LitElement {
|
|
|
23
16
|
render() {
|
|
24
17
|
return html ` <slot></slot> `;
|
|
25
18
|
}
|
|
26
|
-
}
|
|
27
|
-
TestEndAttempt = __decorate([
|
|
28
|
-
customElement('test-end-attempt')
|
|
29
|
-
], TestEndAttempt);
|
|
30
|
-
export { TestEndAttempt };
|
|
19
|
+
}
|
|
31
20
|
//# sourceMappingURL=test-end-attempt.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-end-attempt.js","sourceRoot":"","sources":["../../../src/components/test-end-attempt/test-end-attempt.ts"],"names":[],"mappings":"
|
|
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;AAE5C,OAAO,KAAK,MAAM,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,cAAe,SAAQ,UAAU;aAC5B,WAAM,GAAG,GAAG,CAAA;;QAEtB,MAAM,CAAC,GAAG;;;QAGV,MAAM,CAAC,GAAG;;GAEf,CAAC;IAEF;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH,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';\n\nexport class TestEndAttempt extends LitElement {\n static override styles = css`\n :host {\n ${styles.btn};\n }\n :host([disabled]) {\n ${styles.dis};\n }\n `;\n\n constructor() {\n super();\n this.addEventListener('click', () => this.dispatchEvent(new CustomEvent('test-end-attempt', { bubbles: true })));\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"]}
|
|
@@ -5,9 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { css, html, LitElement } from 'lit';
|
|
8
|
-
import {
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
9
|
import * as styles from '../styles';
|
|
10
|
-
|
|
10
|
+
export class TestItemLink extends LitElement {
|
|
11
11
|
static { this.styles = css `
|
|
12
12
|
:host {
|
|
13
13
|
${styles.btn};
|
|
@@ -34,12 +34,8 @@ let TestItemLink = class TestItemLink extends LitElement {
|
|
|
34
34
|
render() {
|
|
35
35
|
return html ` <slot></slot> `;
|
|
36
36
|
}
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
__decorate([
|
|
39
39
|
property({ type: String, attribute: 'item-id' })
|
|
40
40
|
], TestItemLink.prototype, "itemId", void 0);
|
|
41
|
-
TestItemLink = __decorate([
|
|
42
|
-
customElement('test-item-link')
|
|
43
|
-
], TestItemLink);
|
|
44
|
-
export { TestItemLink };
|
|
45
41
|
//# sourceMappingURL=test-item-link.js.map
|
|
@@ -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,
|
|
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,AAPqB,CAOpB;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([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"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { PropertyValues } from 'lit';
|
|
3
|
+
import type { SessionContext } from '@qti-components/base';
|
|
4
|
+
type SpeechState = 'idle' | 'playing' | 'paused';
|
|
5
|
+
export interface TtsContext {
|
|
6
|
+
state: SpeechState;
|
|
7
|
+
/** Index of the currently highlighted reading element (0-based). */
|
|
8
|
+
currentElementIndex: number;
|
|
9
|
+
/** Total number of navigable reading elements in the current item. */
|
|
10
|
+
elementCount: number;
|
|
11
|
+
play(): void;
|
|
12
|
+
pause(): void;
|
|
13
|
+
resume(): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
prevElement(): void;
|
|
16
|
+
nextElement(): void;
|
|
17
|
+
}
|
|
18
|
+
export { SpeechState };
|
|
19
|
+
export declare const ttsContext: {
|
|
20
|
+
__context__: TtsContext;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Base class shared by all TTS control elements. Consumes `ttsContext` and
|
|
24
|
+
* mirrors the current speech state onto CSS custom states so each child can
|
|
25
|
+
* be styled with `:state(playing)`, `:state(paused)`, `:state(idle)`.
|
|
26
|
+
*/
|
|
27
|
+
declare abstract class TtsButtonBase extends LitElement {
|
|
28
|
+
#private;
|
|
29
|
+
static styles: import("lit").CSSResult;
|
|
30
|
+
protected _tts?: TtsContext;
|
|
31
|
+
updated(changed: PropertyValues): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `<test-item-to-speech>` is the controller and context provider. It manages
|
|
35
|
+
* speech synthesis, word highlighting, and item element lookup. Compose your
|
|
36
|
+
* own player by placing control elements as children.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```html
|
|
40
|
+
* <test-item-to-speech language="nl-NL">
|
|
41
|
+
* <test-tts-play></test-tts-play>
|
|
42
|
+
* <test-tts-prev>◀◀</test-tts-prev>
|
|
43
|
+
* <test-tts-next>▶▶</test-tts-next>
|
|
44
|
+
* <test-tts-stop>■</test-tts-stop>
|
|
45
|
+
* </test-item-to-speech>
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @cssstate idle - No speech active
|
|
49
|
+
* @cssstate playing - Speech is playing
|
|
50
|
+
* @cssstate paused - Speech is paused
|
|
51
|
+
*/
|
|
52
|
+
export declare class TestItemToSpeech extends LitElement {
|
|
53
|
+
#private;
|
|
54
|
+
language: string;
|
|
55
|
+
protected _sessionContext?: SessionContext;
|
|
56
|
+
_ttsContext: TtsContext;
|
|
57
|
+
constructor();
|
|
58
|
+
willUpdate(changed: PropertyValues): void;
|
|
59
|
+
updated(_changed: PropertyValues): void;
|
|
60
|
+
connectedCallback(): void;
|
|
61
|
+
disconnectedCallback(): void;
|
|
62
|
+
render(): import("lit").TemplateResult<1>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Play/pause/resume toggle button — always enabled, cycles through states.
|
|
66
|
+
* Use named slots `play` and `pause` to customise the icons/labels independently.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```html
|
|
70
|
+
* <test-tts-play>
|
|
71
|
+
* <span slot="play">▶ Play</span>
|
|
72
|
+
* <span slot="pause">⏸ Pause</span>
|
|
73
|
+
* </test-tts-play>
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @cssstate idle / playing / paused
|
|
77
|
+
* @csspart button
|
|
78
|
+
*/
|
|
79
|
+
export declare class TestTtsPlay extends TtsButtonBase {
|
|
80
|
+
#private;
|
|
81
|
+
render(): import("lit").TemplateResult<1>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Pause button — enabled only when playing.
|
|
85
|
+
* @cssstate idle / playing / paused
|
|
86
|
+
* @csspart button
|
|
87
|
+
*/
|
|
88
|
+
export declare class TestTtsPause extends TtsButtonBase {
|
|
89
|
+
render(): import("lit").TemplateResult<1>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Resume button — enabled only when paused.
|
|
93
|
+
* @cssstate idle / playing / paused
|
|
94
|
+
* @csspart button
|
|
95
|
+
*/
|
|
96
|
+
export declare class TestTtsResume extends TtsButtonBase {
|
|
97
|
+
render(): import("lit").TemplateResult<1>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Stop button — enabled when playing or paused.
|
|
101
|
+
* @cssstate idle / playing / paused
|
|
102
|
+
* @csspart button
|
|
103
|
+
*/
|
|
104
|
+
export declare class TestTtsStop extends TtsButtonBase {
|
|
105
|
+
render(): import("lit").TemplateResult<1>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Prev-element button — moves cursor to the previous reading element and pauses.
|
|
109
|
+
* Disabled at the first element or when no elements are loaded.
|
|
110
|
+
* @cssstate idle / playing / paused
|
|
111
|
+
* @csspart button
|
|
112
|
+
*/
|
|
113
|
+
export declare class TestTtsPrev extends TtsButtonBase {
|
|
114
|
+
render(): import("lit").TemplateResult<1>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Next-element button — moves cursor to the next reading element and pauses.
|
|
118
|
+
* Disabled at the last element or when no elements are loaded.
|
|
119
|
+
* @cssstate idle / playing / paused
|
|
120
|
+
* @csspart button
|
|
121
|
+
*/
|
|
122
|
+
export declare class TestTtsNext extends TtsButtonBase {
|
|
123
|
+
render(): import("lit").TemplateResult<1>;
|
|
124
|
+
}
|
|
125
|
+
declare global {
|
|
126
|
+
interface HTMLElementTagNameMap {
|
|
127
|
+
'test-item-to-speech': TestItemToSpeech;
|
|
128
|
+
'test-tts-play': TestTtsPlay;
|
|
129
|
+
'test-tts-pause': TestTtsPause;
|
|
130
|
+
'test-tts-resume': TestTtsResume;
|
|
131
|
+
'test-tts-stop': TestTtsStop;
|
|
132
|
+
'test-tts-prev': TestTtsPrev;
|
|
133
|
+
'test-tts-next': TestTtsNext;
|
|
134
|
+
}
|
|
135
|
+
}
|