@pie-element/extended-text-entry 6.7.1 → 6.7.5

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/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.7.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry@6.7.4...@pie-element/extended-text-entry@6.7.5) (2021-12-13)
7
+
8
+ **Note:** Version bump only for package @pie-element/extended-text-entry
9
+
10
+
11
+
12
+
13
+
14
+ ## [6.7.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry@6.7.1...@pie-element/extended-text-entry@6.7.2) (2021-11-29)
15
+
16
+ **Note:** Version bump only for package @pie-element/extended-text-entry
17
+
18
+
19
+
20
+
21
+
6
22
  ## [6.7.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry@6.6.4...@pie-element/extended-text-entry@6.7.1) (2021-11-11)
7
23
 
8
24
  **Note:** Version bump only for package @pie-element/extended-text-entry
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [5.4.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry-configure@5.4.4...@pie-element/extended-text-entry-configure@5.4.5) (2021-12-13)
7
+
8
+ **Note:** Version bump only for package @pie-element/extended-text-entry-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [5.4.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry-configure@5.4.1...@pie-element/extended-text-entry-configure@5.4.2) (2021-11-29)
15
+
16
+ **Note:** Version bump only for package @pie-element/extended-text-entry-configure
17
+
18
+
19
+
20
+
21
+
6
22
  ## [5.4.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/extended-text-entry-configure@5.3.2...@pie-element/extended-text-entry-configure@5.4.1) (2021-11-11)
7
23
 
8
24
  **Note:** Version bump only for package @pie-element/extended-text-entry-configure
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry-configure",
3
3
  "private": true,
