@pie-element/ebsr 6.6.3-next.133 → 6.6.3-next.1353

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.
@@ -85,6 +85,11 @@
85
85
  "type": "boolean",
86
86
  "title": "rationaleEnabled"
87
87
  },
88
+ "spellCheckEnabled": {
89
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
90
+ "type": "boolean",
91
+ "title": "spellCheckEnabled"
92
+ },
88
93
  "studentInstructionsEnabled": {
89
94
  "description": "Indicates if Student Instructions are enabled",
90
95
  "type": "boolean",
@@ -109,6 +114,7 @@
109
114
  "feedbackEnabled",
110
115
  "prompt",
111
116
  "rationaleEnabled",
117
+ "spellCheckEnabled",
112
118
  "studentInstructionsEnabled",
113
119
  "teacherInstructionsEnabled"
114
120
  ]
@@ -195,6 +201,11 @@
195
201
  "type": "boolean",
196
202
  "title": "rationaleEnabled"
197
203
  },
204
+ "spellCheckEnabled": {
205
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
206
+ "type": "boolean",
207
+ "title": "spellCheckEnabled"
208
+ },
198
209
  "studentInstructionsEnabled": {
199
210
  "description": "Indicates if Student Instructions are enabled",
200
211
  "type": "boolean",
@@ -219,6 +230,7 @@
219
230
  "feedbackEnabled",
220
231
  "prompt",
221
232
  "rationaleEnabled",
233
+ "spellCheckEnabled",
222
234
  "studentInstructionsEnabled",
223
235
  "teacherInstructionsEnabled"
224
236
  ]
@@ -387,6 +399,22 @@
387
399
  }
388
400
  }
389
401
  },
402
+ "spellCheck": {
403
+ "title": "ConfigureProp",
404
+ "type": "object",
405
+ "properties": {
406
+ "settings": {
407
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
408
+ "type": "boolean",
409
+ "title": "settings"
410
+ },
411
+ "label": {
412
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
413
+ "type": "string",
414
+ "title": "label"
415
+ }
416
+ }
417
+ },
390
418
  "rationale": {
391
419
  "title": "ConfigureProp",
392
420
  "type": "object",
@@ -435,7 +463,23 @@
435
463
  }
436
464
  }
437
465
  },
438
- "verticalMode": {
466
+ "choicesLayout": {
467
+ "title": "ConfigureProp",
468
+ "type": "object",
469
+ "properties": {
470
+ "settings": {
471
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
472
+ "type": "boolean",
473
+ "title": "settings"
474
+ },
475
+ "label": {
476
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
477
+ "type": "string",
478
+ "title": "label"
479
+ }
480
+ }
481
+ },
482
+ "gridColumns": {
439
483
  "title": "ConfigureProp",
440
484
  "type": "object",
441
485
  "properties": {
@@ -450,6 +494,68 @@
450
494
  "title": "label"
451
495
  }
452
496
  }
497
+ },
498
+ "minAnswerChoices": {
499
+ "description": "Minimum number of answer choices",
500
+ "type": "number",
501
+ "title": "minAnswerChoices"
502
+ },
503
+ "maxAnswerChoices": {
504
+ "description": "Maximum number of answer choices",
505
+ "type": "number",
506
+ "title": "maxAnswerChoices"
507
+ },
508
+ "maxImageWidth": {
509
+ "title": "ConfigureMaxImageDimensionsProp",
510
+ "type": "object",
511
+ "properties": {
512
+ "teacherInstructions": {
513
+ "description": "Indicates the max dimension for images in teacher instructions",
514
+ "type": "number",
515
+ "title": "teacherInstructions"
516
+ },
517
+ "prompt": {
518
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
519
+ "type": "number",
520
+ "title": "prompt"
521
+ },
522
+ "rationale": {
523
+ "description": "Indicates the max dimension for images in rationale",
524
+ "type": "number",
525
+ "title": "rationale"
526
+ },
527
+ "choices": {
528
+ "description": "Indicates the max dimension for images in choices",
529
+ "type": "number",
530
+ "title": "choices"
531
+ }
532
+ }
533
+ },
534
+ "maxImageHeight": {
535
+ "title": "ConfigureMaxImageDimensionsProp",
536
+ "type": "object",
537
+ "properties": {
538
+ "teacherInstructions": {
539
+ "description": "Indicates the max dimension for images in teacher instructions",
540
+ "type": "number",
541
+ "title": "teacherInstructions"
542
+ },
543
+ "prompt": {
544
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
545
+ "type": "number",
546
+ "title": "prompt"
547
+ },
548
+ "rationale": {
549
+ "description": "Indicates the max dimension for images in rationale",
550
+ "type": "number",
551
+ "title": "rationale"
552
+ },
553
+ "choices": {
554
+ "description": "Indicates the max dimension for images in choices",
555
+ "type": "number",
556
+ "title": "choices"
557
+ }
558
+ }
453
559
  }
