@intellectif/lk-react 3.0.0 → 5.0.0

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 (76) hide show
  1. package/README.md +7 -2
  2. package/dist/{WrittenResponse-BHhP936i.d.ts → WrittenResponse-Dkg7FUt-.d.ts} +1 -1
  3. package/dist/{WrittenResponse-B50EjVR0.d.cts → WrittenResponse-DqQ0NjPK.d.cts} +1 -1
  4. package/dist/chunk-3B4ACY4K.cjs +249 -0
  5. package/dist/chunk-3B4ACY4K.cjs.map +1 -0
  6. package/dist/{chunk-3X7MYAFT.js → chunk-3DNJDP73.js} +11 -9
  7. package/dist/chunk-3DNJDP73.js.map +1 -0
  8. package/dist/chunk-4HZ7LQIH.cjs +40 -0
  9. package/dist/chunk-4HZ7LQIH.cjs.map +1 -0
  10. package/dist/{chunk-ZVFWJTT4.js → chunk-5SYL5CJ2.js} +10 -28
  11. package/dist/chunk-5SYL5CJ2.js.map +1 -0
  12. package/dist/{chunk-UXO6KYSZ.cjs → chunk-67RIIDZX.cjs} +17 -15
  13. package/dist/chunk-67RIIDZX.cjs.map +1 -0
  14. package/dist/{chunk-AEQQ7VPF.js → chunk-67WDTQMG.js} +9 -4
  15. package/dist/chunk-67WDTQMG.js.map +1 -0
  16. package/dist/{chunk-7MW7HGOA.cjs → chunk-6COTYW77.cjs} +15 -10
  17. package/dist/chunk-6COTYW77.cjs.map +1 -0
  18. package/dist/chunk-6F4X2NKL.js +54 -0
  19. package/dist/chunk-6F4X2NKL.js.map +1 -0
  20. package/dist/chunk-GB5URWM4.js +38 -0
  21. package/dist/chunk-GB5URWM4.js.map +1 -0
  22. package/dist/chunk-NBFTCGQ5.js +247 -0
  23. package/dist/chunk-NBFTCGQ5.js.map +1 -0
  24. package/dist/chunk-NEWGUDA5.cjs +49 -0
  25. package/dist/chunk-NEWGUDA5.cjs.map +1 -0
  26. package/dist/{chunk-QHOV2A6M.cjs → chunk-PGEG7UZJ.cjs} +2 -34
  27. package/dist/chunk-PGEG7UZJ.cjs.map +1 -0
  28. package/dist/chunk-UQ3BBEIT.js +47 -0
  29. package/dist/chunk-UQ3BBEIT.js.map +1 -0
  30. package/dist/{chunk-W6BH2YMZ.cjs → chunk-WCVD5LVG.cjs} +16 -34
  31. package/dist/chunk-WCVD5LVG.cjs.map +1 -0
  32. package/dist/components/ActivitySequence.cjs +8 -6
  33. package/dist/components/ActivitySequence.d.cts +87 -9
  34. package/dist/components/ActivitySequence.d.ts +87 -9
  35. package/dist/components/ActivitySequence.js +7 -5
  36. package/dist/components/FillInTheBlanks.cjs +4 -3
  37. package/dist/components/FillInTheBlanks.d.cts +1 -1
  38. package/dist/components/FillInTheBlanks.d.ts +1 -1
  39. package/dist/components/FillInTheBlanks.js +3 -2
  40. package/dist/components/MultipleChoice.cjs +4 -3
  41. package/dist/components/MultipleChoice.d.cts +1 -1
  42. package/dist/components/MultipleChoice.d.ts +1 -1
  43. package/dist/components/MultipleChoice.js +3 -2
  44. package/dist/components/StimulusPanel.cjs +13 -0
  45. package/dist/components/StimulusPanel.cjs.map +1 -0
  46. package/dist/components/StimulusPanel.d.cts +30 -0
  47. package/dist/components/StimulusPanel.d.ts +30 -0
  48. package/dist/components/StimulusPanel.js +4 -0
  49. package/dist/components/StimulusPanel.js.map +1 -0
  50. package/dist/components/WrittenResponse.cjs +4 -3
  51. package/dist/components/WrittenResponse.d.cts +3 -3
  52. package/dist/components/WrittenResponse.d.ts +3 -3
  53. package/dist/components/WrittenResponse.js +3 -2
  54. package/dist/index.cjs +36 -26
  55. package/dist/index.cjs.map +1 -1
  56. package/dist/index.d.cts +3 -2
  57. package/dist/index.d.ts +3 -2
  58. package/dist/index.js +12 -7
  59. package/dist/index.js.map +1 -1
  60. package/dist/theme/skin.css +49 -0
  61. package/dist/{types-CNmjqD6M.d.cts → types-CrURyd9-.d.cts} +51 -3
  62. package/dist/{types-CNmjqD6M.d.ts → types-CrURyd9-.d.ts} +51 -3
  63. package/package.json +15 -4
  64. package/dist/chunk-3X7MYAFT.js.map +0 -1
  65. package/dist/chunk-7MW7HGOA.cjs.map +0 -1
  66. package/dist/chunk-AEQQ7VPF.js.map +0 -1
  67. package/dist/chunk-BGWXN44S.js +0 -152
  68. package/dist/chunk-BGWXN44S.js.map +0 -1
  69. package/dist/chunk-HO3AC3WQ.cjs +0 -154
  70. package/dist/chunk-HO3AC3WQ.cjs.map +0 -1
  71. package/dist/chunk-QHOV2A6M.cjs.map +0 -1
  72. package/dist/chunk-UIGIYYGY.js +0 -85
  73. package/dist/chunk-UIGIYYGY.js.map +0 -1
  74. package/dist/chunk-UXO6KYSZ.cjs.map +0 -1
  75. package/dist/chunk-W6BH2YMZ.cjs.map +0 -1
  76. package/dist/chunk-ZVFWJTT4.js.map +0 -1
@@ -1,5 +1,6 @@
1
- export { WrittenResponse } from '../chunk-AEQQ7VPF.js';
2
- import '../chunk-UIGIYYGY.js';
1
+ export { WrittenResponse } from '../chunk-67WDTQMG.js';
2
+ import '../chunk-6F4X2NKL.js';
3
+ import '../chunk-GB5URWM4.js';
3
4
  import '../chunk-5HVUKXF3.js';
4
5
  //# sourceMappingURL=WrittenResponse.js.map
5
6
  //# sourceMappingURL=WrittenResponse.js.map
package/dist/index.cjs CHANGED
@@ -1,59 +1,69 @@
1
1
  'use strict';
2
2
 
3
- var chunkHO3AC3WQ_cjs = require('./chunk-HO3AC3WQ.cjs');
4
- var chunkW6BH2YMZ_cjs = require('./chunk-W6BH2YMZ.cjs');
5
- var chunkUXO6KYSZ_cjs = require('./chunk-UXO6KYSZ.cjs');
6
- var chunk7MW7HGOA_cjs = require('./chunk-7MW7HGOA.cjs');
7
- require('./chunk-QHOV2A6M.cjs');
3
+ var chunkCPF2JJG6_cjs = require('./chunk-CPF2JJG6.cjs');
4
+ var chunk3B4ACY4K_cjs = require('./chunk-3B4ACY4K.cjs');
5
+ var chunkWCVD5LVG_cjs = require('./chunk-WCVD5LVG.cjs');
6
+ var chunk67RIIDZX_cjs = require('./chunk-67RIIDZX.cjs');
7
+ var chunk6COTYW77_cjs = require('./chunk-6COTYW77.cjs');
8
+ require('./chunk-PGEG7UZJ.cjs');
9
+ var chunkNEWGUDA5_cjs = require('./chunk-NEWGUDA5.cjs');
10
+ require('./chunk-4HZ7LQIH.cjs');
8
11
  var chunkHD2AIQRD_cjs = require('./chunk-HD2AIQRD.cjs');
