@pie-element/number-line 9.3.6-next.0 → 9.3.6-next.9

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.
@@ -7,7 +7,7 @@
7
7
  "dependencies": {
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@pie-framework/pie-configure-events": "^1.3.0",
10
- "@pie-lib/pie-toolbox": "2.6.0",
10
+ "@pie-lib/pie-toolbox": "2.6.1",
11
11
  "lodash": "^4.17.15",
12
12
  "react": "^16.8.1",
13
13
  "react-dom": "^16.8.1"
@@ -14,7 +14,7 @@
14
14
  "access": "public"
15
15
  },
16
16
  "dependencies": {
17
- "@pie-lib/pie-toolbox": "2.6.0",
17
+ "@pie-lib/pie-toolbox": "2.6.1",
18
18
  "lodash": "^4.17.15",
19
19
  "mathjs": "^7.5.1"
20
20
  },
package/lib/index.js CHANGED
@@ -55,7 +55,7 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
55
55
 
56
56
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
57
57
 
58
- var _mathRenderingAccessible = require("@pie-lib/pie-toolbox/math-rendering-accessible");
58
+ var _mathRendering = require("@pie-lib/pie-toolbox/math-rendering");
59
59
 
60
60
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
61
61
 
@@ -226,7 +226,7 @@ var NumberLine = /*#__PURE__*/function (_HTMLElement) {
226
226
  var el = /*#__PURE__*/_react["default"].createElement(_numberLine["default"], props);
227
227
 
228
228
  _reactDom["default"].render(el, this, function () {
229
- (0, _mathRenderingAccessible.renderMath)(_this);
229
+ (0, _mathRendering.renderMath)(_this);
230
230
  });
231
231
  }
