@khanacademy/wonder-blocks-form 4.0.5 → 4.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @khanacademy/wonder-blocks-form
2
2
 
3
+ ## 4.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - c20f48f3: Don't transpile classes when building bundles
8
+ - Updated dependencies [c20f48f3]
9
+ - @khanacademy/wonder-blocks-clickable@3.0.6
10
+ - @khanacademy/wonder-blocks-core@5.0.4
11
+ - @khanacademy/wonder-blocks-icon@2.0.6
12
+ - @khanacademy/wonder-blocks-layout@2.0.6
13
+ - @khanacademy/wonder-blocks-typography@2.0.6
14
+
3
15
  ## 4.0.5
4
16
 
5
17
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -23,20 +23,6 @@ function _extends() {
23
23
  return _extends.apply(this, arguments);
24
24
  }
25
25
 
26
- function _setPrototypeOf(o, p) {
27
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
28
- o.__proto__ = p;
29
- return o;
30
- };
31
- return _setPrototypeOf(o, p);
32
- }
33
-
34
- function _inheritsLoose(subClass, superClass) {
35
- subClass.prototype = Object.create(superClass.prototype);
36
- subClass.prototype.constructor = subClass;
37
- _setPrototypeOf(subClass, superClass);
38
- }
39
-
40
26
  function _objectWithoutPropertiesLoose(source, excluded) {
41
27
  if (source == null) return {};
42
28
  var target = {};
@@ -64,18 +50,14 @@ const StyledInput$1 = addStyle("input");
64
50
  const checkboxCheck = {
65
51
  small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z"
66
52
  };
67
- let CheckboxCore = function (_React$Component) {
68
- _inheritsLoose(CheckboxCore, _React$Component);
69
- function CheckboxCore(...args) {
70
- var _this;
71
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
72
- _this.handleChange = () => {
53
+ class CheckboxCore extends React.Component {
54
+ constructor(...args) {
55
+ super(...args);
56
+ this.handleChange = () => {
73
57
  return;
74
58
  };
75
- return _this;
76
59
  }
77
- var _proto = CheckboxCore.prototype;
78
- _proto.render = function render() {
60
+ render() {
79
61
  const _this$props = this.props,
80
62
  {
81
63
  checked,
@@ -109,9 +91,8 @@ let CheckboxCore = function (_React$Component) {
109
91
  size: "small",
110
92
  style: sharedStyles$1.checkIcon
111
93
  }));
112
- };
113
- return CheckboxCore;
114
- }(React.Component);
94
+ }
95
+ }
115
96
  const size$1 = 16;
116
97
  const sharedStyles$1 = StyleSheet.create({
117
98
  inputReset: {
@@ -213,18 +194,14 @@ const {
213
194
  offBlack50
214
195
  } = Color;
215
196
  const StyledInput = addStyle("input");
216
- let RadioCore = function (_React$Component) {
217
- _inheritsLoose(RadioCore, _React$Component);
218
- function RadioCore(...args) {
219
- var _this;
220
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
221
- _this.handleChange = () => {
197
+ class RadioCore extends React.Component {
198
+ constructor(...args) {
199
+ super(...args);
200
+ this.handleChange = () => {
222
201
  return;
223
202
  };
224
- return _this;
225
203
  }
226
- var _proto = RadioCore.prototype;
227
- _proto.render = function render() {
204
+ render() {
228
205
  const _this$props = this.props,
229
206
  {
230
207
  checked,
@@ -255,9 +232,8 @@ let RadioCore = function (_React$Component) {
255
232
  }, props)), disabled && checked && React.createElement("span", {
256
233
  style: disabledChecked
257
234
  }));
258
- };
259
- return RadioCore;
260
- }(React.Component);
235
+ }
236
+ }
261
237
  const size = 16;
262
238
  const disabledChecked = {
263
239
  position: "absolute",
@@ -355,36 +331,32 @@ const _generateStyles = (checked, error) => {
355
331
  };
356
332
 
357
333
  const _excluded$2 = ["label", "description", "onChange", "style", "className", "variant"];
358
- let ChoiceInternal = function (_React$Component) {
359
- _inheritsLoose(ChoiceInternal, _React$Component);
360
- function ChoiceInternal(...args) {
361
- var _this;
362
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
363
- _this.handleLabelClick = event => {
334
+ class ChoiceInternal extends React.Component {
335
+ constructor(...args) {
336
+ super(...args);
337
+ this.handleLabelClick = event => {
364
338
  event.preventDefault();
365
339
  };
366
- _this.handleClick = () => {
340
+ this.handleClick = () => {
367
341
  const {
368
342
  checked,
369
343
  onChange,
370
344
  variant
371
- } = _this.props;
345
+ } = this.props;
372
346
  if (variant === "radio" && checked) {
373
347
  return;
374
348
  }
375
349
  onChange(!checked);
376
350
  };
377
- return _this;
378
351
  }
379
- var _proto = ChoiceInternal.prototype;
380
- _proto.getChoiceCoreComponent = function getChoiceCoreComponent() {
352
+ getChoiceCoreComponent() {
381
353
  if (this.props.variant === "radio") {
382
354
  return RadioCore;
383
355
  } else {
384
356
  return CheckboxCore;
385
357
  }
386
- };
387
- _proto.getLabel = function getLabel() {
358
+ }
359
+ getLabel() {
388
360
  const {
389
361
  disabled,
390
362
  id,
@@ -396,8 +368,8 @@ let ChoiceInternal = function (_React$Component) {
396
368
  htmlFor: id,
397
369
  onClick: this.handleLabelClick
398
370
  }, label));
399
- };
400
- _proto.getDescription = function getDescription(id) {
371
+ }
372
+ getDescription(id) {
401
373
  const {
402
374
  description
403
375
  } = this.props;
@@ -405,8 +377,8 @@ let ChoiceInternal = function (_React$Component) {
405
377
  style: styles$3.description,
406
378
  id: id
407
379
  }, description);
408
- };
409
- _proto.render = function render() {
380
+ }
381
+ render() {
410
382
  const _this$props = this.props,
411
383
  {
412
384
  label,
@@ -442,9 +414,8 @@ let ChoiceInternal = function (_React$Component) {
442
414
  }), label && this.getLabel());
443
415
  }), description && this.getDescription(descriptionId));
444
416
  });
445
- };
446
- return ChoiceInternal;
447
- }(React.Component);
417
+ }
418
+ }
448
419
  ChoiceInternal.defaultProps = {
449
420
  checked: false,
450
421
  disabled: false,
@@ -470,57 +441,40 @@ const styles$3 = StyleSheet.create({
470
441
  }
471
442
  });
