@citolab/qti-components 10.0.0-next.16 → 10.0.0-next.18

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 (67) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +233 -459
  3. package/dist/base.d.ts +12 -10
  4. package/dist/base.js +1 -0
  5. package/dist/chunk-DJ7PB252.js +7 -0
  6. package/dist/chunk-DJ7PB252.js.map +1 -0
  7. package/dist/{chunk-7MYZHZWV.js → chunk-DUKQ53E7.js} +46 -3
  8. package/dist/chunk-DUKQ53E7.js.map +1 -0
  9. package/dist/chunk-J6VX4N7M.js +197 -0
  10. package/dist/chunk-J6VX4N7M.js.map +1 -0
  11. package/dist/{chunk-J3F3JSCW.js → chunk-N453PANH.js} +2 -2
  12. package/dist/chunk-PZ5AY32C.js +10 -0
  13. package/dist/chunk-PZ5AY32C.js.map +1 -0
  14. package/dist/{chunk-NWSDBYK7.js → chunk-QLGUI5VG.js} +2 -2
  15. package/dist/{chunk-H3Z3TMFB.js → chunk-SUPLA6QQ.js} +9 -19
  16. package/dist/chunk-SUPLA6QQ.js.map +1 -0
  17. package/dist/chunk-UCXLDQYA.js +56 -0
  18. package/dist/chunk-UCXLDQYA.js.map +1 -0
  19. package/dist/{chunk-LQ65RILE.js → chunk-UURHLJVM.js} +66 -1803
  20. package/dist/chunk-UURHLJVM.js.map +1 -0
  21. package/dist/{chunk-4DC5Z2LQ.js → chunk-V5GL7PTC.js} +2 -2
  22. package/dist/{chunk-M4TZIB3W.js → chunk-WGUQCB2Z.js} +4 -54
  23. package/dist/chunk-WGUQCB2Z.js.map +1 -0
  24. package/dist/{computed.types.d-n3K2VvB0.d.ts → computed.types.d-D4wskgi0.d.ts} +1 -1
  25. package/dist/corrections.d.ts +13 -14
  26. package/dist/corrections.js +7 -7
  27. package/dist/corrections.js.map +1 -1
  28. package/dist/elements.d.ts +5 -105
  29. package/dist/elements.js +7 -4
  30. package/dist/index.d.ts +17 -13
  31. package/dist/index.js +17 -57
  32. package/dist/interactions.d.ts +5 -4
  33. package/dist/interactions.js +3 -2
  34. package/dist/item.d.ts +6 -4
  35. package/dist/item.js +1 -0
  36. package/dist/item.types.d-Zc6ZQDhu.d.ts +25 -0
  37. package/dist/loader.d.ts +4 -2
  38. package/dist/loader.js +1 -0
  39. package/dist/processing.d.ts +4 -3
  40. package/dist/processing.js +1 -0
  41. package/dist/public-events.d-3dGip9pd.d.ts +105 -0
  42. package/dist/qti-components-jsx.d.ts +2686 -4046
  43. package/dist/{qti-condition-expression.d-B-T1NNl0.d.ts → qti-condition-expression.d-7Kd4LBxn.d.ts} +1 -1
  44. package/dist/{qti-expression.d-B-Cfbqlb.d.ts → qti-expression.d-iH3w6mqf.d.ts} +2 -1
  45. package/dist/{qti-feedback.d-1JL_qHjc.d.ts → qti-feedback.d-CT0W-8Gm.d.ts} +1 -1
  46. package/dist/{qti-item.d-DDMDjWIk.d.ts → qti-item.d-CLChmRvB.d.ts} +2 -1
  47. package/dist/qti-test-state-BAf5AmJ2.d.ts +68 -0
  48. package/dist/qti-test-state.d-D8Q89RzZ.d.ts +57 -0
  49. package/dist/{qti-test.d-CDdyCp6e.d.ts → qti-test.d-COzv7YZG.d.ts} +9 -546
  50. package/dist/{qti-text-entry-interaction.d-BTAKmr4b.d.ts → qti-text-entry-interaction.d-DsUyecBC.d.ts} +3 -2
  51. package/dist/{record.d-Bojj6_LW.d.ts → record.d-BfZhFr0L.d.ts} +1 -1
  52. package/dist/{session.context.d-BNxGeyh9.d.ts → session.context.d-9gRdGK4T.d.ts} +1 -1
  53. package/dist/test-plugin-api.d.ts +134 -0
  54. package/dist/test-plugin-api.js +19 -0
  55. package/dist/test-plugin-api.js.map +1 -0
  56. package/dist/test.d.ts +16 -158
  57. package/dist/test.js +11 -50
  58. package/dist/transformers.js +1 -0
  59. package/dist/{item.types.d-DuVR0ZVK.d.ts → variables.d-DWHlTszN.d.ts} +1 -23
  60. package/package.json +7 -3
  61. package/dist/chunk-7MYZHZWV.js.map +0 -1
  62. package/dist/chunk-H3Z3TMFB.js.map +0 -1
  63. package/dist/chunk-LQ65RILE.js.map +0 -1
  64. package/dist/chunk-M4TZIB3W.js.map +0 -1
  65. /package/dist/{chunk-J3F3JSCW.js.map → chunk-N453PANH.js.map} +0 -0
  66. /package/dist/{chunk-NWSDBYK7.js.map → chunk-QLGUI5VG.js.map} +0 -0
  67. /package/dist/{chunk-4DC5Z2LQ.js.map → chunk-V5GL7PTC.js.map} +0 -0
