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

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 (47) hide show
  1. package/cdn/index.global.js +1 -1
  2. package/cdn/index.js +2 -2
  3. package/dist/base.d.ts +2 -2
  4. package/dist/base.js +1 -1
  5. package/dist/{chunk-UDJ7MHLF.js → chunk-3FQZRJFH.js} +2 -2
  6. package/dist/{chunk-OG5HIRHE.js → chunk-4UO6AGJ6.js} +2 -2
  7. package/dist/{chunk-L7J2ZOJL.js → chunk-HSOILZC6.js} +2 -2
  8. package/dist/{chunk-UURHLJVM.js → chunk-JE6X3IZT.js} +3 -3
  9. package/dist/{chunk-WGUQCB2Z.js → chunk-MFKH6BZM.js} +2 -2
  10. package/dist/{chunk-DUKQ53E7.js → chunk-MXY66QOH.js} +8 -3
  11. package/dist/{chunk-DUKQ53E7.js.map → chunk-MXY66QOH.js.map} +1 -1
  12. package/dist/{chunk-V5GL7PTC.js → chunk-QECECKEC.js} +2 -2
  13. package/dist/{chunk-QLGUI5VG.js → chunk-QKCVC4HF.js} +2 -2
  14. package/dist/{chunk-N453PANH.js → chunk-WTGUKDVH.js} +2 -2
  15. package/dist/{chunk-NZ7ZC4SP.js → chunk-XBBTYGCX.js} +1 -1
  16. package/dist/chunk-XBBTYGCX.js.map +1 -0
  17. package/dist/{chunk-L3LBSAGZ.js → chunk-Y7RSSGDY.js} +2 -2
  18. package/dist/{chunk-SUPLA6QQ.js → chunk-YRXH3YMJ.js} +6 -6
  19. package/dist/{config.context.d-CCqlJXpE.d.ts → config.context.d-Dm11aAuw.d.ts} +16 -0
  20. package/dist/corrections.d.ts +5 -5
  21. package/dist/corrections.js +7 -7
  22. package/dist/elements.js +3 -3
  23. package/dist/index.d.ts +5 -5
  24. package/dist/index.js +12 -12
  25. package/dist/interactions.d.ts +4 -4
  26. package/dist/interactions.js +3 -3
  27. package/dist/item.d.ts +2 -2
  28. package/dist/item.js +3 -3
  29. package/dist/processing.js +3 -3
  30. package/dist/{qti-item.d-CLChmRvB.d.ts → qti-item.d-CxP6KtCH.d.ts} +1 -1
  31. package/dist/{qti-test.d-COzv7YZG.d.ts → qti-test.d-CRqJF2DM.d.ts} +1 -1
  32. package/dist/{qti-text-entry-interaction.d-DsUyecBC.d.ts → qti-text-entry-interaction.d-m0EFv9no.d.ts} +2 -2
  33. package/dist/{record.d-BfZhFr0L.d.ts → record.d-N1Bq7e1f.d.ts} +1 -1
  34. package/dist/test.d.ts +3 -3
  35. package/dist/test.js +4 -4
  36. package/package.json +2 -2
  37. package/dist/chunk-NZ7ZC4SP.js.map +0 -1
  38. /package/dist/{chunk-UDJ7MHLF.js.map → chunk-3FQZRJFH.js.map} +0 -0
  39. /package/dist/{chunk-OG5HIRHE.js.map → chunk-4UO6AGJ6.js.map} +0 -0
  40. /package/dist/{chunk-L7J2ZOJL.js.map → chunk-HSOILZC6.js.map} +0 -0
  41. /package/dist/{chunk-UURHLJVM.js.map → chunk-JE6X3IZT.js.map} +0 -0
  42. /package/dist/{chunk-WGUQCB2Z.js.map → chunk-MFKH6BZM.js.map} +0 -0
  43. /package/dist/{chunk-V5GL7PTC.js.map → chunk-QECECKEC.js.map} +0 -0
  44. /package/dist/{chunk-QLGUI5VG.js.map → chunk-QKCVC4HF.js.map} +0 -0
  45. /package/dist/{chunk-N453PANH.js.map → chunk-WTGUKDVH.js.map} +0 -0
  46. /package/dist/{chunk-L3LBSAGZ.js.map → chunk-Y7RSSGDY.js.map} +0 -0
  47. /package/dist/{chunk-SUPLA6QQ.js.map → chunk-YRXH3YMJ.js.map} +0 -0
package/cdn/index.js CHANGED
@@ -7767,7 +7767,7 @@ CES.load();
7767
7767
  </button>
