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

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