@citolab/qti-components 8.0.1 → 8.0.2

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 (60) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +103 -103
  3. package/dist/base.d.ts +3 -3
  4. package/dist/base.js +1 -1
  5. package/dist/chunk-4DB4SC5K.js +100 -0
  6. package/dist/chunk-4DB4SC5K.js.map +1 -0
  7. package/dist/{chunk-WVVMNF74.js → chunk-7AVWRQIS.js} +188 -160
  8. package/dist/{chunk-WVVMNF74.js.map → chunk-7AVWRQIS.js.map} +1 -1
  9. package/dist/{chunk-CAO4JRLY.js → chunk-BQFWCZFH.js} +2 -2
  10. package/dist/{chunk-LVBIQDPM.js → chunk-CK7AV2UJ.js} +147 -101
  11. package/dist/chunk-CK7AV2UJ.js.map +1 -0
  12. package/dist/{chunk-7HC5SMCU.js → chunk-G6GFQDVN.js} +1 -96
  13. package/dist/chunk-G6GFQDVN.js.map +1 -0
  14. package/dist/{chunk-RXGDQDOV.js → chunk-HBSWJC3B.js} +478 -392
  15. package/dist/chunk-HBSWJC3B.js.map +1 -0
  16. package/dist/chunk-HQESINXH.js +834 -0
  17. package/dist/chunk-HQESINXH.js.map +1 -0
  18. package/dist/{chunk-XU7HNT4F.js → chunk-J5SQLKNP.js} +145 -119
  19. package/dist/{chunk-XU7HNT4F.js.map → chunk-J5SQLKNP.js.map} +1 -1
  20. package/dist/{chunk-V5G7X53Y.js → chunk-NJQHUUTN.js} +2 -2
  21. package/dist/{chunk-QECOPVPO.js → chunk-RSVRS5AK.js} +59 -58
  22. package/dist/chunk-RSVRS5AK.js.map +1 -0
  23. package/dist/{chunk-F4BNJWYN.js → chunk-TWPXES3S.js} +642 -673
  24. package/dist/chunk-TWPXES3S.js.map +1 -0
  25. package/dist/{chunk-NA2N2WSG.js → chunk-VAE6HBKR.js} +176 -152
  26. package/dist/{chunk-NA2N2WSG.js.map → chunk-VAE6HBKR.js.map} +1 -1
  27. package/dist/{chunk-3AJOQCDU.js → chunk-ZII6M3SN.js} +2 -2
  28. package/dist/{computed.types.d-rKLSPvVG.d.ts → computed.types.d-DpKIYO6e.d.ts} +2 -0
  29. package/dist/corrections.d.ts +12 -29
  30. package/dist/corrections.js +8 -9
  31. package/dist/elements.d.ts +86 -86
  32. package/dist/elements.js +4 -5
  33. package/dist/index.d.ts +6 -37
  34. package/dist/index.js +13 -14
  35. package/dist/{interaction.d-D4MstYRz.d.ts → interaction.d-CJiMv8H7.d.ts} +13 -2
  36. package/dist/interactions.d.ts +11 -1299
  37. package/dist/interactions.js +4 -5
  38. package/dist/item.d.ts +3 -3
  39. package/dist/item.js +5 -5
  40. package/dist/processing.js +2 -2
  41. package/dist/qti-components-jsx.d.ts +759 -739
  42. package/dist/qti-test.d-_YAlhDbt.d.ts +702 -0
  43. package/dist/qti-text-entry-interaction.d-BGdfV9qG.d.ts +1567 -0
  44. package/dist/test.d.ts +11 -678
  45. package/dist/test.js +6 -7
  46. package/package.json +8 -7
  47. package/dist/chunk-64XSIBGO.js +0 -241
  48. package/dist/chunk-64XSIBGO.js.map +0 -1
  49. package/dist/chunk-7HC5SMCU.js.map +0 -1
  50. package/dist/chunk-F4BNJWYN.js.map +0 -1
  51. package/dist/chunk-H3J7LFRO.js +0 -2243
  52. package/dist/chunk-H3J7LFRO.js.map +0 -1
  53. package/dist/chunk-LVBIQDPM.js.map +0 -1
  54. package/dist/chunk-QECOPVPO.js.map +0 -1
  55. package/dist/chunk-RXGDQDOV.js.map +0 -1
  56. package/dist/chunk-X3E5HXG2.js +0 -20
  57. package/dist/chunk-X3E5HXG2.js.map +0 -1
  58. /package/dist/{chunk-CAO4JRLY.js.map → chunk-BQFWCZFH.js.map} +0 -0
  59. /package/dist/{chunk-V5G7X53Y.js.map → chunk-NJQHUUTN.js.map} +0 -0
  60. /package/dist/{chunk-3AJOQCDU.js.map → chunk-ZII6M3SN.js.map} +0 -0