4
- "version": "5.4.1",
4
+ "version": "5.4.5",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -10,8 +10,8 @@
10
10
  "dependencies": {
11
11
  "@material-ui/core": "^3.9.2",
12
12
  "@pie-framework/pie-configure-events": "^1.2.0",
13
- "@pie-lib/config-ui": "^10.10.11",
14
- "@pie-lib/editable-html": "^7.17.11",
13
+ "@pie-lib/config-ui": "^10.10.13",
14
+ "@pie-lib/editable-html": "^7.17.13",
15
15
  "lodash": "^4.17.15",
16
16
  "prop-types": "^15.6.2",
17
17
  "react": "^16.8.1",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry-controller",
3
3
  "private": true,
4
- "version": "4.1.15",
4
+ "version": "4.1.17",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
package/lib/main.js CHANGED
@@ -39,8 +39,6 @@ var _renderUi = require("@pie-lib/render-ui");
39
39
 
40
40
  var _mathRendering = require("@pie-lib/math-rendering");
41
41
 
42
- var _classnames = _interopRequireDefault(require("classnames"));
43
-
44
42
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
45
43
 
46
44
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
@@ -112,11 +110,9 @@ var Main = /*#__PURE__*/function (_React$Component) {
112
110
  var maxHeight = '40vh';
113
111
  log('[render] disabled? ', disabled);
114
112
 
115
- var teacherInstructionsDiv = /*#__PURE__*/_react["default"].createElement("div", {
116
- className: "teacher-instructions",
117
- dangerouslySetInnerHTML: {
118
- __html: teacherInstructions
119
- }
113
+ var teacherInstructionsDiv = /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
114
+ defaultClassName: "teacher-instructions",
115
+ prompt: teacherInstructions
120
116
  });
121
117
 
122
118
  return /*#__PURE__*/_react["default"].createElement("div", {
@@ -131,11 +127,11 @@ var Main = /*#__PURE__*/function (_React$Component) {
131
127
  },
132
128
  className: classes.collapsible
133
129
  }, teacherInstructionsDiv) : teacherInstructionsDiv, /*#__PURE__*/_react["default"].createElement("br", null)), model.prompt && /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
134
- className: (0, _classnames["default"])(classes.prompt, 'prompt'),
135
- dangerouslySetInnerHTML: {
136
- __html: model.prompt
137
- }
138
- }), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
130
+ className: classes.prompt
131
+ }, /*#__PURE__*/_react["default"].createElement(_renderUi.PreviewPrompt, {
132
+ defaultClassName: "prompt",
133
+ prompt: model.prompt
134
+ })), /*#__PURE__*/_react["default"].createElement(_editableHtml["default"], {
139
135
  onChange: this.changeSession,
140
136
  markup: value || '',
141
137
  width: width && width.toString(),
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/main.jsx"],"names":["log","style","theme","main","backgroundColor","color","background","text","prompt","width","marginBottom","spacing","unit","fontSize","Main","props","onChange","containerRef","model","classes","session","dimensions","disabled","feedback","teacherInstructions","mathInput","animationsDisabled","value","height","maxHeight","teacherInstructionsDiv","__html","ref","hidden","visible","collapsible","changeSession","toString","math","customKeys","keypadMode","equationEditor","controlledKeypadMode","video","audio","React","Component","PropTypes","func","isRequired","object","shape","string"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SALb;AAME,QAAA,QAAQ,EAAEP,QANZ;AAOE,QAAA,cAAc,EAAE,IAPlB;AAQE,QAAA,WAAW,EAAE;AACXgB,UAAAA,IAAI,EAAE;AACJhB,YAAAA,QAAQ,EAAE,CAACG,SADP;AAEJc,YAAAA,UAAU,EAAE,KAAKxB,KAAL,CAAWG,KAAX,CAAiBqB,UAFzB;AAGJC,YAAAA,UAAU,EAAE,KAAKzB,KAAL,CAAWG,KAAX,CAAiBuB,cAHzB;AAIJC,YAAAA,oBAAoB,EAAE;AAJlB,WADK;AAOXC,UAAAA,KAAK,EAAE;AACLrB,YAAAA,QAAQ,EAAE;AADL,WAPI;AAUVsB,UAAAA,KAAK,EAAE;AACNtB,YAAAA,QAAQ,EAAE;AADJ;AAVG;AARf,QA3BF,EAkDGC,QAAQ,iBACP,0DACE,2CADF,eAEE,gCAAC,kBAAD;AAAU,QAAA,WAAW,EAAC,SAAtB;AAAgC,QAAA,QAAQ,EAAEA;AAA1C,QAFF,CAnDJ,CADF;AA2DD;;;EA1FuBsB,kBAAMC,S;;;iCAAnBhC,I,eACQ;AACjBE,EAAAA,QAAQ,EAAE+B,sBAAUC,IAAV,CAAeC,UADR;AAEjB/B,EAAAA,KAAK,EAAE6B,sBAAUG,MAFA;AAGjB/B,EAAAA,OAAO,EAAE4B,sBAAUG,MAAV,CAAiBD,UAHT;AAIjB7B,EAAAA,OAAO,EAAE2B,sBAAUI,KAAV,CAAgB;AACvBxB,IAAAA,KAAK,EAAEoB,sBAAUK;AADM,GAAhB,EAENH;AANc,C;;eA4FN,wBAAWhD,KAAX,EAAkBa,IAAlB,C","sourcesContent":["import React from 'react';\nimport EditableHTML from '@pie-lib/editable-html';\nimport PropTypes from 'prop-types';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport debounce from 'lodash/debounce';\nimport { color, Feedback, Collapsible } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport classNames from 'classnames';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst style = theme => ({\n main: {\n backgroundColor: color.background(),\n color: color.text()\n },\n prompt: {\n width: '100%',\n color: color.text(),\n marginBottom: theme.spacing.unit * 2,\n fontSize: 'inherit'\n }\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n onChange: PropTypes.func.isRequired,\n model: PropTypes.object,\n classes: PropTypes.object.isRequired,\n session: PropTypes.shape({\n value: PropTypes.string\n }).isRequired\n };\n\n componentDidUpdate() {\n if (this.containerRef) {\n renderMath(this.containerRef);\n }\n }\n\n changeSession = debounce(this.props.onChange, 1500);\n\n render() {\n const { model, classes, session } = this.props;\n const { dimensions, disabled, feedback, teacherInstructions, mathInput, animationsDisabled } = model;\n const { value } = session;\n const { width, height } = dimensions || {};\n const maxHeight = '40vh';\n log('[render] disabled? ', disabled);\n\n const teacherInstructionsDiv = <div\n className=\"teacher-instructions\"\n dangerouslySetInnerHTML={{ __html: teacherInstructions }}\n />;\n\n return (\n <div\n className={classes.main}\n ref={ref => {\n this.containerRef = ref;\n }}\n >\n {\n teacherInstructions && (\n <div>\n {!animationsDisabled ? (\n <Collapsible\n labels={{hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions'}}\n className={classes.collapsible}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : teacherInstructionsDiv }\n <br/>\n </div>\n )\n }\n {model.prompt && (\n <Typography\n className={classNames(classes.prompt, 'prompt')}\n dangerouslySetInnerHTML={{ __html: model.prompt }}\n />\n )}\n <EditableHTML\n onChange={this.changeSession}\n markup={value || ''}\n width={width && width.toString()}\n minHeight={height && height.toString()}\n maxHeight={maxHeight}\n disabled={disabled}\n highlightShape={true}\n pluginProps={{\n math: {\n disabled: !mathInput,\n customKeys: this.props.model.customKeys,\n keypadMode: this.props.model.equationEditor,\n controlledKeypadMode: false\n },\n video: {\n disabled: true\n },\n audio: {\n disabled: true\n }\n }}\n />\n {feedback && (\n <div>\n <br />\n <Feedback correctness=\"correct\" feedback={feedback}/>\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default withStyles(style)(Main);\n"],"file":"main.js"}
1
+ {"version":3,"sources":["../src/main.jsx"],"names":["log","style","theme","main","backgroundColor","color","background","text","prompt","width","marginBottom","spacing","unit","fontSize","Main","props","onChange","containerRef","model","classes","session","dimensions","disabled","feedback","teacherInstructions","mathInput","animationsDisabled","value","height","maxHeight","teacherInstructionsDiv","ref","hidden","visible","collapsible","changeSession","toString","math","customKeys","keypadMode","equationEditor","controlledKeypadMode","video","audio","React","Component","PropTypes","func","isRequired","object","shape","string"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,6BAAN,CAAZ;;AAEA,IAAMC,KAAK,GAAG,SAARA,KAAQ,CAAAC,KAAK;AAAA,SAAK;AACtBC,IAAAA,IAAI,EAAE;AACJC,MAAAA,eAAe,EAAEC,gBAAMC,UAAN,EADb;AAEJD,MAAAA,KAAK,EAAEA,gBAAME,IAAN;AAFH,KADgB;AAKtBC,IAAAA,MAAM,EAAE;AACNC,MAAAA,KAAK,EAAE,MADD;AAENJ,MAAAA,KAAK,EAAEA,gBAAME,IAAN,EAFD;AAGNG,MAAAA,YAAY,EAAER,KAAK,CAACS,OAAN,CAAcC,IAAd,GAAqB,CAH7B;AAINC,MAAAA,QAAQ,EAAE;AAJJ;AALc,GAAL;AAAA,CAAnB;;IAaaC,I;;;;;;;;;;;;;;;sGAgBK,0BAAS,MAAKC,KAAL,CAAWC,QAApB,EAA8B,IAA9B,C;;;;;;WANhB,8BAAqB;AACnB,UAAI,KAAKC,YAAT,EAAuB;AACrB,uCAAW,KAAKA,YAAhB;AACD;AACF;;;WAID,kBAAS;AAAA;;AACP,wBAAoC,KAAKF,KAAzC;AAAA,UAAQG,KAAR,eAAQA,KAAR;AAAA,UAAeC,OAAf,eAAeA,OAAf;AAAA,UA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ACvBvB,IAAAA,KAAK,EAAEmB,sBAAUK;AADM,GAAhB,EAENH;AANc,C;;eA0FN,wBAAW/C,KAAX,EAAkBa,IAAlB,C","sourcesContent":["import React from 'react';\nimport EditableHTML from '@pie-lib/editable-html';\nimport PropTypes from 'prop-types';\nimport Typography from '@material-ui/core/Typography';\nimport { withStyles } from '@material-ui/core/styles';\nimport debug from 'debug';\nimport debounce from 'lodash/debounce';\nimport {color, Feedback, Collapsible, PreviewPrompt} from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst style = theme => ({\n main: {\n backgroundColor: color.background(),\n color: color.text()\n },\n prompt: {\n width: '100%',\n color: color.text(),\n marginBottom: theme.spacing.unit * 2,\n fontSize: 'inherit'\n }\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n onChange: PropTypes.func.isRequired,\n model: PropTypes.object,\n classes: PropTypes.object.isRequired,\n session: PropTypes.shape({\n value: PropTypes.string\n }).isRequired\n };\n\n componentDidUpdate() {\n if (this.containerRef) {\n renderMath(this.containerRef);\n }\n }\n\n changeSession = debounce(this.props.onChange, 1500);\n\n render() {\n const { model, classes, session } = this.props;\n const { dimensions, disabled, feedback, teacherInstructions, mathInput, animationsDisabled } = model;\n const { value } = session;\n const { width, height } = dimensions || {};\n const maxHeight = '40vh';\n log('[render] disabled? ', disabled);\n\n const teacherInstructionsDiv = <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />;\n\n return (\n <div\n className={classes.main}\n ref={ref => {\n this.containerRef = ref;\n }}\n >\n {\n teacherInstructions && (\n <div>\n {!animationsDisabled ? (\n <Collapsible\n labels={{hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions'}}\n className={classes.collapsible}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : teacherInstructionsDiv }\n <br/>\n </div>\n )\n }\n {model.prompt && (\n <Typography\n className={classes.prompt}\n >\n <PreviewPrompt defaultClassName=\"prompt\" prompt={model.prompt} />\n </Typography>\n )}\n <EditableHTML\n onChange={this.changeSession}\n markup={value || ''}\n width={width && width.toString()}\n minHeight={height && height.toString()}\n maxHeight={maxHeight}\n disabled={disabled}\n highlightShape={true}\n pluginProps={{\n math: {\n disabled: !mathInput,\n customKeys: this.props.model.customKeys,\n keypadMode: this.props.model.equationEditor,\n controlledKeypadMode: false\n },\n video: {\n disabled: true\n },\n audio: {\n disabled: true\n }\n }}\n />\n {feedback && (\n <div>\n <br />\n <Feedback correctness=\"correct\" feedback={feedback}/>\n </div>\n )}\n </div>\n );\n }\n}\n\nexport default withStyles(style)(Main);\n"],"file":"main.js"}
package/lib/print.js CHANGED
@@ -47,7 +47,8 @@ var log = (0, _debug["default"])('pie-element:extended-text-entry:print');
47
47
 
48
48
  var preparePrintModel = function preparePrintModel(model, opts) {
49
49
  var instr = opts.role === 'instructor';
50
- model.teacherInstructions = instr ? model.teacherInstructions : undefined;
50
+ model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
51
+ model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
51
52
  model.showTeacherInstructions = instr;
52
53
  model.mode = instr ? 'evaluate' : model.mode;
53
54
  var defaultDimensions = {
package/lib/print.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","teacherInstructions","undefined","showTeacherInstructions","mode","defaultDimensions","height","width","dimensions","disabled","feedback","animationsDisabled","ExtendedTextEntryPrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","onChange","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uCAAN,CAAZ;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AAC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C,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAhBD,MAgBO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KArBc,EAsBf,EAtBe,EAuBf;AAAE+B,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAvBe,CAAjB;AALY;AA8Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKf,QAAL,GAAgBe,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKf,MAAL,GAAce,CAAd;;AACA,WAAKb,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAzC4Bc,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport debug from 'debug';\n\nconst log = debug('pie-element:extended-text-entry:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.teacherInstructions = instr ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n const defaultDimensions = { height: 100, width: 500 };\n\n model.dimensions = {\n ...defaultDimensions,\n ...model.dimensions\n };\n\n model.disabled = true;\n model.feedback = undefined;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExtendedTextEntryPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n onChange: () => {}\n });\n\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true }\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
1
+ {"version":3,"sources":["../src/print.js"],"names":["log","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","mode","defaultDimensions","height","width","dimensions","disabled","feedback","animationsDisabled","ExtendedTextEntryPrint","_options","_model","_session","_rerender","printModel","element","React","createElement","Main","session","onChange","ReactDOM","render","leading","trailing","o","s","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,uCAAN,CAAZ;;AAEA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,KAAD,EAAQC,IAAR,EAAiB;AACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAL,KAAc,YAA5B;AAEAH,EAAAA,KAAK,CAACI,MAAN,GAAeJ,KAAK,CAACK,aAAN,KAAwB,KAAxB,GAAgCL,KAAK,CAACI,MAAtC,GAA+CE,SAA9D;AACAN,EAAAA,KAAK,CAACO,mBAAN,GAA4BL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SAA9G;AACAN,EAAAA,KAAK,CAACS,uBAAN,GAAgCP,KAAhC;AACAF,EAAAA,KAAK,CAACU,IAAN,GAAaR,KAAK,GAAG,UAAH,GAAgBF,KAAK,CAACU,IAAxC;AAEA,MAAMC,iBAAiB,GAAG;AAAEC,IAAAA,MAAM,EAAE,GAAV;AAAeC,IAAAA,KAAK,EAAE;AAAtB,GAA1B;AAEAb,EAAAA,KAAK,CAACc,UAAN,mCACKH,iBADL,GAEKX,KAAK,CAACc,UAFX;AAKAd,EAAAA,KAAK,CAACe,QAAN,GAAiB,IAAjB;AACAf,EAAAA,KAAK,CAACgB,QAAN,GAAiBV,SAAjB;AACAN,EAAAA,KAAK,CAACiB,kBAAN,GAA2B,IAA3B;AAEA,SAAOjB,KAAP;AACD,CApBD;;IAsBqBkB,sB;;;;;AACnB,oCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,QAAL,GAAgB,IAAhB;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,EAAhB;AACA,UAAKC,SAAL,GAAiB,0BACf,YAAM;AACJ,UAAI,MAAKF,MAAL,IAAe,MAAKC,QAAxB,EAAkC;AAChC,YAAME,UAAU,GAAGxB,iBAAiB,CAAC,MAAKqB,MAAN,EAAc,MAAKD,QAAnB,CAApC;;AAEA,YAAMK,OAAO,GACX,MAAKL,QAAL,iBACAM,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACxB3B,UAAAA,KAAK,EAAEuB,UADiB;AAExBK,UAAAA,OAAO,EAAE,EAFe;AAGxBC,UAAAA,QAAQ,EAAE,oBAAM,CAAE;AAHM,SAA1B,CAFF;;AASAC,6BAASC,MAAT,CAAgBP,OAAhB,kDAA+B,YAAM;AACnC1B,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAhBD,MAgBO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KArBc,EAsBf,EAtBe,EAuBf;AAAEkC,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAvBe,CAAjB;AALY;AA8Bb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKf,QAAL,GAAgBe,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKf,MAAL,GAAce,CAAd;;AACA,WAAKb,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDAzC4Bc,W","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport debug from 'debug';\n\nconst log = debug('pie-element:extended-text-entry:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n const defaultDimensions = { height: 100, width: 500 };\n\n model.dimensions = {\n ...defaultDimensions,\n ...model.dimensions\n };\n\n model.disabled = true;\n model.feedback = undefined;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExtendedTextEntryPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n onChange: () => {}\n });\n\n\n ReactDOM.render(element, this, () => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true }\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n}\n"],"file":"print.js"}
@@ -0,0 +1,386 @@
1
+ import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.2.14/module/index.js";
2
+ import {_dll_pie_lib__config_ui} from "../../../@pie-lib/config-module@^1.0.15/module/index.js";
3
+ import {_dll_pie_lib__editable_html} from "../../../@pie-lib/editable-html-module@^1.0.15/module/index.js";
4
+ var lib = {};
5
+ Object.defineProperty(lib, "__esModule", {
6
+ value: true
7
+ });
8
+ class ModelUpdatedEvent extends CustomEvent {
9
+ constructor(update, reset = false) {
10
+ super(ModelUpdatedEvent.TYPE, {
11
+ bubbles: true,
12
+ detail: {
13
+ update,
14
+ reset
15
+ }
16
+ });
17
+ this.update = update;
18
+ this.reset = reset;
19
+ }
20
+ }
21
+ ModelUpdatedEvent.TYPE = 'model.updated';
22
+ var ModelUpdatedEvent_1 = lib.ModelUpdatedEvent = ModelUpdatedEvent;
23
+ class DeleteImageEvent extends CustomEvent {
24
+ constructor(src, done) {
25
+ super(DeleteImageEvent.TYPE, {
26
+ bubbles: true,
27
+ detail: {
28
+ src,
29
+ done
30
+ }
31
+ });
32
+ this.src = src;
33
+ this.done = done;
34
+ }
35
+ }
36
+ DeleteImageEvent.TYPE = 'delete.image';
37
+ var DeleteImageEvent_1 = lib.DeleteImageEvent = DeleteImageEvent;
38
+ class InsertImageEvent extends CustomEvent {
39
+ constructor(handler) {
40
+ super(InsertImageEvent.TYPE, {
41
+ bubbles: true,
42
+ detail: handler
43
+ });
44
+ this.handler = handler;
45
+ }
46
+ }
47
+ InsertImageEvent.TYPE = 'insert.image';
48
+ var InsertImageEvent_1 = lib.InsertImageEvent = InsertImageEvent;
49
+ const React$1 = _dll_react;
50
+ const PropTypes = _dll_prop_types;
51
+ const {Typography: Typography} = _dll_material_ui__core;
52
+ const {withStyles: withStyles} = _dll_material_ui__core_styles;
53
+ const {FeedbackSelector: FeedbackSelector} = _dll_pie_lib__config_ui;
54
+ const {InputContainer: InputContainer} = _dll_pie_lib__config_ui;
55
+ const {settings: settings} = _dll_pie_lib__config_ui;
56
+ const {layout: layout} = _dll_pie_lib__config_ui;
57
+ const EditableHtml = _dll_pie_lib__editable_html;
58
+ const {ALL_PLUGINS: ALL_PLUGINS} = _dll_pie_lib__editable_html;
59
+ const _jsxFileName = "/home/circleci/repo/packages/extended-text-entry/configure/src/main.jsx";
60
+ const {Panel, toggle, numberFields, dropdown} = settings;
61
+ const defaultFeedback = {
62
+ type: 'default',
63
+ default: 'Your answer has been submitted'
64
+ };
65
+ class Main extends React$1.Component {
66
+ static __initStatic() {
67
+ this.propTypes = {
68
+ onModelChanged: PropTypes.func.isRequired,
69
+ onConfigurationChanged: PropTypes.func,
70
+ model: PropTypes.object.isRequired,
71
+ configuration: PropTypes.object.isRequired,
72
+ imageSupport: PropTypes.object.isRequired,
73
+ classes: PropTypes.object.isRequired
74
+ };
75
+ }
76
+ constructor(props) {
77
+ super(props);
78
+ Main.prototype.__init.call(this);
79
+ Main.prototype.__init2.call(this);
80
+ Main.prototype.__init3.call(this);
81
+ this.state = {
82
+ setDimensions: true
83
+ };
84
+ }
85
+ __init() {
86
+ this.onPromptChange = markup => {
87
+ const {onModelChanged, model} = this.props;
88
+ onModelChanged({
89
+ ...model,
90
+ prompt: markup
91
+ });
92
+ };
93
+ }
94
+ __init2() {
95
+ this.changeFeedback = feedback => {
96
+ const {model, onModelChanged} = this.props;
97
+ const update = {
98
+ ...model,
99
+ feedback
100
+ };
101
+ onModelChanged(update);
102
+ };
103
+ }
104
+ __init3() {
105
+ this.changeTeacherInstructions = teacherInstructions => {
106
+ const {model, onModelChanged} = this.props;
107
+ const update = {
108
+ ...model,
109
+ teacherInstructions
110
+ };
111
+ onModelChanged(update);
112
+ };
113
+ }
114
+ render() {
115
+ const {model, classes, onModelChanged, configuration, onConfigurationChanged, imageSupport} = this.props;
116
+ const {multiple = {}, feedback = {}, teacherInstructions = {}, prompt = {}, studentInstructions = {}, mathInput = {}, dimensions = {}, equationEditor = {}} = configuration || ({});
117
+ const {teacherInstructionsEnabled, promptEnabled, feedbackEnabled} = model || ({});
118
+ const toolbarOpts = {};
119
+ switch (model.toolbarEditorPosition) {
120
+ case 'top':
121
+ toolbarOpts.position = 'top';
122
+ break;
123
+ default:
124
+ toolbarOpts.position = 'bottom';
125
+ break;
126
+ }
127
+ return React$1.createElement(layout.ConfigLayout, {
128
+ settings: React$1.createElement(Panel, {
129
+ model: model,
130
+ configuration: configuration,
131
+ onChangeModel: model => onModelChanged(model),
132
+ onChangeConfiguration: config => onConfigurationChanged(config),
133
+ groups: {
134
+ 'Settings': {
135
+ mathInput: mathInput.settings && toggle(mathInput.label),
136
+ equationEditor: equationEditor.enabled && model.mathInput && dropdown(equationEditor.label, ['Grade 1 - 2', 'Grade 3 - 5', 'Grade 6 - 7', 'Grade 8 - HS', 'geometry', 'advanced-algebra', 'statistics', 'miscellaneous']),
137
+ dimensions: numberFields(dimensions.label, {
138
+ width: {
139
+ label: 'Width (px)',
140
+ suffix: 'px',
141
+ min: 100,
142
+ max: 500
143
+ },
144
+ height: {
145
+ label: 'Height (px)',
146
+ suffix: 'px',
147
+ min: 100,
148
+ max: 500
149
+ }
150
+ }),
151
+ 'multiple.enabled': multiple.settings && toggle(multiple.label, true),
152
+ promptEnabled: prompt.settings && toggle(prompt.label),
153
+ feedbackEnabled: feedback.settings && toggle(feedback.label)
154
+ },
155
+ 'Properties': {
156
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
157
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label)
158
+ }
159
+ },
160
+ __self: this,
161
+ __source: {
162
+ fileName: _jsxFileName,
163
+ lineNumber: 84
164
+ }
165
+ }),
166
+ __self: this,
167
+ __source: {
168
+ fileName: _jsxFileName,
169
+ lineNumber: 82
170
+ }
171
+ }, React$1.createElement('div', {
172
+ __self: this,
173
+ __source: {
174
+ fileName: _jsxFileName,
175
+ lineNumber: 132
176
+ }
177
+ }, teacherInstructionsEnabled && React$1.createElement(InputContainer, {
178
+ label: teacherInstructions.label,
179
+ className: classes.promptContainer,
180
+ __self: this,
181
+ __source: {
182
+ fileName: _jsxFileName,
183
+ lineNumber: 135
184
+ }
185
+ }, React$1.createElement(EditableHtml, {
186
+ className: classes.prompt,
187
+ markup: model.teacherInstructions || '',
188
+ onChange: this.changeTeacherInstructions,
189
+ imageSupport: imageSupport,
190
+ nonEmpty: false,
191
+ toolbarOpts: toolbarOpts,
192
+ __self: this,
193
+ __source: {
194
+ fileName: _jsxFileName,
195
+ lineNumber: 136
196
+ }
197
+ })), React$1.createElement('br', {
198
+ __self: this,
199
+ __source: {
200
+ fileName: _jsxFileName,
201
+ lineNumber: 147
202
+ }
203
+ }), promptEnabled && React$1.createElement(InputContainer, {
204
+ label: prompt.label,
205
+ className: classes.promptContainer,
206
+ __self: this,
207
+ __source: {
208
+ fileName: _jsxFileName,
209
+ lineNumber: 150
210
+ }
211
+ }, React$1.createElement(EditableHtml, {
212
+ activePlugins: ALL_PLUGINS,
213
+ className: classes.prompt,
214
+ markup: model.prompt || '',
215
+ onChange: this.onPromptChange,
216
+ imageSupport: imageSupport,
217
+ nonEmpty: false,
218
+ toolbarOpts: toolbarOpts,
219
+ __self: this,
220
+ __source: {
221
+ fileName: _jsxFileName,
222
+ lineNumber: 151
223
+ }
224
+ })), feedbackEnabled && React$1.createElement(React$1.Fragment, {
225
+ __self: this,
226
+ __source: {
227
+ fileName: _jsxFileName,
228
+ lineNumber: 165
229
+ }
230
+ }, React$1.createElement(Typography, {
231
+ className: classes.header,
232
+ variant: "subheading",
233
+ __self: this,
234
+ __source: {
235
+ fileName: _jsxFileName,
236
+ lineNumber: 166
237
+ }
238
+ }, "Feedback"), React$1.createElement(FeedbackSelector, {
239
+ label: "When submitted, show",
240
+ feedback: model.feedback || defaultFeedback,
241
+ onChange: this.changeFeedback,
242
+ toolbarOpts: toolbarOpts,
243
+ __self: this,
244
+ __source: {
245
+ fileName: _jsxFileName,
246
+ lineNumber: 170
247
+ }
248
+ }))));
249
+ }
250
+ }
251
+ Main.__initStatic();
252
+ var Main$1 = withStyles(theme => ({
253
+ header: {
254
+ paddingBottom: theme.spacing.unit
255
+ },
256
+ promptContainer: {
257
+ paddingTop: theme.spacing.unit * 2,
258
+ marginBottom: theme.spacing.unit * 2,
259
+ width: '100%'
260
+ },
261
+ promptInput: {
262
+ width: '100%',
263
+ marginBottom: theme.spacing.unit
264
+ },
265
+ field: {
266
+ width: '200px'
267
+ }
268
+ }))(Main);
269
+ var defaults = {
270
+ model: {
271
+ dimensions: {
272
+ height: 100,
273
+ width: 500
274
+ },
275
+ prompt: 'This is the question prompt',
276
+ mathInput: false,
277
+ equationEditor: 'miscellaneous',
278
+ feedbackEnabled: true,
279
+ rationaleEnabled: true,
280
+ promptEnabled: true,
281
+ teacherInstructionsEnabled: true,
282
+ studentInstructionsEnabled: true,
283
+ toolbarEditorPosition: 'bottom'
284
+ },
285
+ configuration: {
286
+ dimensions: {
287
+ settings: true,
288
+ label: 'Text-Entry Display Size'
289
+ },
290
+ equationEditor: {
291
+ settings: false,
292
+ label: 'Equation Editor',
293
+ enabled: true
294
+ },
295
+ feedback: {
296
+ settings: true,
297
+ label: 'Feedback'
298
+ },
299
+ mathInput: {
300
+ settings: true,
301
+ label: 'Student response can include math notation',
302
+ enabled: false
303
+ },
304
+ multiple: {
305
+ settings: false,
306
+ label: 'Multiple Parts',
307
+ enabled: false
308
+ },
309
+ studentInstructions: {
310
+ settings: false,
311
+ label: 'Student Instructions'
312
+ },
313
+ prompt: {
314
+ settings: true,
315
+ label: 'Prompt'
316
+ },
317
+ teacherInstructions: {
318
+ settings: true,
319
+ label: 'Teacher Instructions'
320
+ }
321
+ }
322
+ };
323
+ const React = _dll_react;
324
+ const ReactDOM = _dll_react_dom;
325
+ class ExtendedTextEntry extends HTMLElement {
326
+ static __initStatic() {
327
+ this.createDefaultModel = (model = {}) => ({
328
+ ...defaults.model,
329
+ ...model
330
+ });
331
+ }
332
+ constructor() {
333
+ super();
334
+ this._model = ExtendedTextEntry.createDefaultModel();
335
+ this._configuration = defaults.configuration;
336
+ }
337
+ set model(m) {
338
+ this._model = ExtendedTextEntry.createDefaultModel(m);
339
+ this.render();
340
+ }
341
+ set configuration(c) {
342
+ this._configuration = {
343
+ ...defaults.configuration,
344
+ ...c
345
+ };
346
+ this.render();
347
+ }
348
+ onModelChanged(m) {
349
+ this._model = m;
350
+ this.render();
351
+ this.dispatchEvent(new ModelUpdatedEvent_1(this._model, false));
352
+ }
353
+ onConfigurationChanged(c) {
354
+ this._configuration = {
355
+ ...defaults.configuration,
356
+ ...c
357
+ };
358
+ if (this._model) {
359
+ this.onModelChanged(this._model);
360
+ }
361
+ this.render();
362
+ }
363
+ insertImage(handler) {
364
+ this.dispatchEvent(new InsertImageEvent_1(handler));
365
+ }
366
+ onDeleteImage(src, done) {
367
+ this.dispatchEvent(new DeleteImageEvent_1(src, done));
368
+ }
369
+ render() {
370
+ if (this._model) {
371
+ const element = React.createElement(Main$1, {
372
+ model: this._model,
373
+ configuration: this._configuration,
374
+ onModelChanged: this.onModelChanged.bind(this),
375
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
376
+ imageSupport: {
377
+ add: this.insertImage.bind(this),
378
+ delete: this.onDeleteImage.bind(this)
379
+ }
380
+ });
381
+ ReactDOM.render(element, this);
382
+ }
383
+ }
384
+ }
385
+ ExtendedTextEntry.__initStatic();
386
+ export {ExtendedTextEntry as default};
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Get the feedback from a {FeedbackConfig}
3
+ *
4
+ * @param {FeedbackConfig} feedback
5
+ * @param {string} fallback
6
+ */
7
+ const getFeedback = (feedback, fallback) =>
8
+ new Promise(resolve => {
9
+ if (!feedback || feedback.type === 'none') {
10
+ resolve(undefined);
11
+ return;
12
+ }
13
+ feedback = feedback || {};
14
+ const out = feedback[feedback.type] || fallback;
15
+ resolve(out);
16
+ });
17
+
18
+ var defaults = {
19
+ dimensions: {
20
+ height: 100,
21
+ width: 500,
22
+ }
23
+ };
24
+
25
+ async function createDefaultModel(model = {}) {
26
+
27
+ return {
28
+ ...defaults,
29
+ ...model,
30
+ };
31
+ }
32
+
33
+ const normalize = question => ({
34
+ ...defaults,
35
+ feedbackEnabled: true,
36
+ rationaleEnabled: true,
37
+ promptEnabled: true,
38
+ teacherInstructionsEnabled: true,
39
+ studentInstructionsEnabled: true,
40
+ ...question,
41
+ });
42
+
43
+
44
+ async function model(question, session, env) {
45
+ const normalizedQuestion = normalize(question);
46
+
47
+ const fb =
48
+ env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
49
+ ? getFeedback(normalizedQuestion.feedback, 'Your answer has been submitted')
50
+ : Promise.resolve(undefined);
51
+
52
+ let teacherInstructions = null;
53
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
54
+ teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
55
+ } else {
56
+ teacherInstructions = null;
57
+ }
58
+
59
+ let equationEditor = normalizedQuestion.equationEditor || 'miscellaneous';
60
+
61
+ switch (normalizedQuestion.equationEditor) {
62
+ case 'Grade 1 - 2':
63
+ equationEditor = 1;
64
+ break;
65
+ case 'Grade 3 - 5':
66
+ equationEditor = 3;
67
+ break;
68
+ case 'Grade 6 - 7':
69
+ equationEditor = 6;
70
+ break;
71
+ case 'Grade 8 - HS':
72
+ equationEditor = 8;
73
+ break;
74
+ }
75
+
76
+ return fb.then(feedback => ({
77
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
78
+ dimensions: normalizedQuestion.dimensions,
79
+ customKeys: normalizedQuestion.customKeys || [],
80
+ disabled: env.mode !== 'gather',
81
+ feedback,
82
+ teacherInstructions,
83
+ mathInput: normalizedQuestion.mathInput,
84
+ equationEditor
85
+ }));
86
+ }
87
+
88
+ async function outcome(/*question, session, env*/) {
89
+ return {
90
+ score: 0,
91
+ completed: 'n/a',
92
+ note: 'Requires manual scoring'
93
+ };
94
+ }
95
+
96
+ export { createDefaultModel, model, normalize, outcome };