@pie-element/math-templated 6.0.0-beta.1 → 6.0.0-next.42
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.
- package/configure/package.json +6 -6
- package/controller/package.json +4 -4
- package/module/configure.js +1 -0
- package/module/controller.js +5044 -0
- package/module/demo.js +67 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +22 -0
- package/module/print-demo.js +105 -0
- package/module/print.html +18 -0
- package/package.json +8 -8
package/configure/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"@mui/icons-material": "^7.3.4",
|
|
12
12
|
"@mui/material": "^7.3.4",
|
|
13
13
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
14
|
-
"@pie-lib/config-ui": "12.1.
|
|
15
|
-
"@pie-lib/editable-html-tip-tap": "1.1.
|
|
16
|
-
"@pie-lib/math-toolbar": "2.1.
|
|
17
|
-
"@pie-lib/render-ui": "5.1.
|
|
18
|
-
"debug": "^
|
|
14
|
+
"@pie-lib/config-ui": "12.1.1-next.0",
|
|
15
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
|
|
16
|
+
"@pie-lib/math-toolbar": "2.1.1-next.0",
|
|
17
|
+
"@pie-lib/render-ui": "5.1.1-next.0",
|
|
18
|
+
"debug": "^4.1.1",
|
|
19
19
|
"lodash": "^4.17.15",
|
|
20
|
-
"prop-types": "^15.
|
|
20
|
+
"prop-types": "^15.8.1",
|
|
21
21
|
"react": "18.2.0",
|
|
22
22
|
"react-dom": "18.2.0"
|
|
23
23
|
},
|
package/controller/package.json
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@pie-framework/math-validation": "^1.4.2",
|
|
10
|
-
"@pie-lib/controller-utils": "1.1.
|
|
11
|
-
"@pie-lib/translator": "3.1.
|
|
12
|
-
"debug": "^
|
|
13
|
-
"lodash": "^4.17.
|
|
10
|
+
"@pie-lib/controller-utils": "1.1.1-next.0",
|
|
11
|
+
"@pie-lib/translator": "3.1.1-next.0",
|
|
12
|
+
"debug": "^4.1.1",
|
|
13
|
+
"lodash": "^4.17.23"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"lodash": "^4.17.15"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as a,_dll_mui__material_styles as o,_dll_mui__icons_material as s,_dll_pie_lib__render_ui as i,_dll_lodash as l,_dll_debug as r}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__config_ui as p}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as d}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";import{_dll_pie_lib__math_toolbar as c}from"../../../@pie-lib/math-edit-module@^3.0.5/module/index.js";var h,u=e;h=u.createRoot,u.hydrateRoot;var g={};Object.defineProperty(g,"__esModule",{value:!0});class m extends CustomEvent{constructor(e,t=!1){super(m.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}m.TYPE="model.updated";var _=g.ModelUpdatedEvent=m;class b extends CustomEvent{constructor(e,t){super(b.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}b.TYPE="delete.image";var C=g.DeleteImageEvent=b;class y extends CustomEvent{constructor(e){super(y.TYPE,{bubbles:!0,detail:e}),this.handler=e}}y.TYPE="insert.image";var f=g.InsertImageEvent=y;class E extends CustomEvent{constructor(e,t){super(E.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}E.TYPE="delete.sound";var S=g.DeleteSoundEvent=E;class w extends CustomEvent{constructor(e){super(w.TYPE,{bubbles:!0,detail:e}),this.handler=e}}w.TYPE="insert.sound";var v=g.InsertSoundEvent=w;const x=t,A=n,{Card:I}=a,{CardContent:k}=a,{Button:T}=a,{FormControlLabel:R}=a,{Typography:M}=a,{InputLabel:O}=a,{Checkbox:P}=a,{Select:D}=a,{MenuItem:K}=a,{IconButton:j}=a,{styled:q}=o,{Delete:L}=s,{color:B}=i,{InputContainer:H}=p,{MathToolbar:$}=c,Z=q(I)(({theme:e})=>({marginBottom:e.spacing(2.5),width:"100%",minWidth:"548px",border:`1px solid ${e.palette.grey[700]}`,display:"flex",flexDirection:"column",justifyContent:"space-between"})),z=q(k)(({theme:e})=>({paddingBottom:`${e.spacing(2)}px !important`})),W=q(M)({fontWeight:700,fontSize:"1.2rem",flex:3}),F=q(H)(({theme:e})=>({flex:2,"& > *:not(label)":{marginTop:e.spacing(1)}})),N=q("div")(({theme:e})=>({marginBottom:e.spacing(2)})),Y=q("div")({display:"flex",alignItems:"center",justifyContent:"space-between"}),G=q("div")({display:"flex"}),U=q(T)(({theme:e})=>({border:`1px solid ${e.palette.grey.A400}`,color:B.text()})),V=q(j)(({theme:e})=>({marginLeft:e.spacing(1)})),J=q("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)})),Q=q("div")(({theme:e})=>({background:e.palette.grey.A100,color:e.palette.grey.A700,display:"inline",minWidth:"50px",padding:"8px",border:"1px solid #C0C3CF"})),X=q("div")({display:"flex",justifyContent:"space-between",alignItems:"center"}),ee=q(P)({color:`${B.tertiary()} !important`});if("undefined"!=typeof document){const e="math-templated-response-styles";if(!document.getElementById(e)){const t=document.createElement("style");t.id=e,t.textContent="\n .response-editor {\n display: flex;\n align-items: center;\n justify-content: center;\n width: 100%;\n min-width: 500px;\n max-width: 900px;\n height: auto;\n min-height: 40px;\n }\n .math-toolbar {\n width: 100%;\n }\n ",document.head.appendChild(t)}}class te extends x.Component{static __initStatic(){this.propTypes={defaultResponse:A.bool,error:A.object,mode:A.oneOfType([A.string,A.number]),onResponseChange:A.func.isRequired,onResponseDone:A.func.isRequired,response:A.object.isRequired,cIgnoreOrder:A.object.isRequired,cAllowTrailingZeros:A.object.isRequired,responseKey:A.number.isRequired}}static __initStatic2(){this.defaultProps={defaultResponse:!1,mode:"8"}}constructor(e){super(e),te.prototype.__init.call(this),te.prototype.__init2.call(this),te.prototype.__init3.call(this),te.prototype.__init4.call(this),te.prototype.__init5.call(this),te.prototype.__init6.call(this),te.prototype.__init7.call(this),te.prototype.__init8.call(this),te.prototype.__init9.call(this),te.prototype.__init10.call(this),te.prototype.__init11.call(this);const{response:{alternates:t}={}}=e||{},n=Object.keys(t||{}).length;this.state={alternateIdCounter:n+1,showKeypad:{openCount:0,main:!1}}}__init(){this.onChange=e=>t=>{const{response:n,onResponseChange:a,responseKey:o}=this.props,s={...n};s[e]=t.target.value,a(s,o)}}__init2(){this.onConfigChanged=e=>t=>{const{response:n,onResponseChange:a,responseKey:o}=this.props,s={...n};s[e]=t.target.checked,a(s,o)}}__init3(){this.onLiteralOptionsChange=e=>()=>{const{response:t,onResponseChange:n,responseKey:a}=this.props,o={...t};o[e]=!t[e],n(o,a)}}__init4(){this.onAnswerChange=e=>{const{response:t,onResponseChange:n,responseKey:a}=this.props,o={...t};o.answer=e,n(o,a)}}__init5(){this.onAlternateAnswerChange=e=>t=>{const{response:n,onResponseChange:a,responseKey:o}=this.props,s={...n};s.alternates[e]=t,a(s,o)}}__init6(){this.onAddAlternate=()=>{const{response:e,onResponseChange:t,responseKey:n}=this.props,{alternateIdCounter:a}=this.state,o={...e};o.alternates||(o.alternates={}),o.alternates[a]="",t(o,n),this.setState({alternateIdCounter:a+1})}}__init7(){this.onRemoveAlternate=e=>()=>{const{response:t,onResponseChange:n,responseKey:a}=this.props,o={...t};delete o.alternates[e],n(o,a),this.setState(t=>({showKeypad:{...t.showKeypad,openCount:t.showKeypad[e]?t.showKeypad.openCount-1:t.showKeypad.openCount}}))}}__init8(){this.onDone=()=>{const{onResponseDone:e}=this.props;this.setState(e=>({showKeypad:{...e.showKeypad,openCount:e.showKeypad.openCount-1,main:!1}})),e()}}__init9(){this.onFocus=()=>{this.setState(e=>({showKeypad:{...e.showKeypad,openCount:e.showKeypad.main?e.showKeypad.openCount:e.showKeypad.openCount+1,main:!0}}))}}__init10(){this.onAlternateFocus=e=>()=>{this.setState(t=>({showKeypad:{...t.showKeypad,openCount:t.showKeypad[e]?t.showKeypad.openCount:t.showKeypad.openCount+1,[e]:!0}}))}}__init11(){this.onAlternateDone=e=>()=>{this.setState(t=>({showKeypad:{...t.showKeypad,openCount:t.showKeypad.openCount-1,[e]:!1}}))}}render(){const{mode:e,responseKey:t,response:n,cAllowTrailingZeros:a,cIgnoreOrder:o,error:s}=this.props,{showKeypad:i}=this.state,{validation:l,answer:r,alternates:p,ignoreOrder:d,allowTrailingZeros:c}=n,h=Object.keys(p||{}).length>0,u={editor:"response-editor",mathToolbar:"math-toolbar"},g={minHeight:(i.openCount>0?430:230)+"px"},m=`R ${parseInt(t)+1}`;return x.createElement(Z,{style:g},x.createElement(z,null,x.createElement(Y,null,x.createElement(W,{component:"div"},"Response for ",x.createElement(Q,null,m)),x.createElement(F,{label:"Validation"},x.createElement(D,{onChange:this.onChange("validation"),value:l||"literal",MenuProps:{transitionDuration:{enter:225,exit:195}}},x.createElement(K,{value:"literal"},"Literal Validation"),x.createElement(K,{value:"symbolic"},"Symbolic Validation")))),"literal"===l&&x.createElement(G,null,a.enabled&&x.createElement(R,{label:a.label,control:x.createElement(ee,{checked:c,onChange:this.onLiteralOptionsChange("allowTrailingZeros")})}),o.enabled&&x.createElement(R,{label:o.label,control:x.createElement(ee,{checked:d,onChange:this.onLiteralOptionsChange("ignoreOrder")})})),x.createElement(N,null,x.createElement(O,null,"Correct Answer"),x.createElement($,{keypadMode:e,classNames:u,controlledKeypad:!0,showKeypad:i.main,latex:r||"",onChange:this.onAnswerChange,onFocus:this.onFocus,onDone:this.onDone,error:s&&s.answer}),s&&s.answer?x.createElement(J,null,s.answer):null),h&&Object.keys(p).map((t,n)=>x.createElement(N,{key:t},x.createElement(O,null,"Alternate",Object.keys(p).length>1?` ${n+1}`:""),x.createElement(X,null,x.createElement($,{classNames:u,controlledKeypad:!0,keypadMode:e,showKeypad:i[t]||!1,latex:p[t]||"",onChange:this.onAlternateAnswerChange(t),onFocus:this.onAlternateFocus(t),onDone:this.onAlternateDone(t),error:s&&s[t]}),x.createElement(V,{onClick:this.onRemoveAlternate(t),size:"large"},x.createElement(L,null))),s&&s[t]?x.createElement(J,null,s[t]):null)),x.createElement(U,{type:"primary",onClick:this.onAddAlternate},"ADD ALTERNATE")))}}te.__initStatic(),te.__initStatic2();const ne="imes|riangle|an|heta|herefore",ae="throot|parallel|cong|approx|eq|e|sim",oe=new RegExp(`(\\t(?!${ne}))|(\\n(?!${ae}))|(\\\\t(?!${ne}))|(\\\\n(?!${ae}))`,"g"),se=e=>e.replace(oe,"").replace(/\\"/g,'"').replace(/\\\//g,"/"),ie=e=>{const t=((e="")=>{const t=document.createElement("div");return t.innerHTML=e.trim(),t})(se(e||"")||"");return t.querySelectorAll('[data-type="math_templated"]').forEach(e=>e.replaceWith(`{{${e.dataset.index}}}`)),t.innerHTML},le=/\{\{(\d+)\}\}/g,re=(e,t)=>e?se(e).replace(le,(e,n)=>{const a=function(e){let t,n=e[0],a=1;for(;a<e.length;){const o=e[a],s=e[a+1];if(a+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=s(n)):"call"!==o&&"optionalCall"!==o||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}([t,"access",e=>e[n],"optionalAccess",e=>e.answer])||"";return`<span data-type="math_templated" data-index="${n}" data-value="${a}"></span>`}):"",pe=t,de=n,{styled:ce}=o,{Typography:he}=a,{Select:ue}=a,{MenuItem:ge}=a,{Tooltip:me}=a,{Info:_e}=s,{cloneDeep:be}=l,{pick:Ce}=l,{throttle:ye}=l,{InputContainer:fe}=p,{settings:Ee}=p,{layout:Se}=p,we=d,{ALL_PLUGINS:ve}=d;function xe(e){let t,n=e[0],a=1;for(;a<e.length;){const o=e[a],s=e[a+1];if(a+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=s(n)):"call"!==o&&"optionalCall"!==o||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}const{dropdown:Ae}=Ee,{Panel:Ie,toggle:ke}=Ee,Te=ce(fe)(({theme:e})=>({width:"100%",paddingTop:e.spacing(2),marginBottom:e.spacing(2)})),Re=ce(we)({width:"100%"}),Me=ce("div")(({theme:e})=>({color:e.palette.error.main,fontSize:"0.75rem",marginTop:e.spacing(1)})),Oe=ce("div")(({theme:e})=>({color:e.palette.error.main,fontSize:"0.75rem",marginBottom:e.spacing(1)})),Pe=ce(we)(({theme:e})=>({width:"100%",marginTop:e.spacing(2),marginBottom:e.spacing(3)})),De=ce(fe)(({theme:e})=>({width:"100%",marginTop:e.spacing(2),"& > *:not(label)":{marginTop:e.spacing(1)},marginBottom:e.spacing(2)})),Ke=ce(ue)({width:"100%"}),je=ce(he)(({theme:e})=>({fontSize:1.25*e.typography.fontSize,fontWeight:"bold"})),qe=ce("div")({display:"flex",alignItems:"center",gap:"8px"}),Le=ce(me)(({theme:e})=>({"& .MuiTooltip-tooltip":{fontSize:e.typography.fontSize-2,whiteSpace:"pre",maxWidth:"500px"}}));class Be extends pe.Component{constructor(...e){super(...e),Be.prototype.__init.call(this),Be.prototype.__init2.call(this),Be.prototype.__init3.call(this),Be.prototype.__init4.call(this),Be.prototype.__init5.call(this),Be.prototype.__init6.call(this),Be.prototype.__init7.call(this),Be.prototype.__init8.call(this),Be.prototype.__init9.call(this)}static __initStatic(){this.propTypes={model:de.object.isRequired,configuration:de.object.isRequired,onModelChanged:de.func.isRequired,onConfigurationChanged:de.func.isRequired,imageSupport:de.shape({add:de.func.isRequired,delete:de.func.isRequired}),uploadSoundSupport:de.object}}__init(){this.state={}}componentDidMount(){const{model:{slateMarkup:e}}=this.props;this.setState({markup:e})}__init2(){this.handleChange=(e,t)=>{const{onModelChanged:n,model:a}=this.props,o=be(a);o[e]=t,n(o)}}__init3(){this.onResponseChange=(e,t)=>{const{model:n,onModelChanged:a}=this.props,o={...n};o.responses[t]=e,a(o)}}__init4(){this.onResponseDone=()=>{const{model:e,onModelChanged:t}=this.props;t({...e,slateMarkup:re(e.markup,e.responses)})}}__init5(){this.onChangeResponse=(e,t)=>{const{model:n,onModelChanged:a}=this.props,{responses:o}=n;o[e]?o[e][0].answer=t||"":o[e]=[{answer:t||"",id:"response"+e,allowSpaces:!0}],a({...n,responses:o})}}__init6(){this.onResponsesChanged=e=>{this.props.onModelChanged({...this.props.model,responses:e})}}__init7(){this.onChange=e=>{const{model:{responses:t,validationDefault:n,allowTrailingZerosDefault:a,ignoreOrderDefault:o},onModelChanged:s}=this.props,i={},l=(e=>{const t=document.createElement("div");return t.innerHTML=e.trim(),t})(e);l.querySelectorAll('[data-type="math_templated"]').forEach((e,s)=>{const{value:l,index:r}=e.dataset;l||(e.dataset.value=""),i[s]=t[r]||{allowSpaces:!0,validation:n||"symbolic",allowTrailingZeros:a||!1,ignoreOrder:o||!1,answer:"",alternates:{}},e.dataset.index=s.toString()});const r=ie(e);this.setState({cachedResponses:void 0},()=>s({...this.props.model,slateMarkup:l.innerHTML,responses:i,markup:r}))}}__init8(){this.onHandleAreaChange=ye(e=>{const{model:{responses:t},onModelChanged:n}=this.props,{cachedResponses:a}=this.state;if(!e)return;const o=t?be(t):{},s=a?be(a):{};e.forEach(e=>{const t=e.data.get("index");!o[t]&&s[t]?(Object.assign(o,Ce(s,t)),Object.prototype.hasOwnProperty.call(s,t)&&delete s[t]):(Object.assign(s,Ce(o,t)),Object.prototype.hasOwnProperty.call(o,t)&&delete o[t])}),this.setState({cachedResponses:s},()=>n({...this.props.model,responses:o}))},500,{trailing:!1,leading:!0})}__init9(){this.onBlur=e=>{const{relatedTarget:t,currentTarget:n}=e||{},a=function e(t,n=0){if(!t||n>=16)return null;const a=t.offsetParent;return a?"tooltip"===a.getAttribute("role")?a:e(a,n+1):null}(t),o=a?function e(t,n=0){if(!t||n>=4)return null;const a=xe([t,"optionalAccess",e=>e.children,"optionalAccess",e=>e[0]]);return a?a.attributes&&a.attributes["data-keypad"]?a:e(a,n+1):null}(a):null;t&&n&&xe([o,"optionalAccess",e=>e.attributes,"access",e=>e["data-keypad"]])||this.setState({activeAnswerBlock:""})}}render(){const{configuration:e,imageSupport:t,model:n,onConfigurationChanged:a,onModelChanged:o,uploadSoundSupport:s}=this.props,{baseInputConfiguration:i={},contentDimensions:l={},prompt:r={},rationale:p={},settingsPanelDisabled:d,teacherInstructions:c={},language:h={},languageChoices:u={},spellCheck:g={},playerSpellCheck:m={},maxImageWidth:_={},maxImageHeight:b={},mathMlOptions:C={},template:y={},editSource:f={},ignoreOrder:E={},allowTrailingZeros:S={},partialScoring:w={},maxResponseAreas:v}=e||{},{errors:x,extraCSSRules:A,promptEnabled:I,rationaleEnabled:k,spellCheckEnabled:T,teacherInstructionsEnabled:R,toolbarEditorPosition:M,responses:O,equationEditor:P}=n||{},{prompt:D,rationale:K,responseAreas:j,teacherInstructions:q,responses:L={}}=x||{},B=(e=>{const{maxResponseAreas:t}=e;return"Validation requirements:\nCorrect answers should not be blank.\nEach answer defined for a response area should be unique.\nThere should be at least 1 "+(t?`and at most ${t} `:"")+"response area"+(t?"s":"")+" defined."})(e),H={"language.enabled":h.settings&&ke(h.label,!0),language:h.settings&&h.enabled&&Ae(u.label,u.options)},$={teacherInstructionsEnabled:c.settings&&ke(c.label),rationaleEnabled:p.settings&&ke(p.label),promptEnabled:r.settings&&ke(r.label),spellCheckEnabled:g.settings&&ke(g.label),playerSpellCheckEnabled:m.settings&&ke(m.label),"editSource.enabled":xe([f,"optionalAccess",e=>e.settings])&&ke(f.label,!0),partialScoring:w.settings&&ke(w.label)},Z=_&&_.prompt,z=b&&b.prompt,W={position:"top"===M?"top":"bottom"},F=(e={},t={})=>({...t,...e});return pe.createElement(Se.ConfigLayout,{extraCSSRules:A,dimensions:l,hideSettings:d,settings:pe.createElement(Ie,{model:n,configuration:e,onChangeModel:e=>o(e),onChangeConfiguration:a,groups:{Settings:H,Properties:$}})},R&&pe.createElement(Te,{label:c.label},pe.createElement(Re,{markup:n.teacherInstructions||"",onChange:e=>this.handleChange("teacherInstructions",e),imageSupport:t,nonEmpty:!1,error:q,toolbarOpts:W,pluginProps:F(xe([c,"optionalAccess",e=>e.inputConfiguration]),i),spellCheck:T,maxImageWidth:_&&_.teacherInstructions||Z,maxImageHeight:b&&b.teacherInstructions||z,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:C}),q&&pe.createElement(Me,null,q)),I&&pe.createElement(Te,{label:r.label},pe.createElement(Re,{markup:n.prompt,onChange:e=>this.handleChange("prompt",e),imageSupport:t,nonEmpty:!1,disableUnderline:!0,error:D,toolbarOpts:W,pluginProps:F(xe([c,"optionalAccess",e=>e.inputConfiguration]),i),spellCheck:T,maxImageWidth:Z,maxImageHeight:z,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:C}),D&&pe.createElement(Me,null,D)),pe.createElement(qe,null,pe.createElement(je,{component:"div"},"Response Template"),pe.createElement(Le,{disableFocusListener:!0,disableTouchListener:!0,placement:"right",title:B},pe.createElement(_e,{fontSize:"small",color:"primary"}))),pe.createElement(Pe,{activePlugins:ve,toolbarOpts:{position:"top"},spellCheck:T,pluginProps:F(xe([y,"optionalAccess",e=>e.inputConfiguration]),i),responseAreaProps:{type:"math-templated",respAreaToolbar:null,error:()=>L,onHandleAreaChange:this.onHandleAreaChange,maxResponseAreas:v},markup:n.slateMarkup,onChange:this.onChange,imageSupport:t,disableImageAlignmentButtons:!0,onBlur:this.onBlur,disabled:!1,highlightShape:!1,error:j,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:C}),j&&pe.createElement(Oe,null,j),pe.createElement(je,null,"Define Response"),pe.createElement(De,{label:"Response Template Equation Editor"},pe.createElement(Ke,{MenuProps:{transitionDuration:{enter:225,exit:195}},onChange:e=>this.handleChange("equationEditor",e.target.value),value:P},pe.createElement(ge,{value:"non-negative-integers"},"Numeric - Non-Negative Integers"),pe.createElement(ge,{value:"integers"},"Numeric - Integers"),pe.createElement(ge,{value:"decimals"},"Numeric - Decimals"),pe.createElement(ge,{value:"fractions"},"Numeric - Fractions"),pe.createElement(ge,{value:1},"Grade 1 - 2"),pe.createElement(ge,{value:3},"Grade 3 - 5"),pe.createElement(ge,{value:6},"Grade 6 - 7"),pe.createElement(ge,{value:8},"Grade 8 - HS"),pe.createElement(ge,{value:"geometry"},"Geometry"),pe.createElement(ge,{value:"advanced-algebra"},"Advanced Algebra"),pe.createElement(ge,{value:"statistics"},"Statistics"),pe.createElement(ge,{value:"item-authoring"},"Item Authoring"))),Object.keys(O||{}).map((e,t)=>{const n=O[t];return n?pe.createElement(te,{key:t,responseKey:t,mode:P,response:n,onResponseChange:this.onResponseChange,onResponseDone:this.onResponseDone,index:t,cIgnoreOrder:E,cAllowTrailingZeros:S,error:L&&L[t]}):null}),k&&pe.createElement(Te,{label:p.label},pe.createElement(Re,{markup:n.rationale||"",onChange:e=>this.handleChange("rationale",e),imageSupport:t,nonEmpty:!1,error:K,toolbarOpts:W,pluginProps:F(xe([p,"optionalAccess",e=>e.inputConfiguration]),{...i,math:{controlledKeypadMode:!1}}),spellCheck:T,maxImageWidth:_&&_.rationale||Z,maxImageHeight:b&&b.rationale||z,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:C}),K&&pe.createElement(Me,null,K)))}}Be.__initStatic();var He={allowTrailingZerosDefault:!1,equationEditor:"8",ignoreOrderDefault:!1,markup:"",playerSpellCheckEnabled:!0,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,responses:{},spellCheckEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",validationDefault:"literal"},$e={ignoreOrder:{settings:!0,label:"Ignore Order",enabled:!0},allowTrailingZeros:{settings:!0,label:"Allow Trailing Zeros",enabled:!0},partialScoring:{settings:!0,label:"Allow Partial Scoring"},baseInputConfiguration:{html:{disabled:!0},audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},prompt:{label:"Prompt",settings:!0,inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},editSource:{label:"Edit Source",settings:!0,enabled:!1},playerSpellCheck:{label:"Student Spellcheck",settings:!0,enabled:!0},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},template:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},maxImageWidth:{teacherInstructions:300,prompt:300,rationale:300},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]},maxResponseAreas:10};const Ze=t,ze=r,{defaults:We}=l,{isArray:Fe}=l;function Ne(e){let t,n=e[0],a=1;for(;a<e.length;){const o=e[a],s=e[a+1];if(a+=2,("optionalAccess"===o||"optionalCall"===o)&&null==n)return;"access"===o||"optionalAccess"===o?(t=n,n=s(n)):"call"!==o&&"optionalCall"!==o||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}const Ye=ze("math-templated:configure");class Ge extends HTMLElement{static __initStatic(){this.prepareModel=(e={})=>{const{validationDefault:t,allowTrailingZerosDefault:n,ignoreOrderDefault:a,responses:o={}}=e,s=Object.keys(o).reduce((e,s)=>{const i=o[s];return e[s]={...i,validation:i.validation||t,allowTrailingZeros:i.allowTrailingZeros||n,ignoreOrder:i.ignoreOrder||a},e},{}),i={...He,...e,responses:s},l=i.slateMarkup||re(i.markup,i.responses),r=ie(l);return i.responses&&Object.keys(i.responses).forEach(e=>{Fe(i.responses[e])&&(i.responses[e]=(i.responses[e]||[]).map((e,t)=>e.answer?e:(Ye('Choice does not contain "answer" property, which is required.',e),{answer:`${t}`,...e})))}),{...i,slateMarkup:l,markup:r}}}constructor(){super(),this._root=null,this._model=Ge.prepareModel(),this._configuration=$e,this.onModelChanged=this.onModelChanged.bind(this),this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=Ge.prepareModel(e),this._render()}set configuration(e){this._configuration=We(e,$e),Ne([e,"access",e=>e.language,"optionalAccess",e=>e.enabled])?Ne([e,"access",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=e.languageChoices.options[0].value):e.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find(e=>e.value===this._model.language)||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}set disableSidePanel(e){this._disableSidePanel=e,this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new _(this._model,t))}onModelChanged(e,t){this._model=Ge.prepareModel(e),this._render(),this.dispatchModelUpdated(t)}onConfigurationChanged(e){this._configuration=e,this._render()}insertImage(e){this.dispatchEvent(new f(e))}onDeleteImage(e,t){this.dispatchEvent(new C(e,t))}insertSound(e){this.dispatchEvent(new v(e))}onDeleteSound(e,t){this.dispatchEvent(new S(e,t))}_render(){Ye("_render");let e=Ze.createElement(Be,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged,disableSidePanel:this._disableSidePanel,imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=h(this)),this._root.render(e)}disconnectedCallback(){this._root&&this._root.unmount()}}Ge.__initStatic();export{Ge as default};
|