package/dist/base.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { C as ComputedItemContext } from './computed-item.types.d-BKZdSLLJ.js';
2
- import { C as ComputedContext } from './computed.types.d-rKLSPvVG.js';
3
- export { a as ComputedItem, I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './computed.types.d-rKLSPvVG.js';
2
+ import { C as ComputedContext } from './computed.types.d-DpKIYO6e.js';
3
+ export { a as ComputedItem, I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './computed.types.d-DpKIYO6e.js';
4
4
  export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-BvU9r-Mg.js';
5
- export { C as ChoiceRole, I as Interaction, a as InteractionContext, i as interactionContext } from './interaction.d-D4MstYRz.js';
5
+ export { C as ChoiceRole, I as Interaction, a as InteractionContext, i as interactionContext } from './interaction.d-CJiMv8H7.js';
6
6
  import { I as ItemContext, B as BaseType } from './item.types.d-QU7LljEK.js';
7
7
  export { C as Calculate, a as Cardinality, 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, l as itemContextVariables } from './item.types.d-QU7LljEK.js';
8
8
  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';
package/dist/base.js CHANGED
@@ -34,7 +34,7 @@ import {
34
34
  sessionContext,
35
35
  testContext,
36
36
  validationMessage
37
- } from "./chunk-H3J7LFRO.js";
37
+ } from "./chunk-HQESINXH.js";
38
38
  export {
39
39
  INITIAL_SESSION_CONTEXT,
40
40
  INITIAL_TEST_CONTEXT,
@@ -0,0 +1,100 @@
1
+ // ../qti-utilities/dist/decorators/watch.js
2
+ function watch(propertyName, options) {
3
+ const resolvedOptions = {
4
+ waitUntilFirstUpdate: false,
5
+ ...options
6
+ };
7
+ return (proto, decoratedFnName) => {
8
+ const { update } = proto;
9
+ const watchedProperties = Array.isArray(propertyName) ? propertyName : [propertyName];
10
+ proto.update = function(changedProps) {
11
+ watchedProperties.forEach((property) => {
12
+ const key = property;
13
+ if (changedProps.has(key)) {
14
+ const oldValue = changedProps.get(key);
15
+ const newValue = this[key];
16
+ if (oldValue !== newValue) {
17
+ if (!resolvedOptions.waitUntilFirstUpdate || this.hasUpdated) {
18
+ this[decoratedFnName](oldValue, newValue);
19
+ }
20
+ }
21
+ }
22
+ });
23
+ update.call(this, changedProps);
24
+ };
25
+ };
26
+ }
27
+
28
+ // ../qti-utilities/dist/directives/spread-args.js
29
+ import { nothing } from "lit/html.js";
30
+ import { directive } from "lit/directive.js";
31
+ import { AsyncDirective } from "lit/async-directive.js";
32
+ var SpreadArgsDirective = class extends AsyncDirective {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.prevData = {};
36
+ }
37
+ render(_spreadData) {
38
+ return nothing;
39
+ }
40
+ update(part, [spreadData]) {
41
+ if (this.element !== part.element) {
42
+ this.element = part.element;
43
+ }
44
+ this.host = part.options?.host || this.element;
45
+ this.apply(spreadData);
46
+ this.groom(spreadData);
47
+ this.prevData = { ...spreadData };
48
+ return nothing;
49
+ }
50
+ apply(data) {
51
+ const filteredData = this.#filterArgs(data);
52
+ const { prevData, element } = this;
53
+ for (const key in filteredData) {
54
+ const value = filteredData[key];
55
+ if (value === prevData[key]) {
56
+ continue;
57
+ }
58
+ if (value === true) {
59
+ element.setAttribute(key, "");
60
+ } else if (value === false) {
61
+ element.removeAttribute(key);
62
+ } else if (value != null) {
63
+ element.setAttribute(key, String(value));
64
+ } else {
65
+ element.removeAttribute(key);
66
+ }
67
+ }
68
+ }
69
+ groom(data) {
70
+ const { prevData, element } = this;
71
+ if (!prevData)
72
+ return;
73
+ const filteredData = data ? this.#filterArgs(data) : {};
74
+ for (const key in prevData) {
75
+ if (!filteredData || !(key in filteredData)) {
76
+ element.removeAttribute(key);
77
+ }
78
+ }
79
+ }
80
+ #filterArgs(args) {
81
+ return Object.fromEntries(Object.entries(args).filter(([key, value]) => {
82
+ if (typeof value === "function") {
83
+ return false;
84
+ }
85
+ if (key === "max-choices" && value === 0) {
86
+ return true;
87
+ }
88
+ if (value === "" || value === null || value === void 0) {
89
+ return false;
90
+ }
91
+ return true;
92
+ }));
93
+ }
94
+ };
95
+ var spreadArgs = directive(SpreadArgsDirective);
96
+
97
+ export {
98
+ watch
99
+ };
100
+ //# sourceMappingURL=chunk-4DB4SC5K.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../qti-utilities/src/decorators/watch.ts","../../qti-utilities/src/directives/spread-args.ts"],"sourcesContent":["import type { LitElement } from 'lit';\n\ntype UpdateHandler = (prev?: unknown, next?: unknown) => void;\n\ntype NonUndefined<A> = A extends undefined ? never : A;\n\nexport type UpdateHandlerFunctionKeys<T extends object> = {\n [K in keyof T]-?: NonUndefined<T[K]> extends UpdateHandler ? K : never;\n}[keyof T];\n\ninterface WatchOptions {\n /**\n * If true, will only start watching after the initial update/render\n */\n waitUntilFirstUpdate?: boolean;\n}\n\n/**\n * Runs when observed properties change, e.g. @property or @state, but before the component updates. To wait for an\n * update to complete after a change occurs, use `await this.updateComplete` in the handler. To start watching after the\n * initial update/render, use `{ waitUntilFirstUpdate: true }` or `this.hasUpdated` in the handler.\n *\n * Usage:\n *\n * @watch('propName')\n * handlePropChange(oldValue, newValue) {\n * ...\n * }\n */\nexport function watch(propertyName: string | string[], options?: WatchOptions) {\n const resolvedOptions: Required<WatchOptions> = {\n waitUntilFirstUpdate: false,\n ...options\n };\n return <ElemClass extends LitElement>(\n proto: ElemClass,\n decoratedFnName: UpdateHandlerFunctionKeys<ElemClass> | any\n ) => {\n // @ts-expect-error - update is a protected property\n const { update } = proto;\n const watchedProperties = Array.isArray(propertyName) ? propertyName : [propertyName];\n\n // @ts-expect-error - update is a protected property\n proto.update = function (this: ElemClass, changedProps: Map<keyof ElemClass, ElemClass[keyof ElemClass]>) {\n watchedProperties.forEach(property => {\n const key = property as keyof ElemClass;\n if (changedProps.has(key)) {\n const oldValue = changedProps.get(key);\n const newValue = this[key];\n\n if (oldValue !== newValue) {\n if (!resolvedOptions.waitUntilFirstUpdate || this.hasUpdated) {\n ((this as any)[decoratedFnName] as unknown as UpdateHandler)(oldValue, newValue);\n }\n }\n }\n });\n\n update.call(this, changedProps);\n };\n };\n}\n","import { nothing } from 'lit/html.js';\nimport { directive } from 'lit/directive.js';\nimport { AsyncDirective } from 'lit/async-directive.js';\n\nimport type { ElementPart, Part } from 'lit';\n\n/**\n * A directive that spreads arguments to HTML attributes with intelligent filtering.\n *\n * Features:\n * - Includes `max-choices=\"0\"` even though 0 is falsy\n * - Excludes boolean attributes with no value, empty string, null, or undefined\n * - Excludes event handlers and functions\n *\n * Based on the @open-wc/lit-helpers spread directive implementation.\n */\nexport class SpreadArgsDirective extends AsyncDirective {\n host!: EventTarget | object | Element;\n element!: Element;\n prevData: { [key: string]: unknown } = {};\n\n render(_spreadData: { [key: string]: unknown }) {\n return nothing;\n }\n\n update(part: Part, [spreadData]: Parameters<this['render']>) {\n if (this.element !== (part as ElementPart).element) {\n this.element = (part as ElementPart).element;\n }\n this.host = part.options?.host || this.element;\n this.apply(spreadData);\n this.groom(spreadData);\n this.prevData = { ...spreadData };\n return nothing;\n }\n\n apply(data: { [key: string]: unknown }) {\n // Filter the data according to our rules\n const filteredData = this.#filterArgs(data);\n\n const { prevData, element } = this;\n for (const key in filteredData) {\n const value = filteredData[key];\n if (value === prevData[key]) {\n continue;\n }\n\n // Handle different attribute types\n if (value === true) {\n // Boolean attribute - just set the attribute name\n element.setAttribute(key, '');\n } else if (value === false) {\n // Remove false boolean attributes\n element.removeAttribute(key);\n } else if (value != null) {\n // Standard attribute with value\n element.setAttribute(key, String(value));\n } else {\n // Remove null/undefined attributes\n element.removeAttribute(key);\n }\n }\n }\n\n groom(data: { [key: string]: unknown }) {\n const { prevData, element } = this;\n if (!prevData) return;\n\n // Filter the current data to see what we should have\n const filteredData = data ? this.#filterArgs(data) : {};\n\n for (const key in prevData) {\n if (!filteredData || !(key in filteredData)) {\n // Remove attributes that are no longer present in filtered data\n element.removeAttribute(key);\n }\n }\n }\n\n #filterArgs(args: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(args).filter(([key, value]) => {\n // Always exclude functions (events/functions)\n if (typeof value === 'function') {\n return false;\n }\n\n // Special case for max-choices: include when value is 0\n if (key === 'max-choices' && value === 0) {\n return true;\n }\n\n // Exclude empty strings, null, and undefined\n if (value === '' || value === null || value === undefined) {\n return false;\n }\n\n // Include all other truthy values\n return true;\n })\n );\n }\n}\n\n/**\n * A directive that spreads arguments to HTML attributes with intelligent filtering.\n *\n * @param args - Object containing key-value pairs to spread as attributes\n *\n * @example\n * ```typescript\n * import { spreadArgs } from '@qti-components/utilities';\n *\n * const args = {\n * 'max-choices': 0, // Will be included\n * disabled: true, // Will be included as disabled=\"\"\n * hidden: false, // Will be excluded\n * title: '', // Will be excluded\n * onClick: () => {}, // Will be excluded\n * id: 'my-element' // Will be included as id=\"my-element\"\n * };\n *\n * html`<my-element ${spreadArgs(args)}></my-element>`;\n * ```\n */\nexport const spreadArgs = directive(SpreadArgsDirective);\n\n/**\n * Helper function version that works with @open-wc/lit-helpers spread directive.\n * @deprecated Use the spreadArgs directive directly instead.\n */\nexport function filterArgsForSpread(args: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(args).filter(([, value]) => {\n if (typeof value === 'function') return false;\n if (value === '' || value === null || value === undefined) return false;\n return true;\n })\n );\n}\n"],"mappings":";AA6BM,SAAU,MAAM,cAAiC,SAAsB;AAC3E,QAAM,kBAA0C;IAC9C,sBAAsB;IACtB,GAAG;;AAEL,SAAO,CACL,OACA,oBACE;AAEF,UAAM,EAAE,OAAM,IAAK;AACnB,UAAM,oBAAoB,MAAM,QAAQ,YAAY,IAAI,eAAe,CAAC,YAAY;AAGpF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