@pie-element/number-line 5.11.3-next.508 → 5.11.3-next.510

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,38 @@
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.13.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.13.6...@pie-element/number-line@5.13.7) (2021-12-23)
7
+
8
+ **Note:** Version bump only for package @pie-element/number-line
9
+
10
+
11
+
12
+
13
+
14
+ ## [5.13.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.13.4...@pie-element/number-line@5.13.5) (2021-12-13)
15
+
16
+ **Note:** Version bump only for package @pie-element/number-line
17
+
18
+
19
+
20
+
21
+
22
+ ## [5.13.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.13.1...@pie-element/number-line@5.13.2) (2021-11-29)
23
+
24
+ **Note:** Version bump only for package @pie-element/number-line
25
+
26
+
27
+
28
+
29
+
30
+ ## [5.13.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.12.3...@pie-element/number-line@5.13.1) (2021-11-11)
31
+
32
+ **Note:** Version bump only for package @pie-element/number-line
33
+
34
+
35
+
36
+
37
+
6
38
  # [5.13.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.11.2...@pie-element/number-line@5.13.0) (2021-11-11)
7
39
 
8
40
 
@@ -23,6 +55,38 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
23
55
 
24
56
 
25
57
 
58
+
59
+ ## [5.12.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.12.2...@pie-element/number-line@5.12.3) (2021-10-04)
60
+
61
+ **Note:** Version bump only for package @pie-element/number-line
62
+
63
+
64
+
65
+
66
+
67
+ ## [5.12.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.12.1...@pie-element/number-line@5.12.2) (2021-09-20)
68
+
69
+
70
+ ### Bug Fixes
71
+
72
+ * pie-lib updates ([e521c2f](https://github.com/pie-framework/pie-elements/commit/e521c2f1a44aa7f3e14f82a1cee05ceb484ed0a6))
73
+ * Updated pie-lib versions ([2fe4c5d](https://github.com/pie-framework/pie-elements/commit/2fe4c5d0be2d40f5fdb34815855695a7f1087f56))
74
+ * Updated pie-lib versions ([1c23830](https://github.com/pie-framework/pie-elements/commit/1c23830fc75d1de5f7bb3bb16de3c665ae5fa350))
75
+ * **number-line:** fix initial view on pits ([4f3e572](https://github.com/pie-framework/pie-elements/commit/4f3e572a16356e5a2d16557f9c23d7a011f24578))
76
+ * **number-line:** initial view should render correctly in pits ([dcbeb43](https://github.com/pie-framework/pie-elements/commit/dcbeb43ea593671129843801d148663ee98bb048))
77
+
78
+
79
+
80
+
81
+
82
+ ## [5.12.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.12.0...@pie-element/number-line@5.12.1) (2021-09-01)
83
+
84
+ **Note:** Version bump only for package @pie-element/number-line
85
+
86
+
87
+
88
+
89
+
26
90
  # [5.12.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line@5.11.2...@pie-element/number-line@5.12.0) (2021-08-05)
27
91
 
28
92
 
@@ -3,7 +3,39 @@
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.8.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.2...@pie-element/number-line-configure@4.8.4) (2021-11-11)
6
+ ## [4.8.12](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.11...@pie-element/number-line-configure@4.8.12) (2021-12-23)
7
+
8
+ **Note:** Version bump only for package @pie-element/number-line-configure
9
+
10
+
11
+
12
+
13
+
14
+ ## [4.8.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.9...@pie-element/number-line-configure@4.8.10) (2021-12-13)
15
+
16
+ **Note:** Version bump only for package @pie-element/number-line-configure
17
+
18
+
19
+
20
+
21
+
22
+ ## [4.8.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.6...@pie-element/number-line-configure@4.8.7) (2021-11-29)
23
+
24
+ **Note:** Version bump only for package @pie-element/number-line-configure
25
+
26
+
27
+
28
+
29
+
30
+ ## [4.8.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.5...@pie-element/number-line-configure@4.8.6) (2021-10-04)
31
+
32
+ **Note:** Version bump only for package @pie-element/number-line-configure
33
+
34
+
35
+
36
+
37
+
38
+ ## [4.8.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.4...@pie-element/number-line-configure@4.8.5) (2021-09-20)
7
39
 
8
40
 
9
41
  ### Bug Fixes
@@ -16,6 +48,14 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
16
48
 
17
49
 
18
50
 
51
+ ## [4.8.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.3...@pie-element/number-line-configure@4.8.4) (2021-09-01)
52
+
53
+ **Note:** Version bump only for package @pie-element/number-line-configure
54
+
55
+
56
+
57
+
58
+
19
59
  ## [4.8.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-configure@4.8.2...@pie-element/number-line-configure@4.8.3) (2021-08-05)
20
60
 
21
61
  **Note:** Version bump only for package @pie-element/number-line-configure
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/number-line-configure",
3
3
  "private": true,
4
- "version": "4.8.4",
4
+ "version": "4.8.12",
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
7
7
  "dependencies": {
@@ -3,6 +3,14 @@
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.3.19](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-controller@4.3.17...@pie-element/number-line-controller@4.3.19) (2021-11-11)
7
+
8
+ **Note:** Version bump only for package @pie-element/number-line-controller
9
+
10
+
11
+
12
+
13
+
6
14
  ## [4.3.18](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-controller@4.3.17...@pie-element/number-line-controller@4.3.18) (2021-11-11)
7
15
 
8
16
  **Note:** Version bump only for package @pie-element/number-line-controller
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/number-line-controller",
3
3
  "private": true,
4
- "version": "4.3.18",
4
+ "version": "4.3.22",
5
5
  "description": "Controller logic for @pie-ui/number-line",
6
6
  "keywords": [
7
7
  "pie",
package/lib/index.js CHANGED
@@ -203,7 +203,7 @@ var NumberLine = /*#__PURE__*/function (_HTMLElement) {
203
203
 
204
204
  try {
205
205
  if (this._model && this._session) {
206
- if (!this._session.answer || !this._session.answer.length) {
206
+ if (!this._session.answer) {
207
207
  this._applyInitialElements();
208
208
  }
209
209
 
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AASA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAKqBA,U;;;;;AACnB,wBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,qBAAL;;AACA,WAAKC,OAAL;;AACA,WAAKC,QAAL,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;;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 || !this._session.answer.length) {\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","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;;;AASA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;IAKqBA,U;;;;;AACnB,wBAAc;AAAA;AAAA;AAEb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKC,MAAL,GAAcD,CAAd;;AACA,WAAKE,qB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C,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/number-line",
3
- "version": "5.11.3-next.508+83da7dce9",
3
+ "version": "5.11.3-next.510+0c1268378",
4
4
  "repository": "pie-framework/pie-elements",
5
5
  "description": "",
6
6
  "publishConfig": {
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "author": "pie framework developers",
29
29
  "license": "ISC",
30
- "gitHead": "83da7dce98cce892b028c9e3c7e958548e47d353",
30
+ "gitHead": "0c1268378bd302cb3f67636b752e9cd5d8495b34",
31
31
  "scripts": {
32
32
  "postpublish": "../../scripts/postpublish"
33
33
  },