@pie-element/number-line 5.12.3 → 5.13.1-next.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/CHANGELOG.md CHANGED
@@ -3,15 +3,7 @@
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.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)
7
-
8
- **Note:** Version bump only for package @pie-element/number-line
9
-
10
-
11
-
12
-
13
-
14
- ## [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)
6
+ # [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)
15
7
 
16
8
 
17
9
  ### Bug Fixes
@@ -23,12 +15,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
23
15
  * **number-line:** initial view should render correctly in pits ([dcbeb43](https://github.com/pie-framework/pie-elements/commit/dcbeb43ea593671129843801d148663ee98bb048))
24
16
 
25
17
 
18
+ ### Features
26
19
 
27
-
28
-
29
- ## [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)
30
-
31
- **Note:** Version bump only for package @pie-element/number-line
20
+ * **number-line:** set toolbar editor position to bottom ([148ccaf](https://github.com/pie-framework/pie-elements/commit/148ccafcf586debe3710c63029f5fae3d9c66c1f))
32
21
 
33
22
 
34
23
 
@@ -3,15 +3,7 @@
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.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)
7
-
8
- **Note:** Version bump only for package @pie-element/number-line-configure
9
-
10
-
11
-
12
-
13
-
14
- ## [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)
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)
15
7
 
16
8
 
17
9
  ### Bug Fixes
@@ -24,14 +16,6 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
24
16
 
25
17
 
26
18
 
27
- ## [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)
28
-
29
- **Note:** Version bump only for package @pie-element/number-line-configure
30
-
31
-
32
-
33
-
34
-
35
19
  ## [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)
36
20
 
37
21
  **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.6",
4
+ "version": "4.8.4",
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.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
+
8
+ **Note:** Version bump only for package @pie-element/number-line-controller
9
+
10
+
11
+
12
+
13
+
6
14
  ## [4.3.17](https://github.com/pie-framework/pie-elements/compare/@pie-element/number-line-controller@4.3.15...@pie-element/number-line-controller@4.3.17) (2021-08-05)
7
15
 
8
16
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/number-line-controller",
3
3
  "private": true,
4
- "version": "4.3.17",
4
+ "version": "4.3.18",
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) {
206
+ if (!this._session.answer || !this._session.answer.length) {
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,CAAc,WAAd;AACD;;;SAED,aAAYC,CAAZ,EAAe;AACb,WAAKC,QAAL,GAAgBD,CAAhB;;AACA,WAAKH,qBAAL;;AACA,WAAKC,OAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;WAED,sBAAa;AACX,aAAO,KAAKG,QAAL,GAAgB,CAAC,KAAKA,QAAL,CAAcC,MAAd,IAAwB,EAAzB,EAA6BC,MAA7B,GAAsC,CAAtD,GAA0D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AAK,GAAG,2BAAU,KAAKpC,MAAf,CAAZ;AACAoC,UAAAA,KAAK,CAACC,eAAN,GACED,KAAK,CAACC,eAAN,IAAyBD,KAAK,CAACC,eAAN,CAAsBH,GAAtB,CAA0BC,2BAA1B,CAD3B;AAGA,cAAIG,KAAK,GAAG;AACVF,YAAAA,KAAK,EAALA,KADU;AAEV9B,YAAAA,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;;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","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,CAAc,WAAd;AACD;;;SAED,aAAYC,CAAZ,EAAe;AACb,WAAKC,QAAL,GAAgBD,CAAhB;;AACA,WAAKH,qBAAL;;AACA,WAAKC,OAAL;AACD;;;WAED,6BAAoB;AAClB,WAAKA,OAAL;AACD;;;WAED,sBAAa;AACX,aAAO,KAAKG,QAAL,GAAgB,CAAC,KAAKA,QAAL,CAAcC,MAAd,IAAwB,EAAzB,EAA6BC,MAA7B,GAAsC,CAAtD,GAA0D,KAAjE;AACD;;;WAED,kB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CC,2BAAjC,CAAb;AACA,cAAIC,KAAK,GAAG,2BAAU,KAAKpC,MAAf,CAAZ;AACAoC,UAAAA,KAAK,CAACC,eAAN,GACED,KAAK,CAACC,eAAN,IAAyBD,KAAK,CAACC,eAAN,CAAsBH,GAAtB,CAA0BC,2BAA1B,CAD3B;AAGA,cAAIG,KAAK,GAAG;AACVF,YAAAA,KAAK,EAALA,KADU;AAEV9B,YAAAA,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;;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 || !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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/number-line",
3
- "version": "5.12.3",
3
+ "version": "5.13.1-next.0+d2dc19035",
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.29",
11
+ "@pie-lib/correct-answer-toggle": "^2.3.31",
12
12
  "@pie-lib/feedback": "^0.4.27",
13
13
  "@pie-lib/icons": "^2.4.25",
14
- "@pie-lib/math-rendering": "^2.3.9",
15
- "@pie-lib/render-ui": "^4.12.0",
14
+ "@pie-lib/math-rendering": "^2.3.11",
15
+ "@pie-lib/render-ui": "^4.12.2",
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": "5df8639d9e81211ec961ca9847c07ae708ed4374",
30
+ "gitHead": "d2dc19035d4961c1c47b2b41dca50c756915da76",
31
31
  "scripts": {
32
32
  "postpublish": "../../scripts/postpublish"
33
33
  },