@pie-element/number-line 5.14.7 → 5.14.10

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,30 @@
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.14.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.14.9...@pie-element/number-line@5.14.10) (2022-05-09)
7
+
8
+ **Note:** Version bump only for package @pie-element/number-line
9
+
10
+
11
+
12
+
13
+
14
+ ## [5.14.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.14.8...@pie-element/number-line@5.14.9) (2022-05-03)
15
+
16
+ **Note:** Version bump only for package @pie-element/number-line
17
+
18
+
19
+
20
+
21
+
22
+ ## [5.14.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.14.7...@pie-element/number-line@5.14.8) (2022-04-12)
23
+
24
+ **Note:** Version bump only for package @pie-element/number-line
25
+
26
+
27
+
28
+
29
+
6
30
  ## [5.14.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.14.6...@pie-element/number-line@5.14.7) (2022-03-28)
7
31
 
8
32
  **Note:** Version bump only for package @pie-element/number-line
@@ -3,6 +3,30 @@
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
+ ## [4.9.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.9.8...@pie-element/number-line-configure@4.9.9) (2022-05-09)
7
+
8
+ **Note:** Version bump only for package @pie-element/number-line-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [4.9.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.9.7...@pie-element/number-line-configure@4.9.8) (2022-05-03)
15
+
16
+ **Note:** Version bump only for package @pie-element/number-line-configure
17
+
18
+
19
+
20
+
21
+
22
+ ## [4.9.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.9.6...@pie-element/number-line-configure@4.9.7) (2022-04-12)
23
+
24
+ **Note:** Version bump only for package @pie-element/number-line-configure
25
+
26
+
27
+
28
+
29
+
6
30
  ## [4.9.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.9.5...@pie-element/number-line-configure@4.9.6) (2022-03-28)
7
31
 
8
32
  **Note:** Version bump only for package @pie-element/number-line-configure
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@pie-element/number-line-configure",
3
3
  "private": true,
4
- "version": "4.9.6",
4
+ "version": "4.9.9",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
7
7
  "dependencies": {
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@pie-framework/pie-configure-events": "^1.2.0",
10
- "@pie-lib/config-ui": "^10.10.24",
11
- "@pie-lib/editable-html": "^7.19.3",
10
+ "@pie-lib/config-ui": "^10.12.2",
11
+ "@pie-lib/editable-html": "^7.22.2",
12
12
  "react": "^16.8.1",
13
13
  "react-dom": "^16.8.1"
14
14
  }
package/lib/index.js CHANGED
@@ -88,6 +88,9 @@ var NumberLine = /*#__PURE__*/function (_HTMLElement) {
88
88
  }
89
89
  }, {
90
90
  key: "session",
91
+ get: function get() {
92
+ return this._session;
93
+ },
91
94
  set: function set(s) {
92
95
  this._session = s;
93
96
 
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["NumberLine","m","_model","_applyInitialElements","_render","dispatch","s","_session","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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AAG+B,kBAAMC,aAAN,CAAoBC,sBAApB,EAAmCd,KAAnC,CAAT;;AACAe,+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;;;kDA1IqCC,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 {\n lineIsSwitched,\n switchGraphLine,\n toGraphFormat,\n toSessionFormat\n} 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/math-rendering';\n\n//Expose some additional modules for configuration\nexport { Graph, NumberLineComponent, tickUtils, dataConverter, pointChooser };\n\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 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 =\n 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 =\n 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 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":";;;;;;;;;;;;;;;;;;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;;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,OA3BD,CA2BE,OAAOoC,CAAP,EAAU;AACV,cAAMA,CAAN;AACD;AACF;;;kDA/IqCC,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 {\n lineIsSwitched,\n switchGraphLine,\n toGraphFormat,\n toSessionFormat\n} 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/math-rendering';\n\n//Expose some additional modules for configuration\nexport { Graph, NumberLineComponent, tickUtils, dataConverter, pointChooser };\n\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 =\n 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 =\n 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": "5.14.7",
3
+ "version": "5.14.10",
4
4
  "repository": "pie-framework/pie-elements",
5
5
  "description": "",
6
6
  "publishConfig": {
@@ -8,11 +8,11 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
- "@pie-lib/correct-answer-toggle": "^2.3.35",
11
+ "@pie-lib/correct-answer-toggle": "^2.3.36",
12
12
  "@pie-lib/feedback": "^0.4.27",
13
13
  "@pie-lib/icons": "^2.4.25",
14
- "@pie-lib/math-rendering": "^2.3.13",
15
- "@pie-lib/render-ui": "^4.12.5",
14
+ "@pie-lib/math-rendering": "^2.4.0",
15
+ "@pie-lib/render-ui": "^4.12.6",
16
16
  "classnames": "^2.2.5",
17
17
  "d3-scale": "^3.2.1",
18
18
  "d3-selection": "^1.4.1",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "author": "pie framework developers",
29
29
  "license": "ISC",
30
- "gitHead": "92cd24e6736b2eed8f82ac44ba775ad4f2080ade",
30
+ "gitHead": "43f534de577f1eb49e63c8dc43d5519754d4df93",
31
31
  "scripts": {
32
32
  "postpublish": "../../scripts/postpublish"
33
33
  },