@khanacademy/wonder-blocks-form 4.0.5 → 4.0.7
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 +21 -0
- package/dist/components/checkbox-group.js.flow +1 -1
- package/dist/components/radio-group.js.flow +1 -1
- package/dist/es/index.js +106 -181
- package/dist/index.js +106 -181
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @khanacademy/wonder-blocks-form
|
|
2
2
|
|
|
3
|
+
## 4.0.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @khanacademy/wonder-blocks-clickable@3.0.7
|
|
8
|
+
- @khanacademy/wonder-blocks-icon@2.0.7
|
|
9
|
+
- @khanacademy/wonder-blocks-layout@2.0.7
|
|
10
|
+
- @khanacademy/wonder-blocks-typography@2.0.7
|
|
11
|
+
|
|
12
|
+
## 4.0.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- c20f48f3: Don't transpile classes when building bundles
|
|
17
|
+
- Updated dependencies [c20f48f3]
|
|
18
|
+
- @khanacademy/wonder-blocks-clickable@3.0.6
|
|
19
|
+
- @khanacademy/wonder-blocks-core@5.0.4
|
|
20
|
+
- @khanacademy/wonder-blocks-icon@2.0.6
|
|
21
|
+
- @khanacademy/wonder-blocks-layout@2.0.6
|
|
22
|
+
- @khanacademy/wonder-blocks-typography@2.0.6
|
|
23
|
+
|
|
3
24
|
## 4.0.5
|
|
4
25
|
|
|
5
26
|
### 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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
340
|
+
this.handleClick = () => {
|
|
367
341
|
const {
|
|
368
342
|
checked,
|
|
369
343
|
onChange,
|
|
370
344
|
variant
|
|
371
|
-
} =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
474
|
-
|
|
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
|
-
|
|
485
|
-
}(React.Component);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
486
451
|
Checkbox.defaultProps = {
|
|
487
452
|
disabled: false,
|
|
488
453
|
error: false
|
|
489
454
|
};
|
|
490
455
|
|
|
491
|
-
|
|
492
|
-
|
|
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
|
-
|
|
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
|
-
|
|
511
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
565
|
-
|
|
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 = [
|
|
525
|
+
const updatedSelection = [...selectedValues.slice(0, index), ...selectedValues.slice(index + 1)];
|
|
578
526
|
onChange(updatedSelection);
|
|
579
527
|
} else {
|
|
580
|
-
onChange([
|
|
528
|
+
onChange([...selectedValues, changedValue]);
|
|
581
529
|
}
|
|
582
|
-
}
|
|
583
|
-
|
|
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
|
-
|
|
627
|
-
}(React.Component);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
628
575
|
|
|
629
576
|
const StyledFieldset = addStyle("fieldset");
|
|
630
577
|
const StyledLegend = addStyle("legend");
|
|
631
|
-
|
|
632
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
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
|
-
|
|
636
|
+
this.maybeValidate = newValue => {
|
|
698
637
|
const {
|
|
699
638
|
validate,
|
|
700
639
|
onValidate,
|
|
701
640
|
required
|
|
702
|
-
} =
|
|
641
|
+
} = this.props;
|
|
703
642
|
if (validate) {
|
|
704
643
|
const maybeError = validate(newValue) || null;
|
|
705
|
-
|
|
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
|
-
|
|
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
|
-
|
|
663
|
+
this.handleChange = event => {
|
|
725
664
|
const {
|
|
726
665
|
onChange
|
|
727
|
-
} =
|
|
666
|
+
} = this.props;
|
|
728
667
|
const newValue = event.target.value;
|
|
729
|
-
|
|
668
|
+
this.maybeValidate(newValue);
|
|
730
669
|
onChange(newValue);
|
|
731
670
|
};
|
|
732
|
-
|
|
671
|
+
this.handleFocus = event => {
|
|
733
672
|
const {
|
|
734
673
|
onFocus
|
|
735
|
-
} =
|
|
736
|
-
|
|
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
|
-
|
|
683
|
+
this.handleBlur = event => {
|
|
745
684
|
const {
|
|
746
685
|
onBlur
|
|
747
|
-
} =
|
|
748
|
-
|
|
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
|
-
|
|
696
|
+
this.state.error = props.validate(props.value) || null;
|
|
758
697
|
}
|
|
759
|
-
return _this;
|
|
760
698
|
}
|
|
761
|
-
|
|
762
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
699
|
+
componentDidMount() {
|
|
763
700
|
if (this.props.value !== "") {
|
|
764
701
|
this.maybeValidate(this.props.value);
|
|
765
702
|
}
|
|
766
|
-
}
|
|
767
|
-
|
|
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
|
-
|
|
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
|
-
|
|
864
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
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
|
-
} =
|
|
959
|
-
|
|
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
|
-
|
|
895
|
+
this.handleFocus = event => {
|
|
968
896
|
const {
|
|
969
897
|
onFocus
|
|
970
|
-
} =
|
|
971
|
-
|
|
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
|
-
|
|
907
|
+
this.handleBlur = event => {
|
|
980
908
|
const {
|
|
981
909
|
onBlur
|
|
982
|
-
} =
|
|
983
|
-
|
|
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
|
-
|
|
919
|
+
this.state = {
|
|
992
920
|
error: null,
|
|
993
921
|
focused: false
|
|
994
922
|
};
|
|
995
|
-
return _this;
|
|
996
923
|
}
|
|
997
|
-
|
|
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
|
-
|
|
1055
|
-
}(React.Component);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
1056
981
|
LabeledTextField.defaultProps = {
|
|
1057
982
|
type: "text",
|
|
1058
983
|
disabled: false,
|