@pie-qti/default-components 0.1.10 → 0.1.11
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/chunks/__vite-browser-external-BjvdLQIS.js +9 -0
- package/dist/chunks/__vite-browser-external-BjvdLQIS.js.map +1 -0
- package/dist/chunks/chunk-Bayd9M4T.js +20 -0
- package/dist/chunks/{mathlive.min-Bvtiaxg4.js → mathlive.min-CAPebTxM.js} +245 -29
- package/dist/chunks/{mathlive.min-Bvtiaxg4.js.map → mathlive.min-CAPebTxM.js.map} +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/associate/index.d.ts +0 -1
- package/dist/plugins/associate/index.js +1 -0
- package/dist/plugins/associate/index.js.map +1 -0
- package/dist/plugins/choice/index.d.ts +0 -1
- package/dist/plugins/choice/index.js +1 -0
- package/dist/plugins/choice/index.js.map +1 -0
- package/dist/plugins/custom/index.d.ts +0 -1
- package/dist/plugins/custom/index.js +1 -0
- package/dist/plugins/custom/index.js.map +1 -0
- package/dist/plugins/end-attempt/index.d.ts +0 -1
- package/dist/plugins/end-attempt/index.js +1 -0
- package/dist/plugins/end-attempt/index.js.map +1 -0
- package/dist/plugins/extended-text/index.d.ts +0 -1
- package/dist/plugins/extended-text/index.js +1 -0
- package/dist/plugins/extended-text/index.js.map +1 -0
- package/dist/plugins/gap-match/index.d.ts +0 -1
- package/dist/plugins/gap-match/index.js +1 -0
- package/dist/plugins/gap-match/index.js.map +1 -0
- package/dist/plugins/graphic-associate/index.d.ts +0 -1
- package/dist/plugins/graphic-associate/index.js +1 -0
- package/dist/plugins/graphic-associate/index.js.map +1 -0
- package/dist/plugins/graphic-gap-match/index.d.ts +0 -1
- package/dist/plugins/graphic-gap-match/index.js +1 -0
- package/dist/plugins/graphic-gap-match/index.js.map +1 -0
- package/dist/plugins/graphic-order/index.d.ts +0 -1
- package/dist/plugins/graphic-order/index.js +1 -0
- package/dist/plugins/graphic-order/index.js.map +1 -0
- package/dist/plugins/hotspot/index.d.ts +0 -1
- package/dist/plugins/hotspot/index.js +1 -0
- package/dist/plugins/hotspot/index.js.map +1 -0
- package/dist/plugins/hottext/index.d.ts +0 -1
- package/dist/plugins/hottext/index.js +1 -0
- package/dist/plugins/hottext/index.js.map +1 -0
- package/dist/plugins/match/index.d.ts +0 -1
- package/dist/plugins/match/index.js +1 -0
- package/dist/plugins/match/index.js.map +1 -0
- package/dist/plugins/media/index.d.ts +0 -1
- package/dist/plugins/media/index.js +1 -0
- package/dist/plugins/media/index.js.map +1 -0
- package/dist/plugins/order/index.d.ts +0 -1
- package/dist/plugins/order/index.js +1 -0
- package/dist/plugins/order/index.js.map +1 -0
- package/dist/plugins/position-object/index.d.ts +0 -1
- package/dist/plugins/position-object/index.js +1 -0
- package/dist/plugins/position-object/index.js.map +1 -0
- package/dist/plugins/public-types.d.ts +5 -0
- package/dist/plugins/public-types.js +2 -0
- package/dist/plugins/public-types.js.map +1 -0
- package/dist/plugins/select-point/index.d.ts +0 -1
- package/dist/plugins/select-point/index.js +1 -0
- package/dist/plugins/select-point/index.js.map +1 -0
- package/dist/plugins/slider/index.d.ts +0 -1
- package/dist/plugins/slider/index.js +1 -0
- package/dist/plugins/slider/index.js.map +1 -0
- package/dist/plugins.js +25917 -7690
- package/dist/plugins.js.map +1 -1
- package/dist/shared/actions/typesetAction.d.ts +0 -1
- package/dist/shared/actions/typesetAction.js +1 -0
- package/dist/shared/actions/typesetAction.js.map +1 -0
- package/dist/shared/extensions/MathLiveEditor.d.ts +0 -1
- package/dist/shared/extensions/MathLiveEditor.js +1 -0
- package/dist/shared/extensions/MathLiveEditor.js.map +1 -0
- package/dist/shared/index.d.ts +0 -1
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/utils/eventHelpers.d.ts +0 -1
- package/dist/shared/utils/eventHelpers.js +1 -0
- package/dist/shared/utils/eventHelpers.js.map +1 -0
- package/dist/shared/utils/matchGroupUtils.d.ts +0 -1
- package/dist/shared/utils/matchGroupUtils.js +1 -0
- package/dist/shared/utils/matchGroupUtils.js.map +1 -0
- package/dist/shared/utils/pairHelpers.d.ts +0 -1
- package/dist/shared/utils/pairHelpers.js +1 -0
- package/dist/shared/utils/pairHelpers.js.map +1 -0
- package/dist/shared/utils/webComponentHelpers.d.ts +0 -1
- package/dist/shared/utils/webComponentHelpers.js +1 -0
- package/dist/shared/utils/webComponentHelpers.js.map +1 -0
- package/package.json +11 -33
- package/dist/index.d.ts.map +0 -1
- package/dist/plugins/associate/index.d.ts.map +0 -1
- package/dist/plugins/choice/index.d.ts.map +0 -1
- package/dist/plugins/custom/index.d.ts.map +0 -1
- package/dist/plugins/end-attempt/index.d.ts.map +0 -1
- package/dist/plugins/extended-text/index.d.ts.map +0 -1
- package/dist/plugins/gap-match/index.d.ts.map +0 -1
- package/dist/plugins/graphic-associate/index.d.ts.map +0 -1
- package/dist/plugins/graphic-gap-match/index.d.ts.map +0 -1
- package/dist/plugins/graphic-order/index.d.ts.map +0 -1
- package/dist/plugins/hotspot/index.d.ts.map +0 -1
- package/dist/plugins/hottext/index.d.ts.map +0 -1
- package/dist/plugins/index.d.ts +0 -31
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/index.js +0 -31
- package/dist/plugins/match/index.d.ts.map +0 -1
- package/dist/plugins/media/index.d.ts.map +0 -1
- package/dist/plugins/order/index.d.ts.map +0 -1
- package/dist/plugins/position-object/index.d.ts.map +0 -1
- package/dist/plugins/select-point/index.d.ts.map +0 -1
- package/dist/plugins/slider/index.d.ts.map +0 -1
- package/dist/shared/actions/typesetAction.d.ts.map +0 -1
- package/dist/shared/extensions/MathLiveEditor.d.ts.map +0 -1
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/utils/eventHelpers.d.ts.map +0 -1
- package/dist/shared/utils/matchGroupUtils.d.ts.map +0 -1
- package/dist/shared/utils/pairHelpers.d.ts.map +0 -1
- package/dist/shared/utils/touchDragHelper.d.ts +0 -2
- package/dist/shared/utils/touchDragHelper.d.ts.map +0 -1
- package/dist/shared/utils/touchDragHelper.js +0 -1
- package/dist/shared/utils/webComponentHelpers.d.ts.map +0 -1
- package/src/catalog/CatalogPopup.svelte +0 -163
- package/src/index.ts +0 -141
- package/src/plugins/associate/AssociateInteraction.svelte +0 -304
- package/src/plugins/associate/index.ts +0 -9
- package/src/plugins/choice/ChoiceInteraction.svelte +0 -355
- package/src/plugins/choice/index.ts +0 -9
- package/src/plugins/custom/CustomInteraction.svelte +0 -61
- package/src/plugins/custom/index.ts +0 -9
- package/src/plugins/drawing/DrawingInteraction.svelte +0 -99
- package/src/plugins/end-attempt/EndAttemptInteraction.svelte +0 -142
- package/src/plugins/end-attempt/index.ts +0 -9
- package/src/plugins/extended-text/ExtendedTextInteraction.svelte +0 -152
- package/src/plugins/extended-text/index.ts +0 -9
- package/src/plugins/gap-match/GapMatchInteraction.svelte +0 -556
- package/src/plugins/gap-match/index.ts +0 -9
- package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +0 -503
- package/src/plugins/graphic-associate/index.ts +0 -9
- package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +0 -593
- package/src/plugins/graphic-gap-match/index.ts +0 -9
- package/src/plugins/graphic-order/GraphicOrderInteraction.svelte +0 -241
- package/src/plugins/graphic-order/index.ts +0 -9
- package/src/plugins/hotspot/HotspotInteraction.svelte +0 -287
- package/src/plugins/hotspot/index.ts +0 -9
- package/src/plugins/hottext/HottextInteraction.svelte +0 -325
- package/src/plugins/hottext/index.ts +0 -9
- package/src/plugins/index.ts +0 -32
- package/src/plugins/match/MatchInteraction.svelte +0 -82
- package/src/plugins/match/index.ts +0 -9
- package/src/plugins/media/MediaInteraction.svelte +0 -216
- package/src/plugins/media/index.ts +0 -9
- package/src/plugins/order/OrderInteraction.svelte +0 -280
- package/src/plugins/order/index.ts +0 -9
- package/src/plugins/position-object/PositionObjectInteraction.svelte +0 -903
- package/src/plugins/position-object/README.md +0 -130
- package/src/plugins/position-object/index.ts +0 -9
- package/src/plugins/select-point/SelectPointInteraction.svelte +0 -571
- package/src/plugins/select-point/index.ts +0 -9
- package/src/plugins/slider/SliderInteraction.svelte +0 -141
- package/src/plugins/slider/index.ts +0 -9
- package/src/plugins/upload/UploadInteraction.svelte +0 -59
- package/src/shared/actions/typesetAction.ts +0 -87
- package/src/shared/components/CustomInteractionFallback.svelte +0 -153
- package/src/shared/components/DragHandle.svelte +0 -44
- package/src/shared/components/DrawingCanvas.svelte +0 -259
- package/src/shared/components/FileUpload.svelte +0 -158
- package/src/shared/components/GraphicGapMatch.svelte +0 -318
- package/src/shared/components/GraphicGapMatchAdapter.svelte +0 -45
- package/src/shared/components/InlineInteractionRenderer.svelte +0 -141
- package/src/shared/components/MatchDragDrop.svelte +0 -481
- package/src/shared/components/MathContent.svelte +0 -18
- package/src/shared/components/ModalFeedbackDisplay.svelte +0 -91
- package/src/shared/components/RichTextEditor.svelte +0 -316
- package/src/shared/components/ShadowBaseStyles.svelte +0 -390
- package/src/shared/components/SortableList.svelte +0 -297
- package/src/shared/extensions/MathLiveEditor.ts +0 -299
- package/src/shared/index.ts +0 -15
- package/src/shared/styles/shared.css +0 -16
- package/src/shared/utils/eventHelpers.ts +0 -69
- package/src/shared/utils/matchGroupUtils.ts +0 -14
- package/src/shared/utils/pairHelpers.ts +0 -109
- package/src/shared/utils/webComponentHelpers.ts +0 -69
- package/src/svelte-shims.d.ts +0 -9
- /package/{src → dist}/shared/styles/qti-shared-vocabulary.css +0 -0
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
/**
|
|
3
|
-
* Sortable list component with keyboard, mouse, and touch support
|
|
4
|
-
* Accessible via drag-and-drop, keyboard (Space/Enter to grab, arrow keys to move), or touch
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { I18nProvider } from '@pie-qti/i18n';
|
|
8
|
-
import { touchDrag } from '@pie-qti/qti-common';
|
|
9
|
-
import DragHandle from './DragHandle.svelte';
|
|
10
|
-
import '../styles/shared.css';
|
|
11
|
-
|
|
12
|
-
interface Item {
|
|
13
|
-
id: string;
|
|
14
|
-
text: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface Props {
|
|
18
|
-
items: Item[];
|
|
19
|
-
orderedIds: string[];
|
|
20
|
-
correctOrder?: string[];
|
|
21
|
-
orientation?: 'vertical' | 'horizontal';
|
|
22
|
-
disabled?: boolean;
|
|
23
|
-
i18n?: I18nProvider;
|
|
24
|
-
onReorder: (newOrder: string[]) => void;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
items,
|
|
29
|
-
orderedIds,
|
|
30
|
-
correctOrder = [],
|
|
31
|
-
orientation = 'vertical',
|
|
32
|
-
disabled = false,
|
|
33
|
-
i18n,
|
|
34
|
-
onReorder,
|
|
35
|
-
}: Props = $props();
|
|
36
|
-
|
|
37
|
-
let draggedId = $state<string | null>(null);
|
|
38
|
-
let dragOverId = $state<string | null>(null);
|
|
39
|
-
let keyboardSelectedId = $state<string | null>(null); // Item picked up via keyboard
|
|
40
|
-
let announceText = $state<string>(''); // For screen reader announcements
|
|
41
|
-
|
|
42
|
-
// Mouse drag handlers
|
|
43
|
-
function handleDragStart(id: string) {
|
|
44
|
-
if (disabled) return;
|
|
45
|
-
draggedId = id;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function handleDragOver(event: DragEvent, id: string) {
|
|
49
|
-
if (disabled) return;
|
|
50
|
-
event.preventDefault();
|
|
51
|
-
dragOverId = id;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function handleDragLeave() {
|
|
55
|
-
dragOverId = null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function handleDrop(event: DragEvent, dropId: string) {
|
|
59
|
-
if (disabled || !draggedId) return;
|
|
60
|
-
event.preventDefault();
|
|
61
|
-
|
|
62
|
-
if (draggedId !== dropId) {
|
|
63
|
-
const oldIndex = orderedIds.indexOf(draggedId);
|
|
64
|
-
const newIndex = orderedIds.indexOf(dropId);
|
|
65
|
-
|
|
66
|
-
const newOrder = [...orderedIds];
|
|
67
|
-
newOrder.splice(oldIndex, 1);
|
|
68
|
-
newOrder.splice(newIndex, 0, draggedId);
|
|
69
|
-
|
|
70
|
-
onReorder(newOrder);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
draggedId = null;
|
|
74
|
-
dragOverId = null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function handleDragEnd() {
|
|
78
|
-
draggedId = null;
|
|
79
|
-
dragOverId = null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Keyboard handlers
|
|
83
|
-
function handleKeyDown(event: KeyboardEvent, id: string) {
|
|
84
|
-
if (disabled) return;
|
|
85
|
-
|
|
86
|
-
const currentIndex = orderedIds.indexOf(id);
|
|
87
|
-
const item = items.find((i) => i.id === id);
|
|
88
|
-
const itemName = item?.text || 'Item';
|
|
89
|
-
|
|
90
|
-
// Space or Enter: Pick up or drop item
|
|
91
|
-
if (event.key === ' ' || event.key === 'Enter') {
|
|
92
|
-
handlePickupOrDrop(event, id, itemName, currentIndex);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Escape: Cancel keyboard selection
|
|
97
|
-
if (event.key === 'Escape' && keyboardSelectedId) {
|
|
98
|
-
handleCancelSelection(event, itemName);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Arrow keys: Move item or change focus
|
|
103
|
-
if (keyboardSelectedId === id) {
|
|
104
|
-
handleArrowKeyMovement(event, itemName, currentIndex);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function handlePickupOrDrop(
|
|
109
|
-
event: KeyboardEvent,
|
|
110
|
-
id: string,
|
|
111
|
-
itemName: string,
|
|
112
|
-
currentIndex: number
|
|
113
|
-
) {
|
|
114
|
-
event.preventDefault();
|
|
115
|
-
|
|
116
|
-
if (keyboardSelectedId === id) {
|
|
117
|
-
// Drop item
|
|
118
|
-
keyboardSelectedId = null;
|
|
119
|
-
announceText = `${itemName} dropped at position ${currentIndex + 1} of ${orderedIds.length}`;
|
|
120
|
-
} else {
|
|
121
|
-
// Pick up item
|
|
122
|
-
keyboardSelectedId = id;
|
|
123
|
-
announceText = `${itemName} grabbed. Current position ${currentIndex + 1} of ${orderedIds.length}. Use arrow keys to move, Space or Enter to drop.`;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function handleCancelSelection(event: KeyboardEvent, itemName: string) {
|
|
128
|
-
event.preventDefault();
|
|
129
|
-
announceText = `${itemName} selection cancelled`;
|
|
130
|
-
keyboardSelectedId = null;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function handleArrowKeyMovement(event: KeyboardEvent, itemName: string, currentIndex: number) {
|
|
134
|
-
if (event.key === 'ArrowUp' && orientation === 'vertical' && currentIndex > 0) {
|
|
135
|
-
event.preventDefault();
|
|
136
|
-
moveItem(currentIndex, currentIndex - 1);
|
|
137
|
-
announceText = `${itemName} moved to position ${currentIndex} of ${orderedIds.length}`;
|
|
138
|
-
} else if (
|
|
139
|
-
event.key === 'ArrowDown' &&
|
|
140
|
-
orientation === 'vertical' &&
|
|
141
|
-
currentIndex < orderedIds.length - 1
|
|
142
|
-
) {
|
|
143
|
-
event.preventDefault();
|
|
144
|
-
moveItem(currentIndex, currentIndex + 1);
|
|
145
|
-
announceText = `${itemName} moved to position ${currentIndex + 2} of ${orderedIds.length}`;
|
|
146
|
-
} else if (event.key === 'ArrowLeft' && orientation === 'horizontal' && currentIndex > 0) {
|
|
147
|
-
event.preventDefault();
|
|
148
|
-
moveItem(currentIndex, currentIndex - 1);
|
|
149
|
-
announceText = `${itemName} moved to position ${currentIndex} of ${orderedIds.length}`;
|
|
150
|
-
} else if (
|
|
151
|
-
event.key === 'ArrowRight' &&
|
|
152
|
-
orientation === 'horizontal' &&
|
|
153
|
-
currentIndex < orderedIds.length - 1
|
|
154
|
-
) {
|
|
155
|
-
event.preventDefault();
|
|
156
|
-
moveItem(currentIndex, currentIndex + 1);
|
|
157
|
-
announceText = `${itemName} moved to position ${currentIndex + 2} of ${orderedIds.length}`;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function moveItem(fromIndex: number, toIndex: number) {
|
|
162
|
-
const newOrder = [...orderedIds];
|
|
163
|
-
const [movedItem] = newOrder.splice(fromIndex, 1);
|
|
164
|
-
newOrder.splice(toIndex, 0, movedItem);
|
|
165
|
-
onReorder(newOrder);
|
|
166
|
-
}
|
|
167
|
-
</script>
|
|
168
|
-
|
|
169
|
-
<!-- Screen reader announcements -->
|
|
170
|
-
<div aria-live="polite" aria-atomic="true" class="sr-only">
|
|
171
|
-
{announceText}
|
|
172
|
-
</div>
|
|
173
|
-
|
|
174
|
-
<!-- Instructions for keyboard users -->
|
|
175
|
-
<div id="sortable-instructions" class="sr-only">
|
|
176
|
-
Press Space or Enter to grab an item. Use arrow keys to move the item. Press Space or Enter again to drop. Press Escape to cancel.
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<div
|
|
180
|
-
role="list"
|
|
181
|
-
aria-label={i18n?.t('interactions.order.listLabel') ?? 'Reorderable list of choices'}
|
|
182
|
-
aria-describedby="sortable-instructions"
|
|
183
|
-
data-orientation={orientation}
|
|
184
|
-
part="list"
|
|
185
|
-
class="qti-sortable-list space-y-2"
|
|
186
|
-
class:flex={orientation === 'horizontal'}
|
|
187
|
-
class:gap-2={orientation === 'horizontal'}
|
|
188
|
-
>
|
|
189
|
-
{#each orderedIds as id, index (id)}
|
|
190
|
-
{@const item = items.find((i) => i.id === id)}
|
|
191
|
-
{#if item}
|
|
192
|
-
{@const isGrabbed = keyboardSelectedId === id}
|
|
193
|
-
{@const correctIndex = correctOrder.indexOf(id)}
|
|
194
|
-
{@const isCorrect = correctIndex !== -1 && correctIndex === index}
|
|
195
|
-
<div role="listitem">
|
|
196
|
-
<button
|
|
197
|
-
type="button"
|
|
198
|
-
draggable={!disabled}
|
|
199
|
-
use:touchDrag
|
|
200
|
-
ondragstart={() => handleDragStart(id)}
|
|
201
|
-
ondragover={(e) => handleDragOver(e, id)}
|
|
202
|
-
ondragleave={handleDragLeave}
|
|
203
|
-
ondrop={(e) => handleDrop(e, id)}
|
|
204
|
-
ondragend={handleDragEnd}
|
|
205
|
-
onkeydown={(e) => handleKeyDown(e, id)}
|
|
206
|
-
disabled={disabled}
|
|
207
|
-
aria-label="{item.text}. Position {index + 1} of {orderedIds.length}{isGrabbed ? '. Grabbed. Use arrow keys to move.' : ''}{isCorrect ? '. Correct position' : ''}"
|
|
208
|
-
aria-grabbed={isGrabbed}
|
|
209
|
-
data-grabbed={isGrabbed}
|
|
210
|
-
data-correct={isCorrect}
|
|
211
|
-
data-disabled={disabled}
|
|
212
|
-
part="item"
|
|
213
|
-
class="qti-sortable-item flex items-center gap-2 p-3 bg-base-200 rounded select-none transition-all w-full text-left"
|
|
214
|
-
class:cursor-grab={!disabled && !isGrabbed}
|
|
215
|
-
class:cursor-not-allowed={disabled}
|
|
216
|
-
class:opacity-50={disabled || draggedId === id}
|
|
217
|
-
class:ring-2={(dragOverId === id && draggedId !== id) || isGrabbed}
|
|
218
|
-
class:ring-primary={(dragOverId === id && draggedId !== id) || isGrabbed}
|
|
219
|
-
class:bg-primary={isGrabbed}
|
|
220
|
-
class:bg-opacity-20={isGrabbed || isCorrect}
|
|
221
|
-
class:bg-success={isCorrect}
|
|
222
|
-
class:border-success={isCorrect}
|
|
223
|
-
>
|
|
224
|
-
<span part="index" class="qti-sortable-index badge {isCorrect ? 'badge-success' : 'badge-neutral'}">{index + 1}</span>
|
|
225
|
-
<DragHandle size={1} opacity={0.5} class="text-base-content" />
|
|
226
|
-
<span part="text" class="qti-sortable-text flex-1">{item.text}</span>
|
|
227
|
-
{#if isCorrect}
|
|
228
|
-
<span class="badge badge-success badge-sm">{i18n?.t('interactions.choice.correct', 'Correct') ?? 'Correct'}</span>
|
|
229
|
-
{/if}
|
|
230
|
-
</button>
|
|
231
|
-
</div>
|
|
232
|
-
{/if}
|
|
233
|
-
{/each}
|
|
234
|
-
</div>
|
|
235
|
-
|
|
236
|
-
<style>
|
|
237
|
-
/* Minimal, self-contained layout so the component doesn't break when Tailwind utilities aren't present */
|
|
238
|
-
.qti-sortable-list {
|
|
239
|
-
display: flex;
|
|
240
|
-
flex-direction: column;
|
|
241
|
-
gap: 0.5rem;
|
|
242
|
-
}
|
|
243
|
-
.qti-sortable-list[data-orientation='horizontal'] {
|
|
244
|
-
flex-direction: row;
|
|
245
|
-
flex-wrap: wrap;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
.qti-sortable-item {
|
|
249
|
-
display: flex;
|
|
250
|
-
align-items: center;
|
|
251
|
-
gap: 0.5rem;
|
|
252
|
-
width: 100%;
|
|
253
|
-
padding: 0.75rem;
|
|
254
|
-
border-radius: 0.5rem;
|
|
255
|
-
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
256
|
-
background: var(--color-base-200, oklch(98% 0 0));
|
|
257
|
-
color: var(--color-base-content, oklch(21% 0 0));
|
|
258
|
-
text-align: left;
|
|
259
|
-
user-select: none;
|
|
260
|
-
transition: background-color 120ms ease, border-color 120ms ease, outline-color 120ms ease,
|
|
261
|
-
opacity 120ms ease;
|
|
262
|
-
}
|
|
263
|
-
.qti-sortable-item:focus-visible {
|
|
264
|
-
outline: 2px solid var(--color-primary, oklch(45% 0.24 277));
|
|
265
|
-
outline-offset: 2px;
|
|
266
|
-
}
|
|
267
|
-
.qti-sortable-item[data-grabbed='true'] {
|
|
268
|
-
border-color: var(--color-primary, oklch(45% 0.24 277));
|
|
269
|
-
background: color-mix(in oklch, var(--color-primary, oklch(45% 0.24 277)) 8%, transparent);
|
|
270
|
-
}
|
|
271
|
-
.qti-sortable-item[data-correct='true'] {
|
|
272
|
-
border-color: var(--color-success, oklch(76% 0.177 163.223));
|
|
273
|
-
background: color-mix(in oklch, var(--color-success, oklch(76% 0.177 163.223)) 8%, transparent);
|
|
274
|
-
}
|
|
275
|
-
.qti-sortable-item[data-disabled='true'] {
|
|
276
|
-
opacity: 0.55;
|
|
277
|
-
cursor: not-allowed;
|
|
278
|
-
}
|
|
279
|
-
.qti-sortable-index {
|
|
280
|
-
display: inline-flex;
|
|
281
|
-
align-items: center;
|
|
282
|
-
justify-content: center;
|
|
283
|
-
min-width: 1.75rem;
|
|
284
|
-
height: 1.25rem;
|
|
285
|
-
padding: 0 0.4rem;
|
|
286
|
-
border-radius: 9999px;
|
|
287
|
-
font-size: 0.75rem;
|
|
288
|
-
font-weight: 600;
|
|
289
|
-
border: 1px solid var(--color-base-300, oklch(95% 0 0));
|
|
290
|
-
background: var(--color-base-100, oklch(100% 0 0));
|
|
291
|
-
color: var(--color-base-content, oklch(21% 0 0));
|
|
292
|
-
}
|
|
293
|
-
.qti-sortable-text {
|
|
294
|
-
flex: 1 1 auto;
|
|
295
|
-
min-width: 0;
|
|
296
|
-
}
|
|
297
|
-
</style>
|
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
/// <reference lib="dom" />
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* MathLive Editor Extension for TipTap
|
|
5
|
-
*
|
|
6
|
-
* Integrates MathLive (visual math editor) with TipTap's Mathematics extension.
|
|
7
|
-
* Provides a modal dialog with MathLive mathfield for editing LaTeX formulas.
|
|
8
|
-
*
|
|
9
|
-
* Note: MathLive CSS is loaded dynamically to avoid build issues with package exports.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { MathfieldElement } from 'mathlive';
|
|
13
|
-
// Import MathLive CSS from the local package
|
|
14
|
-
import 'mathlive/static.css';
|
|
15
|
-
|
|
16
|
-
// Dynamically import MathLive to register the custom element
|
|
17
|
-
let mathLiveLoaded: Promise<void> | null = null;
|
|
18
|
-
|
|
19
|
-
async function ensureMathLiveLoaded(): Promise<void> {
|
|
20
|
-
if (!mathLiveLoaded && typeof window !== 'undefined') {
|
|
21
|
-
mathLiveLoaded = (async () => {
|
|
22
|
-
// Import MathLive to register the <math-field> custom element
|
|
23
|
-
// CSS is already imported at the top of this file
|
|
24
|
-
await import('mathlive');
|
|
25
|
-
})();
|
|
26
|
-
}
|
|
27
|
-
return mathLiveLoaded || Promise.resolve();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface MathLiveEditorOptions {
|
|
31
|
-
/** Called when user confirms the LaTeX input */
|
|
32
|
-
onConfirm: (latex: string) => void;
|
|
33
|
-
/** Called when user cancels */
|
|
34
|
-
onCancel: () => void;
|
|
35
|
-
/** Initial LaTeX value */
|
|
36
|
-
initialLatex?: string;
|
|
37
|
-
/** Whether this is inline or block math */
|
|
38
|
-
isBlock?: boolean;
|
|
39
|
-
/** Optional i18n provider for translations */
|
|
40
|
-
i18n?: { t: (key: string) => string | undefined };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Opens a modal dialog with MathLive editor for LaTeX input
|
|
45
|
-
*/
|
|
46
|
-
export async function openMathLiveEditor(options: MathLiveEditorOptions): Promise<() => void> {
|
|
47
|
-
const { onConfirm, onCancel, initialLatex = '', isBlock = false } = options;
|
|
48
|
-
|
|
49
|
-
// Ensure MathLive is loaded and registered before creating the mathfield
|
|
50
|
-
await ensureMathLiveLoaded();
|
|
51
|
-
|
|
52
|
-
// Create modal overlay - use DaisyUI modal classes
|
|
53
|
-
const overlay = document.createElement('div');
|
|
54
|
-
overlay.className = 'modal modal-open';
|
|
55
|
-
overlay.style.cssText = `
|
|
56
|
-
position: fixed;
|
|
57
|
-
top: 0;
|
|
58
|
-
left: 0;
|
|
59
|
-
right: 0;
|
|
60
|
-
bottom: 0;
|
|
61
|
-
background: rgba(0, 0, 0, 0.5);
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
justify-content: center;
|
|
65
|
-
z-index: 9999;
|
|
66
|
-
`;
|
|
67
|
-
|
|
68
|
-
// Create modal dialog - use DaisyUI modal-box class
|
|
69
|
-
const modal = document.createElement('div');
|
|
70
|
-
modal.className = 'modal-box max-w-2xl';
|
|
71
|
-
modal.style.cssText = `
|
|
72
|
-
padding: 1.5rem;
|
|
73
|
-
position: relative;
|
|
74
|
-
z-index: 10000;
|
|
75
|
-
`;
|
|
76
|
-
|
|
77
|
-
// Create header - use DaisyUI font-bold text-lg
|
|
78
|
-
const header = document.createElement('h3');
|
|
79
|
-
header.textContent = isBlock ? (options.i18n?.t('interactions.extendedText.insertBlockMath') ?? 'Insert Block Math') : (options.i18n?.t('interactions.extendedText.insertInlineMath') ?? 'Insert Inline Math');
|
|
80
|
-
header.className = 'font-bold text-lg mb-4';
|
|
81
|
-
|
|
82
|
-
// Create form control wrapper
|
|
83
|
-
const formControl = document.createElement('div');
|
|
84
|
-
formControl.className = 'form-control';
|
|
85
|
-
|
|
86
|
-
// Create label for mathfield
|
|
87
|
-
const label = document.createElement('label');
|
|
88
|
-
label.className = 'label';
|
|
89
|
-
const labelText = document.createElement('span');
|
|
90
|
-
labelText.className = 'label-text';
|
|
91
|
-
labelText.textContent = options.i18n?.t('interactions.extendedText.enterMathExpression') ?? 'Enter your math expression:';
|
|
92
|
-
label.appendChild(labelText);
|
|
93
|
-
|
|
94
|
-
// Create MathLive mathfield - style like DaisyUI input
|
|
95
|
-
const mathfield = document.createElement('math-field') as MathfieldElement;
|
|
96
|
-
mathfield.value = initialLatex;
|
|
97
|
-
mathfield.className = 'input input-bordered w-full';
|
|
98
|
-
mathfield.style.cssText = `
|
|
99
|
-
display: block;
|
|
100
|
-
min-height: 100px;
|
|
101
|
-
padding: 0.75rem;
|
|
102
|
-
font-size: 1.125rem;
|
|
103
|
-
`;
|
|
104
|
-
|
|
105
|
-
// Set MathLive options for better UX via attributes
|
|
106
|
-
// Use 'manual' mode so keyboard only shows when explicitly requested
|
|
107
|
-
mathfield.setAttribute('virtual-keyboard-mode', 'manual');
|
|
108
|
-
mathfield.setAttribute('smart-mode', 'on');
|
|
109
|
-
// Explicitly enable virtual keyboard
|
|
110
|
-
mathfield.setAttribute('use-shared-virtual-keyboard', 'true');
|
|
111
|
-
// Hide the built-in virtual keyboard toggle
|
|
112
|
-
mathfield.setAttribute('virtual-keyboard-toggle-glyph', '');
|
|
113
|
-
|
|
114
|
-
// Inject CSS to ensure virtual keyboard appears above modal and accepts clicks
|
|
115
|
-
const style = document.createElement('style');
|
|
116
|
-
style.textContent = `
|
|
117
|
-
/* Ensure MathLive virtual keyboard appears above the modal and is clickable */
|
|
118
|
-
.ML__keyboard {
|
|
119
|
-
z-index: 10001 !important;
|
|
120
|
-
pointer-events: auto !important;
|
|
121
|
-
}
|
|
122
|
-
/* Hide the built-in keyboard toggle button in the mathfield - try multiple selectors */
|
|
123
|
-
.ML__virtual-keyboard-toggle,
|
|
124
|
-
.ML__keyboard-toggle,
|
|
125
|
-
math-field::part(virtual-keyboard-toggle) {
|
|
126
|
-
display: none !important;
|
|
127
|
-
visibility: hidden !important;
|
|
128
|
-
opacity: 0 !important;
|
|
129
|
-
pointer-events: none !important;
|
|
130
|
-
}
|
|
131
|
-
`;
|
|
132
|
-
document.head.appendChild(style);
|
|
133
|
-
|
|
134
|
-
// Create LaTeX preview label
|
|
135
|
-
const previewLabel = document.createElement('label');
|
|
136
|
-
previewLabel.className = 'label';
|
|
137
|
-
const previewLabelText = document.createElement('span');
|
|
138
|
-
previewLabelText.className = 'label-text';
|
|
139
|
-
previewLabelText.textContent = options.i18n?.t('interactions.extendedText.latexSource') ?? 'LaTeX source:';
|
|
140
|
-
previewLabel.appendChild(previewLabelText);
|
|
141
|
-
|
|
142
|
-
// Create LaTeX preview/source - use alert info styling
|
|
143
|
-
const latexPreview = document.createElement('div');
|
|
144
|
-
latexPreview.className = 'alert alert-info';
|
|
145
|
-
latexPreview.style.cssText = `
|
|
146
|
-
font-family: 'Monaco', 'Courier New', monospace;
|
|
147
|
-
font-size: 0.875rem;
|
|
148
|
-
word-break: break-all;
|
|
149
|
-
margin-bottom: 1rem;
|
|
150
|
-
`;
|
|
151
|
-
latexPreview.textContent = initialLatex || '(LaTeX will appear here)';
|
|
152
|
-
|
|
153
|
-
// Update preview when mathfield changes
|
|
154
|
-
mathfield.addEventListener('input', () => {
|
|
155
|
-
const latex = mathfield.value;
|
|
156
|
-
latexPreview.textContent = latex || '(LaTeX will appear here)';
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Create button container - use DaisyUI modal-action class
|
|
160
|
-
const buttons = document.createElement('div');
|
|
161
|
-
buttons.className = 'modal-action';
|
|
162
|
-
buttons.style.cssText = 'justify-content: space-between;';
|
|
163
|
-
|
|
164
|
-
// Create left-side buttons (keyboard toggle)
|
|
165
|
-
const leftButtons = document.createElement('div');
|
|
166
|
-
leftButtons.style.cssText = 'display: flex; gap: 0.5rem;';
|
|
167
|
-
|
|
168
|
-
// Create Keyboard Toggle button
|
|
169
|
-
const keyboardBtn = document.createElement('button');
|
|
170
|
-
keyboardBtn.textContent = `⌨️ ${options.i18n?.t('interactions.extendedText.keyboard') ?? 'Keyboard'}`;
|
|
171
|
-
keyboardBtn.type = 'button';
|
|
172
|
-
keyboardBtn.className = 'btn btn-sm btn-outline';
|
|
173
|
-
keyboardBtn.onclick = () => {
|
|
174
|
-
if (mathfield.executeCommand) {
|
|
175
|
-
mathfield.executeCommand('toggleVirtualKeyboard');
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
leftButtons.appendChild(keyboardBtn);
|
|
180
|
-
|
|
181
|
-
// Create right-side buttons (Cancel/Insert)
|
|
182
|
-
const rightButtons = document.createElement('div');
|
|
183
|
-
rightButtons.style.cssText = 'display: flex; gap: 0.5rem;';
|
|
184
|
-
|
|
185
|
-
// Create Cancel button - use DaisyUI classes
|
|
186
|
-
const cancelBtn = document.createElement('button');
|
|
187
|
-
cancelBtn.textContent = options.i18n?.t('common.cancel') ?? 'Cancel';
|
|
188
|
-
cancelBtn.type = 'button';
|
|
189
|
-
cancelBtn.className = 'btn btn-ghost';
|
|
190
|
-
|
|
191
|
-
// Create Insert button - use DaisyUI classes
|
|
192
|
-
const insertBtn = document.createElement('button');
|
|
193
|
-
insertBtn.textContent = initialLatex
|
|
194
|
-
? (options.i18n?.t('interactions.extendedText.update') ?? 'Update')
|
|
195
|
-
: (options.i18n?.t('interactions.extendedText.insert') ?? 'Insert');
|
|
196
|
-
insertBtn.type = 'button';
|
|
197
|
-
insertBtn.className = 'btn btn-primary';
|
|
198
|
-
|
|
199
|
-
rightButtons.appendChild(cancelBtn);
|
|
200
|
-
rightButtons.appendChild(insertBtn);
|
|
201
|
-
|
|
202
|
-
// Assemble modal
|
|
203
|
-
buttons.appendChild(leftButtons);
|
|
204
|
-
buttons.appendChild(rightButtons);
|
|
205
|
-
|
|
206
|
-
// Assemble form-control
|
|
207
|
-
formControl.appendChild(label);
|
|
208
|
-
formControl.appendChild(mathfield);
|
|
209
|
-
formControl.appendChild(previewLabel);
|
|
210
|
-
formControl.appendChild(latexPreview);
|
|
211
|
-
|
|
212
|
-
modal.appendChild(header);
|
|
213
|
-
modal.appendChild(formControl);
|
|
214
|
-
modal.appendChild(buttons);
|
|
215
|
-
|
|
216
|
-
overlay.appendChild(modal);
|
|
217
|
-
|
|
218
|
-
// Cleanup function
|
|
219
|
-
const cleanup = () => {
|
|
220
|
-
// Remove event listeners to prevent memory leaks
|
|
221
|
-
cancelBtn.removeEventListener('click', handleCancel);
|
|
222
|
-
insertBtn.removeEventListener('click', handleConfirm);
|
|
223
|
-
document.removeEventListener('keydown', handleEscape);
|
|
224
|
-
overlay.removeEventListener('click', handleOverlayClick);
|
|
225
|
-
|
|
226
|
-
// Hide virtual keyboard before cleanup
|
|
227
|
-
if (mathfield.executeCommand) {
|
|
228
|
-
mathfield.executeCommand('hideVirtualKeyboard');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Remove DOM elements
|
|
232
|
-
overlay.remove();
|
|
233
|
-
style.remove();
|
|
234
|
-
|
|
235
|
-
// Restore body scroll
|
|
236
|
-
document.body.style.overflow = '';
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
// Event handlers
|
|
240
|
-
const handleCancel = () => {
|
|
241
|
-
cleanup();
|
|
242
|
-
onCancel();
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
const handleConfirm = () => {
|
|
246
|
-
const latex = mathfield.value;
|
|
247
|
-
cleanup();
|
|
248
|
-
onConfirm(latex);
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const handleEscape = (e: KeyboardEvent) => {
|
|
252
|
-
if (e.key === 'Escape') {
|
|
253
|
-
handleCancel();
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
const handleOverlayClick = (e: MouseEvent) => {
|
|
258
|
-
// Don't close if clicking on the modal content or virtual keyboard
|
|
259
|
-
const target = e.target as HTMLElement;
|
|
260
|
-
|
|
261
|
-
// Check if click is on overlay background (not modal or keyboard)
|
|
262
|
-
if (target === overlay) {
|
|
263
|
-
// Additional check: don't close if virtual keyboard is open
|
|
264
|
-
// MathLive virtual keyboard has class 'ML__keyboard'
|
|
265
|
-
const virtualKeyboard = document.querySelector('.ML__keyboard');
|
|
266
|
-
if (!virtualKeyboard) {
|
|
267
|
-
handleCancel();
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// Attach event listeners
|
|
273
|
-
cancelBtn.addEventListener('click', handleCancel);
|
|
274
|
-
insertBtn.addEventListener('click', handleConfirm);
|
|
275
|
-
document.addEventListener('keydown', handleEscape);
|
|
276
|
-
overlay.addEventListener('click', handleOverlayClick);
|
|
277
|
-
|
|
278
|
-
// Prevent body scroll when modal is open
|
|
279
|
-
document.body.style.overflow = 'hidden';
|
|
280
|
-
|
|
281
|
-
// Add to DOM
|
|
282
|
-
document.body.appendChild(overlay);
|
|
283
|
-
|
|
284
|
-
// Focus the mathfield (but don't auto-show keyboard)
|
|
285
|
-
setTimeout(() => {
|
|
286
|
-
mathfield.focus();
|
|
287
|
-
// Try to programmatically disable the built-in toggle via options
|
|
288
|
-
try {
|
|
289
|
-
(mathfield as any).setOptions({
|
|
290
|
-
virtualKeyboardToggleGlyph: '',
|
|
291
|
-
});
|
|
292
|
-
} catch (e) {
|
|
293
|
-
// Silently ignore if this API doesn't exist
|
|
294
|
-
}
|
|
295
|
-
}, 100);
|
|
296
|
-
|
|
297
|
-
// Return cleanup function
|
|
298
|
-
return cleanup;
|
|
299
|
-
}
|
package/src/shared/index.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared utilities and helpers for QTI interaction plugins
|
|
3
|
-
*
|
|
4
|
-
* This module exports common utilities used across all interaction plugins.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Typeset action for math rendering
|
|
9
|
-
export * from './actions/typesetAction.js';
|
|
10
|
-
// MathLive editor extension for visual math input
|
|
11
|
-
export * from './extensions/MathLiveEditor.js';
|
|
12
|
-
// Event helpers for creating CustomEvents
|
|
13
|
-
export * from './utils/eventHelpers.js';
|
|
14
|
-
// Pair helpers for matching/association interactions
|
|
15
|
-
export * from './utils/pairHelpers.js';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared styles for QTI components
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
/* Screen reader only - hides content visually but keeps it accessible */
|
|
6
|
-
.sr-only {
|
|
7
|
-
position: absolute;
|
|
8
|
-
width: 1px;
|
|
9
|
-
height: 1px;
|
|
10
|
-
padding: 0;
|
|
11
|
-
margin: -1px;
|
|
12
|
-
overflow: hidden;
|
|
13
|
-
clip: rect(0, 0, 0, 0);
|
|
14
|
-
white-space: nowrap;
|
|
15
|
-
border-width: 0;
|
|
16
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import type { QTIChangeEventDetail } from '@pie-qti/item-player/web-components';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Event emission helpers for QTI components
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a standardized QTI change event
|
|
9
|
-
* @param responseId - The response identifier
|
|
10
|
-
* @param value - The response value
|
|
11
|
-
* @returns A CustomEvent that can be dispatched
|
|
12
|
-
*/
|
|
13
|
-
function requireResponseId(responseId: string | undefined): string {
|
|
14
|
-
if (!responseId || responseId.trim().length === 0) {
|
|
15
|
-
throw new Error('qti-change event requires a non-empty responseId');
|
|
16
|
-
}
|
|
17
|
-
return responseId;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type TypedQtiChangeEventDetail<TValue> = Omit<QTIChangeEventDetail, 'value'> & {
|
|
21
|
-
value: TValue;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export function createQtiChangeEvent<TValue = unknown>(
|
|
25
|
-
responseId: string | undefined,
|
|
26
|
-
value: TValue
|
|
27
|
-
): CustomEvent<TypedQtiChangeEventDetail<TValue>> {
|
|
28
|
-
return new CustomEvent('qti-change', {
|
|
29
|
-
detail: {
|
|
30
|
-
responseId: requireResponseId(responseId),
|
|
31
|
-
value,
|
|
32
|
-
timestamp: Date.now(),
|
|
33
|
-
},
|
|
34
|
-
bubbles: true,
|
|
35
|
-
composed: true,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Emits a QTI change event from an element
|
|
41
|
-
* @param element - The element to dispatch from (usually component root)
|
|
42
|
-
* @param responseId - The response identifier
|
|
43
|
-
* @param value - The response value
|
|
44
|
-
*/
|
|
45
|
-
export function emitQtiChange(
|
|
46
|
-
element: HTMLElement | EventTarget,
|
|
47
|
-
responseId: string | undefined,
|
|
48
|
-
value: unknown
|
|
49
|
-
): void {
|
|
50
|
-
const event = createQtiChangeEvent(responseId, value);
|
|
51
|
-
element.dispatchEvent(event);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function emitInteractionChange<TValue>({
|
|
55
|
-
target,
|
|
56
|
-
responseId,
|
|
57
|
-
value,
|
|
58
|
-
onChange,
|
|
59
|
-
}: {
|
|
60
|
-
target: HTMLElement | EventTarget | undefined;
|
|
61
|
-
responseId: string | undefined;
|
|
62
|
-
value: TValue;
|
|
63
|
-
onChange?: (value: TValue) => void;
|
|
64
|
-
}): void {
|
|
65
|
-
onChange?.(value);
|
|
66
|
-
if (target) {
|
|
67
|
-
emitQtiChange(target, responseId, value);
|
|
68
|
-
}
|
|
69
|
-
}
|