@pie-element/drawing-response 6.0.1-next.4 → 6.0.1-next.8

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
@@ -158,7 +158,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
158
158
 
159
159
  ### Features
160
160
 
161
- * add a different property in the config, forceEnabled, to force a value ([300c664](https://github.com/pie-framework/pie-elements/commit/300c664618f46177137deef3bced2d096cdb8126))
161
+ * add a different property in the config, to force a value ([300c664](https://github.com/pie-framework/pie-elements/commit/300c664618f46177137deef3bced2d096cdb8126))
162
162
 
163
163
 
164
164
 
@@ -147,7 +147,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
147
147
 
148
148
  ### Features
149
149
 
150
- * add a different property in the config, forceEnabled, to force a value ([300c664](https://github.com/pie-framework/pie-elements/commit/300c664618f46177137deef3bced2d096cdb8126))
150
+ * add a different property in the config, to force a value ([300c664](https://github.com/pie-framework/pie-elements/commit/300c664618f46177137deef3bced2d096cdb8126))
151
151
 
152
152
 
153
153
 
@@ -51,6 +51,8 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
51
51
  var _super = _createSuper(DrawableResponseConfigure);
52
52
 
53
53
  function DrawableResponseConfigure() {
54
+ var _this$_configuration$;
55
+
54
56
  var _this;
55
57
 
56
58
  (0, _classCallCheck2["default"])(this, DrawableResponseConfigure);
@@ -73,8 +75,14 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
73
75
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDeleteImage", function (src, done) {
74
76
  _this.dispatchEvent(new _pieConfigureEvents.DeleteImageEvent(src, done));
75
77
  });
76
- _this._configuration = _defaults["default"].configuration;
77
- _this._model = DrawableResponseConfigure.createDefaultModel({});
78
+ _this._configuration = _defaults["default"].configuration; // if configuration.withRubric.forceEnabled is true, then we
79
+ // update the configuration (we do not want to display the toggle in the Settings Panel)
80
+
81
+ if ((_this$_configuration$ = _this._configuration.withRubric) !== null && _this$_configuration$ !== void 0 && _this$_configuration$.forceEnabled) {
82
+ _this._configuration.withRubric.settings = false;
83
+ }
84
+
85
+ _this._model = DrawableResponseConfigure.createDefaultModel({}, _this._configuration);
78
86
  _this.onModelChanged = _this.onModelChanged.bind((0, _assertThisInitialized2["default"])(_this));
79
87
  return _this;
80
88
  }
@@ -82,7 +90,7 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
82
90
  (0, _createClass2["default"])(DrawableResponseConfigure, [{
83
91
  key: "model",
84
92
  set: function set(s) {
85
- this._model = DrawableResponseConfigure.createDefaultModel(s);
93
+ this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);
86
94
 
87
95
  this._render();
88
96
  }
@@ -91,6 +99,21 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
91
99
  set: function set(c) {
92
100
  this._configuration = c;
93
101
 
102
+ var _ref = c || {},
103
+ _ref$withRubric = _ref.withRubric,
104
+ withRubric = _ref$withRubric === void 0 ? {} : _ref$withRubric; // if configuration.withRubric.forceEnabled is true, then we update the model
105
+ // without triggering the Model Updated event (for more details, check documentation)
106
+ // and also update the configuration (we do not want to display the toggle in the Settings Panel)
107
+
108
+
109
+ if (withRubric !== null && withRubric !== void 0 && withRubric.forceEnabled) {
110
+ this._configuration.withRubric.settings = false;
111
+
112
+ if (!this._model.rubricEnabled) {
113
+ this._model.rubricEnabled = true;
114
+ }
115
+ }
116
+
94
117
  this._render();
95
118
  }
96
119
  }, {
@@ -137,7 +160,19 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
137
160
 
138
161
  exports["default"] = DrawableResponseConfigure;
139
162
  (0, _defineProperty2["default"])(DrawableResponseConfigure, "createDefaultModel", function () {
163
+ var _config$withRubric;
164
+
140
165
  var model = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
141
- return _objectSpread(_objectSpread({}, _defaults["default"].model), model);
166
+ var config = arguments.length > 1 ? arguments[1] : undefined;
167
+
168
+ var defaultModel = _objectSpread(_objectSpread({}, _defaults["default"].model), model); // if configuration.withRubric.forceEnabled is true, then we update the model
169
+ // without triggering the Model Updated event (for more details, check documentation)
170
+
171
+
172
+ if (config !== null && config !== void 0 && (_config$withRubric = config.withRubric) !== null && _config$withRubric !== void 0 && _config$withRubric.forceEnabled && !defaultModel.rubricEnabled) {
173
+ defaultModel.rubricEnabled = true;
174
+ }
175
+
176
+ return defaultModel;
142
177
  });
143
178
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","DrawableResponseConfigure","m","reset","_model","dispatchModelUpdated","_render","c","_configuration","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","sensibleDefaults","configuration","createDefaultModel","onModelChanged","bind","s","resetValue","ModelUpdatedEvent","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,yB;;;;;AAQnB,uCAAc;AAAA;;AAAA;AACZ;AADY,uGAwBG,UAACC,CAAD,EAAIC,KAAJ,EAAc;AAC7B,YAAKC,MAAL,GAAcF,CAAd;;AACA,YAAKG,oBAAL,CAA0BF,KAA1B;;AACA,YAAKG,OAAL;AACD,KA5Ba;AAAA,+GA8BW,UAACC,CAAD,EAAO;AAC9B,YAAKC,cAAL,GAAsBD,CAAtB;;AAEA,YAAKD,OAAL;AACD,KAlCa;AAAA,oGAoCA,UAACG,OAAD,EAAa;AACzB,YAAKC,aAAL,CAAmB,IAAIC,oCAAJ,CAAqBF,OAArB,CAAnB;AACD,KAtCa;AAA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AKtCC,QAAAA,YAAY,EAAE;AACZC,UAAAA,GAAG,EAAE,KAAKC,WADE;AAEZ,oBAAQ,KAAKC;AAFD,SALwB;AAStCC,QAAAA,kBAAkB,EAAE;AAClBH,UAAAA,GAAG,EAAE,KAAKI,WAAL,CAAiBjB,IAAjB,CAAsB,IAAtB,CADa;AAElB,oBAAQ,KAAKkB,aAAL,CAAmBlB,IAAnB,CAAwB,IAAxB;AAFU;AATkB,OAA1B,CAAd;;AAcAmB,2BAASC,MAAT,CAAgBd,OAAhB,EAAyB,IAAzB;AACD;;;kDA9EoDe,W;;;iCAAlCvC,yB,wBACS,YAAgB;AAAA,MAAf4B,KAAe,uEAAP,EAAO;AAC1C,yCACKd,qBAAiBc,KADtB,GAEKA,KAFL;AAID,C","sourcesContent":["import {\n DeleteImageEvent,\n DeleteSoundEvent,\n InsertImageEvent,\n InsertSoundEvent,\n ModelUpdatedEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class DrawableResponseConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => {\n return {\n ...sensibleDefaults.model,\n ...model,\n };\n };\n\n constructor() {\n super();\n this._configuration = sensibleDefaults.configuration;\n this._model = DrawableResponseConfigure.createDefaultModel({});\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = DrawableResponseConfigure.createDefaultModel(s);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged = (m, reset) => {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n };\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n\n this._render();\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\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 _render() {\n log('_render');\n\n let element = React.createElement(Root, {\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.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","DrawableResponseConfigure","m","reset","_model","dispatchModelUpdated","_render","c","_configuration","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","sensibleDefaults","configuration","withRubric","forceEnabled","settings","createDefaultModel","onModelChanged","bind","s","rubricEnabled","resetValue","ModelUpdatedEvent","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement","config","defaultModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,yB;;;;;AAgBnB,uCAAc;AAAA;;AAAA;;AAAA;AACZ;AADY,uGA6CG,UAACC,CAAD,EAAIC,KAAJ,EAAc;AAC7B,YAAKC,MAAL,GAAcF,CAAd;;AACA,YAAKG,oBAAL,CAA0BF,KAA1B;;AACA,YAAKG,OAAL;AACD,KAjDa;AAAA,+GAmDW,UAACC,CAAD,EAAO;AAC9B,YAAKC,cAAL,GAAsBD,CAAtB;;AAEA,YAAKD,OAAL;AACD,KAv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AACA,MAAIY,MAAM,SAAN,IAAAA,MAAM,WAAN,0BAAAA,MAAM,CAAE5B,UAAR,kEAAoBC,YAApB,IAAoC,CAAC4B,YAAY,CAACtB,aAAtD,EAAqE;AACnEsB,IAAAA,YAAY,CAACtB,aAAb,GAA6B,IAA7B;AACD;;AAED,SAAOsB,YAAP;AACD,C","sourcesContent":["import {\n DeleteImageEvent,\n DeleteSoundEvent,\n InsertImageEvent,\n InsertSoundEvent,\n ModelUpdatedEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class DrawableResponseConfigure extends HTMLElement {\n static createDefaultModel = (model = {}, config) => {\n const defaultModel = {\n ...sensibleDefaults.model,\n ...model,\n };\n\n // if configuration.withRubric.forceEnabled is true, then we update the model\n // without triggering the Model Updated event (for more details, check documentation)\n if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {\n defaultModel.rubricEnabled = true;\n }\n\n return defaultModel;\n };\n\n constructor() {\n super();\n this._configuration = sensibleDefaults.configuration;\n\n // if configuration.withRubric.forceEnabled is true, then we\n // update the configuration (we do not want to display the toggle in the Settings Panel)\n if (this._configuration.withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n }\n\n this._model = DrawableResponseConfigure.createDefaultModel({}, this._configuration);\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n\n const { withRubric = {} } = c || {};\n\n // if configuration.withRubric.forceEnabled is true, then we update the model\n // without triggering the Model Updated event (for more details, check documentation)\n // and also update the configuration (we do not want to display the toggle in the Settings Panel)\n if (withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n\n if (!this._model.rubricEnabled) {\n this._model.rubricEnabled = true;\n }\n }\n\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged = (m, reset) => {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n };\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n\n this._render();\n };\n\n insertImage = (handler) => {\n this.dispatchEvent(new InsertImageEvent(handler));\n };\n\n onDeleteImage = (src, done) => {\n this.dispatchEvent(new DeleteImageEvent(src, done));\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 _render() {\n log('_render');\n\n let element = React.createElement(Root, {\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.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
@@ -16,28 +16,57 @@ import sensibleDefaults from './defaults';
16
16
  const log = debug('hotspot:configure');
17
17
 
18
18
  export default class DrawableResponseConfigure extends HTMLElement {
19
- static createDefaultModel = (model = {}) => {
20
- return {
19
+ static createDefaultModel = (model = {}, config) => {
20
+ const defaultModel = {
21
21
  ...sensibleDefaults.model,
22
22
  ...model,
23
23
  };
24
+
25
+ // if configuration.withRubric.forceEnabled is true, then we update the model
26
+ // without triggering the Model Updated event (for more details, check documentation)
27
+ if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {
28
+ defaultModel.rubricEnabled = true;
29
+ }
30
+
31
+ return defaultModel;
24
32
  };
25
33
 
26
34
  constructor() {
27
35
  super();
28
36
  this._configuration = sensibleDefaults.configuration;
29
- this._model = DrawableResponseConfigure.createDefaultModel({});
37
+
38
+ // if configuration.withRubric.forceEnabled is true, then we
39
+ // update the configuration (we do not want to display the toggle in the Settings Panel)
40
+ if (this._configuration.withRubric?.forceEnabled) {
41
+ this._configuration.withRubric.settings = false;
42
+ }
43
+
44
+ this._model = DrawableResponseConfigure.createDefaultModel({}, this._configuration);
30
45
  this.onModelChanged = this.onModelChanged.bind(this);
31
46
  }
32
47
 
33
48
  set model(s) {
34
- this._model = DrawableResponseConfigure.createDefaultModel(s);
49
+ this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);
35
50
  this._render();
36
51
  }
37
52
 
38
53
  set configuration(c) {
39
54
  this._configuration = c;
40
55
 
56
+ const { withRubric = {} } = c || {};
57
+
58
+ // if configuration.withRubric.forceEnabled is true, then we update the model
59
+ // without triggering the Model Updated event (for more details, check documentation)
60
+ // and also update the configuration (we do not want to display the toggle in the Settings Panel)
61
+ if (withRubric?.forceEnabled) {
62
+ this._configuration.withRubric.settings = false;
63
+
64
+ if (!this._model.rubricEnabled) {
65
+ this._model.rubricEnabled = true;
66
+ }
67
+ }
68
+
69
+
41
70
  this._render();
42
71
  }
43
72
 
@@ -150,7 +150,7 @@
150
150
  "title": "label"
151
151
  },
152
152
  "forceEnabled": {
153
- "description": "Indicates the value for the toggle; if true, this property will not be visible in Settings Panel",
153
+ "description": "Indicates the value for the toggle;\nif true:\n- this property will not be visible in Settings Panel (settings will become automatically false)\n- the model property afferent to it will become automatically false",
154
154
  "type": "boolean",
155
155
  "title": "forceEnabled"
156
156
  }
@@ -243,7 +243,7 @@
243
243
  "title": "label"
244
244
  },
245
245
  "forceEnabled": {
246
- "description": "Indicates the value for the toggle; if true, this property will not be visible in Settings Panel",
246
+ "description": "Indicates the value for the toggle;\nif true:\n- this property will not be visible in Settings Panel (settings will become automatically false)\n- the model property afferent to it will become automatically false",
247
247
  "type": "boolean",
248
248
  "title": "forceEnabled"
249
249
  }
@@ -117,7 +117,10 @@ Indicates the label for the item that has to be displayed in the Settings Panel
117
117
 
118
118
  ## `forceEnabled` (boolean)
119
119
 
120
- Indicates the value for the toggle; if true, this property will not be visible in Settings Panel
120
+ Indicates the value for the toggle;
121
+ if true:
122
+ - this property will not be visible in Settings Panel (settings will become automatically false)
123
+ - the model property afferent to it will become automatically false
121
124
 
122
125
  # `showPrompt` (boolean)
123
126
 
@@ -196,4 +199,7 @@ Indicates the label for the item that has to be displayed in the Settings Panel
196
199
 
197
200
  ### `forceEnabled` (boolean)
198
201
 
199
- Indicates the value for the toggle; if true, this property will not be visible in Settings Panel
202
+ Indicates the value for the toggle;
203
+ if true:
204
+ - this property will not be visible in Settings Panel (settings will become automatically false)
205
+ - the model property afferent to it will become automatically false
@@ -183,7 +183,7 @@
183
183
  "title": "label"
184
184
  },
185
185
  "forceEnabled": {
186
- "description": "Indicates the value for the toggle; if true, this property will not be visible in Settings Panel",
186
+ "description": "Indicates the value for the toggle;\nif true:\n- this property will not be visible in Settings Panel (settings will become automatically false)\n- the model property afferent to it will become automatically false",
187
187
  "type": "boolean",
188
188
  "title": "forceEnabled"
189
189
  }
@@ -142,7 +142,10 @@ Indicates the label for the item that has to be displayed in the Settings Panel
142
142
 
143
143
  ### `forceEnabled` (boolean)
144
144
 
145
- Indicates the value for the toggle; if true, this property will not be visible in Settings Panel
145
+ Indicates the value for the toggle;
146
+ if true:
147
+ - this property will not be visible in Settings Panel (settings will become automatically false)
148
+ - the model property afferent to it will become automatically false
146
149
 
147
150
  ## `Dimension` (object)
148
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-element/drawing-response",
3
- "version": "6.0.1-next.4+69bbaac49",
3
+ "version": "6.0.1-next.8+ad9e76520",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "author": "pie framework developers",
26
26
  "license": "ISC",
27
- "gitHead": "69bbaac49e1321a823e9fa76cfcbcabc46fed010",
27
+ "gitHead": "ad9e7652097da344bb9a66d3fd478f98f4990d79",
28
28
  "scripts": {
29
29
  "postpublish": "../../scripts/postpublish"
30
30
  },