454
560
  }
455
561
  },
@@ -469,6 +575,32 @@
469
575
  }
470
576
  }
471
577
  },
578
+ "ConfigureMaxImageDimensionsProp": {
579
+ "title": "ConfigureMaxImageDimensionsProp",
580
+ "type": "object",
581
+ "properties": {
582
+ "teacherInstructions": {
583
+ "description": "Indicates the max dimension for images in teacher instructions",
584
+ "type": "number",
585
+ "title": "teacherInstructions"
586
+ },
587
+ "prompt": {
588
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
589
+ "type": "number",
590
+ "title": "prompt"
591
+ },
592
+ "rationale": {
593
+ "description": "Indicates the max dimension for images in rationale",
594
+ "type": "number",
595
+ "title": "rationale"
596
+ },
597
+ "choices": {
598
+ "description": "Indicates the max dimension for images in choices",
599
+ "type": "number",
600
+ "title": "choices"
601
+ }
602
+ }
603
+ },
472
604
  "Part": {
473
605
  "title": "Part",
474
606
  "type": "object",
@@ -551,6 +683,11 @@
551
683
  "type": "boolean",
552
684
  "title": "rationaleEnabled"
553
685
  },
686
+ "spellCheckEnabled": {
687
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
688
+ "type": "boolean",
689
+ "title": "spellCheckEnabled"
690
+ },
554
691
  "studentInstructionsEnabled": {
555
692
  "description": "Indicates if Student Instructions are enabled",
556
693
  "type": "boolean",
@@ -575,6 +712,7 @@
575
712
  "feedbackEnabled",
576
713
  "prompt",
577
714
  "rationaleEnabled",
715
+ "spellCheckEnabled",
578
716
  "studentInstructionsEnabled",
579
717
  "teacherInstructionsEnabled"
580
718
  ]
@@ -68,6 +68,10 @@ Indicates if Feedback is enabled
68
68
 
69
69
  Indicates if Rationale are enabled
70
70
 
71
+ ## `spellCheckEnabled` (boolean, required)
72
+
73
+ Indicates if spellcheck is enabled for the author. Default value is true
74
+
71
75
  ## `studentInstructionsEnabled` (boolean, required)
72
76
 
73
77
  Indicates if Student Instructions are enabled
@@ -148,6 +152,10 @@ Indicates if Feedback is enabled
148
152
 
149
153
  Indicates if Rationale are enabled
150
154
 
155
+ ## `spellCheckEnabled` (boolean, required)
156
+
157
+ Indicates if spellcheck is enabled for the author. Default value is true
158
+
151
159
  ## `studentInstructionsEnabled` (boolean, required)
152
160
 
153
161
  Indicates if Student Instructions are enabled
@@ -290,6 +298,18 @@ Indicates if the item has to be displayed in the Settings Panel
290
298
 
291
299
  Indicates the label for the item that has to be displayed in the Settings Panel
292
300
 
301
+ ### `spellCheck` (object)
302
+
303
+ Properties of the `spellCheck` object:
304
+
305
+ #### `settings` (boolean)
306
+
307
+ Indicates if the item has to be displayed in the Settings Panel
308
+
309
+ #### `label` (string)
310
+
311
+ Indicates the label for the item that has to be displayed in the Settings Panel
312
+
293
313
  ### `rationale` (object)
294
314
 
295
315
  Properties of the `rationale` object:
@@ -326,9 +346,21 @@ Indicates if the item has to be displayed in the Settings Panel
326
346
 
327
347
  Indicates the label for the item that has to be displayed in the Settings Panel
328
348
 