package/dist/base.d.ts CHANGED
@@ -1,17 +1,19 @@
1
- import { C as ComputedItemContext } from './session.context.d-BNxGeyh9.js';
2
- export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-BNxGeyh9.js';
3
- import { C as ComputedContext } from './computed.types.d-n3K2VvB0.js';
4
- export { a as ComputedItem } from './computed.types.d-n3K2VvB0.js';
1
+ import { C as ComputedItemContext } from './session.context.d-9gRdGK4T.js';
2
+ export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-9gRdGK4T.js';
3
+ import { C as ComputedContext } from './computed.types.d-D4wskgi0.js';
4
+ export { a as ComputedItem } from './computed.types.d-D4wskgi0.js';
5
5
  export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-CCqlJXpE.js';
6
- export { C as ChoiceRole, I as Interaction, a as InteractionContext, R as RecordFieldValues, b as RecordValue, V as ValidityKind, c as ValidityTrigger, i as inferRecordFieldBaseType, d as interactionContext, e as isRecordValue, r as readRecordFieldValues } from './record.d-Bojj6_LW.js';
7
- import { b as ItemContext, B as BaseType } from './item.types.d-DuVR0ZVK.js';
8
- export { C as Calculate, a as Cardinality, I as InterpolationTableEntry, M as Multiple, O as Ordered, c as OutcomeVariable, Q as QtiAreaMapEntry, d as QtiAreaMapping, e as QtiMapEntry, f as QtiMapping, R as ResponseInteraction, g as ResponseVariable, T as TemplateVariable, V as VariableDeclaration, h as VariableValue, i as areaShape, j as directedPair, k as float, l as integer, m as itemContextVariables } from './item.types.d-DuVR0ZVK.js';
6
+ export { C as ChoiceRole, I as Interaction, a as InteractionContext, R as RecordFieldValues, b as RecordValue, V as ValidityKind, c as ValidityTrigger, i as inferRecordFieldBaseType, d as interactionContext, e as isRecordValue, r as readRecordFieldValues } from './record.d-BfZhFr0L.js';
7
+ import { I as ItemContext } from './item.types.d-Zc6ZQDhu.js';
8
+ export { i as itemContextVariables } from './item.types.d-Zc6ZQDhu.js';
9
9
  export { Q as QtiContext, a as QtiContextType, S as Seed, b as asSeed, i as isSeed, q as qtiContext } from './qti.context.d-CejJMlfZ.js';
10
- export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-B-Cfbqlb.js';
10
+ export { I as INITIAL_TEST_CONTEXT, Q as QtiExpression, a as QtiExpressionBase, T as TestContext, t as testContext } from './qti-expression.d-iH3w6mqf.js';
11
11
  import * as lit from 'lit';