232
232
  } catch (e) {
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["NumberLine","m","_model","_applyInitialElements","_render","dispatch","_session","s","answer","length","type","dispatchEvent","CustomEvent","bubbles","detail","complete","isComplete","data","push","dispatchSessionChanged","index","el","position","Error","left","right","update","splice","indices","filter","v","some","d","pop","graph","initialElements","map","toGraphFormat","model","correctResponse","props","onAddElement","addElement","bind","onMoveElement","moveElement","onDeleteElements","deleteElements","onUndoElement","undoElement","onClearElements","clearElements","React","createElement","RootComponent","ReactDOM","render","e","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AAIA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAIqBA,U;;;;;AACnB,wBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,qBAAL;;AACA,WAAKC,OAAL;;AACA,WAAKC,QAAL,CAAc,WAAd;AACD;;;SAQD,eAAc;AACZ,aAAO,KAAKC,QAAZ;AACD,K;SARD,aAAYC,CAAZ,EAAe;AACb,WAAKD,QAAL,GAAgBC,CAAhB;;AACA,WAAKJ,qBAAL;;AACA,WAAKC,OAAL;AACD;;;WAMD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;WAED,sBAAa;AACX,aAAO,KAAKE,QAAL,GAAgB,CAAC,KAAKA,QAAL,CAAcE,MAAd,IAAwB,EAAzB,EAA6BC,MAA7B,GAAsC,CAAtD,GAA0D,KAAjE;AACD;;;WAED,kBAASC,IAAT,EAAe;AACb,WAAKC,aAAL,CACE,IAAIC,WAAJ,CAAgBF,IAAhB,EAAsB;AACpBG,QAAAA,OAAO,EAAE,IADW;AAEpBC,QAAAA,MAAM,EAAE;AACNC,UAAAA,QAAQ,EAAE,KAAKC,UAAL;AADJ;AAFY,OAAtB,CADF;AAQD;;;WAED,kCAAyB;AACvB,WAAKX,QAAL,CAAc,iBAAd;AACD;;;WAED,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UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAHJ;AAIVC,YAAAA,aAAa,EAAE,KAAKC,WAAL,CAAiBF,IAAjB,CAAsB,IAAtB,CAJL;AAKVG,YAAAA,gBAAgB,EAAE,KAAKC,cAAL,CAAoBJ,IAApB,CAAyB,IAAzB,CALR;AAMVK,YAAAA,aAAa,EAAE,KAAKC,WAAL,CAAiBN,IAAjB,CAAsB,IAAtB,CANL;AAOVO,YAAAA,eAAe,EAAE,KAAKC,aAAL,CAAmBR,IAAnB,CAAwB,IAAxB;AAPP,WAAZ;;AAUA,cAAItB,EAAE,gBAAG+B,kBAAMC,aAAN,CAAoBC,sBAApB,EAAmCd,KAAnC,CAAT;;AAEAe,+BAASC,MAAT,CAAgBnC,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,qDAAW,KAAX;AACD,WAFD;AAGD;AACF,OA1BD,CA0BE,OAAOoC,CAAP,EAAU;AACV,cAAMA,CAAN;AACD;AACF;;;kDA7IqCC,W","sourcesContent":["import * as dataConverter from './data-converter';\nimport * as pointChooser from './number-line/point-chooser';\nimport * as tickUtils from './number-line/graph/tick-utils';\n\nimport { lineIsSwitched, switchGraphLine, toGraphFormat, toSessionFormat } from './data-converter';\n\nimport Graph from './number-line/graph';\nimport NumberLineComponent from './number-line';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport RootComponent from './number-line';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering-accessible';\n\n//Expose some additional modules for configuration\nexport { Graph, NumberLineComponent, tickUtils, dataConverter, pointChooser };\nexport default class NumberLine extends HTMLElement {\n constructor() {\n super();\n }\n\n set model(m) {\n this._model = m;\n this._applyInitialElements();\n this._render();\n this.dispatch('model-set');\n }\n\n set session(s) {\n this._session = s;\n this._applyInitialElements();\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n connectedCallback() {\n this._render();\n }\n\n isComplete() {\n return this._session ? (this._session.answer || []).length > 0 : false;\n }\n\n dispatch(type) {\n this.dispatchEvent(\n new CustomEvent(type, {\n bubbles: true,\n detail: {\n complete: this.isComplete(),\n },\n }),\n );\n }\n\n dispatchSessionChanged() {\n this.dispatch('session-changed');\n }\n\n addElement(data) {\n if (!this._session) {\n return;\n }\n\n this._session.answer = this._session.answer || [];\n this._session.answer.push(toSessionFormat(data));\n this.dispatchSessionChanged();\n this._render();\n }\n\n moveElement(index, el, position) {\n let answer = this._session.answer[index];\n\n if (!answer) {\n throw new Error('cant find element at index: ', index);\n }\n\n if (el.type === 'line' && position.left === position.right) {\n this._render();\n return;\n }\n\n //set the new position\n el.position = position;\n\n let update = el.type === 'line' && lineIsSwitched(el) ? switchGraphLine(el) : el;\n\n this._session.answer.splice(index, 1, toSessionFormat(update));\n\n this.dispatchSessionChanged();\n this._render();\n }\n\n deleteElements(indices) {\n this._session.answer = this._session.answer.filter((v, index) => {\n return !indices.some((d) => d === index);\n });\n this.dispatchSessionChanged();\n this._render();\n }\n\n undoElement() {\n this._session.answer.pop();\n this.dispatchSessionChanged();\n this._render();\n }\n\n clearElements() {\n this._session.answer = [];\n this.dispatchSessionChanged();\n this._render();\n }\n\n _applyInitialElements() {\n if (\n this._model &&\n this._model.graph &&\n this._model.graph.initialElements &&\n this._session &&\n (!this._session.answer || !this._session.answer.length)\n ) {\n this._session.answer = cloneDeep(this._model.graph.initialElements);\n }\n }\n\n _render() {\n try {\n if (this._model && this._session) {\n if (!this._session.answer) {\n this._applyInitialElements();\n }\n\n let answer = (this._session.answer || []).map(toGraphFormat);\n let model = cloneDeep(this._model);\n model.correctResponse = model.correctResponse && model.correctResponse.map(toGraphFormat);\n\n let props = {\n model,\n answer,\n onAddElement: this.addElement.bind(this),\n onMoveElement: this.moveElement.bind(this),\n onDeleteElements: this.deleteElements.bind(this),\n onUndoElement: this.undoElement.bind(this),\n onClearElements: this.clearElements.bind(this),\n };\n\n let el = React.createElement(RootComponent, props);\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n } catch (e) {\n throw e;\n }\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["NumberLine","m","_model","_applyInitialElements","_render","dispatch","_session","s","answer","length","type","dispatchEvent","CustomEvent","bubbles","detail","complete","isComplete","data","push","dispatchSessionChanged","index","el","position","Error","left","right","update","splice","indices","filter","v","some","d","pop","graph","initialElements","map","toGraphFormat","model","correctResponse","props","onAddElement","addElement","bind","onMoveElement","moveElement","onDeleteElements","deleteElements","onUndoElement","undoElement","onClearElements","clearElements","React","createElement","RootComponent","ReactDOM","render","e","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AAIA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAIqBA,U;;;;;AACnB,wBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,qBAAL;;AACA,WAAKC,OAAL;;AACA,WAAKC,QAAL,CAAc,WAAd;AACD;;;SAQD,eAAc;AACZ,aAAO,KAAKC,QAAZ;AACD,K;SARD,aAAYC,CAAZ,EAAe;AACb,WAAKD,QAAL,GAAgBC,CAAhB;;AACA,WAAKJ,qBAAL;;AACA,WAAKC,OAAL;AACD;;;WAMD,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;WAED,sBAAa;AACX,aAAO,KAAKE,QAAL,GAAgB,CAAC,KAAKA,QAAL,CAAcE,MAAd,IAAwB,EAAzB,EAA6BC,MAA7B,GAAsC,CAAtD,GAA0D,KAAjE;AACD;;;WAED,kBAASC,IAAT,EAAe;AACb,WAAKC,aAAL,CACE,IAAIC,WAAJ,CAAgBF,IAAhB,EAAsB;AACpBG,QAAAA,OAAO,EAAE,IADW;AAEpBC,QAAAA,MAAM,EAAE;AACNC,UAAAA,QAAQ,EAAE,KAAKC,UAAL;AADJ;AAFY,OAAtB,CADF;AAQD;;;WA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AA,MAAM,EAANA,MAFU;AAGViC,YAAAA,YAAY,EAAE,KAAKC,UAAL,CAAgBC,IAAhB,CAAqB,IAArB,CAHJ;AAIVC,YAAAA,aAAa,EAAE,KAAKC,WAAL,CAAiBF,IAAjB,CAAsB,IAAtB,CAJL;AAKVG,YAAAA,gBAAgB,EAAE,KAAKC,cAAL,CAAoBJ,IAApB,CAAyB,IAAzB,CALR;AAMVK,YAAAA,aAAa,EAAE,KAAKC,WAAL,CAAiBN,IAAjB,CAAsB,IAAtB,CANL;AAOVO,YAAAA,eAAe,EAAE,KAAKC,aAAL,CAAmBR,IAAnB,CAAwB,IAAxB;AAPP,WAAZ;;AAUA,cAAItB,EAAE,gBAAG+B,kBAAMC,aAAN,CAAoBC,sBAApB,EAAmCd,KAAnC,CAAT;;AAEAe,+BAASC,MAAT,CAAgBnC,EAAhB,EAAoB,IAApB,EAA0B,YAAM;AAC9B,2CAAW,KAAX;AACD,WAFD;AAGD;AACF,OA1BD,CA0BE,OAAOoC,CAAP,EAAU;AACV,cAAMA,CAAN;AACD;AACF;;;kDA7IqCC,W","sourcesContent":["import * as dataConverter from './data-converter';\nimport * as pointChooser from './number-line/point-chooser';\nimport * as tickUtils from './number-line/graph/tick-utils';\n\nimport { lineIsSwitched, switchGraphLine, toGraphFormat, toSessionFormat } from './data-converter';\n\nimport Graph from './number-line/graph';\nimport NumberLineComponent from './number-line';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport RootComponent from './number-line';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { renderMath } from '@pie-lib/pie-toolbox/math-rendering';\n\n//Expose some additional modules for configuration\nexport { Graph, NumberLineComponent, tickUtils, dataConverter, pointChooser };\nexport default class NumberLine extends HTMLElement {\n constructor() {\n super();\n }\n\n set model(m) {\n this._model = m;\n this._applyInitialElements();\n this._render();\n this.dispatch('model-set');\n }\n\n set session(s) {\n this._session = s;\n this._applyInitialElements();\n this._render();\n }\n\n get session() {\n return this._session;\n }\n\n connectedCallback() {\n this._render();\n }\n\n isComplete() {\n return this._session ? (this._session.answer || []).length > 0 : false;\n }\n\n dispatch(type) {\n this.dispatchEvent(\n new CustomEvent(type, {\n bubbles: true,\n detail: {\n complete: this.isComplete(),\n },\n }),\n );\n }\n\n dispatchSessionChanged() {\n this.dispatch('session-changed');\n }\n\n addElement(data) {\n if (!this._session) {\n return;\n }\n\n this._session.answer = this._session.answer || [];\n this._session.answer.push(toSessionFormat(data));\n this.dispatchSessionChanged();\n this._render();\n }\n\n moveElement(index, el, position) {\n let answer = this._session.answer[index];\n\n if (!answer) {\n throw new Error('cant find element at index: ', index);\n }\n\n if (el.type === 'line' && position.left === position.right) {\n this._render();\n return;\n }\n\n //set the new position\n el.position = position;\n\n let update = el.type === 'line' && lineIsSwitched(el) ? switchGraphLine(el) : el;\n\n this._session.answer.splice(index, 1, toSessionFormat(update));\n\n this.dispatchSessionChanged();\n this._render();\n }\n\n deleteElements(indices) {\n this._session.answer = this._session.answer.filter((v, index) => {\n return !indices.some((d) => d === index);\n });\n this.dispatchSessionChanged();\n this._render();\n }\n\n undoElement() {\n this._session.answer.pop();\n this.dispatchSessionChanged();\n this._render();\n }\n\n clearElements() {\n this._session.answer = [];\n this.dispatchSessionChanged();\n this._render();\n }\n\n _applyInitialElements() {\n if (\n this._model &&\n this._model.graph &&\n this._model.graph.initialElements &&\n this._session &&\n (!this._session.answer || !this._session.answer.length)\n ) {\n this._session.answer = cloneDeep(this._model.graph.initialElements);\n }\n }\n\n _render() {\n try {\n if (this._model && this._session) {\n if (!this._session.answer) {\n this._applyInitialElements();\n }\n\n let answer = (this._session.answer || []).map(toGraphFormat);\n let model = cloneDeep(this._model);\n model.correctResponse = model.correctResponse && model.correctResponse.map(toGraphFormat);\n\n let props = {\n model,\n answer,\n onAddElement: this.addElement.bind(this),\n onMoveElement: this.moveElement.bind(this),\n onDeleteElements: this.deleteElements.bind(this),\n onUndoElement: this.undoElement.bind(this),\n onClearElements: this.clearElements.bind(this),\n };\n\n let el = React.createElement(RootComponent, props);\n\n ReactDOM.render(el, this, () => {\n renderMath(this);\n });\n }\n } catch (e) {\n throw e;\n }\n }\n}\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/number-line",
3
- "version": "9.3.6-next.0+97e48ba3c",
3
+ "version": "9.3.6-next.9+fc356f486",
4
4
  "repository": "pie-framework/pie-elements",
5
5
  "description": "",
6
6
  "publishConfig": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
- "@pie-lib/pie-toolbox": "2.6.0",
11
+ "@pie-lib/pie-toolbox": "2.6.1",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-scale": "^3.2.1",
14
14
  "d3-selection": "^1.4.1",
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "author": "pie framework developers",
25
25
  "license": "ISC",
26
- "gitHead": "97e48ba3c442bfacd2124fde97313b792ba6178c",
26
+ "gitHead": "fc356f4869ba382ef40f5af91d4971e33a8add15",
27
27
  "scripts": {
28
28
  "postpublish": "../../scripts/postpublish"
29
29
  },