@pie-element/charting 2.7.18 → 2.7.20-beta.1443

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.
@@ -3,6 +3,381 @@
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.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.3.0...@pie-element/charting-configure@5.4.0) (2023-01-17)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * update pie-libs and update defaults ([f53fba9](https://github.com/pie-framework/pie-elements/commit/f53fba9cbed649e3b37895baa39855769781547f))
12
+
13
+
14
+ ### Features
15
+
16
+ * update pie-libs ([6423903](https://github.com/pie-framework/pie-elements/commit/6423903898b041f56db2111de2e4aac4ee9f1fd3))
17
+
18
+
19
+
20
+
21
+
22
+ # [5.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.2.3...@pie-element/charting-configure@5.3.0) (2023-01-05)
23
+
24
+
25
+ ### Features
26
+
27
+ * update pie-libs ([b174476](https://github.com/pie-framework/pie-elements/commit/b174476729119a0689f1f8adfc8c235246676cab))
28
+ * update pie-libs ([f72c3c8](https://github.com/pie-framework/pie-elements/commit/f72c3c8d8bc9bbf061bb81502317157a63c22972))
29
+ * update pie-libs ([8490729](https://github.com/pie-framework/pie-elements/commit/8490729a2389d36fd3968f0806119fde96577842))
30
+ * **charting:** added configuration prop to hide the settings panel PD-1999 ([a877144](https://github.com/pie-framework/pie-elements/commit/a8771441a7b62eaa061ccaee1ac8940fdcbb87be))
31
+
32
+
33
+
34
+
35
+
36
+ ## [5.2.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.2.2...@pie-element/charting-configure@5.2.3) (2022-12-21)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * updated pie-libs ([8cb5b90](https://github.com/pie-framework/pie-elements/commit/8cb5b90d501ccbdf5ffd764e6555faa48b8f54d6))
42
+
43
+
44
+
45
+
46
+
47
+ ## [5.2.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.2.1...@pie-element/charting-configure@5.2.2) (2022-12-20)
48
+
49
+
50
+ ### Bug Fixes
51
+
52
+ * updated pie-libs ([6549302](https://github.com/pie-framework/pie-elements/commit/65493026fbf356c5ab752ae6a14d961d4b256368))
53
+
54
+
55
+
56
+
57
+
58
+ ## [5.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.2.0...@pie-element/charting-configure@5.2.1) (2022-12-07)
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * update libs ([441f403](https://github.com/pie-framework/pie-elements/commit/441f403870b7bec0d61fab58b8d93dbe0ead4c32))
64
+ * update libs for PD-2030 PD-2031 ([3174022](https://github.com/pie-framework/pie-elements/commit/3174022d45603ed217bbe8804a142b07084636a5))
65
+ * updated lib PD-1715 ([42e788d](https://github.com/pie-framework/pie-elements/commit/42e788db0c792838994e55001952da7701251a8e))
66
+ * updated libs ([c20de3a](https://github.com/pie-framework/pie-elements/commit/c20de3a6ba4499a090c809e18e52588d2a585fa0))
67
+ * updated libs ([0eed79a](https://github.com/pie-framework/pie-elements/commit/0eed79a32c3b777c16c8cabf201513fc1d2726a0))
68
+ * updated libs ([343c9ec](https://github.com/pie-framework/pie-elements/commit/343c9ec3dccba7f781e90ae2bd195cac6f78f467))
69
+
70
+
71
+
72
+
73
+
74
+ # [5.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.1.2...@pie-element/charting-configure@5.2.0) (2022-11-15)
75
+
76
+
77
+ ### Bug Fixes
78
+
79
+ * **charting:** fix typo ([136ba52](https://github.com/pie-framework/pie-elements/commit/136ba521354dc58b73f9038767005d50da2dab94))
80
+
81
+
82
+ ### Features
83
+
84
+ * **charting:** add error messages for not valid correct response ([89de5ad](https://github.com/pie-framework/pie-elements/commit/89de5ad3b78ad2070db61b7808536b5d01c9cee0))
85
+ * **charting:** add sanity checks ([fa86a09](https://github.com/pie-framework/pie-elements/commit/fa86a09b9ade0aae654b2b94e652b3146e5fdbf2))
86
+ * **charting:** move validation function in controller ([e603e16](https://github.com/pie-framework/pie-elements/commit/e603e164cc206eec99488e48a52fc05989f919ea))
87
+ * **charting:** validation for category labels ([d9a697e](https://github.com/pie-framework/pie-elements/commit/d9a697e15ab9c2059799c4695cc11b9d31b574f6))
88
+ * **charting:** validation- work in progress ([1ac5501](https://github.com/pie-framework/pie-elements/commit/1ac5501b1842331861d93c0e51fa07fb8d0b8f42))
89
+
90
+
91
+
92
+
93
+
94
+ ## [5.1.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.1.1...@pie-element/charting-configure@5.1.2) (2022-11-11)
95
+
96
+
97
+ ### Bug Fixes
98
+
99
+ * **charting:** add sanity checks for withRubric ([a4e7fdc](https://github.com/pie-framework/pie-elements/commit/a4e7fdc85a89f8e018f7797fbe242a03be44eaa7))
100
+ * **drag-in-the-blank:** add sanity checks for withRubric ([709cdea](https://github.com/pie-framework/pie-elements/commit/709cdeaf53b19e44aab3be4250b01e8c50dcc645))
101
+
102
+
103
+
104
+
105
+
106
+ ## [5.1.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.1.0...@pie-element/charting-configure@5.1.1) (2022-10-31)
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * **charting:** add sanity checks for range and domain ([653e1e0](https://github.com/pie-framework/pie-elements/commit/653e1e0dea5f6a2453d17dfd2589e24509717775))
112
+
113
+
114
+
115
+
116
+
117
+ # [5.1.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.10...@pie-element/charting-configure@5.1.0) (2022-10-17)
118
+
119
+
120
+ ### Bug Fixes
121
+
122
+ * render math content in configure part PD-2082 ([732e5da](https://github.com/pie-framework/pie-elements/commit/732e5daa7da2a28a543c869133ef01733cd71818))
123
+ * update snapshots ([9781596](https://github.com/pie-framework/pie-elements/commit/978159686bbbd6b727dff4b88ce4ab9606504586))
124
+
125
+
126
+ ### Features
127
+
128
+ * set withRubric to false in item default configurations. Set rubricEnabled to true if it's enabled for drawing-response and extended-text-entry ([a209057](https://github.com/pie-framework/pie-elements/commit/a209057f5a3fa5438efc8595453c89c11959a8f5))
129
+ * update libs ([7e174fb](https://github.com/pie-framework/pie-elements/commit/7e174fba75e7ea668900ad5c103751cefe33e2af))
130
+ * **charting:** add pie-api config PD-23 ([b0f9e82](https://github.com/pie-framework/pie-elements/commit/b0f9e82c1c809b7f900b655aac6fce1375779679))
131
+ * **charting:** add settings to enable rubric. Add withRubric prop to configuration and rubricEnabled prop to model PD-2094 ([a58f5af](https://github.com/pie-framework/pie-elements/commit/a58f5af7cc94f2c6e1debcdd51f62d19e36fed19))
132
+ * **charting:** refactor ability to edit chart labels and title ([3d5be82](https://github.com/pie-framework/pie-elements/commit/3d5be82f1db8748d2adab0458137a3c9b7f17eb1))
133
+ * **charting:** updated snapshot PD-2094 ([3c1b10c](https://github.com/pie-framework/pie-elements/commit/3c1b10c81f57598bc454aecb50dbbf9ecb1c517e))
134
+ * enable spanish and special characters in author PD-2120 ([85fd3dd](https://github.com/pie-framework/pie-elements/commit/85fd3dd0fc10da1a2dfd5a842809c625790f8ba9))
135
+ * **charting:** add uploadSoundSupport property PD-23-updated ([c17de2c](https://github.com/pie-framework/pie-elements/commit/c17de2c1ce6933c9a218d3198b333d827d9682b5))
136
+
137
+
138
+
139
+
140
+
141
+ ## [5.0.10](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.9...@pie-element/charting-configure@5.0.10) (2022-09-29)
142
+
143
+ **Note:** Version bump only for package @pie-element/charting-configure
144
+
145
+
146
+
147
+
148
+
149
+ ## [5.0.9](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.8...@pie-element/charting-configure@5.0.9) (2022-09-14)
150
+
151
+ **Note:** Version bump only for package @pie-element/charting-configure
152
+
153
+
154
+
155
+
156
+
157
+ ## [5.0.8](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.7...@pie-element/charting-configure@5.0.8) (2022-09-13)
158
+
159
+ **Note:** Version bump only for package @pie-element/charting-configure
160
+
161
+
162
+
163
+
164
+
165
+ ## [5.0.7](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.6...@pie-element/charting-configure@5.0.7) (2022-08-31)
166
+
167
+ **Note:** Version bump only for package @pie-element/charting-configure
168
+
169
+
170
+
171
+
172
+
173
+ ## [5.0.6](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.5...@pie-element/charting-configure@5.0.6) (2022-08-16)
174
+
175
+ **Note:** Version bump only for package @pie-element/charting-configure
176
+
177
+
178
+
179
+
180
+
181
+ ## [5.0.5](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.4...@pie-element/charting-configure@5.0.5) (2022-08-08)
182
+
183
+ **Note:** Version bump only for package @pie-element/charting-configure
184
+
185
+
186
+
187
+
188
+
189
+ ## [5.0.4](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.3...@pie-element/charting-configure@5.0.4) (2022-08-02)
190
+
191
+ **Note:** Version bump only for package @pie-element/charting-configure
192
+
193
+
194
+
195
+
196
+
197
+ ## [5.0.3](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.2...@pie-element/charting-configure@5.0.3) (2022-07-22)
198
+
199
+ **Note:** Version bump only for package @pie-element/charting-configure
200
+
201
+
202
+
203
+
204
+
205
+ ## [5.0.2](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.1...@pie-element/charting-configure@5.0.2) (2022-07-20)
206
+
207
+ **Note:** Version bump only for package @pie-element/charting-configure
208
+
209
+
210
+
211
+
212
+
213
+ ## [5.0.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@5.0.0...@pie-element/charting-configure@5.0.1) (2022-07-19)
214
+
215
+ **Note:** Version bump only for package @pie-element/charting-configure
216
+
217
+
218
+
219
+
220
+
221
+ # [5.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@4.0.0...@pie-element/charting-configure@5.0.0) (2022-06-28)
222
+
223
+
224
+ ### Bug Fixes
225
+
226
+ * updated pie-lib since the previous version was a breaking change that was not released properly ([e51250d](https://github.com/pie-framework/pie-elements/commit/e51250dfe5b2d6593e186c685b6f75167479ff39))
227
+
228
+
229
+ ### Features
230
+
231
+ * **charting:** add maxImageWidth and maxImageHeight props PD-1801 ([0bff787](https://github.com/pie-framework/pie-elements/commit/0bff787ff2c9301138346f02e04646ee55f659fc))
232
+ * **charting:** remove editCategoryEnabled property ([0ea2a3c](https://github.com/pie-framework/pie-elements/commit/0ea2a3cf9c4ebf09c493ad6aee02ee1cc1987b36))
233
+ * **charting:** remove editCategoryEnabled property checkbox and usage. ([b844871](https://github.com/pie-framework/pie-elements/commit/b84487145c2d92edaaed2427070e4294b0681803))
234
+
235
+
236
+ ### Reverts
237
+
238
+ * Revert "try to add student can add categories checkbox in pie-lib" ([0ba8f3f](https://github.com/pie-framework/pie-elements/commit/0ba8f3f80ea98eee535b0c2da1da92b4899ada83))
239
+
240
+
241
+ ### BREAKING CHANGES
242
+
243
+ * **charting:** The editCategoryEnabled checkbox and property was removed.
244
+ Enabled property will be used for each category.
245
+ * **charting:** The editCategoryEnabled propery has been removed
246
+
247
+
248
+
249
+
250
+
251
+ # [4.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@3.0.0...@pie-element/charting-configure@4.0.0) (2022-06-28)
252
+
253
+
254
+ ### chore
255
+
256
+ * Merge master with develop. ([cdca48a](https://github.com/pie-framework/pie-elements/commit/cdca48abaa1d4179e4a961e13d171e14b7ed2444))
257
+
258
+
259
+ ### BREAKING CHANGES
260
+
261
+ * Image percent buttons were removed from toolbar.
262
+ New properties maxImageWidth and maxImageHeight were added.
263
+
264
+
265
+
266
+
267
+
268
+ # [3.0.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.49...@pie-element/charting-configure@3.0.0) (2022-06-13)
269
+
270
+
271
+ ### Features
272
+
273
+ * **charting:** remove editCategoryEnabled property checkbox and usage. ([b5e6a93](https://github.com/pie-framework/pie-elements/commit/b5e6a93fb99c957bec304bac7d7bf34ee3c98f27))
274
+
275
+
276
+ ### BREAKING CHANGES
277
+
278
+ * **charting:** The editCategoryEnabled checkbox and property was removed.
279
+ Enabled property will be used for each category.
280
+
281
+
282
+
283
+
284
+
285
+ ## [2.1.49](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.48...@pie-element/charting-configure@2.1.49) (2022-05-30)
286
+
287
+ **Note:** Version bump only for package @pie-element/charting-configure
288
+
289
+
290
+
291
+
292
+
293
+ ## [2.1.48](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.47...@pie-element/charting-configure@2.1.48) (2022-05-16)
294
+
295
+ **Note:** Version bump only for package @pie-element/charting-configure
296
+
297
+
298
+
299
+
300
+
301
+ ## [2.1.47](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.46...@pie-element/charting-configure@2.1.47) (2022-05-09)
302
+
303
+ **Note:** Version bump only for package @pie-element/charting-configure
304
+
305
+
306
+
307
+
308
+
309
+ ## [2.1.46](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.45...@pie-element/charting-configure@2.1.46) (2022-05-03)
310
+
311
+ **Note:** Version bump only for package @pie-element/charting-configure
312
+
313
+
314
+
315
+
316
+
317
+ ## [2.1.45](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.44...@pie-element/charting-configure@2.1.45) (2022-04-12)
318
+
319
+ **Note:** Version bump only for package @pie-element/charting-configure
320
+
321
+
322
+
323
+
324
+
325
+ ## [2.1.44](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.43...@pie-element/charting-configure@2.1.44) (2022-03-28)
326
+
327
+ **Note:** Version bump only for package @pie-element/charting-configure
328
+
329
+
330
+
331
+
332
+
333
+ ## [2.1.43](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.42...@pie-element/charting-configure@2.1.43) (2022-03-22)
334
+
335
+ **Note:** Version bump only for package @pie-element/charting-configure
336
+
337
+
338
+
339
+
340
+
341
+ ## [2.1.42](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.41...@pie-element/charting-configure@2.1.42) (2022-03-08)
342
+
343
+ **Note:** Version bump only for package @pie-element/charting-configure
344
+
345
+
346
+
347
+
348
+
349
+ ## [2.1.41](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.40...@pie-element/charting-configure@2.1.41) (2022-03-08)
350
+
351
+ **Note:** Version bump only for package @pie-element/charting-configure
352
+
353
+
354
+
355
+
356
+
357
+ ## [2.1.40](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.39...@pie-element/charting-configure@2.1.40) (2022-02-21)
358
+
359
+ **Note:** Version bump only for package @pie-element/charting-configure
360
+
361
+
362
+
363
+
364
+
365
+ ## [2.1.39](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.38...@pie-element/charting-configure@2.1.39) (2022-02-04)
366
+
367
+ **Note:** Version bump only for package @pie-element/charting-configure
368
+
369
+
370
+
371
+
372
+
373
+ ## [2.1.38](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.37...@pie-element/charting-configure@2.1.38) (2022-01-24)
374
+
375
+ **Note:** Version bump only for package @pie-element/charting-configure
376
+
377
+
378
+
379
+
380
+
6
381
  ## [2.1.37](https://github.com/pie-framework/pie-elements/compare/@pie-element/charting-configure@2.1.36...@pie-element/charting-configure@2.1.37) (2022-01-10)
7
382
 
8
383
  **Note:** Version bump only for package @pie-element/charting-configure
@@ -31,15 +31,19 @@ var _styles = require("@material-ui/core/styles");
31
31
 
32
32
  var _charting = require("@pie-lib/charting");
33
33
 
34
+ var _configUi = require("@pie-lib/config-ui");
35
+
36
+ var _Checkbox = _interopRequireDefault(require("@material-ui/core/Checkbox"));
37
+
34
38
  var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
35
39
 
36
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
41
 
38
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
43
 
40
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
44
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
45
 
42
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
46
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
47
 
44
48
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
45
49
 
@@ -59,37 +63,119 @@ var styles = function styles(theme) {
59
63
  };
60
64
  };
61
65
 
66
+ var restoreCorrectAnswer = function restoreCorrectAnswer(correctAnswer, data) {
67
+ if (!correctAnswer) {
68
+ return data;
69
+ }
70
+
71
+ var correctResponseDefinition = [];
72
+ (data || []).forEach(function (category, currentIndex) {
73
+ var _correctAnswer$curren, _correctAnswer$curren2;
74
+
75
+ var editable = category.editable,
76
+ interactive = category.interactive;
77
+ var label = editable && (_correctAnswer$curren = correctAnswer[currentIndex]) !== null && _correctAnswer$curren !== void 0 && _correctAnswer$curren.label ? correctAnswer[currentIndex].label : category.label;
78
+ var value = interactive && (_correctAnswer$curren2 = correctAnswer[currentIndex]) !== null && _correctAnswer$curren2 !== void 0 && _correctAnswer$curren2.value ? correctAnswer[currentIndex].value : category.value;
79
+ correctResponseDefinition[currentIndex] = {
80
+ label: label,
81
+ value: value,
82
+ editable: category.editable,
83
+ interactive: category.interactive
84
+ };
85
+ });
86
+ return correctResponseDefinition;
87
+ };
88
+
62
89
  var ChartingConfig = /*#__PURE__*/function (_React$Component) {
63
90
  (0, _inherits2["default"])(ChartingConfig, _React$Component);
64
91
 
65
92
  var _super = _createSuper(ChartingConfig);
66
93
 
67
- function ChartingConfig() {
94
+ function ChartingConfig(props) {
68
95
  var _this;
69
96
 
70
97
  (0, _classCallCheck2["default"])(this, ChartingConfig);
71
-
72
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73
- args[_key] = arguments[_key];
74
- }
75
-
76
- _this = _super.call.apply(_super, [this].concat(args));
98
+ _this = _super.call(this, props);
99
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleAlertDialog", function (open, callback) {
100
+ return _this.setState({
101
+ dialog: {
102
+ open: open
103
+ }
104
+ }, callback);
105
+ });
77
106
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeData", function (data) {
78
107
  return _this.props.onChange(_objectSpread(_objectSpread({}, _this.props.model), {}, {
79
108
  data: data
80
109
  }));
81
110
  });
111
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeAddRemoveEnabled", function (value) {
112
+ var model = _this.props.model;
113
+ var correctAnswer = restoreCorrectAnswer(model.correctAnswer.data, model.data);
114
+
115
+ if (!value) {
116
+ _this.setState({
117
+ dialog: {
118
+ open: true,
119
+ title: 'Warning',
120
+ text: "This change will remove any correct answer categories that are not part of the initial item configuration.",
121
+ onConfirm: function onConfirm() {
122
+ return _this.handleAlertDialog(false, _this.props.onChange(_objectSpread(_objectSpread({}, _this.props.model), {}, {
123
+ addCategoryEnabled: value,
124
+ correctAnswer: {
125
+ data: correctAnswer
126
+ }
127
+ })));
128
+ },
129
+ onClose: function onClose() {
130
+ return _this.handleAlertDialog(false);
131
+ }
132
+ }
133
+ });
134
+ } else {
135
+ _this.props.onChange(_objectSpread(_objectSpread({}, _this.props.model), {}, {
136
+ addCategoryEnabled: value
137
+ }));
138
+ }
139
+ });
140
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeTitle", function (title) {
141
+ return _this.props.onChange(_objectSpread(_objectSpread({}, _this.props.model), {}, {
142
+ title: title
143
+ }));
144
+ });
145
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "changeLabel", function (type, label) {
146
+ return _this.props.onChange(_objectSpread(_objectSpread({}, _this.props.model), {}, (0, _defineProperty2["default"])({}, type, _objectSpread(_objectSpread({}, _this.props.model[type]), {}, {
147
+ label: label
148
+ }))));
149
+ });
150
+ _this.state = {
151
+ dialog: {
152
+ open: false
153
+ }
154
+ };
82
155
  return _this;
83
156
  }
84
157
 
85
158
  (0, _createClass2["default"])(ChartingConfig, [{
86
159
  key: "render",
87
160
  value: function render() {
161
+ var _this2 = this;
162
+
88
163
  var _this$props = this.props,
89
164
  classes = _this$props.classes,
90
165
  model = _this$props.model,
91
- charts = _this$props.charts;
92
- return /*#__PURE__*/React.createElement("div", null, "Define Graph Attributes", /*#__PURE__*/React.createElement("div", {
166
+ charts = _this$props.charts,
167
+ labelsPlaceholders = _this$props.labelsPlaceholders,
168
+ titlePlaceholder = _this$props.titlePlaceholder,
169
+ showPixelGuides = _this$props.showPixelGuides;
170
+ var dialog = this.state.dialog;
171
+
172
+ var _ref = model || {},
173
+ _ref$domain = _ref.domain,
174
+ domain = _ref$domain === void 0 ? {} : _ref$domain,
175
+ _ref$range = _ref.range,
176
+ range = _ref$range === void 0 ? {} : _ref$range;
177
+
178
+ return /*#__PURE__*/React.createElement("div", null, "Define Initial Chart Attributes", /*#__PURE__*/React.createElement("div", {
93
179
  className: classes.container
94
180
  }, /*#__PURE__*/React.createElement("div", {
95
181
  className: classes.column,
@@ -97,18 +183,39 @@ var ChartingConfig = /*#__PURE__*/function (_React$Component) {
97
183
  }, /*#__PURE__*/React.createElement(_Typography["default"], {
98
184
  component: "div",
99
185
  type: "body1"
100
- }, /*#__PURE__*/React.createElement("span", null, "Use the tools below to set background shapes")), /*#__PURE__*/React.createElement(_charting.Chart, {
186
+ }, /*#__PURE__*/React.createElement("span", null, "Use the tools below to set up the chart as it will initially appear to students.")), /*#__PURE__*/React.createElement(_charting.Chart, {
187
+ defineChart: true,
188
+ showPixelGuides: showPixelGuides,
101
189
  chartType: model.chartType,
102
190
  size: model.graph,
103
- domain: model.domain,
104
- range: model.range,
105
- charts: charts,
106
- data: model.data,
191
+ domain: domain,
192
+ range: range,
193
+ charts: charts // index is a property used for setting the correct answer data; it's needed in order to remove categories from other data sets from the same index it was removed from the initial data
194
+ ,
195
+ data: model.data.map(function (category, index) {
196
+ return _objectSpread(_objectSpread({}, category), {}, {
197
+ index: index
198
+ });
199
+ }),
107
200
  title: model.title,
108
201
  onDataChange: this.changeData,
109
- editCategoryEnabled: true,
202
+ onChangeTitle: this.changeTitle,
203
+ onChangeLabels: this.changeLabel,
110
204
  addCategoryEnabled: true,
111
- categoryDefaultLabel: model.categoryDefaultLabel
205
+ categoryDefaultLabel: model.categoryDefaultLabel,
206
+ labelsPlaceholders: labelsPlaceholders,
207
+ titlePlaceholder: titlePlaceholder === null || titlePlaceholder === void 0 ? void 0 : titlePlaceholder.label
208
+ }), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(_Checkbox["default"], {
209
+ checked: model.addCategoryEnabled,
210
+ onChange: function onChange(e) {
211
+ _this2.changeAddRemoveEnabled(e.target.checked);
212
+ }
213
+ }), "Student can add categories"), /*#__PURE__*/React.createElement(_configUi.AlertDialog, {
214
+ open: dialog.open,
215
+ title: dialog.title,
216
+ text: dialog.text,
217
+ onClose: dialog.onClose,
218
+ onConfirm: dialog.onConfirm
112
219
  }))));
113
220
  }
114
221
  }]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/charting-config.jsx"],"names":["styles","theme","container","marginTop","spacing","unit","marginBottom","display","flex","column","ChartingConfig","data","props","onChange","model","classes","charts","chartType","graph","domain","range","title","changeData","categoryDefaultLabel","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAAAC,KAAK;AAAA,SAAK;AACvBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CADvB;AAETC,MAAAA,YAAY,EAAEL,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CAF1B;AAGTE,MAAAA,OAAO,EAAE,MAHA;AAITC,MAAAA,IAAI,EAAE;AAJG,KADY;AAOvBC,IAAAA,MAAM,EAAE;AACND,MAAAA,IAAI,EAAE;AADA;AAPe,GAAL;AAAA,CAApB;;IAYaE,c;;;;;;;;;;;;;;;mGAQE,UAAAC,IAAI;AAAA,aAAI,MAAKC,KAAL,CAAWC,QAAX,iCAAyB,MAAKD,KAAL,CAAWE,KAApC;AAA2CH,QAAAA,IAAI,EAAJA;AAA3C,SAAJ;AAAA,K;;;;;;WAEjB,kBAAS;AACP,wBAAmC,KAAKC,KAAxC;AAAA,UAAQG,OAAR,eAAQA,OAAR;AAAA,UAAiBD,KAAjB,eAAiBA,KAAjB;AAAA,UAAwBE,MAAxB,eAAwBA,MAAxB;AAEA,0BACE,yEAGE;AAAK,QAAA,SAAS,EAAED,OAAO,CAACb;AAAxB,sBACE;AAAK,QAAA,SAAS,EAAEa,OAAO,CAACN,MAAxB;AAAgC,QAAA,GAAG,EAAC;AAApC,sBACE,oBAAC,sBAAD;AAAY,QAAA,SAAS,EAAC,KAAtB;AAA4B,QAAA,IAAI,EAAC;AAAjC,sBACE,iFADF,CADF,eAKE,oBAAC,eAAD;AACE,QAAA,SAAS,EAAEK,KAAK,CAACG,SADnB;AAEE,QAAA,IAAI,EAAEH,KAAK,CAACI,KAFd;AAGE,QAAA,MAAM,EAAEJ,KAAK,CAACK,MAHhB;AAIE,QAAA,KAAK,EAAEL,KAAK,CAACM,KAJf;AAKE,QAAA,MAAM,EAAEJ,MALV;AAME,QAAA,IAAI,EAAEF,KAAK,CAACH,IANd;AAOE,QAAA,KAAK,EAAEG,KAAK,CAACO,KAPf;AAQE,QAAA,YAAY,EAAE,KAAKC,UARrB;AASE,QAAA,mBAAmB,EAAE,IATvB;AAUE,QAAA,kBAAkB,EAAE,IAVtB;AAWE,QAAA,oBAAoB,EAAER,KAAK,CAACS;AAX9B,QALF,CADF,CAHF,CADF;AA4BD;;;EAzCiCC,KAAK,CAACC,S;;;iCAA7Bf,c,eACQ;AACjBK,EAAAA,OAAO,EAAEW,sBAAUC,MAAV,CAAiBC,UADT;AAEjBd,EAAAA,KAAK,EAAEY,sBAAUC,MAAV,CAAiBC,UAFP;AAGjBf,EAAAA,QAAQ,EAAEa,sBAAUG,IAAV,CAAeD,UAHR;AAIjBZ,EAAAA,MAAM,EAAEU,sBAAUI;AAJD,C;;eA2CN,wBAAW9B,MAAX,EAAmBU,cAAnB,C","sourcesContent":["import * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\n\nimport Typography from '@material-ui/core/Typography';\n\nconst styles = theme => ({\n container: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit * 3,\n display: 'flex',\n flex: 1,\n },\n column: {\n flex: 1\n }\n});\n\nexport class ChartingConfig extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array\n };\n\n changeData = data => this.props.onChange({ ...this.props.model, data });\n\n render() {\n const { classes, model, charts } = this.props;\n\n return (\n <div>\n Define Graph Attributes\n\n <div className={classes.container}>\n <div className={classes.column} key=\"graph\">\n <Typography component=\"div\" type=\"body1\">\n <span>Use the tools below to set background shapes</span>\n </Typography>\n\n <Chart\n chartType={model.chartType}\n size={model.graph}\n domain={model.domain}\n range={model.range}\n charts={charts}\n data={model.data}\n title={model.title}\n onDataChange={this.changeData}\n editCategoryEnabled={true}\n addCategoryEnabled={true}\n categoryDefaultLabel={model.categoryDefaultLabel}\n />\n </div>\n\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(ChartingConfig);\n"],"file":"charting-config.js"}
1
+ {"version":3,"sources":["../src/charting-config.jsx"],"names":["styles","theme","container","marginTop","spacing","unit","marginBottom","display","flex","column","restoreCorrectAnswer","correctAnswer","data","correctResponseDefinition","forEach","category","currentIndex","editable","interactive","label","value","ChartingConfig","props","open","callback","setState","dialog","onChange","model","title","text","onConfirm","handleAlertDialog","addCategoryEnabled","onClose","type","state","classes","charts","labelsPlaceholders","titlePlaceholder","showPixelGuides","domain","range","chartType","graph","map","index","changeData","changeTitle","changeLabel","categoryDefaultLabel","e","changeAddRemoveEnabled","target","checked","React","Component","PropTypes","object","isRequired","func","array"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;AAEA,IAAMA,MAAM,GAAG,SAATA,MAAS,CAACC,KAAD;AAAA,SAAY;AACzBC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAEF,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CADvB;AAETC,MAAAA,YAAY,EAAEL,KAAK,CAACG,OAAN,CAAcC,IAAd,GAAqB,CAF1B;AAGTE,MAAAA,OAAO,EAAE,MAHA;AAITC,MAAAA,IAAI,EAAE;AAJG,KADc;AAOzBC,IAAAA,MAAM,EAAE;AACND,MAAAA,IAAI,EAAE;AADA;AAPiB,GAAZ;AAAA,CAAf;;AAYA,IAAME,oBAAoB,GAAG,SAAvBA,oBAAuB,CAACC,aAAD,EAAgBC,IAAhB,EAAyB;AACpD,MAAI,CAACD,aAAL,EAAoB;AAClB,WAAOC,IAAP;AACD;;AAED,MAAIC,yBAAyB,GAAG,EAAhC;AA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'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { Chart } from '@pie-lib/charting';\nimport { AlertDialog } from '@pie-lib/config-ui';\nimport Checkbox from '@material-ui/core/Checkbox';\n\nimport Typography from '@material-ui/core/Typography';\n\nconst styles = (theme) => ({\n container: {\n marginTop: theme.spacing.unit * 3,\n marginBottom: theme.spacing.unit * 3,\n display: 'flex',\n flex: 1,\n },\n column: {\n flex: 1,\n },\n});\n\nconst restoreCorrectAnswer = (correctAnswer, data) => {\n if (!correctAnswer) {\n return data;\n }\n\n let correctResponseDefinition = [];\n\n (data || []).forEach((category, currentIndex) => {\n const { editable, interactive } = category;\n\n const label = editable && correctAnswer[currentIndex]?.label ? correctAnswer[currentIndex].label : category.label;\n\n const value =\n interactive && correctAnswer[currentIndex]?.value ? correctAnswer[currentIndex].value : category.value;\n\n correctResponseDefinition[currentIndex] = {\n label: label,\n value: value,\n editable: category.editable,\n interactive: category.interactive,\n };\n });\n\n return correctResponseDefinition;\n};\n\nexport class ChartingConfig extends React.Component {\n static propTypes = {\n classes: PropTypes.object.isRequired,\n model: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n charts: PropTypes.array,\n };\n\n constructor(props) {\n super(props);\n this.state = {\n dialog: {\n open: false,\n },\n };\n }\n\n handleAlertDialog = (open, callback) =>\n this.setState(\n {\n dialog: { open },\n },\n callback,\n );\n\n changeData = (data) => this.props.onChange({ ...this.props.model, data });\n\n changeAddRemoveEnabled = (value) => {\n const { model } = this.props;\n const correctAnswer = restoreCorrectAnswer(model.correctAnswer.data, model.data);\n\n if (!value) {\n this.setState({\n dialog: {\n open: true,\n title: 'Warning',\n text: `This change will remove any correct answer categories that are not part of the initial item configuration.`,\n onConfirm: () =>\n this.handleAlertDialog(\n false,\n this.props.onChange({\n ...this.props.model,\n addCategoryEnabled: value,\n correctAnswer: { data: correctAnswer },\n }),\n ),\n onClose: () => this.handleAlertDialog(false),\n },\n });\n } else {\n this.props.onChange({ ...this.props.model, addCategoryEnabled: value });\n }\n };\n\n changeTitle = (title) => this.props.onChange({ ...this.props.model, title });\n\n changeLabel = (type, label) =>\n this.props.onChange({\n ...this.props.model,\n [type]: {\n ...this.props.model[type],\n label,\n },\n });\n\n render() {\n const { classes, model, charts, labelsPlaceholders, titlePlaceholder, showPixelGuides } = this.props;\n const { dialog } = this.state;\n const { domain = {}, range = {} } = model || {};\n\n return (\n <div>\n Define Initial Chart Attributes\n <div className={classes.container}>\n <div className={classes.column} key=\"graph\">\n <Typography component=\"div\" type=\"body1\">\n <span>Use the tools below to set up the chart as it will initially appear to students.</span>\n </Typography>\n\n <Chart\n defineChart={true}\n showPixelGuides={showPixelGuides}\n chartType={model.chartType}\n size={model.graph}\n domain={domain}\n range={range}\n charts={charts}\n // index is a property used for setting the correct answer data; it's needed in order to remove categories from other data sets from the same index it was removed from the initial data\n data={model.data.map((category, index) => ({\n ...category,\n index: index,\n }))}\n title={model.title}\n onDataChange={this.changeData}\n onChangeTitle={this.changeTitle}\n onChangeLabels={this.changeLabel}\n addCategoryEnabled={true}\n categoryDefaultLabel={model.categoryDefaultLabel}\n labelsPlaceholders={labelsPlaceholders}\n titlePlaceholder={titlePlaceholder?.label}\n />\n <div>\n <Checkbox\n checked={model.addCategoryEnabled}\n onChange={(e) => {\n this.changeAddRemoveEnabled(e.target.checked);\n }}\n />\n Student can add categories\n </div>\n\n <AlertDialog\n open={dialog.open}\n title={dialog.title}\n text={dialog.text}\n onClose={dialog.onClose}\n onConfirm={dialog.onConfirm}\n />\n </div>\n </div>\n </div>\n );\n }\n}\n\nexport default withStyles(styles)(ChartingConfig);\n"],"file":"charting-config.js"}