@pie-qti/default-components 1.0.0-beta.4 → 1.0.0-beta.5

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 (99) hide show
  1. package/README.md +13 -0
  2. package/dist/chunks/mathlive.min-Cmxm6f5R.js.map +1 -1
  3. package/dist/index.js +13 -110
  4. package/dist/index.js.map +1 -1
  5. package/dist/plugins/extended-text/textInput.d.ts +47 -0
  6. package/dist/plugins/extended-text/textInput.js +65 -0
  7. package/dist/plugins/extended-text/textInput.js.map +1 -0
  8. package/dist/plugins/media/mediaPlayback.d.ts +39 -0
  9. package/dist/plugins/media/mediaPlayback.js +49 -0
  10. package/dist/plugins/media/mediaPlayback.js.map +1 -0
  11. package/dist/plugins.js +13689 -21735
  12. package/dist/plugins.js.map +1 -1
  13. package/dist/shared/components/icons.d.ts +12 -0
  14. package/dist/shared/components/icons.js +13 -0
  15. package/dist/shared/components/icons.js.map +1 -0
  16. package/dist/shared/components/keyboardCrosshair.svelte.d.ts +37 -0
  17. package/dist/shared/components/keyboardCrosshair.svelte.js +67 -0
  18. package/dist/shared/components/keyboardCrosshair.svelte.js.map +1 -0
  19. package/dist/shared/components/pickUpPlace.svelte.d.ts +42 -0
  20. package/dist/shared/components/pickUpPlace.svelte.js +58 -0
  21. package/dist/shared/components/pickUpPlace.svelte.js.map +1 -0
  22. package/dist/shared/extensions/MathLiveEditor.d.ts +33 -6
  23. package/dist/shared/extensions/MathLiveEditor.js +354 -175
  24. package/dist/shared/extensions/MathLiveEditor.js.map +1 -1
  25. package/dist/shared/extensions/modalDialog.d.ts +31 -0
  26. package/dist/shared/extensions/modalDialog.js +165 -0
  27. package/dist/shared/extensions/modalDialog.js.map +1 -0
  28. package/dist/shared/index.d.ts +1 -0
  29. package/dist/shared/index.js +2 -0
  30. package/dist/shared/index.js.map +1 -1
  31. package/dist/shared/styles/qti-pnp.css +44 -0
  32. package/dist/shared/styles/qti-shared-vocabulary.css +6 -2
  33. package/dist/shared/styles/srOnly.d.ts +23 -0
  34. package/dist/shared/styles/srOnly.js +70 -0
  35. package/dist/shared/styles/srOnly.js.map +1 -0
  36. package/dist/shared/utils/accessibleText.d.ts +24 -0
  37. package/dist/shared/utils/accessibleText.js +72 -0
  38. package/dist/shared/utils/accessibleText.js.map +1 -0
  39. package/dist/shared/utils/announcer.svelte.d.ts +26 -0
  40. package/dist/shared/utils/announcer.svelte.js +30 -0
  41. package/dist/shared/utils/announcer.svelte.js.map +1 -0
  42. package/dist/shared/utils/capacity.d.ts +26 -0
  43. package/dist/shared/utils/capacity.js +37 -0
  44. package/dist/shared/utils/capacity.js.map +1 -0
  45. package/dist/shared/utils/choiceName.d.ts +44 -0
  46. package/dist/shared/utils/choiceName.js +28 -0
  47. package/dist/shared/utils/choiceName.js.map +1 -0
  48. package/dist/shared/utils/confirmationFlow.svelte.d.ts +31 -0
  49. package/dist/shared/utils/confirmationFlow.svelte.js +41 -0
  50. package/dist/shared/utils/confirmationFlow.svelte.js.map +1 -0
  51. package/dist/shared/utils/eliminationTool.svelte.d.ts +11 -0
  52. package/dist/shared/utils/eliminationTool.svelte.js +26 -0
  53. package/dist/shared/utils/eliminationTool.svelte.js.map +1 -0
  54. package/dist/shared/utils/graphicRegions.d.ts +78 -0
  55. package/dist/shared/utils/graphicRegions.js +169 -0
  56. package/dist/shared/utils/graphicRegions.js.map +1 -0
  57. package/dist/shared/utils/interactionAria.d.ts +18 -5
  58. package/dist/shared/utils/interactionAria.js +42 -3
  59. package/dist/shared/utils/interactionAria.js.map +1 -1
  60. package/dist/shared/utils/interactionProps.d.ts +52 -0
  61. package/dist/shared/utils/interactionProps.js +14 -0
  62. package/dist/shared/utils/interactionProps.js.map +1 -0
  63. package/dist/shared/utils/matchGroupUtils.d.ts +26 -4
  64. package/dist/shared/utils/matchGroupUtils.js +25 -8
  65. package/dist/shared/utils/matchGroupUtils.js.map +1 -1
  66. package/dist/shared/utils/minimumRequirement.d.ts +56 -0
  67. package/dist/shared/utils/minimumRequirement.js +50 -0
  68. package/dist/shared/utils/minimumRequirement.js.map +1 -0
  69. package/dist/shared/utils/pairHelpers.d.ts +46 -12
  70. package/dist/shared/utils/pairHelpers.js +64 -12
  71. package/dist/shared/utils/pairHelpers.js.map +1 -1
  72. package/dist/shared/utils/radioGroup.d.ts +13 -0
  73. package/dist/shared/utils/radioGroup.js +27 -0
  74. package/dist/shared/utils/radioGroup.js.map +1 -0
  75. package/dist/shared/utils/stageImage.svelte.d.ts +56 -0
  76. package/dist/shared/utils/stageImage.svelte.js +76 -0
  77. package/dist/shared/utils/stageImage.svelte.js.map +1 -0
  78. package/dist/shared/utils/webComponentHelpers.d.ts +37 -5
  79. package/dist/shared/utils/webComponentHelpers.js +72 -19
  80. package/dist/shared/utils/webComponentHelpers.js.map +1 -1
  81. package/dist/shared.css +1 -1
  82. package/package.json +10 -10
  83. package/dist/chunks/__vite-browser-external-DwKjyYZK.js +0 -9
  84. package/dist/chunks/__vite-browser-external-DwKjyYZK.js.map +0 -1
  85. package/dist/chunks/ar-Cqx9S4Im.js +0 -919
  86. package/dist/chunks/ar-Cqx9S4Im.js.map +0 -1
  87. package/dist/chunks/es-DjA7IQ-N.js +0 -864
  88. package/dist/chunks/es-DjA7IQ-N.js.map +0 -1
  89. package/dist/chunks/fr-BhV6wQNG.js +0 -864
  90. package/dist/chunks/fr-BhV6wQNG.js.map +0 -1
  91. package/dist/chunks/nl-B0JlnB-a.js +0 -863
  92. package/dist/chunks/nl-B0JlnB-a.js.map +0 -1
  93. package/dist/chunks/ro-ClR0jejm.js +0 -864
  94. package/dist/chunks/ro-ClR0jejm.js.map +0 -1
  95. package/dist/chunks/rolldown-runtime-Y_bBpyJl.js +0 -20
  96. package/dist/chunks/th-RfNMAg5z.js +0 -863
  97. package/dist/chunks/th-RfNMAg5z.js.map +0 -1
  98. package/dist/chunks/zh-Hans-DJ82CLmG.js +0 -863
  99. package/dist/chunks/zh-Hans-DJ82CLmG.js.map +0 -1
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Path data of the stroke icons the interactions share, rendered through
3
+ * `Icon.svelte`. Each icon is a 24×24 stroke drawing with round caps and
4
+ * joins; the interaction chooses the part name and classes, so what renders
5
+ * at each call site stays exactly what it rendered with its inline copy.
6
+ */
7
+ /** A completed action: a tick. */
8
+ export declare const ICON_CHECK = "M5 13l4 4L19 7";
9
+ /** A remove action: a cross. */
10
+ export declare const ICON_CLOSE = "M6 18L18 6M6 6l12 12";
11
+ /** An informational state: a circled i. */
12
+ export declare const ICON_INFO = "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z";
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Path data of the stroke icons the interactions share, rendered through
3
+ * `Icon.svelte`. Each icon is a 24×24 stroke drawing with round caps and
4
+ * joins; the interaction chooses the part name and classes, so what renders
5
+ * at each call site stays exactly what it rendered with its inline copy.
6
+ */
7
+ /** A completed action: a tick. */
8
+ export const ICON_CHECK = 'M5 13l4 4L19 7';
9
+ /** A remove action: a cross. */
10
+ export const ICON_CLOSE = 'M6 18L18 6M6 6l12 12';
11
+ /** An informational state: a circled i. */
12
+ export const ICON_INFO = 'M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z';
13
+ //# sourceMappingURL=icons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../src/shared/components/icons.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kCAAkC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC;AAE3C,gCAAgC;AAChC,MAAM,CAAC,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,CAAC,MAAM,SAAS,GAAG,2DAA2D,CAAC","sourcesContent":["/**\n * Path data of the stroke icons the interactions share, rendered through\n * `Icon.svelte`. Each icon is a 24×24 stroke drawing with round caps and\n * joins; the interaction chooses the part name and classes, so what renders\n * at each call site stays exactly what it rendered with its inline copy.\n */\n\n/** A completed action: a tick. */\nexport const ICON_CHECK = 'M5 13l4 4L19 7';\n\n/** A remove action: a cross. */\nexport const ICON_CLOSE = 'M6 18L18 6M6 6l12 12';\n\n/** An informational state: a circled i. */\nexport const ICON_INFO = 'M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z';\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The shared keyboard crosshair of the point-placement stages (select point,
3
+ * position object): a normalized position on the stage ([0, 1] × [0, 1],
4
+ * clamped) with the arrow-key movement both interactions share — 5% per press,
5
+ * 1% with Shift for fine steps — and the active flag that shows the overlay.
6
+ *
7
+ * What each interaction keeps for itself: rounding (select point rounds the
8
+ * point at placement, position object at emission) and every gate and refusal
9
+ * (select point's maxChoices, position object's stage capacity, `canAddMore`
10
+ * and its Escape-cancel), plus the announcements, which need the interaction's
11
+ * i18n provider.
12
+ */
13
+ export declare const CROSSHAIR_LARGE_STEP = 0.05;
14
+ export declare const CROSSHAIR_SMALL_STEP = 0.01;
15
+ export interface KeyboardCrosshair {
16
+ /** Whether the crosshair overlay is visible (keyboard placement in progress). */
17
+ readonly active: boolean;
18
+ /** Normalized x on the stage, 0–1, clamped. */
19
+ readonly x: number;
20
+ /** Normalized y on the stage, 0–1, clamped. */
21
+ readonly y: number;
22
+ /** Move to the stage centre (the default starting position). */
23
+ centre(): void;
24
+ activate(): void;
25
+ deactivate(): void;
26
+ /** Jump to a normalized position, clamped to the stage. */
27
+ jumpTo(x: number, y: number): void;
28
+ /**
29
+ * One arrow-key step, fine when Shift is held. Moves nothing and returns
30
+ * false for any other key.
31
+ */
32
+ move(key: string, fine: boolean): boolean;
33
+ }
34
+ export declare function createKeyboardCrosshair(options?: {
35
+ largeStep?: number;
36
+ smallStep?: number;
37
+ }): KeyboardCrosshair;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The shared keyboard crosshair of the point-placement stages (select point,
3
+ * position object): a normalized position on the stage ([0, 1] × [0, 1],
4
+ * clamped) with the arrow-key movement both interactions share — 5% per press,
5
+ * 1% with Shift for fine steps — and the active flag that shows the overlay.
6
+ *
7
+ * What each interaction keeps for itself: rounding (select point rounds the
8
+ * point at placement, position object at emission) and every gate and refusal
9
+ * (select point's maxChoices, position object's stage capacity, `canAddMore`
10
+ * and its Escape-cancel), plus the announcements, which need the interaction's
11
+ * i18n provider.
12
+ */
13
+ export const CROSSHAIR_LARGE_STEP = 0.05;
14
+ export const CROSSHAIR_SMALL_STEP = 0.01;
15
+ export function createKeyboardCrosshair(options = {}) {
16
+ let active = $state(false);
17
+ let x = $state(0.5);
18
+ let y = $state(0.5);
19
+ const large = options.largeStep ?? CROSSHAIR_LARGE_STEP;
20
+ const small = options.smallStep ?? CROSSHAIR_SMALL_STEP;
21
+ return {
22
+ get active() {
23
+ return active;
24
+ },
25
+ get x() {
26
+ return x;
27
+ },
28
+ get y() {
29
+ return y;
30
+ },
31
+ centre() {
32
+ x = 0.5;
33
+ y = 0.5;
34
+ },
35
+ activate() {
36
+ active = true;
37
+ },
38
+ deactivate() {
39
+ active = false;
40
+ },
41
+ jumpTo(nextX, nextY) {
42
+ x = Math.max(0, Math.min(1, nextX));
43
+ y = Math.max(0, Math.min(1, nextY));
44
+ },
45
+ move(key, fine) {
46
+ const step = fine ? small : large;
47
+ switch (key) {
48
+ case 'ArrowLeft':
49
+ x = Math.max(0, x - step);
50
+ break;
51
+ case 'ArrowRight':
52
+ x = Math.min(1, x + step);
53
+ break;
54
+ case 'ArrowUp':
55
+ y = Math.max(0, y - step);
56
+ break;
57
+ case 'ArrowDown':
58
+ y = Math.min(1, y + step);
59
+ break;
60
+ default:
61
+ return false;
62
+ }
63
+ return true;
64
+ },
65
+ };
66
+ }
67
+ //# sourceMappingURL=keyboardCrosshair.svelte.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardCrosshair.svelte.js","sourceRoot":"","sources":["../../../src/shared/components/keyboardCrosshair.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAsBzC,MAAM,UAAU,uBAAuB,CACtC,UAAsD,EAAE;IAExD,IAAI,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACpB,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,IAAI,oBAAoB,CAAC;IACxD,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,IAAI,oBAAoB,CAAC;IAExD,OAAO;QACN,IAAI,MAAM;YACT,OAAO,MAAM,CAAC;QACf,CAAC;QACD,IAAI,CAAC;YACJ,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,CAAC;YACJ,OAAO,CAAC,CAAC;QACV,CAAC;QACD,MAAM;YACL,CAAC,GAAG,GAAG,CAAC;YACR,CAAC,GAAG,GAAG,CAAC;QACT,CAAC;QACD,QAAQ;YACP,MAAM,GAAG,IAAI,CAAC;QACf,CAAC;QACD,UAAU;YACT,MAAM,GAAG,KAAK,CAAC;QAChB,CAAC;QACD,MAAM,CAAC,KAAa,EAAE,KAAa;YAClC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;YACpC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QACrC,CAAC;QACD,IAAI,CAAC,GAAW,EAAE,IAAa;YAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;YAClC,QAAQ,GAAG,EAAE,CAAC;gBACb,KAAK,WAAW;oBACf,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;oBAC1B,MAAM;gBACP,KAAK,YAAY;oBAChB,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;oBAC1B,MAAM;gBACP,KAAK,SAAS;oBACb,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;oBAC1B,MAAM;gBACP,KAAK,WAAW;oBACf,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;oBAC1B,MAAM;gBACP;oBACC,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * The shared keyboard crosshair of the point-placement stages (select point,\n * position object): a normalized position on the stage ([0, 1] × [0, 1],\n * clamped) with the arrow-key movement both interactions share — 5% per press,\n * 1% with Shift for fine steps — and the active flag that shows the overlay.\n *\n * What each interaction keeps for itself: rounding (select point rounds the\n * point at placement, position object at emission) and every gate and refusal\n * (select point's maxChoices, position object's stage capacity, `canAddMore`\n * and its Escape-cancel), plus the announcements, which need the interaction's\n * i18n provider.\n */\n\nexport const CROSSHAIR_LARGE_STEP = 0.05;\nexport const CROSSHAIR_SMALL_STEP = 0.01;\n\nexport interface KeyboardCrosshair {\n\t/** Whether the crosshair overlay is visible (keyboard placement in progress). */\n\treadonly active: boolean;\n\t/** Normalized x on the stage, 0–1, clamped. */\n\treadonly x: number;\n\t/** Normalized y on the stage, 0–1, clamped. */\n\treadonly y: number;\n\t/** Move to the stage centre (the default starting position). */\n\tcentre(): void;\n\tactivate(): void;\n\tdeactivate(): void;\n\t/** Jump to a normalized position, clamped to the stage. */\n\tjumpTo(x: number, y: number): void;\n\t/**\n\t * One arrow-key step, fine when Shift is held. Moves nothing and returns\n\t * false for any other key.\n\t */\n\tmove(key: string, fine: boolean): boolean;\n}\n\nexport function createKeyboardCrosshair(\n\toptions: { largeStep?: number; smallStep?: number } = {},\n): KeyboardCrosshair {\n\tlet active = $state(false);\n\tlet x = $state(0.5);\n\tlet y = $state(0.5);\n\tconst large = options.largeStep ?? CROSSHAIR_LARGE_STEP;\n\tconst small = options.smallStep ?? CROSSHAIR_SMALL_STEP;\n\n\treturn {\n\t\tget active() {\n\t\t\treturn active;\n\t\t},\n\t\tget x() {\n\t\t\treturn x;\n\t\t},\n\t\tget y() {\n\t\t\treturn y;\n\t\t},\n\t\tcentre() {\n\t\t\tx = 0.5;\n\t\t\ty = 0.5;\n\t\t},\n\t\tactivate() {\n\t\t\tactive = true;\n\t\t},\n\t\tdeactivate() {\n\t\t\tactive = false;\n\t\t},\n\t\tjumpTo(nextX: number, nextY: number) {\n\t\t\tx = Math.max(0, Math.min(1, nextX));\n\t\t\ty = Math.max(0, Math.min(1, nextY));\n\t\t},\n\t\tmove(key: string, fine: boolean): boolean {\n\t\t\tconst step = fine ? small : large;\n\t\t\tswitch (key) {\n\t\t\t\tcase 'ArrowLeft':\n\t\t\t\t\tx = Math.max(0, x - step);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowRight':\n\t\t\t\t\tx = Math.min(1, x + step);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowUp':\n\t\t\t\t\ty = Math.max(0, y - step);\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'ArrowDown':\n\t\t\t\t\ty = Math.min(1, y + step);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault:\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t};\n}\n"]}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The pick-up/place flow of the drag-and-drop surfaces — gap match, graphic gap match, match
3
+ * (MatchDragDrop) and the sortable list. One item at a time is held: picked up with the
4
+ * keyboard or a pointer activation (the single-pointer alternative to dragging, WCAG 2.5.7),
5
+ * then placed on a target or put down. A pointer drag is tracked beside it, so what a drop
6
+ * would place — the dragged item during a drag, else the held one — is the one value each
7
+ * interaction marks its refusing targets from.
8
+ *
9
+ * The rules every surface shares live here: activating the held item again puts it down and
10
+ * activating another one switches to it; a refused placement keeps the item held, so the
11
+ * candidate can try another target or cancel, and an accepted one puts it down; Escape puts it
12
+ * down.
13
+ *
14
+ * What each interaction keeps for itself: which items may be picked up and which targets take
15
+ * them (capacity, matchGroup), how a placement changes the response, the announcements (each
16
+ * has its own i18n keys), whether Escape prevents the default, and where focus goes.
17
+ */
18
+ export interface PickUpPlace {
19
+ /** The held item's identifier, or null. */
20
+ readonly held: string | null;
21
+ /** The item a pointer drag is carrying, or null. */
22
+ readonly dragged: string | null;
23
+ /** What a drop would place: the dragged item during a drag, else the held one. */
24
+ readonly active: string | null;
25
+ /** Whether `id` is the held item. */
26
+ isHeld(id: string): boolean;
27
+ /** Pick `id` up, or put it down when it is the held item. Returns whether `id` is held now. */
28
+ toggle(id: string): boolean;
29
+ /**
30
+ * Place the held item on `target` through `attempt`, which applies the placement and
31
+ * returns whether it was accepted. An accepted placement puts the item down and returns
32
+ * it; a refused one keeps it held and returns null, as does holding nothing.
33
+ */
34
+ place<T>(target: T, attempt: (item: string, target: T) => boolean): string | null;
35
+ /** Put the held item down without placing it (Escape, or a move made another way). Returns it, or null. */
36
+ release(): string | null;
37
+ /** A pointer drag of `id` starts. */
38
+ startDrag(id: string): void;
39
+ /** The pointer drag dropped or ended. */
40
+ endDrag(): void;
41
+ }
42
+ export declare function createPickUpPlace(): PickUpPlace;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The pick-up/place flow of the drag-and-drop surfaces — gap match, graphic gap match, match
3
+ * (MatchDragDrop) and the sortable list. One item at a time is held: picked up with the
4
+ * keyboard or a pointer activation (the single-pointer alternative to dragging, WCAG 2.5.7),
5
+ * then placed on a target or put down. A pointer drag is tracked beside it, so what a drop
6
+ * would place — the dragged item during a drag, else the held one — is the one value each
7
+ * interaction marks its refusing targets from.
8
+ *
9
+ * The rules every surface shares live here: activating the held item again puts it down and
10
+ * activating another one switches to it; a refused placement keeps the item held, so the
11
+ * candidate can try another target or cancel, and an accepted one puts it down; Escape puts it
12
+ * down.
13
+ *
14
+ * What each interaction keeps for itself: which items may be picked up and which targets take
15
+ * them (capacity, matchGroup), how a placement changes the response, the announcements (each
16
+ * has its own i18n keys), whether Escape prevents the default, and where focus goes.
17
+ */
18
+ export function createPickUpPlace() {
19
+ let held = $state(null);
20
+ let dragged = $state(null);
21
+ return {
22
+ get held() {
23
+ return held;
24
+ },
25
+ get dragged() {
26
+ return dragged;
27
+ },
28
+ get active() {
29
+ return dragged ?? held;
30
+ },
31
+ isHeld(id) {
32
+ return held === id;
33
+ },
34
+ toggle(id) {
35
+ held = held === id ? null : id;
36
+ return held === id;
37
+ },
38
+ place(target, attempt) {
39
+ const item = held;
40
+ if (item === null || !attempt(item, target))
41
+ return null;
42
+ held = null;
43
+ return item;
44
+ },
45
+ release() {
46
+ const item = held;
47
+ held = null;
48
+ return item;
49
+ },
50
+ startDrag(id) {
51
+ dragged = id;
52
+ },
53
+ endDrag() {
54
+ dragged = null;
55
+ },
56
+ };
57
+ }
58
+ //# sourceMappingURL=pickUpPlace.svelte.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pickUpPlace.svelte.js","sourceRoot":"","sources":["../../../src/shared/components/pickUpPlace.svelte.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2BH,MAAM,UAAU,iBAAiB;IAChC,IAAI,IAAI,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IACvC,IAAI,OAAO,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IAE1C,OAAO;QACN,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,OAAO;YACV,OAAO,OAAO,CAAC;QAChB,CAAC;QACD,IAAI,MAAM;YACT,OAAO,OAAO,IAAI,IAAI,CAAC;QACxB,CAAC;QACD,MAAM,CAAC,EAAU;YAChB,OAAO,IAAI,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,MAAM,CAAC,EAAU;YAChB,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,KAAK,EAAE,CAAC;QACpB,CAAC;QACD,KAAK,CAAI,MAAS,EAAE,OAA6C;YAChE,MAAM,IAAI,GAAG,IAAI,CAAC;YAClB,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;gBAAE,OAAO,IAAI,CAAC;YACzD,IAAI,GAAG,IAAI,CAAC;YACZ,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO;YACN,MAAM,IAAI,GAAG,IAAI,CAAC;YAClB,IAAI,GAAG,IAAI,CAAC;YACZ,OAAO,IAAI,CAAC;QACb,CAAC;QACD,SAAS,CAAC,EAAU;YACnB,OAAO,GAAG,EAAE,CAAC;QACd,CAAC;QACD,OAAO;YACN,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;KACD,CAAC;AACH,CAAC","sourcesContent":["/**\n * The pick-up/place flow of the drag-and-drop surfaces — gap match, graphic gap match, match\n * (MatchDragDrop) and the sortable list. One item at a time is held: picked up with the\n * keyboard or a pointer activation (the single-pointer alternative to dragging, WCAG 2.5.7),\n * then placed on a target or put down. A pointer drag is tracked beside it, so what a drop\n * would place — the dragged item during a drag, else the held one — is the one value each\n * interaction marks its refusing targets from.\n *\n * The rules every surface shares live here: activating the held item again puts it down and\n * activating another one switches to it; a refused placement keeps the item held, so the\n * candidate can try another target or cancel, and an accepted one puts it down; Escape puts it\n * down.\n *\n * What each interaction keeps for itself: which items may be picked up and which targets take\n * them (capacity, matchGroup), how a placement changes the response, the announcements (each\n * has its own i18n keys), whether Escape prevents the default, and where focus goes.\n */\n\nexport interface PickUpPlace {\n\t/** The held item's identifier, or null. */\n\treadonly held: string | null;\n\t/** The item a pointer drag is carrying, or null. */\n\treadonly dragged: string | null;\n\t/** What a drop would place: the dragged item during a drag, else the held one. */\n\treadonly active: string | null;\n\t/** Whether `id` is the held item. */\n\tisHeld(id: string): boolean;\n\t/** Pick `id` up, or put it down when it is the held item. Returns whether `id` is held now. */\n\ttoggle(id: string): boolean;\n\t/**\n\t * Place the held item on `target` through `attempt`, which applies the placement and\n\t * returns whether it was accepted. An accepted placement puts the item down and returns\n\t * it; a refused one keeps it held and returns null, as does holding nothing.\n\t */\n\tplace<T>(target: T, attempt: (item: string, target: T) => boolean): string | null;\n\t/** Put the held item down without placing it (Escape, or a move made another way). Returns it, or null. */\n\trelease(): string | null;\n\t/** A pointer drag of `id` starts. */\n\tstartDrag(id: string): void;\n\t/** The pointer drag dropped or ended. */\n\tendDrag(): void;\n}\n\nexport function createPickUpPlace(): PickUpPlace {\n\tlet held = $state<string | null>(null);\n\tlet dragged = $state<string | null>(null);\n\n\treturn {\n\t\tget held() {\n\t\t\treturn held;\n\t\t},\n\t\tget dragged() {\n\t\t\treturn dragged;\n\t\t},\n\t\tget active() {\n\t\t\treturn dragged ?? held;\n\t\t},\n\t\tisHeld(id: string): boolean {\n\t\t\treturn held === id;\n\t\t},\n\t\ttoggle(id: string): boolean {\n\t\t\theld = held === id ? null : id;\n\t\t\treturn held === id;\n\t\t},\n\t\tplace<T>(target: T, attempt: (item: string, target: T) => boolean): string | null {\n\t\t\tconst item = held;\n\t\t\tif (item === null || !attempt(item, target)) return null;\n\t\t\theld = null;\n\t\t\treturn item;\n\t\t},\n\t\trelease(): string | null {\n\t\t\tconst item = held;\n\t\t\theld = null;\n\t\t\treturn item;\n\t\t},\n\t\tstartDrag(id: string): void {\n\t\t\tdragged = id;\n\t\t},\n\t\tendDrag(): void {\n\t\t\tdragged = null;\n\t\t},\n\t};\n}\n"]}
@@ -1,19 +1,46 @@
1
1
  import 'mathlive/static.css';