329
- ### `verticalMode` (object)
349
+ ### `choicesLayout` (object)
350
+
351
+ Properties of the `choicesLayout` object:
352
+
353
+ #### `settings` (boolean)
354
+
355
+ Indicates if the item has to be displayed in the Settings Panel
356
+
357
+ #### `label` (string)
358
+
359
+ Indicates the label for the item that has to be displayed in the Settings Panel
360
+
361
+ ### `gridColumns` (object)
330
362
 
331
- Properties of the `verticalMode` object:
363
+ Properties of the `gridColumns` object:
332
364
 
333
365
  #### `settings` (boolean)
334
366
 
@@ -338,6 +370,54 @@ Indicates if the item has to be displayed in the Settings Panel
338
370
 
339
371
  Indicates the label for the item that has to be displayed in the Settings Panel
340
372
 
373
+ ### `minAnswerChoices` (number)
374
+
375
+ Minimum number of answer choices
376
+
377
+ ### `maxAnswerChoices` (number)
378
+
379
+ Maximum number of answer choices
380
+
381
+ ### `maxImageWidth` (object)
382
+
383
+ Properties of the `maxImageWidth` object:
384
+
385
+ #### `teacherInstructions` (number)
386
+
387
+ Indicates the max dimension for images in teacher instructions
388
+
389
+ #### `prompt` (number)
390
+
391
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
392
+
393
+ #### `rationale` (number)
394
+
395
+ Indicates the max dimension for images in rationale
396
+
397
+ #### `choices` (number)
398
+
399
+ Indicates the max dimension for images in choices
400
+
401
+ ### `maxImageHeight` (object)
402
+
403
+ Properties of the `maxImageHeight` object:
404
+
405
+ #### `teacherInstructions` (number)
406
+
407
+ Indicates the max dimension for images in teacher instructions
408
+
409
+ #### `prompt` (number)
410
+
411
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
412
+
413
+ #### `rationale` (number)
414
+
415
+ Indicates the max dimension for images in rationale
416
+
417
+ #### `choices` (number)
418
+
419
+ Indicates the max dimension for images in choices
420
+
341
421
  ## `ConfigureProp` (object)
342
422
 
343
423
  Properties of the `ConfigureProp` object:
@@ -350,6 +430,26 @@ Indicates if the item has to be displayed in the Settings Panel
350
430
 
351
431
  Indicates the label for the item that has to be displayed in the Settings Panel
352
432
 
433
+ ## `ConfigureMaxImageDimensionsProp` (object)
434
+
435
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
436
+
437
+ ### `teacherInstructions` (number)
438
+
439
+ Indicates the max dimension for images in teacher instructions
440
+
441
+ ### `prompt` (number)
442
+
443
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
444
+
445
+ ### `rationale` (number)
446
+
447
+ Indicates the max dimension for images in rationale
448
+
449
+ ### `choices` (number)
450
+
451
+ Indicates the max dimension for images in choices
452
+
353
453
  ## `Part` (object)
354
454
 
355
455
  Properties of the `Part` object:
@@ -416,6 +516,10 @@ Indicates if Feedback is enabled
416
516
 
417
517
  Indicates if Rationale are enabled
418
518
 
519
+ ### `spellCheckEnabled` (boolean, required)
520
+
521
+ Indicates if spellcheck is enabled for the author. Default value is true
522
+
419
523
  ### `studentInstructionsEnabled` (boolean, required)
420
524
 
421
525
  Indicates if Student Instructions are enabled
package/lib/index.js CHANGED
@@ -5,9 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.isSessionComplete = void 0;
9
-
10
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
8
+ exports.isSessionComplete = exports["default"] = void 0;
11
9
 
12
10
  var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
13
11
 
@@ -15,6 +13,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
15
13
 
16
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
15
 
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
19
 
20
20
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
@@ -31,13 +31,13 @@ var _get = _interopRequireDefault(require("lodash/get"));
31
31
 
32
32
  var _debug = _interopRequireDefault(require("debug"));
33
33
 
34
- 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; }
34
+ 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; }
35
35
 
36
- 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; }
36
+ 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; }
37
37
 
38
38
  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); }; }
39
39
 
40
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
41
41
 
42
42
  var SESSION_CHANGED = _piePlayerEvents.SessionChangedEvent.TYPE;
43
43
  var MC_TAG_NAME = 'ebsr-multiple-choice';