12
- export { Q as QtiFeedback, a as QtiVariableDeclaration } from './qti-feedback.d-1JL_qHjc.js';
13
- export { Q as QtiConditionExpression } from './qti-condition-expression.d-B-T1NNl0.js';
12
+ export { Q as QtiFeedback, a as QtiVariableDeclaration } from './qti-feedback.d-CT0W-8Gm.js';
13
+ export { Q as QtiConditionExpression } from './qti-condition-expression.d-7Kd4LBxn.js';
14
14
  export { D as DirectedPair, I as Identifier, P as Point, R as ResponseValue, i as iterResponseValues, p as parsePair, a as parsePoint, b as parseResponseAttribute, r as responseAttributeConverter, s as serializePair, c as serializePoint, d as serializeResponseAttribute } from './response.d-_8y4kjGP.js';
15
+ import { B as BaseType } from './variables.d-DWHlTszN.js';
16
+ export { C as Calculate, a as Cardinality, I as InterpolationTableEntry, M as Multiple, O as Ordered, b as OutcomeVariable, Q as QtiAreaMapEntry, c as QtiAreaMapping, d as QtiMapEntry, e as QtiMapping, R as ResponseInteraction, f as ResponseVariable, T as TemplateVariable, V as VariableDeclaration, g as VariableValue, h as areaShape, i as directedPair, j as float, k as integer } from './variables.d-DWHlTszN.js';
15
17
  export { F as FormAssociatedInteraction, I as IInteraction, R as ReadonlyInteraction, a as RegisteredInteraction, b as ResettableInteraction, c as ResponseIdentifiedInteraction, d as ResponseInteractionElement, V as ValidatableInteraction } from './interaction.interface.d-CvjHM2bi.js';
16
18
  export { Q as QtiExitResponseSignal, a as QtiExitTestSignal, b as QtiRuleBase, c as QtiRuleElement } from './qti-rule-base.d-CeKP0Ooi.js';
17
19
 
package/dist/base.js CHANGED
@@ -49,6 +49,7 @@ import {
49
49
  unregisterCustomOperator,
50
50
  validationMessage
51
51
  } from "./chunk-NZ7ZC4SP.js";