7768
7768
  <slot @slotchange=${this.#g}></slot>
7769
7769
  </div>
7770
- `}renderValidationMessage(){return v`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return v` ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()} `}async connectedCallback(){super.connectedCallback(),this.#r(),this.#u(),await this.updateComplete,this.isConnected&&this.updateMenuWidth()}disconnectedCallback(){super.disconnectedCallback(),this.#b(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(t){t.has("configContext")&&this.#r()}updated(t){t.has("_dropdownOpen")&&this._dropdownOpen&&(this.#f(),this.#v()[0]?.focus()),(t.has("disabled")||t.has("readonly"))&&this.#f()}#t(){let t=this.options[0]?.content;return typeof t=="string"&&t.trim()===""}menuAutoSizeRows(){let t=super.menuAutoSizeRows();return this.#t()?t.filter(e=>!e.matches('button[part~="option-prompt"]')):t}#e(){return this.options.find(t=>t.selected)??this.options[0]}#r(){let t=Array.from(this.querySelectorAll("qti-inline-choice")),e=this.dataPrompt??this.configContext?.inlineChoicePrompt??"select",r=this._pendingResponse,i=r!==void 0?r??"":this.options.find(a=>a.selected)?.value??"",n=[{content:e,value:"",selected:i===""},...t.map(a=>{let c=a.getAttribute("identifier")??"";return{content:Array.from(a.childNodes).map(l=>l.cloneNode(!0)),value:c,selected:c!==""&&c===i}})],s=n.some(a=>a.selected);this.options=s?n:n.map((a,c)=>({...a,selected:c===0})),this._pendingResponse=void 0,this.#f(),this.updateMenuWidth()}shouldAutoSizeMenu(){return this.configContext?.inlineChoiceAutosize===!1?!1:!Array.from(this.classList).some(t=>t.startsWith("qti-input-width-"))}menuAutoSizeExtraWidth(){let t=this.renderRoot.querySelector('span[part~="icon"]');if(!t)return 0;let e=this.renderRoot.querySelector('button[part="trigger"]'),r=e&&parseFloat(getComputedStyle(e).columnGap)||0;return t.offsetWidth+r}validate(){let t=this.options.find(s=>s.selected),e=t?t.value!=="":!1,r=this.required||this.minChoices>=1,i=e||!r,n=this.dataset.minChoicesMessage||"Please select an option.";return this.setInteractionValidity(i,i?"":n,this,{suppressInline:!0,kind:"min"}),i}reportValidity(t){return super.reportValidity(t)}reset(){this.resetValidityReport(),this.#n(!1),this.options=this.options.map((t,e)=>({...t,selected:e===0})),this.#f()}set response(t){let e=t??"";if(this.options.length===0){this._pendingResponse=t;return}this.options=this.options.map(r=>({...r,selected:r.value===e})),this.#f()}get response(){let t=this.options.find(e=>e.selected)?.value??"";return t===""?null:t}#i(t){this.options=this.options.map(e=>({...e,selected:e.value===t})),this.#f(),this.validate(),this.reportValidity({trigger:"change"}),this.saveResponse(t),this.#n(!1)}#n(t){let e=this.#h();if(e){if(t){e.matches(":popover-open")||e.showPopover();return}e.matches(":popover-open")&&e.hidePopover()}}#o;#s;#a;#c;#p(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#l(){let t=document.activeElement;for(;t&&t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}#d(t){return t===this||this.contains(t)||this.renderRoot.contains(t)}#h(){return this.renderRoot.querySelector(`#${this._menuId}`)}#u(){this._slotObserver=new MutationObserver(()=>this.#r()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#g;#m;#b(){let t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let e of t)e.removeEventListener("click",this.#m),e.removeAttribute("tabindex"),e.internals.role=null,e.internals.ariaSelected=null,e.internals.ariaChecked="false",e.internals.states.delete("checked")}async#f(){this._internals.setFormValue(this.response),await this.updateComplete;let t=this.options.find(r=>r.selected)?.value??"",e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let r of e){let n=(r.getAttribute("identifier")??"")===t;r.removeEventListener("click",this.#m),r.addEventListener("click",this.#m),r.disabled=this.disabled,r.readonly=this.readonly,r.internals.role="option",r.internals.ariaSelected=n?"true":"false",r.internals.ariaChecked=n?"true":"false",r.internals.ariaDisabled=this.disabled?"true":"false",r.internals.ariaReadOnly=this.readonly?"true":"false",n?r.internals.states.add("checked"):r.internals.states.delete("checked"),r.tabIndex=-1}}#v(){let t=this.renderRoot.querySelector('button[part~="option"]:not([hidden])'),e=Array.from(this.querySelectorAll("qti-inline-choice"));return[...t?[t]:[],...e]}};Zt([T()],rt.prototype,"options",void 0);Zt([T()],rt.prototype,"_dropdownOpen",void 0);Zt([R({context:yt,subscribe:!0}),p({attribute:!1})],rt.prototype,"configContext",void 0);Zt([p({type:String,attribute:"data-prompt"})],rt.prototype,"dataPrompt",void 0);Zt([p({type:String,attribute:"data-clear-label"})],rt.prototype,"dataClearLabel",void 0);Zt([N("dataPrompt",{waitUntilFirstUpdate:!0})],rt.prototype,"_handleDataPromptChange",void 0);Zt([p({type:Boolean,reflect:!0,converter:{fromAttribute:o=>o==="true"||o==="",toAttribute:o=>o?"true":null}})],rt.prototype,"required",void 0);Zt([p({type:Number,attribute:"min-choices"})],rt.prototype,"minChoices",void 0);Zt([N(["required","minChoices"],{waitUntilFirstUpdate:!0})],rt.prototype,"_handleRequiredChange",void 0);Zt([p({attribute:"response",reflect:!1,noAccessor:!0})],rt.prototype,"response",null);var rs=[{tag:"qti-inline-choice-interaction",ctor:rt}];var yp=[M,U,w`
7770
+ `}renderValidationMessage(){return v`<div id="validation-message" part="message" role="alert" style="display:none;"></div>`}render(){return v` ${this.renderTrigger()} ${this.renderMenu()} ${this.renderValidationMessage()} `}async connectedCallback(){super.connectedCallback(),this.#r(),this.#u(),await this.updateComplete,this.isConnected&&this.updateMenuWidth()}disconnectedCallback(){super.disconnectedCallback(),this.#b(),this._slotObserver?.disconnect(),this._slotObserver=null}willUpdate(t){t.has("configContext")&&this.#r()}updated(t){t.has("_dropdownOpen")&&this._dropdownOpen&&(this.#f(),this.#v()[0]?.focus()),(t.has("disabled")||t.has("readonly"))&&this.#f()}#t(){let t=this.options[0]?.content;return typeof t=="string"&&t.trim()===""}menuAutoSizeRows(){let t=super.menuAutoSizeRows();return this.#t()?t.filter(e=>!e.matches('button[part~="option-prompt"]')):t}#e(){return this.options.find(t=>t.selected)??this.options[0]}#r(){let t=Array.from(this.querySelectorAll("qti-inline-choice")),e=this.dataPrompt??this.configContext?.inlineChoicePrompt??"select",r=this._pendingResponse,i=r!==void 0?r??"":this.options.find(a=>a.selected)?.value??"",n=[{content:e,value:"",selected:i===""},...t.map(a=>{let c=a.getAttribute("identifier")??"";return{content:Array.from(a.childNodes).map(l=>l.cloneNode(!0)),value:c,selected:c!==""&&c===i}})],s=n.some(a=>a.selected);this.options=s?n:n.map((a,c)=>({...a,selected:c===0})),this._pendingResponse=void 0,this.#f(),this.updateMenuWidth()}shouldAutoSizeMenu(){return this.configContext?.inlineChoiceAutosize===!1?!1:!Array.from(this.classList).some(t=>t.startsWith("qti-input-width-"))}menuAutoSizeExtraWidth(){let t=this.renderRoot.querySelector('span[part~="icon"]');if(!t)return 0;let e=this.renderRoot.querySelector('button[part="trigger"]'),r=e&&parseFloat(getComputedStyle(e).columnGap)||0;return t.offsetWidth+r}validate(){let t=this.options.find(s=>s.selected),e=t?t.value!=="":!1,r=this.required||this.minChoices>=1,i=e||!r,n=this.dataset.minSelectionsMessage||this.dataset.minChoicesMessage||"Please select an option.";return this.setInteractionValidity(i,i?"":n,this,{suppressInline:!0,kind:"min"}),i}reportValidity(t){return super.reportValidity(t)}reset(){this.resetValidityReport(),this.#n(!1),this.options=this.options.map((t,e)=>({...t,selected:e===0})),this.#f()}set response(t){let e=t??"";if(this.options.length===0){this._pendingResponse=t;return}this.options=this.options.map(r=>({...r,selected:r.value===e})),this.#f()}get response(){let t=this.options.find(e=>e.selected)?.value??"";return t===""?null:t}#i(t){this.options=this.options.map(e=>({...e,selected:e.value===t})),this.#f(),this.validate(),this.reportValidity({trigger:"change"}),this.saveResponse(t),this.#n(!1)}#n(t){let e=this.#h();if(e){if(t){e.matches(":popover-open")||e.showPopover();return}e.matches(":popover-open")&&e.hidePopover()}}#o;#s;#a;#c;#p(){this.renderRoot.querySelector('button[part="trigger"]')?.focus()}#l(){let t=document.activeElement;for(;t&&t instanceof HTMLElement&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}#d(t){return t===this||this.contains(t)||this.renderRoot.contains(t)}#h(){return this.renderRoot.querySelector(`#${this._menuId}`)}#u(){this._slotObserver=new MutationObserver(()=>this.#r()),this._slotObserver.observe(this,{childList:!0,subtree:!0})}#g;#m;#b(){let t=Array.from(this.querySelectorAll("qti-inline-choice"));for(let e of t)e.removeEventListener("click",this.#m),e.removeAttribute("tabindex"),e.internals.role=null,e.internals.ariaSelected=null,e.internals.ariaChecked="false",e.internals.states.delete("checked")}async#f(){this._internals.setFormValue(this.response),await this.updateComplete;let t=this.options.find(r=>r.selected)?.value??"",e=Array.from(this.querySelectorAll("qti-inline-choice"));for(let r of e){let n=(r.getAttribute("identifier")??"")===t;r.removeEventListener("click",this.#m),r.addEventListener("click",this.#m),r.disabled=this.disabled,r.readonly=this.readonly,r.internals.role="option",r.internals.ariaSelected=n?"true":"false",r.internals.ariaChecked=n?"true":"false",r.internals.ariaDisabled=this.disabled?"true":"false",r.internals.ariaReadOnly=this.readonly?"true":"false",n?r.internals.states.add("checked"):r.internals.states.delete("checked"),r.tabIndex=-1}}#v(){let t=this.renderRoot.querySelector('button[part~="option"]:not([hidden])'),e=Array.from(this.querySelectorAll("qti-inline-choice"));return[...t?[t]:[],...e]}};Zt([T()],rt.prototype,"options",void 0);Zt([T()],rt.prototype,"_dropdownOpen",void 0);Zt([R({context:yt,subscribe:!0}),p({attribute:!1})],rt.prototype,"configContext",void 0);Zt([p({type:String,attribute:"data-prompt"})],rt.prototype,"dataPrompt",void 0);Zt([p({type:String,attribute:"data-clear-label"})],rt.prototype,"dataClearLabel",void 0);Zt([N("dataPrompt",{waitUntilFirstUpdate:!0})],rt.prototype,"_handleDataPromptChange",void 0);Zt([p({type:Boolean,reflect:!0,converter:{fromAttribute:o=>o==="true"||o==="",toAttribute:o=>o?"true":null}})],rt.prototype,"required",void 0);Zt([p({type:Number,attribute:"min-choices"})],rt.prototype,"minChoices",void 0);Zt([N(["required","minChoices"],{waitUntilFirstUpdate:!0})],rt.prototype,"_handleRequiredChange",void 0);Zt([p({attribute:"response",reflect:!1,noAccessor:!0})],rt.prototype,"response",null);var rs=[{tag:"qti-inline-choice-interaction",ctor:rt}];var yp=[M,U,w`
7771
7771
  /*
7772
7772
  * A custom element is inline unless it says otherwise, and this one never did. Its shadow content
7773
7773
  * is block-level, so block-in-inline generated the anonymous block boxes and it looked correct —
@@ -9816,7 +9816,7 @@ https://requirejs.org/docs/errors.html#\`+r);return h.requireType=r,h.requireMod
9816
9816
  width: 100%;
9817
9817
  min-height: 50px;
9818
9818
  }
9819
- `]}#e;set responseDeclaration(t){this.#e=t}get responseDeclaration(){if(this.#e)return this.#e;let t=this.responseVariable;if(!t)return null;let e={baseType:t.baseType,cardinality:t.cardinality},r=t.correctResponse;return Cf(r)&&(e.correctResponse={value:r}),e}#r(){let t=this.responseDeclaration;if(!t?.correctResponse||wf.includes(this.status))return t;let{correctResponse:e,...r}=t;return r}#i;#n;#o;#s;#a(){if(this.#i===null&&this.requirePathsJson)try{let t=JSON.parse(this.requirePathsJson);if(Array.isArray(t)||!t||typeof t!="object")throw new Error("Require paths must be a JSON object.");this.#i=t}catch(t){console.error("Error parsing require paths JSON:",t),this._errorMessage=`Error parsing require paths JSON: ${t.message}`,this.#i={}}return this.#i||{}}#c(){if(this.#n===null&&this.requireShimJson)try{this.#n=JSON.parse(this.requireShimJson)}catch(t){console.error("Error parsing require shim JSON:",t),this._errorMessage=`Error parsing require shim JSON: ${t.message}`,this.#n={}}return this.#n||{}}#p(){return this.#a()}#l(){return this.#c()}#d(t){if(t&&Array.isArray(t.record)){let e=Tp(t.record);return Object.keys(e).length?e:null}for(let e in t)if(t.hasOwnProperty(e)){let r=t[e];if(r){for(let i in r)if(r.hasOwnProperty(i)){let n=r[i];if(i==="file"){if(Array.isArray(n))return n.map(hn).filter(a=>a!==null);let s=hn(n);if(s!==null)return s;continue}if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}getDirectChildrenByTag(t){let e=t.toLowerCase();return Array.from(this.children).filter(r=>r.tagName.toLowerCase()===e)}normalizeListValue(t){return t==null?[]:Array.isArray(t)?t:[t]}variableToQtiVariableJSON(t,e,r){if(e==="record"||r==="record")return ls(t);if(e!=="single"){let i=this.normalizeListValue(t).map(n=>ti(n,r));return{list:{[r]:i}}}return{base:{[r]:ti(t,r)}}}getQtiContextDefaultsFromItem(){let t=this.closest("qti-assessment-item");if(!t)return{};let e={};return t.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(i=>{let n=i.querySelector("qti-default-value");if(!n)return;let{value:s,baseTypes:a}=ji(n.querySelectorAll("qti-value"));for(let[c,l]of Object.entries(s))e[c]=ti(l,a[c]??"string")}),e}getQtiContextRecord(){let t=this.getQtiContextDefaultsFromItem(),e=this.qtiContext?.QTI_CONTEXT||{},r={...t,...e};if(!Object.keys(r).length)return null;let i={candidateIdentifier:r.candidateIdentifier??"",testIdentifier:r.testIdentifier??"",environmentIdentifier:r.environmentIdentifier??"",...r};return ls(i)}getTemplateVariables(){let t={},e=this.getDirectChildrenByTag("qti-template-variable");return e.length&&e.forEach(r=>{let i=r.getAttribute("template-identifier")||r.getAttribute("identifier")||"";if(!i)return;let n=this.context?.variables?.find(c=>c.identifier===i);if(!n)return;let s=n.cardinality||"single",a=n.baseType||"string";t[i]=this.variableToQtiVariableJSON(n.value,s,a)}),t}getContextVariables(){let t={},e=this.getDirectChildrenByTag("qti-context-variable");return e.length&&e.forEach(r=>{let i=r.getAttribute("identifier")||"";if(!i)return;if(i==="QTI_CONTEXT"){let c=this.getQtiContextRecord();c&&(t[i]=c);return}let n=this.context?.variables?.find(c=>c.identifier===i);if(!n)return;let s=n.cardinality||"single",a=n.baseType||"string";t[i]=this.variableToQtiVariableJSON(n.value,s,a)}),t}#h(t){let e={...t};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);e[i]=t[r]}return e}#u(t){let e={...t},r=(i,n,s)=>{let a=i;for(let c=0;c<n.length;c+=1){let l=n[c];if(c===n.length-1){a[l]=s;return}(!a[l]||typeof a[l]!="object"||Array.isArray(a[l]))&&(a[l]={}),a=a[l]}};for(let[i,n]of Object.entries(t)){if(!i.includes("__"))continue;let s=i.split("__").filter(Boolean);s.length<2||r(e,s,n)}return e}responseVariablesToQtiVariableJSON(t,e,r,i){if(e==="record")return _p(t,i);if(e!=="single"){let n={list:{}};return n.list[r]=dn(r)?this.normalizeListValue(t).map(pn).filter(Boolean):t,n}else{let n={base:{}};return n.base[r]=dn(r)?pn(t):t,n}}#g(){return this.response===null||this.response===void 0?!1:ce(this.response)?Object.values(this.response).some(t=>t!==""&&t!==null&&t!==void 0):Array.isArray(this.response)?this.response.length===0?!1:this.response.some(t=>t!==""&&t!==null&&t!==void 0):this.response!==""}#m(t,e){let r=this.dataset.invalidresponsemessage||"Invalid response.",i=t?"":e&&e.trim().length>0?e:r;this._internals.setValidity(t?{}:{customError:!0},i)}validate(){let t=typeof this.#o=="boolean"?this.#o:this.#g();return this.#m(t,this.#s),t}set value(t){t===null?this.#t=[]:this.#t=Array.isArray(t)?t:t.split(",")}get value(){return this.#t===null||this.#t===void 0?null:ce(this.#t)?JSON.stringify(this.#t):Array.isArray(this.#t)?this.#t.join(","):String(this.#t)}set boundTo(t){if(!t||!t[this.responseIdentifier])return;let e=this.#d(t[this.responseIdentifier]);this.#t=e,this.saveResponse(e)}get boundTo(){let t={},e=this.context?.variables?.find(r=>r.identifier===this.responseIdentifier);if(e){let r=e.cardinality||"single",i=e.baseType||"string",n=e.value||null,s=e.fieldBaseTypes,a=this.responseVariablesToQtiVariableJSON(n,r,i,s);t[this.responseIdentifier]=a}return t}#b(t){return t&&t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}#f(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=this.#b(i):e[r]=i;return e}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage)}sendMessageToIframe(t,e){let r=this.iframe?.contentWindow;if(!this._iframeLoaded||!r){this._pendingMessages.push({method:t,params:e});return}r.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:t,params:e},"*")}#v(){this._pendingMessages.length&&(this._pendingMessages.forEach(t=>{this.sendMessageToIframe(t.method,t.params)}),this._pendingMessages=[])}createIframe(){this._interactionReady=!1,this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.#x(),this.#y()};let t=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=t;let e=this.generateIframeContent();this.iframe.srcdoc=e,this.appendChild(this.iframe)}#y(){let t=this.#h(this.#u(this.#f({...this.dataset}))),e=this.context?.state?.[this.responseIdentifier],r=typeof e=="string"&&e.length>0?e:null,i={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Yn(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:t,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#q(),boundTo:r?null:this.boundTo,responseDeclaration:this.#r(),status:this.status,state:r};this.sendMessageToIframe("initialize",i)}#q(){let t=[],e=this.querySelector("qti-interaction-modules");if(e){let r=e.querySelectorAll("qti-interaction-module");for(let i of r)t.push({id:i.getAttribute("id"),primaryPath:i.getAttribute("primary-path"),fallbackPath:i.getAttribute("fallback-path")})}return t}#x(){let t=this.querySelector("qti-interaction-markup");t&&this.sendMessageToIframe("setMarkup",t.innerHTML);let e=Array.from(this.querySelectorAll("qti-stylesheet"));if(e.length){let i=e.map(n=>n.outerHTML).join(`
9819
+ `]}#e;set responseDeclaration(t){this.#e=t}get responseDeclaration(){if(this.#e)return this.#e;let t=this.responseVariable;if(!t)return null;let e={baseType:t.baseType,cardinality:t.cardinality},r=t.correctResponse;return Cf(r)&&(e.correctResponse={value:r}),e}#r(){let t=this.responseDeclaration;if(!t?.correctResponse||wf.includes(this.status))return t;let{correctResponse:e,...r}=t;return r}#i;#n;#o;#s;#a(){if(this.#i===null&&this.requirePathsJson)try{let t=JSON.parse(this.requirePathsJson);if(Array.isArray(t)||!t||typeof t!="object")throw new Error("Require paths must be a JSON object.");this.#i=t}catch(t){console.error("Error parsing require paths JSON:",t),this._errorMessage=`Error parsing require paths JSON: ${t.message}`,this.#i={}}return this.#i||{}}#c(){if(this.#n===null&&this.requireShimJson)try{this.#n=JSON.parse(this.requireShimJson)}catch(t){console.error("Error parsing require shim JSON:",t),this._errorMessage=`Error parsing require shim JSON: ${t.message}`,this.#n={}}return this.#n||{}}#p(){return this.#a()}#l(){return this.#c()}#d(t){if(t&&Array.isArray(t.record)){let e=Tp(t.record);return Object.keys(e).length?e:null}for(let e in t)if(t.hasOwnProperty(e)){let r=t[e];if(r){for(let i in r)if(r.hasOwnProperty(i)){let n=r[i];if(i==="file"){if(Array.isArray(n))return n.map(hn).filter(a=>a!==null);let s=hn(n);if(s!==null)return s;continue}if(Array.isArray(n))return n.map(String);if(n!=null)return String(n)}}}return null}getDirectChildrenByTag(t){let e=t.toLowerCase();return Array.from(this.children).filter(r=>r.tagName.toLowerCase()===e)}normalizeListValue(t){return t==null?[]:Array.isArray(t)?t:[t]}variableToQtiVariableJSON(t,e,r){if(e==="record"||r==="record")return ls(t);if(e!=="single"){let i=this.normalizeListValue(t).map(n=>ti(n,r));return{list:{[r]:i}}}return{base:{[r]:ti(t,r)}}}getQtiContextDefaultsFromItem(){let t=this.closest("qti-assessment-item");if(!t)return{};let e={};return t.querySelectorAll('qti-context-declaration[identifier="QTI_CONTEXT"]').forEach(i=>{let n=i.querySelector("qti-default-value");if(!n)return;let{value:s,baseTypes:a}=ji(n.querySelectorAll("qti-value"));for(let[c,l]of Object.entries(s))e[c]=ti(l,a[c]??"string")}),e}getQtiContextRecord(){let t=this.getQtiContextDefaultsFromItem(),e=this.qtiContext?.QTI_CONTEXT||{},r={...t,...e};if(!Object.keys(r).length)return null;let i={candidateIdentifier:r.candidateIdentifier??"",testIdentifier:r.testIdentifier??"",environmentIdentifier:r.environmentIdentifier??"",...r};return ls(i)}getTemplateVariables(){let t={},e=this.getDirectChildrenByTag("qti-template-variable");return e.length&&e.forEach(r=>{let i=r.getAttribute("template-identifier")||r.getAttribute("identifier")||"";if(!i)return;let n=this.context?.variables?.find(c=>c.identifier===i);if(!n)return;let s=n.cardinality||"single",a=n.baseType||"string";t[i]=this.variableToQtiVariableJSON(n.value,s,a)}),t}getContextVariables(){let t={},e=this.getDirectChildrenByTag("qti-context-variable");return e.length&&e.forEach(r=>{let i=r.getAttribute("identifier")||"";if(!i)return;if(i==="QTI_CONTEXT"){let c=this.getQtiContextRecord();c&&(t[i]=c);return}let n=this.context?.variables?.find(c=>c.identifier===i);if(!n)return;let s=n.cardinality||"single",a=n.baseType||"string";t[i]=this.variableToQtiVariableJSON(n.value,s,a)}),t}#h(t){let e={...t};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let i=r.replace(/[A-Z]/g,n=>`-${n.toLowerCase()}`);e[i]=t[r]}return e}#u(t){let e={...t},r=(i,n,s)=>{let a=i;for(let c=0;c<n.length;c+=1){let l=n[c];if(c===n.length-1){a[l]=s;return}(!a[l]||typeof a[l]!="object"||Array.isArray(a[l]))&&(a[l]={}),a=a[l]}};for(let[i,n]of Object.entries(t)){if(!i.includes("__"))continue;let s=i.split("__").filter(Boolean);s.length<2||r(e,s,n)}return e}responseVariablesToQtiVariableJSON(t,e,r,i){if(e==="record")return _p(t,i);if(e!=="single"){let n={list:{}};return n.list[r]=dn(r)?this.normalizeListValue(t).map(pn).filter(Boolean):t,n}else{let n={base:{}};return n.base[r]=dn(r)?pn(t):t,n}}#g(){return this.response===null||this.response===void 0?!1:ce(this.response)?Object.values(this.response).some(t=>t!==""&&t!==null&&t!==void 0):Array.isArray(this.response)?this.response.length===0?!1:this.response.some(t=>t!==""&&t!==null&&t!==void 0):this.response!==""}#m(t,e){let r=this.dataset.invalidresponsemessage||"Invalid response.",i=t?"":e&&e.trim().length>0?e:r;this._internals.setValidity(t?{}:{customError:!0},i)}validate(){let t=typeof this.#o=="boolean"?this.#o:this.#g();return this.#m(t,this.#s),t}set value(t){t===null?this.#t=[]:this.#t=Array.isArray(t)?t:t.split(",")}get value(){return this.#t===null||this.#t===void 0?null:ce(this.#t)?JSON.stringify(this.#t):Array.isArray(this.#t)?this.#t.join(","):String(this.#t)}set boundTo(t){if(!t||!t[this.responseIdentifier])return;let e=this.#d(t[this.responseIdentifier]);this.#t=e,this.saveResponse(e)}get boundTo(){let t={},e=this.context?.variables?.find(r=>r.identifier===this.responseIdentifier);if(e){let r=e.cardinality||"single",i=e.baseType||"string",n=e.value||null,s=e.fieldBaseTypes,a=this.responseVariablesToQtiVariableJSON(n,r,i,s);t[this.responseIdentifier]=a}return t}#b(t){return t&&t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#x27;/g,"'").replace(/&#x2F;/g,"/").replace(/&#x60;/g,"`").replace(/&#x3D;/g,"=")}#f(t){let e={};for(let[r,i]of Object.entries(t))typeof i=="string"?e[r]=this.#b(i):e[r]=i;return e}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("message",this.handleIframeMessage)}sendMessageToIframe(t,e){let r=this.iframe?.contentWindow;if(!this._iframeLoaded||!r){this._pendingMessages.push({method:t,params:e});return}r.postMessage({source:"qti-portable-custom-interaction",responseIdentifier:this.responseIdentifier,method:t,params:e},"*")}#v(){this._pendingMessages.length&&(this._pendingMessages.forEach(t=>{this.sendMessageToIframe(t.method,t.params)}),this._pendingMessages=[])}createIframe(){this._interactionReady=!1,this.iframe=document.createElement("iframe"),this.iframe.id=`pci-iframe-${this.responseIdentifier}`,this.iframe.setAttribute("title","QTI PCI Iframe"),this.iframe.setAttribute("aria-label","QTI PCI Iframe"),this.iframe.setAttribute("aria-hidden","false"),this.iframe.setAttribute("role","application"),this.iframe.style.width="100%",this.iframe.style.border="none",this.iframe.style.display="block",this.iframe.onload=()=>{this._iframeLoaded=!0,this.#x(),this.#y()};let t=`qti-pci-${this.responseIdentifier}-${Date.now()}`;this.iframe.name=t;let{sandbox:e,allow:r}=this.configContext?.pciIframe??{};e!==void 0&&this.iframe.setAttribute("sandbox",e),r&&this.iframe.setAttribute("allow",r);let i=this.generateIframeContent();this.iframe.srcdoc=i,this.appendChild(this.iframe)}#y(){let t=this.#h(this.#u(this.#f({...this.dataset}))),e=this.context?.state?.[this.responseIdentifier],r=typeof e=="string"&&e.length>0?e:null,i={module:this.module,customInteractionTypeIdentifier:this.customInteractionTypeIdentifier,baseUrl:this.baseUrl?this.baseUrl.startsWith("http")||this.baseUrl.startsWith("blob")||this.baseUrl.startsWith("base64")?this.baseUrl:Yn(`${window.location.origin}${this.baseUrl}`):window.location.origin,responseIdentifier:this.responseIdentifier,properties:t,contextVariables:this.getContextVariables(),templateVariables:this.getTemplateVariables(),dataAttributes:{...this.dataset},interactionModules:this.#q(),boundTo:r?null:this.boundTo,responseDeclaration:this.#r(),status:this.status,state:r};this.sendMessageToIframe("initialize",i)}#q(){let t=[],e=this.querySelector("qti-interaction-modules");if(e){let r=e.querySelectorAll("qti-interaction-module");for(let i of r)t.push({id:i.getAttribute("id"),primaryPath:i.getAttribute("primary-path"),fallbackPath:i.getAttribute("fallback-path")})}return t}#x(){let t=this.querySelector("qti-interaction-markup");t&&this.sendMessageToIframe("setMarkup",t.innerHTML);let e=Array.from(this.querySelectorAll("qti-stylesheet"));if(e.length){let i=e.map(n=>n.outerHTML).join(`
9820
9820
  `);this.sendMessageToIframe("setStylesheets",i)}let r=this.querySelector("properties");r&&this.sendMessageToIframe("setProperties",r.innerHTML)}#C(){}connectedCallback(){super.connectedCallback(),this.#o=null,this.#s="";let t=this.response;(Array.isArray(t)?t.length>0:t)||(this.response=this.responseVariable?.value??null),window.addEventListener("message",this.handleIframeMessage),this.createIframe()}generateIframeContent(){let t=window.getComputedStyle(document.body),e=JSON.stringify(this.#p()),r=JSON.stringify(this.#l()),i=this.dataset.baseUrl?this.dataset.baseUrl.startsWith("/")?`${window.location.origin}${this.dataset.baseUrl}`:this.dataset.baseUrl:"",n=i?i.endsWith("/")?i:`${i}/`:`${window.location.origin}/`,s=this.dataset.forwardConsole==="true",a=this.dataset.componentsCdnUrl,c=this.dataset.componentsCssUrl,l=this.requireJsUrl?`<script src="${this.requireJsUrl}"></script>`:`<script>${qf(Rp)}</script>`,d=`
9821
9821
  font-family: ${t.getPropertyValue("font-family")};
9822
9822
  font-size: ${t.getPropertyValue("font-size")};
package/dist/base.d.ts CHANGED
@@ -2,8 +2,8 @@ import { C as ComputedItemContext } from './session.context.d-9gRdGK4T.js';
2
2
  export { I as INITIAL_SESSION_CONTEXT, S as SessionContext, V as View, s as sessionContext } from './session.context.d-9gRdGK4T.js';
3
3
  import { C as ComputedContext } from './computed.types.d-D4wskgi0.js';
4
4
  export { a as ComputedItem } from './computed.types.d-D4wskgi0.js';
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-BfZhFr0L.js';
5
+ export { C as ConfigContext, V as ValidationDisplayMode, c as configContext } from './config.context.d-Dm11aAuw.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-N1Bq7e1f.js';
7
7
  import { I as ItemContext } from './item.types.d-Zc6ZQDhu.js';
8
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';
package/dist/base.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  testContext,
49
49
  unregisterCustomOperator,
50
50
  validationMessage
51
- } from "./chunk-NZ7ZC4SP.js";
51
+ } from "./chunk-XBBTYGCX.js";
52
52
  import "./chunk-PZ5AY32C.js";
53
53
  export {
54
54
  CustomStateSetShim,
@@ -9,7 +9,7 @@ import {
9
9
  isRecordValue,
10
10
  itemContext,
11
11
  testContext
12
- } from "./chunk-NZ7ZC4SP.js";
12
+ } from "./chunk-XBBTYGCX.js";
13
13
 
14
14
  // ../qti-processing/dist/components/qti-and/qti-and.js
15
15
  var QtiAnd = class extends qtiAndMixin(QtiConditionExpression) {
@@ -3385,4 +3385,4 @@ export {
3385
3385
  QtiVariable,
3386
3386
  qtiProcessingElements
3387
3387
  };
3388
- //# sourceMappingURL=chunk-UDJ7MHLF.js.map
3388
+ //# sourceMappingURL=chunk-3FQZRJFH.js.map
@@ -11,7 +11,7 @@ import {
11
11
  computedItemContext,
12
12
  configContext,
13
13
  qtiContext
14
- } from "./chunk-NZ7ZC4SP.js";
14
+ } from "./chunk-XBBTYGCX.js";
15
15
 
16
16
  // ../qti-item/dist/components/item-container/item-container.js
17
17
  import { consume } from "@lit/context";
@@ -349,4 +349,4 @@ export {
349
349
  QtiItem,
350
350
  qtiItemElements
351
351
  };
352
- //# sourceMappingURL=chunk-OG5HIRHE.js.map
352
+ //# sourceMappingURL=chunk-4UO6AGJ6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  qtiItemElements
3
- } from "./chunk-OG5HIRHE.js";
3
+ } from "./chunk-4UO6AGJ6.js";
4
4
 
5
5
  // ../qti-item/dist/register.js
6
6
  for (const { tag, ctor } of qtiItemElements) {
@@ -8,4 +8,4 @@ for (const { tag, ctor } of qtiItemElements) {
8
8
  customElements.define(tag, ctor);
9
9
  }
10
10
  }
11
- //# sourceMappingURL=chunk-L7J2ZOJL.js.map
11
+ //# sourceMappingURL=chunk-HSOILZC6.js.map
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-J6VX4N7M.js";
8
8
  import {
9
9
  QtiModalFeedback
10
- } from "./chunk-WGUQCB2Z.js";
10
+ } from "./chunk-MFKH6BZM.js";
11
11
  import {
12
12
  listenPublic
13
13
  } from "./chunk-UCXLDQYA.js";
@@ -31,7 +31,7 @@ import {
31
31
  qtiContext,
32
32
  sessionContext,
33
33
  testContext
34
- } from "./chunk-NZ7ZC4SP.js";
34
+ } from "./chunk-XBBTYGCX.js";
35
35
 
36
36
  // ../qti-test/dist/components/qti-assessment-item-ref/qti-assessment-item-ref.js
37
37
  import { LitElement, nothing as nothing2 } from "lit";
@@ -3941,4 +3941,4 @@ export {
3941
3941
  * Portions Copyright (c) 2013, the Dart project authors.
3942
3942
  *)
3943
3943
  */
3944
- //# sourceMappingURL=chunk-UURHLJVM.js.map
3944
+ //# sourceMappingURL=chunk-JE6X3IZT.js.map
@@ -15,7 +15,7 @@ import {
15
15
  itemContext,
16
16
  itemContextVariables,
17
17
  readRecordFieldValues
18
- } from "./chunk-NZ7ZC4SP.js";
18
+ } from "./chunk-XBBTYGCX.js";
19
19
 
