@citolab/qti-components 10.0.0-next.15 → 10.0.0-next.17

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 (84) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +1503 -2931
  3. package/dist/base.d.ts +37 -11
  4. package/dist/base.js +8 -1
  5. package/dist/{chunk-G2EIC7H2.js → chunk-7MYZHZWV.js} +955 -364
  6. package/dist/chunk-7MYZHZWV.js.map +1 -0
  7. package/dist/chunk-DJ7PB252.js +7 -0
  8. package/dist/chunk-DJ7PB252.js.map +1 -0
  9. package/dist/{chunk-F553IZPL.js → chunk-J3F3JSCW.js} +2 -2
  10. package/dist/chunk-J6VX4N7M.js +197 -0
  11. package/dist/chunk-J6VX4N7M.js.map +1 -0
  12. package/dist/{chunk-32PI7KWX.js → chunk-L3LBSAGZ.js} +2 -2
  13. package/dist/{chunk-WIUPAUJV.js → chunk-L7J2ZOJL.js} +2 -2
  14. package/dist/{chunk-IM5AKPIJ.js → chunk-NZ7ZC4SP.js} +96 -4
  15. package/dist/chunk-NZ7ZC4SP.js.map +1 -0
  16. package/dist/{chunk-XY5DHYIH.js → chunk-OG5HIRHE.js} +3 -3
  17. package/dist/chunk-PZ5AY32C.js +10 -0
  18. package/dist/chunk-PZ5AY32C.js.map +1 -0
  19. package/dist/{chunk-HT3LSWXL.js → chunk-QLGUI5VG.js} +2 -2
  20. package/dist/chunk-UCXLDQYA.js +56 -0
  21. package/dist/chunk-UCXLDQYA.js.map +1 -0
  22. package/dist/{chunk-5AJZGRWI.js → chunk-UDJ7MHLF.js} +4 -4
  23. package/dist/chunk-UDJ7MHLF.js.map +1 -0
  24. package/dist/{chunk-MIQZBDTB.js → chunk-UURHLJVM.js} +107 -1809
  25. package/dist/chunk-UURHLJVM.js.map +1 -0
  26. package/dist/{chunk-IWNRQVNW.js → chunk-V5GL7PTC.js} +2 -2
  27. package/dist/{chunk-QT7WQXCS.js → chunk-WGUQCB2Z.js} +28 -82
  28. package/dist/chunk-WGUQCB2Z.js.map +1 -0
  29. package/dist/chunk-WWY2H2YO.js +7 -0
  30. package/dist/chunk-WWY2H2YO.js.map +1 -0
  31. package/dist/{chunk-URYYGVTA.js → chunk-ZAHZVBV7.js} +60 -75
  32. package/dist/chunk-ZAHZVBV7.js.map +1 -0
  33. package/dist/{computed.types.d-IXACuBr7.d.ts → computed.types.d-D4wskgi0.d.ts} +2 -2
  34. package/dist/corrections.d.ts +123 -20
  35. package/dist/corrections.js +11 -11
  36. package/dist/corrections.js.map +1 -1
  37. package/dist/elements.d.ts +35 -112
  38. package/dist/elements.js +8 -5
  39. package/dist/index.d.ts +18 -14
  40. package/dist/index.js +29 -63
  41. package/dist/interactions.d.ts +84 -17
  42. package/dist/interactions.js +4 -3
  43. package/dist/item.css +1057 -2383
  44. package/dist/item.d.ts +6 -4
  45. package/dist/item.js +5 -4
  46. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  47. package/dist/loader.d.ts +4 -2
  48. package/dist/loader.js +1 -0
  49. package/dist/processing.d.ts +4 -3
  50. package/dist/processing.js +4 -3
  51. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  52. package/dist/qti-components-jsx.d.ts +4058 -4421
  53. package/dist/{qti-condition-expression.d-B-T1NNl0.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  54. package/dist/{qti-expression.d-B-Cfbqlb.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  55. package/dist/{qti-feedback.d-GAqMqAt6.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +2 -2
  56. package/dist/{qti-item.d-pFcNk0th.d.ts → qti-item.d-CLChmRvB.d.ts} +2 -1
  57. package/dist/qti-test-state-BAf5AmJ2.d.ts +68 -0
  58. package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
  59. package/dist/{qti-test.d-BjhVQnQy.d.ts → qti-test.d-COzv7YZG.d.ts} +14 -548
  60. package/dist/{qti-text-entry-interaction.d-DECzpIzi.d.ts → qti-text-entry-interaction.d-DsUyecBC.d.ts} +144 -43
  61. package/dist/{record.d-CljDLwRz.d.ts → record.d-BfZhFr0L.d.ts} +34 -3
  62. package/dist/{session.context.d-DW09Lrie.d.ts → session.context.d-9gRdGK4T.d.ts} +2 -2
  63. package/dist/test-plugin-api.d.ts +134 -0
  64. package/dist/test-plugin-api.js +19 -0
  65. package/dist/test-plugin-api.js.map +1 -0
  66. package/dist/test.d.ts +16 -158
  67. package/dist/test.js +13 -52
  68. package/dist/transformers.js +1 -0
  69. package/dist/{item.types.d-DuVR0ZVK.d.ts → variables.d-DWHlTszN.d.ts} +1 -23
  70. package/package.json +13 -9
  71. package/dist/chunk-5AJZGRWI.js.map +0 -1
  72. package/dist/chunk-G2EIC7H2.js.map +0 -1
  73. package/dist/chunk-IM5AKPIJ.js.map +0 -1
  74. package/dist/chunk-MIQZBDTB.js.map +0 -1
  75. package/dist/chunk-QT7WQXCS.js.map +0 -1
  76. package/dist/chunk-RNLSNH4N.js +0 -7
  77. package/dist/chunk-RNLSNH4N.js.map +0 -1
  78. package/dist/chunk-URYYGVTA.js.map +0 -1
  79. /package/dist/{chunk-F553IZPL.js.map → chunk-J3F3JSCW.js.map} +0 -0
  80. /package/dist/{chunk-32PI7KWX.js.map → chunk-L3LBSAGZ.js.map} +0 -0
  81. /package/dist/{chunk-WIUPAUJV.js.map → chunk-L7J2ZOJL.js.map} +0 -0
  82. /package/dist/{chunk-XY5DHYIH.js.map → chunk-OG5HIRHE.js.map} +0 -0
  83. /package/dist/{chunk-HT3LSWXL.js.map → chunk-QLGUI5VG.js.map} +0 -0
  84. /package/dist/{chunk-IWNRQVNW.js.map → chunk-V5GL7PTC.js.map} +0 -0
@@ -0,0 +1,7 @@
1
+ // ../qti-test/dist/plugin-state.js
2
+ var pluginState = (context, plugin) => context?.plugins?.[plugin];
3
+
4
+ export {
5
+ pluginState
6
+ };
7
+ //# sourceMappingURL=chunk-DJ7PB252.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-test/src/plugin-state.ts"],"sourcesContent":["import type { ComputedContext } from '@qti-components/base';\nimport type { QtiTestPluginState } from './types/qti-test-state';\n\n/**\n * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the\n * plugin has stored anything. Read it from `computedContext`; write it by dispatching\n * `qc-test-update-plugin-state` (`dispatchPublic`).\n */\nexport const pluginState = <K extends keyof QtiTestPluginState & string>(\n context: Pick<ComputedContext, 'plugins'> | undefined,\n plugin: K\n): QtiTestPluginState[K] | undefined => context?.plugins?.[plugin] as QtiTestPluginState[K] | undefined;\n"],"mappings":";AAQO,IAAM,cAAc,CACzB,SACA,WACsC,SAAS,UAAU,MAAM;","names":[]}
@@ -21,7 +21,7 @@ import {
21
21
  elements8,
22
22
  elements9,
23
23
  qtiInteractionElements
24
- } from "./chunk-G2EIC7H2.js";
24
+ } from "./chunk-7MYZHZWV.js";
25
25
 
26
26
  // ../qti-interactions/dist/register-all.js
27
27
  for (const { tag, ctor } of qtiInteractionElements) {
@@ -176,4 +176,4 @@ for (const { tag, ctor } of elements21) {
176
176
  customElements.define(tag, ctor);
177
177
  }
178
178
  }
179
- //# sourceMappingURL=chunk-F553IZPL.js.map
179
+ //# sourceMappingURL=chunk-J3F3JSCW.js.map
@@ -0,0 +1,197 @@
1
+ import {
2
+ dispatchDeclared,
3
+ listenDeclared
4
+ } from "./chunk-UCXLDQYA.js";
5
+ import {
6
+ __export
7
+ } from "./chunk-PZ5AY32C.js";
8
+
9
+ // ../qti-test/dist/public-events.js
10
+ var PUBLIC_EVENTS = {
11
+ "qc-test-navigate": { kind: "request", scope: "test", deprecated: "cito-test-navigate" },
12
+ "qc-test-end-attempt": { kind: "request", scope: "test", deprecated: "cito-test-end-attempt" },
13
+ "qc-test-submit": { kind: "request", scope: "test", deprecated: "cito-test-submit" },
14
+ "qc-test-update-outcome": { kind: "request", scope: "test", deprecated: "cito-test-update-outcome" },
15
+ "qc-test-update-plugin-state": { kind: "request", scope: "test", deprecated: "cito-test-update-plugin-state" },
16
+ "qc-test-switch-view": { kind: "request", scope: "test", deprecated: "cito-test-switch-view" },
17
+ "qc-test-submitted": { kind: "notification", scope: "test", deprecated: "cito-test-submitted" },
18
+ "qc-test-navigated": { kind: "notification", scope: "test", deprecated: "cito-test-navigated" },
19
+ "qc-test-navigation-started": { kind: "notification", scope: "test", deprecated: "cito-test-navigation-started" },
20
+ "qc-test-navigation-failed": { kind: "notification", scope: "test", deprecated: "cito-test-navigation-failed" },
21
+ "qc-test-rendered": { kind: "notification", scope: "test", deprecated: "cito-test-rendered" },
22
+ "qc-test-loaded": { kind: "notification", scope: "test", deprecated: "cito-test-loaded" },
23
+ "qc-test-state-changed": { kind: "notification", scope: "test", deprecated: "cito-test-state-changed" },
24
+ "qc-test-items-skipped": { kind: "notification", scope: "test", deprecated: "cito-test-items-skipped" },
25
+ "qc-test-end-reached": { kind: "notification", scope: "test", deprecated: "cito-test-end-reached" },
26
+ "qc-item-ref-connected": { kind: "notification", scope: "item", deprecated: "cito-item-ref-connected" }
27
+ };
28
+ function dispatchPublic(target, name, detail) {
29
+ dispatchDeclared(target, PUBLIC_EVENTS, name, detail);
30
+ }
31
+ function listenPublic(target, name, handler) {
32
+ listenDeclared(target, PUBLIC_EVENTS, name, handler);
33
+ }
34
+
35
+ // ../qti-test/dist/components/styles.js
36
+ var styles_exports = {};
37
+ __export(styles_exports, {
38
+ btn: () => btn,
39
+ btnActive: () => btnActive,
40
+ btnInteractive: () => btnInteractive,
41
+ btnPrimary: () => btnPrimary,
42
+ btnPrimaryActive: () => btnPrimaryActive,
43
+ btnPrimaryInteractive: () => btnPrimaryInteractive,
44
+ button: () => button,
45
+ buttonPrimary: () => buttonPrimary,
46
+ control: () => control,
47
+ dis: () => dis,
48
+ focusRing: () => focusRing,
49
+ form: () => form,
50
+ hostBox: () => hostBox,
51
+ ind: () => ind
52
+ });
53
+ import { css, html } from "lit";
54
+ var surface = css`var(--qti-color-base-100, var(--qc-color-base-100, var(--cito-color-base-100, Canvas)))`;
55
+ var content = css`var(--qti-color-base-content, var(--qc-color-base-content, var(--cito-color-base-content, CanvasText)))`;
56
+ var neutral = css`var(--qti-color-neutral, var(--qc-color-neutral, var(--cito-color-neutral, CanvasText)))`;
57
+ var neutralContent = css`var(--qti-color-neutral-content, var(--qc-color-neutral-content, var(--cito-color-neutral-content, Canvas)))`;
58
+ var radius = css`var(--button-border-radius, var(--test-button-border-radius, var(--qti-radius-field, var(--qc-radius-field, var(--cito-radius-field, 0.2rem)))))`;
59
+ var borderWidth = css`var(--qti-border-width, var(--qc-border-width, var(--cito-border-width, 1px)))`;
60
+ var hostBox = css`
61
+ display: inline-flex;
62
+ cursor: pointer;
63
+ user-select: none;
64
+ border-radius: ${radius};
65
+ `;
66
+ var form = css`
67
+ display: flex;
68
+ flex: 1 1 auto;
69
+ align-items: center;
70
+ justify-content: center;
71
+ gap: 0.375em;
72
+ box-sizing: border-box;
73
+ min-block-size: var(--button-size, var(--test-button-size, 2.25rem));
74
+ padding: 0 0.875rem;
75
+ font: inherit;
76
+ line-height: 1.25;
77
+ cursor: pointer;
78
+ user-select: none;
79
+ border-radius: ${radius};
80
+ `;
81
+ var btn = css`
82
+ ${form};
83
+ background-color: var(--button-background-color, var(--test-button-background-color, ${surface}));
84
+ color: var(--button-color, var(--test-button-color, inherit));
85
+ border: ${borderWidth} solid
86
+ var(
87
+ --button-border-color,
88
+ var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})))
89
+ );
90
+ `;
91
+ var btnPrimary = css`
92
+ background-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
93
+ color: var(--button-primary-color, var(--test-button-primary-color, ${neutralContent}));
94
+ border-color: var(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));
95
+ `;
96
+ var btnInteractive = css`
97
+ background-color: var(
98
+ --button-hover-background-color,
99
+ var(--test-button-hover-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%)))
100
+ );
101
+ `;
102
+ var btnPrimaryInteractive = css`
103
+ background-color: var(
104
+ --button-primary-hover-background-color,
105
+ var(
106
+ --test-button-primary-hover-background-color,
107
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))
108
+ )
109
+ );
110
+ `;
111
+ var btnActive = css`
112
+ background-color: var(
113
+ --button-active-background-color,
114
+ var(--test-button-active-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%)))
115
+ );
116
+ `;
117
+ var btnPrimaryActive = css`
118
+ background-color: var(
119
+ --button-primary-active-background-color,
120
+ var(
121
+ --test-button-primary-active-background-color,
122
+ color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))
123
+ )
124
+ );
125
+ `;
126
+ var focusRing = css`
127
+ outline: var(--qti-focus-border-width, 2px) solid var(--qti-focus-color, Highlight);
128
+ outline-offset: var(--qti-focus-offset, 2px);
129
+ `;
130
+ var dis = css`
131
+ cursor: not-allowed;
132
+ opacity: 0.45;
133
+ `;
134
+ var ind = css`
135
+ ${form};
136
+ border: ${borderWidth} solid var(--qti-border-color, GrayText);
137
+ `;
138
+ var control = html`<span class="control" part="button"><slot></slot></span>`;
139
+ var button = css`
140
+ :host {
141
+ ${hostBox};
142
+ }
143
+ .control {
144
+ ${btn};
145
+ }
146
+ @media (hover: hover) and (pointer: fine) {
147
+ :host(:hover:not([disabled])) .control {
148
+ ${btnInteractive};
149
+ }
150
+ }
151
+ :host(:active:not([disabled])) .control {
152
+ ${btnActive};
153
+ }
154
+ /* The press the theme gives a choice (qti-motion.css), from the same knob: a touch smaller while
155
+ the button is down, springing back on release; 0 motion means no press. */
156
+ .control {
157
+ transition:
158
+ background-color calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1),
159
+ scale calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1);
160
+ }
161
+ :host(:active:not([disabled])) .control {
162
+ scale: calc(1 - 0.03 * var(--qti-motion, 1));
163
+ }
164
+ :host(:focus-visible) {
165
+ ${focusRing};
166
+ }
167
+ :host([disabled]) {
168
+ ${dis};
169
+ }
170
+ :host([disabled]) .control {
171
+ cursor: not-allowed;
172
+ }
173
+ `;
174
+ var buttonPrimary = css`
175
+ .control {
176
+ ${btnPrimary};
177
+ }
178
+ @media (hover: hover) and (pointer: fine) {
179
+ :host(:hover:not([disabled])) .control {
180
+ ${btnPrimaryInteractive};
181
+ }
182
+ }
183
+ :host(:active:not([disabled])) .control {
184
+ ${btnPrimaryActive};
185
+ }
186
+ `;
187
+
188
+ export {
189
+ PUBLIC_EVENTS,
190
+ dispatchPublic,
191
+ listenPublic,
192
+ control,
193
+ button,
194
+ buttonPrimary,
195
+ styles_exports
196
+ };
197
+ //# sourceMappingURL=chunk-J6VX4N7M.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-test/src/public-events.ts","../../qti-test/src/components/styles.ts"],"sourcesContent":["import { dispatchDeclared, listenDeclared } from '@qti-components/elements/public-events';\n\nimport type { View } from '@qti-components/base';\nimport type { PublicEventDeclaration } from '@qti-components/elements/public-events';\nimport type { QtiTestState } from './types/qti-test-state';\n\n/**\n * The public events of the test. The name tells you it is public: everything here starts with\n * `qc-`; every other event is internal plumbing and may change in any release.\n *\n * Requests are verbs (a host or plugin dispatches them at the test), notifications are past tense\n * (the test dispatches them). All bubble and are composed.\n *\n * `deprecated` is the `cito-` name this event had in 9.x. One helper (`dispatchPublic`,\n * `listenPublic`) sends or handles both names until the next major, then the field goes. The 7.x\n * names (`qti-request-navigation`, `test-end-attempt`, `on-test-switch-view`, …) are no longer sent\n * or handled.\n */\nexport interface NavigationTarget {\n type: 'item' | 'section';\n id: string;\n}\n\nexport interface NavigationFailure {\n message: string;\n details?: unknown;\n itemId?: string;\n sectionId?: string;\n}\n\nexport interface PublicEventMap {\n 'qc-test-navigate': CustomEvent<NavigationTarget>;\n /**\n * Ends an attempt: processes the response of the item-ref `itemId`, or, without it, of the item on\n * screen. `<test-end-attempt>` sends the `itemId` of the item it is stamped into or names.\n */\n 'qc-test-end-attempt': CustomEvent<{ itemId?: string }>;\n /** Scores the test: resets its outcomes to their defaults, runs outcome processing, then `qc-test-submitted`. */\n 'qc-test-submit': CustomEvent<Record<string, never>>;\n 'qc-test-update-outcome': CustomEvent<{\n assessmentItemRefId: string;\n outcomeVariableId: string;\n value: number | string;\n }>;\n 'qc-test-switch-view': CustomEvent<View>;\n /** `value` is JSON; `null` or `undefined` removes the plugin's entry. */\n 'qc-test-update-plugin-state': CustomEvent<{ plugin: string; value: unknown }>;\n /** Outcome processing ran after a submit: read the test outcomes now. */\n 'qc-test-submitted': CustomEvent<Record<string, never>>;\n 'qc-test-navigated': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-started': CustomEvent<NavigationTarget>;\n 'qc-test-navigation-failed': CustomEvent<NavigationFailure>;\n 'qc-test-rendered': CustomEvent<{ identifier: string; element: Element }[]>;\n // `qc-test-loaded` (detail: the `QtiAssessmentTest`) is added by qti-assessment-test.ts, so this\n // module imports no element: that import would be a cycle.\n 'qc-test-state-changed': CustomEvent<QtiTestState>;\n 'qc-test-items-skipped': CustomEvent<{ ids: string[] }>;\n 'qc-test-end-reached': CustomEvent<Record<string, never>>;\n 'qc-item-ref-connected': CustomEvent<{ identifier: string; href: string; category: string }>;\n}\n\nexport type PublicEventName = keyof PublicEventMap;\n\nexport const PUBLIC_EVENTS: Record<PublicEventName, PublicEventDeclaration> = {\n 'qc-test-navigate': { kind: 'request', scope: 'test', deprecated: 'cito-test-navigate' },\n 'qc-test-end-attempt': { kind: 'request', scope: 'test', deprecated: 'cito-test-end-attempt' },\n 'qc-test-submit': { kind: 'request', scope: 'test', deprecated: 'cito-test-submit' },\n 'qc-test-update-outcome': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-outcome' },\n 'qc-test-update-plugin-state': { kind: 'request', scope: 'test', deprecated: 'cito-test-update-plugin-state' },\n 'qc-test-switch-view': { kind: 'request', scope: 'test', deprecated: 'cito-test-switch-view' },\n 'qc-test-submitted': { kind: 'notification', scope: 'test', deprecated: 'cito-test-submitted' },\n 'qc-test-navigated': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigated' },\n 'qc-test-navigation-started': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-started' },\n 'qc-test-navigation-failed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-navigation-failed' },\n 'qc-test-rendered': { kind: 'notification', scope: 'test', deprecated: 'cito-test-rendered' },\n 'qc-test-loaded': { kind: 'notification', scope: 'test', deprecated: 'cito-test-loaded' },\n 'qc-test-state-changed': { kind: 'notification', scope: 'test', deprecated: 'cito-test-state-changed' },\n 'qc-test-items-skipped': { kind: 'notification', scope: 'test', deprecated: 'cito-test-items-skipped' },\n 'qc-test-end-reached': { kind: 'notification', scope: 'test', deprecated: 'cito-test-end-reached' },\n 'qc-item-ref-connected': { kind: 'notification', scope: 'item', deprecated: 'cito-item-ref-connected' }\n};\n\ndeclare global {\n interface HTMLElementEventMap extends PublicEventMap {}\n}\n\n/**\n * Dispatch a public event, and its deprecated name with the same `detail` object. The detail is\n * always an object so `listenPublic` can tell the two apart from one dispatch.\n */\nexport function dispatchPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n detail: PublicEventMap[K] extends CustomEvent<infer D> ? D : never\n): void {\n dispatchDeclared(target, PUBLIC_EVENTS, name, detail);\n}\n\n/**\n * Listen for a public event and its deprecated name; the handler runs once for a sender that\n * dispatched both. See `listenDeclared`.\n */\nexport function listenPublic<K extends PublicEventName>(\n target: EventTarget,\n name: K,\n handler: (e: PublicEventMap[K]) => void\n): void {\n listenDeclared(target, PUBLIC_EVENTS, name, handler as (e: Event) => void);\n}\n","// /* eslint-disable lit-plugin(no-invalid-css) */\nimport { css, html } 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): `--qc-*` first, the older\n * `--cito-*` name as its fallback for this major, and a CSS system colour behind both for a page\n * that loads no theme: Canvas and CanvasText follow the page's color-scheme, so the controls stay\n * legible in dark mode without the theme too. Hover and press mix the content colour into the\n * fill, by --qti-hover-mix and --qti-active-mix.\n *\n * Paint comes from the `--button-*` slots, the one button slot set the theme's `@mixin paint button`\n * reads too, so a host that repaints its buttons repaints the test controls, the end-attempt and the\n * upload button alike. The older `--test-button-*` names are aliases: each slot is read as\n * `var(--button-X, var(--test-button-X, <default>))`. Never the shared `--qti-component-*` tokens:\n * those also paint the items' own borders, and a change to how a button looks must not move an\n * interaction.\n *\n * --button-size, --button-border-radius the box\n * --button-background-color, --button-color, --button-border-color,\n * --button-hover-background-color, --button-active-background-color\n * the neutral look, and the filled look's slots\n * --button-primary-background-color, --button-primary-color,\n * --button-primary-hover-background-color, --button-primary-active-background-color\n * the filled look only\n * --button-selected-background-color, --button-selected-color\n * a toggle that is on (the host carries :state(selected))\n *\n * --test-button-<same> aliases of the names above\n */\n\nconst surface = css`var(--qti-color-base-100, var(--qc-color-base-100, var(--cito-color-base-100, Canvas)))`;\nconst content = css`var(--qti-color-base-content, var(--qc-color-base-content, var(--cito-color-base-content, CanvasText)))`;\nconst neutral = css`var(--qti-color-neutral, var(--qc-color-neutral, var(--cito-color-neutral, CanvasText)))`;\nconst neutralContent = css`var(--qti-color-neutral-content, var(--qc-color-neutral-content, var(--cito-color-neutral-content, Canvas)))`;\nconst radius = css`var(--button-border-radius, var(--test-button-border-radius, var(--qti-radius-field, var(--qc-radius-field, var(--cito-radius-field, 0.2rem)))))`;\nconst borderWidth = css`var(--qti-border-width, var(--qc-border-width, var(--cito-border-width, 1px)))`;\n\n/*\n * A test control is drawn on an inner element (`.control`, part \"button\"), never on its host.\n *\n * A page's reset, Tailwind's preflight for one (`*, ::before, ::after { margin: 0; padding: 0; border: 0 solid }`),\n * is a rule of the page, and a page rule beats the `:host` rules of a shadow root whatever its layer or its\n * specificity. A control that paints its padding and border on the host loses them to such a reset. The\n * inner element lives in the shadow tree, where the page's `*` does not reach, so the control looks the same with\n * or without a reset. The host keeps only what a reset leaves alone: its display, the radius its focus ring\n * follows, and the cursor.\n */\nexport const hostBox = css`\n display: inline-flex;\n cursor: pointer;\n user-select: none;\n border-radius: ${radius};\n`;\n\n/** The box of the control itself: the inner element. */\nexport const form = css`\n display: flex;\n flex: 1 1 auto;\n align-items: center;\n justify-content: center;\n gap: 0.375em;\n box-sizing: border-box;\n min-block-size: var(--button-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: ${radius};\n`;\n\nexport const btn = css`\n ${form};\n background-color: var(--button-background-color, var(--test-button-background-color, ${surface}));\n color: var(--button-color, var(--test-button-color, inherit));\n border: ${borderWidth} solid\n var(\n --button-border-color,\n var(--test-button-border-color, var(--qti-border-color, color-mix(in oklab, ${content} 45%, ${surface})))\n );\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(--button-primary-background-color, var(--test-button-primary-background-color, ${neutral}));\n color: var(--button-primary-color, var(--test-button-primary-color, ${neutralContent}));\n border-color: var(--button-primary-background-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 --button-hover-background-color,\n var(--test-button-hover-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-hover-mix, 8%)))\n );\n`;\n\nexport const btnPrimaryInteractive = css`\n background-color: var(\n --button-primary-hover-background-color,\n var(\n --test-button-primary-hover-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-hover-mix, 8%))\n )\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 --button-active-background-color,\n var(--test-button-active-background-color, color-mix(in oklab, ${surface}, ${content} var(--qti-active-mix, 16%)))\n );\n`;\n\nexport const btnPrimaryActive = css`\n background-color: var(\n --button-primary-active-background-color,\n var(\n --test-button-primary-active-background-color,\n color-mix(in oklab, ${neutral}, ${neutralContent} var(--qti-active-mix, 16%))\n )\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: ${borderWidth} solid var(--qti-border-color, GrayText);\n`;\n\n/** What a test control renders: the inner element that carries the look (see `hostBox`). */\nexport const control = html`<span class=\"control\" part=\"button\"><slot></slot></span>`;\n\n/**\n * The stylesheet of a neutral test control: the host box, the look on `.control`, and its hover, press,\n * focus and disabled states. A control with its own content (a bookmark's icon) adds to it.\n */\nexport const button = css`\n :host {\n ${hostBox};\n }\n .control {\n ${btn};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnActive};\n }\n /* The press the theme gives a choice (qti-motion.css), from the same knob: a touch smaller while\n the button is down, springing back on release; 0 motion means no press. */\n .control {\n transition:\n background-color calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1),\n scale calc(200ms * var(--qti-motion, 1)) cubic-bezier(0.2, 0, 0, 1);\n }\n :host(:active:not([disabled])) .control {\n scale: calc(1 - 0.03 * var(--qti-motion, 1));\n }\n :host(:focus-visible) {\n ${focusRing};\n }\n :host([disabled]) {\n ${dis};\n }\n :host([disabled]) .control {\n cursor: not-allowed;\n }\n`;\n\n/** The filled look of `test-next`: add after `button`, so its rules win at equal specificity. */\nexport const buttonPrimary = css`\n .control {\n ${btnPrimary};\n }\n @media (hover: hover) and (pointer: fine) {\n :host(:hover:not([disabled])) .control {\n ${btnPrimaryInteractive};\n }\n }\n :host(:active:not([disabled])) .control {\n ${btnPrimaryActive};\n }\n`;\n"],"mappings":";;;;;;;;;AA+DO,IAAM,gBAAiE;EAC5E,oBAAoB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,qBAAoB;EACtF,uBAAuB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAuB;EAC5F,kBAAkB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,mBAAkB;EAClF,0BAA0B,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,2BAA0B;EAClG,+BAA+B,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,gCAA+B;EAC5G,uBAAuB,EAAE,MAAM,WAAW,OAAO,QAAQ,YAAY,wBAAuB;EAC5F,qBAAqB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,sBAAqB;EAC7F,qBAAqB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,sBAAqB;EAC7F,8BAA8B,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,+BAA8B;EAC/G,6BAA6B,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,8BAA6B;EAC7G,oBAAoB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,qBAAoB;EAC3F,kBAAkB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,mBAAkB;EACvF,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;EACrG,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;EACrG,uBAAuB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,wBAAuB;EACjG,yBAAyB,EAAE,MAAM,gBAAgB,OAAO,QAAQ,YAAY,0BAAyB;;AAWjG,SAAU,eACd,QACA,MACA,QAAkE;AAElE,mBAAiB,QAAQ,eAAe,MAAM,MAAM;AACtD;AAMM,SAAU,aACd,QACA,MACA,SAAuC;AAEvC,iBAAe,QAAQ,eAAe,MAAM,OAA6B;AAC3E;;;AC5GA;;;;;;;;;;;;;;;;;AACA,SAAS,KAAK,YAAY;AAoC1B,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,iBAAiB;AACvB,IAAM,SAAS;AACf,IAAM,cAAc;AAYb,IAAM,UAAU;;;;mBAIJ,MAAM;;AAIlB,IAAM,OAAO;;;;;;;;;;;;;mBAaD,MAAM;;AAGlB,IAAM,MAAM;IACf,IAAI;yFACiF,OAAO;;YAEpF,WAAW;;;oFAG6D,OAAO,SAAS,OAAO;;;AAKpG,IAAM,aAAa;yGAC+E,OAAO;wEACxC,cAAc;qGACe,OAAO;;AAIrG,IAAM,iBAAiB;;;oEAGsC,OAAO,KAAK,OAAO;;;AAIhF,IAAM,wBAAwB;;;;;4BAKT,OAAO,KAAK,cAAc;;;;AAM/C,IAAM,YAAY;;;qEAG4C,OAAO,KAAK,OAAO;;;AAIjF,IAAM,mBAAmB;;;;;4BAKJ,OAAO,KAAK,cAAc;;;;AAM/C,IAAM,YAAY;;;;AAKlB,IAAM,MAAM;;;;AAKZ,IAAM,MAAM;IACf,IAAI;YACI,WAAW;;AAIhB,IAAM,UAAU;AAMhB,IAAM,SAAS;;MAEhB,OAAO;;;MAGP,GAAG;;;;QAID,cAAc;;;;MAIhB,SAAS;;;;;;;;;;;;;MAaT,SAAS;;;MAGT,GAAG;;;;;;AAQF,IAAM,gBAAgB;;MAEvB,UAAU;;;;QAIR,qBAAqB;;;;MAIvB,gBAAgB;;;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiProcessingElements
3
- } from "./chunk-5AJZGRWI.js";
3
+ } from "./chunk-UDJ7MHLF.js";
4
4
 
