@khanacademy/wonder-blocks-form 4.2.2 → 4.3.0

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/checkbox-core.d.ts +13 -8
  3. package/dist/components/checkbox-core.js.flow +19 -10
  4. package/dist/components/checkbox-group.d.ts +2 -5
  5. package/dist/components/checkbox-group.js.flow +5 -6
  6. package/dist/components/checkbox.d.ts +33 -39
  7. package/dist/components/checkbox.js.flow +38 -41
  8. package/dist/components/choice-internal.d.ts +19 -31
  9. package/dist/components/choice-internal.js.flow +25 -32
  10. package/dist/components/choice.d.ts +50 -60
  11. package/dist/components/choice.js.flow +79 -84
  12. package/dist/components/radio-core.d.ts +13 -5
  13. package/dist/components/radio-core.js.flow +19 -7
  14. package/dist/components/radio-group.d.ts +2 -5
  15. package/dist/components/radio-group.js.flow +5 -6
  16. package/dist/components/radio.d.ts +18 -24
  17. package/dist/components/radio.js.flow +24 -27
  18. package/dist/es/index.js +262 -294
  19. package/dist/index.js +262 -294
  20. package/dist/util/types.d.ts +1 -1
  21. package/dist/util/types.js.flow +1 -1
  22. package/package.json +6 -6
  23. package/src/components/__tests__/{checkbox.test.js → checkbox.test.tsx} +55 -1
  24. package/src/components/checkbox-core.tsx +32 -31
  25. package/src/components/checkbox-group.tsx +33 -22
  26. package/src/components/checkbox.tsx +21 -16
  27. package/src/components/choice-internal.tsx +60 -58
  28. package/src/components/choice.tsx +39 -32
  29. package/src/components/radio-core.tsx +16 -14
  30. package/src/components/radio-group.tsx +14 -11
  31. package/src/components/radio.tsx +21 -16
  32. package/src/util/types.ts +1 -1
  33. package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.js CHANGED
@@ -91,61 +91,55 @@ const checkPath = {
91
91
  const indeterminatePath = {
92
92
  small: "M3 8C3 7.44772 3.44772 7 4 7H12C12.5523 7 13 7.44772 13 8C13 8.55228 12.5523 9 12 9H4C3.44772 9 3 8.55228 3 8Z"
93
93
  };
94
- class CheckboxCore extends React__namespace.Component {
95
- constructor(...args) {
96
- super(...args);
97
- this.inputRef = React__namespace.createRef();
98
- this.handleChange = () => {
99
- return;
100
- };
101
- }
102
- componentDidMount() {
103
- if (this.props.checked == null && this.inputRef.current != null) {
104
- this.inputRef.current.indeterminate = true;
105
- }
106
- }
107
- componentDidUpdate(prevProps) {
108
- if (this.inputRef.current != null) {
109
- this.inputRef.current.indeterminate = this.props.checked == null;
94
+ const CheckboxCore = React__namespace.forwardRef((props, ref) => {
95
+ const {
96
+ checked,
97
+ disabled,
98
+ error,
99
+ groupName,
100
+ id,
101
+ testId
102
+ } = props,
103
+ sharedProps = _objectWithoutPropertiesLoose(props, _excluded$4);
104
+ const innerRef = React__namespace.useRef(null);
105
+ React__namespace.useEffect(() => {
106
+ if (innerRef.current != null) {
107
+ innerRef.current.indeterminate = checked == null;
110
108
  }
111
- }
112
- render() {
113
- const _this$props = this.props,
114
- {
115
- checked,
116
- disabled,
117
- error,
118
- groupName,
119
- id,
120
- testId
121
- } = _this$props,
122
- sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$4);
123
- const stateStyles = _generateStyles$1(checked, error);
124
- const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, !disabled && stateStyles.default, disabled && sharedStyles$1.disabled];
125
- const props = {
126
- "data-test-id": testId
127
- };
128
- const checkboxIcon = React__namespace.createElement(Icon__default["default"], {
129
- color: disabled ? offBlack32$1 : white$1,
130
- icon: checked ? checkPath : indeterminatePath,
131
- size: "small",
132
- style: sharedStyles$1.checkboxIcon
133
- });
134
- const ariaChecked = mapCheckedToAriaChecked(checked);
135
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2, _extends({}, sharedProps, {
136
- ref: this.inputRef,
137
- type: "checkbox",
138
- "aria-checked": ariaChecked,
139
- "aria-invalid": error,
140
- checked: checked != null ? checked : undefined,
141
- disabled: disabled,
142
- id: id,
143
- name: groupName,
144
- onChange: this.handleChange,
145
- style: defaultStyle
146
- }, props)), checked || checked == null ? checkboxIcon : React__namespace.createElement(React__namespace.Fragment, null));
147
- }
148
- }
109
+ }, [checked, innerRef]);
110
+ const handleChange = () => {
111
+ return;
112
+ };
113
+ const stateStyles = _generateStyles$1(checked, error);
114
+ const defaultStyle = [sharedStyles$1.inputReset, sharedStyles$1.default, !disabled && stateStyles.default, disabled && sharedStyles$1.disabled];
115
+ const checkboxIcon = React__namespace.createElement(Icon__default["default"], {
116
+ color: disabled ? offBlack32$1 : white$1,
117
+ icon: checked ? checkPath : indeterminatePath,
118
+ size: "small",
119
+ style: sharedStyles$1.checkboxIcon
120
+ });
121
+ const ariaChecked = mapCheckedToAriaChecked(checked);
122
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$2, _extends({}, sharedProps, {
123
+ ref: node => {
124
+ innerRef.current = node;
125
+ if (typeof ref === "function") {
126
+ ref(node);
127
+ } else if (ref != null) {
128
+ ref.current = node;
129
+ }
130
+ },
131
+ type: "checkbox",
132
+ "aria-checked": ariaChecked,
133
+ "aria-invalid": error,
134
+ checked: checked != null ? checked : undefined,
135
+ disabled: disabled,
136
+ id: id,
137
+ name: groupName,
138
+ onChange: handleChange,
139
+ style: defaultStyle,
140
+ "data-test-id": testId
141
+ })), checked || checked == null ? checkboxIcon : React__namespace.createElement(React__namespace.Fragment, null));
142
+ });
149
143
  const size$1 = 16;