@@ -53,7 +53,7 @@ var EbsrMC = /*#__PURE__*/function (_MultipleChoice) {
53
53
  return _super.apply(this, arguments);
54
54
  }
55
55
 
56
- return EbsrMC;
56
+ return (0, _createClass2["default"])(EbsrMC);
57
57
  }(_multipleChoice["default"]);
58
58
 
59
59
  var defineMultipleChoice = function defineMultipleChoice() {
@@ -125,6 +125,9 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
125
125
  }
126
126
  }, {
127
127
  key: "session",
128
+ get: function get() {
129
+ return this._session;
130
+ },
128
131
  set: function set(s) {
129
132
  var _this3 = this;
130
133
 
@@ -138,7 +141,7 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
138
141
  }, {
139
142
  key: "setPartModel",
140
143
  value: function setPartModel(part, key) {
141
- if (this._model && this._model[key]) {
144
+ if (this._model && this._model[key] && part) {
142
145
  var mode = this._model.mode;
143
146
  part.model = _objectSpread(_objectSpread({}, this._model[key]), {}, {
144
147
  mode: mode,
@@ -149,7 +152,7 @@ var Ebsr = /*#__PURE__*/function (_HTMLElement) {
149
152
  }, {
150
153
  key: "setPartSession",
151
154
  value: function setPartSession(part, key) {
152
- if (this._session && this._model) {
155
+ if (this._session && this._model && part) {
153
156
  var value = this._session.value;
154
157
  part.session = value && value[key] ? value[key] : {
155
158
  id: key
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["SESSION_CHANGED","SessionChangedEvent","TYPE","MC_TAG_NAME","log","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","Ebsr","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","mode","model","keyMode","choicePrefix","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AACA,IAAMA,eAAe,GAAGC,qCAAoBC,IAA5C;AACA,IAAMC,WAAW,GAAG,sBAApB;AACA,IAAMC,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEMC,M;;;;;;;;;;;EAAeC,0B;;AAErB,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,GAAM;AACjC,MAAI,CAACC,cAAc,CAACC,GAAf,CAAmBN,WAAnB,CAAL,EAAsC;AACpCK,IAAAA,cAAc,CAACE,MAAf,CAAsBP,WAAtB,EAAmCE,MAAnC;AACD;AACF,CAJD;;AAMAE,oBAAoB;;AAEpB,IAAMI,eAAe,GAAG,SAAlBA,eAAkB,CAACC,CAAD;AAAA,SAAOC,KAAK,CAACC,OAAN,CAAcF,CAAd,KAAoBA,CAAC,CAACG,MAAF,GAAW,CAAtC;AAAA,CAAxB;;AAEO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,OAAD,EAAa;AAC5C,MAAML,CAAC,GAAG,qBAAIK,OAAJ,EAAa,mBAAb,CAAV;AACA,MAAMC,CAAC,GAAG,qBAAID,OAAJ,EAAa,mBAAb,CAAV;AAEA,SAAON,eAAe,CAACC,CAAD,CAAf,IAAsBD,eAAe,CAACO,CAAD,CAA5C;AACD,CALM;;;;IAOcC,I;;;;;AACnB,kBAAc;AAAA;;AAAA;AACZ;AADY,yGAMK,UAACC,CAAD,EAAO;AACxB,UAAIA,CAAC,CAACC,MAAF,mDAAJ,EAAuB;AACrB;AACD;;AAEDD,MAAAA,CAAC,CAACE,cAAF;AACAF,MAAAA,CAAC,CAACG,wBAAF;AAEA,UAAMC,EAAE,GAAGJ,CAAC,CAACC,MAAF,CAASI,YAAT,CAAsB,IAAtB,CAAX;;AAEA,UAAID,EAAJ,EAAQ;AACN,YAAME,GAAG,i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ionChangedEvent } from '@pie-framework/pie-player-events';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport get from 'lodash/get';\nimport debug from 'debug';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst log = debug('pie-elements:ebsr');\n\nclass EbsrMC extends MultipleChoice {}\n\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMC);\n }\n};\n\ndefineMultipleChoice();\n\nconst isNonEmptyArray = (a) => Array.isArray(a) && a.length > 0;\n\nexport const isSessionComplete = (session) => {\n const a = get(session, 'value.partA.value');\n const b = get(session, 'value.partB.value');\n\n return isNonEmptyArray(a) && isNonEmptyArray(b);\n};\n\nexport default class Ebsr extends HTMLElement {\n constructor() {\n super();\n this._model = {};\n this._session = {};\n }\n\n onSessionUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target.getAttribute('id');\n\n if (id) {\n const key = `part${id.toUpperCase()}`;\n\n if (e.update) {\n this._model[key] = e.update;\n }\n //TODO: accessing a private property here. The session event should contain the update in future to prevent this.\n this.dispatchSessionChanged(e.srcElement._session, key);\n }\n };\n\n set model(m) {\n this._model = m;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartModel(this.partA, 'partA');\n this.setPartModel(this.partB, 'partB');\n });\n }\n\n set session(s) {\n this._session = s;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartSession(this.partA, 'partA');\n this.setPartSession(this.partB, 'partB');\n });\n }\n\n setPartModel(part, key) {\n if (this._model && this._model[key]) {\n const { mode } = this._model;\n\n part.model = {\n ...this._model[key],\n mode,\n keyMode: this._model[key].choicePrefix,\n };\n }\n }\n\n setPartSession(part, key) {\n if (this._session && this._model) {\n const { value } = this._session;\n part.session = value && value[key] ? value[key] : { id: key };\n }\n }\n\n dispatchSessionChanged(partSession, key) {\n this._session.value = {\n ...this._session.value,\n [key]: partSession,\n };\n\n log('[onSessionChanged] session: ', this._session);\n const complete = isSessionComplete(this._session);\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), complete)\n );\n }\n\n get partA() {\n return this.querySelector(`${MC_TAG_NAME}#a`);\n }\n\n get partB() {\n return this.querySelector(`${MC_TAG_NAME}#b`);\n }\n\n connectedCallback() {\n this._render();\n this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n disconnectedCallback() {\n this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n _render() {\n this.innerHTML = `\n <div>\n <${MC_TAG_NAME} id=\"a\"></${MC_TAG_NAME}>\n <${MC_TAG_NAME} id=\"b\"></${MC_TAG_NAME}>\n </div>\n `;\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["SESSION_CHANGED","SessionChangedEvent","TYPE","MC_TAG_NAME","log","EbsrMC","MultipleChoice","defineMultipleChoice","customElements","get","define","isNonEmptyArray","a","Array","isArray","length","isSessionComplete","session","b","Ebsr","e","target","preventDefault","stopImmediatePropagation","id","getAttribute","key","toUpperCase","update","_model","dispatchSessionChanged","srcElement","_session","m","whenDefined","then","setPartModel","partA","partB","s","setPartSession","part","mode","model","keyMode","choicePrefix","value","partSession","complete","dispatchEvent","tagName","toLowerCase","querySelector","_render","addEventListener","onSessionUpdated","removeEventListener","innerHTML","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;AACA,IAAMA,eAAe,GAAGC,qCAAoBC,IAA5C;AACA,IAAMC,WAAW,GAAG,sBAApB;AACA,IAAMC,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEMC,M;;;;;;;;;;;EAAeC,0B;;AAErB,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAuB,GAAM;AACjC,MAAI,CAACC,cAAc,CAACC,GAAf,CAAmBN,WAAnB,CAAL,E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sBoB,KAAK,CAACpB,GAAD,CAA3B,GAAmC;AAAEF,UAAAA,EAAE,EAAEE;AAAN,SAAlD;AACD;AACF;;;WAED,gCAAuBqB,WAAvB,EAAoCrB,GAApC,EAAyC;AACvC,WAAKM,QAAL,CAAcc,KAAd,mCACK,KAAKd,QAAL,CAAcc,KADnB,4CAEGpB,GAFH,EAESqB,WAFT;AAKA3C,MAAAA,GAAG,CAAC,8BAAD,EAAiC,KAAK4B,QAAtC,CAAH;AACA,UAAMgB,QAAQ,GAAGhC,iBAAiB,CAAC,KAAKgB,QAAN,CAAlC;AACA,WAAKiB,aAAL,CACE,IAAIhD,oCAAJ,CAAwB,KAAKiD,OAAL,CAAaC,WAAb,EAAxB,EAAoDH,QAApD,CADF;AAGD;;;SAED,eAAY;AACV,aAAO,KAAKI,aAAL,WAAsBjD,WAAtB,QAAP;AACD;;;SAED,eAAY;AACV,aAAO,KAAKiD,aAAL,WAAsBjD,WAAtB,QAAP;AACD;;;WAED,6BAAoB;AAClB,WAAKkD,OAAL;;AACA,WAAKC,gBAAL,CAAsBtD,eAAtB,EAAuC,KAAKuD,gBAA5C;AACD;;;WAED,gCAAuB;AACrB,WAAKC,mBAAL,CAAyBxD,eAAzB,EAA0C,KAAKuD,gBAA/C;AACD;;;WAED,mBAAU;AACR,WAAKE,SAAL,qCAEOtD,WAFP,yBAE+BA,WAF/B,yBAGOA,WAHP,yBAG+BA,WAH/B;AAMD;;;kDA1G+BuD,W","sourcesContent":["import { SessionChangedEvent } from '@pie-framework/pie-player-events';\nimport MultipleChoice from '@pie-element/multiple-choice';\nimport get from 'lodash/get';\nimport debug from 'debug';\nconst SESSION_CHANGED = SessionChangedEvent.TYPE;\nconst MC_TAG_NAME = 'ebsr-multiple-choice';\nconst log = debug('pie-elements:ebsr');\n\nclass EbsrMC extends MultipleChoice {}\n\nconst defineMultipleChoice = () => {\n if (!customElements.get(MC_TAG_NAME)) {\n customElements.define(MC_TAG_NAME, EbsrMC);\n }\n};\n\ndefineMultipleChoice();\n\nconst isNonEmptyArray = (a) => Array.isArray(a) && a.length > 0;\n\nexport const isSessionComplete = (session) => {\n const a = get(session, 'value.partA.value');\n const b = get(session, 'value.partB.value');\n\n return isNonEmptyArray(a) && isNonEmptyArray(b);\n};\n\nexport default class Ebsr extends HTMLElement {\n constructor() {\n super();\n this._model = {};\n this._session = {};\n }\n\n onSessionUpdated = (e) => {\n if (e.target === this) {\n return;\n }\n\n e.preventDefault();\n e.stopImmediatePropagation();\n\n const id = e.target.getAttribute('id');\n\n if (id) {\n const key = `part${id.toUpperCase()}`;\n\n if (e.update) {\n this._model[key] = e.update;\n }\n //TODO: accessing a private property here. The session event should contain the update in future to prevent this.\n this.dispatchSessionChanged(e.srcElement._session, key);\n }\n };\n\n set model(m) {\n this._model = m;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartModel(this.partA, 'partA');\n this.setPartModel(this.partB, 'partB');\n });\n }\n\n set session(s) {\n this._session = s;\n\n customElements.whenDefined(MC_TAG_NAME).then(() => {\n this.setPartSession(this.partA, 'partA');\n this.setPartSession(this.partB, 'partB');\n });\n }\n\n get session() {\n return this._session;\n }\n\n setPartModel(part, key) {\n if (this._model && this._model[key] && part) {\n const { mode } = this._model;\n\n part.model = {\n ...this._model[key],\n mode,\n keyMode: this._model[key].choicePrefix,\n };\n }\n }\n\n setPartSession(part, key) {\n if (this._session && this._model && part) {\n const { value } = this._session;\n part.session = value && value[key] ? value[key] : { id: key };\n }\n }\n\n dispatchSessionChanged(partSession, key) {\n this._session.value = {\n ...this._session.value,\n [key]: partSession,\n };\n\n log('[onSessionChanged] session: ', this._session);\n const complete = isSessionComplete(this._session);\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), complete)\n );\n }\n\n get partA() {\n return this.querySelector(`${MC_TAG_NAME}#a`);\n }\n\n get partB() {\n return this.querySelector(`${MC_TAG_NAME}#b`);\n }\n\n connectedCallback() {\n this._render();\n this.addEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n disconnectedCallback() {\n this.removeEventListener(SESSION_CHANGED, this.onSessionUpdated);\n }\n\n _render() {\n this.innerHTML = `\n <div>\n <${MC_TAG_NAME} id=\"a\"></${MC_TAG_NAME}>\n <${MC_TAG_NAME} id=\"b\"></${MC_TAG_NAME}>\n </div>\n `;\n }\n}\n"],"file":"index.js"}