52
+ import "./chunk-PZ5AY32C.js";
52
53
  export {
53
54
  CustomStateSetShim,
54
55
  INITIAL_SESSION_CONTEXT,
@@ -0,0 +1,7 @@
1
+ // ../qti-test/dist/plugin-state.js
2
+ var pluginState = (context, plugin) => context?.plugins?.[plugin];
3
+
4
+ export {
5
+ pluginState
6
+ };
7
+ //# sourceMappingURL=chunk-DJ7PB252.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-test/src/plugin-state.ts"],"sourcesContent":["import type { ComputedContext } from '@qti-components/base';\nimport type { QtiTestPluginState } from './types/qti-test-state';\n\n/**\n * A plugin's entry in the state, typed through `QtiTestPluginState`, or `undefined` before the\n * plugin has stored anything. Read it from `computedContext`; write it by dispatching\n * `qc-test-update-plugin-state` (`dispatchPublic`).\n */\nexport const pluginState = <K extends keyof QtiTestPluginState & string>(\n context: Pick<ComputedContext, 'plugins'> | undefined,\n plugin: K\n): QtiTestPluginState[K] | undefined => context?.plugins?.[plugin] as QtiTestPluginState[K] | undefined;\n"],"mappings":";AAQO,IAAM,cAAc,CACzB,SACA,WACsC,SAAS,UAAU,MAAM;","names":[]}
@@ -8997,11 +8997,44 @@ var qti_portable_custom_interaction_styles_default = [
8997
8997
  `
8998
8998
  ];
8999
8999
 
9000
+ // ../interactions/portable-custom-interaction/dist/file-response.js
9001
+ var isFileBaseType = (baseType) => baseType === "file";
9002
+ var isQtiFileData = (value) => typeof value === "object" && value !== null && typeof value.data === "string";
9003
+ var fileToDataUrl = (file) => {
9004
+ if (file === null || file === void 0 || file === "")
9005
+ return null;
9006
+ if (typeof file === "string")
9007
+ return file;
9008
+ if (!isQtiFileData(file) || file.data === "")
9009
+ return null;
9010
+ if (file.data.startsWith("data:"))
9011
+ return file.data;
9012
+ return `data:${file.mime || "application/octet-stream"};base64,${file.data}`;
9013
+ };
9014
+ var dataUrlToFile = (value) => {
9015
+ if (value === null || value === void 0 || value === "")
9016
+ return null;
9017
+ if (typeof value === "object")
9018
+ return isQtiFileData(value) ? value : null;
9019
+ const text = String(value);
9020
+ const match = /^data:([^;,]*)((?:;[^;,]*)*),([\s\S]*)$/.exec(text);
9021
+ if (!match)
9022
+ return { data: text, mime: "application/octet-stream" };
9023
+ const [, mime, params, payload] = match;
9024
+ if (params.split(";").includes("base64"))
9025
+ return { data: payload, mime: mime || "text/plain" };
9026
+ let binary = "";
9027
+ new TextEncoder().encode(decodeURIComponent(payload)).forEach((byte) => binary += String.fromCharCode(byte));
9028
+ return { data: btoa(binary), mime: mime || "text/plain" };
9029
+ };
9030
+
9000
9031
  // ../interactions/portable-custom-interaction/dist/record-response.js
9001
9032
  var PAIR_BASE_TYPES = /* @__PURE__ */ new Set(["point", "pair", "directedPair"]);
9002
9033
  var coerceBaseValue = (value, baseType) => {
9003
9034
  if (value === null || value === void 0)
9004
9035
  return value;
9036
+ if (isFileBaseType(baseType))
9037
+ return dataUrlToFile(value);
9005
9038
  switch (baseType) {
9006
9039
  case "integer": {
9007
9040
  if (typeof value === "number")
@@ -9111,6 +9144,8 @@ var toQtiLiteral = (value) => {
9111
9144
  return null;
9112
9145
  if (Array.isArray(value))
9113
9146
  return value.map(String).join(" ");
9147
+ if (isQtiFileData(value))
9148
+ return fileToDataUrl(value);
9114
9149
  if (typeof value === "object") {
9115
9150
  try {
9116
9151
  return JSON.stringify(value);
@@ -9412,6 +9447,14 @@ var QtiPortableCustomInteraction = class extends Interaction {
9412
9447
  for (const nestedKey in nestedObject) {
9413
9448
  if (nestedObject.hasOwnProperty(nestedKey)) {
9414
9449
  const value = nestedObject[nestedKey];
9450
+ if (nestedKey === "file") {
9451
+ if (Array.isArray(value))
9452
+ return value.map(fileToDataUrl).filter((v) => v !== null);
9453
+ const dataUrl = fileToDataUrl(value);
9454
+ if (dataUrl !== null)
9455
+ return dataUrl;
9456
+ continue;
9457
+ }
9415
9458
  if (Array.isArray(value)) {
9416
9459
  return value.map(String);
9417
9460
  } else if (value !== void 0 && value !== null) {
@@ -9586,11 +9629,11 @@ var QtiPortableCustomInteraction = class extends Interaction {
9586
9629
  }
9587
9630
  if (cardinality !== "single") {
9588
9631
  const list = { list: {} };
9589
- list.list[baseType] = input;
9632
+ list.list[baseType] = isFileBaseType(baseType) ? this.normalizeListValue(input).map(dataUrlToFile).filter(Boolean) : input;
9590
9633
  return list;
9591
9634
  } else {
9592
9635
  const base = { base: {} };
9593
- base.base[baseType] = input;
9636
+ base.base[baseType] = isFileBaseType(baseType) ? dataUrlToFile(input) : input;
9594
9637
  return base;
9595
9638
  }
9596
9639
  }
@@ -12766,4 +12809,4 @@ export {
12766
12809
  elements31 as elements21,
12767
12810
  qtiInteractionElements
12768
12811
  };
12769
- //# sourceMappingURL=chunk-7MYZHZWV.js.map
12812
+ //# sourceMappingURL=chunk-DUKQ53E7.js.map