@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.
Files changed (180) hide show
  1. package/dist/chunks/__vite-browser-external-BjvdLQIS.js +9 -0
  2. package/dist/chunks/__vite-browser-external-BjvdLQIS.js.map +1 -0
  3. package/dist/chunks/chunk-Bayd9M4T.js +20 -0
  4. package/dist/chunks/{mathlive.min-Bvtiaxg4.js → mathlive.min-CAPebTxM.js} +245 -29
  5. package/dist/chunks/{mathlive.min-Bvtiaxg4.js.map → mathlive.min-CAPebTxM.js.map} +1 -1
  6. package/dist/index.d.ts +0 -1
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/plugins/associate/index.d.ts +0 -1
  10. package/dist/plugins/associate/index.js +1 -0
  11. package/dist/plugins/associate/index.js.map +1 -0
  12. package/dist/plugins/choice/index.d.ts +0 -1
  13. package/dist/plugins/choice/index.js +1 -0
  14. package/dist/plugins/choice/index.js.map +1 -0
  15. package/dist/plugins/custom/index.d.ts +0 -1
  16. package/dist/plugins/custom/index.js +1 -0
  17. package/dist/plugins/custom/index.js.map +1 -0
  18. package/dist/plugins/end-attempt/index.d.ts +0 -1
  19. package/dist/plugins/end-attempt/index.js +1 -0
  20. package/dist/plugins/end-attempt/index.js.map +1 -0
  21. package/dist/plugins/extended-text/index.d.ts +0 -1
  22. package/dist/plugins/extended-text/index.js +1 -0
  23. package/dist/plugins/extended-text/index.js.map +1 -0
  24. package/dist/plugins/gap-match/index.d.ts +0 -1
  25. package/dist/plugins/gap-match/index.js +1 -0
  26. package/dist/plugins/gap-match/index.js.map +1 -0
  27. package/dist/plugins/graphic-associate/index.d.ts +0 -1
  28. package/dist/plugins/graphic-associate/index.js +1 -0
  29. package/dist/plugins/graphic-associate/index.js.map +1 -0
  30. package/dist/plugins/graphic-gap-match/index.d.ts +0 -1
  31. package/dist/plugins/graphic-gap-match/index.js +1 -0
  32. package/dist/plugins/graphic-gap-match/index.js.map +1 -0
  33. package/dist/plugins/graphic-order/index.d.ts +0 -1
  34. package/dist/plugins/graphic-order/index.js +1 -0
  35. package/dist/plugins/graphic-order/index.js.map +1 -0
  36. package/dist/plugins/hotspot/index.d.ts +0 -1
  37. package/dist/plugins/hotspot/index.js +1 -0
  38. package/dist/plugins/hotspot/index.js.map +1 -0
  39. package/dist/plugins/hottext/index.d.ts +0 -1
  40. package/dist/plugins/hottext/index.js +1 -0
  41. package/dist/plugins/hottext/index.js.map +1 -0
  42. package/dist/plugins/match/index.d.ts +0 -1
  43. package/dist/plugins/match/index.js +1 -0
  44. package/dist/plugins/match/index.js.map +1 -0
  45. package/dist/plugins/media/index.d.ts +0 -1
  46. package/dist/plugins/media/index.js +1 -0
  47. package/dist/plugins/media/index.js.map +1 -0
  48. package/dist/plugins/order/index.d.ts +0 -1
  49. package/dist/plugins/order/index.js +1 -0
  50. package/dist/plugins/order/index.js.map +1 -0
  51. package/dist/plugins/position-object/index.d.ts +0 -1
  52. package/dist/plugins/position-object/index.js +1 -0
  53. package/dist/plugins/position-object/index.js.map +1 -0
  54. package/dist/plugins/public-types.d.ts +5 -0
  55. package/dist/plugins/public-types.js +2 -0
  56. package/dist/plugins/public-types.js.map +1 -0
  57. package/dist/plugins/select-point/index.d.ts +0 -1
  58. package/dist/plugins/select-point/index.js +1 -0
  59. package/dist/plugins/select-point/index.js.map +1 -0
  60. package/dist/plugins/slider/index.d.ts +0 -1
  61. package/dist/plugins/slider/index.js +1 -0
  62. package/dist/plugins/slider/index.js.map +1 -0
  63. package/dist/plugins.js +25917 -7690
  64. package/dist/plugins.js.map +1 -1
  65. package/dist/shared/actions/typesetAction.d.ts +0 -1
  66. package/dist/shared/actions/typesetAction.js +1 -0
  67. package/dist/shared/actions/typesetAction.js.map +1 -0
  68. package/dist/shared/extensions/MathLiveEditor.d.ts +0 -1
  69. package/dist/shared/extensions/MathLiveEditor.js +1 -0
  70. package/dist/shared/extensions/MathLiveEditor.js.map +1 -0
  71. package/dist/shared/index.d.ts +0 -1
  72. package/dist/shared/index.js +1 -0
  73. package/dist/shared/index.js.map +1 -0
  74. package/dist/shared/utils/eventHelpers.d.ts +0 -1
  75. package/dist/shared/utils/eventHelpers.js +1 -0
  76. package/dist/shared/utils/eventHelpers.js.map +1 -0
  77. package/dist/shared/utils/matchGroupUtils.d.ts +0 -1
  78. package/dist/shared/utils/matchGroupUtils.js +1 -0
  79. package/dist/shared/utils/matchGroupUtils.js.map +1 -0
  80. package/dist/shared/utils/pairHelpers.d.ts +0 -1
  81. package/dist/shared/utils/pairHelpers.js +1 -0
  82. package/dist/shared/utils/pairHelpers.js.map +1 -0
  83. package/dist/shared/utils/webComponentHelpers.d.ts +0 -1
  84. package/dist/shared/utils/webComponentHelpers.js +1 -0
  85. package/dist/shared/utils/webComponentHelpers.js.map +1 -0
  86. package/package.json +11 -33
  87. package/dist/index.d.ts.map +0 -1
  88. package/dist/plugins/associate/index.d.ts.map +0 -1
  89. package/dist/plugins/choice/index.d.ts.map +0 -1
  90. package/dist/plugins/custom/index.d.ts.map +0 -1
  91. package/dist/plugins/end-attempt/index.d.ts.map +0 -1
  92. package/dist/plugins/extended-text/index.d.ts.map +0 -1
  93. package/dist/plugins/gap-match/index.d.ts.map +0 -1
  94. package/dist/plugins/graphic-associate/index.d.ts.map +0 -1
  95. package/dist/plugins/graphic-gap-match/index.d.ts.map +0 -1
  96. package/dist/plugins/graphic-order/index.d.ts.map +0 -1
  97. package/dist/plugins/hotspot/index.d.ts.map +0 -1
  98. package/dist/plugins/hottext/index.d.ts.map +0 -1
  99. package/dist/plugins/index.d.ts +0 -31
  100. package/dist/plugins/index.d.ts.map +0 -1
  101. package/dist/plugins/index.js +0 -31
  102. package/dist/plugins/match/index.d.ts.map +0 -1
  103. package/dist/plugins/media/index.d.ts.map +0 -1
  104. package/dist/plugins/order/index.d.ts.map +0 -1
  105. package/dist/plugins/position-object/index.d.ts.map +0 -1
  106. package/dist/plugins/select-point/index.d.ts.map +0 -1
  107. package/dist/plugins/slider/index.d.ts.map +0 -1
  108. package/dist/shared/actions/typesetAction.d.ts.map +0 -1
  109. package/dist/shared/extensions/MathLiveEditor.d.ts.map +0 -1
  110. package/dist/shared/index.d.ts.map +0 -1
  111. package/dist/shared/utils/eventHelpers.d.ts.map +0 -1
  112. package/dist/shared/utils/matchGroupUtils.d.ts.map +0 -1
  113. package/dist/shared/utils/pairHelpers.d.ts.map +0 -1
  114. package/dist/shared/utils/touchDragHelper.d.ts +0 -2
  115. package/dist/shared/utils/touchDragHelper.d.ts.map +0 -1
  116. package/dist/shared/utils/touchDragHelper.js +0 -1
  117. package/dist/shared/utils/webComponentHelpers.d.ts.map +0 -1
  118. package/src/catalog/CatalogPopup.svelte +0 -163
  119. package/src/index.ts +0 -141
  120. package/src/plugins/associate/AssociateInteraction.svelte +0 -304
  121. package/src/plugins/associate/index.ts +0 -9
  122. package/src/plugins/choice/ChoiceInteraction.svelte +0 -355
  123. package/src/plugins/choice/index.ts +0 -9
  124. package/src/plugins/custom/CustomInteraction.svelte +0 -61
  125. package/src/plugins/custom/index.ts +0 -9
  126. package/src/plugins/drawing/DrawingInteraction.svelte +0 -99
  127. package/src/plugins/end-attempt/EndAttemptInteraction.svelte +0 -142
  128. package/src/plugins/end-attempt/index.ts +0 -9
  129. package/src/plugins/extended-text/ExtendedTextInteraction.svelte +0 -152
  130. package/src/plugins/extended-text/index.ts +0 -9
  131. package/src/plugins/gap-match/GapMatchInteraction.svelte +0 -556
  132. package/src/plugins/gap-match/index.ts +0 -9
  133. package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +0 -503
  134. package/src/plugins/graphic-associate/index.ts +0 -9
  135. package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +0 -593
  136. package/src/plugins/graphic-gap-match/index.ts +0 -9
  137. package/src/plugins/graphic-order/GraphicOrderInteraction.svelte +0 -241
  138. package/src/plugins/graphic-order/index.ts +0 -9
  139. package/src/plugins/hotspot/HotspotInteraction.svelte +0 -287
  140. package/src/plugins/hotspot/index.ts +0 -9
  141. package/src/plugins/hottext/HottextInteraction.svelte +0 -325
  142. package/src/plugins/hottext/index.ts +0 -9
  143. package/src/plugins/index.ts +0 -32
  144. package/src/plugins/match/MatchInteraction.svelte +0 -82
  145. package/src/plugins/match/index.ts +0 -9
  146. package/src/plugins/media/MediaInteraction.svelte +0 -216
  147. package/src/plugins/media/index.ts +0 -9
  148. package/src/plugins/order/OrderInteraction.svelte +0 -280
  149. package/src/plugins/order/index.ts +0 -9
  150. package/src/plugins/position-object/PositionObjectInteraction.svelte +0 -903
  151. package/src/plugins/position-object/README.md +0 -130
  152. package/src/plugins/position-object/index.ts +0 -9
  153. package/src/plugins/select-point/SelectPointInteraction.svelte +0 -571
  154. package/src/plugins/select-point/index.ts +0 -9
  155. package/src/plugins/slider/SliderInteraction.svelte +0 -141
  156. package/src/plugins/slider/index.ts +0 -9
  157. package/src/plugins/upload/UploadInteraction.svelte +0 -59
  158. package/src/shared/actions/typesetAction.ts +0 -87
  159. package/src/shared/components/CustomInteractionFallback.svelte +0 -153
  160. package/src/shared/components/DragHandle.svelte +0 -44
  161. package/src/shared/components/DrawingCanvas.svelte +0 -259
  162. package/src/shared/components/FileUpload.svelte +0 -158
  163. package/src/shared/components/GraphicGapMatch.svelte +0 -318
  164. package/src/shared/components/GraphicGapMatchAdapter.svelte +0 -45
  165. package/src/shared/components/InlineInteractionRenderer.svelte +0 -141
  166. package/src/shared/components/MatchDragDrop.svelte +0 -481
  167. package/src/shared/components/MathContent.svelte +0 -18
  168. package/src/shared/components/ModalFeedbackDisplay.svelte +0 -91
  169. package/src/shared/components/RichTextEditor.svelte +0 -316
  170. package/src/shared/components/ShadowBaseStyles.svelte +0 -390
  171. package/src/shared/components/SortableList.svelte +0 -297
  172. package/src/shared/extensions/MathLiveEditor.ts +0 -299
  173. package/src/shared/index.ts +0 -15
  174. package/src/shared/styles/shared.css +0 -16
  175. package/src/shared/utils/eventHelpers.ts +0 -69
  176. package/src/shared/utils/matchGroupUtils.ts +0 -14
  177. package/src/shared/utils/pairHelpers.ts +0 -109
  178. package/src/shared/utils/webComponentHelpers.ts +0 -69
  179. package/src/svelte-shims.d.ts +0 -9
  180. /package/{src → dist}/shared/styles/qti-shared-vocabulary.css +0 -0
