@pie-element/placement-ordering 8.15.5-next.6 → 8.15.6-next.16

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,17 @@
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
+ ## [8.15.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@8.15.4...@pie-element/placement-ordering@8.15.5) (2023-09-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add sanity checks DNA-18268 ([29d7de9](https://github.com/pie-framework/pie-elements/commit/29d7de9422c075117173a3afeb2b29acf1caab3c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.15.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering@8.15.3...@pie-element/placement-ordering@8.15.4) (2023-09-05)
7
18
 
8
19
 
@@ -3,6 +3,17 @@
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
+ ## [6.12.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@6.12.4...@pie-element/placement-ordering-configure@6.12.5) (2023-09-18)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add sanity checks DNA-18268 ([29d7de9](https://github.com/pie-framework/pie-elements/commit/29d7de9422c075117173a3afeb2b29acf1caab3c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.12.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/placement-ordering-configure@6.12.3...@pie-element/placement-ordering-configure@6.12.4) (2023-09-05)
7
18
 
8
19
 
@@ -128,22 +128,26 @@ var PlacementOrdering = /*#__PURE__*/function (_HTMLElement) {
128
128
  }, {
129
129
  key: "configuration",
130
130
  set: function set(c) {
131
- var _this2 = this;
131
+ var _newConfiguration$lan,
132
+ _this2 = this;
132
133
 
133
134
  var info = prepareCustomizationObject(c, this._model);
134
135
  this.onModelChanged(info.model);
135
- this._configuration = info.configuration; // if language:enabled is true, then the corresponding default item model should include a language value;
136
+
137
+ var newConfiguration = _objectSpread(_objectSpread({}, _defaults["default"].configuration), info.configuration);
138
+
139
+ this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
136
140
  // if it is false, then the language field should be omitted from the item model.
137
141
  // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
138
142
  // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
139
143
 
140
- if (c.language.enabled) {
141
- var _c$languageChoices, _c$languageChoices$op;
144
+ if (newConfiguration !== null && newConfiguration !== void 0 && (_newConfiguration$lan = newConfiguration.language) !== null && _newConfiguration$lan !== void 0 && _newConfiguration$lan.enabled) {
145
+ var _newConfiguration$lan2, _newConfiguration$lan3;
142
146
 
143
- if ((_c$languageChoices = c.languageChoices) !== null && _c$languageChoices !== void 0 && (_c$languageChoices$op = _c$languageChoices.options) !== null && _c$languageChoices$op !== void 0 && _c$languageChoices$op.length) {
144
- this._model.language = c.languageChoices.options[0].value;
147
+ if (newConfiguration !== null && newConfiguration !== void 0 && (_newConfiguration$lan2 = newConfiguration.languageChoices) !== null && _newConfiguration$lan2 !== void 0 && (_newConfiguration$lan3 = _newConfiguration$lan2.options) !== null && _newConfiguration$lan3 !== void 0 && _newConfiguration$lan3.length) {
148
+ this._model.language = newConfiguration === null || newConfiguration === void 0 ? void 0 : newConfiguration.languageChoices.options[0].value;
145
149
  }
146
- } else if (c.language.settings && this._model.language) {
150
+ } else if (newConfiguration.language.settings && this._model.language) {
147
151
  this._configuration.language.enabled = true;
148
152
 
149
153
  if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["prepareCustomizationObject","config","model","configuration","defaultValues","addWeightToCorrectResponse","correctResponse","map","correct","weight","undefined","id","PlacementOrdering","_model","createDefaultModel","_configuration","onModelChanged","resetSession","_rerender","dispatchUpdate","onConfigurationChanged","insertImage","handler","dispatchEvent","InsertImageEvent","deleteImage","src","done","DeleteImageEvent","reset","ModelUpdatedEvent","s","c","info","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","uploadSoundSupport","insertSound","bind","onDeleteSound","ReactDOM","render","HTMLElement","mapChoicesToReturnCorrectResponse","choices","ch","defaultModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA6B,CAACC,MAAD,EAASC,KAAT,EAAmB;AACpD,MAAMC,aAAa,GAAG,2BAASF,MAAT,EAAiBG,qBAAcD,aAA/B,CAAtB;AAEA,SAAO;AAAEA,IAAAA,aAAa,EAAbA,aAAF;AAAiBD,IAAAA,KAAK,EAALA;AAAjB,GAAP;AACD,CAJD;;AAMO,IAAMG,0BAA0B,GAAG,SAA7BA,0BAA6B,CAACC,eAAD;AAAA,SACxCA,eAAe,IACfA,eAAe,CAACC,GAAhB,CAAoB,UAACC,OAAD,EAAa;AAC/B;AACA,QAAIA,OAAO,CAACC,MAAR,KAAmBC,SAAvB,EAAkC;AAChC,aAAO;AAAEC,QAAAA,EAAE,EAAEH,OAAO,CAACG,EAAd;AAAkBF,QAAAA,MAAM,EAAED,OAAO,CAACC;AAAlC,OAAP;AACD,KAFD,MAEO;AACL,aAAO;AAAEE,QAAAA,EAAE,EAAEH,OAAN;AAAeC,QAAAA,MAAM,EAAE;AAAvB,OAAP;AACD;AACF,GAPD,CAFwC;AAAA,CAAnC;AAUP;AACA;AACA;AACA;;;;;IACqBG,iB;;;;;AAmBnB,+BAAc;AAAA;;AAAA;AACZ;AAEA,UAAKC,MAAL,GAAcD,iBAAiB,CAACE,kBAAlB,EAAd;AACA,UAAKC,cAAL,GAAsBX,qBAAcD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+BA,eAA/B;AACD;;AAED,SAAOyD,YAAP;AACD,C","sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './design';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport defaultValues from './defaults';\nimport defaults from 'lodash/defaults';\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, defaultValues.configuration);\n\n return { configuration, model };\n};\n\nexport const addWeightToCorrectResponse = (correctResponse) =>\n correctResponse &&\n correctResponse.map((correct) => {\n // if weight is set\n if (correct.weight !== undefined) {\n return { id: correct.id, weight: correct.weight };\n } else {\n return { id: correct, weight: 0 };\n }\n });\n/**\n * assuming that the correct response will be set via ui, not via config,\n * correctResponse (if not set) will be initialized with choices default order\n */\nexport default class PlacementOrdering extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const mapChoicesToReturnCorrectResponse = (choices) => choices && choices.map((ch) => ({ id: ch.id, weight: 0 }));\n\n let correctResponse =\n addWeightToCorrectResponse(model.correctResponse) || mapChoicesToReturnCorrectResponse(model.choices);\n\n const defaultModel = {\n ...defaultValues.model,\n ...model,\n };\n\n if (correctResponse) {\n defaultModel.correctResponse = correctResponse;\n }\n\n return defaultModel;\n };\n\n constructor() {\n super();\n\n this._model = PlacementOrdering.createDefaultModel();\n this._configuration = defaultValues.configuration;\n\n this.onModelChanged = (model, resetSession) => {\n this._model = model;\n this._rerender();\n this.dispatchUpdate(resetSession);\n };\n\n this.onConfigurationChanged = (configuration) => {\n this._configuration = prepareCustomizationObject(configuration).configuration;\n\n this.onModelChanged(this._model);\n this._rerender();\n };\n\n this.insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n this.deleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n }\n\n dispatchUpdate(reset) {\n this.dispatchEvent(new ModelUpdatedEvent(this._model, reset));\n }\n\n set model(s) {\n this._model = PlacementOrdering.createDefaultModel(s);\n this._rerender();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n this._configuration = info.configuration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (c.language.enabled) {\n if (c.languageChoices?.options?.length) {\n this._model.language = c.languageChoices.options[0].value;\n }\n } else if (c.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._rerender();\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _rerender() {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n imageSupport: {\n add: this.insertImage,\n delete: this.deleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["prepareCustomizationObject","config","model","configuration","defaultValues","addWeightToCorrectResponse","correctResponse","map","correct","weight","undefined","id","PlacementOrdering","_model","createDefaultModel","_configuration","onModelChanged","resetSession","_rerender","dispatchUpdate","onConfigurationChanged","insertImage","handler","dispatchEvent","InsertImageEvent","deleteImage","src","done","DeleteImageEvent","reset","ModelUpdatedEvent","s","c","info","newConfiguration","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Main","imageSupport","add","uploadSoundSupport","insertSound","bind","onDeleteSound","ReactDOM","render","HTMLElement","mapChoicesToReturnCorrectResponse","choices","ch","defaultModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,0BAA0B,GAAG,SAA7BA,0BAA6B,CAACC,MAAD,EAASC,KAAT,EAAmB;AACpD,MAAMC,aAAa,GAAG,2BAASF,MAAT,EAAiBG,qBAAcD,aAA/B,CAAtB;AAEA,SAAO;AAAEA,IAAAA,aAAa,EAAbA,aAAF;AAAiBD,IAAAA,KAAK,EAALA;AAAjB,GAAP;AACD,CAJD;;AAMO,IAAMG,0BAA0B,GAAG,SAA7BA,0BAA6B,CAACC,eAAD;AAAA,SACxCA,eAAe,IACfA,eAAe,CAACC,GAAhB,CAAoB,UAACC,OAAD,EAAa;AAC/B;AACA,QAAIA,OAAO,CAACC,MAAR,KAAmBC,SAAvB,EAAkC;AAChC,aAAO;AAAEC,QAAAA,EAAE,EAAEH,OAAO,CAACG,EAAd;AAAkBF,QAAAA,MAAM,EAAED,OAAO,CAACC;AAAlC,OAAP;AACD,KAFD,MAEO;AACL,aAAO;AAAEE,QAAAA,EAAE,EAAEH,OAAN;AAAeC,QAAAA,MAAM,EAAE;AAAvB,OAAP;AACD;AACF,GAPD,CAFwC;AAAA,CAAnC;AAUP;AACA;AACA;AACA;;;;;IACqBG,iB;;;;;AAmBnB,+BAAc;AAAA;;AAAA;AACZ;AAEA,UAAKC,MAAL,GAAcD,iBAAiB,CAACE,kBAAlB,EAAd;AACA,UAAKC,cAAL,GAAsBX,qBAAcD,aAApC;;AAEA,UAAKa,cAAL,GAAsB,UAACd,KAAD,EAAQe,YAAR,EAAyB;AAC7C,YAAKJ,MAAL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GA,MAAME,YAAY,mCACb5D,qBAAcF,KADD,GAEbA,KAFa,CAAlB;;AAKA,MAAII,eAAJ,EAAqB;AACnB0D,IAAAA,YAAY,CAAC1D,eAAb,GAA+BA,eAA/B;AACD;;AAED,SAAO0D,YAAP;AACD,C","sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport Main from './design';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport defaultValues from './defaults';\nimport defaults from 'lodash/defaults';\n\nconst prepareCustomizationObject = (config, model) => {\n const configuration = defaults(config, defaultValues.configuration);\n\n return { configuration, model };\n};\n\nexport const addWeightToCorrectResponse = (correctResponse) =>\n correctResponse &&\n correctResponse.map((correct) => {\n // if weight is set\n if (correct.weight !== undefined) {\n return { id: correct.id, weight: correct.weight };\n } else {\n return { id: correct, weight: 0 };\n }\n });\n/**\n * assuming that the correct response will be set via ui, not via config,\n * correctResponse (if not set) will be initialized with choices default order\n */\nexport default class PlacementOrdering extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n const mapChoicesToReturnCorrectResponse = (choices) => choices && choices.map((ch) => ({ id: ch.id, weight: 0 }));\n\n let correctResponse =\n addWeightToCorrectResponse(model.correctResponse) || mapChoicesToReturnCorrectResponse(model.choices);\n\n const defaultModel = {\n ...defaultValues.model,\n ...model,\n };\n\n if (correctResponse) {\n defaultModel.correctResponse = correctResponse;\n }\n\n return defaultModel;\n };\n\n constructor() {\n super();\n\n this._model = PlacementOrdering.createDefaultModel();\n this._configuration = defaultValues.configuration;\n\n this.onModelChanged = (model, resetSession) => {\n this._model = model;\n this._rerender();\n this.dispatchUpdate(resetSession);\n };\n\n this.onConfigurationChanged = (configuration) => {\n this._configuration = prepareCustomizationObject(configuration).configuration;\n\n this.onModelChanged(this._model);\n this._rerender();\n };\n\n this.insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n this.deleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n };\n }\n\n dispatchUpdate(reset) {\n this.dispatchEvent(new ModelUpdatedEvent(this._model, reset));\n }\n\n set model(s) {\n this._model = PlacementOrdering.createDefaultModel(s);\n this._rerender();\n }\n\n set configuration(c) {\n const info = prepareCustomizationObject(c, this._model);\n\n this.onModelChanged(info.model);\n\n const newConfiguration = {\n ...defaultValues.configuration,\n ...info.configuration,\n };\n\n this._configuration = newConfiguration;\n\n // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._rerender();\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n _rerender() {\n let element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n imageSupport: {\n add: this.insertImage,\n delete: this.deleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/placement-ordering-configure",
3
- "version": "6.12.4",
3
+ "version": "6.12.5",
4
4
  "private": true,
5
5
  "main": "lib/index.js",
6
6
  "module": "src/index.js",
@@ -8,9 +8,9 @@
8
8
  "@material-ui/core": "^3.9.2",
9
9
  "@material-ui/icons": "^3.0.1",
10
10
  "@pie-framework/pie-configure-events": "^1.3.0",
11
- "@pie-lib/config-ui": "^11.9.12",
12
- "@pie-lib/editable-html": "^10.0.7",
13
- "@pie-lib/scoring-config": "^3.6.53",
11
+ "@pie-lib/config-ui": "^11.9.14",
12
+ "@pie-lib/editable-html": "^11.0.1",
13
+ "@pie-lib/scoring-config": "^3.6.55",
14
14
  "debug": "^3.1.0",
15
15
  "lodash": "^4.17.15",
16
16
  "nested-property": "^0.0.7",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/placement-ordering",
3
- "version": "8.15.5-next.6+26199b255",
3
+ "version": "8.15.6-next.16+f206ae3c9",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -9,10 +9,10 @@
9
9
  "dependencies": {
10
10
  "@material-ui/core": "^3.9.2",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
- "@pie-lib/correct-answer-toggle": "^2.5.4",
12
+ "@pie-lib/correct-answer-toggle": "^2.5.6",
13
13
  "@pie-lib/drag": "^2.2.4",
14
- "@pie-lib/math-rendering": "^2.5.18",
15
- "@pie-lib/render-ui": "^4.15.2",
14
+ "@pie-lib/math-rendering": "^3.1.0",
15
+ "@pie-lib/render-ui": "^4.15.4",
16
16
  "@pie-lib/translator": "^2.3.0",
17
17
  "debug": "^4.1.1",
18
18
  "decimal.js": "^10.0.0",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "author": "",
28
28
  "license": "ISC",
29
- "gitHead": "26199b255ddbcb9255f2769091c7ba58f8b1dae0",
29
+ "gitHead": "f206ae3c9c6f9e4a092ac223de5f55c3a3cc5f83",
30
30
  "scripts": {
31
31
  "postpublish": "../../scripts/postpublish"
32
32
  },