472
443
 
473
- let Checkbox = function (_React$Component) {
474
- _inheritsLoose(Checkbox, _React$Component);
475
- function Checkbox() {
476
- return _React$Component.apply(this, arguments) || this;
477
- }
478
- var _proto = Checkbox.prototype;
479
- _proto.render = function render() {
444
+ class Checkbox extends React.Component {
445
+ render() {
480
446
  return React.createElement(ChoiceInternal, _extends({
481
447
  variant: "checkbox"
482
448
  }, this.props));
483
- };
484
- return Checkbox;
485
- }(React.Component);
449
+ }
450
+ }
486
451
  Checkbox.defaultProps = {
487
452
  disabled: false,
488
453
  error: false
489
454
  };
490
455
 
491
- let Radio = function (_React$Component) {
492
- _inheritsLoose(Radio, _React$Component);
493
- function Radio() {
494
- return _React$Component.apply(this, arguments) || this;
495
- }
496
- var _proto = Radio.prototype;
497
- _proto.render = function render() {
456
+ class Radio extends React.Component {
457
+ render() {
498
458
  return React.createElement(ChoiceInternal, _extends({
499
459
  variant: "radio"
500
460
  }, this.props));
501
- };
502
- return Radio;
503
- }(React.Component);
461
+ }
462
+ }
504
463
  Radio.defaultProps = {
505
464
  disabled: false,
506
465
  error: false
507
466
  };
508
467
 
509
468
  const _excluded$1 = ["value", "variant"];
510
- let Choice = function (_React$Component) {
511
- _inheritsLoose(Choice, _React$Component);
512
- function Choice() {
513
- return _React$Component.apply(this, arguments) || this;
514
- }
515
- var _proto = Choice.prototype;
516
- _proto.getChoiceComponent = function getChoiceComponent(variant) {
469
+ class Choice extends React.Component {
470
+ getChoiceComponent(variant) {
517
471
  if (variant === "checkbox") {
518
472
  return Checkbox;
519
473
  } else {
520
474
  return Radio;
521
475
  }
522
- };
523
- _proto.render = function render() {
476
+ }
477
+ render() {
524
478
  const _this$props = this.props,
525
479
  {
526
480
  variant
@@ -528,9 +482,8 @@ let Choice = function (_React$Component) {
528
482
  remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
529
483
  const ChoiceComponent = this.getChoiceComponent(variant);
530
484
  return React.createElement(ChoiceComponent, remainingProps);
531
- };
532
- return Choice;
533
- }(React.Component);
485
+ }
486
+ }
534
487
  Choice.defaultProps = {
535
488
  checked: false,
536
489
  disabled: false,
@@ -561,26 +514,21 @@ const styles$2 = StyleSheet.create({
561
514
 
562
515
  const StyledFieldset$1 = addStyle("fieldset");
563
516
  const StyledLegend$1 = addStyle("legend");
564
- let CheckboxGroup = function (_React$Component) {
565
- _inheritsLoose(CheckboxGroup, _React$Component);
566
- function CheckboxGroup() {
567
- return _React$Component.apply(this, arguments) || this;
568
- }
569
- var _proto = CheckboxGroup.prototype;
570
- _proto.handleChange = function handleChange(changedValue, originalCheckedState) {
517
+ class CheckboxGroup extends React.Component {
518
+ handleChange(changedValue, originalCheckedState) {
571
519
  const {
572
520
  onChange,
573
521
  selectedValues
574
522
  } = this.props;
575
523
  if (originalCheckedState) {
576
524
  const index = selectedValues.indexOf(changedValue);
577
- const updatedSelection = [].concat(selectedValues.slice(0, index), selectedValues.slice(index + 1));
525
+ const updatedSelection = [...selectedValues.slice(0, index), ...selectedValues.slice(index + 1)];
578
526
  onChange(updatedSelection);
579
527
  } else {
580
- onChange([].concat(selectedValues, [changedValue]));
528
+ onChange([...selectedValues, changedValue]);
581
529
  }
582
- };
583
- _proto.render = function render() {
530
+ }
531
+ render() {
584
532
  const {
585
533
  children,
586
534
  label,
@@ -622,22 +570,16 @@ let CheckboxGroup = function (_React$Component) {
622
570
  variant: "checkbox"
623
571
  });
624
572
  })));
625
- };
626
- return CheckboxGroup;
627
- }(React.Component);
573
+ }
574
+ }
628
575
 
629
576
  const StyledFieldset = addStyle("fieldset");
630
577
  const StyledLegend = addStyle("legend");
631
- let RadioGroup = function (_React$Component) {
632
- _inheritsLoose(RadioGroup, _React$Component);
633
- function RadioGroup() {
634
- return _React$Component.apply(this, arguments) || this;
635
- }
636
- var _proto = RadioGroup.prototype;
637
- _proto.handleChange = function handleChange(changedValue) {
578
+ class RadioGroup extends React.Component {
579
+ handleChange(changedValue) {
638
580
  this.props.onChange(changedValue);
639
- };
640
- _proto.render = function render() {
581
+ }
582
+ render() {
641
583
  const {
642
584
  children,
643
585
  label,
@@ -679,30 +621,27 @@ let RadioGroup = function (_React$Component) {
679
621
  variant: "radio"
680
622
  });
681
623
  })));
682
- };
683
- return RadioGroup;
684
- }(React.Component);
624
+ }
625
+ }
685
626
 
