@pie-qti/default-components 0.1.4 → 0.1.6
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/index.d.ts +15 -24
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -123
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +1 -0
- package/dist/shared/utils/eventHelpers.d.ts +5 -1
- package/dist/shared/utils/eventHelpers.d.ts.map +1 -1
- package/dist/shared/utils/matchGroupUtils.d.ts +8 -0
- package/dist/shared/utils/matchGroupUtils.d.ts.map +1 -0
- package/dist/shared/utils/matchGroupUtils.js +13 -0
- package/package.json +8 -4
- package/src/catalog/CatalogPopup.svelte +163 -0
- package/src/index.ts +72 -144
- package/src/plugins/associate/AssociateInteraction.svelte +41 -4
- package/src/plugins/choice/ChoiceInteraction.svelte +143 -4
- package/src/plugins/drawing/DrawingInteraction.svelte +9 -0
- package/src/plugins/extended-text/ExtendedTextInteraction.svelte +56 -1
- package/src/plugins/gap-match/GapMatchInteraction.svelte +174 -12
- package/src/plugins/graphic-associate/GraphicAssociateInteraction.svelte +85 -9
- package/src/plugins/graphic-gap-match/GraphicGapMatchInteraction.svelte +197 -107
- package/src/plugins/hotspot/HotspotInteraction.svelte +50 -7
- package/src/plugins/hottext/HottextInteraction.svelte +33 -4
- package/src/plugins/index.ts +1 -0
- package/src/plugins/match/MatchInteraction.svelte +13 -1
- package/src/plugins/media/MediaInteraction.svelte +5 -2
- package/src/plugins/order/OrderInteraction.svelte +132 -11
- package/src/plugins/position-object/PositionObjectInteraction.svelte +247 -9
- package/src/plugins/select-point/SelectPointInteraction.svelte +139 -7
- package/src/shared/components/FileUpload.svelte +7 -2
- package/src/shared/components/GraphicGapMatch.svelte +5 -3
- package/src/shared/components/GraphicGapMatchAdapter.svelte +10 -1
- package/src/shared/components/InlineInteractionRenderer.svelte +28 -11
- package/src/shared/components/MatchDragDrop.svelte +48 -2
- package/src/shared/components/ModalFeedbackDisplay.svelte +15 -5
- package/src/shared/styles/qti-shared-vocabulary.css +320 -0
- package/src/shared/utils/eventHelpers.ts +8 -1
- package/src/shared/utils/matchGroupUtils.ts +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @pie-qti/default-components
|
|
3
3
|
*
|
|
4
|
-
* Default Svelte-based component implementations for the QTI
|
|
4
|
+
* Default Svelte-based component implementations for the QTI player.
|
|
5
5
|
* These components are packaged as web components that work with the
|
|
6
6
|
* framework-agnostic @pie-qti/item-player core.
|
|
7
7
|
*/
|
|
8
|
-
import type { ComponentRegistry } from '@pie-qti/item-player';
|
|
9
8
|
export * from './shared/index.js';
|
|
9
|
+
interface DefaultComponentRegistration {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
tagName: string;
|
|
13
|
+
}
|
|
14
|
+
interface DefaultComponentRegistry {
|
|
15
|
+
register(type: string, component: DefaultComponentRegistration): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function getDefaultComponentTypes(): string[];
|
|
10
18
|
/**
|
|
11
|
-
* Register all default components with the ComponentRegistry
|
|
19
|
+
* Register all default components with the ComponentRegistry.
|
|
12
20
|
*
|
|
13
|
-
* This function should be called once at application startup to make
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* IMPORTANT: Before calling this function, you MUST import the plugin loader:
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import '@pie-qti/default-components/plugins';
|
|
19
|
-
* ```
|
|
20
|
-
* This import triggers web component registration via Svelte's customElement option.
|
|
21
|
-
*
|
|
22
|
-
* @param registry - The ComponentRegistry instance from the Player
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { Player } from '@pie-qti/item-player';
|
|
27
|
-
* import '@pie-qti/default-components/plugins'; // Load web components
|
|
28
|
-
* import { registerDefaultComponents } from '@pie-qti/default-components';
|
|
29
|
-
*
|
|
30
|
-
* const player = new Player(qtiXml);
|
|
31
|
-
* registerDefaultComponents(player.getComponentRegistry());
|
|
32
|
-
* ```
|
|
21
|
+
* This function should be called once at application startup to make all default
|
|
22
|
+
* block interaction components available to the player. Inline interactions are
|
|
23
|
+
* rendered in-flow by @pie-qti/item-player.
|
|
33
24
|
*/
|
|
34
|
-
export declare function registerDefaultComponents(registry:
|
|
25
|
+
export declare function registerDefaultComponents(registry: DefaultComponentRegistry): void;
|
|
35
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,mBAAmB,CAAC;AAElC,UAAU,4BAA4B;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,wBAAwB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,4BAA4B,GAAG,IAAI,CAAC;CACtE;AAoGD,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAEnD;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,IAAI,CAUlF"}
|
package/dist/index.js
CHANGED
|
@@ -1,190 +1,126 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @pie-qti/default-components
|
|
3
3
|
*
|
|
4
|
-
* Default Svelte-based component implementations for the QTI
|
|
4
|
+
* Default Svelte-based component implementations for the QTI player.
|
|
5
5
|
* These components are packaged as web components that work with the
|
|
6
6
|
* framework-agnostic @pie-qti/item-player core.
|
|
7
7
|
*/
|
|
8
8
|
// Export shared utilities and helpers
|
|
9
9
|
export * from './shared/index.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
*
|
|
13
|
-
* This function should be called once at application startup to make
|
|
14
|
-
* all default interaction components available to the player.
|
|
15
|
-
*
|
|
16
|
-
* IMPORTANT: Before calling this function, you MUST import the plugin loader:
|
|
17
|
-
* ```typescript
|
|
18
|
-
* import '@pie-qti/default-components/plugins';
|
|
19
|
-
* ```
|
|
20
|
-
* This import triggers web component registration via Svelte's customElement option.
|
|
21
|
-
*
|
|
22
|
-
* @param registry - The ComponentRegistry instance from the Player
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```typescript
|
|
26
|
-
* import { Player } from '@pie-qti/item-player';
|
|
27
|
-
* import '@pie-qti/default-components/plugins'; // Load web components
|
|
28
|
-
* import { registerDefaultComponents } from '@pie-qti/default-components';
|
|
29
|
-
*
|
|
30
|
-
* const player = new Player(qtiXml);
|
|
31
|
-
* registerDefaultComponents(player.getComponentRegistry());
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export function registerDefaultComponents(registry) {
|
|
35
|
-
// ChoiceInteraction - Radio buttons or checkboxes
|
|
36
|
-
registry.register('choiceInteraction', {
|
|
10
|
+
const DEFAULT_COMPONENTS_BY_TYPE = {
|
|
11
|
+
choiceInteraction: {
|
|
37
12
|
name: 'default-choice',
|
|
38
|
-
priority: 0,
|
|
39
13
|
description: 'Default Svelte-based choice interaction',
|
|
40
|
-
canHandle: () => true,
|
|
41
14
|
tagName: 'pie-qti-choice',
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// SliderInteraction - Range slider
|
|
45
|
-
registry.register('sliderInteraction', {
|
|
15
|
+
},
|
|
16
|
+
sliderInteraction: {
|
|
46
17
|
name: 'default-slider',
|
|
47
|
-
priority: 0,
|
|
48
18
|
description: 'Default Svelte-based slider interaction',
|
|
49
|
-
canHandle: () => true,
|
|
50
19
|
tagName: 'pie-qti-slider',
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
registry.register('orderInteraction', {
|
|
20
|
+
},
|
|
21
|
+
orderInteraction: {
|
|
54
22
|
name: 'default-order',
|
|
55
|
-
priority: 0,
|
|
56
23
|
description: 'Default Svelte-based order interaction',
|
|
57
|
-
canHandle: () => true,
|
|
58
24
|
tagName: 'pie-qti-order',
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
registry.register('matchInteraction', {
|
|
25
|
+
},
|
|
26
|
+
matchInteraction: {
|
|
62
27
|
name: 'default-match',
|
|
63
|
-
priority: 0,
|
|
64
28
|
description: 'Default Svelte-based match interaction',
|
|
65
|
-
canHandle: () => true,
|
|
66
29
|
tagName: 'pie-qti-match',
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
registry.register('associateInteraction', {
|
|
30
|
+
},
|
|
31
|
+
associateInteraction: {
|
|
70
32
|
name: 'default-associate',
|
|
71
|
-
priority: 0,
|
|
72
33
|
description: 'Default Svelte-based associate interaction',
|
|
73
|
-
canHandle: () => true,
|
|
74
34
|
tagName: 'pie-qti-associate',
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
registry.register('gapMatchInteraction', {
|
|
35
|
+
},
|
|
36
|
+
gapMatchInteraction: {
|
|
78
37
|
name: 'default-gap-match',
|
|
79
|
-
priority: 0,
|
|
80
38
|
description: 'Default Svelte-based gap match interaction',
|
|
81
|
-
canHandle: () => true,
|
|
82
39
|
tagName: 'pie-qti-gap-match',
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
registry.register('hotspotInteraction', {
|
|
40
|
+
},
|
|
41
|
+
hotspotInteraction: {
|
|
86
42
|
name: 'default-hotspot',
|
|
87
|
-
priority: 0,
|
|
88
43
|
description: 'Default Svelte-based hotspot interaction',
|
|
89
|
-
canHandle: () => true,
|
|
90
44
|
tagName: 'pie-qti-hotspot',
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
registry.register('hottextInteraction', {
|
|
45
|
+
},
|
|
46
|
+
hottextInteraction: {
|
|
94
47
|
name: 'default-hottext',
|
|
95
|
-
priority: 0,
|
|
96
48
|
description: 'Default Svelte-based hottext interaction',
|
|
97
|
-
canHandle: () => true,
|
|
98
49
|
tagName: 'pie-qti-hottext',
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
registry.register('mediaInteraction', {
|
|
50
|
+
},
|
|
51
|
+
mediaInteraction: {
|
|
102
52
|
name: 'default-media',
|
|
103
|
-
priority: 0,
|
|
104
53
|
description: 'Default Svelte-based media interaction',
|
|
105
|
-
canHandle: () => true,
|
|
106
54
|
tagName: 'pie-qti-media',
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
registry.register('customInteraction', {
|
|
55
|
+
},
|
|
56
|
+
customInteraction: {
|
|
110
57
|
name: 'default-custom',
|
|
111
|
-
priority: 0,
|
|
112
58
|
description: 'Default Svelte-based custom interaction',
|
|
113
|
-
canHandle: () => true,
|
|
114
59
|
tagName: 'pie-qti-custom',
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
registry.register('endAttemptInteraction', {
|
|
60
|
+
},
|
|
61
|
+
endAttemptInteraction: {
|
|
118
62
|
name: 'default-end-attempt',
|
|
119
|
-
priority: 0,
|
|
120
63
|
description: 'Default Svelte-based end attempt interaction',
|
|
121
|
-
canHandle: () => true,
|
|
122
64
|
tagName: 'pie-qti-end-attempt',
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
registry.register('positionObjectInteraction', {
|
|
65
|
+
},
|
|
66
|
+
positionObjectInteraction: {
|
|
126
67
|
name: 'default-position-object',
|
|
127
|
-
priority: 0,
|
|
128
68
|
description: 'Default Svelte-based position object interaction',
|
|
129
|
-
canHandle: () => true,
|
|
130
69
|
tagName: 'pie-qti-position-object',
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
registry.register('graphicGapMatchInteraction', {
|
|
70
|
+
},
|
|
71
|
+
graphicGapMatchInteraction: {
|
|
134
72
|
name: 'default-graphic-gap-match',
|
|
135
|
-
priority: 0,
|
|
136
73
|
description: 'Default Svelte-based graphic gap match interaction',
|
|
137
|
-
canHandle: () => true,
|
|
138
74
|
tagName: 'pie-qti-graphic-gap-match',
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
registry.register('graphicOrderInteraction', {
|
|
75
|
+
},
|
|
76
|
+
graphicOrderInteraction: {
|
|
142
77
|
name: 'default-graphic-order',
|
|
143
|
-
priority: 0,
|
|
144
78
|
description: 'Default Svelte-based graphic order interaction',
|
|
145
|
-
canHandle: () => true,
|
|
146
79
|
tagName: 'pie-qti-graphic-order',
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
registry.register('graphicAssociateInteraction', {
|
|
80
|
+
},
|
|
81
|
+
graphicAssociateInteraction: {
|
|
150
82
|
name: 'default-graphic-associate',
|
|
151
|
-
priority: 0,
|
|
152
83
|
description: 'Default Svelte-based graphic associate interaction',
|
|
153
|
-
canHandle: () => true,
|
|
154
84
|
tagName: 'pie-qti-graphic-associate',
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
registry.register('selectPointInteraction', {
|
|
85
|
+
},
|
|
86
|
+
selectPointInteraction: {
|
|
158
87
|
name: 'default-select-point',
|
|
159
|
-
priority: 0,
|
|
160
88
|
description: 'Default Svelte-based select point interaction',
|
|
161
|
-
canHandle: () => true,
|
|
162
89
|
tagName: 'pie-qti-select-point',
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
registry.register('extendedTextInteraction', {
|
|
90
|
+
},
|
|
91
|
+
extendedTextInteraction: {
|
|
166
92
|
name: 'default-extended-text',
|
|
167
|
-
priority: 0,
|
|
168
93
|
description: 'Default Svelte-based extended text interaction',
|
|
169
|
-
canHandle: () => true,
|
|
170
94
|
tagName: 'pie-qti-extended-text',
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
registry.register('uploadInteraction', {
|
|
95
|
+
},
|
|
96
|
+
uploadInteraction: {
|
|
174
97
|
name: 'default-upload',
|
|
175
|
-
priority: 0,
|
|
176
98
|
description: 'Default Svelte-based upload interaction',
|
|
177
|
-
canHandle: () => true,
|
|
178
99
|
tagName: 'pie-qti-upload',
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
registry.register('drawingInteraction', {
|
|
100
|
+
},
|
|
101
|
+
drawingInteraction: {
|
|
182
102
|
name: 'default-drawing',
|
|
183
|
-
priority: 0,
|
|
184
103
|
description: 'Default Svelte-based drawing interaction',
|
|
185
|
-
canHandle: () => true,
|
|
186
104
|
tagName: 'pie-qti-drawing',
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
export function getDefaultComponentTypes() {
|
|
108
|
+
return Object.keys(DEFAULT_COMPONENTS_BY_TYPE);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Register all default components with the ComponentRegistry.
|
|
112
|
+
*
|
|
113
|
+
* This function should be called once at application startup to make all default
|
|
114
|
+
* block interaction components available to the player. Inline interactions are
|
|
115
|
+
* rendered in-flow by @pie-qti/item-player.
|
|
116
|
+
*/
|
|
117
|
+
export function registerDefaultComponents(registry) {
|
|
118
|
+
for (const [type, component] of Object.entries(DEFAULT_COMPONENTS_BY_TYPE)) {
|
|
119
|
+
registry.register(type, component);
|
|
120
|
+
}
|
|
121
|
+
registry.register('catalogPopup', {
|
|
122
|
+
name: 'default-catalog-popup',
|
|
123
|
+
description: 'Default Svelte-based catalog popup dialog',
|
|
124
|
+
tagName: 'pie-qti-catalog-popup',
|
|
187
125
|
});
|
|
188
|
-
// Note: TextEntryInteraction and InlineChoiceInteraction are handled
|
|
189
|
-
// by ItemRenderer as inline interactions, not as separate components
|
|
190
126
|
}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -27,4 +27,5 @@ import './select-point/SelectPointInteraction.svelte';
|
|
|
27
27
|
import './extended-text/ExtendedTextInteraction.svelte';
|
|
28
28
|
import './upload/UploadInteraction.svelte';
|
|
29
29
|
import './drawing/DrawingInteraction.svelte';
|
|
30
|
+
import '../catalog/CatalogPopup.svelte';
|
|
30
31
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AACzC,OAAO,yCAAyC,CAAC;AACjD,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,4CAA4C,CAAC;AACpD,OAAO,oDAAoD,CAAC;AAC5D,OAAO,uDAAuD,CAAC;AAC/D,OAAO,gDAAgD,CAAC;AACxD,OAAO,wDAAwD,CAAC;AAChE,OAAO,8CAA8C,CAAC;AACtD,OAAO,gDAAgD,CAAC;AACxD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,mCAAmC,CAAC;AAC3C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,iCAAiC,CAAC;AACzC,OAAO,iCAAiC,CAAC;AACzC,OAAO,yCAAyC,CAAC;AACjD,OAAO,wCAAwC,CAAC;AAChD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,4CAA4C,CAAC;AACpD,OAAO,oDAAoD,CAAC;AAC5D,OAAO,uDAAuD,CAAC;AAC/D,OAAO,gDAAgD,CAAC;AACxD,OAAO,wDAAwD,CAAC;AAChE,OAAO,8CAA8C,CAAC;AACtD,OAAO,gDAAgD,CAAC;AACxD,OAAO,mCAAmC,CAAC;AAC3C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,gCAAgC,CAAC"}
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { QTIChangeEventDetail } from '@pie-qti/item-player/web-components';
|
|
2
|
-
|
|
2
|
+
type TypedQtiChangeEventDetail<TValue> = Omit<QTIChangeEventDetail, 'value'> & {
|
|
3
|
+
value: TValue;
|
|
4
|
+
};
|
|
5
|
+
export declare function createQtiChangeEvent<TValue = unknown>(responseId: string | undefined, value: TValue): CustomEvent<TypedQtiChangeEventDetail<TValue>>;
|
|
3
6
|
/**
|
|
4
7
|
* Emits a QTI change event from an element
|
|
5
8
|
* @param element - The element to dispatch from (usually component root)
|
|
@@ -7,4 +10,5 @@ export declare function createQtiChangeEvent(responseId: string | undefined, val
|
|
|
7
10
|
* @param value - The response value
|
|
8
11
|
*/
|
|
9
12
|
export declare function emitQtiChange(element: HTMLElement | EventTarget, responseId: string | undefined, value: unknown): void;
|
|
13
|
+
export {};
|
|
10
14
|
//# sourceMappingURL=eventHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventHelpers.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/eventHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAmBhF,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"eventHelpers.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/eventHelpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAmBhF,KAAK,yBAAyB,CAAC,MAAM,IAAI,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG;IAC9E,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,MAAM,GAAG,OAAO,EACpD,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,MAAM,GACX,WAAW,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAUhD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC5B,OAAO,EAAE,WAAW,GAAG,WAAW,EAClC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,OAAO,GACZ,IAAI,CAGN"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if a source and target choice are compatible for pairing.
|
|
3
|
+
*
|
|
4
|
+
* Per QTI spec, an empty/absent matchGroup is unrestricted (pairs with anything).
|
|
5
|
+
* Two non-empty matchGroups are compatible only if they share at least one value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isCompatibleMatchGroup(sourceGroups: string[] | undefined, targetGroups: string[] | undefined): boolean;
|
|
8
|
+
//# sourceMappingURL=matchGroupUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchGroupUtils.d.ts","sourceRoot":"","sources":["../../../src/shared/utils/matchGroupUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACrC,YAAY,EAAE,MAAM,EAAE,GAAG,SAAS,EAClC,YAAY,EAAE,MAAM,EAAE,GAAG,SAAS,GAChC,OAAO,CAIT"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if a source and target choice are compatible for pairing.
|
|
3
|
+
*
|
|
4
|
+
* Per QTI spec, an empty/absent matchGroup is unrestricted (pairs with anything).
|
|
5
|
+
* Two non-empty matchGroups are compatible only if they share at least one value.
|
|
6
|
+
*/
|
|
7
|
+
export function isCompatibleMatchGroup(sourceGroups, targetGroups) {
|
|
8
|
+
if (!sourceGroups || sourceGroups.length === 0)
|
|
9
|
+
return true;
|
|
10
|
+
if (!targetGroups || targetGroups.length === 0)
|
|
11
|
+
return true;
|
|
12
|
+
return sourceGroups.some((g) => targetGroups.includes(g));
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-qti/default-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Default Svelte-based component implementations for QTI (2.x and 3.0) player",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@pie-qti/i18n": "0.1.
|
|
31
|
-
"@pie-qti/item-player": "0.1.
|
|
32
|
-
"@pie-qti/qti-common": "0.1.
|
|
30
|
+
"@pie-qti/i18n": "0.1.6",
|
|
31
|
+
"@pie-qti/item-player": "0.1.6",
|
|
32
|
+
"@pie-qti/qti-common": "0.1.6",
|
|
33
33
|
"@tiptap/core": "^3.15.3",
|
|
34
34
|
"@tiptap/extension-mathematics": "^3.15.3",
|
|
35
35
|
"@tiptap/extension-placeholder": "^3.15.3",
|
|
@@ -90,6 +90,10 @@
|
|
|
90
90
|
"./shared/extensions/*": {
|
|
91
91
|
"types": "./dist/shared/extensions/*.d.ts",
|
|
92
92
|
"import": "./dist/shared/extensions/*.js"
|
|
93
|
+
},
|
|
94
|
+
"./src/shared/styles/qti-shared-vocabulary.css": {
|
|
95
|
+
"style": "./src/shared/styles/qti-shared-vocabulary.css",
|
|
96
|
+
"default": "./src/shared/styles/qti-shared-vocabulary.css"
|
|
93
97
|
}
|
|
94
98
|
},
|
|
95
99
|
"repository": {
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<svelte:options customElement="pie-qti-catalog-popup" />
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
/**
|
|
5
|
+
* CatalogPopup — accessible floating dialog for QTI 3.0 catalog entries.
|
|
6
|
+
*
|
|
7
|
+
* Renders glossary definitions, keyword translations, and illustrated-glossary images.
|
|
8
|
+
* Focus-trapped: Tab/Shift+Tab cycle within; Escape closes.
|
|
9
|
+
* For platform-level usages (TTS, signing, braille) the player fires a qti-catalog-lookup
|
|
10
|
+
* event instead of mounting this component.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface Props {
|
|
14
|
+
/** HTML content from CatalogEntry.html (or URL for illustrated-glossary). */
|
|
15
|
+
content: string;
|
|
16
|
+
/** Accessible label for the dialog (the term text). */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Callback when the popup is closed. */
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { content, label, onClose }: Props = $props();
|
|
23
|
+
|
|
24
|
+
// Illustrated-glossary: if content looks like a URL, render as <img>
|
|
25
|
+
const isUrl = $derived(/^(https?:\/\/|\/)/i.test(content.trim()));
|
|
26
|
+
|
|
27
|
+
let dialogEl: HTMLDivElement | undefined = $state();
|
|
28
|
+
let closeBtn: HTMLButtonElement | undefined = $state();
|
|
29
|
+
|
|
30
|
+
// Move focus into the popup on mount
|
|
31
|
+
$effect(() => {
|
|
32
|
+
if (dialogEl) {
|
|
33
|
+
closeBtn?.focus();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
function handleKeyDown(event: KeyboardEvent) {
|
|
38
|
+
if (event.key === 'Escape') {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
onClose();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Focus trap: keep Tab within the popup
|
|
45
|
+
if (event.key === 'Tab' && dialogEl) {
|
|
46
|
+
const focusable = Array.from(
|
|
47
|
+
dialogEl.querySelectorAll<HTMLElement>(
|
|
48
|
+
'a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
49
|
+
)
|
|
50
|
+
).filter((el) => el.offsetParent !== null);
|
|
51
|
+
|
|
52
|
+
if (focusable.length === 0) {
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const first = focusable[0];
|
|
58
|
+
const last = focusable[focusable.length - 1];
|
|
59
|
+
|
|
60
|
+
if (event.shiftKey && document.activeElement === first) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
last.focus();
|
|
63
|
+
} else if (!event.shiftKey && document.activeElement === last) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
first.focus();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
72
|
+
<div
|
|
73
|
+
bind:this={dialogEl}
|
|
74
|
+
role="dialog"
|
|
75
|
+
aria-label={label}
|
|
76
|
+
aria-modal="true"
|
|
77
|
+
tabindex="-1"
|
|
78
|
+
class="qti-catalog-popup"
|
|
79
|
+
onkeydown={handleKeyDown}
|
|
80
|
+
>
|
|
81
|
+
<div class="qti-catalog-popup__header">
|
|
82
|
+
<span class="qti-catalog-popup__title">{label}</span>
|
|
83
|
+
<button
|
|
84
|
+
bind:this={closeBtn}
|
|
85
|
+
type="button"
|
|
86
|
+
class="qti-catalog-popup__close"
|
|
87
|
+
aria-label="Close"
|
|
88
|
+
onclick={onClose}
|
|
89
|
+
>✕</button>
|
|
90
|
+
</div>
|
|
91
|
+
<div class="qti-catalog-popup__body">
|
|
92
|
+
{#if isUrl}
|
|
93
|
+
<img src={content} alt={label} class="qti-catalog-popup__img" />
|
|
94
|
+
{:else}
|
|
95
|
+
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
|
|
96
|
+
{@html content}
|
|
97
|
+
{/if}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<style>
|
|
102
|
+
.qti-catalog-popup {
|
|
103
|
+
position: absolute;
|
|
104
|
+
z-index: 1000;
|
|
105
|
+
background: var(--color-base-100, #fff);
|
|
106
|
+
border: 1px solid var(--color-base-300, #d1d5db);
|
|
107
|
+
border-radius: 0.5rem;
|
|
108
|
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
|
|
109
|
+
min-width: 16rem;
|
|
110
|
+
max-width: 24rem;
|
|
111
|
+
padding: 0;
|
|
112
|
+
font-size: 0.9rem;
|
|
113
|
+
line-height: 1.5;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.qti-catalog-popup__header {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
justify-content: space-between;
|
|
120
|
+
padding: 0.5rem 0.75rem;
|
|
121
|
+
border-bottom: 1px solid var(--color-base-300, #d1d5db);
|
|
122
|
+
background: var(--color-base-200, #f9fafb);
|
|
123
|
+
border-radius: 0.5rem 0.5rem 0 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.qti-catalog-popup__title {
|
|
127
|
+
font-weight: 600;
|
|
128
|
+
font-size: 0.85rem;
|
|
129
|
+
color: var(--color-base-content, #111);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.qti-catalog-popup__close {
|
|
133
|
+
background: none;
|
|
134
|
+
border: none;
|
|
135
|
+
cursor: pointer;
|
|
136
|
+
font-size: 1rem;
|
|
137
|
+
line-height: 1;
|
|
138
|
+
padding: 0.2rem 0.4rem;
|
|
139
|
+
border-radius: 0.25rem;
|
|
140
|
+
color: var(--color-base-content, #111);
|
|
141
|
+
opacity: 0.6;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.qti-catalog-popup__close:hover,
|
|
145
|
+
.qti-catalog-popup__close:focus-visible {
|
|
146
|
+
opacity: 1;
|
|
147
|
+
background: var(--color-base-300, #e5e7eb);
|
|
148
|
+
outline: 2px solid var(--color-primary, #4f46e5);
|
|
149
|
+
outline-offset: 1px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.qti-catalog-popup__body {
|
|
153
|
+
padding: 0.75rem;
|
|
154
|
+
color: var(--color-base-content, #111);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.qti-catalog-popup__img {
|
|
158
|
+
max-width: 100%;
|
|
159
|
+
height: auto;
|
|
160
|
+
display: block;
|
|
161
|
+
margin: 0 auto;
|
|
162
|
+
}
|
|
163
|
+
</style>
|