150
144
  const sharedStyles$1 = aphrodite.StyleSheet.create({
151
145
  inputReset: {
@@ -255,43 +249,36 @@ const {
255
249
  offBlack50
256
250
  } = Color__default["default"];
257
251
  const StyledInput$1 = wonderBlocksCore.addStyle("input");
258
- class RadioCore extends React__namespace.Component {
259
- constructor(...args) {
260
- super(...args);
261
- this.handleChange = () => {
262
- return;
263
- };
264
- }
265
- render() {
266
- const _this$props = this.props,
267
- {
268
- checked,
269
- disabled,
270
- error,
271
- groupName,
272
- id,
273
- testId
274
- } = _this$props,
275
- sharedProps = _objectWithoutPropertiesLoose(_this$props, _excluded$3);
276
- const stateStyles = _generateStyles(checked, error);
277
- const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
278
- const props = {
279
- "data-test-id": testId
280
- };
281
- return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends({}, sharedProps, {
282
- type: "radio",
283
- "aria-invalid": error,
284
- checked: checked != null ? checked : undefined,
285
- disabled: disabled,
286
- id: id,
287
- name: groupName,
288
- onChange: this.handleChange,
289
- style: defaultStyle
290
- }, props)), disabled && checked && React__namespace.createElement("span", {
291
- style: disabledChecked
292
- }));
293
- }
294
- }
252
+ const RadioCore = React__namespace.forwardRef((props, ref) => {
253
+ const handleChange = () => {
254
+ return;
255
+ };
256
+ const {
257
+ checked,
258
+ disabled,
259
+ error,
260
+ groupName,
261
+ id,
262
+ testId
263
+ } = props,
264
+ sharedProps = _objectWithoutPropertiesLoose(props, _excluded$3);
265
+ const stateStyles = _generateStyles(checked, error);
266
+ const defaultStyle = [sharedStyles.inputReset, sharedStyles.default, !disabled && stateStyles.default, disabled && sharedStyles.disabled];
267
+ return React__namespace.createElement(React__namespace.Fragment, null, React__namespace.createElement(StyledInput$1, _extends({}, sharedProps, {
268
+ type: "radio",
269
+ "aria-invalid": error,
270
+ checked: checked != null ? checked : undefined,
271
+ disabled: disabled,
272
+ id: id,
273
+ name: groupName,
274
+ onChange: handleChange,
275
+ style: defaultStyle,
276
+ "data-test-id": testId,
277
+ ref: ref
278
+ })), disabled && checked && React__namespace.createElement("span", {
279
+ style: disabledChecked
280
+ }));
281
+ });
295
282
  const size = 16;
296
283
  const disabledChecked = {
297
284
  position: "absolute",
@@ -396,86 +383,70 @@ const _generateStyles = (checked, error) => {
396
383
  return styles$4[styleKey];
397
384
  };
398
385
 
399
- const _excluded$2 = ["label", "description", "id", "onChange", "style", "className", "variant"];
400
- class ChoiceInternal extends React__namespace.Component {
401
- constructor(...args) {
402
- super(...args);
403
- this.handleClick = () => {
404
- const {
405
- checked,
406
- onChange,
407
- variant
408
- } = this.props;
409
- if (variant === "radio" && checked) {
410
- return;
411
- }
412
- onChange(!checked);
413
- };
414
- }
415
- getChoiceCoreComponent() {
416
- if (this.props.variant === "radio") {
386
+ const ChoiceInternal = React__namespace.forwardRef((props, ref) => {
387
+ const {
388
+ checked,
389
+ description,
390
+ disabled = false,
391
+ error = false,
392
+ id,
393
+ label,
394
+ onChange,
395
+ style,
396
+ className,
397
+ variant
398
+ } = props;
399
+ const handleClick = () => {
400
+ if (variant === "radio" && checked) {
401
+ return;
402
+ }
403
+ onChange(!checked);
404
+ };
405
+ const getChoiceCoreComponent = () => {
406
+ if (variant === "radio") {
417
407
  return RadioCore;
418
408
  } else {
419
409
  return CheckboxCore;
420
410
  }
421
- }
422
- getLabel(id) {
423
- const {
424
- disabled,
425
- label
426
- } = this.props;
411
+ };
412
+ const getLabel = id => {
427
413
  return React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
428
414
  style: [styles$3.label, disabled && styles$3.disabledLabel]
429
415
  }, React__namespace.createElement("label", {
430
416
  htmlFor: id
431
417
  }, label));
432
- }
433
- getDescription(id) {
434
- const {
435
- description
436
- } = this.props;
418
+ };
419
+ const getDescription = id => {
437
420
  return React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
438
421
  style: styles$3.description,
439
422
  id: id
440
423
  }, description);
441
- }
442
- render() {
443
- const _this$props = this.props,
444
- {
445
- label,
446
- description,
447
- id,
448
- style,
449
- className
450
- } = _this$props,
451
- coreProps = _objectWithoutPropertiesLoose(_this$props, _excluded$2);
452
- const ChoiceCore = this.getChoiceCoreComponent();
453
- return React__namespace.createElement(wonderBlocksCore.UniqueIDProvider, {
454
- mockOnFirstRender: true,
455
- scope: "choice"
456
- }, ids => {
457
- const uniqueId = id || ids.get("main");
458
- const descriptionId = description ? ids.get("description") : undefined;
459
- return React__namespace.createElement(wonderBlocksCore.View, {
460
- style: style,
461
- className: className
462
- }, React__namespace.createElement(wonderBlocksCore.View, {
463
- style: styles$3.wrapper,
464
- tabIndex: -1
465
- }, React__namespace.createElement(ChoiceCore, _extends({}, coreProps, {
466
- id: uniqueId,
467
- "aria-describedby": descriptionId,
468
- onClick: this.handleClick
469
- })), React__namespace.createElement(wonderBlocksLayout.Strut, {
470
- size: Spacing__default["default"].xSmall_8
471
- }), label && this.getLabel(uniqueId)), description && this.getDescription(descriptionId));
472
- });
473
- }
474
- }
475
- ChoiceInternal.defaultProps = {
476
- disabled: false,
477
- error: false
478
- };
424
+ };
425
+ const ChoiceCore = getChoiceCoreComponent();
426
+ return React__namespace.createElement(wonderBlocksCore.UniqueIDProvider, {
427
+ mockOnFirstRender: true,
428
+ scope: "choice"
429
+ }, ids => {
430
+ const uniqueId = id || ids.get("main");
431
+ const descriptionId = description ? ids.get("description") : undefined;
432
+ return React__namespace.createElement(wonderBlocksCore.View, {
433
+ style: style,
434
+ className: className
435
+ }, React__namespace.createElement(wonderBlocksCore.View, {
436
+ style: styles$3.wrapper,
437
+ tabIndex: -1
438
+ }, React__namespace.createElement(ChoiceCore, _extends({}, props, {
439
+ id: uniqueId,
440
+ "aria-describedby": descriptionId,
441
+ onClick: handleClick,
442
+ disabled: disabled,
443
+ error: error,
444
+ ref: ref
445
+ })), React__namespace.createElement(wonderBlocksLayout.Strut, {
446
+ size: Spacing__default["default"].xSmall_8
447
+ }), label && getLabel(uniqueId)), description && getDescription(descriptionId));
448
+ });
449
+ });
479
450
  const styles$3 = aphrodite.StyleSheet.create({
480
451
  wrapper: {
481
452
  flexDirection: "row",
@@ -495,54 +466,58 @@ const styles$3 = aphrodite.StyleSheet.create({
495
466
  }
496
467
  });
497
468
 
498
- class Checkbox extends React__namespace.Component {
499
- render() {
500
- return React__namespace.createElement(ChoiceInternal, _extends({
501
- variant: "checkbox"
502
- }, this.props));
503
- }
504
- }
505
- Checkbox.defaultProps = {
506
- disabled: false,
507
- error: false
508
- };
469
+ const Checkbox = React__namespace.forwardRef((props, ref) => {
470
+ const {
471
+ disabled = false,
472
+ error = false
473
+ } = props;
474
+ return React__namespace.createElement(ChoiceInternal, _extends({}, props, {
475
+ variant: "checkbox",
476
+ disabled: disabled,
477
+ error: error,
478
+ ref: ref
479
+ }));
480
+ });
509
481
 
510
- class Radio extends React__namespace.Component {
511
- render() {
512
- return React__namespace.createElement(ChoiceInternal, _extends({
513
- variant: "radio"
514
- }, this.props));
515
- }
516
- }
517
- Radio.defaultProps = {
518
- disabled: false,
519
- error: false
520
- };
482
+ const _excluded$2 = ["disabled", "error"];
483
+ const Radio = React__namespace.forwardRef((props, ref) => {
484
+ const {
485
+ disabled = false,
486
+ error = false
487
+ } = props,
488
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded$2);
489
+ return React__namespace.createElement(ChoiceInternal, _extends({}, otherProps, {
490
+ variant: "radio",
491
+ disabled: disabled,
492
+ error: error,
493
+ ref: ref
494
+ }));
495
+ });
521
496
 
522
- const _excluded$1 = ["value", "variant"];
523
- class Choice extends React__namespace.Component {
524
- getChoiceComponent(variant) {
497
+ const _excluded$1 = ["checked", "disabled", "onChange", "value", "variant"];
498
+ const Choice = React__namespace.forwardRef((props, ref) => {
499
+ const {
500
+ checked = false,
501
+ disabled = false,
502
+ onChange = () => {},
503
+ variant
504
+ } = props,
505
+ remainingProps = _objectWithoutPropertiesLoose(props, _excluded$1);
506
+ const getChoiceComponent = variant => {
525
507
  if (variant === "checkbox") {
526
508
  return Checkbox;
527
509
  } else {
528
510
  return Radio;
529
511
  }
530
- }
531
- render() {
532
- const _this$props = this.props,
533
- {
534
- variant
535
- } = _this$props,
536
- remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
537
- const ChoiceComponent = this.getChoiceComponent(variant);
538
- return React__namespace.createElement(ChoiceComponent, remainingProps);
539
- }
540
- }
541
- Choice.defaultProps = {
542
- checked: false,
543
- disabled: false,
544
- onChange: () => {}
545
- };
512
+ };
513
+ const ChoiceComponent = getChoiceComponent(variant);
514
+ return React__namespace.createElement(ChoiceComponent, _extends({}, remainingProps, {
515
+ checked: checked,
516
+ disabled: disabled,
517
+ onChange: onChange,
518
+ ref: ref
519
+ }));
520
+ });
546
521
 
547
522
  const styles$2 = aphrodite.StyleSheet.create({
548
523
  fieldset: {
@@ -568,12 +543,19 @@ const styles$2 = aphrodite.StyleSheet.create({
568
543
 
569
544
  const StyledFieldset$1 = wonderBlocksCore.addStyle("fieldset");
570
545
  const StyledLegend$1 = wonderBlocksCore.addStyle("legend");
571
- class CheckboxGroup extends React__namespace.Component {
572
- handleChange(changedValue, originalCheckedState) {
573
- const {
574
- onChange,
575
- selectedValues
576
- } = this.props;
546
+ const CheckboxGroup = React__namespace.forwardRef((props, ref) => {
547
+ const {
548
+ children,
549
+ label,
550
+ description,
551
+ errorMessage,
552
+ groupName,
553
+ onChange,
554
+ selectedValues,
555
+ style,
556
+ testId
557
+ } = props;
558
+ const handleChange = (changedValue, originalCheckedState) => {
577
559
  if (originalCheckedState) {
578
560
  const index = selectedValues.indexOf(changedValue);
579
561
  const updatedSelection = [...selectedValues.slice(0, index), ...selectedValues.slice(index + 1)];
@@ -581,102 +563,88 @@ class CheckboxGroup extends React__namespace.Component {
581
563
  } else {
582
564
  onChange([...selectedValues, changedValue]);
583
565
  }
584
- }
585
- render() {
566
+ };
567
+ const allChildren = React__namespace.Children.toArray(children).filter(Boolean);
568
+ return React__namespace.createElement(StyledFieldset$1, {
569
+ "data-test-id": testId,
570
+ style: styles$2.fieldset,
571
+ ref: ref
572
+ }, React__namespace.createElement(wonderBlocksCore.View, {
573
+ style: style
574
+ }, label && React__namespace.createElement(StyledLegend$1, {
575
+ style: styles$2.legend
576
+ }, React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, label)), description && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
577
+ style: styles$2.description
578
+ }, description), errorMessage && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
579
+ style: styles$2.error
580
+ }, errorMessage), (label || description || errorMessage) && React__namespace.createElement(wonderBlocksLayout.Strut, {
581
+ size: Spacing__default["default"].small_12
582
+ }), allChildren.map((child, index) => {
586
583
  const {
587
- children,
588
- label,
589
- description,
590
- errorMessage,
591
- groupName,
592
- selectedValues,
593
584
  style,
594
- testId
595
- } = this.props;
596
- const allChildren = React__namespace.Children.toArray(children).filter(Boolean);
597
- return React__namespace.createElement(StyledFieldset$1, {
598
- "data-test-id": testId,
599
- style: styles$2.fieldset
600
- }, React__namespace.createElement(wonderBlocksCore.View, {
601
- style: style
602
- }, label && React__namespace.createElement(StyledLegend$1, {
603
- style: styles$2.legend
604
- }, React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, label)), description && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
605
- style: styles$2.description
606
- }, description), errorMessage && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
607
- style: styles$2.error
608
- }, errorMessage), (label || description || errorMessage) && React__namespace.createElement(wonderBlocksLayout.Strut, {
609
- size: Spacing__default["default"].small_12
610
- }), allChildren.map((child, index) => {
611
- const {
612
- style,
613
- value
614
- } = child.props;
615
- const checked = selectedValues.includes(value);
616
- return React__namespace.cloneElement(child, {
617
- checked: checked,
618
- error: !!errorMessage,
619
- groupName: groupName,
620
- id: `${groupName}-${value}`,
621
- key: value,
622
- onChange: () => this.handleChange(value, checked),
623
- style: [index > 0 && styles$2.defaultLineGap, style],
624
- variant: "checkbox"
625
- });
626
- })));
627
- }
628
- }
585
+ value
586
+ } = child.props;
587
+ const checked = selectedValues.includes(value);
588
+ return React__namespace.cloneElement(child, {
589
+ checked: checked,
590
+ error: !!errorMessage,
591
+ groupName: groupName,
592
+ id: `${groupName}-${value}`,
593
+ key: value,
594
+ onChange: () => handleChange(value, checked),
595
+ style: [index > 0 && styles$2.defaultLineGap, style],
596
+ variant: "checkbox"
597
+ });
598
+ })));
599
+ });
629
600
 