@@ -1,280 +0,0 @@
1
- <svelte:options customElement="pie-qti-order" />
2
-
3
- <script lang="ts">
4
- import type { OrderInteractionData } from '@pie-qti/item-player';
5
- import type { I18nProvider } from '@pie-qti/i18n';
6
- import { typesetAction } from '../../shared/actions/typesetAction';
7
- import ShadowBaseStyles from '../../shared/components/ShadowBaseStyles.svelte';
8
- import SortableList from '../../shared/components/SortableList.svelte';
9
- import { createQtiChangeEvent } from '../../shared/utils/eventHelpers';
10
- import { parseJsonProp } from '../../shared/utils/webComponentHelpers';
11
-
12
- interface Props {
13
- interaction?: OrderInteractionData | string;
14
- response?: string[] | null;
15
- correctResponse?: string[] | null;
16
- disabled?: boolean;
17
- role?: string;
18
- i18n?: I18nProvider;
19
- typeset?: (element: HTMLElement) => void;
20
- onChange?: (value: string[]) => void;
21
- /** When true, renders an elimination toggle button per choice (QTI 3.0 PNP §6.2). */
22
- eliminationTool?: boolean;
23
- }
24
-
25
- let { interaction = $bindable(), response = $bindable(), correctResponse = $bindable(), disabled = false, role = 'candidate', i18n = $bindable(), typeset, onChange, eliminationTool = false }: Props = $props();
26
-
27
- // Parse props that may be JSON strings (web component usage)
28
- const parsedInteraction = $derived(parseJsonProp<OrderInteractionData>(interaction));
29
- const parsedResponse = $derived(parseJsonProp<string[]>(response));
30
- const parsedCorrectResponse = $derived(parseJsonProp<string[]>(correctResponse));
31
- const isShowingCorrect = $derived(role === 'scorer' && parsedCorrectResponse !== null);
32
-
33
- // Get reference to the root element for event dispatching
34
- let rootElement: HTMLDivElement | undefined = $state();
35
-
36
- // Track whether user has confirmed their order
37
- let hasConfirmed = $state(false);
38
-
39
- // Shuffle choices on first render when shuffle=true, respecting fixed=true per choice.
40
- // Uses a simple seeded shuffle keyed to the responseId so the order is stable within a session.
41
- const shuffledChoiceIds = $derived.by(() => {
42
- const choices = parsedInteraction?.choices;
43
- if (!choices || !parsedInteraction?.shuffle) {
44
- return choices?.map((c) => c.identifier) ?? [];
45
- }
46
-
47
- // Separate fixed and non-fixed choices
48
- const fixedSlots = new Map<number, string>(); // index → identifier
49
- const movable: string[] = [];
50
- for (let i = 0; i < choices.length; i++) {
51
- if (choices[i].fixed) {
52
- fixedSlots.set(i, choices[i].identifier);
53
- } else {
54
- movable.push(choices[i].identifier);
55
- }
56
- }
57
-
58
- // Fisher-Yates shuffle with a simple deterministic seed
59
- const seed = (parsedInteraction.responseId ?? 'order').split('').reduce((a, c) => a + c.charCodeAt(0), 0);
60
- const rng = (n: number) => {
61
- // LCG: good enough for presentation shuffle
62
- return ((seed * 1664525 + 1013904223 + n * 22695477) & 0x7fffffff) / 0x7fffffff;
63
- };
64
- for (let i = movable.length - 1; i > 0; i--) {
65
- const j = Math.floor(rng(i) * (i + 1));
66
- [movable[i], movable[j]] = [movable[j], movable[i]];
67
- }
68
-
69
- // Reconstruct full array, inserting fixed choices back into their original slots
70
- const result: string[] = new Array(choices.length);
71
- let movableIdx = 0;
72
- for (let i = 0; i < choices.length; i++) {
73
- if (fixedSlots.has(i)) {
74
- result[i] = fixedSlots.get(i)!;
75
- } else {
76
- result[i] = movable[movableIdx++];
77
- }
78
- }
79
- return result;
80
- });
81
-
82
- // Get ordered IDs from response, or use shuffled/original order
83
- const orderedIds = $derived(
84
- parsedResponse && parsedResponse.length > 0
85
- ? parsedResponse
86
- : shuffledChoiceIds
87
- );
88
-
89
- // Track initial order to detect if user has made changes
90
- const initialOrder = $derived(parsedInteraction?.choices.map((c) => c.identifier) ?? []);
91
- const hasReordered = $derived(
92
- orderedIds.length > 0 &&
93
- orderedIds.some((id, index) => id !== initialOrder[index])
94
- );
95
-
96
- // Show confirmation button when response is null or when not confirmed yet
97
- const needsConfirmation = $derived(
98
- !disabled &&
99
- (!response || !hasConfirmed) &&
100
- orderedIds.length > 0
101
- );
102
-
103
- function handleReorder(newOrder: string[]) {
104
- hasConfirmed = true; // Auto-confirm on drag
105
- response = newOrder;
106
- // Call onChange callback if provided (for Svelte component usage)
107
- onChange?.(newOrder);
108
- // Dispatch event for web component usage - event will bubble up to the host element
109
- if (rootElement) {
110
- rootElement.dispatchEvent(createQtiChangeEvent(parsedInteraction?.responseId, newOrder));
111
- }
112
- }
113
-
114
- function confirmOrder() {
115
- if (disabled || hasConfirmed) return;
116
-
117
- hasConfirmed = true;
118
- const currentOrder = orderedIds;
119
- response = currentOrder;
120
-
121
- // Call onChange callback if provided (for Svelte component usage)
122
- onChange?.(currentOrder);
123
- // Dispatch event for web component usage - event will bubble up to the host element
124
- if (rootElement) {
125
- rootElement.dispatchEvent(createQtiChangeEvent(parsedInteraction?.responseId, currentOrder));
126
- }
127
- }
128
-
129
- // Reset confirmation state when response is externally cleared
130
- $effect(() => {
131
- if (response === null || (Array.isArray(response) && response.length === 0)) {
132
- hasConfirmed = false;
133
- }
134
- });
135
-
136
- // Elimination tool state
137
- let eliminatedChoices = $state(new Set<string>());
138
-
139
- function toggleElimination(identifier: string) {
140
- const next = new Set(eliminatedChoices);
141
- if (next.has(identifier)) {
142
- next.delete(identifier);
143
- } else {
144
- next.add(identifier);
145
- }
146
- eliminatedChoices = next;
147
- }
148
-
149
- function eliminationLabel(identifier: string): string {
150
- return eliminatedChoices.has(identifier)
151
- ? (i18n?.t('interactions.choice.restoreChoice') ?? 'Restore')
152
- : (i18n?.t('interactions.choice.eliminateChoice') ?? 'Eliminate');
153
- }
154
- </script>
155
-
156
- <ShadowBaseStyles />
157
-
158
- <div bind:this={rootElement} class="qti-order-interaction" use:typesetAction={{ typeset }}>
159
- {#if !parsedInteraction}
160
- <div class="alert alert-error">{i18n?.t('common.errorNoData', 'No interaction data provided')}</div>
161
- {:else}
162
- {#if parsedInteraction.prompt}
163
- <div class="mb-3 text-sm text-base-content/70">
164
- {@html parsedInteraction.prompt}
165
- </div>
166
- {/if}
167
-
168
- <div class="qti-order-sortable-wrapper" class:qti-order-with-elimination={eliminationTool}>
169
- <SortableList
170
- items={parsedInteraction.choices.map(c => ({ id: c.identifier, text: c.text }))}
171
- {orderedIds}
172
- correctOrder={isShowingCorrect ? (parsedCorrectResponse || []) : []}
173
- orientation="vertical"
174
- {disabled}
175
- onReorder={handleReorder}
176
- />
177
- {#if eliminationTool}
178
- <div class="qti-order-elimination-col" aria-hidden="true">
179
- {#each orderedIds as id (id)}
180
- <button
181
- type="button"
182
- class="qti-eliminate-btn"
183
- aria-label={eliminationLabel(id)}
184
- aria-pressed={eliminatedChoices.has(id)}
185
- aria-hidden="false"
186
- onclick={() => toggleElimination(id)}
187
- data-eliminated={eliminatedChoices.has(id) ? '' : undefined}
188
- >✕</button>
189
- {/each}
190
- </div>
191
- {/if}
192
- </div>
193
-
194
- <!-- Confirmation button for WCAG 2.2 SC 3.3.4 compliance -->
195
- <div class="mt-4 flex items-center gap-3">
196
- {#if needsConfirmation}
197
- <button
198
- type="button"
199
- class="btn btn-primary btn-sm"
200
- onclick={confirmOrder}
201
- aria-label={i18n?.t('interactions.order.confirmAria') ?? 'Confirm this order as your answer'}
202
- >
203
- {hasReordered
204
- ? (i18n?.t('interactions.order.confirmOrder') ?? 'Confirm Order')
205
- : (i18n?.t('interactions.order.confirmOrderNoChanges') ?? 'Confirm Order (No Changes)')}
206
- </button>
207
- <span class="text-xs text-base-content/60">
208
- {i18n?.t('interactions.order.instruction') ?? 'Drag items to reorder, or click to confirm the current order'}
209
- </span>
210
- {:else if hasConfirmed}
211
- <div class="badge badge-success gap-2">
212
- <svg
213
- xmlns="http://www.w3.org/2000/svg"
214
- fill="none"
215
- viewBox="0 0 24 24"
216
- part="confirmed-icon"
217
- class="qti-icon-sm inline-block w-4 h-4 stroke-current"
218
- >
219
- <path
220
- stroke-linecap="round"
221
- stroke-linejoin="round"
222
- stroke-width="2"
223
- d="M5 13l4 4L19 7"
224
- ></path>
225
- </svg>
226
- Order confirmed
227
- </div>
228
- {/if}
229
- </div>
230
- {/if}
231
- </div>
232
-
233
- <style>
234
- /* Minimal icon sizing so SVGs don't fall back to browser default size without Tailwind */
235
- .qti-icon-sm {
236
- width: 1rem;
237
- height: 1rem;
238
- flex: 0 0 auto;
239
- }
240
-
241
- /* Elimination tool layout */
242
- .qti-order-sortable-wrapper {
243
- position: relative;
244
- }
245
-
246
- .qti-order-with-elimination {
247
- display: grid;
248
- grid-template-columns: 1fr auto;
249
- gap: 0.25rem;
250
- align-items: start;
251
- }
252
-
253
- .qti-order-elimination-col {
254
- display: flex;
255
- flex-direction: column;
256
- gap: 0.5rem;
257
- }
258
-
259
- .qti-eliminate-btn {
260
- background: none;
261
- border: 1px solid currentColor;
262
- border-radius: 50%;
263
- width: 1.75rem;
264
- height: 1.75rem;
265
- font-size: 0.75rem;
266
- cursor: pointer;
267
- opacity: 0.4;
268
- padding: 0;
269
- display: flex;
270
- align-items: center;
271
- justify-content: center;
272
- flex-shrink: 0;
273
- }
274
-
275
- .qti-eliminate-btn:hover,
276
- .qti-eliminate-btn[data-eliminated] {
277
- opacity: 1;
278
- color: var(--color-error, oklch(63% 0.237 25.331));
279
- }
280
- </style>
@@ -1,9 +0,0 @@
1
- // Svelte component exported via web component
2
-
3
- export const metadata = {
4
- interactionType: 'orderInteraction',
5
- tagName: 'pie-qti-order',
6
- name: 'default-order',
7
- description: 'Default Svelte-based order interaction',
8
- priority: 0,
9
- };