9
12
  var chunkIYLQSNLE_cjs = require('./chunk-IYLQSNLE.cjs');
10
- var chunkCPF2JJG6_cjs = require('./chunk-CPF2JJG6.cjs');
11
13
 
12
14
  // src/components/types.ts
13
15
  function asRenderable(redacted) {
14
16
  return redacted;
15
17
  }
18
+ function asRenderableSequence(entries) {
19
+ return entries;
20
+ }
16
21
 
17
- Object.defineProperty(exports, "ActivitySequence", {
22
+ Object.defineProperty(exports, "ThemeProvider", {
18
23
  enumerable: true,
19
- get: function () { return chunkHO3AC3WQ_cjs.ActivitySequence; }
24
+ get: function () { return chunkCPF2JJG6_cjs.ThemeProvider; }
20
25
  });
21
- Object.defineProperty(exports, "MultipleChoice", {
26
+ Object.defineProperty(exports, "darkTheme", {
22
27
  enumerable: true,
23
- get: function () { return chunkW6BH2YMZ_cjs.MultipleChoice; }
28
+ get: function () { return chunkCPF2JJG6_cjs.darkTheme; }
24
29
  });
25
- Object.defineProperty(exports, "FillInTheBlanks", {
30
+ Object.defineProperty(exports, "defaultTheme", {
26
31
  enumerable: true,
27
- get: function () { return chunkUXO6KYSZ_cjs.FillInTheBlanks; }
32
+ get: function () { return chunkCPF2JJG6_cjs.defaultTheme; }
28
33
  });
29
- Object.defineProperty(exports, "WrittenResponse", {
34
+ Object.defineProperty(exports, "useTheme", {
30
35
  enumerable: true,
31
- get: function () { return chunk7MW7HGOA_cjs.WrittenResponse; }
36
+ get: function () { return chunkCPF2JJG6_cjs.useTheme; }
32
37
  });
33
- Object.defineProperty(exports, "useActivityState", {
38
+ Object.defineProperty(exports, "ActivitySequence", {
34
39
  enumerable: true,
35
- get: function () { return chunkHD2AIQRD_cjs.useActivityState; }
40
+ get: function () { return chunk3B4ACY4K_cjs.ActivitySequence; }
36
41
  });
37
- Object.defineProperty(exports, "useXAPI", {
42
+ Object.defineProperty(exports, "MultipleChoice", {
38
43
  enumerable: true,
39
- get: function () { return chunkIYLQSNLE_cjs.useXAPI; }
44
+ get: function () { return chunkWCVD5LVG_cjs.MultipleChoice; }
40
45
  });
41
- Object.defineProperty(exports, "ThemeProvider", {
46
+ Object.defineProperty(exports, "FillInTheBlanks", {
42
47
  enumerable: true,
43
- get: function () { return chunkCPF2JJG6_cjs.ThemeProvider; }
48
+ get: function () { return chunk67RIIDZX_cjs.FillInTheBlanks; }
44
49
  });
45
- Object.defineProperty(exports, "darkTheme", {
50
+ Object.defineProperty(exports, "WrittenResponse", {
46
51
  enumerable: true,
47
- get: function () { return chunkCPF2JJG6_cjs.darkTheme; }
52
+ get: function () { return chunk6COTYW77_cjs.WrittenResponse; }
48
53
  });
49
- Object.defineProperty(exports, "defaultTheme", {
54
+ Object.defineProperty(exports, "StimulusPanel", {
50
55
  enumerable: true,
51
- get: function () { return chunkCPF2JJG6_cjs.defaultTheme; }
56
+ get: function () { return chunkNEWGUDA5_cjs.StimulusPanel; }
52
57
  });
53
- Object.defineProperty(exports, "useTheme", {
58
+ Object.defineProperty(exports, "useActivityState", {
54
59
  enumerable: true,
55
- get: function () { return chunkCPF2JJG6_cjs.useTheme; }
60
+ get: function () { return chunkHD2AIQRD_cjs.useActivityState; }
61
+ });
62
+ Object.defineProperty(exports, "useXAPI", {
63
+ enumerable: true,
64
+ get: function () { return chunkIYLQSNLE_cjs.useXAPI; }
56
65
  });
57
66
  exports.asRenderable = asRenderable;
67
+ exports.asRenderableSequence = asRenderableSequence;
58
68
  //# sourceMappingURL=index.cjs.map
59
69
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAqHO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: Renderable<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n"]}
1
+ {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AA2IO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA4BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.cjs","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — the built-in components\n * throw at render rather than fail at submit time, so a mis-wired exam item is\n * loud, not silent.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n"]}
package/dist/index.d.cts CHANGED
@@ -1,12 +1,13 @@
1
1
  export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItemOutcome } from './components/ActivitySequence.cjs';
2
2
  export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.cjs';
3
3
  export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.cjs';
4
- export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as asRenderable } from './types-CNmjqD6M.cjs';
4
+ export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.cjs';
5
+ export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as RenderableActivity, c as asRenderable, d as asRenderableSequence } from './types-CrURyd9-.cjs';
5
6
  export { WrittenResponse } from './components/WrittenResponse.cjs';
6
7
  export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.cjs';
7
8
  export { UseXAPIResult, useXAPI } from './hooks/useXAPI.cjs';
8
9
  export { ThemeProvider, ThemeProviderProps, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.cjs';
9
- export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-B50EjVR0.cjs';
10
+ export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-DqQ0NjPK.cjs';
10
11
  import '@intellectif/lk-core';
11
12
  import 'react';
12
13
  import 'react/jsx-runtime';
package/dist/index.d.ts CHANGED
@@ -1,12 +1,13 @@
1
1
  export { ActivityRenderer, ActivitySequence, ActivitySequenceProps, SequenceItemOutcome } from './components/ActivitySequence.js';
2
2
  export { FillInTheBlanks, FillInTheBlanksProps } from './components/FillInTheBlanks.js';
3
3
  export { MultipleChoice, MultipleChoiceProps } from './components/MultipleChoice.js';
4
- export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as asRenderable } from './types-CNmjqD6M.js';
4
+ export { StimulusPanel, StimulusPanelProps } from './components/StimulusPanel.js';
5
+ export { A as ActivityProps, H as HtmlSanitizer, R as RenderMode, a as Renderable, b as RenderableActivity, c as asRenderable, d as asRenderableSequence } from './types-CrURyd9-.js';
5
6
  export { WrittenResponse } from './components/WrittenResponse.js';
6
7
  export { ActivityState, UseActivityStateResult, useActivityState } from './hooks/useActivityState.js';
7
8
  export { UseXAPIResult, useXAPI } from './hooks/useXAPI.js';
8
9
  export { ThemeProvider, ThemeProviderProps, darkTheme, defaultTheme, useTheme } from './theme/ThemeProvider.js';
9
- export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-BHhP936i.js';
10
+ export { W as WrittenResponseProps, a as WrittenResponseSubmission } from './WrittenResponse-Dkg7FUt-.js';
10
11
  import '@intellectif/lk-core';
11
12
  import 'react';
12
13
  import 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -1,17 +1,22 @@
1
- export { ActivitySequence } from './chunk-BGWXN44S.js';
2
- export { MultipleChoice } from './chunk-ZVFWJTT4.js';
3
- export { FillInTheBlanks } from './chunk-3X7MYAFT.js';
4
- export { WrittenResponse } from './chunk-AEQQ7VPF.js';
5
- import './chunk-UIGIYYGY.js';
1
+ export { ThemeProvider, darkTheme, defaultTheme, useTheme } from './chunk-B3FUUKZ2.js';
2
+ export { ActivitySequence } from './chunk-NBFTCGQ5.js';
3
+ export { MultipleChoice } from './chunk-5SYL5CJ2.js';
4
+ export { FillInTheBlanks } from './chunk-3DNJDP73.js';
5
+ export { WrittenResponse } from './chunk-67WDTQMG.js';
6
+ import './chunk-6F4X2NKL.js';
7
+ export { StimulusPanel } from './chunk-UQ3BBEIT.js';
8
+ import './chunk-GB5URWM4.js';
6
9
  export { useActivityState } from './chunk-5HVUKXF3.js';
7
10
  export { useXAPI } from './chunk-E4MNA2IQ.js';
8
- export { ThemeProvider, darkTheme, defaultTheme, useTheme } from './chunk-B3FUUKZ2.js';
9
11
 
10
12
  // src/components/types.ts
11
13
  function asRenderable(redacted) {
12
14
  return redacted;
13
15
  }
16
+ function asRenderableSequence(entries) {
17
+ return entries;
18
+ }
14
19
 
15
- export { asRenderable };
20
+ export { asRenderable, asRenderableSequence };
16
21
  //# sourceMappingURL=index.js.map
17
22
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;AAqHO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: Renderable<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n"]}
1
+ {"version":3,"sources":["../src/components/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AA2IO,SAAS,aACd,QAAA,EACmB;AACnB,EAAA,OAAO,QAAA;AACT;AA4BO,SAAS,qBACd,OAAA,EAC8C;AAC9C,EAAA,OAAO,OAAA;AACT","file":"index.js","sourcesContent":["import type {\n ActivityData,\n ActivityResult,\n InteractionEvent,\n ItemGroup,\n ItemOutcome,\n LearnerResponse,\n RedactedActivityData,\n SequenceEntry,\n ThemeTokens,\n} from '@intellectif/lk-core';\n\n/**\n * How an activity is being presented. This is the single switch that decides\n * whether the component may grade, reveal, or submit — the three things a\n * summative exam must take away from the client.\n *\n * - `practice` (default, v1 behaviour): the component owns the attempt. It\n * scores locally on submit, reveals correctness and feedback, and calls\n * `onComplete` with a full {@link ActivityResult}.\n * - `exam`: the component NEVER scores and NEVER reveals correctness. Submit\n * emits the raw learner response through `onSubmit`; the server grades it.\n * Safe to render redacted data, because nothing here needs the answer key.\n * - `review`: read-only. Renders the learner's submitted answer, and marks\n * correctness only from an `outcome` the caller supplies (which the server\n * computed). Nothing is submittable.\n */\nexport type RenderMode = 'practice' | 'exam' | 'review';\n\n/**\n * Makes the answer-key-bearing parts of an activity optional, so a component\n * can render either full activity data OR a `redact()` projection with the\n * same props. Fields the SDK classifies `answer-key` become optional here;\n * a component in `exam` mode must not read them at all.\n */\nexport type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {\n scoringStrategy?: unknown;\n /** Present on a `redact()` projection. */\n redacted?: true;\n};\n\n/**\n * {@link Renderable} DISTRIBUTED over a union of activity types.\n *\n * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on\n * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the\n * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single\n * object type carrying only the fields every activity shares. Narrowing it\n * dies with it — after `if (data.type === 'multiple-choice')` the compiler\n * still refuses `data.options`, because the union it would narrow to no\n * longer exists.\n *\n * The conditional below re-distributes, so `RenderableActivity` is a real\n * union of per-type renderables and `.type` narrows again. Anything that\n * accepts \"some renderable activity, I don't know which\" — a custom renderer,\n * a sequence entry — must use THIS, not `Renderable<ActivityData>`.\n */\nexport type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown\n ? Renderable<TData>\n : never;\n\n/**\n * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,\n * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a\n * dependency and, worse, a false promise. Rich text is rendered only when you\n * supply this function; without it the component falls back to the plain-text\n * field, which is always escaped. Fail-safe by construction: the SDK never\n * injects HTML it was not explicitly given a sanitiser for.\n */\nexport type HtmlSanitizer = (html: string) => string;\n\n/**\n * The prop contract shared by every activity component (Req 3.1). Defined\n * here (React-specific) rather than in lk-core, which is React-free.\n *\n * Controlled / uncontrolled follows the React convention: pass `value` +\n * `onChange` to own the learner's answer (restore an in-progress attempt,\n * autosave a delta, drive a review); pass `defaultValue` to seed an\n * uncontrolled component; pass neither for the v1 behaviour.\n */\nexport interface ActivityProps<TData extends ActivityData = ActivityData> {\n /** Activity content. Accepts a `redact()` projection in `exam` mode. */\n data: RenderableActivity<TData>;\n /**\n * Called when the component scored the attempt itself. Only ever fires in\n * `practice` mode — in `exam` mode the client does not grade, so there is\n * no `ActivityResult` to give you; use `onSubmit`.\n */\n onComplete?: (result: ActivityResult) => void;\n /**\n * Called on submit with the raw learner response and no grade. Fires in\n * every mode, before `onComplete`, so an exam runner can persist the\n * response and let the server score it.\n */\n onSubmit?: (response: LearnerResponse) => void;\n /** Controlled value: the learner's current response. */\n value?: LearnerResponse;\n /** Initial response for an uncontrolled component (ignored when `value` is set). */\n defaultValue?: LearnerResponse;\n /** Fires on every change to the learner's response. Required for a controlled component. */\n onChange?: (response: LearnerResponse) => void;\n /** Presentation mode. Defaults to `practice`. */\n renderMode?: RenderMode;\n /**\n * Server-computed outcome, used by `review` mode to mark correctness\n * without the client ever scoring. Ignored in other modes.\n */\n outcome?: ItemOutcome;\n /** Renders author-supplied rich text when provided. See {@link HtmlSanitizer}. */\n sanitizeHtml?: HtmlSanitizer;\n onInteraction?: (event: InteractionEvent) => void;\n /** Per-instance token overrides, applied as inline CSS vars on the root. */\n theme?: Partial<ThemeTokens>;\n locale?: string;\n disabled?: boolean;\n}\n\n/**\n * Bridges a server-produced `redact()` projection into the `data` prop.\n *\n * `RedactedActivityData` is deliberately index-signature typed in lk-core — it\n * proves a payload is learner-safe, not what shape it has — so TypeScript\n * cannot know it still carries the public fields a renderer needs. This is the\n * SDK's single, documented crossing of that gap, so an exam runner does not\n * have to write `as unknown as` at every call site:\n *\n * ```tsx\n * <MultipleChoice\n * data={asRenderable<MultipleChoiceData>(redactedFromServer)}\n * renderMode=\"exam\"\n * onSubmit={persist}\n * />\n * ```\n *\n * Safe because `exam` mode reads only public fields; the answer-key fields the\n * type claims are exactly the ones the component is forbidden to touch there.\n * A future release will derive per-type redacted interfaces so this becomes\n * unnecessary.\n */\nexport function asRenderable<TData extends ActivityData>(\n redacted: RedactedActivityData,\n): Renderable<TData> {\n return redacted as unknown as Renderable<TData>;\n}\n\n/**\n * The same bridge as {@link asRenderable}, for a whole sequence: activities\n * and item groups as a server hands them over, ready for `<ActivitySequence>`.\n *\n * Needed for the same reason and no other. `redactItemGroup` returns\n * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an\n * index-signature type whose fields are all `unknown` — so its `question` is\n * not a `string` and it satisfies no per-type renderable, however the prop is\n * widened. Widening alone cannot fix this; a crossing point is required, and\n * having exactly one keeps `as unknown as` out of consumer code.\n *\n * ```tsx\n * const entries = await fetchExam(); // redacted, server-side\n * <ActivitySequence\n * activities={asRenderableSequence(entries)}\n * renderMode=\"exam\" // REQUIRED: see below\n * shuffleSeed={attemptId}\n * onSubmit={persist}\n * />\n * ```\n *\n * Pass `renderMode=\"exam\"` (or `\"review\"`). Redacted data has no answer key,\n * and the default `practice` mode grades locally — the built-in components\n * throw at render rather than fail at submit time, so a mis-wired exam item is\n * loud, not silent.\n */\nexport function asRenderableSequence(\n entries: readonly (RedactedActivityData | RedactedItemGroupData)[],\n): readonly SequenceEntry<RenderableActivity>[] {\n return entries as unknown as readonly SequenceEntry<RenderableActivity>[];\n}\n\n/** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */\ntype RedactedItemGroupData = ItemGroup<RedactedActivityData> & { redacted: true };\n"]}
@@ -111,6 +111,55 @@
111
111
  cursor: default;
112
112
  }
113
113
 
114
+ /* ── Shared stimulus (an item group's passage / recording / image) ──── */
115
+ .lk-stimulus {
116
+ margin: 0 0 var(--lk-spacing-lg);
117
+ padding: var(--lk-spacing-md) var(--lk-spacing-lg);
118
+ background: var(--lk-color-surface-raised);
119
+ border: 1px solid var(--lk-color-border);
120
+ border-radius: var(--lk-radius-base);
121
+ }
122
+
123
+ .lk-stimulus-title {
124
+ margin: 0 0 var(--lk-spacing-xs);
125
+ font-size: var(--lk-font-size-lg);
126
+ font-weight: var(--lk-font-weight-bold);
127
+ }
128
+
129
+ .lk-stimulus-range {
130
+ margin: 0 0 var(--lk-spacing-md);
131
+ font-size: var(--lk-font-size-sm);
132
+ color: var(--lk-color-text-muted);
133
+ }
134
+
135
+ .lk-stimulus .lk-media {
136
+ margin-bottom: var(--lk-spacing-md);
137
+ }
138
+
139
+ .lk-stimulus-body {
140
+ margin: 0;
141
+ line-height: var(--lk-line-height-base);
142
+ }
143
+
144
+ /* A plain-text passage keeps its authored paragraph breaks. */
145
+ .lk-stimulus-body[data-format="text"] {
146
+ white-space: pre-wrap;
147
+ }
148
+
149
+ .lk-stimulus-body[data-format="html"] > :first-child {
150
+ margin-top: 0;
151
+ }
152
+
153
+ .lk-stimulus-body[data-format="html"] > :last-child {
154
+ margin-bottom: 0;
155
+ }
156
+
157
+ .lk-stimulus-attribution {
158
+ margin: var(--lk-spacing-sm) 0 0;
159
+ font-size: var(--lk-font-size-sm);
160
+ color: var(--lk-color-text-muted);
161
+ }
162
+
114
163
  /* ── Multiple choice options ─────────────────────────────────────────── */
115
164
  .lk-mc-option {
116
165
  display: flex;
@@ -1,4 +1,4 @@
1
- import { ActivityData, ActivityResult, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens, RedactedActivityData } from '@intellectif/lk-core';
1
+ import { ActivityData, ActivityResult, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens, RedactedActivityData, ItemGroup, SequenceEntry } from '@intellectif/lk-core';
2
2
 
3
3
  /**
4
4
  * How an activity is being presented. This is the single switch that decides
@@ -27,6 +27,23 @@ type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {
27
27
  /** Present on a `redact()` projection. */
28
28
  redacted?: true;
29
29
  };
30
+ /**
31
+ * {@link Renderable} DISTRIBUTED over a union of activity types.
32
+ *
33
+ * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on
34
+ * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the
35
+ * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single
36
+ * object type carrying only the fields every activity shares. Narrowing it
37
+ * dies with it — after `if (data.type === 'multiple-choice')` the compiler
38
+ * still refuses `data.options`, because the union it would narrow to no
39
+ * longer exists.
40
+ *
41
+ * The conditional below re-distributes, so `RenderableActivity` is a real
42
+ * union of per-type renderables and `.type` narrows again. Anything that
43
+ * accepts "some renderable activity, I don't know which" — a custom renderer,
44
+ * a sequence entry — must use THIS, not `Renderable<ActivityData>`.
45
+ */
46
+ type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown ? Renderable<TData> : never;
30
47
  /**
31
48
  * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,
32
49
  * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a
@@ -47,7 +64,7 @@ type HtmlSanitizer = (html: string) => string;
47
64
  */
48
65
  interface ActivityProps<TData extends ActivityData = ActivityData> {
49
66
  /** Activity content. Accepts a `redact()` projection in `exam` mode. */
50
- data: Renderable<TData>;
67
+ data: RenderableActivity<TData>;
51
68
  /**
52
69
  * Called when the component scored the attempt itself. Only ever fires in
53
70
  * `practice` mode — in `exam` mode the client does not grade, so there is
@@ -104,5 +121,36 @@ interface ActivityProps<TData extends ActivityData = ActivityData> {
104
121
  * unnecessary.
105
122
  */
106
123
  declare function asRenderable<TData extends ActivityData>(redacted: RedactedActivityData): Renderable<TData>;
124
+ /**
125
+ * The same bridge as {@link asRenderable}, for a whole sequence: activities
126
+ * and item groups as a server hands them over, ready for `<ActivitySequence>`.
127
+ *
128
+ * Needed for the same reason and no other. `redactItemGroup` returns
129
+ * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an
130
+ * index-signature type whose fields are all `unknown` — so its `question` is
131
+ * not a `string` and it satisfies no per-type renderable, however the prop is
132
+ * widened. Widening alone cannot fix this; a crossing point is required, and
133
+ * having exactly one keeps `as unknown as` out of consumer code.
134
+ *
135
+ * ```tsx
136
+ * const entries = await fetchExam(); // redacted, server-side
137
+ * <ActivitySequence
138
+ * activities={asRenderableSequence(entries)}
139
+ * renderMode="exam" // REQUIRED: see below
140
+ * shuffleSeed={attemptId}
141
+ * onSubmit={persist}
142
+ * />
143
+ * ```
144
+ *
145
+ * Pass `renderMode="exam"` (or `"review"`). Redacted data has no answer key,
146
+ * and the default `practice` mode grades locally — the built-in components
147
+ * throw at render rather than fail at submit time, so a mis-wired exam item is
148
+ * loud, not silent.
149
+ */
150
+ declare function asRenderableSequence(entries: readonly (RedactedActivityData | RedactedItemGroupData)[]): readonly SequenceEntry<RenderableActivity>[];
151
+ /** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */
152
+ type RedactedItemGroupData = ItemGroup<RedactedActivityData> & {
153
+ redacted: true;
154
+ };
107
155
 
108
- export { type ActivityProps as A, type HtmlSanitizer as H, type RenderMode as R, type Renderable as a, asRenderable as b };
156
+ export { type ActivityProps as A, type HtmlSanitizer as H, type RenderMode as R, type Renderable as a, type RenderableActivity as b, asRenderable as c, asRenderableSequence as d };
@@ -1,4 +1,4 @@
1
- import { ActivityData, ActivityResult, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens, RedactedActivityData } from '@intellectif/lk-core';
1
+ import { ActivityData, ActivityResult, LearnerResponse, ItemOutcome, InteractionEvent, ThemeTokens, RedactedActivityData, ItemGroup, SequenceEntry } from '@intellectif/lk-core';
2
2
 
3
3
  /**
4
4
  * How an activity is being presented. This is the single switch that decides
@@ -27,6 +27,23 @@ type Renderable<TData> = Omit<TData, 'scoringStrategy'> & {
27
27
  /** Present on a `redact()` projection. */
28
28
  redacted?: true;
29
29
  };
30
+ /**
31
+ * {@link Renderable} DISTRIBUTED over a union of activity types.
32
+ *
33
+ * This distinction is load-bearing, not cosmetic. `Renderable<T>` is built on
34
+ * `Omit`, and `Omit` does not distribute: `Omit<A | B, K>` collapses to the
35
+ * keys A and B have IN COMMON, so `Renderable<ActivityData>` is a single
36
+ * object type carrying only the fields every activity shares. Narrowing it
37
+ * dies with it — after `if (data.type === 'multiple-choice')` the compiler
38
+ * still refuses `data.options`, because the union it would narrow to no
39
+ * longer exists.
40
+ *
41
+ * The conditional below re-distributes, so `RenderableActivity` is a real
42
+ * union of per-type renderables and `.type` narrows again. Anything that
43
+ * accepts "some renderable activity, I don't know which" — a custom renderer,
44
+ * a sequence entry — must use THIS, not `Renderable<ActivityData>`.
45
+ */
46
+ type RenderableActivity<TData extends ActivityData = ActivityData> = TData extends unknown ? Renderable<TData> : never;
30
47
  /**
31
48
  * Sanitiser for author-supplied rich text (`questionHtml`, `passageHtml`,
32
49
  * `promptHtml`). The SDK deliberately ships NO sanitiser — that would add a
@@ -47,7 +64,7 @@ type HtmlSanitizer = (html: string) => string;
47
64
  */
48
65
  interface ActivityProps<TData extends ActivityData = ActivityData> {
49
66
  /** Activity content. Accepts a `redact()` projection in `exam` mode. */
50
- data: Renderable<TData>;
67
+ data: RenderableActivity<TData>;
51
68
  /**
52
69
  * Called when the component scored the attempt itself. Only ever fires in
53
70
  * `practice` mode — in `exam` mode the client does not grade, so there is
@@ -104,5 +121,36 @@ interface ActivityProps<TData extends ActivityData = ActivityData> {
104
121
  * unnecessary.
105
122
  */
106
123
  declare function asRenderable<TData extends ActivityData>(redacted: RedactedActivityData): Renderable<TData>;
124
+ /**
125
+ * The same bridge as {@link asRenderable}, for a whole sequence: activities
126
+ * and item groups as a server hands them over, ready for `<ActivitySequence>`.
127
+ *
128
+ * Needed for the same reason and no other. `redactItemGroup` returns
129
+ * `ItemGroup<RedactedActivityData>`, and `RedactedActivityData` is an
130
+ * index-signature type whose fields are all `unknown` — so its `question` is
131
+ * not a `string` and it satisfies no per-type renderable, however the prop is
132
+ * widened. Widening alone cannot fix this; a crossing point is required, and
133
+ * having exactly one keeps `as unknown as` out of consumer code.
134
+ *
135
+ * ```tsx
136
+ * const entries = await fetchExam(); // redacted, server-side
137
+ * <ActivitySequence
138
+ * activities={asRenderableSequence(entries)}
139
+ * renderMode="exam" // REQUIRED: see below
140
+ * shuffleSeed={attemptId}
141
+ * onSubmit={persist}
142
+ * />
143
+ * ```
144
+ *
145
+ * Pass `renderMode="exam"` (or `"review"`). Redacted data has no answer key,
146
+ * and the default `practice` mode grades locally — the built-in components
147
+ * throw at render rather than fail at submit time, so a mis-wired exam item is
148
+ * loud, not silent.
149
+ */
150
+ declare function asRenderableSequence(entries: readonly (RedactedActivityData | RedactedItemGroupData)[]): readonly SequenceEntry<RenderableActivity>[];
151
+ /** Structural shape of a `redactItemGroup()` projection, as it arrives from a server. */
152
+ type RedactedItemGroupData = ItemGroup<RedactedActivityData> & {
153
+ redacted: true;
154
+ };
107
155
 
108
- export { type ActivityProps as A, type HtmlSanitizer as H, type RenderMode as R, type Renderable as a, asRenderable as b };
156
+ export { type ActivityProps as A, type HtmlSanitizer as H, type RenderMode as R, type Renderable as a, type RenderableActivity as b, asRenderable as c, asRenderableSequence as d };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intellectif/lk-react",
3
- "version": "3.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "React 19 activity components, hooks, and theming for learning-kit",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,6 +52,16 @@
52
52
  "default": "./dist/components/FillInTheBlanks.cjs"
53
53
  }
54
54
  },
55
+ "./components/StimulusPanel": {
56
+ "import": {
57
+ "types": "./dist/components/StimulusPanel.d.ts",
58
+ "default": "./dist/components/StimulusPanel.js"
59
+ },
60
+ "require": {
61
+ "types": "./dist/components/StimulusPanel.d.cts",
62
+ "default": "./dist/components/StimulusPanel.cjs"
63
+ }
64
+ },
55
65
  "./components/WrittenResponse": {
56
66
  "import": {
57
67
  "types": "./dist/components/WrittenResponse.d.ts",
@@ -105,7 +115,7 @@
105
115
  "peerDependencies": {
106
116
  "react": "^19",
107
117
  "react-dom": "^19",
108
- "@intellectif/lk-core": "^0.4.0"
118
+ "@intellectif/lk-core": "^0.6.0"
109
119
  },
110
120
  "devDependencies": {
111
121
  "@axe-core/react": "^4.10.0",
@@ -124,7 +134,7 @@
124
134
  "tsup": "^8.3.0",
125
135
  "vitest": "^4.1.6",
126
136
  "vitest-axe": "^0.1.0",
127
- "@intellectif/lk-core": "0.4.0"
137
+ "@intellectif/lk-core": "0.6.0"
128
138
  },
129
139
  "license": "MIT",
130
140
  "engines": {
@@ -137,6 +147,7 @@
137
147
  "lint": "biome check .",
138
148
  "e2e": "playwright test -c ../../playwright.config.ts",
139
149
  "publint": "publint",
140
- "attw": "attw --pack . --ignore-rules no-resolution --exclude-entrypoints \"theme/defaults.css\" \"theme/skin.css\""
150
+ "attw": "attw --pack . --ignore-rules no-resolution --exclude-entrypoints \"theme/defaults.css\" \"theme/skin.css\"",
151
+ "typecheck": "tsc -p tsconfig.typecheck.json"
141
152
  }
142
153
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/FillInTheBlanks/FillInTheBlanks.tsx","../src/components/FillInTheBlanks/index.tsx"],"names":["result","FillInTheBlanks","jsx"],"mappings":";;;;;;AAoCA,IAAM,WAAA,GAAc,0BAAA;AAIpB,SAAS,aAAa,OAAA,EAA4B;AAChD,EAAA,MAAM,WAAsB,EAAC;AAC7B,EAAA,MAAM,EAAA,GAAK,IAAI,MAAA,CAAO,WAAW,CAAA;AACjC,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,OAAA,GAAU,CAAA;AACd,EAAA,IAAI,KAAA,GAAQ,EAAA,CAAG,IAAA,CAAK,OAAO,CAAA;AAC3B,EAAA,OAAO,UAAU,IAAA,EAAM;AACrB,IAAA,IAAI,KAAA,CAAM,QAAQ,IAAA,EAAM;AACtB,MAAA,QAAA,CAAS,IAAA,CAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,KAAA,EAAO,OAAA,CAAQ,KAAA,CAAM,IAAA,EAAM,KAAA,CAAM,KAAK,CAAA,EAAG,CAAA;AAAA,IACzE;AACA,IAAA,OAAA,IAAW,CAAA;AACX,IAAA,QAAA,CAAS,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,IAAI,KAAA,CAAM,CAAC,CAAA,EAAa,OAAA,EAAS,CAAA;AAChE,IAAA,IAAA,GAAO,KAAA,CAAM,KAAA,GAAQ,KAAA,CAAM,CAAC,CAAA,CAAE,MAAA;AAC9B,IAAA,K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EAAe,KAAA,CAAM,IAAA,EAAM,KAAA,EAChD,QAAA,kBAAAA,GAAAA,CAAC,eAAA,EAAA,EAAqB,GAAG,KAAA,EAAO,CAAA,EAClC,CAAA;AAEJ","file":"chunk-3X7MYAFT.js","sourcesContent":["'use client';\n\nimport {\n ActivitySchemaError,\n assertRedacted,\n type FillInTheBlanksData,\n type FillInTheBlanksLearnerResponse,\n type LearnerResponse,\n type ScoringDetail,\n type ScoringResult,\n score,\n validateActivity,\n xAPIBuilder,\n} from '@intellectif/lk-core';\nimport { type CSSProperties, useEffect, useMemo, useRef, useState } from 'react';\nimport { useActivityState } from '../../hooks/useActivityState.js';\nimport { ANONYMOUS_ACTOR, isDevelopment, objectIdFor } from '../_internal.js';\nimport { ActivityMedia } from '../shared/ActivityMedia.js';\nimport { FeedbackRegion } from '../shared/FeedbackRegion.js';\nimport type { ActivityProps } from '../types.js';\n\nexport interface FillInTheBlanksProps extends ActivityProps<FillInTheBlanksData> {\n /**\n * After submission, replace each incorrectly-answered blank with its first\n * accepted answer, styled distinctly (Req 5.7). Component-specific prop: it\n * is presentation, not activity data, and is outside the fixed Req-3.1 set.\n *\n * Ignored in `exam` mode — revealing the key is precisely what an exam must\n * not do, and on a `redact()` projection there is no key to reveal. In\n * `review` mode it applies only to blanks the supplied `outcome` marks\n * incorrect, and only when the caller passed data that still carries the key\n * (e.g. `redact(data, { reveal: 'after-submit' })`).\n */\n showCorrectAnswers?: boolean;\n}\n\nconst PLACEHOLDER = /\\{\\{\\s*([^{}]+?)\\s*\\}\\}/g;\n\ntype Segment = { kind: 'text'; value: string } | { kind: 'blank'; id: string; ordinal: number };\n\nfunction parsePassage(passage: string): Segment[] {\n const segments: Segment[] = [];\n const re = new RegExp(PLACEHOLDER);\n let last = 0;\n let ordinal = 0;\n let match = re.exec(passage);\n while (match !== null) {\n if (match.index > last) {\n segments.push({ kind: 'text', value: passage.slice(last, match.index) });\n }\n ordinal += 1;\n segments.push({ kind: 'blank', id: match[1] as string, ordinal });\n last = match.index + match[0].length;\n match = re.exec(passage);\n }\n if (last < passage.length) {\n segments.push({ kind: 'text', value: passage.slice(last) });\n }\n return segments;\n}\n\n/** Shared empty map: keeps the \"no response supplied\" path allocation-free. */\nconst NO_ANSWERS: Record<string, string> = {};\n\n/**\n * Reads the answer map out of a `LearnerResponse`. A response of another\n * activity type is treated as \"no answers\" rather than throwing: a controlled\n * host that has not yet swapped its state on an activity change would\n * otherwise crash the attempt.\n */\nfunction answersOf(response: LearnerResponse | undefined): Record<string, string> {\n return response !== undefined && response.type === 'fill-in-the-blanks'\n ? response.answers\n : NO_ANSWERS;\n}\n\n/**\n * Per-item correctness keyed by blank id. Prefers the unambiguous `outcome`\n * field (always written by the built-in scorers since lk-core 0.3.0) and\n * falls back to the deprecated `correct` boolean so a 0.2-era\n * consumer-constructed `ItemOutcome` still marks correctly in `review`.\n */\nfunction correctnessByItem(details: readonly ScoringDetail[]): Map<string, boolean> {\n const map = new Map<string, boolean>();\n for (const detail of details) {\n map.set(\n detail.itemId,\n detail.outcome !== undefined ? detail.outcome === 'correct' : detail.correct,\n );\n }\n return map;\n}\n\nexport function FillInTheBlanks({\n data,\n onComplete,\n onSubmit,\n onChange,\n onInteraction,\n value,\n defaultValue,\n renderMode = 'practice',\n outcome,\n sanitizeHtml,\n theme,\n locale,\n disabled,\n showCorrectAnswers,\n}: FillInTheBlanksProps) {\n const isExam = renderMode === 'exam';\n const isReview = renderMode === 'review';\n\n // Dev-only boundary validation (Req 2.3); throws in render so the wrapping\n // ActivityErrorBoundary catches it. Re-runs only when data changes.\n const devError = useMemo(() => {\n if (!isDevelopment()) {\n return null;\n }\n if (data.redacted === true) {\n // A redact() projection cannot satisfy the full content schema — the\n // answer key is gone by design. Validate it against the STRICT redacted\n // schema instead, which additionally proves the payload is learner-safe.\n try {\n assertRedacted(data);\n return null;\n } catch (error) {\n return error instanceof Error ? error : new Error(String(error));\n }\n }\n const result = validateActivity('fill-in-the-blanks', data);\n return result.success ? null : new ActivitySchemaError('fill-in-the-blanks', result.errors);\n }, [data]);\n\n const { state, start, complete, getTimeSpent, reset } = useActivityState();\n // Controlled when `value` is supplied: the answers rendered are ALWAYS the\n // caller's, and internal state is never read. Uncontrolled otherwise,\n // seeded from `defaultValue`.\n const isControlled = value !== undefined;\n const [internalAnswers, setInternalAnswers] = useState<Record<string, string>>(() =>\n answersOf(defaultValue),\n );\n const [revealed, setRevealed] = useState<Set<string>>(() => new Set());\n const [result, setResult] = useState<ScoringResult | null>(null);\n const [summary, setSummary] = useState<string | null>(null);\n const [feedbackHidden, setFeedbackHidden] = useState(false);\n\n const answers = isControlled ? answersOf(value) : internalAnswers;\n\n // `defaultValue` is read only by the reset effect, and it is commonly an\n // inline object literal — putting it in that effect's deps would re-seed\n // (and wipe) the learner's typing on every render. Mirror it into a ref in\n // its own effect, which commits before the reset effect below.\n const defaultValueRef = useRef(defaultValue);\n useEffect(() => {\n defaultValueRef.current = defaultValue;\n }, [defaultValue]);\n\n // `data` is an intentional reset trigger (Req 3.7), not read in the body.\n // biome-ignore lint/correctness/useExhaustiveDependencies: data is the reset trigger (Req 3.7)\n useEffect(() => {\n setInternalAnswers(answersOf(defaultValueRef.current));\n setRevealed(new Set());\n setResult(null);\n setSummary(null);\n setFeedbackHidden(false);\n reset();\n }, [data, reset]);\n\n /*\n * RICH TEXT — deliberate, documented limitation (see `sanitizeHtml`).\n *\n * Every other activity can render its `*Html` field through the caller's\n * sanitiser, because the rich text is a LEAF: the sanitised string is\n * handed to one `dangerouslySetInnerHTML` node and nothing is inserted into\n * it. A fill-in-the-blanks passage is not a leaf — it is the CONTAINER of\n * the React-controlled `<input>`s, one per `{{id}}` placeholder.\n *\n * Placing those inputs inside sanitised HTML means slicing the sanitised\n * string at the placeholders and injecting each slice as its own HTML\n * fragment, which is unsafe and broken on both counts:\n * 1. Broken: the slices are unbalanced. `<p>A {{x}} B</p>` yields `<p>A `\n * and ` B</p>`; the fragment parser auto-closes both, so the input\n * lands OUTSIDE the paragraph and the authored block structure is\n * destroyed.\n * 2. Unsafe: the sanitiser's guarantee covers the document it returned,\n * not arbitrary substrings of it. A placeholder inside an attribute\n * (`<img alt=\"{{x}}\">`) splits mid-attribute, and re-parsing the\n * halves in a fresh context is exactly the mutation (mXSS) class of\n * transformation that voids a sanitiser's output guarantee. An exam\n * runner must never depend on that.\n *\n * The safe alternative — parse the sanitised string once into a detached\n * DOM, split only TEXT nodes at placeholders, and portal the inputs into\n * anchors — needs a DOM at render time (no SSR) and a large imperative\n * subsystem. Until that lands, the plain-text `passage` is rendered (always\n * escaped by React), which is correct, answerable, and safe in every mode.\n * `data.passageHtml` is carried and redacted by lk-core regardless, so no\n * authored content is lost — only this component declines to render it.\n */\n useEffect(() => {\n if (isDevelopment() && sanitizeHtml !== undefined && data.passageHtml !== undefined) {\n console.warn(\n '[lk-react] FillInTheBlanks ignores `passageHtml`: the passage hosts the answer inputs, ' +\n 'so rich HTML cannot be split at {{placeholders}} without voiding the sanitiser. ' +\n 'Rendering the plain `passage` instead.',\n );\n }\n }, [sanitizeHtml, data.passageHtml]);\n\n const segments = useMemo(() => parsePassage(data.passage), [data.passage]);\n const blankById = useMemo(() => new Map(data.blanks.map((b) => [b.id, b])), [data.blanks]);\n\n if (devError) {\n throw devError;\n }\n\n const submitted = state === 'completed';\n const inactive = disabled === true || submitted || isReview;\n\n /**\n * Whether the component may show answer-key-derived information (per-blank\n * correctness, authored feedback, correct answers). NEVER in `exam`; in\n * `practice` only after the component scored locally; in `review` only once\n * the caller supplies a SCORED outcome — an item that is still awaiting a\n * grade must not have its key revealed just because it is being read back.\n */\n const revealing = isReview ? outcome?.status === 'scored' : !isExam && submitted;\n\n const fireInteraction = (\n type: 'blank-filled' | 'hint-requested' | 'submitted',\n payload: Record<string, unknown>,\n ): void => {\n onInteraction?.({ type, activityId: data.id, timestamp: Date.now(), payload });\n };\n\n const handleChange = (blankId: string, text: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n const next = { ...answers, [blankId]: text };\n if (!isControlled) {\n setInternalAnswers(next);\n }\n onChange?.({ type: 'fill-in-the-blanks', answers: next });\n fireInteraction('blank-filled', { blankId, value: text });\n };\n\n const toggleHint = (blankId: string): void => {\n if (inactive) {\n return;\n }\n if (state === 'idle') {\n start();\n }\n setRevealed((prev) => {\n const next = new Set(prev);\n if (next.has(blankId)) {\n next.delete(blankId);\n return next;\n }\n next.add(blankId);\n return next;\n });\n // Only a reveal is a \"hint requested\"; hiding is not a new request.\n if (!revealed.has(blankId)) {\n fireInteraction('hint-requested', { blankId });\n }\n };\n\n const handleSubmit = (event: React.FormEvent): void => {\n event.preventDefault();\n if (inactive) {\n return;\n }\n const response: FillInTheBlanksLearnerResponse = { type: 'fill-in-the-blanks', answers };\n // Fires in every submitting mode and always BEFORE onComplete, so an exam\n // runner can persist the raw response regardless of local grading.\n onSubmit?.(response);\n\n if (isExam) {\n // EXAM: the client neither grades nor reveals. No score()/evaluate(), no\n // read of any answer-key field, no onComplete — and no xAPI statement,\n // because its `correctResponsesPattern` IS the answer key. The server\n // owns the grade; it emits the statement.\n complete();\n setSummary('Answer submitted.');\n fireInteraction('submitted', { answers });\n return;\n }\n\n // PRACTICE: unchanged v1 behaviour. `data` carries the key here — exam\n // mode is the only path that may be handed a redact() projection.\n const scoringResult = score('fill-in-the-blanks', data as FillInTheBlanksData, response);\n complete();\n const timeSpent = getTimeSpent();\n const xapiStatement = xAPIBuilder.buildAnsweredStatement({\n actor: ANONYMOUS_ACTOR,\n object: {\n id: objectIdFor(data.id),\n name: { [data.locale ?? 'en-US']: data.title },\n type: 'http://adlnet.gov/expapi/activities/cmi.interaction',\n interactionType: 'fill-in',\n correctResponsesPattern: [\n data.blanks.map((blank) => blank.acceptedAnswers[0] ?? '').join('[,]'),\n ],\n },\n scoringResult,\n timeSpentMs: timeSpent,\n response: JSON.stringify(answers),\n });\n setResult(scoringResult);\n onComplete?.({\n score: scoringResult.score,\n maxScore: scoringResult.maxScore,\n passed: scoringResult.passed,\n timeSpent,\n xapiStatement,\n });\n // Core selects the authored overall feedback on `passed` (B3 fix).\n const overall = scoringResult.feedback;\n setSummary(\n `Answer submitted. Score ${Math.round(scoringResult.score * 100)}%. ${\n scoringResult.passed ? 'Passed.' : 'Not passed.'\n }${overall ? ` ${overall}` : ''}`,\n );\n fireInteraction('submitted', { answers, score: scoringResult.score });\n };\n\n const correctByBlank = useMemo(() => {\n if (isExam) {\n // Nothing is ever marked client-side in an exam.\n return new Map<string, boolean>();\n }\n if (isReview) {\n // Correctness comes ONLY from the server-computed outcome; the component\n // never scores in review, so an absent/ungraded outcome marks nothing.\n return outcome?.status === 'scored'\n ? correctnessByItem(outcome.details)\n : new Map<string, boolean>();\n }\n return correctnessByItem(result?.details ?? []);\n }, [isExam, isReview, outcome, result]);\n\n /** Review has no local score: its summary is read off `outcome`, or nothing. */\n const reviewSummary = useMemo(() => {\n if (!isReview || outcome === undefined) {\n return null;\n }\n if (outcome.status === 'scored') {\n return `Score ${Math.round(outcome.score * 100)}%. ${\n outcome.passed ? 'Passed.' : 'Not passed.'\n }${outcome.feedback ? ` ${outcome.feedback}` : ''}`;\n }\n return outcome.status === 'deferred' ? 'Not graded yet.' : 'No grade available.';\n }, [isReview, outcome]);\n\n return (\n <form\n className=\"lk-fib\"\n aria-label={data.title}\n lang={locale}\n data-render-mode={renderMode}\n style={theme as CSSProperties | undefined}\n onSubmit={handleSubmit}\n >\n {data.media ? <ActivityMedia media={data.media} /> : null}\n <fieldset disabled={inactive}>\n <p className=\"lk-fib-passage\">\n {segments.map((seg, i) => {\n if (seg.kind === 'text') {\n // biome-ignore lint/suspicious/noArrayIndexKey: passage segments are positional and static\n return <span key={`t${i}`}>{seg.value}</span>;\n }\n const blank = blankById.get(seg.id);\n if (!blank) {\n return null;\n }\n // `Renderable` only widens `scoringStrategy` at the type level, so\n // the answer-key fields still LOOK required here while a redact()\n // projection omits them at runtime. Read them defensively, and\n // never at all in exam mode.\n const acceptedAnswers: string[] | undefined = isExam\n ? undefined\n : blank.acceptedAnswers;\n const blankFeedback = isExam ? undefined : blank.feedback;\n const correctness = correctByBlank.get(seg.id);\n const hintId = `${data.id}-hint-${seg.id}`;\n const correctAnswer = acceptedAnswers?.[0];\n if (revealing && showCorrectAnswers && correctness === false && correctAnswer) {\n return (\n <span key={seg.id} className=\"lk-fib-answer\" data-correct=\"false\">\n {correctAnswer}\n </span>\n );\n }\n return (\n <span key={seg.id} className=\"lk-fib-blank\">\n <input\n type=\"text\"\n aria-label={`Fill in blank ${seg.ordinal}`}\n aria-describedby={blank.hint ? hintId : undefined}\n value={answers[seg.id] ?? ''}\n disabled={inactive}\n aria-disabled={inactive || undefined}\n data-correct={\n revealing && correctness !== undefined ? String(correctness) : undefined\n }\n onChange={(e) => handleChange(seg.id, e.target.value)}\n />\n {/*\n Hints stay available in exam mode by design: lk-core's field\n policy classifies `blanks.hint` as `public`, so it survives\n redact() and is not part of the answer key.\n */}\n {blank.hint ? (\n <>\n {/*\n Default affordance is an icon; the accessible NAME stays\n text via aria-label (screen readers + tests rely on it).\n The glyph is restylable/replaceable via .lk-fib-hint-btn.\n */}\n <button\n type=\"button\"\n className=\"lk-fib-hint-btn\"\n aria-controls={hintId}\n aria-expanded={revealed.has(seg.id)}\n aria-label={revealed.has(seg.id) ? 'Hide hint' : 'Show hint'}\n disabled={inactive}\n onClick={() => toggleHint(seg.id)}\n >\n <svg\n className=\"lk-fib-hint-icon\"\n viewBox=\"0 0 24 24\"\n width=\"16\"\n height=\"16\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n <path\n fill=\"currentColor\"\n d=\"M9 21h6v-1H9v1Zm3-19a7 7 0 0 0-4 12.74V17h8v-2.26A7 7 0 0 0 12 2Z\"\n />\n </svg>\n </button>\n {/*\n Not role=\"tooltip\": a real ARIA tooltip is a named\n hover/focus popup with strict WCAG 1.4.13 constraints.\n This is an accessible click-to-toggle disclosure that is\n the input's aria-describedby target and is announced via\n aria-live; the skin gives it a tooltip-like *visual*\n without the tooltip *semantics*. (Refines Task 15.3.)\n */}\n <span id={hintId} aria-live=\"polite\">\n {revealed.has(seg.id) ? blank.hint : ''}\n </span>\n </>\n ) : null}\n {revealing && !feedbackHidden && blankFeedback ? (\n <span\n className=\"lk-fib-blank-feedback\"\n role=\"note\"\n data-correct={correctness !== undefined ? String(correctness) : undefined}\n >\n {blankFeedback}\n </span>\n ) : null}\n </span>\n );\n })}\n </p>\n {/* Review is read-only: there is nothing to submit. */}\n {isReview ? null : (\n <button type=\"submit\" disabled={inactive}>\n {isExam ? 'Submit answers' : 'Check answers'}\n </button>\n )}\n </fieldset>\n {revealing && data.blanks.some((b) => b.feedback) ? (\n <button\n type=\"button\"\n className=\"lk-fib-feedback-toggle\"\n aria-expanded={!feedbackHidden}\n onClick={() => setFeedbackHidden((h) => !h)}\n >\n {feedbackHidden ? 'Show feedback' : 'Hide feedback'}\n </button>\n ) : null}\n <FeedbackRegion id={`${data.id}-feedback`}>\n {isReview ? reviewSummary : summary}\n </FeedbackRegion>\n </form>\n );\n}\n","'use client';\n\nimport { ActivityErrorBoundary } from '../ActivityErrorBoundary.js';\nimport {\n FillInTheBlanks as FillInTheBlanksCore,\n type FillInTheBlanksProps,\n} from './FillInTheBlanks.js';\n\nexport type { FillInTheBlanksProps } from './FillInTheBlanks.js';\n\n/**\n * Public Fill-in-the-Blanks activity: the core wrapped in\n * `ActivityErrorBoundary` so a render failure (incl. the dev schema-validation\n * throw) degrades to an accessible fallback instead of crashing the host.\n */\nexport function FillInTheBlanks(props: FillInTheBlanksProps) {\n return (\n <ActivityErrorBoundary activityTitle={props.data?.title}>\n <FillInTheBlanksCore {...props} />\n </ActivityErrorBoundary>\n );\n}\n"]}