@pie-element/extended-text-entry 13.4.1-next.0 → 14.0.0-beta.0

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/lib/print.js CHANGED
@@ -1,96 +1,61 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports["default"] = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
-
16
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
17
-
18
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
19
-
20
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
21
-
22
- var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapNativeSuper"));
23
-
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
25
-
7
+ exports.default = void 0;
26
8
  var _react = _interopRequireDefault(require("react"));
27
-
28
- var _reactDom = _interopRequireDefault(require("react-dom"));
29
-
9
+ var _client = require("react-dom/client");
30
10
  var _debounce = _interopRequireDefault(require("lodash/debounce"));
31
-
32
11
  var _main = _interopRequireDefault(require("./main"));
33
-
34
12
  var _mathRendering = require("@pie-lib/math-rendering");
35
-
36
13
  var _debug = _interopRequireDefault(require("debug"));
37
-
38
- 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); }; }
39
-
40
- 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; } }
41
-
42
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
43
-
44
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45
-
46
- var log = (0, _debug["default"])('pie-element:extended-text-entry:print');
47
-
48
- var preparePrintModel = function preparePrintModel(model, opts) {
49
- var instr = opts.role === 'instructor';
14
+ const log = (0, _debug.default)('pie-element:extended-text-entry:print');
15
+ const preparePrintModel = (model, opts) => {
16
+ const instr = opts.role === 'instructor';
50
17
  model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
51
18
  model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
52
19
  model.showTeacherInstructions = instr;
53
20
  model.mode = instr ? 'evaluate' : model.mode;
54
- var defaultDimensions = {
21
+ const defaultDimensions = {
55
22
  height: 100,
56
23
  width: 500
57
24
  };
58
- model.dimensions = _objectSpread(_objectSpread({}, defaultDimensions), model.dimensions);
25
+ model.dimensions = {
26
+ ...defaultDimensions,
27
+ ...model.dimensions
28
+ };
59
29
  model.disabled = true;
60
30
  model.feedback = undefined;
61
31
  model.animationsDisabled = true;
62
32
  return model;
63
33
  };
64
-
65
- var ExtendedTextEntryPrint = /*#__PURE__*/function (_HTMLElement) {
66
- (0, _inherits2["default"])(ExtendedTextEntryPrint, _HTMLElement);
67
-
68
- var _super = _createSuper(ExtendedTextEntryPrint);
69
-
70
- function ExtendedTextEntryPrint() {
71
- var _this;
72
-
73
- (0, _classCallCheck2["default"])(this, ExtendedTextEntryPrint);
74
- _this = _super.call(this);
75
- _this._options = null;
76
- _this._model = null;
77
- _this._session = [];
78
- _this._rerender = (0, _debounce["default"])(function () {
79
- if (_this._model && _this._session) {
80
- var printModel = preparePrintModel(_this._model, _this._options);
81
-
82
- var element = _this._options && /*#__PURE__*/_react["default"].createElement(_main["default"], {
34
+ class ExtendedTextEntryPrint extends HTMLElement {
35
+ constructor() {
36
+ super();
37
+ this._options = null;
38
+ this._model = null;
39
+ this._session = [];
40
+ this._root = null;
41
+ this._rerender = (0, _debounce.default)(() => {
42
+ if (this._model && this._session) {
43
+ const printModel = preparePrintModel(this._model, this._options);
44
+ const element = this._options && /*#__PURE__*/_react.default.createElement(_main.default, {
83
45
  model: printModel,
84
46
  session: {},
85
- onChange: function onChange() {},
86
- onValueChange: function onValueChange() {},
87
- onAnnotationsChange: function onAnnotationsChange() {},
88
- onCommentChange: function onCommentChange() {}
47
+ onChange: () => {},
48
+ onValueChange: () => {},
49
+ onAnnotationsChange: () => {},
50
+ onCommentChange: () => {}
89
51
  });
90
-
91
- _reactDom["default"].render(element, (0, _assertThisInitialized2["default"])(_this), function () {
52
+ if (!this._root) {
53
+ this._root = (0, _client.createRoot)(this);
54
+ }
55
+ this._root.render(element);
56
+ queueMicrotask(() => {
92
57
  log('render complete - render math');
93
- (0, _mathRendering.renderMath)((0, _assertThisInitialized2["default"])(_this));
58
+ (0, _mathRendering.renderMath)(this);
94
59
  });
95
60
  } else {
96
61
  log('skip');
@@ -99,27 +64,20 @@ var ExtendedTextEntryPrint = /*#__PURE__*/function (_HTMLElement) {
99
64
  leading: false,
100
65
  trailing: true
101
66
  });
102
- return _this;
103
67
  }
104
-
105
- (0, _createClass2["default"])(ExtendedTextEntryPrint, [{
106
- key: "options",
107
- set: function set(o) {
108
- this._options = o;
109
- }
110
- }, {
111
- key: "model",
112
- set: function set(s) {
113
- this._model = s;
114
-
115
- this._rerender();
68
+ set options(o) {
69
+ this._options = o;
70
+ }
71
+ set model(s) {
72
+ this._model = s;
73
+ this._rerender();
74
+ }
75
+ connectedCallback() {}
76
+ disconnectedCallback() {
77
+ if (this._root) {
78
+ this._root.unmount();
116
79
  }
117
- }, {
118
- key: "connectedCallback",
119
- value: function connectedCallback() {}
120
- }]);
121
- return ExtendedTextEntryPrint;
122
- }( /*#__PURE__*/(0, _wrapNativeSuper2["default"])(HTMLElement));
123
-
124
- exports["default"] = ExtendedTextEntryPrint;
80
+ }
81
+ }
82
+ exports.default = ExtendedTextEntryPrint;
125
83
  //# sourceMappingURL=print.js.map
package/lib/print.js.map CHANGED
@@ -1 +1 @@
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","onValueChange","onAnnotationsChange","onCommentChange","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,GACEL,KAAK,IAAIF,KAAK,CAACQ,0BAAN,KAAqC,KAA9C,GAAsDR,KAAK,CAACO,mBAA5D,GAAkFD,SADpF;AAEAN,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,CArBD;;IAuBqBkB,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,CAHM;AAIxBC,UAAAA,aAAa,EAAE,yBAAM,CAAE,CAJC;AAKxBC,UAAAA,mBAAmB,EAAE,+BAAM,CAAE,CALL;AAMxBC,UAAAA,eAAe,EAAE,2BAAM,CAAE;AAND,SAA1B,CAFF;;AAWAC,6BAASC,MAAT,CAAgBV,OAAhB,kDAA+B,YAAM;AACnC1B,UAAAA,GAAG,CAAC,+BAAD,CAAH;AACA;AACD,SAHD;AAID,OAlBD,MAkBO;AACLA,QAAAA,GAAG,CAAC,MAAD,CAAH;AACD;AACF,KAvBc,EAwBf,EAxBe,EAyBf;AAAEqC,MAAAA,OAAO,EAAE,KAAX;AAAkBC,MAAAA,QAAQ,EAAE;AAA5B,KAzBe,CAAjB;AALY;AAgCb;;;;SACD,aAAYC,CAAZ,EAAe;AACb,WAAKlB,QAAL,GAAgBkB,CAAhB;AACD;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKlB,MAAL,GAAckB,CAAd;;AACA,WAAKhB,SAAL;AACD;;;WAED,6BAAoB,CAAE;;;kDA3C4BiB,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 =\n 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 onValueChange: () => {},\n onAnnotationsChange: () => {},\n onCommentChange: () => {},\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,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_debounce","_main","_mathRendering","_debug","log","debug","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","mode","defaultDimensions","height","width","dimensions","disabled","feedback","animationsDisabled","ExtendedTextEntryPrint","HTMLElement","constructor","_options","_model","_session","_root","_rerender","debounce","printModel","element","React","createElement","Main","session","onChange","onValueChange","onAnnotationsChange","onCommentChange","createRoot","render","queueMicrotask","renderMath","leading","trailing","options","o","s","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\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 =\n 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._root = null;\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 onValueChange: () => {},\n onAnnotationsChange: () => {},\n onCommentChange: () => {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\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 disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,uCAAuC,CAAC;AAE1D,MAAMC,iBAAiB,GAAGA,CAACC,KAAK,EAAEC,IAAI,KAAK;EACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,KAAK,YAAY;EAExCH,KAAK,CAACI,MAAM,GAAGJ,KAAK,CAACK,aAAa,KAAK,KAAK,GAAGL,KAAK,CAACI,MAAM,GAAGE,SAAS;EACvEN,KAAK,CAACO,mBAAmB,GACvBL,KAAK,IAAIF,KAAK,CAACQ,0BAA0B,KAAK,KAAK,GAAGR,KAAK,CAACO,mBAAmB,GAAGD,SAAS;EAC7FN,KAAK,CAACS,uBAAuB,GAAGP,KAAK;EACrCF,KAAK,CAACU,IAAI,GAAGR,KAAK,GAAG,UAAU,GAAGF,KAAK,CAACU,IAAI;EAE5C,MAAMC,iBAAiB,GAAG;IAAEC,MAAM,EAAE,GAAG;IAAEC,KAAK,EAAE;EAAI,CAAC;EAErDb,KAAK,CAACc,UAAU,GAAG;IACjB,GAAGH,iBAAiB;IACpB,GAAGX,KAAK,CAACc;EACX,CAAC;EAEDd,KAAK,CAACe,QAAQ,GAAG,IAAI;EACrBf,KAAK,CAACgB,QAAQ,GAAGV,SAAS;EAC1BN,KAAK,CAACiB,kBAAkB,GAAG,IAAI;EAE/B,OAAOjB,KAAK;AACd,CAAC;AAEc,MAAMkB,sBAAsB,SAASC,WAAW,CAAC;EAC9DC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,QAAQ,GAAG,IAAI;IACpB,IAAI,CAACC,MAAM,GAAG,IAAI;IAClB,IAAI,CAACC,QAAQ,GAAG,EAAE;IAClB,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,SAAS,GAAG,IAAAC,iBAAQ,EACvB,MAAM;MACJ,IAAI,IAAI,CAACJ,MAAM,IAAI,IAAI,CAACC,QAAQ,EAAE;QAChC,MAAMI,UAAU,GAAG5B,iBAAiB,CAAC,IAAI,CAACuB,MAAM,EAAE,IAAI,CAACD,QAAQ,CAAC;QAEhE,MAAMO,OAAO,GACX,IAAI,CAACP,QAAQ,iBACbQ,cAAK,CAACC,aAAa,CAACC,aAAI,EAAE;UACxB/B,KAAK,EAAE2B,UAAU;UACjBK,OAAO,EAAE,CAAC,CAAC;UACXC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;UAClBC,aAAa,EAAEA,CAAA,KAAM,CAAC,CAAC;UACvBC,mBAAmB,EAAEA,CAAA,KAAM,CAAC,CAAC;UAC7BC,eAAe,EAAEA,CAAA,KAAM,CAAC;QAC1B,CAAC,CAAC;QAEJ,IAAI,CAAC,IAAI,CAACZ,KAAK,EAAE;UACf,IAAI,CAACA,KAAK,GAAG,IAAAa,kBAAU,EAAC,IAAI,CAAC;QAC/B;QACA,IAAI,CAACb,KAAK,CAACc,MAAM,CAACV,OAAO,CAAC;QAC1BW,cAAc,CAAC,MAAM;UACnB1C,GAAG,CAAC,+BAA+B,CAAC;UACpC,IAAA2C,yBAAU,EAAC,IAAI,CAAC;QAClB,CAAC,CAAC;MACJ,CAAC,MAAM;QACL3C,GAAG,CAAC,MAAM,CAAC;MACb;IACF,CAAC,EACD,EAAE,EACF;MAAE4C,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAK,CACnC,CAAC;EACH;EACA,IAAIC,OAAOA,CAACC,CAAC,EAAE;IACb,IAAI,CAACvB,QAAQ,GAAGuB,CAAC;EACnB;EAEA,IAAI5C,KAAKA,CAAC6C,CAAC,EAAE;IACX,IAAI,CAACvB,MAAM,GAAGuB,CAAC;IACf,IAAI,CAACpB,SAAS,CAAC,CAAC;EAClB;EAEAqB,iBAAiBA,CAAA,EAAG,CAAC;EAErBC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACvB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACwB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhC,sBAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "13.4.1-next.0+bb17c7e0a",
3
+ "version": "14.0.0-beta.0",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -9,28 +9,26 @@
9
9
  "author": "pie framework developers",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@material-ui/core": "^3.9.2",
13
- "@material-ui/icons": "^3.0.2",
12
+ "@emotion/react": "^11.14.0",
13
+ "@emotion/style": "^0.8.0",
14
+ "@mui/icons-material": "^7.3.4",
15
+ "@mui/material": "^7.3.4",
14
16
  "@pie-framework/pie-player-events": "^0.1.0",
15
- "@pie-lib/config-ui": "11.30.2",
16
- "@pie-lib/editable-html": "11.21.2",
17
- "@pie-lib/math-rendering": "3.22.1",
18
- "@pie-lib/render-ui": "4.35.2",
17
+ "@pie-lib/config-ui": "11.30.4-next.0",
18
+ "@pie-lib/editable-html": "11.21.4-next.0",
19
+ "@pie-lib/math-rendering": "3.22.3-next.0",
20
+ "@pie-lib/render-ui": "4.35.4-next.0",
19
21
  "classnames": "^2.2.5",
20
22
  "debug": "^4.1.1",
21
23
  "lodash.throttle": "^4.1.1",
22
24
  "prop-types": "^15.6.1",
23
- "react": "^16.8.1",
24
- "react-dom": "^16.8.1"
25
+ "react": "18.2.0",
26
+ "react-dom": "18.2.0"
25
27
  },
26
- "gitHead": "bb17c7e0a54b6b5ff139075cccf1e341cc6f859f",
28
+ "gitHead": "028605f2d7b2b3b7e5b8840078c0d2c5d9a562e0",
27
29
  "scripts": {
28
30
  "postpublish": "../../scripts/postpublish"
29
31
  },
30
32
  "main": "lib/index.js",
31
- "module": "src/index.js",
32
- "exports": {
33
- ".": "./src/index.js",
34
- "./print": "./src/print.js"
35
- }
33
+ "module": "src/index.js"
36
34
  }
@@ -1 +0,0 @@
1
- import{_dll_react as e,_dll_prop_types as t,_dll_material_ui__core as n,_dll_material_ui__core_styles as a,_dll_react_dom as i}from"../../../@pie-lib/shared-module@^1.17.5/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^2.23.3/module/index.js";import{_dll_pie_lib__editable_html as o}from"../../../@pie-lib/editable-html-module@^5.9.5/module/index.js";var l={};Object.defineProperty(l,"__esModule",{value:!0});class r extends CustomEvent{constructor(e,t=!1){super(r.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}r.TYPE="model.updated";var d=l.ModelUpdatedEvent=r;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}c.TYPE="delete.image";var p=l.DeleteImageEvent=c;class u extends CustomEvent{constructor(e){super(u.TYPE,{bubbles:!0,detail:e}),this.handler=e}}u.TYPE="insert.image";var h=l.InsertImageEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.sound";var b=l.DeleteSoundEvent=g;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.sound";var E=l.InsertSoundEvent=m;const _=e,f=t,{Typography:C}=n,{withStyles:I}=a,{FeedbackSelector:v}=s,{InputContainer:S}=s,{settings:x}=s,{layout:y}=s,k=o,{ALL_PLUGINS:P}=o;function w(e){let t,n=e[0],a=1;for(;a<e.length;){const i=e[a],s=e[a+1];if(a+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=s(n)):"call"!==i&&"optionalCall"!==i||(n=s(((...e)=>n.call(t,...e))),t=void 0)}return n}const{Panel:T,toggle:M,numberFields:A,dropdown:D}=x,R={type:"default",default:"Your answer has been submitted"};class q extends _.Component{static __initStatic(){this.propTypes={onModelChanged:f.func.isRequired,onConfigurationChanged:f.func,model:f.object.isRequired,configuration:f.object.isRequired,imageSupport:f.object.isRequired,uploadSoundSupport:f.object.isRequired,classes:f.object.isRequired}}constructor(e){super(e),q.prototype.__init.call(this),q.prototype.__init2.call(this),q.prototype.__init3.call(this),this.state={setDimensions:!0}}__init(){this.onPromptChange=e=>{const{onModelChanged:t,model:n}=this.props;t({...n,prompt:e})}}__init2(){this.changeFeedback=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,feedback:e})}}__init3(){this.changeTeacherInstructions=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,teacherInstructions:e})}}render(){const{model:e,classes:t,configuration:n,imageSupport:a,onConfigurationChanged:i,onModelChanged:s,uploadSoundSupport:o}=this.props,{annotations:l={},contentDimensions:r={},dimensions:d={},equationEditor:c={},feedback:p={},playerSpellCheck:u={},prompt:h={},settingsPanelDisabled:g,spanishInput:b={},specialInput:m={},spellCheck:E={},studentInstructions:f={},teacherInstructions:I={},mathInput:x={},maxImageWidth:q={},maxImageHeight:Y={},multiple:j={},withRubric:O={},mathMlOptions:H={},baseInputConfiguration:N={}}=n||{},{errors:F={},extraCSSRules:G,feedbackEnabled:W,promptEnabled:L,spellCheckEnabled:z,teacherInstructionsEnabled:B,toolbarEditorPosition:U}=e||{},{prompt:J,teacherInstructions:K}=F,Q=q&&q.prompt,V=Y&&Y.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:x.settings&&M(x.label),equationEditor:c.enabled&&e.mathInput&&D(c.label,["non-negative-integers","integers","decimals","fractions","Grade 1 - 2","Grade 3 - 5","Grade 6 - 7","Grade 8 - HS","geometry","advanced-algebra","statistics","item-authoring"]),spanishInput:b.settings&&M(b.label),specialInput:m.settings&&M(m.label),dimensions:d.settings&&A(d.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":j.settings&&M(j.label,!0),promptEnabled:h.settings&&M(h.label),feedbackEnabled:p.settings&&M(p.label),annotationsEnabled:l.settings&&M(l.label),spellCheckEnabled:E.settings&&M(E.label),playerSpellCheckDisabled:u.settings&&M(u.label)},$={teacherInstructionsEnabled:I.settings&&M(I.label),studentInstructionsEnabled:f.settings&&M(f.label),rubricEnabled:w([O,"optionalAccess",e=>e.settings])&&M(w([O,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...N},e||{});return _.createElement(y.ConfigLayout,{extraCSSRules:G,dimensions:r,hideSettings:g,settings:_.createElement(T,{model:e,configuration:n,onChangeModel:e=>s(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&_.createElement(S,{label:I.label,className:t.promptContainer},_.createElement(k,{className:t.prompt,markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:a,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:z,maxImageWidth:q&&q.teacherInstructions||Q,maxImageHeight:Y&&Y.teacherInstructions||V,uploadSoundSupport:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:H,pluginProps:ee(w([I,"optionalAccess",e=>e.inputConfiguration]))}),K&&_.createElement("div",{className:t.errorText},K)),L&&_.createElement(S,{label:h.label,className:t.promptContainer},_.createElement(k,{activePlugins:P,className:t.prompt,markup:e.prompt||"",onChange:this.onPromptChange,imageSupport:a,nonEmpty:!1,error:J,toolbarOpts:X,spellCheck:z,maxImageWidth:Q,maxImageHeight:V,uploadSoundSupport:o,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:H,pluginProps:ee(w([h,"optionalAccess",e=>e.inputConfiguration]))}),J&&_.createElement("div",{className:t.errorText},J)),W&&_.createElement(_.Fragment,null,_.createElement(C,{className:t.header,variant:"subheading"},"Feedback"),_.createElement(v,{label:"When submitted, show",feedback:e.feedback||R,onChange:this.changeFeedback,toolbarOpts:X})))}}q.__initStatic();var Y=I((e=>({header:{paddingBottom:e.spacing.unit},promptContainer:{paddingTop:2*e.spacing.unit,marginBottom:2*e.spacing.unit,width:"100%"},errorText:{fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing.unit}})))(q),j={annotationsEnabled:!1,dimensions:{height:100,width:500},equationEditor:"Grade 8 - HS",feedbackEnabled:!1,mathInput:!1,playerSpellCheckDisabled:!0,predefinedAnnotations:[{label:"good",text:"good",type:"positive"},{label:"★",text:"★",type:"positive"},{label:":-)",text:":-)",type:"positive"},{label:"creative",text:"creative",type:"positive"},{label:"run-on",text:"run-on",type:"negative"},{label:"frag",text:"fragment",type:"negative"},{label:"tran",text:"transition",type:"negative"},{label:"supp",text:"support needed",type:"negative"},{label:"punc",text:"punctuation",type:"negative"},{label:"agr",text:"agreement wrong",type:"negative"},{label:"unclear",text:"unclear",type:"negative"},{label:"cut",text:"cut",type:"negative"},{label:"sp",text:"spelling",type:"negative"},{label:"cap",text:"capitalization",type:"negative"},{label:"inf",text:"informal",type:"negative"},{label:"awk",text:"awkward",type:"negative"}],prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,spanishInput:!1,specialInput:!1,spellCheckEnabled:!0,studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom"},O={annotations:{settings:!1,label:"Annotations"},baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},dimensions:{settings:!0,label:"Text-Entry Display Size"},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},playerSpellCheck:{label:"Disable Student Spellcheck",settings:!0,enabled:!0},equationEditor:{settings:!1,label:"Equation Editor",enabled:!0},feedback:{settings:!0,label:"Feedback"},mathInput:{settings:!0,label:"Student response can include math notation",enabled:!1},settingsPanelDisabled:!1,spanishInput:{settings:!0,label:"Students can insert Spanish",enabled:!1},specialInput:{settings:!0,label:"Students can insert Special Characters",enabled:!1},multiple:{settings:!1,label:"Multiple Parts",enabled:!1},studentInstructions:{settings:!1,label:"Student Instructions"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,prompt:300},maxImageHeight:{teacherInstructions:300,prompt:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1}};const H=e,N=i;function F(e){let t,n=e[0],a=1;for(;a<e.length;){const i=e[a],s=e[a+1];if(a+=2,("optionalAccess"===i||"optionalCall"===i)&&null==n)return;"access"===i||"optionalAccess"===i?(t=n,n=s(n)):"call"!==i&&"optionalCall"!==i||(n=s(((...e)=>n.call(t,...e))),t=void 0)}return n}class G extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...j,...e};return F([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._configuration=O,F([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=G.createDefaultModel({},this._configuration)}set model(e){this._model=G.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...O,...e};const{withRubric:t={}}=e||{};F([t,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1,this._model.rubricEnabled||(this._model.rubricEnabled=!0)),this.render()}onModelChanged(e){this._model=e,this.render(),this.dispatchEvent(new d(this._model,!1))}onConfigurationChanged(e){this._configuration={...O,...e},this._model&&this.onModelChanged(this._model),this.render()}insertImage(e){this.dispatchEvent(new h(e))}onDeleteImage(e,t){this.dispatchEvent(new p(e,t))}insertSound(e){this.dispatchEvent(new E(e))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=H.createElement(Y,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});N.render(e,this)}}}G.__initStatic();export{G as default};
@@ -1,139 +0,0 @@
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
- annotationsEnabled: false,
20
- dimensions: { height: 100, width: 500 },
21
- equationEditor: 'Grade 8 - HS',
22
- feedbackEnabled: false,
23
- mathInput: false,
24
- playerSpellCheckDisabled: true,
25
- predefinedAnnotations: [
26
- { label: 'good', text: 'good', type: 'positive' },
27
- { label: '★', text: '★', type: 'positive' },
28
- { label: ':-)', text: ':-)', type: 'positive' },
29
- { label: 'creative', text: 'creative', type: 'positive' },
30
- { label: 'run-on', text: 'run-on', type: 'negative' },
31
- { label: 'frag', text: 'fragment', type: 'negative' },
32
- { label: 'tran', text: 'transition', type: 'negative' },
33
- { label: 'supp', text: 'support needed', type: 'negative' },
34
- { label: 'punc', text: 'punctuation', type: 'negative' },
35
- { label: 'agr', text: 'agreement wrong', type: 'negative' },
36
- { label: 'unclear', text: 'unclear', type: 'negative' },
37
- { label: 'cut', text: 'cut', type: 'negative' },
38
- { label: 'sp', text: 'spelling', type: 'negative' },
39
- { label: 'cap', text: 'capitalization', type: 'negative' },
40
- { label: 'inf', text: 'informal', type: 'negative' },
41
- { label: 'awk', text: 'awkward', type: 'negative' },
42
- ],
43
- prompt: '',
44
- promptEnabled: true,
45
- rationale: '',
46
- rationaleEnabled: true,
47
- studentInstructionsEnabled: true,
48
- teacherInstructions: '',
49
- teacherInstructionsEnabled: true,
50
- toolbarEditorPosition: 'bottom',
51
- };
52
-
53
- async function createDefaultModel(model = {}) {
54
-
55
- return { ...defaults, ...model };
56
- }
57
-
58
- const normalize = (question) => ({ ...defaults, ...question });
59
-
60
- async function model(question, session, env) {
61
- const normalizedQuestion = normalize(question);
62
-
63
- const fb =
64
- env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
65
- ? getFeedback(normalizedQuestion.feedback, 'Your answer has been submitted')
66
- : Promise.resolve(undefined);
67
-
68
- let teacherInstructions = null;
69
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
70
- teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
71
- } else {
72
- teacherInstructions = null;
73
- }
74
-
75
- let equationEditor = normalizedQuestion.equationEditor || 'miscellaneous';
76
-
77
- switch (normalizedQuestion.equationEditor) {
78
- case 'Grade 1 - 2':
79
- equationEditor = 1;
80
- break;
81
- case 'Grade 3 - 5':
82
- equationEditor = 3;
83
- break;
84
- case 'Grade 6 - 7':
85
- equationEditor = 6;
86
- break;
87
- case 'Grade 8 - HS':
88
- equationEditor = 8;
89
- break;
90
- }
91
-
92
- const annotatorMode = normalizedQuestion.annotationsEnabled && (env.role === 'instructor' || env.mode === 'evaluate');
93
-
94
- return fb.then((feedback) => ({
95
- prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
96
- dimensions: normalizedQuestion.dimensions,
97
- customKeys: normalizedQuestion.customKeys || [],
98
- id: normalizedQuestion.id,
99
- disabled: env.mode !== 'gather',
100
- feedback,
101
- teacherInstructions,
102
- language: normalizedQuestion.language,
103
- mathInput: normalizedQuestion.mathInput,
104
- spanishInput: normalizedQuestion.spanishInput,
105
- specialInput: normalizedQuestion.specialInput,
106
- equationEditor,
107
- spellCheckEnabled: !normalizedQuestion.playerSpellCheckDisabled,
108
- playersToolbarPosition: normalizedQuestion.playersToolbarPosition || 'bottom',
109
- annotatorMode,
110
- disabledAnnotator: normalizedQuestion.annotationsEnabled ? env.role !== 'instructor' : true,
111
- predefinedAnnotations: normalizedQuestion.annotationsEnabled ? normalizedQuestion.predefinedAnnotations : [],
112
- extraCSSRules: normalizedQuestion.extraCSSRules,
113
- }));
114
- }
115
-
116
- async function outcome(/*question, session, env*/) {
117
- return {
118
- score: 0,
119
- completed: 'n/a',
120
- note: 'Requires manual scoring',
121
- };
122
- }
123
-
124
- // remove all html tags except img, iframe and source tag for audio
125
- const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
126
-
127
- const validate = (model = {}, config = {}) => {
128
- const errors = {};
129
-
130
- ['teacherInstructions', 'prompt'].forEach((field) => {
131
- if (config[field]?.required && !getContent(model[field])) {
132
- errors[field] = 'This field is required.';
133
- }
134
- });
135
-
136
- return errors;
137
- };
138
-
139
- export { createDefaultModel, model, normalize, outcome, validate };
package/module/demo.js DELETED
@@ -1,38 +0,0 @@
1
- import Configure from './configure.js';
2
- import Element from './element.js';
3
- import * as controller from './controller.js';
4
-
5
- var generate = {};
6
-
7
- generate.model = (id, element) => ({
8
- id,
9
- element,
10
- customKeys: ['\\square'],
11
- feedback: { type: 'default', default: 'this is default feedback' },
12
- prompt: 'This is the question prompt',
13
- promptEnabled: true,
14
- mathInput: true,
15
- playersToolbarPosition: 'bottom',
16
- toolbarEditorPosition: 'bottom',
17
- spellCheckEnabled: true,
18
- rubricEnabled: false,
19
- annotationsEnabled: false,
20
- });
21
-
22
- const { model } = generate;
23
- var config = {
24
- elements: {
25
- 'extended-text-entry': '../..',
26
- },
27
- models: [model('1', 'extended-text-entry')],
28
- };
29
-
30
- //Note: demo-el is a custom element loaded in the markup.
31
- customElements.whenDefined("demo-el").then(() => {
32
- config.models.forEach((m) => {
33
- const de = document.createElement("demo-el");
34
- document.body.appendChild(de);
35
- de.def = { tagName: m.element, Element, Configure, controller };
36
- de.model = m;
37
- });
38
- });
package/module/element.js DELETED
@@ -1 +0,0 @@
1
- import{_dll_react as e,_dll_classnames as t,_dll_prop_types as n,_dll_material_ui__core as o,_dll_material_ui__core_styles as i,_dll_lodash as s,_dll_debug as a,_dll_pie_lib__render_ui as r,_dll_react_dom as l}from"../../../@pie-lib/shared-module@^1.17.5/module/index.js";import{_dll_pie_lib__math_rendering as d}from"../../../@pie-lib/math-rendering-module@^3.1.5/module/index.js";import{_dll_pie_lib__editable_html as c}from"../../../@pie-lib/editable-html-module@^5.9.5/module/index.js";import{_dll_pie_lib__config_ui as p}from"../../../@pie-lib/config-module@^2.23.3/module/index.js";const h=(e,t,n)=>{const o=n||[],i=o.reduce(((e,t)=>e+t.textContent.length),0);let s=!0;if(i>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&s;)s=h(e,t,o),e=e.nextSibling;return o},m=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:i,endOffset:s}=e,a=[];let r=!1,l=!1,d="";const c=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(d+=t.substring(i,s)),r=l=!0):e===n?(t&&(d+=t.substring(i)),r=!0):e===o?(t&&(d+=t.substring(0,s)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&r&&!l&&(d+=t,a.push(e)),p.forEach((e=>{l||c(e)}))};return c(t),[a,d]},u=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},g=e=>{if(e.startContainer===e.endContainer)return[u(e)];const[t]=m(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=u(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const s=u(i);return[o,...t.map((e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t})),s]},b=(e,t)=>{(e||[]).forEach((e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let i=0;i<o;i++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)})),t.normalize()},f=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},v=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),C=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),x=e=>document.querySelector(`[data-ann-id='${e}']`),y=e,_=t,E=n,{Popover:w}=o,{TextField:S}=o,{withStyles:A}=i;class R extends y.Component{static __initStatic(){this.propTypes={anchorEl:E.object,open:E.bool,offset:E.number,value:E.string,type:E.string,onClose:E.func,onDelete:E.func,onSave:E.func,onTypeChange:E.func}}constructor(e){super(e),R.prototype.__init.call(this),R.prototype.__init2.call(this),R.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:o}=this.props,{value:i}=this.state;""===i&&o(),e!==i&&t(e,i),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,classes:t,offset:n,onDelete:o,open:i,type:s}=this.props,{value:a}=this.state;return y.createElement(w,{anchorEl:e,elevation:2,open:i,onClose:this.handleSave,classes:{paper:_(t.arrow,s)},style:{marginTop:`${n}px`,transition:"margin-top 2s ease-out"},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},y.createElement("div",{className:_(t.wrapper,s)},y.createElement(S,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,rowsMax:4,value:a,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),y.createElement("div",{className:t.holder},y.createElement("div",{className:t.button,onClick:o},"Delete"),y.createElement("div",{className:_(t.button,s),onClick:this.handleTypeChange},"negative"===s?"Green":"Pink"),y.createElement("div",{className:t.button,onClick:this.handleSave},"Save"))))}}R.__initStatic();var k=A((e=>({wrapper:{width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,"&.negative":{borderColor:"rgb(255, 204, 238) !important"},"&.positive":{borderColor:"rgb(153, 255, 153) !important"}},holder:{display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`},positive:{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},negative:{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},button:{flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},"&.negative:hover":{backgroundColor:"rgb(153, 255, 153) !important"},"&.positive:hover":{backgroundColor:"rgb(255, 204, 238) !important"}},arrow:{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},"&.negative::before":{borderRightColor:"rgb(255, 204, 238) !important"},"&.positive::before":{borderRightColor:"rgb(153, 255, 153) !important"}}})))(R);const N=e,T=t,M=n,{withStyles:L}=i,{Popover:I}=o;class W extends N.Component{static __initStatic(){this.propTypes={anchorEl:M.object,open:M.bool,annotations:M.array,isNewAnnotation:M.bool,onClose:M.func,onDelete:M.func,onEdit:M.func,onWrite:M.func,onAnnotate:M.func}}render(){const{anchorEl:e,annotations:t,classes:n,isNewAnnotation:o,onAnnotate:i,onClose:s,onEdit:a,onDelete:r,onWrite:l,open:d}=this.props;return N.createElement(I,{anchorEl:e,open:d,onClose:s,classes:{paper:n.arrow},elevation:5,anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},N.createElement("div",{className:n.mainWrapper},N.createElement("div",{className:n.annotationsWrapper},t.map(((e,t)=>N.createElement("div",{key:`annotation-${t}`,className:T(n.button,"positive"===e.type?n.positive:n.negative),onClick:()=>i(e)},e.label)))),N.createElement("div",{className:n.controlsWrapper},N.createElement("div",{className:n.button,onClick:s},"Cancel"),N.createElement("div",{style:{pointerEvents:"none"},className:n.button}),o?N.createElement(N.Fragment,null,N.createElement("div",{className:T(n.button,n.positive),onClick:()=>l("positive")},"Write"),N.createElement("div",{className:T(n.button,n.negative),onClick:()=>l("negative")},"Write")):N.createElement(N.Fragment,null,N.createElement("div",{className:n.button,onClick:r},"Delete"),N.createElement("div",{className:n.button,onClick:a},"Edit")))))}}W.__initStatic();var P=L((e=>({mainWrapper:{width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`},annotationsWrapper:{display:"flex",flexWrap:"wrap"},controlsWrapper:{display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`},button:{width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]}},positive:{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},negative:{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},holder:{display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`},arrow:{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}})))(W);const D=e,{withStyles:H}=i,O=t,$=n,z=c,{InputContainer:j}=p;class q extends D.Component{static __initStatic(){this.propTypes={text:$.string,comment:$.string,annotations:$.array,predefinedAnnotations:$.array,onChange:$.func.isRequired,onCommentChange:$.func.isRequired,width:$.number,height:$.number,maxHeight:$.string,disabled:$.bool,disabledMath:$.bool,customKeys:$.array,keypadMode:$.string,classes:$.object.isRequired}}constructor(e){super(e),q.prototype.__init.call(this),q.prototype.__init2.call(this),q.prototype.__init3.call(this),q.prototype.__init4.call(this),q.prototype.__init5.call(this),q.prototype.__init6.call(this),q.prototype.__init7.call(this),q.prototype.__init8.call(this),q.prototype.__init9.call(this),q.prototype.__init10.call(this),q.prototype.__init11.call(this),q.prototype.__init12.call(this),q.prototype.__init13.call(this),q.prototype.__init14.call(this),q.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach((e=>{const[t,n]=((e,t,n)=>{const o=h(n,t),i=[];let s=0;return o.forEach((n=>{const o=s+n.textContent.length;[e,t].forEach((e=>{s<=e&&e<o&&i.push({node:n,offset:e-s})})),s=o})),i})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const i=g(o);this.createDOMAnnotation(i,e)}})),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach((t=>{const n=C(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`}))}}}__init2(){this.handleClick=e=>{const{annotations:t,classes:n}=this.props,{selectionDetails:o}=this.state;if(o)return;const{id:i,annId:s}=e.target.dataset,a=i||s,r=C(a),l=x(a),d=t.findIndex((e=>e.id===a)),c=l.hasAttribute("data-freeform");c&&l.classList.add(n.highlight),this.setState({anchorEl:r[0],openedMenu:!!i||!!s&&!c,openedEditor:!!s&&c,selectedElems:r,labelElem:l,annotationIndex:d,annotation:t[d],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{classes:t}=this.props,{id:n,annId:o}=e.target.dataset,i=n||o,s=C(i),a=x(i),r=a.hasAttribute("data-freeform");s.forEach((e=>e.classList.add(t.hover))),a.classList.add(r?t.sideAnnotationHover:t.labelHover)}}__init4(){this.handleCancelHover=e=>{const{classes:t}=this.props,{id:n,annId:o}=e.target.dataset,i=n||o,s=C(i),a=x(i),r=a.hasAttribute("data-freeform");s.forEach((e=>e.classList.remove(t.hover))),a.classList.remove(r?t.sideAnnotationHover:t.labelHover)}}__init5(){this.handleClose=e=>{const{classes:t}=this.props,{selectedElems:n,labelElem:o}=this.state;n.length&&!n[0].hasAttribute("data-id")&&b(n,this.textRef),o&&o.classList.remove(t.highlight),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),f()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)f();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=m(n),[,i]=m(e),s=o.length;return{quote:i,start:s,end:s+i.length}})(e,this.textRef),n=g(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:o,annotationIndex:i,annotation:s}=this.state;(v(s.label)?this.labelsRef:n[0]).removeChild(o),b(n,this.textRef),e.splice(i,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{classes:n,disabled:o}=this.props,{id:i,label:s,type:a}=t;(e||[]).forEach((e=>{e.dataset.id=i,e.className=O(n.annotation,a),e.onclick=!o&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover}));const r=e&&e[0]||{},l=document.createElement("SPAN");if(l.dataset.annId=i,l.innerHTML=s,l.onclick=!o&&this.handleClick,l.onmouseover=this.handleHover,l.onmouseout=this.handleCancelHover,v(s)){const e=(r.offsetTop?r.offsetTop:r.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;l.dataset.freeform=!0,l.className=O(n.sideAnnotation,a),l.style.top=`${e}px`,l.style.left=`${t}px`,this.labelsRef.appendChild(l)}else l.className=O(n.annotationLabel,a),r.appendChild(l)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,i={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,i),i}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:i}=this.state,{type:s,text:a}=e;if(o){const e={...o,label:a,type:s},{type:n,label:r}=o;this.updateLabel(r,e,s!==n&&n),t.splice(i,1,e)}else{const e=this.createNewAnnotation(a,s);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,o=this.createNewAnnotation("",e),i=x(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:i}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:i}=this.state,{label:s,type:a}=t;v(s)&&v(e)||!v(s)&&!v(e)?(i.innerHTML=s,n&&(i.classList.remove(n),i.classList.add(a),o.forEach((e=>{e.classList.remove(n),e.classList.add(a)})))):v(s)&&!v(e)?(o[0].removeChild(i),this.createDOMAnnotation(o,t)):!v(s)&&v(e)&&(this.labelsRef.removeChild(i),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:i}=this.state,{type:s,label:a}=t[o],r="positive"===s?"negative":"positive",l={...t[o],type:r,label:e};i.forEach((e=>{e.classList.remove(s),e.classList.add(r)})),this.updateLabel(a,l,s),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:i}=this.state,s={...n[i],label:t};this.updateLabel(e,s),n.splice(i,1,s),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{classes:e,comment:t,customKeys:n,disabled:o,disabledMath:i,keypadMode:s,height:a,width:r,maxHeight:l,onCommentChange:d,predefinedAnnotations:c,text:p}=this.props,{anchorEl:h,annotation:m,openedMenu:u,openedEditor:g,selectionDetails:b}=this.state,v=h&&(h.offsetTop?h.offsetTop:h.offsetParent.offsetTop),C=this.textRef&&v?v-this.textRef.scrollTop-8:0;return D.createElement("div",null,D.createElement("div",{className:e.wrapper},D.createElement("div",{className:e.textContainer,style:{width:r-34,minHeight:a,maxHeight:l},ref:e=>this.textRef=e,onMouseDown:o?()=>{}:f,onMouseUp:o?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:p}}),D.createElement("div",{className:e.labelsContainer,ref:e=>this.labelsRef=e})),D.createElement(j,{label:"Comment",className:e.commentContainer},D.createElement(z,{className:e.prompt,markup:t||"",onChange:d,width:r&&(r+104).toString(),disabled:o,pluginProps:{math:{disabled:i,customKeys:n,keypadMode:s,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0}}})),D.createElement(P,{anchorEl:h,open:u&&!o,annotations:c,isNewAnnotation:!!b,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),D.createElement(k,{anchorEl:this.textRef,open:g&&!o,offset:C,value:m&&m.label||"",type:m&&m.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}q.__initStatic();var B=H((e=>({textContainer:{padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}},labelsContainer:{width:"230px"},wrapper:{position:"relative",overflowX:"hidden",display:"flex"},commentContainer:{paddingTop:2*e.spacing.unit,marginBottom:2*e.spacing.unit,marginTop:2*e.spacing.unit,width:"100%"},annotation:{position:"relative",cursor:"pointer","&.positive":{backgroundColor:"rgb(51, 255, 51, 0.5)"},"&.negative":{backgroundColor:"rgba(255, 102, 204, 0.4)"}},annotationLabel:{backgroundColor:"rgb(242, 242, 242)",padding:"2px",position:"absolute",userSelect:"none",whiteSpace:"nowrap",top:"-10px",left:"-2px",fontSize:e.typography.fontSize-2,fontStyle:"normal",fontWeight:"normal",lineHeight:"6px","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","&.positive":{color:"rgb(0, 128, 0)"},"&.negative":{color:"rgb(204, 0, 136)"}},labelHover:{zIndex:20,"&.positive":{color:"rgb(0, 77, 0)"},"&.negative":{color:"rgb(153, 0, 102)"}},highlight:{zIndex:10},hover:{zIndex:20,"&.positive":{backgroundColor:"rgb(51, 255, 51, 0.7)"},"&.negative":{backgroundColor:"rgba(255, 102, 204, 0.55)"}},sideAnnotationHover:{zIndex:20,"&.negative":{backgroundColor:"rgb(255, 179, 230) !important","&:before":{borderRightColor:"rgb(255, 179, 230) !important"}},"&.positive":{backgroundColor:"rgb(128, 255, 128) !important","&:before":{borderRightColor:"rgb(153, 255, 153) !important"}}},sideAnnotation:{position:"absolute",padding:e.spacing.unit/2,borderRadius:"4px",marginLeft:e.spacing.unit,width:"180px",whiteSpace:"pre-wrap",wordBreak:"break-word",border:`2px solid ${e.palette.common.white}`,fontSize:e.typography.fontSize,fontStyle:"normal",fontWeight:"normal","&:before":{position:"absolute",right:"100%",top:"5px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px"},"&.negative":{backgroundColor:"rgb(255, 204, 238)","&:before":{borderRightColor:"rgb(255, 204, 238)"}},"&.positive":{backgroundColor:"rgb(153, 255, 153)","&:before":{borderRightColor:"rgb(153, 255, 153)"}}}})))(q);const K=e,F=n,V=t,{debounce:Y}=s,U=a,{Typography:G}=o,{withStyles:X}=i,{color:Q}=r,{Feedback:J}=r,{Collapsible:Z}=r,{PreviewPrompt:ee}=r,{UiLayout:te}=r,ne=c,oe=U("@pie-ui:extended-text-entry");class ie extends K.Component{constructor(...e){super(...e),ie.prototype.__init.call(this),ie.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:F.func.isRequired,onAnnotationsChange:F.func.isRequired,onCommentChange:F.func.isRequired,model:F.object,classes:F.object.isRequired,session:F.shape({value:F.string,annotations:F.array,comment:F.string}).isRequired}}__init(){this.changeSessionValue=Y(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=Y(this.props.onCommentChange,1500)}render(){const{model:e,classes:t,session:n,onAnnotationsChange:o}=this.props,{animationsDisabled:i,annotatorMode:s,customKeys:a,dimensions:r,disabled:l,disabledAnnotator:d,equationEditor:c,extraCSSRules:p,feedback:h,mathInput:m,playersToolbarPosition:u,predefinedAnnotations:g,prompt:b,spanishInput:f,specialInput:v,spellCheckEnabled:C,teacherInstructions:x}=e,{annotations:y,comment:_,value:E}=n,{width:w,height:S}=r||{},A="40vh",R={position:"top"===u?"top":"bottom"};oe("[render] disabled? ",l);const k=K.createElement(ee,{defaultClassName:"teacher-instructions",prompt:x}),N=[];return f&&N.push({language:"spanish"}),v&&N.push({language:"special"}),K.createElement(te,{extraCSSRules:p,className:t.main,ref:e=>{this.containerRef=e}},K.createElement("h2",{className:t.srOnly},"Constructed Response Question"),x&&K.createElement("div",{className:t.teacherInstructions},i?k:K.createElement(Z,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"},className:t.collapsible},k)),b&&K.createElement(G,{component:"span",className:t.prompt},K.createElement(ee,{defaultClassName:"prompt",prompt:e.prompt})),s?K.createElement(B,{text:E||"",annotations:y||[],comment:_||"",predefinedAnnotations:g||[],onChange:o,onCommentChange:this.changeSessionComment,width:w,height:S,maxHeight:A,disabled:d,disabledMath:!m,customKeys:a,keypadMode:c}):K.createElement(ne,{className:V(t.editor,"response-area-editor"),onChange:this.changeSessionValue,markup:E||"",maxWidth:w&&w.toString(),minWidth:"100px",minHeight:S&&S.toString(),maxHeight:A,disabled:l,highlightShape:!0,toolbarOpts:R,spellCheck:C,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!m,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:N}),h&&K.createElement(J,{correctness:"correct",feedback:h}))}}ie.__initStatic();var se=X((e=>({main:{backgroundColor:Q.background(),color:Q.text()},prompt:{width:"100%",color:Q.text(),marginBottom:2*e.spacing.unit,fontSize:"inherit"},teacherInstructions:{marginBottom:2*e.spacing.unit},editor:{marginBottom:2*e.spacing.unit,borderRadius:"4px"},srOnly:{position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"}})))(ie),ae={};Object.defineProperty(ae,"__esModule",{value:!0});class re extends CustomEvent{constructor(e,t,n){super(re.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}re.TYPE="model-set";var le=ae.ModelSetEvent=re;class de extends CustomEvent{constructor(e,t){super(de.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}de.TYPE="session-changed";var ce=ae.SessionChangedEvent=de;const pe=e,he=l,me=a,{renderMath:ue}=d,ge=me("@pie-elements:extended-text-entry"),be=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function fe(e){if("string"==typeof e)try{const t=be.parseFromString(e,"text/html");return t.body.textContent}catch(t){return ge("tried to parse as dom and failed",e),e}}function ve(e){const t=fe(e);return void 0!==t&&t.length>0}class Ce extends HTMLElement{constructor(){super(),this._model=null,this._session=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new le(this.tagName.toLowerCase(),!1,!!this._model)),this.render()}set session(e){this._session=e,this.render()}get session(){return this._session}valueChange(e){this._session.value=e,this.dispatchEvent(new ce(this.tagName.toLowerCase(),ve(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new ce(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new ce(this.tagName.toLowerCase(),ve(e))),this.render()}connectedCallback(){this.setAttribute("aria-label","Written Response Question"),this.setAttribute("role","region"),this.render()}render(){if(this._model&&this._session){let e=pe.createElement(se,{model:this._model,session:this._session,onValueChange:this.valueChange.bind(this),onAnnotationsChange:this.annotationsChange.bind(this),onCommentChange:this.commentChange.bind(this)});this.setLangAttribute(),he.render(e,this,(()=>{ue(this)}))}}}export{Ce as default,ve as isComplete,fe as textContent};
package/module/index.html DELETED
@@ -1,21 +0,0 @@
1
-
2
- <!doctype html>
3
- <html>
4
- <head>
5
- <title>@pie-element/extended-text-entry@13.4.0</title>
6
- <script
7
- type="module"
8
- src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
9
-
10
- <link
11
- href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
12
- rel="stylesheet"
13
- />
14
- <style>
15
- html, body {
16
- font-family: 'Roboto', sans-serif;
17
- }
18
- </style>
19
- <script type="module" src="./demo.js"></script>
20
- </head>
21
- </html>
@@ -1,22 +0,0 @@
1
- {
2
- "name": "@pie-element/extended-text-entry",
3
- "version": "13.4.0",
4
- "modules": [
5
- {
6
- "name": "@pie-lib/shared-module",
7
- "version": "^1.17.5"
8
- },
9
- {
10
- "name": "@pie-lib/math-rendering-module",
11
- "version": "^3.1.5"
12
- },
13
- {
14
- "name": "@pie-lib/editable-html-module",
15
- "version": "^5.9.5"
16
- },
17
- {
18
- "name": "@pie-lib/config-module",
19
- "version": "^2.23.3"
20
- }
21
- ]
22
- }
@@ -1,76 +0,0 @@
1
- import PrintElement from './print.js';
2
-
3
- var generate = {};
4
-
5
- generate.model = (id, element) => ({
6
- id,
7
- element,
8
- customKeys: ['\\square'],
9
- feedback: { type: 'default', default: 'this is default feedback' },
10
- prompt: 'This is the question prompt',
11
- promptEnabled: true,
12
- mathInput: true,
13
- playersToolbarPosition: 'bottom',
14
- toolbarEditorPosition: 'bottom',
15
- spellCheckEnabled: true,
16
- rubricEnabled: false,
17
- annotationsEnabled: false,
18
- });
19
-
20
- const { model } = generate;
21
- var config = {
22
- elements: {
23
- 'extended-text-entry': '../..',
24
- },
25
- models: [model('1', 'extended-text-entry')],
26
- };
27
-
28
- // new init - just shows off print!
29
-
30
- const init = async () => {
31
- console.log('define the element...');
32
- await Promise.all(
33
- config.models.map(async (m) => {
34
- try {
35
- const printTag = `${m.element}-print`;
36
- if (customElements.get(printTag)) {
37
- return true;
38
- } else {
39
- customElements.define(printTag, PrintElement);
40
- await customElements.whenDefined(printTag);
41
- return true;
42
- }
43
- } catch (e) {
44
- return false;
45
- }
46
- })
47
- );
48
-
49
- console.log('now apply the model...');
50
- config.models.forEach((m) => {
51
- const printTag = `${m.element}-print`;
52
- const h3s = document.createElement('h3');
53
- h3s.textContent = 'student mode';
54
- document.body.appendChild(h3s);
55
- const de = document.createElement(printTag);
56
- document.body.appendChild(de);
57
- de.options = {};
58
- de.model = m;
59
-
60
- const h3 = document.createElement('h3');
61
- h3.textContent = 'instructor mode';
62
- document.body.appendChild(h3);
63
- const instr = document.createElement(printTag);
64
- document.body.appendChild(instr);
65
- instr.options = { mode: 'instructor' };
66
- instr.model = JSON.parse(JSON.stringify(m));
67
- });
68
- };
69
-
70
- init()
71
- .then(() => {
72
- console.log('ready');
73
- })
74
- .catch((e) => {
75
- console.error(e);
76
- });