686
627
  const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
687
628
  const defaultErrorMessage = "This field is required.";
688
- let TextField = function (_React$Component) {
689
- _inheritsLoose(TextField, _React$Component);
690
- function TextField(props) {
691
- var _this;
692
- _this = _React$Component.call(this, props) || this;
693
- _this.state = {
629
+ class TextField extends React.Component {
630
+ constructor(props) {
631
+ super(props);
632
+ this.state = {
694
633
  error: null,
695
634
  focused: false
696
635
  };
697
- _this.maybeValidate = newValue => {
636
+ this.maybeValidate = newValue => {
698
637
  const {
699
638
  validate,
700
639
  onValidate,
701
640
  required
702
- } = _this.props;
641
+ } = this.props;
703
642
  if (validate) {
704
643
  const maybeError = validate(newValue) || null;
705
- _this.setState({
644
+ this.setState({
706
645
  error: maybeError
707
646
  }, () => {
708
647
  if (onValidate) {
@@ -712,7 +651,7 @@ let TextField = function (_React$Component) {
712
651
  } else if (required) {
713
652
  const requiredString = typeof required === "string" ? required : defaultErrorMessage;
714
653
  const maybeError = newValue ? null : requiredString;
715
- _this.setState({
654
+ this.setState({
716
655
  error: maybeError
717
656
  }, () => {
718
657
  if (onValidate) {
@@ -721,19 +660,19 @@ let TextField = function (_React$Component) {
721
660
  });
722
661
  }
723
662
  };
724
- _this.handleChange = event => {
663
+ this.handleChange = event => {
725
664
  const {
726
665
  onChange
727
- } = _this.props;
666
+ } = this.props;
728
667
  const newValue = event.target.value;
729
- _this.maybeValidate(newValue);
668
+ this.maybeValidate(newValue);
730
669
  onChange(newValue);
731
670
  };
732
- _this.handleFocus = event => {
671
+ this.handleFocus = event => {
733
672
  const {
734
673
  onFocus
735
- } = _this.props;
736
- _this.setState({
674
+ } = this.props;
675
+ this.setState({
737
676
  focused: true
738
677
  }, () => {
739
678
  if (onFocus) {
@@ -741,11 +680,11 @@ let TextField = function (_React$Component) {
741
680
  }
742
681
  });
743
682
  };
744
- _this.handleBlur = event => {
683
+ this.handleBlur = event => {
745
684
  const {
746
685
  onBlur
747
- } = _this.props;
748
- _this.setState({
686
+ } = this.props;
687
+ this.setState({
749
688
  focused: false
750
689
  }, () => {
751
690
  if (onBlur) {
@@ -754,17 +693,15 @@ let TextField = function (_React$Component) {
754
693
  });
755
694
  };
756
695
  if (props.validate && props.value !== "") {
757
- _this.state.error = props.validate(props.value) || null;
696
+ this.state.error = props.validate(props.value) || null;
758
697
  }
759
- return _this;
760
698
  }
761
- var _proto = TextField.prototype;
762
- _proto.componentDidMount = function componentDidMount() {
699
+ componentDidMount() {
763
700
  if (this.props.value !== "") {
764
701
  this.maybeValidate(this.props.value);
765
702
  }
766
- };
767
- _proto.render = function render() {
703
+ }
704
+ render() {
768
705
  const _this$props = this.props,
769
706
  {
770
707
  id,
@@ -797,9 +734,8 @@ let TextField = function (_React$Component) {
797
734
  autoComplete: autoComplete,
798
735
  ref: forwardedRef
799
736
  }, otherProps));
800
- };
801
- return TextField;
802
- }(React.Component);
737
+ }
738
+ }
803
739
  TextField.defaultProps = {
804
740
  type: "text",
805
741
  disabled: false,
@@ -860,13 +796,8 @@ var TextField$1 = React.forwardRef((props, ref) => React.createElement(TextField
860
796
  })));
861
797
 
862
798
  const StyledSpan = addStyle("span");
863
- let FieldHeading = function (_React$Component) {
864
- _inheritsLoose(FieldHeading, _React$Component);
865
- function FieldHeading() {
866
- return _React$Component.apply(this, arguments) || this;
867
- }
868
- var _proto = FieldHeading.prototype;
869
- _proto.renderLabel = function renderLabel() {
799
+ class FieldHeading extends React.Component {
800
+ renderLabel() {
870
801
  const {
871
802
  label,
872
803
  id,
@@ -885,8 +816,8 @@ let FieldHeading = function (_React$Component) {
885
816
  }, label, required && requiredIcon), React.createElement(Strut, {
886
817
  size: Spacing.xxxSmall_4
887
818
  }));
888
- };
889
- _proto.maybeRenderDescription = function maybeRenderDescription() {
819
+ }
820
+ maybeRenderDescription() {
890
821
  const {
891
822
  description,
892
823
  testId
@@ -900,8 +831,8 @@ let FieldHeading = function (_React$Component) {
900
831
  }, description), React.createElement(Strut, {
901
832
  size: Spacing.xxxSmall_4
902
833
  }));
903
- };
904
- _proto.maybeRenderError = function maybeRenderError() {
834
+ }
835
+ maybeRenderError() {
905
836
  const {
906
837
  error,
907
838
  id,
@@ -918,8 +849,8 @@ let FieldHeading = function (_React$Component) {
918
849
  id: id && `${id}-error`,
919
850
  testId: testId && `${testId}-error`
920
851
  }, error));
921
- };
922
- _proto.render = function render() {
852
+ }
853
+ render() {
923
854
  const {
924
855
  field,
925
856
  style
@@ -929,9 +860,8 @@ let FieldHeading = function (_React$Component) {
929
860
  }, this.renderLabel(), this.maybeRenderDescription(), React.createElement(Strut, {
930
861
  size: Spacing.xSmall_8
931
862
  }), field, this.maybeRenderError());
932
- };
933
- return FieldHeading;
934
- }(React.Component);
863
+ }
864
+ }
935
865
  const styles = StyleSheet.create({
936
866
  label: {
937
867
  color: Color.offBlack
@@ -947,16 +877,14 @@ const styles = StyleSheet.create({
947
877
  }
948
878
  });
949
879
 
950
- let LabeledTextField = function (_React$Component) {
951
- _inheritsLoose(LabeledTextField, _React$Component);
952
- function LabeledTextField(props) {
953
- var _this;
954
- _this = _React$Component.call(this, props) || this;
955
- _this.handleValidate = errorMessage => {
880
+ class LabeledTextField extends React.Component {
881
+ constructor(props) {
882
+ super(props);
883
+ this.handleValidate = errorMessage => {
956
884
  const {
957
885
  onValidate
958
- } = _this.props;
959
- _this.setState({
886
+ } = this.props;
887
+ this.setState({
960
888
  error: errorMessage
961
889
  }, () => {
962
890
  if (onValidate) {
@@ -964,11 +892,11 @@ let LabeledTextField = function (_React$Component) {
964
892
  }
965
893
  });
966
894
  };
967
- _this.handleFocus = event => {
895
+ this.handleFocus = event => {
968
896
  const {
969
897
  onFocus
970
- } = _this.props;
971
- _this.setState({
898
+ } = this.props;
899
+ this.setState({
972
900
  focused: true
973
901
  }, () => {
974
902
  if (onFocus) {
@@ -976,11 +904,11 @@ let LabeledTextField = function (_React$Component) {
976
904
  }
977
905
  });
978
906
  };
979
- _this.handleBlur = event => {
907
+ this.handleBlur = event => {
980
908
  const {
981
909
  onBlur
982
- } = _this.props;
983
- _this.setState({
910
+ } = this.props;
911
+ this.setState({
984
912
  focused: false
985
913
  }, () => {
986
914
  if (onBlur) {
@@ -988,14 +916,12 @@ let LabeledTextField = function (_React$Component) {
988
916
  }
989
917
  });
990
918
  };
991
- _this.state = {
919
+ this.state = {
992
920
  error: null,
993
921
  focused: false
994
922
  };
995
- return _this;
996
923
  }
997
- var _proto = LabeledTextField.prototype;
998
- _proto.render = function render() {
924
+ render() {
999
925
  const {
1000
926
  id,
1001
927
  type,
@@ -1050,9 +976,8 @@ let LabeledTextField = function (_React$Component) {
1050
976
  required: !!required,
1051
977
  error: !this.state.focused && this.state.error || ""
1052
978
  }));
1053
- };
1054
- return LabeledTextField;
1055
- }(React.Component);
979
+ }
980
+ }
1056
981
  LabeledTextField.defaultProps = {
1057
982
  type: "text",
1058
983
  disabled: false,
package/dist/index.js CHANGED
@@ -52,20 +52,6 @@ function _extends() {
52
52
  return _extends.apply(this, arguments);
53
53
  }
54
54
 
55
- function _setPrototypeOf(o, p) {
56
- _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
57
- o.__proto__ = p;
58
- return o;
59
- };
60
- return _setPrototypeOf(o, p);
61
- }
62
-
63
- function _inheritsLoose(subClass, superClass) {
64
- subClass.prototype = Object.create(superClass.prototype);
65
- subClass.prototype.constructor = subClass;
66
- _setPrototypeOf(subClass, superClass);
67
- }
68
-
69
55
  function _objectWithoutPropertiesLoose(source, excluded) {
70
56
  if (source == null) return {};
71
57
  var target = {};
@@ -93,18 +79,14 @@ const StyledInput$1 = wonderBlocksCore.addStyle("input");
93
79
  const checkboxCheck = {
94
80
  small: "M11.263 4.324a1 1 0 1 1 1.474 1.352l-5.5 6a1 1 0 0 1-1.505-.036l-2.5-3a1 1 0 1 1 1.536-1.28L6.536 9.48l4.727-5.157z"
95
81
  };
96
- let CheckboxCore = function (_React$Component) {
97
- _inheritsLoose(CheckboxCore, _React$Component);
98
- function CheckboxCore(...args) {
99
- var _this;
100
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
101
- _this.handleChange = () => {
82
+ class CheckboxCore extends React__namespace.Component {
83
+ constructor(...args) {
84
+ super(...args);
85
+ this.handleChange = () => {
102
86
  return;
103
87
  };
104
- return _this;
105
88
  }
106
- var _proto = CheckboxCore.prototype;
107
- _proto.render = function render() {
89
+ render() {
108
90
  const _this$props = this.props,
109
91
  {
110
92
  checked,
@@ -138,9 +120,8 @@ let CheckboxCore = function (_React$Component) {
138
120
  size: "small",
139
121
  style: sharedStyles$1.checkIcon
140
122
  }));
141
- };
142
- return CheckboxCore;
143
- }(React__namespace.Component);
123
+ }
124
+ }
144
125
  const size$1 = 16;
145
126
  const sharedStyles$1 = aphrodite.StyleSheet.create({
146
127
  inputReset: {
@@ -242,18 +223,14 @@ const {
242
223
  offBlack50
243
224
  } = Color__default["default"];
244
225
  const StyledInput = wonderBlocksCore.addStyle("input");
245
- let RadioCore = function (_React$Component) {
246
- _inheritsLoose(RadioCore, _React$Component);
247
- function RadioCore(...args) {
248
- var _this;
249
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
250
- _this.handleChange = () => {
226
+ class RadioCore extends React__namespace.Component {
227
+ constructor(...args) {
228
+ super(...args);
229
+ this.handleChange = () => {
251
230
  return;
252
231
  };
253
- return _this;
254
232
  }
255
- var _proto = RadioCore.prototype;
256
- _proto.render = function render() {
233
+ render() {
257
234
  const _this$props = this.props,
258
235
  {
259
236
  checked,
@@ -284,9 +261,8 @@ let RadioCore = function (_React$Component) {
284
261
  }, props)), disabled && checked && React__namespace.createElement("span", {
285
262
  style: disabledChecked
286
263
  }));
287
- };
288
- return RadioCore;
289
- }(React__namespace.Component);
264
+ }
265
+ }
290
266
  const size = 16;
291
267
  const disabledChecked = {
292
268
  position: "absolute",
@@ -384,36 +360,32 @@ const _generateStyles = (checked, error) => {
384
360
  };
385
361
 
386
362
  const _excluded$2 = ["label", "description", "onChange", "style", "className", "variant"];
387
- let ChoiceInternal = function (_React$Component) {
388
- _inheritsLoose(ChoiceInternal, _React$Component);
389
- function ChoiceInternal(...args) {
390
- var _this;
391
- _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
392
- _this.handleLabelClick = event => {
363
+ class ChoiceInternal extends React__namespace.Component {
364
+ constructor(...args) {
365
+ super(...args);
366
+ this.handleLabelClick = event => {
393
367
  event.preventDefault();
394
368
  };
395
- _this.handleClick = () => {
369
+ this.handleClick = () => {
396
370
  const {
397
371
  checked,
398
372
  onChange,
399
373
  variant
400
- } = _this.props;
374
+ } = this.props;
401
375
  if (variant === "radio" && checked) {
402
376
  return;
403
377
  }
404
378
  onChange(!checked);
405
379
  };
406
- return _this;
407
380
  }
408
- var _proto = ChoiceInternal.prototype;
409
- _proto.getChoiceCoreComponent = function getChoiceCoreComponent() {
381
+ getChoiceCoreComponent() {
410
382
  if (this.props.variant === "radio") {
411
383
  return RadioCore;
412
384
  } else {
413
385
  return CheckboxCore;
414
386
  }
415
- };
416
- _proto.getLabel = function getLabel() {
387
+ }
388
+ getLabel() {
417
389
  const {
418
390
  disabled,
419
391
  id,
@@ -425,8 +397,8 @@ let ChoiceInternal = function (_React$Component) {
425
397
  htmlFor: id,
426
398
  onClick: this.handleLabelClick
427
399
  }, label));
428
- };
429
- _proto.getDescription = function getDescription(id) {
400
+ }
401
+ getDescription(id) {
430
402
  const {
431
403
  description
432
404
  } = this.props;
@@ -434,8 +406,8 @@ let ChoiceInternal = function (_React$Component) {
434
406
  style: styles$3.description,
435
407
  id: id
436
408
  }, description);
437
- };
438
- _proto.render = function render() {
409
+ }
410
+ render() {
439
411
  const _this$props = this.props,
440
412
  {
441
413
  label,
@@ -471,9 +443,8 @@ let ChoiceInternal = function (_React$Component) {
471
443
  }), label && this.getLabel());
472
444
  }), description && this.getDescription(descriptionId));
473
445
  });
474
- };
475
- return ChoiceInternal;
476
- }(React__namespace.Component);
446
+ }
447
+ }
477
448
  ChoiceInternal.defaultProps = {
478
449
  checked: false,
479
450
  disabled: false,
@@ -499,57 +470,40 @@ const styles$3 = aphrodite.StyleSheet.create({
499
470
  }
500
471
  });
501
472
 
502
- let Checkbox = function (_React$Component) {
503
- _inheritsLoose(Checkbox, _React$Component);
504
- function Checkbox() {
505
- return _React$Component.apply(this, arguments) || this;
506
- }
507
- var _proto = Checkbox.prototype;
508
- _proto.render = function render() {
473
+ class Checkbox extends React__namespace.Component {
474
+ render() {
509
475
  return React__namespace.createElement(ChoiceInternal, _extends({
510
476
  variant: "checkbox"
511
477
  }, this.props));
512
- };
513
- return Checkbox;
514
- }(React__namespace.Component);
478
+ }
479
+ }
515
480
  Checkbox.defaultProps = {
516
481
  disabled: false,
517
482
  error: false
518
483
  };
519
484
 
520
- let Radio = function (_React$Component) {
521
- _inheritsLoose(Radio, _React$Component);
522
- function Radio() {
523
- return _React$Component.apply(this, arguments) || this;
524
- }
525
- var _proto = Radio.prototype;
526
- _proto.render = function render() {
485
+ class Radio extends React__namespace.Component {
486
+ render() {
527
487
  return React__namespace.createElement(ChoiceInternal, _extends({
528
488
  variant: "radio"
529
489
  }, this.props));
530
- };
531
- return Radio;
532
- }(React__namespace.Component);
490
+ }
491
+ }
533
492
  Radio.defaultProps = {
534
493
  disabled: false,
535
494
  error: false
536
495
  };
537
496
 
538
497
  const _excluded$1 = ["value", "variant"];
539
- let Choice = function (_React$Component) {
540
- _inheritsLoose(Choice, _React$Component);
541
- function Choice() {
542
- return _React$Component.apply(this, arguments) || this;
543
- }
544
- var _proto = Choice.prototype;
545
- _proto.getChoiceComponent = function getChoiceComponent(variant) {
498
+ class Choice extends React__namespace.Component {
499
+ getChoiceComponent(variant) {
546
500
  if (variant === "checkbox") {
547
501
  return Checkbox;
548
502
  } else {
549
503
  return Radio;
550
504
  }
551
- };
552
- _proto.render = function render() {
505
+ }
506
+ render() {
553
507
  const _this$props = this.props,
554
508
  {
555
509
  variant
@@ -557,9 +511,8 @@ let Choice = function (_React$Component) {
557
511
  remainingProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
558
512
  const ChoiceComponent = this.getChoiceComponent(variant);
559
513
  return React__namespace.createElement(ChoiceComponent, remainingProps);
560
- };
561
- return Choice;
562
- }(React__namespace.Component);
514
+ }
515
+ }
563
516
  Choice.defaultProps = {
564
517
  checked: false,
565
518
  disabled: false,
@@ -590,26 +543,21 @@ const styles$2 = aphrodite.StyleSheet.create({
590
543
 
591
544
  const StyledFieldset$1 = wonderBlocksCore.addStyle("fieldset");
592
545
  const StyledLegend$1 = wonderBlocksCore.addStyle("legend");
593
- let CheckboxGroup = function (_React$Component) {
594
- _inheritsLoose(CheckboxGroup, _React$Component);
595
- function CheckboxGroup() {
596
- return _React$Component.apply(this, arguments) || this;
597
- }
598
- var _proto = CheckboxGroup.prototype;
599
- _proto.handleChange = function handleChange(changedValue, originalCheckedState) {
546
+ class CheckboxGroup extends React__namespace.Component {
547
+ handleChange(changedValue, originalCheckedState) {
600
548
  const {
601
549
  onChange,
602
550
  selectedValues
603
551
  } = this.props;
604
552
  if (originalCheckedState) {
605
553
  const index = selectedValues.indexOf(changedValue);
606
- const updatedSelection = [].concat(selectedValues.slice(0, index), selectedValues.slice(index + 1));
554
+ const updatedSelection = [...selectedValues.slice(0, index), ...selectedValues.slice(index + 1)];
607
555
  onChange(updatedSelection);
608
556
  } else {
609
- onChange([].concat(selectedValues, [changedValue]));
557
+ onChange([...selectedValues, changedValue]);
610
558
  }
611
- };
612
- _proto.render = function render() {
559
+ }
560
+ render() {
613
561
  const {
614
562
  children,
615
563
  label,
@@ -651,22 +599,16 @@ let CheckboxGroup = function (_React$Component) {
651
599
  variant: "checkbox"
652
600
  });
653
601
  })));
654
- };
655
- return CheckboxGroup;
656
- }(React__namespace.Component);
602
+ }
603
+ }
657
604
 
658
605
  const StyledFieldset = wonderBlocksCore.addStyle("fieldset");
659
606
  const StyledLegend = wonderBlocksCore.addStyle("legend");
660
- let RadioGroup = function (_React$Component) {
661
- _inheritsLoose(RadioGroup, _React$Component);
662
- function RadioGroup() {
663
- return _React$Component.apply(this, arguments) || this;
664
- }
665
- var _proto = RadioGroup.prototype;
666
- _proto.handleChange = function handleChange(changedValue) {
607
+ class RadioGroup extends React__namespace.Component {
608
+ handleChange(changedValue) {
667
609
  this.props.onChange(changedValue);
668
- };
669
- _proto.render = function render() {
610
+ }
611
+ render() {
670
612
  const {
671
613
  children,
672
614
  label,
@@ -708,30 +650,27 @@ let RadioGroup = function (_React$Component) {
708
650
  variant: "radio"
709
651
  });
710
652
  })));
711
- };
712
- return RadioGroup;
713
- }(React__namespace.Component);
653
+ }
654
+ }
714
655
 
715
656
  const _excluded = ["id", "type", "value", "disabled", "onKeyDown", "placeholder", "light", "style", "testId", "readOnly", "autoComplete", "forwardedRef", "onFocus", "onBlur", "onValidate", "validate", "onChange", "required"];
716
657
  const defaultErrorMessage = "This field is required.";
717
- let TextField = function (_React$Component) {
718
- _inheritsLoose(TextField, _React$Component);
719
- function TextField(props) {
720
- var _this;
721
- _this = _React$Component.call(this, props) || this;
722
- _this.state = {
658
+ class TextField extends React__namespace.Component {
659
+ constructor(props) {
660
+ super(props);
661
+ this.state = {
723
662
  error: null,
724
663
  focused: false
725
664
  };
726
- _this.maybeValidate = newValue => {
665
+ this.maybeValidate = newValue => {
727
666
  const {
728
667
  validate,
729
668
  onValidate,
730
669
  required
731
- } = _this.props;
670
+ } = this.props;
732
671
  if (validate) {
733
672
  const maybeError = validate(newValue) || null;
734
- _this.setState({
673
+ this.setState({
735
674
  error: maybeError
736
675
  }, () => {
737
676
  if (onValidate) {
@@ -741,7 +680,7 @@ let TextField = function (_React$Component) {
741
680
  } else if (required) {
742
681
  const requiredString = typeof required === "string" ? required : defaultErrorMessage;
743
682
  const maybeError = newValue ? null : requiredString;
744
- _this.setState({
683
+ this.setState({
745
684
  error: maybeError
746
685
  }, () => {
747
686
  if (onValidate) {
@@ -750,19 +689,19 @@ let TextField = function (_React$Component) {
750
689
  });
751
690
  }
752
691
  };
753
- _this.handleChange = event => {
692
+ this.handleChange = event => {
754
693
  const {
755
694
  onChange
756
- } = _this.props;
695
+ } = this.props;
757
696
  const newValue = event.target.value;
758
- _this.maybeValidate(newValue);
697
+ this.maybeValidate(newValue);
759
698
  onChange(newValue);
760
699
  };
761
- _this.handleFocus = event => {
700
+ this.handleFocus = event => {
762
701
  const {
763
702
  onFocus
764
- } = _this.props;
765
- _this.setState({
703
+ } = this.props;
704
+ this.setState({
766
705
  focused: true
767
706
  }, () => {
768
707
  if (onFocus) {
@@ -770,11 +709,11 @@ let TextField = function (_React$Component) {
770
709
  }
771
710
  });
772
711
  };
773
- _this.handleBlur = event => {
712
+ this.handleBlur = event => {
774
713
  const {
775
714
  onBlur
776
- } = _this.props;
777
- _this.setState({
715
+ } = this.props;
716
+ this.setState({
778
717
  focused: false
779
718
  }, () => {
780
719
  if (onBlur) {
@@ -783,17 +722,15 @@ let TextField = function (_React$Component) {
783
722
  });
784
723
  };
785
724
  if (props.validate && props.value !== "") {
786
- _this.state.error = props.validate(props.value) || null;
725
+ this.state.error = props.validate(props.value) || null;
787
726
  }
788
- return _this;
789
727
  }
790
- var _proto = TextField.prototype;
791
- _proto.componentDidMount = function componentDidMount() {
728
+ componentDidMount() {
792
729
  if (this.props.value !== "") {
793
730
  this.maybeValidate(this.props.value);
794
731
  }
795
- };
796
- _proto.render = function render() {
732
+ }
733
+ render() {
797
734
  const _this$props = this.props,
798
735
  {
799
736
  id,
@@ -826,9 +763,8 @@ let TextField = function (_React$Component) {
826
763
  autoComplete: autoComplete,
827
764
  ref: forwardedRef
828
765
  }, otherProps));
829
- };
830
- return TextField;
831
- }(React__namespace.Component);
766
+ }
767
+ }
832
768
  TextField.defaultProps = {
833
769
  type: "text",
834
770
  disabled: false,
@@ -889,13 +825,8 @@ var TextField$1 = React__namespace.forwardRef((props, ref) => React__namespace.c
889
825
  })));
890
826
 
891
827
  const StyledSpan = wonderBlocksCore.addStyle("span");
892
- let FieldHeading = function (_React$Component) {
893
- _inheritsLoose(FieldHeading, _React$Component);
894
- function FieldHeading() {
895
- return _React$Component.apply(this, arguments) || this;
896
- }
897
- var _proto = FieldHeading.prototype;
898
- _proto.renderLabel = function renderLabel() {
828
+ class FieldHeading extends React__namespace.Component {
829
+ renderLabel() {
899
830
  const {
900
831
  label,
901
832
  id,
@@ -914,8 +845,8 @@ let FieldHeading = function (_React$Component) {
914
845
  }, label, required && requiredIcon), React__namespace.createElement(wonderBlocksLayout.Strut, {
915
846
  size: Spacing__default["default"].xxxSmall_4
916
847
  }));
917
- };
918
- _proto.maybeRenderDescription = function maybeRenderDescription() {
848
+ }
849
+ maybeRenderDescription() {
919
850
  const {
920
851
  description,
921
852
  testId
@@ -929,8 +860,8 @@ let FieldHeading = function (_React$Component) {
929
860
  }, description), React__namespace.createElement(wonderBlocksLayout.Strut, {
930
861
  size: Spacing__default["default"].xxxSmall_4
931
862
  }));
932
- };
933
- _proto.maybeRenderError = function maybeRenderError() {
863
+ }
864
+ maybeRenderError() {
934
865
  const {
935
866
  error,
936
867
  id,
@@ -947,8 +878,8 @@ let FieldHeading = function (_React$Component) {
947
878
  id: id && `${id}-error`,
948
879
  testId: testId && `${testId}-error`
949
880
  }, error));
950
- };
951
- _proto.render = function render() {
881
+ }
882
+ render() {
952
883
  const {
953
884
  field,
954
885
  style
@@ -958,9 +889,8 @@ let FieldHeading = function (_React$Component) {
958
889
  }, this.renderLabel(), this.maybeRenderDescription(), React__namespace.createElement(wonderBlocksLayout.Strut, {
959
890
  size: Spacing__default["default"].xSmall_8
960
891
  }), field, this.maybeRenderError());
961
- };
962
- return FieldHeading;
963
- }(React__namespace.Component);
892
+ }
893
+ }
964
894
  const styles = aphrodite.StyleSheet.create({
965
895
  label: {
966
896
  color: Color__default["default"].offBlack
@@ -976,16 +906,14 @@ const styles = aphrodite.StyleSheet.create({
976
906
  }
977
907
  });
978
908
 
979
- let LabeledTextField = function (_React$Component) {
980
- _inheritsLoose(LabeledTextField, _React$Component);
981
- function LabeledTextField(props) {
982
- var _this;
983
- _this = _React$Component.call(this, props) || this;
984
- _this.handleValidate = errorMessage => {
909
+ class LabeledTextField extends React__namespace.Component {
910
+ constructor(props) {
911
+ super(props);
912
+ this.handleValidate = errorMessage => {
985
913
  const {
986
914
  onValidate
987
- } = _this.props;
988
- _this.setState({
915
+ } = this.props;
916
+ this.setState({
989
917
  error: errorMessage
990
918
  }, () => {
991
919
  if (onValidate) {
@@ -993,11 +921,11 @@ let LabeledTextField = function (_React$Component) {
993
921
  }
994
922
  });
995
923
  };
996
- _this.handleFocus = event => {
924
+ this.handleFocus = event => {
997
925
  const {
998
926
  onFocus
999
- } = _this.props;
1000
- _this.setState({
927
+ } = this.props;
928
+ this.setState({
1001
929
  focused: true
1002
930
  }, () => {
1003
931
  if (onFocus) {
@@ -1005,11 +933,11 @@ let LabeledTextField = function (_React$Component) {
1005
933
  }
1006
934
  });
1007
935
  };
1008
- _this.handleBlur = event => {
936
+ this.handleBlur = event => {
1009
937
  const {
1010
938
  onBlur
1011
- } = _this.props;
1012
- _this.setState({
939
+ } = this.props;
940
+ this.setState({
1013
941
  focused: false
1014
942
  }, () => {
1015
943
  if (onBlur) {
@@ -1017,14 +945,12 @@ let LabeledTextField = function (_React$Component) {
1017
945
  }
1018
946
  });
1019
947
  };
1020
- _this.state = {
948
+ this.state = {
1021
949
  error: null,
1022
950
  focused: false
1023
951
  };
1024
- return _this;
1025
952
  }
1026
- var _proto = LabeledTextField.prototype;
1027
- _proto.render = function render() {
953
+ render() {
1028
954
  const {
1029
955
  id,
1030
956
  type,
@@ -1079,9 +1005,8 @@ let LabeledTextField = function (_React$Component) {
1079
1005
  required: !!required,
1080
1006
  error: !this.state.focused && this.state.error || ""
1081
1007
  }));
1082
- };
1083
- return LabeledTextField;
1084
- }(React__namespace.Component);
1008
+ }
1009
+ }
1085
1010
  LabeledTextField.defaultProps = {
1086
1011
  type: "text",
1087
1012
  disabled: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-form",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "design": "v1",
5
5
  "description": "Form components for Wonder Blocks.",
6
6
  "main": "dist/index.js",
@@ -16,19 +16,19 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^3.0.5",
19
+ "@khanacademy/wonder-blocks-clickable": "^3.0.6",
20
20
  "@khanacademy/wonder-blocks-color": "^2.0.1",
21
- "@khanacademy/wonder-blocks-core": "^5.0.3",
22
- "@khanacademy/wonder-blocks-icon": "^2.0.5",
23
- "@khanacademy/wonder-blocks-layout": "^2.0.5",
21
+ "@khanacademy/wonder-blocks-core": "^5.0.4",
22
+ "@khanacademy/wonder-blocks-icon": "^2.0.6",
23
+ "@khanacademy/wonder-blocks-layout": "^2.0.6",
24
24
  "@khanacademy/wonder-blocks-spacing": "^4.0.1",
25
- "@khanacademy/wonder-blocks-typography": "^2.0.5"
25
+ "@khanacademy/wonder-blocks-typography": "^2.0.6"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "aphrodite": "^1.2.5",
29
29
  "react": "16.14.0"
30
30
  },
31
31
  "devDependencies": {
32
- "wb-dev-build-settings": "^0.9.4"
32
+ "wb-dev-build-settings": "^0.9.5"
33
33
  }
34
34
  }