5
5
  // ../qti-processing/dist/register.js
6
6
  for (const { tag, ctor } of qtiProcessingElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiProcessingElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-32PI7KWX.js.map
11
+ //# sourceMappingURL=chunk-L3LBSAGZ.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiItemElements
3
- } from "./chunk-XY5DHYIH.js";
3
+ } from "./chunk-OG5HIRHE.js";
4
4
 
5
5
  // ../qti-item/dist/register.js
6
6
  for (const { tag, ctor } of qtiItemElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiItemElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-WIUPAUJV.js.map
11
+ //# sourceMappingURL=chunk-L7J2ZOJL.js.map
@@ -202,6 +202,35 @@ var validationMessage = css3`
202
202
  }
203
203
  `;
204
204
 
205
+ // ../qti-base/dist/utils/state-aliases.js
206
+ var STATE_ALIASES = {
207
+ chip: ["drag"],
208
+ drop: ["droppable"],
209
+ lifted: ["dragging"],
210
+ used: ["placeholder"],
211
+ "return-target": ["return-anchor"],
212
+ "drag-over": ["hover"],
213
+ "candidate-partial": ["candidate-partially-correct"]
214
+ };
215
+ function setState(states, name, on, oldNames) {
216
+ if (!states)
217
+ return;
218
+ const names = [name, ...oldNames ?? STATE_ALIASES[name] ?? []];
219
+ for (const n of names) {
220
+ if (on)
221
+ states.add(n);
222
+ else
223
+ states.delete(n);
224
+ }
225
+ }
226
+ function hasState(states, name) {
227
+ if (!states)
228
+ return false;
229
+ if (states.has(name))
230
+ return true;
231
+ return (STATE_ALIASES[name] ?? []).some((n) => states.has(n));
232
+ }
233
+
205
234
  // ../qti-base/dist/abstract/interaction.js
206
235
  import { ContextConsumer, consume, provide } from "@lit/context";
207
236
  import { LitElement } from "lit";
@@ -321,11 +350,40 @@ var Interaction = class extends LitElement {
321
350
  set value(val) {
322
351
  this.response = val ? JSON.parse(val) : null;
323
352
  }
324
- reportValidity() {
353
+ /** Forget that a submit has reported: a reset or a new attempt waits for a submit again. */
354
+ resetValidityReport() {
355
+ this._validityReported = false;
356
+ this.clearInlineValidationMessage();
357
+ }
358
+ /**
359
+ * Show the validity state, in the configured mode.
360
+ *
361
+ * When it shows depends on what asked: a `change` (the candidate picked or dropped something)
362
+ * reports what they just did wrong, too many, at once; too few is not an error until they say they
363
+ * are done, so a `submit` (the item's end attempt, a form's submit) is what first shows it. After
364
+ * that first submit, changes report in full, so the message clears the moment the minimum is met
365
+ * and comes back if it is lost again. The validity itself is always set: a form with a
366
+ * below-minimum interaction cannot submit either way.
367
+ */
368
+ reportValidity(options) {
369
+ const trigger = options?.trigger ?? "submit";
370
+ if (trigger === "submit")
371
+ this.validate?.();
325
372
  const isValid = this._internals.validity.valid;
326
373
  const mode = this.validationDisplayMode;
374
+ if (trigger === "submit")
375
+ this._validityReported = true;
376
+ if (trigger === "change" && !this._validityReported && this._validityKind === "min") {
377
+ this.clearInlineValidationMessage();
378
+ return isValid;
379
+ }
327
380
  if (mode === "native" || mode === "both") {
328
- this._internals.reportValidity();
381
+ this._reportingNatively = true;
382
+ try {
383
+ this._internals.reportValidity();
384
+ } finally {
385
+ this._reportingNatively = false;
386
+ }
329
387
  }
330
388
  if (mode === "inline" || mode === "both") {
331
389
  this.updateInlineValidationMessage();
@@ -372,6 +430,7 @@ var Interaction = class extends LitElement {
372
430
  setInteractionValidity(isValid, validityMessage = "", anchor, options) {
373
431
  const validityAnchor = anchor ?? this;
374
432
  this._internals.setValidity(isValid ? {} : { customError: true }, validityMessage, validityAnchor);
433
+ this._validityKind = isValid ? void 0 : options?.kind ?? "other";
375
434
  if (options?.suppressInline !== true && (this.validationDisplayMode === "inline" || this.validationDisplayMode === "both")) {
376
435
  this.updateInlineValidationMessage();
377
436
  }
@@ -401,9 +460,11 @@ var Interaction = class extends LitElement {
401
460
  return this.shadowRoot?.querySelector("#validation-message");
402
461
  }
403
462
  reset() {
463
+ this.resetValidityReport();
404
464
  this.response = null;
405
465
  }
406
466
  formResetCallback() {
467
+ this.resetValidityReport();
407
468
  this.reset();
408
469
  }
409
470
  connectedCallback() {
@@ -433,6 +494,24 @@ var Interaction = class extends LitElement {
433
494
  }
434
495
  }));
435
496
  }
497
+ /**
498
+ * `disabled` and `readonly` are states as well as attributes (qti-theme CONTRACT.md §3): a theme
499
+ * reads `:state(disabled)` on the host the way it reads it on a choice. The attribute stays
500
+ * reflected, so `[disabled]` keeps matching.
501
+ */
502
+ update(changed) {
503
+ const first = !this.hasUpdated;
504
+ super.update(changed);
505
+ if (first) {
506
+ const run = () => this.isConnected && this.validate();
507
+ void this.updateComplete.then(run);
508
+ requestAnimationFrame(() => requestAnimationFrame(run));
509
+ }
510
+ if (changed.has("disabled"))
511
+ setState(this._internals.states, "disabled", this.disabled);
512
+ if (changed.has("readonly"))
513
+ setState(this._internals.states, "readonly", this.readonly);
514
+ }
436
515
  constructor() {
437
516
  super();
438
517
  this.#itemContext = new ContextConsumer(this, {
@@ -445,7 +524,17 @@ var Interaction = class extends LitElement {
445
524
  this._interactionContext = { choiceRole: null, draggablesSelector: null };
446
525
  this.disabled = false;
447
526
  this.readonly = false;
527
+ this._validityReported = false;
528
+ this._reportingNatively = false;
448
529
  this._internals = this.attachInternals();
530
+ this.addEventListener("invalid", () => {
531
+ if (this._reportingNatively)
532
+ return;
533
+ this._validityReported = true;
534
+ if (this.validationDisplayMode === "inline" || this.validationDisplayMode === "both") {
535
+ this.updateInlineValidationMessage();
536
+ }
537
+ });
449
538
  this.addEventListener("qti-interaction-response", (e) => {
450
539
  this.#lastResponse = JSON.stringify(e.detail?.response ?? null);
451
540
  });
@@ -870,7 +959,7 @@ var QtiFeedback = class extends LitElement4 {
870
959
  }
871
960
  /**
872
961
  * Called when this feedback is about to show. Return `false` to keep it hidden: the host shows the
873
- * content itself. The elements dispatch `cito-feedback-show` here.
962
+ * content itself. The elements dispatch `qc-feedback-show` here.
874
963
  */
875
964
  feedbackShowing() {
876
965
  return true;
@@ -1280,6 +1369,9 @@ export {
1280
1369
  boxSizing,
1281
1370
  dropRegion,
1282
1371
  validationMessage,
1372
+ STATE_ALIASES,
1373
+ setState,
1374
+ hasState,
1283
1375
  Interaction,
1284
1376
  QtiVariableDeclaration,
1285
1377
  QtiExpression,
@@ -1308,4 +1400,4 @@ export {
1308
1400
  getCustomOperator,
1309
1401
  ScoringHelper
1310
1402
  };
1311
- //# sourceMappingURL=chunk-IM5AKPIJ.js.map
1403
+ //# sourceMappingURL=chunk-NZ7ZC4SP.js.map