2
+ /**
3
+ * The translation surface the editor uses; an `I18nProvider` satisfies it, and
4
+ * so does the earlier `{ t(key) }` shape.
5
+ */
6
+ export interface MathLiveEditorI18n {
7
+ t: (key: string, fallback?: string, values?: Record<string, unknown>) => string | undefined;
8
+ }
9
+ /** How a dialog closed without its math being confirmed. */
10
+ export interface MathLiveEditorCancelDetails {
11
+ /**
12
+ * True when a host closed the dialog (`pie-qti-close-transient-ui`, a proctor pause), not
13
+ * the candidate: the opener may keep `latex` and offer it again when the candidate reopens
14
+ * the dialog, so the pause does not cost them what they typed.
15
+ */
16
+ interrupted: boolean;
17
+ /** The LaTeX in the field when the dialog closed (the initial value if it never opened). */
18
+ latex: string;
19
+ }
2
20
  export interface MathLiveEditorOptions {
3
21
  /** Called when user confirms the LaTeX input */
4
22
  onConfirm: (latex: string) => void;
5
- /** Called when user cancels */
6
- onCancel: () => void;
23
+ /** Called when the dialog closes without confirming: the candidate cancelled, or a host closed it. */
24
+ onCancel: (details: MathLiveEditorCancelDetails) => void;
7
25
  /** Initial LaTeX value */
8
26
  initialLatex?: string;
9
27
  /** Whether this is inline or block math */
10
28
  isBlock?: boolean;
29
+ /**
30
+ * Whether the dialog inserts new math or edits existing math: it sets the
31
+ * title and the confirm button. Defaults to `edit` when `initialLatex` is set.
32
+ */
33
+ mode?: 'insert' | 'edit';
34
+ /**
35
+ * The control that opened the dialog, where focus returns when it closes.
36
+ * Defaults to the element focused when the dialog was requested.
37
+ */
38
+ returnFocusTo?: HTMLElement | null;
11
39
  /** Optional i18n provider for translations */
12
- i18n?: {
13
- t: (key: string) => string | undefined;
14
- };
40
+ i18n?: MathLiveEditorI18n;
15
41
  }
16
42
  /**
17
- * Opens a modal dialog with MathLive editor for LaTeX input
43
+ * Opens a modal dialog with MathLive editor for LaTeX input.
44
+ * Resolves to a function that closes the dialog without calling either callback.
18
45
  */
19
46
  export declare function openMathLiveEditor(options: MathLiveEditorOptions): Promise<() => void>;