@pie-element/ebsr 10.5.11-next.0 → 10.5.11-next.6

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.
@@ -2,7 +2,7 @@ exports.model = (id, element) => ({
2
2
  id,
3
3
  element,
4
4
  partA: {
5
- choiceMode: 'radio',
5
+ choiceMode: 'checkbox',
6
6
  choices: [
7
7
  {
8
8
  value: 'yellow',
@@ -24,7 +24,7 @@ exports.model = (id, element) => ({
24
24
  promptEnabled: true,
25
25
  },
26
26
  partB: {
27
- choiceMode: 'radio',
27
+ choiceMode: 'checkbox',
28
28
  choices: [
29
29
  {
30
30
  value: 'orange',
package/module/demo.js CHANGED
@@ -8,7 +8,7 @@ generate.model = (id, element) => ({
8
8
  id,
9
9
  element,
10
10
  partA: {
11
- choiceMode: 'radio',
11
+ choiceMode: 'checkbox',
12
12
  choices: [
13
13
  {
14
14
  value: 'yellow',
@@ -30,7 +30,7 @@ generate.model = (id, element) => ({
30
30
  promptEnabled: true,
31
31
  },
32
32
  partB: {
33
- choiceMode: 'radio',
33
+ choiceMode: 'checkbox',
34
34
  choices: [
35
35
  {
36
36
  value: 'orange',
package/module/element.js CHANGED
@@ -12276,7 +12276,7 @@ const inputStyles = {
12276
12276
  }
12277
12277
  };
12278
12278
  const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12279
- const {correctness, classes, checked, onChange, disabled, value, id} = props;
12279
+ const {correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef} = props;
12280
12280
  const key = k => correctness ? `${correctness}-${k}` : k;
12281
12281
  const resolved = {
12282
12282
  root: classes[key('root')],
@@ -12291,7 +12291,9 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12291
12291
  };
12292
12292
  return React$4.createElement(Checkbox, {
12293
12293
  id: id,
12294
+ inputRef: inputRef,
12294
12295
  'aria-checked': checked,
12296
+ onKeyDown: onKeyDown,
12295
12297
  focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
12296
12298
  disableRipple: true,
12297
12299
  ...miniProps,
@@ -12309,7 +12311,7 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12309
12311
  });
12310
12312
  });
12311
12313
  const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12312
- const {correctness, classes, checked, onChange, disabled, value, id, tagName} = props;
12314
+ const {correctness, classes, checked, onChange, disabled, value, id, tagName, inputRef} = props;
12313
12315
  const key = k => correctness ? `${correctness}-${k}` : k;
12314
12316
  const resolved = {
12315
12317
  root: classes[key('root')],
@@ -12324,6 +12326,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12324
12326
  };
12325
12327
  return React$4.createElement(Radio, {
12326
12328
  id: id,
12329
+ inputRef: inputRef,
12327
12330
  'aria-checked': checked,
12328
12331
  focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
12329
12332
  disableRipple: true,
@@ -12338,7 +12341,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12338
12341
  __self: undefined,
12339
12342
  __source: {
12340
12343
  fileName: _jsxFileName$3,
12341
- lineNumber: 165
12344
+ lineNumber: 167
12342
12345
  }
12343
12346
  });
12344
12347
  });
@@ -12357,6 +12360,7 @@ class ChoiceInput extends React$4.Component {
12357
12360
  value: PropTypes$3.string.isRequired,
12358
12361
  classes: PropTypes$3.object,
12359
12362
  className: PropTypes$3.string,
12363
+ tagName: PropTypes$3.string,
12360
12364
  hideTick: PropTypes$3.bool,
12361
12365
  isEvaluateMode: PropTypes$3.bool,
12362
12366
  choicesLayout: PropTypes$3.oneOf(['vertical', 'grid', 'horizontal']),
@@ -12372,6 +12376,7 @@ class ChoiceInput extends React$4.Component {
12372
12376
  }
12373
12377
  constructor(props) {
12374
12378
  super(props);
12379
+ ChoiceInput.prototype.__init.call(this);
12375
12380
  this.onToggleChoice = this.onToggleChoice.bind(this);
12376
12381
  this.choiceId = this.generateChoiceId();
12377
12382
  this.descId = `${this.choiceId}-desc`;
@@ -12382,6 +12387,28 @@ class ChoiceInput extends React$4.Component {
12382
12387
  generateChoiceId() {
12383
12388
  return 'choice-' + (Math.random() * 10000).toFixed();
12384
12389
  }
12390
+ __init() {
12391
+ this.handleKeyDown = event => {
12392
+ const {choiceMode} = this.props;
12393
+ if (choiceMode !== 'checkbox') return;
12394
+ const isArrowDown = event.key === 'ArrowDown';
12395
+ const isArrowUp = event.key === 'ArrowUp';
12396
+ if (!isArrowDown && !isArrowUp) return;
12397
+ event.preventDefault();
12398
+ const currentEl = document.getElementById(this.choiceId);
12399
+ if (!currentEl) return;
12400
+ const fieldset = currentEl.closest('fieldset');
12401
+ if (!fieldset) return;
12402
+ const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
12403
+ const currentIndex = groupCheckboxes.findIndex(el => el === currentEl);
12404
+ if (currentIndex === -1) return;
12405
+ const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
12406
+ const nextEl = groupCheckboxes[nextIndex];
12407
+ if (nextEl) {
12408
+ nextEl.focus();
12409
+ }
12410
+ };
12411
+ }
12385
12412
  render() {
12386
12413
  const {choiceMode, disabled, displayKey, feedback, label, correctness, classes, className, rationale, hideTick, isEvaluateMode, choicesLayout, value, checked, tagName, isSelectionButtonBelow} = this.props;
12387
12414
  const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
@@ -12396,7 +12423,7 @@ class ChoiceInput extends React$4.Component {
12396
12423
  __self: this,
12397
12424
  __source: {
12398
12425
  fileName: _jsxFileName$3,
12399
- lineNumber: 255
12426
+ lineNumber: 290
12400
12427
  }
12401
12428
  }, displayKey, ".", '\u00A0', React$4.createElement(PreviewPrompt$1, {
12402
12429
  className: "label",
@@ -12405,7 +12432,7 @@ class ChoiceInput extends React$4.Component {
12405
12432
  __self: this,
12406
12433
  __source: {
12407
12434
  fileName: _jsxFileName$3,
12408
- lineNumber: 257
12435
+ lineNumber: 292
12409
12436
  }
12410
12437
  })) : React$4.createElement(PreviewPrompt$1, {
12411
12438
  className: "label",
@@ -12414,7 +12441,7 @@ class ChoiceInput extends React$4.Component {
12414
12441
  __self: this,
12415
12442
  __source: {
12416
12443
  fileName: _jsxFileName$3,
12417
- lineNumber: 260
12444
+ lineNumber: 295
12418
12445
  }
12419
12446
  }));
12420
12447
  const screenReaderLabel = React$4.createElement('span', {
@@ -12423,7 +12450,7 @@ class ChoiceInput extends React$4.Component {
12423
12450
  __self: this,
12424
12451
  __source: {
12425
12452
  fileName: _jsxFileName$3,
12426
- lineNumber: 266
12453
+ lineNumber: 301
12427
12454
  }
12428
12455
  }, choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below');
12429
12456
  const tagProps = {
@@ -12434,6 +12461,7 @@ class ChoiceInput extends React$4.Component {
12434
12461
  value,
12435
12462
  id: this.choiceId,
12436
12463
  onChange: this.onToggleChoice,
12464
+ onKeyDown: this.handleKeyDown,
12437
12465
  'aria-describedby': this.descId
12438
12466
  };
12439
12467
  const hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
@@ -12442,7 +12470,7 @@ class ChoiceInput extends React$4.Component {
12442
12470
  __self: this,
12443
12471
  __source: {
12444
12472
  fileName: _jsxFileName$3,
12445
- lineNumber: 293
12473
+ lineNumber: 329
12446
12474
  }
12447
12475
  }, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
12448
12476
  ...tagProps,
@@ -12452,14 +12480,15 @@ class ChoiceInput extends React$4.Component {
12452
12480
  __self: this,
12453
12481
  __source: {
12454
12482
  fileName: _jsxFileName$3,
12455
- lineNumber: 295
12483
+ lineNumber: 331
12456
12484
  }
12457
12485
  }), displayKey ? `${displayKey}.` : '') : React$4.createElement(React$4.Fragment, null, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
12458
12486
  ...tagProps,
12487
+ inputRef: this.props.autoFocusRef,
12459
12488
  __self: this,
12460
12489
  __source: {
12461
12490
  fileName: _jsxFileName$3,
12462
- lineNumber: 301
12491
+ lineNumber: 337
12463
12492
  }
12464
12493
  }));
12465
12494
  return React$4.createElement('div', {
@@ -12467,28 +12496,28 @@ class ChoiceInput extends React$4.Component {
12467
12496
  __self: this,
12468
12497
  __source: {
12469
12498
  fileName: _jsxFileName$3,
12470
- lineNumber: 306
12499
+ lineNumber: 342
12471
12500
  }
12472
12501
  }, React$4.createElement('div', {
12473
12502
  className: classes.row,
12474
12503
  __self: this,
12475
12504
  __source: {
12476
12505
  fileName: _jsxFileName$3,
12477
- lineNumber: 307
12506
+ lineNumber: 343
12478
12507
  }
12479
12508
  }, !hideTick && isEvaluateMode && React$4.createElement(FeedbackTick$1, {
12480
12509
  correctness: correctness,
12481
12510
  __self: this,
12482
12511
  __source: {
12483
12512
  fileName: _jsxFileName$3,
12484
- lineNumber: 308
12513
+ lineNumber: 344
12485
12514
  }
12486
12515
  }), React$4.createElement('div', {
12487
12516
  className: classNames$2(holderClassNames, 'checkbox-holder'),
12488
12517
  __self: this,
12489
12518
  __source: {
12490
12519
  fileName: _jsxFileName$3,
12491
- lineNumber: 309
12520
+ lineNumber: 345
12492
12521
  }
12493
12522
  }, React$4.createElement(StyledFormControlLabel, {
12494
12523
  label: choicelabel,
@@ -12499,7 +12528,7 @@ class ChoiceInput extends React$4.Component {
12499
12528
  __self: this,
12500
12529
  __source: {
12501
12530
  fileName: _jsxFileName$3,
12502
- lineNumber: 310
12531
+ lineNumber: 346
12503
12532
  }
12504
12533
  }))), rationale && React$4.createElement(PreviewPrompt$1, {
12505
12534
  className: "rationale",
@@ -12508,7 +12537,7 @@ class ChoiceInput extends React$4.Component {
12508
12537
  __self: this,
12509
12538
  __source: {
12510
12539
  fileName: _jsxFileName$3,
12511
- lineNumber: 319
12540
+ lineNumber: 355
12512
12541
  }
12513
12542
  }), React$4.createElement(Feedback, {
12514
12543
  feedback: feedback,
@@ -12516,7 +12545,7 @@ class ChoiceInput extends React$4.Component {
12516
12545
  __self: this,
12517
12546
  __source: {
12518
12547
  fileName: _jsxFileName$3,
12519
- lineNumber: 320
12548
+ lineNumber: 356
12520
12549
  }
12521
12550
  }));
12522
12551
  }
@@ -12545,7 +12574,7 @@ class Choice extends React$3.Component {
12545
12574
  };
12546
12575
  }
12547
12576
  render() {
12548
- const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, tagName} = this.props;
12577
+ const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, autoFocusRef, tagName} = this.props;
12549
12578
  const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
12550
12579
  const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
12551
12580
  const choiceProps = {
@@ -12578,15 +12607,16 @@ class Choice extends React$3.Component {
12578
12607
  __self: this,
12579
12608
  __source: {
12580
12609
  fileName: _jsxFileName$2,
12581
- lineNumber: 67
12610
+ lineNumber: 68
12582
12611
  }
12583
12612
  }, React$3.createElement(ChoiceInput$1, {
12584
12613
  ...choiceProps,
12585
12614
  className: names,
12615
+ autoFocusRef: autoFocusRef,
12586
12616
  __self: this,
12587
12617
  __source: {
12588
12618
  fileName: _jsxFileName$2,
12589
- lineNumber: 68
12619
+ lineNumber: 69
12590
12620
  }
12591
12621
  }));
12592
12622
  }
@@ -12609,7 +12639,8 @@ Choice.propTypes = {
12609
12639
  gridColumns: PropTypes$2.string,
12610
12640
  selectedAnswerBackgroundColor: PropTypes$2.string,
12611
12641
  tagName: PropTypes$2.string,
12612
- isSelectionButtonBelow: PropTypes$2.bool
12642
+ isSelectionButtonBelow: PropTypes$2.bool,
12643
+ autoFocusRef: PropTypes$2.object
12613
12644
  };
12614
12645
  var StyledChoice = styles$b.withStyles(theme => ({
12615
12646
  choice: {
@@ -12637,6 +12668,27 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
12637
12668
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12638
12669
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
12639
12670
  const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
12671
+ function _optionalChain$2(ops) {
12672
+ let lastAccessLHS = undefined;
12673
+ let value = ops[0];
12674
+ let i = 1;
12675
+ while (i < ops.length) {
12676
+ const op = ops[i];
12677
+ const fn = ops[i + 1];
12678
+ i += 2;
12679
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
12680
+ return undefined;
12681
+ }
12682
+ if (op === 'access' || op === 'optionalAccess') {
12683
+ lastAccessLHS = value;
12684
+ value = fn(value);
12685
+ } else if (op === 'call' || op === 'optionalCall') {
12686
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
12687
+ lastAccessLHS = undefined;
12688
+ }
12689
+ }
12690
+ return value;
12691
+ }
12640
12692
  const {translator} = Translator;
12641
12693
  const styles$1 = theme => ({
12642
12694
  main: {
@@ -12727,11 +12779,13 @@ class MultipleChoice$1 extends React$2.Component {
12727
12779
  MultipleChoice$1.prototype.__init.call(this);
12728
12780
  MultipleChoice$1.prototype.__init2.call(this);
12729
12781
  MultipleChoice$1.prototype.__init3.call(this);
12782
+ MultipleChoice$1.prototype.__init4.call(this);
12730
12783
  this.state = {
12731
12784
  showCorrect: this.props.alwaysShowCorrect || false,
12732
12785
  maxSelectionsErrorState: false
12733
12786
  };
12734
12787
  this.onToggle = this.onToggle.bind(this);
12788
+ this.firstInputRef = React$2.createRef();
12735
12789
  }
12736
12790
  isSelected(value) {
12737
12791
  const sessionValue = this.props.session && this.props.session.value;
@@ -12836,17 +12890,29 @@ class MultipleChoice$1 extends React$2.Component {
12836
12890
  __self: this,
12837
12891
  __source: {
12838
12892
  fileName: _jsxFileName$1,
12839
- lineNumber: 219
12893
+ lineNumber: 220
12840
12894
  }
12841
12895
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12842
12896
  className: classes.srOnly,
12843
12897
  __self: this,
12844
12898
  __source: {
12845
12899
  fileName: _jsxFileName$1,
12846
- lineNumber: 221
12900
+ lineNumber: 222
12847
12901
  }
12848
12902
  }, "Multiple Select Question");
12849
12903
  }
12904
+ __init4() {
12905
+ this.handleGroupFocus = e => {
12906
+ const fieldset = e.currentTarget;
12907
+ const activeEl = document.activeElement;
12908
+ if (fieldset.contains(activeEl) && activeEl !== fieldset) {
12909
+ return;
12910
+ }
12911
+ if (_optionalChain$2([this, 'access', _3 => _3.firstInputRef, 'optionalAccess', _4 => _4.current])) {
12912
+ this.firstInputRef.current.focus();
12913
+ }
12914
+ };
12915
+ }
12850
12916
  render() {
12851
12917
  const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
12852
12918
  const {showCorrect, maxSelectionsErrorState} = this.state;
@@ -12864,7 +12930,7 @@ class MultipleChoice$1 extends React$2.Component {
12864
12930
  __self: this,
12865
12931
  __source: {
12866
12932
  fileName: _jsxFileName$1,
12867
- lineNumber: 255
12933
+ lineNumber: 269
12868
12934
  }
12869
12935
  });
12870
12936
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12892,21 +12958,21 @@ class MultipleChoice$1 extends React$2.Component {
12892
12958
  __self: this,
12893
12959
  __source: {
12894
12960
  fileName: _jsxFileName$1,
12895
- lineNumber: 278
12961
+ lineNumber: 296
12896
12962
  }
12897
12963
  }, partLabel && React$2.createElement('h3', {
12898
12964
  className: classes.partLabel,
12899
12965
  __self: this,
12900
12966
  __source: {
12901
12967
  fileName: _jsxFileName$1,
12902
- lineNumber: 279
12968
+ lineNumber: 297
12903
12969
  }
12904
12970
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12905
12971
  className: classes.teacherInstructions,
12906
12972
  __self: this,
12907
12973
  __source: {
12908
12974
  fileName: _jsxFileName$1,
12909
- lineNumber: 284
12975
+ lineNumber: 302
12910
12976
  }
12911
12977
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12912
12978
  labels: {
@@ -12916,16 +12982,17 @@ class MultipleChoice$1 extends React$2.Component {
12916
12982
  __self: this,
12917
12983
  __source: {
12918
12984
  fileName: _jsxFileName$1,
12919
- lineNumber: 286
12985
+ lineNumber: 304
12920
12986
  }
12921
12987
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12922
12988
  tabIndex: 0,
12923
12989
  className: classes.fieldset,
12990
+ onFocus: this.handleGroupFocus,
12924
12991
  role: choiceMode === 'radio' ? 'radiogroup' : 'group',
12925
12992
  __self: this,
12926
12993
  __source: {
12927
12994
  fileName: _jsxFileName$1,
12928
- lineNumber: 300
12995
+ lineNumber: 318
12929
12996
  }
12930
12997
  }, React$2.createElement(PreviewPrompt, {
12931
12998
  className: "prompt",
@@ -12937,7 +13004,7 @@ class MultipleChoice$1 extends React$2.Component {
12937
13004
  __self: this,
12938
13005
  __source: {
12939
13006
  fileName: _jsxFileName$1,
12940
- lineNumber: 301
13007
+ lineNumber: 324
12941
13008
  }
12942
13009
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12943
13010
  show: showCorrectAnswerToggle,
@@ -12947,7 +13014,7 @@ class MultipleChoice$1 extends React$2.Component {
12947
13014
  __self: this,
12948
13015
  __source: {
12949
13016
  fileName: _jsxFileName$1,
12950
- lineNumber: 311
13017
+ lineNumber: 334
12951
13018
  }
12952
13019
  }), React$2.createElement('div', {
12953
13020
  className: classNames({
@@ -12958,9 +13025,10 @@ class MultipleChoice$1 extends React$2.Component {
12958
13025
  __self: this,
12959
13026
  __source: {
12960
13027
  fileName: _jsxFileName$1,
12961
- lineNumber: 319
13028
+ lineNumber: 342
12962
13029
  }
12963
13030
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
13031
+ autoFocusRef: index === 0 ? this.firstInputRef : null,
12964
13032
  choicesLayout: this.props.choicesLayout,
12965
13033
  selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
12966
13034
  gridColumns: gridColumns,
@@ -12982,21 +13050,21 @@ class MultipleChoice$1 extends React$2.Component {
12982
13050
  __self: this,
12983
13051
  __source: {
12984
13052
  fileName: _jsxFileName$1,
12985
- lineNumber: 327
13053
+ lineNumber: 350
12986
13054
  }
12987
13055
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12988
13056
  className: classes.errorText,
12989
13057
  __self: this,
12990
13058
  __source: {
12991
13059
  fileName: _jsxFileName$1,
12992
- lineNumber: 352
13060
+ lineNumber: 376
12993
13061
  }
12994
13062
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12995
13063
  className: classes.errorText,
12996
13064
  __self: this,
12997
13065
  __source: {
12998
13066
  fileName: _jsxFileName$1,
12999
- lineNumber: 357
13067
+ lineNumber: 379
13000
13068
  }
13001
13069
  }, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
13002
13070
  lng: language,
@@ -6,7 +6,7 @@ generate.model = (id, element) => ({
6
6
  id,
7
7
  element,
8
8
  partA: {
9
- choiceMode: 'radio',
9
+ choiceMode: 'checkbox',
10
10
  choices: [
11
11
  {
12
12
  value: 'yellow',
@@ -28,7 +28,7 @@ generate.model = (id, element) => ({
28
28
  promptEnabled: true,
29
29
  },
30
30
  partB: {
31
- choiceMode: 'radio',
31
+ choiceMode: 'checkbox',
32
32
  choices: [
33
33
  {
34
34
  value: 'orange',
package/module/print.js CHANGED
@@ -12239,7 +12239,7 @@ const inputStyles = {
12239
12239
  }
12240
12240
  };
12241
12241
  const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12242
- const {correctness, classes, checked, onChange, disabled, value, id} = props;
12242
+ const {correctness, classes, checked, onChange, disabled, value, id, onKeyDown, inputRef} = props;
12243
12243
  const key = k => correctness ? `${correctness}-${k}` : k;
12244
12244
  const resolved = {
12245
12245
  root: classes[key('root')],
@@ -12254,7 +12254,9 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12254
12254
  };
12255
12255
  return React$4.createElement(Checkbox, {
12256
12256
  id: id,
12257
+ inputRef: inputRef,
12257
12258
  'aria-checked': checked,
12259
+ onKeyDown: onKeyDown,
12258
12260
  focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
12259
12261
  disableRipple: true,
12260
12262
  ...miniProps,
@@ -12272,7 +12274,7 @@ const StyledCheckbox = styles$b.withStyles(inputStyles)(props => {
12272
12274
  });
12273
12275
  });
12274
12276
  const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12275
- const {correctness, classes, checked, onChange, disabled, value, id, tagName} = props;
12277
+ const {correctness, classes, checked, onChange, disabled, value, id, tagName, inputRef} = props;
12276
12278
  const key = k => correctness ? `${correctness}-${k}` : k;
12277
12279
  const resolved = {
12278
12280
  root: classes[key('root')],
@@ -12287,6 +12289,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12287
12289
  };
12288
12290
  return React$4.createElement(Radio, {
12289
12291
  id: id,
12292
+ inputRef: inputRef,
12290
12293
  'aria-checked': checked,
12291
12294
  focusVisibleClassName: checked ? classes.focusVisibleChecked : classes.focusVisibleUnchecked,
12292
12295
  disableRipple: true,
@@ -12301,7 +12304,7 @@ const StyledRadio = styles$b.withStyles(inputStyles)(props => {
12301
12304
  __self: undefined,
12302
12305
  __source: {
12303
12306
  fileName: _jsxFileName$3,
12304
- lineNumber: 165
12307
+ lineNumber: 167
12305
12308
  }
12306
12309
  });
12307
12310
  });
@@ -12320,6 +12323,7 @@ class ChoiceInput extends React$4.Component {
12320
12323
  value: PropTypes$3.string.isRequired,
12321
12324
  classes: PropTypes$3.object,
12322
12325
  className: PropTypes$3.string,
12326
+ tagName: PropTypes$3.string,
12323
12327
  hideTick: PropTypes$3.bool,
12324
12328
  isEvaluateMode: PropTypes$3.bool,
12325
12329
  choicesLayout: PropTypes$3.oneOf(['vertical', 'grid', 'horizontal']),
@@ -12335,6 +12339,7 @@ class ChoiceInput extends React$4.Component {
12335
12339
  }
12336
12340
  constructor(props) {
12337
12341
  super(props);
12342
+ ChoiceInput.prototype.__init.call(this);
12338
12343
  this.onToggleChoice = this.onToggleChoice.bind(this);
12339
12344
  this.choiceId = this.generateChoiceId();
12340
12345
  this.descId = `${this.choiceId}-desc`;
@@ -12345,6 +12350,28 @@ class ChoiceInput extends React$4.Component {
12345
12350
  generateChoiceId() {
12346
12351
  return 'choice-' + (Math.random() * 10000).toFixed();
12347
12352
  }
12353
+ __init() {
12354
+ this.handleKeyDown = event => {
12355
+ const {choiceMode} = this.props;
12356
+ if (choiceMode !== 'checkbox') return;
12357
+ const isArrowDown = event.key === 'ArrowDown';
12358
+ const isArrowUp = event.key === 'ArrowUp';
12359
+ if (!isArrowDown && !isArrowUp) return;
12360
+ event.preventDefault();
12361
+ const currentEl = document.getElementById(this.choiceId);
12362
+ if (!currentEl) return;
12363
+ const fieldset = currentEl.closest('fieldset');
12364
+ if (!fieldset) return;
12365
+ const groupCheckboxes = Array.from(fieldset.querySelectorAll('input[type="checkbox"]'));
12366
+ const currentIndex = groupCheckboxes.findIndex(el => el === currentEl);
12367
+ if (currentIndex === -1) return;
12368
+ const nextIndex = isArrowDown ? currentIndex + 1 : currentIndex - 1;
12369
+ const nextEl = groupCheckboxes[nextIndex];
12370
+ if (nextEl) {
12371
+ nextEl.focus();
12372
+ }
12373
+ };
12374
+ }
12348
12375
  render() {
12349
12376
  const {choiceMode, disabled, displayKey, feedback, label, correctness, classes, className, rationale, hideTick, isEvaluateMode, choicesLayout, value, checked, tagName, isSelectionButtonBelow} = this.props;
12350
12377
  const Tag = choiceMode === 'checkbox' ? StyledCheckbox : StyledRadio;
@@ -12359,7 +12386,7 @@ class ChoiceInput extends React$4.Component {
12359
12386
  __self: this,
12360
12387
  __source: {
12361
12388
  fileName: _jsxFileName$3,
12362
- lineNumber: 255
12389
+ lineNumber: 290
12363
12390
  }
12364
12391
  }, displayKey, ".", '\u00A0', React$4.createElement(PreviewPrompt$1, {
12365
12392
  className: "label",
@@ -12368,7 +12395,7 @@ class ChoiceInput extends React$4.Component {
12368
12395
  __self: this,
12369
12396
  __source: {
12370
12397
  fileName: _jsxFileName$3,
12371
- lineNumber: 257
12398
+ lineNumber: 292
12372
12399
  }
12373
12400
  })) : React$4.createElement(PreviewPrompt$1, {
12374
12401
  className: "label",
@@ -12377,7 +12404,7 @@ class ChoiceInput extends React$4.Component {
12377
12404
  __self: this,
12378
12405
  __source: {
12379
12406
  fileName: _jsxFileName$3,
12380
- lineNumber: 260
12407
+ lineNumber: 295
12381
12408
  }
12382
12409
  }));
12383
12410
  const screenReaderLabel = React$4.createElement('span', {
@@ -12386,7 +12413,7 @@ class ChoiceInput extends React$4.Component {
12386
12413
  __self: this,
12387
12414
  __source: {
12388
12415
  fileName: _jsxFileName$3,
12389
- lineNumber: 266
12416
+ lineNumber: 301
12390
12417
  }
12391
12418
  }, choiceMode === 'checkbox' ? 'Checkbox to select the answer below' : 'Radio button to select the answer below');
12392
12419
  const tagProps = {
@@ -12397,6 +12424,7 @@ class ChoiceInput extends React$4.Component {
12397
12424
  value,
12398
12425
  id: this.choiceId,
12399
12426
  onChange: this.onToggleChoice,
12427
+ onKeyDown: this.handleKeyDown,
12400
12428
  'aria-describedby': this.descId
12401
12429
  };
12402
12430
  const hasMathOrImage = typeof label === 'string' && (label.includes('<math') || label.includes('\\(') || label.includes('\\[') || label.includes('<img') || label.includes('data-latex') || label.includes('data-raw') || label.includes('<mjx-container'));
@@ -12405,7 +12433,7 @@ class ChoiceInput extends React$4.Component {
12405
12433
  __self: this,
12406
12434
  __source: {
12407
12435
  fileName: _jsxFileName$3,
12408
- lineNumber: 293
12436
+ lineNumber: 329
12409
12437
  }
12410
12438
  }, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
12411
12439
  ...tagProps,
@@ -12415,14 +12443,15 @@ class ChoiceInput extends React$4.Component {
12415
12443
  __self: this,
12416
12444
  __source: {
12417
12445
  fileName: _jsxFileName$3,
12418
- lineNumber: 295
12446
+ lineNumber: 331
12419
12447
  }
12420
12448
  }), displayKey ? `${displayKey}.` : '') : React$4.createElement(React$4.Fragment, null, hasMathOrImage && screenReaderLabel, React$4.createElement(Tag, {
12421
12449
  ...tagProps,
12450
+ inputRef: this.props.autoFocusRef,
12422
12451
  __self: this,
12423
12452
  __source: {
12424
12453
  fileName: _jsxFileName$3,
12425
- lineNumber: 301
12454
+ lineNumber: 337
12426
12455
  }
12427
12456
  }));
12428
12457
  return React$4.createElement('div', {
@@ -12430,28 +12459,28 @@ class ChoiceInput extends React$4.Component {
12430
12459
  __self: this,
12431
12460
  __source: {
12432
12461
  fileName: _jsxFileName$3,
12433
- lineNumber: 306
12462
+ lineNumber: 342
12434
12463
  }
12435
12464
  }, React$4.createElement('div', {
12436
12465
  className: classes.row,
12437
12466
  __self: this,
12438
12467
  __source: {
12439
12468
  fileName: _jsxFileName$3,
12440
- lineNumber: 307
12469
+ lineNumber: 343
12441
12470
  }
12442
12471
  }, !hideTick && isEvaluateMode && React$4.createElement(FeedbackTick$1, {
12443
12472
  correctness: correctness,
12444
12473
  __self: this,
12445
12474
  __source: {
12446
12475
  fileName: _jsxFileName$3,
12447
- lineNumber: 308
12476
+ lineNumber: 344
12448
12477
  }
12449
12478
  }), React$4.createElement('div', {
12450
12479
  className: classNames$2(holderClassNames, 'checkbox-holder'),
12451
12480
  __self: this,
12452
12481
  __source: {
12453
12482
  fileName: _jsxFileName$3,
12454
- lineNumber: 309
12483
+ lineNumber: 345
12455
12484
  }
12456
12485
  }, React$4.createElement(StyledFormControlLabel, {
12457
12486
  label: choicelabel,
@@ -12462,7 +12491,7 @@ class ChoiceInput extends React$4.Component {
12462
12491
  __self: this,
12463
12492
  __source: {
12464
12493
  fileName: _jsxFileName$3,
12465
- lineNumber: 310
12494
+ lineNumber: 346
12466
12495
  }
12467
12496
  }))), rationale && React$4.createElement(PreviewPrompt$1, {
12468
12497
  className: "rationale",
@@ -12471,7 +12500,7 @@ class ChoiceInput extends React$4.Component {
12471
12500
  __self: this,
12472
12501
  __source: {
12473
12502
  fileName: _jsxFileName$3,
12474
- lineNumber: 319
12503
+ lineNumber: 355
12475
12504
  }
12476
12505
  }), React$4.createElement(Feedback, {
12477
12506
  feedback: feedback,
@@ -12479,7 +12508,7 @@ class ChoiceInput extends React$4.Component {
12479
12508
  __self: this,
12480
12509
  __source: {
12481
12510
  fileName: _jsxFileName$3,
12482
- lineNumber: 320
12511
+ lineNumber: 356
12483
12512
  }
12484
12513
  }));
12485
12514
  }
@@ -12508,7 +12537,7 @@ class Choice extends React$3.Component {
12508
12537
  };
12509
12538
  }
12510
12539
  render() {
12511
- const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, tagName} = this.props;
12540
+ const {choice, index, choicesLength, showCorrect, isEvaluateMode, choiceMode, disabled, checked, correctness, displayKey, classes, choicesLayout, gridColumns, isSelectionButtonBelow, selectedAnswerBackgroundColor, autoFocusRef, tagName} = this.props;
12512
12541
  const choiceClass = 'choice' + (index === choicesLength - 1 ? ' last' : '');
12513
12542
  const feedback = !isEvaluateMode || showCorrect ? '' : choice.feedback;
12514
12543
  const choiceProps = {
@@ -12541,15 +12570,16 @@ class Choice extends React$3.Component {
12541
12570
  __self: this,
12542
12571
  __source: {
12543
12572
  fileName: _jsxFileName$2,
12544
- lineNumber: 67
12573
+ lineNumber: 68
12545
12574
  }
12546
12575
  }, React$3.createElement(ChoiceInput$1, {
12547
12576
  ...choiceProps,
12548
12577
  className: names,
12578
+ autoFocusRef: autoFocusRef,
12549
12579
  __self: this,
12550
12580
  __source: {
12551
12581
  fileName: _jsxFileName$2,
12552
- lineNumber: 68
12582
+ lineNumber: 69
12553
12583
  }
12554
12584
  }));
12555
12585
  }
@@ -12572,7 +12602,8 @@ Choice.propTypes = {
12572
12602
  gridColumns: PropTypes$2.string,
12573
12603
  selectedAnswerBackgroundColor: PropTypes$2.string,
12574
12604
  tagName: PropTypes$2.string,
12575
- isSelectionButtonBelow: PropTypes$2.bool
12605
+ isSelectionButtonBelow: PropTypes$2.bool,
12606
+ autoFocusRef: PropTypes$2.object
12576
12607
  };
12577
12608
  var StyledChoice = styles$b.withStyles(theme => ({
12578
12609
  choice: {
@@ -12600,6 +12631,27 @@ const {color: color} = _dll_pie_lib__pie_toolbox_render_ui;
12600
12631
  const {Collapsible: Collapsible} = _dll_pie_lib__pie_toolbox_render_ui;
12601
12632
  const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__pie_toolbox_render_ui;
12602
12633
  const _jsxFileName$1 = "/home/circleci/repo/packages/multiple-choice/src/multiple-choice.jsx";
12634
+ function _optionalChain$1(ops) {
12635
+ let lastAccessLHS = undefined;
12636
+ let value = ops[0];
12637
+ let i = 1;
12638
+ while (i < ops.length) {
12639
+ const op = ops[i];
12640
+ const fn = ops[i + 1];
12641
+ i += 2;
12642
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
12643
+ return undefined;
12644
+ }
12645
+ if (op === 'access' || op === 'optionalAccess') {
12646
+ lastAccessLHS = value;
12647
+ value = fn(value);
12648
+ } else if (op === 'call' || op === 'optionalCall') {
12649
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
12650
+ lastAccessLHS = undefined;
12651
+ }
12652
+ }
12653
+ return value;
12654
+ }
12603
12655
  const {translator: translator$1} = Translator;
12604
12656
  const styles$1 = theme => ({
12605
12657
  main: {
@@ -12690,11 +12742,13 @@ class MultipleChoice$1 extends React$2.Component {
12690
12742
  MultipleChoice$1.prototype.__init.call(this);
12691
12743
  MultipleChoice$1.prototype.__init2.call(this);
12692
12744
  MultipleChoice$1.prototype.__init3.call(this);
12745
+ MultipleChoice$1.prototype.__init4.call(this);
12693
12746
  this.state = {
12694
12747
  showCorrect: this.props.alwaysShowCorrect || false,
12695
12748
  maxSelectionsErrorState: false
12696
12749
  };
12697
12750
  this.onToggle = this.onToggle.bind(this);
12751
+ this.firstInputRef = React$2.createRef();
12698
12752
  }
12699
12753
  isSelected(value) {
12700
12754
  const sessionValue = this.props.session && this.props.session.value;
@@ -12799,17 +12853,29 @@ class MultipleChoice$1 extends React$2.Component {
12799
12853
  __self: this,
12800
12854
  __source: {
12801
12855
  fileName: _jsxFileName$1,
12802
- lineNumber: 219
12856
+ lineNumber: 220
12803
12857
  }
12804
12858
  }, "Multiple Choice Question") : React$2.createElement('h2', {
12805
12859
  className: classes.srOnly,
12806
12860
  __self: this,
12807
12861
  __source: {
12808
12862
  fileName: _jsxFileName$1,
12809
- lineNumber: 221
12863
+ lineNumber: 222
12810
12864
  }
12811
12865
  }, "Multiple Select Question");
12812
12866
  }
12867
+ __init4() {
12868
+ this.handleGroupFocus = e => {
12869
+ const fieldset = e.currentTarget;
12870
+ const activeEl = document.activeElement;
12871
+ if (fieldset.contains(activeEl) && activeEl !== fieldset) {
12872
+ return;
12873
+ }
12874
+ if (_optionalChain$1([this, 'access', _3 => _3.firstInputRef, 'optionalAccess', _4 => _4.current])) {
12875
+ this.firstInputRef.current.focus();
12876
+ }
12877
+ };
12878
+ }
12813
12879
  render() {
12814
12880
  const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session, customAudioButton} = this.props;
12815
12881
  const {showCorrect, maxSelectionsErrorState} = this.state;
@@ -12827,7 +12893,7 @@ class MultipleChoice$1 extends React$2.Component {
12827
12893
  __self: this,
12828
12894
  __source: {
12829
12895
  fileName: _jsxFileName$1,
12830
- lineNumber: 255
12896
+ lineNumber: 269
12831
12897
  }
12832
12898
  });
12833
12899
  const getMultipleChoiceMinSelectionErrorMessage = () => {
@@ -12855,21 +12921,21 @@ class MultipleChoice$1 extends React$2.Component {
12855
12921
  __self: this,
12856
12922
  __source: {
12857
12923
  fileName: _jsxFileName$1,
12858
- lineNumber: 278
12924
+ lineNumber: 296
12859
12925
  }
12860
12926
  }, partLabel && React$2.createElement('h3', {
12861
12927
  className: classes.partLabel,
12862
12928
  __self: this,
12863
12929
  __source: {
12864
12930
  fileName: _jsxFileName$1,
12865
- lineNumber: 279
12931
+ lineNumber: 297
12866
12932
  }
12867
12933
  }, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
12868
12934
  className: classes.teacherInstructions,
12869
12935
  __self: this,
12870
12936
  __source: {
12871
12937
  fileName: _jsxFileName$1,
12872
- lineNumber: 284
12938
+ lineNumber: 302
12873
12939
  }
12874
12940
  }, !animationsDisabled ? React$2.createElement(Collapsible, {
12875
12941
  labels: {
@@ -12879,16 +12945,17 @@ class MultipleChoice$1 extends React$2.Component {
12879
12945
  __self: this,
12880
12946
  __source: {
12881
12947
  fileName: _jsxFileName$1,
12882
- lineNumber: 286
12948
+ lineNumber: 304
12883
12949
  }
12884
12950
  }, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
12885
12951
  tabIndex: 0,
12886
12952
  className: classes.fieldset,
12953
+ onFocus: this.handleGroupFocus,
12887
12954
  role: choiceMode === 'radio' ? 'radiogroup' : 'group',
12888
12955
  __self: this,
12889
12956
  __source: {
12890
12957
  fileName: _jsxFileName$1,
12891
- lineNumber: 300
12958
+ lineNumber: 318
12892
12959
  }
12893
12960
  }, React$2.createElement(PreviewPrompt, {
12894
12961
  className: "prompt",
@@ -12900,7 +12967,7 @@ class MultipleChoice$1 extends React$2.Component {
12900
12967
  __self: this,
12901
12968
  __source: {
12902
12969
  fileName: _jsxFileName$1,
12903
- lineNumber: 301
12970
+ lineNumber: 324
12904
12971
  }
12905
12972
  }), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
12906
12973
  show: showCorrectAnswerToggle,
@@ -12910,7 +12977,7 @@ class MultipleChoice$1 extends React$2.Component {
12910
12977
  __self: this,
12911
12978
  __source: {
12912
12979
  fileName: _jsxFileName$1,
12913
- lineNumber: 311
12980
+ lineNumber: 334
12914
12981
  }
12915
12982
  }), React$2.createElement('div', {
12916
12983
  className: classNames({
@@ -12921,9 +12988,10 @@ class MultipleChoice$1 extends React$2.Component {
12921
12988
  __self: this,
12922
12989
  __source: {
12923
12990
  fileName: _jsxFileName$1,
12924
- lineNumber: 319
12991
+ lineNumber: 342
12925
12992
  }
12926
12993
  }, choices.map((choice, index) => React$2.createElement(StyledChoice, {
12994
+ autoFocusRef: index === 0 ? this.firstInputRef : null,
12927
12995
  choicesLayout: this.props.choicesLayout,
12928
12996
  selectedAnswerBackgroundColor: this.props.selectedAnswerBackgroundColor,
12929
12997
  gridColumns: gridColumns,
@@ -12945,21 +13013,21 @@ class MultipleChoice$1 extends React$2.Component {
12945
13013
  __self: this,
12946
13014
  __source: {
12947
13015
  fileName: _jsxFileName$1,
12948
- lineNumber: 327
13016
+ lineNumber: 350
12949
13017
  }
12950
13018
  })))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
12951
13019
  className: classes.errorText,
12952
13020
  __self: this,
12953
13021
  __source: {
12954
13022
  fileName: _jsxFileName$1,
12955
- lineNumber: 352
13023
+ lineNumber: 376
12956
13024
  }
12957
13025
  }, getMultipleChoiceMinSelectionErrorMessage()), choiceMode === 'checkbox' && maxSelectionsErrorState && React$2.createElement('div', {
12958
13026
  className: classes.errorText,
12959
13027
  __self: this,
12960
13028
  __source: {
12961
13029
  fileName: _jsxFileName$1,
12962
- lineNumber: 357
13030
+ lineNumber: 379
12963
13031
  }
12964
13032
  }, translator$1.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
12965
13033
  lng: language,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@pie-element/ebsr",
3
- "version": "10.5.11-next.0+0089bab2c",
3
+ "version": "10.5.11-next.6+1c7d8ad17",
4
4
  "description": "",
5
5
  "repository": "pie-framework/pie-elements",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "dependencies": {
10
- "@pie-element/multiple-choice": "^9.16.5-next.0+0089bab2c",
10
+ "@pie-element/multiple-choice": "^9.16.5-next.6+1c7d8ad17",
11
11
  "@pie-framework/pie-player-events": "^0.1.0",
12
12
  "@pie-lib/pie-toolbox": "2.19.0",
13
13
  "classnames": "^2.2.5",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "author": "pie framework developers",
18
18
  "license": "ISC",
19
- "gitHead": "0089bab2c797f699f5a03c2764fb94f20d9ecd90",
19
+ "gitHead": "1c7d8ad1742e80602e5d0901bfada9984e70588b",
20
20
  "scripts": {
21
21
  "postpublish": "../../scripts/postpublish"
22
22
  },