@pie-element/math-inline 13.0.3-next.20261007201108 → 13.0.3-next.20261007204357

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.
@@ -293,98 +293,95 @@ var W = class extends n.Component {
293
293
  j && /* @__PURE__ */ x(ce, { children: /* @__PURE__ */ x(M, { prompt: j }) }),
294
294
  ge ? _e : /* @__PURE__ */ x(te, {
295
295
  false: !0,
296
- children: /* @__PURE__ */ S(fe, {
297
- tabIndex: 0,
298
- children: [F === e.simple && /* @__PURE__ */ x(t, {
299
- onSimpleResponseChange: this.onSimpleResponseChange,
300
- showCorrect: i,
301
- emptyResponse: H,
302
- model: n,
303
- session: a,
304
- onSubFieldFocus: this.onSubFieldFocus,
305
- showKeypad: !!r
306
- }), F === e.advanced && /* @__PURE__ */ x(de, {
307
- ref: s,
308
- isIncorrect: !H && !Y && !i,
309
- isCorrect: !H && (Y || i),
310
- showCorrectness: !H && d && u && !p,
311
- correctAnswerShown: i,
312
- printCorrect: C && w,
313
- children: /* @__PURE__ */ x(T, {
314
- ref: (e) => this.setTooltipRef(e),
315
- enterTouchDelay: 0,
316
- interactive: !0,
317
- open: !!r,
318
- slotProps: {
319
- popper: {
320
- container: s?.current || void 0,
321
- placement: "bottom-start",
322
- sx: {
323
- backgroundColor: "transparent",
324
- width: "650px",
325
- opacity: 1,
326
- "& .MuiTooltip-arrow": { display: "none" }
296
+ children: /* @__PURE__ */ S(fe, { children: [F === e.simple && /* @__PURE__ */ x(t, {
297
+ onSimpleResponseChange: this.onSimpleResponseChange,
298
+ showCorrect: i,
299
+ emptyResponse: H,
300
+ model: n,
301
+ session: a,
302
+ onSubFieldFocus: this.onSubFieldFocus,
303
+ showKeypad: !!r
304
+ }), F === e.advanced && /* @__PURE__ */ x(de, {
305
+ ref: s,
306
+ isIncorrect: !H && !Y && !i,
307
+ isCorrect: !H && (Y || i),
308
+ showCorrectness: !H && d && u && !p,
309
+ correctAnswerShown: i,
310
+ printCorrect: C && w,
311
+ children: /* @__PURE__ */ x(T, {
312
+ ref: (e) => this.setTooltipRef(e),
313
+ enterTouchDelay: 0,
314
+ interactive: !0,
315
+ open: !!r,
316
+ slotProps: {
317
+ popper: {
318
+ container: s?.current || void 0,
319
+ placement: "bottom-start",
320
+ sx: {
321
+ backgroundColor: "transparent",
322
+ width: "650px",
323
+ opacity: 1,
324
+ "& .MuiTooltip-arrow": { display: "none" }
325
+ },
326
+ modifiers: [
327
+ {
328
+ name: "offset",
329
+ options: { offset: [0, 8] }
327
330
  },
328
- modifiers: [
329
- {
330
- name: "offset",
331
- options: { offset: [0, 8] }
332
- },
333
- {
334
- name: "preventOverflow",
335
- enabled: !0,
336
- options: {
337
- boundary: "viewport",
338
- padding: 8
339
- }
340
- },
341
- {
342
- name: "computeStyles",
343
- options: {
344
- adaptive: !0,
345
- gpuAcceleration: !0
346
- }
347
- },
348
- {
349
- name: "flip",
350
- enabled: !1
331
+ {
332
+ name: "preventOverflow",
333
+ enabled: !0,
334
+ options: {
335
+ boundary: "viewport",
336
+ padding: 8
351
337
  }
352
- ]
353
- },
354
- tooltip: { sx: {
355
- fontSize: "initial",
356
- backgroundColor: "transparent",
357
- width: "600px",
358
- marginTop: 0,
359
- paddingTop: 0,
360
- boxShadow: "none"
361
- } }
338
+ },
339
+ {
340
+ name: "computeStyles",
341
+ options: {
342
+ adaptive: !0,
343
+ gpuAcceleration: !0
344
+ }
345
+ },
346
+ {
347
+ name: "flip",
348
+ enabled: !1
349
+ }
350
+ ]
362
351
  },
363
- title: Object.keys(a.answers).map((e) => e === r && !(i || d) && /* @__PURE__ */ x(ue, {
364
- "data-keypad": !0,
365
- style: { width: ae(G, I) },
366
- children: /* @__PURE__ */ x(o, {
367
- additionalKeys: G,
368
- mode: I || re,
369
- onClick: this.onClick
370
- })
371
- }, e) || null),
372
- children: /* @__PURE__ */ x("div", { children: /* @__PURE__ */ x(c.Static, {
373
- className: "static-math",
374
- ref: (e) => {
375
- e && (this.mqStatic = e);
376
- },
377
- latex: X,
378
- language: E,
379
- onSubFieldChange: this.subFieldChanged,
380
- getFieldName: this.getFieldName,
381
- setInput: this.setInput,
382
- onSubFieldFocus: this.onSubFieldFocus,
383
- onBlur: this.onBlur
384
- }) })
385
- })
386
- })]
387
- })
352
+ tooltip: { sx: {
353
+ fontSize: "initial",
354
+ backgroundColor: "transparent",
355
+ width: "600px",
356
+ marginTop: 0,
357
+ paddingTop: 0,
358
+ boxShadow: "none"
359
+ } }
360
+ },
361
+ title: Object.keys(a.answers).map((e) => e === r && !(i || d) && /* @__PURE__ */ x(ue, {
362
+ "data-keypad": !0,
363
+ style: { width: ae(G, I) },
364
+ children: /* @__PURE__ */ x(o, {
365
+ additionalKeys: G,
366
+ mode: I || re,
367
+ onClick: this.onClick
368
+ })
369
+ }, e) || null),
370
+ children: /* @__PURE__ */ x("div", { children: /* @__PURE__ */ x(c.Static, {
371
+ className: "static-math",
372
+ ref: (e) => {
373
+ e && (this.mqStatic = e);
374
+ },
375
+ latex: X,
376
+ language: E,
377
+ onSubFieldChange: this.subFieldChanged,
378
+ getFieldName: this.getFieldName,
379
+ setInput: this.setInput,
380
+ onSubFieldFocus: this.onSubFieldFocus,
381
+ onBlur: this.onBlur
382
+ }) })
383
+ })
384
+ })] })
388
385
  }),
389
386
  Z && V && /* @__PURE__ */ x(le, { dangerouslySetInnerHTML: { __html: `<strong>Note:</strong> ${O(A)}` } }),
390
387
  Z && Q && (v ? /* @__PURE__ */ x("div", { dangerouslySetInnerHTML: { __html: O(h) } }) : /* @__PURE__ */ x(N, {
@@ -216,7 +216,7 @@ mid `,`&#8740;`),Z.intercal=Z[`⊺`]=q($,`\\intercal `,`&#8890;`),Z.veebar=Z[`
216
216
  <div class="${t.blockMath}">
217
217
  <span data-answer-block="${e}"></span>
218
218
  </div>
219
- </div>`,text:()=>`text`,latex:()=>`\\embed{answerBlock}[${e}]`}}),!0))}handleAnswerBlockDomUpdate=()=>{let{model:e}=this.props,{session:t,showCorrect:n}=this.state,r=t.answers;this.root&&e.disabled&&!n&&Object.keys(r).forEach(t=>{let n=this.root.querySelector(`[data-answer-block="${t}"]`),i=this.root.querySelector(`[data-answer-block-index="${t}"]`);if(n){let a=r[t];FE(n,a&&a.value||``),e.view&&(n.parentElement.parentElement.classList.remove(`correct`),n.parentElement.parentElement.classList.remove(`incorrect`)),i.textContent=`R`}}),J_(this.root)};countResponseOccurrences(e){let t=e?.match(/\{\{response\}\}/g);return t?t.length:0}UNSAFE_componentWillReceiveProps(e){let{config:t}=this.props.model,{config:n={}}=e.model||{},{session:r}=this.props,{session:i={}}=e||{};if(r&&i&&!cS(r.answers,i.answers)&&this.setState({session:{...i,answers:Yj(i,this.props.model)}}),t.note&&t.language&&t.language!==n.language&&t.note===zj.t(`mathInline.primaryCorrectWithAlternates`,{lng:t.language})&&(t.note=zj.t(`mathInline.primaryCorrectWithAlternates`,{lng:n.language})),(t.env&&t.env.mode!==`evaluate`||n.env&&n.env.mode!==`evaluate`)&&this.setState({...this.state.session,showCorrect:!1}),n.alwaysShowCorrect&&this.setState({showCorrect:!0}),this.countResponseOccurrences(t.expression)<this.countResponseOccurrences(n.expression)&&setTimeout(()=>this.updateAria(),100),t&&t.responses&&t.responses.length!==n.responses.length||!t&&n&&n.responses||t&&n&&t.expression!==n.expression){let e={},t=this.state.session.answers,r=1;(n.expression||``).replace(Hj,()=>{e[`r${r}`]={value:t&&t[`r${r}`]&&t[`r${r}`].value||``},r++}),this.setState(t=>({session:{...t.session,completeAnswer:this.mqStatic&&this.mqStatic.mathField.latex(),answers:e}}),this.handleAnswerBlockDomUpdate)}}shouldComponentUpdate(e,t){let n=cS(this.props.model,e.model),r=cS(this.state,t);return!n||!r}componentDidMount(){this.handleAnswerBlockDomUpdate(),this.updateAria(),setTimeout(()=>J_(this.root),100)}componentDidUpdate(e,t){this.handleAnswerBlockDomUpdate(),(e.model?.config?.responseType!==this.props.model?.config?.responseType||e.model?.language!==this.props.model?.language)&&this.updateAria()}updateAria=()=>{if(this.root){this.root.querySelectorAll(`.mq-selectable`).forEach(e=>e.setAttribute(`aria-hidden`,`true`));let e=zj.t(`mathInline.keypadInstructions`,{lng:this.props.model?.language});this.root.querySelectorAll(`textarea`).forEach((t,n)=>{let r=`${this.instructionsIdPrefix}-${n}`,i=t.closest(`.mq-textarea`);if(i){let n=i.querySelector(`#${r}`);n||(n=document.createElement(`span`),n.id=r,n.className=`sr-only`,i.insertBefore(n,t)),n.textContent=e,t.setAttribute(`aria-describedby`,r)}})}};focusFirstKeypadElement=()=>{setTimeout(()=>{let e=document.querySelector(`[data-keypad]`);if(e){let t=e.querySelector(`button, [role='button']`);t&&t.focus()}},0)};handleKeyDown=(e,t)=>{let n=Kj(e.target,this.root),r=this.mqStatic&&this.mqStatic.inputRef?.current?this.mqStatic.inputRef?.current.contains(document.activeElement):!!document.activeElement?.closest(`.mq-editable-field`),{key:i,type:a}=e;r&&(i===`ArrowDown`||a===`click`||a===`touchstart`)?this.state.activeAnswerBlock!==t&&n&&(this.cleanupKeyDownListener(),this.setState({activeAnswerBlock:t},()=>{this.onSubFieldFocus(t),i===`ArrowDown`&&this.focusFirstKeypadElement()})):e.key===`Escape`&&this.setState({activeAnswerBlock:``})};onSubFieldFocus=e=>{this.handleEvent||(this.handleEvent=t=>{this.handleKeyDown(t,e)},document.addEventListener(`keydown`,this.handleEvent),document.addEventListener(`click`,this.handleEvent),document.addEventListener(`touchstart`,this.handleEvent))};cleanupKeyDownListener=()=>{this.handleEvent&&=(document.removeEventListener(`keydown`,this.handleEvent),document.removeEventListener(`click`,this.handleEvent),document.removeEventListener(`touchstart`,this.handleEvent),null)};componentWillUnmount(){this.cleanupKeyDownListener&&this.cleanupKeyDownListener()}onDone=()=>{};onSimpleResponseChange=e=>{this.setState(t=>({session:{...t.session,response:e}}),this.callOnSessionChange)};toNodeData=e=>{if(!e)return;let{type:t,value:n}=e;return t===`command`||t===`cursor`?e:t===`answer`?{type:`answer`,...e}:n===`clear`?{type:`clear`}:{type:`write`,value:n}};setInput=e=>{this.input=e};onClick=e=>{let t=window.scrollX,n=window.scrollY,r=this.toNodeData(e);r.type===`clear`?this.input.clear():r.type===`command`?Array.isArray(r.value)?r.value.forEach(e=>{this.input.cmd(e)}):this.input.cmd(r.value):r.type===`cursor`?this.input.keystroke(r.value):this.input.write(r.value),this.input.focus(),requestAnimationFrame(()=>{window.scrollTo(t,n),requestAnimationFrame(()=>window.scrollTo(t,n))})};callOnSessionChange=()=>{let{onSessionChange:e}=this.props;e&&e(this.state.session)};toggleShowCorrect=e=>{this.setState({showCorrect:e},this.handleAnswerBlockDomUpdate)};subFieldChanged=(e,t)=>{if(xw(),e){let n=window.scrollX,r=window.scrollY;this.setState(n=>({session:{...n.session,completeAnswer:this.mqStatic&&this.mqStatic.mathField.latex(),answers:{...n.session.answers,[e]:{value:t}}}}),()=>{this.callOnSessionChange(),requestAnimationFrame(()=>{window.scrollTo(n,r)})})}};getFieldName=(e,t)=>{let{answers:n}=this.state.session;if(Object.keys(n||{}).length)return Object.keys(n).find(n=>{let r=t[n];return r&&r.id==e.id})};onBlur=e=>{let{relatedTarget:t,currentTarget:n}=e||{},r=n&&n.closest(`[role=tooltip]`);function i(e,t=0){if(!e||t>=16)return null;let n=e.offsetParent;return n?n.getAttribute(`role`)===`tooltip`?n:i(n,t+1):null}function a(e,t=0){if(!e||t>=4)return null;let n=e?.children?.[0];return n?n.attributes&&n.attributes[`data-keypad`]?n:a(n,t+1):null}let o=i(t),s=o?a(o):null;(!t||!n||!s?.attributes[`data-keypad`])&&(r||this.setState({activeAnswerBlock:``}))};setTooltipRef(e){setTimeout(()=>{if(e&&Wj){let e=document.querySelector(`[role='tooltip']`);e&&e.firstChild.setAttribute(`tabindex`,`-1`)}},1)}render(){let{model:e}=this.props,{activeAnswerBlock:t,showCorrect:n,session:r,tooltipContainerRef:i}=this.state,{config:a,correctness:o,disabled:s,extraCSSRules:c,view:l,teacherInstructions:u,rationale:d,feedback:f,animationsDisabled:p,printMode:m,alwaysShowCorrect:h,language:g}=e||{};if(!a)return null;let{showNote:_,note:v,prompt:y,responses:b,responseType:x,equationEditor:S,customKeys:C,env:{mode:w,role:T}={}}=a||{},E=(n||w===`view`&&T===`instructor`)&&_&&v,D=sS(b),O=!D&&o&&o.correctness!==`correct`,ee=s&&o,k=Gj(C),A=o&&o.correct,j=Jj(e,this.state)||``,te=s&&!o,M=m&&!h,ne=d&&(Uy(d)||Gy(d)),N=u&&(Uy(u)||Gy(u)),re=(0,z.jsx)(sM,{children:(0,z.jsx)(QE,{className:`static-math`,ref:e=>{e&&(this.mqStatic=e)},latex:j,language:g,onSubFieldChange:this.subFieldChanged,getFieldName:this.getFieldName,setInput:this.setInput,onSubFieldFocus:this.onSubFieldFocus,onBlur:this.onBlur})}),ie=(0,z.jsxs)(tM,{children:[w===`gather`&&(0,z.jsx)(cM,{children:zj.t(`mathInline.mathEquationResponseQuestion`,{lng:g})}),te&&N&&(p?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(u)}}):(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showTeacherInstructions`,{lng:g}),visible:zj.t(`common:hideTeacherInstructions`,{lng:g})},children:(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(u)}})})),y&&(0,z.jsx)(eM,{children:(0,z.jsx)(Mj,{prompt:y})}),M?re:(0,z.jsx)(Nj,{false:!0,children:(0,z.jsxs)(oM,{tabIndex:0,children:[x===kk.simple&&(0,z.jsx)(Oj,{onSimpleResponseChange:this.onSimpleResponseChange,showCorrect:n,emptyResponse:D,model:e,session:r,onSubFieldFocus:this.onSubFieldFocus,showKeypad:!!t}),x===kk.advanced&&(0,z.jsx)(aM,{ref:i,isIncorrect:!D&&!A&&!n,isCorrect:!D&&(A||n),showCorrectness:!D&&s&&o&&!l,correctAnswerShown:n,printCorrect:m&&h,children:(0,z.jsx)(Ok,{ref:e=>this.setTooltipRef(e),enterTouchDelay:0,interactive:!0,open:!!t,slotProps:{popper:{container:i?.current||void 0,placement:`bottom-start`,sx:{backgroundColor:`transparent`,width:`650px`,opacity:1,"& .MuiTooltip-arrow":{display:`none`}},modifiers:[{name:`offset`,options:{offset:[0,8]}},{name:`preventOverflow`,enabled:!0,options:{boundary:`viewport`,padding:8}},{name:`computeStyles`,options:{adaptive:!0,gpuAcceleration:!0}},{name:`flip`,enabled:!1}]},tooltip:{sx:{fontSize:`initial`,backgroundColor:`transparent`,width:`600px`,marginTop:0,paddingTop:0,boxShadow:`none`}}},title:Object.keys(r.answers).map(e=>e===t&&!(n||s)&&(0,z.jsx)(iM,{"data-keypad":!0,style:{width:qj(k,S)},children:(0,z.jsx)(pD,{additionalKeys:k,mode:S||Uj,onClick:this.onClick})},e)||null),children:(0,z.jsx)(`div`,{children:(0,z.jsx)(QE,{className:`static-math`,ref:e=>{e&&(this.mqStatic=e)},latex:j,language:g,onSubFieldChange:this.subFieldChanged,getFieldName:this.getFieldName,setInput:this.setInput,onSubFieldFocus:this.onSubFieldFocus,onBlur:this.onBlur})})})})]})}),te&&E&&(0,z.jsx)(nM,{dangerouslySetInnerHTML:{__html:`<strong>Note:</strong> ${cp(v)}`}}),te&&ne&&(p?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(d)}}):(0,z.jsx)(Pj,{labels:{hidden:zj.t(`common:showRationale`,{lng:g}),visible:zj.t(`common:hideRationale`,{lng:g})},children:(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(d)}})}))]});return ee&&(O||N||ne||f)?(0,z.jsx)(Qj,{extraCSSRules:c,ref:e=>{let t=Zs.findDOMNode(e);this.root=t||this.root},children:(0,z.jsx)($j,{interactive:!0,enterTouchDelay:0,placement:`bottom-start`,slotProps:{tooltip:{sx:e=>({background:`${Dp()} !important`,color:pp(),padding:e.spacing(2),border:`1px solid ${jp()}`,fontSize:`16px`,"& :not(.MathJax) > table tr":{"&:nth-child(2n)":{backgroundColor:`unset !important`}}})},popper:{sx:{opacity:1},modifiers:[{name:`offset`,options:{offset:[0,2]}}]}},title:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(tM,{children:O&&(0,z.jsx)(lM,{language:g,show:!0,toggled:n,onToggle:this.toggleShowCorrect})}),N&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showTeacherInstructions`,{lng:g}),visible:zj.t(`common:hideTeacherInstructions`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:u})},`collapsible-teacher-instructions`),E&&Uy(v)&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showNote`,{lng:g}),visible:zj.t(`common:hideNote`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:v})},`collapsible-note`),ne&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showRationale`,{lng:g}),visible:zj.t(`common:hideRationale`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:d})},`collapsible-rationale`),f&&(0,z.jsx)(Fj,{correctness:o.correctness,feedback:f})]}),children:ie})}):(0,z.jsx)(Qj,{extraCSSRules:c,ref:e=>{let t=Zs.findDOMNode(e);this.root=t||this.root},children:ie})}},Zj=()=>({blockContainer:`block-container`,blockResponse:`block-response`,blockMath:`block-math`});if(typeof document<`u`){let e=`math-inline-block-styles`;if(!document.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.textContent=`
219
+ </div>`,text:()=>`text`,latex:()=>`\\embed{answerBlock}[${e}]`}}),!0))}handleAnswerBlockDomUpdate=()=>{let{model:e}=this.props,{session:t,showCorrect:n}=this.state,r=t.answers;this.root&&e.disabled&&!n&&Object.keys(r).forEach(t=>{let n=this.root.querySelector(`[data-answer-block="${t}"]`),i=this.root.querySelector(`[data-answer-block-index="${t}"]`);if(n){let a=r[t];FE(n,a&&a.value||``),e.view&&(n.parentElement.parentElement.classList.remove(`correct`),n.parentElement.parentElement.classList.remove(`incorrect`)),i.textContent=`R`}}),J_(this.root)};countResponseOccurrences(e){let t=e?.match(/\{\{response\}\}/g);return t?t.length:0}UNSAFE_componentWillReceiveProps(e){let{config:t}=this.props.model,{config:n={}}=e.model||{},{session:r}=this.props,{session:i={}}=e||{};if(r&&i&&!cS(r.answers,i.answers)&&this.setState({session:{...i,answers:Yj(i,this.props.model)}}),t.note&&t.language&&t.language!==n.language&&t.note===zj.t(`mathInline.primaryCorrectWithAlternates`,{lng:t.language})&&(t.note=zj.t(`mathInline.primaryCorrectWithAlternates`,{lng:n.language})),(t.env&&t.env.mode!==`evaluate`||n.env&&n.env.mode!==`evaluate`)&&this.setState({...this.state.session,showCorrect:!1}),n.alwaysShowCorrect&&this.setState({showCorrect:!0}),this.countResponseOccurrences(t.expression)<this.countResponseOccurrences(n.expression)&&setTimeout(()=>this.updateAria(),100),t&&t.responses&&t.responses.length!==n.responses.length||!t&&n&&n.responses||t&&n&&t.expression!==n.expression){let e={},t=this.state.session.answers,r=1;(n.expression||``).replace(Hj,()=>{e[`r${r}`]={value:t&&t[`r${r}`]&&t[`r${r}`].value||``},r++}),this.setState(t=>({session:{...t.session,completeAnswer:this.mqStatic&&this.mqStatic.mathField.latex(),answers:e}}),this.handleAnswerBlockDomUpdate)}}shouldComponentUpdate(e,t){let n=cS(this.props.model,e.model),r=cS(this.state,t);return!n||!r}componentDidMount(){this.handleAnswerBlockDomUpdate(),this.updateAria(),setTimeout(()=>J_(this.root),100)}componentDidUpdate(e,t){this.handleAnswerBlockDomUpdate(),(e.model?.config?.responseType!==this.props.model?.config?.responseType||e.model?.language!==this.props.model?.language)&&this.updateAria()}updateAria=()=>{if(this.root){this.root.querySelectorAll(`.mq-selectable`).forEach(e=>e.setAttribute(`aria-hidden`,`true`));let e=zj.t(`mathInline.keypadInstructions`,{lng:this.props.model?.language});this.root.querySelectorAll(`textarea`).forEach((t,n)=>{let r=`${this.instructionsIdPrefix}-${n}`,i=t.closest(`.mq-textarea`);if(i){let n=i.querySelector(`#${r}`);n||(n=document.createElement(`span`),n.id=r,n.className=`sr-only`,i.insertBefore(n,t)),n.textContent=e,t.setAttribute(`aria-describedby`,r)}})}};focusFirstKeypadElement=()=>{setTimeout(()=>{let e=document.querySelector(`[data-keypad]`);if(e){let t=e.querySelector(`button, [role='button']`);t&&t.focus()}},0)};handleKeyDown=(e,t)=>{let n=Kj(e.target,this.root),r=this.mqStatic&&this.mqStatic.inputRef?.current?this.mqStatic.inputRef?.current.contains(document.activeElement):!!document.activeElement?.closest(`.mq-editable-field`),{key:i,type:a}=e;r&&(i===`ArrowDown`||a===`click`||a===`touchstart`)?this.state.activeAnswerBlock!==t&&n&&(this.cleanupKeyDownListener(),this.setState({activeAnswerBlock:t},()=>{this.onSubFieldFocus(t),i===`ArrowDown`&&this.focusFirstKeypadElement()})):e.key===`Escape`&&this.setState({activeAnswerBlock:``})};onSubFieldFocus=e=>{this.handleEvent||(this.handleEvent=t=>{this.handleKeyDown(t,e)},document.addEventListener(`keydown`,this.handleEvent),document.addEventListener(`click`,this.handleEvent),document.addEventListener(`touchstart`,this.handleEvent))};cleanupKeyDownListener=()=>{this.handleEvent&&=(document.removeEventListener(`keydown`,this.handleEvent),document.removeEventListener(`click`,this.handleEvent),document.removeEventListener(`touchstart`,this.handleEvent),null)};componentWillUnmount(){this.cleanupKeyDownListener&&this.cleanupKeyDownListener()}onDone=()=>{};onSimpleResponseChange=e=>{this.setState(t=>({session:{...t.session,response:e}}),this.callOnSessionChange)};toNodeData=e=>{if(!e)return;let{type:t,value:n}=e;return t===`command`||t===`cursor`?e:t===`answer`?{type:`answer`,...e}:n===`clear`?{type:`clear`}:{type:`write`,value:n}};setInput=e=>{this.input=e};onClick=e=>{let t=window.scrollX,n=window.scrollY,r=this.toNodeData(e);r.type===`clear`?this.input.clear():r.type===`command`?Array.isArray(r.value)?r.value.forEach(e=>{this.input.cmd(e)}):this.input.cmd(r.value):r.type===`cursor`?this.input.keystroke(r.value):this.input.write(r.value),this.input.focus(),requestAnimationFrame(()=>{window.scrollTo(t,n),requestAnimationFrame(()=>window.scrollTo(t,n))})};callOnSessionChange=()=>{let{onSessionChange:e}=this.props;e&&e(this.state.session)};toggleShowCorrect=e=>{this.setState({showCorrect:e},this.handleAnswerBlockDomUpdate)};subFieldChanged=(e,t)=>{if(xw(),e){let n=window.scrollX,r=window.scrollY;this.setState(n=>({session:{...n.session,completeAnswer:this.mqStatic&&this.mqStatic.mathField.latex(),answers:{...n.session.answers,[e]:{value:t}}}}),()=>{this.callOnSessionChange(),requestAnimationFrame(()=>{window.scrollTo(n,r)})})}};getFieldName=(e,t)=>{let{answers:n}=this.state.session;if(Object.keys(n||{}).length)return Object.keys(n).find(n=>{let r=t[n];return r&&r.id==e.id})};onBlur=e=>{let{relatedTarget:t,currentTarget:n}=e||{},r=n&&n.closest(`[role=tooltip]`);function i(e,t=0){if(!e||t>=16)return null;let n=e.offsetParent;return n?n.getAttribute(`role`)===`tooltip`?n:i(n,t+1):null}function a(e,t=0){if(!e||t>=4)return null;let n=e?.children?.[0];return n?n.attributes&&n.attributes[`data-keypad`]?n:a(n,t+1):null}let o=i(t),s=o?a(o):null;(!t||!n||!s?.attributes[`data-keypad`])&&(r||this.setState({activeAnswerBlock:``}))};setTooltipRef(e){setTimeout(()=>{if(e&&Wj){let e=document.querySelector(`[role='tooltip']`);e&&e.firstChild.setAttribute(`tabindex`,`-1`)}},1)}render(){let{model:e}=this.props,{activeAnswerBlock:t,showCorrect:n,session:r,tooltipContainerRef:i}=this.state,{config:a,correctness:o,disabled:s,extraCSSRules:c,view:l,teacherInstructions:u,rationale:d,feedback:f,animationsDisabled:p,printMode:m,alwaysShowCorrect:h,language:g}=e||{};if(!a)return null;let{showNote:_,note:v,prompt:y,responses:b,responseType:x,equationEditor:S,customKeys:C,env:{mode:w,role:T}={}}=a||{},E=(n||w===`view`&&T===`instructor`)&&_&&v,D=sS(b),O=!D&&o&&o.correctness!==`correct`,ee=s&&o,k=Gj(C),A=o&&o.correct,j=Jj(e,this.state)||``,te=s&&!o,M=m&&!h,ne=d&&(Uy(d)||Gy(d)),N=u&&(Uy(u)||Gy(u)),re=(0,z.jsx)(sM,{children:(0,z.jsx)(QE,{className:`static-math`,ref:e=>{e&&(this.mqStatic=e)},latex:j,language:g,onSubFieldChange:this.subFieldChanged,getFieldName:this.getFieldName,setInput:this.setInput,onSubFieldFocus:this.onSubFieldFocus,onBlur:this.onBlur})}),ie=(0,z.jsxs)(tM,{children:[w===`gather`&&(0,z.jsx)(cM,{children:zj.t(`mathInline.mathEquationResponseQuestion`,{lng:g})}),te&&N&&(p?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(u)}}):(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showTeacherInstructions`,{lng:g}),visible:zj.t(`common:hideTeacherInstructions`,{lng:g})},children:(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(u)}})})),y&&(0,z.jsx)(eM,{children:(0,z.jsx)(Mj,{prompt:y})}),M?re:(0,z.jsx)(Nj,{false:!0,children:(0,z.jsxs)(oM,{children:[x===kk.simple&&(0,z.jsx)(Oj,{onSimpleResponseChange:this.onSimpleResponseChange,showCorrect:n,emptyResponse:D,model:e,session:r,onSubFieldFocus:this.onSubFieldFocus,showKeypad:!!t}),x===kk.advanced&&(0,z.jsx)(aM,{ref:i,isIncorrect:!D&&!A&&!n,isCorrect:!D&&(A||n),showCorrectness:!D&&s&&o&&!l,correctAnswerShown:n,printCorrect:m&&h,children:(0,z.jsx)(Ok,{ref:e=>this.setTooltipRef(e),enterTouchDelay:0,interactive:!0,open:!!t,slotProps:{popper:{container:i?.current||void 0,placement:`bottom-start`,sx:{backgroundColor:`transparent`,width:`650px`,opacity:1,"& .MuiTooltip-arrow":{display:`none`}},modifiers:[{name:`offset`,options:{offset:[0,8]}},{name:`preventOverflow`,enabled:!0,options:{boundary:`viewport`,padding:8}},{name:`computeStyles`,options:{adaptive:!0,gpuAcceleration:!0}},{name:`flip`,enabled:!1}]},tooltip:{sx:{fontSize:`initial`,backgroundColor:`transparent`,width:`600px`,marginTop:0,paddingTop:0,boxShadow:`none`}}},title:Object.keys(r.answers).map(e=>e===t&&!(n||s)&&(0,z.jsx)(iM,{"data-keypad":!0,style:{width:qj(k,S)},children:(0,z.jsx)(pD,{additionalKeys:k,mode:S||Uj,onClick:this.onClick})},e)||null),children:(0,z.jsx)(`div`,{children:(0,z.jsx)(QE,{className:`static-math`,ref:e=>{e&&(this.mqStatic=e)},latex:j,language:g,onSubFieldChange:this.subFieldChanged,getFieldName:this.getFieldName,setInput:this.setInput,onSubFieldFocus:this.onSubFieldFocus,onBlur:this.onBlur})})})})]})}),te&&E&&(0,z.jsx)(nM,{dangerouslySetInnerHTML:{__html:`<strong>Note:</strong> ${cp(v)}`}}),te&&ne&&(p?(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(d)}}):(0,z.jsx)(Pj,{labels:{hidden:zj.t(`common:showRationale`,{lng:g}),visible:zj.t(`common:hideRationale`,{lng:g})},children:(0,z.jsx)(`div`,{dangerouslySetInnerHTML:{__html:cp(d)}})}))]});return ee&&(O||N||ne||f)?(0,z.jsx)(Qj,{extraCSSRules:c,ref:e=>{let t=Zs.findDOMNode(e);this.root=t||this.root},children:(0,z.jsx)($j,{interactive:!0,enterTouchDelay:0,placement:`bottom-start`,slotProps:{tooltip:{sx:e=>({background:`${Dp()} !important`,color:pp(),padding:e.spacing(2),border:`1px solid ${jp()}`,fontSize:`16px`,"& :not(.MathJax) > table tr":{"&:nth-child(2n)":{backgroundColor:`unset !important`}}})},popper:{sx:{opacity:1},modifiers:[{name:`offset`,options:{offset:[0,2]}}]}},title:(0,z.jsxs)(`div`,{children:[(0,z.jsx)(tM,{children:O&&(0,z.jsx)(lM,{language:g,show:!0,toggled:n,onToggle:this.toggleShowCorrect})}),N&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showTeacherInstructions`,{lng:g}),visible:zj.t(`common:hideTeacherInstructions`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:u})},`collapsible-teacher-instructions`),E&&Uy(v)&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showNote`,{lng:g}),visible:zj.t(`common:hideNote`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:v})},`collapsible-note`),ne&&(0,z.jsx)(rM,{labels:{hidden:zj.t(`common:showRationale`,{lng:g}),visible:zj.t(`common:hideRationale`,{lng:g})},children:(0,z.jsx)(Mj,{prompt:d})},`collapsible-rationale`),f&&(0,z.jsx)(Fj,{correctness:o.correctness,feedback:f})]}),children:ie})}):(0,z.jsx)(Qj,{extraCSSRules:c,ref:e=>{let t=Zs.findDOMNode(e);this.root=t||this.root},children:ie})}},Zj=()=>({blockContainer:`block-container`,blockResponse:`block-response`,blockMath:`block-math`});if(typeof document<`u`){let e=`math-inline-block-styles`;if(!document.getElementById(e)){let t=document.createElement(`style`);t.id=e,t.textContent=`
220
220
  .block-container {
221
221
  margin: 8px !important;
222
222
  display: inline-flex;
package/module/print.js CHANGED
@@ -27932,98 +27932,95 @@ var Gj = class extends _.Component {
27932
27932
  y && /* @__PURE__ */ (0, R.jsx)(Yj, { children: /* @__PURE__ */ (0, R.jsx)(Dj, { prompt: y }) }),
27933
27933
  N ? F : /* @__PURE__ */ (0, R.jsx)(Oj, {
27934
27934
  false: !0,
27935
- children: /* @__PURE__ */ (0, R.jsxs)(tM, {
27936
- tabIndex: 0,
27937
- children: [x === wk.simple && /* @__PURE__ */ (0, R.jsx)(Cj, {
27938
- onSimpleResponseChange: this.onSimpleResponseChange,
27939
- showCorrect: n,
27940
- emptyResponse: D,
27941
- model: e,
27942
- session: r,
27943
- onSubFieldFocus: this.onSubFieldFocus,
27944
- showKeypad: !!t
27945
- }), x === wk.advanced && /* @__PURE__ */ (0, R.jsx)(eM, {
27946
- ref: i,
27947
- isIncorrect: !D && !A && !n,
27948
- isCorrect: !D && (A || n),
27949
- showCorrectness: !D && s && o && !l,
27950
- correctAnswerShown: n,
27951
- printCorrect: m && h,
27952
- children: /* @__PURE__ */ (0, R.jsx)(Ck, {
27953
- ref: (e) => this.setTooltipRef(e),
27954
- enterTouchDelay: 0,
27955
- interactive: !0,
27956
- open: !!t,
27957
- slotProps: {
27958
- popper: {
27959
- container: i?.current || void 0,
27960
- placement: "bottom-start",
27961
- sx: {
27962
- backgroundColor: "transparent",
27963
- width: "650px",
27964
- opacity: 1,
27965
- "& .MuiTooltip-arrow": { display: "none" }
27935
+ children: /* @__PURE__ */ (0, R.jsxs)(tM, { children: [x === wk.simple && /* @__PURE__ */ (0, R.jsx)(Cj, {
27936
+ onSimpleResponseChange: this.onSimpleResponseChange,
27937
+ showCorrect: n,
27938
+ emptyResponse: D,
27939
+ model: e,
27940
+ session: r,
27941
+ onSubFieldFocus: this.onSubFieldFocus,
27942
+ showKeypad: !!t
27943
+ }), x === wk.advanced && /* @__PURE__ */ (0, R.jsx)(eM, {
27944
+ ref: i,
27945
+ isIncorrect: !D && !A && !n,
27946
+ isCorrect: !D && (A || n),
27947
+ showCorrectness: !D && s && o && !l,
27948
+ correctAnswerShown: n,
27949
+ printCorrect: m && h,
27950
+ children: /* @__PURE__ */ (0, R.jsx)(Ck, {
27951
+ ref: (e) => this.setTooltipRef(e),
27952
+ enterTouchDelay: 0,
27953
+ interactive: !0,
27954
+ open: !!t,
27955
+ slotProps: {
27956
+ popper: {
27957
+ container: i?.current || void 0,
27958
+ placement: "bottom-start",
27959
+ sx: {
27960
+ backgroundColor: "transparent",
27961
+ width: "650px",
27962
+ opacity: 1,
27963
+ "& .MuiTooltip-arrow": { display: "none" }
27964
+ },
27965
+ modifiers: [
27966
+ {
27967
+ name: "offset",
27968
+ options: { offset: [0, 8] }
27966
27969
  },
27967
- modifiers: [
27968
- {
27969
- name: "offset",
27970
- options: { offset: [0, 8] }
27971
- },
27972
- {
27973
- name: "preventOverflow",
27974
- enabled: !0,
27975
- options: {
27976
- boundary: "viewport",
27977
- padding: 8
27978
- }
27979
- },
27980
- {
27981
- name: "computeStyles",
27982
- options: {
27983
- adaptive: !0,
27984
- gpuAcceleration: !0
27985
- }
27986
- },
27987
- {
27988
- name: "flip",
27989
- enabled: !1
27970
+ {
27971
+ name: "preventOverflow",
27972
+ enabled: !0,
27973
+ options: {
27974
+ boundary: "viewport",
27975
+ padding: 8
27990
27976
  }
27991
- ]
27992
- },
27993
- tooltip: { sx: {
27994
- fontSize: "initial",
27995
- backgroundColor: "transparent",
27996
- width: "600px",
27997
- marginTop: 0,
27998
- paddingTop: 0,
27999
- boxShadow: "none"
28000
- } }
27977
+ },
27978
+ {
27979
+ name: "computeStyles",
27980
+ options: {
27981
+ adaptive: !0,
27982
+ gpuAcceleration: !0
27983
+ }
27984
+ },
27985
+ {
27986
+ name: "flip",
27987
+ enabled: !1
27988
+ }
27989
+ ]
28001
27990
  },
28002
- title: Object.keys(r.answers).map((e) => e === t && !(n || s) && /* @__PURE__ */ (0, R.jsx)($j, {
28003
- "data-keypad": !0,
28004
- style: { width: Hj(ee, S) },
28005
- children: /* @__PURE__ */ (0, R.jsx)(cD, {
28006
- additionalKeys: ee,
28007
- mode: S || Rj,
28008
- onClick: this.onClick
28009
- })
28010
- }, e) || null),
28011
- children: /* @__PURE__ */ (0, R.jsx)("div", { children: /* @__PURE__ */ (0, R.jsx)(VE.Static, {
28012
- className: "static-math",
28013
- ref: (e) => {
28014
- e && (this.mqStatic = e);
28015
- },
28016
- latex: j,
28017
- language: g,
28018
- onSubFieldChange: this.subFieldChanged,
28019
- getFieldName: this.getFieldName,
28020
- setInput: this.setInput,
28021
- onSubFieldFocus: this.onSubFieldFocus,
28022
- onBlur: this.onBlur
28023
- }) })
28024
- })
28025
- })]
28026
- })
27991
+ tooltip: { sx: {
27992
+ fontSize: "initial",
27993
+ backgroundColor: "transparent",
27994
+ width: "600px",
27995
+ marginTop: 0,
27996
+ paddingTop: 0,
27997
+ boxShadow: "none"
27998
+ } }
27999
+ },
28000
+ title: Object.keys(r.answers).map((e) => e === t && !(n || s) && /* @__PURE__ */ (0, R.jsx)($j, {
28001
+ "data-keypad": !0,
28002
+ style: { width: Hj(ee, S) },
28003
+ children: /* @__PURE__ */ (0, R.jsx)(cD, {
28004
+ additionalKeys: ee,
28005
+ mode: S || Rj,
28006
+ onClick: this.onClick
28007
+ })
28008
+ }, e) || null),
28009
+ children: /* @__PURE__ */ (0, R.jsx)("div", { children: /* @__PURE__ */ (0, R.jsx)(VE.Static, {
28010
+ className: "static-math",
28011
+ ref: (e) => {
28012
+ e && (this.mqStatic = e);
28013
+ },
28014
+ latex: j,
28015
+ language: g,
28016
+ onSubFieldChange: this.subFieldChanged,
28017
+ getFieldName: this.getFieldName,
28018
+ setInput: this.setInput,
28019
+ onSubFieldFocus: this.onSubFieldFocus,
28020
+ onBlur: this.onBlur
28021
+ }) })
28022
+ })
28023
+ })] })
28027
28024
  }),
28028
28025
  M && E && /* @__PURE__ */ (0, R.jsx)(Zj, { dangerouslySetInnerHTML: { __html: `<strong>Note:</strong> ${Bf(v)}` } }),
28029
28026
  M && P && (p ? /* @__PURE__ */ (0, R.jsx)("div", { dangerouslySetInnerHTML: { __html: Bf(d) } }) : /* @__PURE__ */ (0, R.jsx)(kj, {