630
601
  const StyledFieldset = wonderBlocksCore.addStyle("fieldset");
631
602
  const StyledLegend = wonderBlocksCore.addStyle("legend");
632
- class RadioGroup extends React__namespace.Component {
633
- handleChange(changedValue) {
634
- this.props.onChange(changedValue);
635
- }
636
- render() {
603
+ const RadioGroup = React__namespace.forwardRef((props, ref) => {
604
+ const {
605
+ children,
606
+ label,
607
+ description,
608
+ errorMessage,
609
+ groupName,
610
+ onChange,
611
+ selectedValue,
612
+ style,
613
+ testId
614
+ } = props;
615
+ const allChildren = React__namespace.Children.toArray(children).filter(Boolean);
616
+ return React__namespace.createElement(StyledFieldset, {
617
+ "data-test-id": testId,
618
+ style: styles$2.fieldset,
619
+ ref: ref
620
+ }, React__namespace.createElement(wonderBlocksCore.View, {
621
+ style: style
622
+ }, label && React__namespace.createElement(StyledLegend, {
623
+ style: styles$2.legend
624
+ }, React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, label)), description && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
625
+ style: styles$2.description
626
+ }, description), errorMessage && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
627
+ style: styles$2.error
628
+ }, errorMessage), (label || description || errorMessage) && React__namespace.createElement(wonderBlocksLayout.Strut, {
629
+ size: Spacing__default["default"].small_12
630
+ }), allChildren.map((child, index) => {
637
631
  const {
638
- children,
639
- label,
640
- description,
641
- errorMessage,
642
- groupName,
643
- selectedValue,
644
632
  style,
645
- testId
646
- } = this.props;
647
- const allChildren = React__namespace.Children.toArray(children).filter(Boolean);
648
- return React__namespace.createElement(StyledFieldset, {
649
- "data-test-id": testId,
650
- style: styles$2.fieldset
651
- }, React__namespace.createElement(wonderBlocksCore.View, {
652
- style: style
653
- }, label && React__namespace.createElement(StyledLegend, {
654
- style: styles$2.legend
655
- }, React__namespace.createElement(wonderBlocksTypography.LabelMedium, null, label)), description && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
656
- style: styles$2.description
657
- }, description), errorMessage && React__namespace.createElement(wonderBlocksTypography.LabelSmall, {
658
- style: styles$2.error
659
- }, errorMessage), (label || description || errorMessage) && React__namespace.createElement(wonderBlocksLayout.Strut, {
660
- size: Spacing__default["default"].small_12
661
- }), allChildren.map((child, index) => {
662
- const {
663
- style,
664
- value
665
- } = child.props;
666
- const checked = selectedValue === value;
667
- return React__namespace.cloneElement(child, {
668
- checked: checked,
669
- error: !!errorMessage,
670
- groupName: groupName,
671
- id: `${groupName}-${value}`,
672
- key: value,
673
- onChange: () => this.handleChange(value),
674
- style: [index > 0 && styles$2.defaultLineGap, style],
675
- variant: "radio"
676
- });
677
- })));
678
- }
679
- }
633
+ value
634
+ } = child.props;
635
+ const checked = selectedValue === value;
636
+ return React__namespace.cloneElement(child, {
637
+ checked: checked,
638
+ error: !!errorMessage,
639
+ groupName: groupName,
640
+ id: `${groupName}-${value}`,
641
+ key: value,
642
+ onChange: () => onChange(value),
643
+ style: [index > 0 && styles$2.defaultLineGap, style],
644
+ variant: "radio"
645
+ });
646
+ })));
647
+ });
680
648
 
681
649
  const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoFocus", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
682
650
  const defaultErrorMessage = "This field is required.";
@@ -34,7 +34,7 @@ export type ChoiceComponentProps = ChoiceCoreProps & {
34
34
  };
35
35
  export type SharedGroupProps = {
36
36
  /** Children should be Choice components. */
37
- children: Choice;
37
+ children: typeof Choice;
38
38
  /** Group name for this checkbox or radio group. Should be unique for all
39
39
  * such groups displayed on a page. */
40
40
  groupName: string;
@@ -82,7 +82,7 @@ export type SharedGroupProps = {|
82
82
  /**
83
83
  * Children should be Choice components.
84
84
  */
85
- children: Choice,
85
+ children: typeof Choice,
86
86
 
87
87
  /**
88
88
  * Group name for this checkbox or radio group. Should be unique for all