20
20
  // ../qti-elements/dist/components/qti-assessment-item/qti-assessment-item.js
21
21
  import { provide } from "@lit/context";
@@ -1828,4 +1828,4 @@ export {
1828
1828
  QtiTemplateProcessing,
1829
1829
  qtiContentElements
1830
1830
  };
1831
- //# sourceMappingURL=chunk-WGUQCB2Z.js.map
1831
+ //# sourceMappingURL=chunk-MFKH6BZM.js.map
@@ -19,7 +19,7 @@ import {
19
19
  serializeResponseAttribute,
20
20
  setState,
21
21
  validationMessage
22
- } from "./chunk-NZ7ZC4SP.js";
22
+ } from "./chunk-XBBTYGCX.js";
23
23
 
24
24
  // ../interactions/core/dist/elements/qti-associable-hotspot/qti-associable-hotspot.js
25
25
  import { LitElement, html } from "lit";
@@ -8004,7 +8004,7 @@ var QtiInlineChoiceInteraction = class extends MenuAutoSizeMixin(Interaction) {
8004
8004
  const hasSelection = selectedOption ? selectedOption.value !== "" : false;
8005
8005
  const answerDemanded = this.required || this.minChoices >= 1;
8006
8006
  const isValid = hasSelection || !answerDemanded;
8007
- const validityMessage = this.dataset.minChoicesMessage || "Please select an option.";
8007
+ const validityMessage = this.dataset.minSelectionsMessage || this.dataset.minChoicesMessage || "Please select an option.";
8008
8008
  this.setInteractionValidity(isValid, isValid ? "" : validityMessage, this, { suppressInline: true, kind: "min" });
8009
8009
  return isValid;
8010
8010
  }
@@ -9769,6 +9769,11 @@ var QtiPortableCustomInteraction = class extends Interaction {
9769
9769
  };
9770
9770
  const iframeName = `qti-pci-${this.responseIdentifier}-${Date.now()}`;
9771
9771
  this.iframe.name = iframeName;
9772
+ const { sandbox, allow } = this.configContext?.pciIframe ?? {};
9773
+ if (sandbox !== void 0)
9774
+ this.iframe.setAttribute("sandbox", sandbox);
9775
+ if (allow)
9776
+ this.iframe.setAttribute("allow", allow);
9772
9777
  const iframeContent = this.generateIframeContent();
9773
9778
  this.iframe.srcdoc = iframeContent;
9774
9779
  this.appendChild(this.iframe);
@@ -12809,4 +12814,4 @@ export {
12809
12814
  elements31 as elements21,
12810
12815
  qtiInteractionElements
12811
12816
  };
12812
- //# sourceMappingURL=chunk-DUKQ53E7.js.map
12817
+ //# sourceMappingURL=chunk-MXY66QOH.js.map