@khanacademy/wonder-blocks-form 2.4.8 → 3.0.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 (31) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/es/index.js +11 -11
  3. package/dist/index.js +71 -75
  4. package/docs.md +5 -1
  5. package/package.json +2 -2
  6. package/src/__docs__/_overview_.stories.mdx +15 -0
  7. package/src/components/__docs__/checkbox-group.stories.js +0 -1
  8. package/src/components/__docs__/labeled-text-field.argtypes.js +2 -2
  9. package/src/components/__docs__/labeled-text-field.stories.js +25 -0
  10. package/src/components/__docs__/radio.stories.js +3 -2
  11. package/src/components/__tests__/checkbox-group.test.js +118 -67
  12. package/src/components/__tests__/field-heading.test.js +40 -0
  13. package/src/components/__tests__/radio-group.test.js +131 -58
  14. package/src/components/checkbox-group.js +5 -13
  15. package/src/components/checkbox.js +2 -2
  16. package/src/components/choice-internal.js +5 -3
  17. package/src/components/choice.js +2 -2
  18. package/src/components/field-heading.js +27 -43
  19. package/src/components/labeled-text-field.js +2 -3
  20. package/src/components/radio-group.js +2 -2
  21. package/src/components/radio.js +2 -2
  22. package/src/index.js +0 -2
  23. package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +0 -6126
  24. package/src/__tests__/generated-snapshot.test.js +0 -654
  25. package/src/components/checkbox-group.md +0 -200
  26. package/src/components/checkbox.md +0 -134
  27. package/src/components/field-heading.md +0 -43
  28. package/src/components/labeled-text-field.md +0 -535
  29. package/src/components/radio-group.md +0 -129
  30. package/src/components/radio.md +0 -26
  31. package/src/components/text-field.md +0 -770
@@ -6,11 +6,7 @@ import {View, addStyle, type StyleType} from "@khanacademy/wonder-blocks-core";
6
6
  import Color from "@khanacademy/wonder-blocks-color";
7
7
  import {Strut} from "@khanacademy/wonder-blocks-layout";
8
8
  import Spacing from "@khanacademy/wonder-blocks-spacing";
9
- import {
10
- type Typography,
11
- LabelMedium,
12
- LabelSmall,
13
- } from "@khanacademy/wonder-blocks-typography";
9
+ import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
14
10
 
15
11
  type Props = {|
16
12
  /**
@@ -21,12 +17,12 @@ type Props = {|
21
17
  /**
22
18
  * The title for the label element.
23
19
  */
24
- label: string | React.Element<Typography>,
20
+ label: React.Node,
25
21
 
26
22
  /**
27
23
  * The text for the description element.
28
24
  */
29
- description?: string | React.Element<Typography>,
25
+ description?: React.Node,
30
26
 
31
27
  /**
32
28
  * Whether this field is required to continue.
@@ -36,7 +32,7 @@ type Props = {|
36
32
  /**
37
33
  * The message for the error element.
38
34
  */
39
- error?: string | React.Element<Typography>,
35
+ error?: React.Node,
40
36
 
41
37
  /**
42
38
  * Custom styles for the field heading container.
@@ -76,19 +72,15 @@ export default class FieldHeading extends React.Component<Props> {
76
72
 
77
73
  return (
78
74
  <React.Fragment>
79
- {typeof label === "string" ? (
80
- <LabelMedium
81
- style={styles.label}
82
- tag="label"
83
- htmlFor={id && `${id}-field`}
84
- testId={testId && `${testId}-label`}
85
- >
86
- {label}
87
- {required && requiredIcon}
88
- </LabelMedium>
89
- ) : (
90
- label
91
- )}
75
+ <LabelMedium
76
+ style={styles.label}
77
+ tag="label"
78
+ htmlFor={id && `${id}-field`}
79
+ testId={testId && `${testId}-label`}
80
+ >
81
+ {label}
82
+ {required && requiredIcon}
83
+ </LabelMedium>
92
84
  <Strut size={Spacing.xxxSmall_4} />
93
85
  </React.Fragment>
94
86
  );
@@ -103,16 +95,12 @@ export default class FieldHeading extends React.Component<Props> {
103
95
 
104
96
  return (
105
97
  <React.Fragment>
106
- {typeof description === "string" ? (
107
- <LabelSmall
108
- style={styles.description}
109
- testId={testId && `${testId}-description`}
110
- >
111
- {description}
112
- </LabelSmall>
113
- ) : (
114
- description
115
- )}
98
+ <LabelSmall
99
+ style={styles.description}
100
+ testId={testId && `${testId}-description`}
101
+ >
102
+ {description}
103
+ </LabelSmall>
116
104
  <Strut size={Spacing.xxxSmall_4} />
117
105
  </React.Fragment>
118
106
  );
@@ -128,18 +116,14 @@ export default class FieldHeading extends React.Component<Props> {
128
116
  return (
129
117
  <React.Fragment>
130
118
  <Strut size={Spacing.small_12} />
131
- {typeof error === "string" ? (
132
- <LabelSmall
133
- style={styles.error}
134
- role="alert"
135
- id={id && `${id}-error`}
136
- testId={testId && `${testId}-error`}
137
- >
138
- {error}
139
- </LabelSmall>
140
- ) : (
141
- error
142
- )}
119
+ <LabelSmall
120
+ style={styles.error}
121
+ role="alert"
122
+ id={id && `${id}-error`}
123
+ testId={testId && `${testId}-error`}
124
+ >
125
+ {error}
126
+ </LabelSmall>
143
127
  </React.Fragment>
144
128
  );
145
129
  }
@@ -2,7 +2,6 @@
2
2
  import * as React from "react";
3
3
 
4
4
  import {IDProvider, type StyleType} from "@khanacademy/wonder-blocks-core";
5
- import {type Typography} from "@khanacademy/wonder-blocks-typography";
6
5
 
7
6
  import FieldHeading from "./field-heading.js";
8
7
  import TextField, {type TextFieldType} from "./text-field.js";
@@ -24,12 +23,12 @@ type Props = {|
24
23
  /**
25
24
  * Provide a label for the TextField.
26
25
  */
27
- label: string | React.Element<Typography>,
26
+ label: React.Node,
28
27
 
29
28
  /**
30
29
  * Provide a description for the TextField.
31
30
  */
32
- description?: string | React.Element<Typography>,
31
+ description?: React.Node,
33
32
 
34
33
  /**
35
34
  * The input value.
@@ -28,12 +28,12 @@ type RadioGroupProps = {|
28
28
  * Optional label for the group. This label is optional to allow for
29
29
  * greater flexibility in implementing checkbox and radio groups.
30
30
  */
31
- label?: string,
31
+ label?: React.Node,
32
32
 
33
33
  /**
34
34
  * Optional description for the group.
35
35
  */
36
- description?: string,
36
+ description?: React.Node,
37
37
 
38
38
  /**
39
39
  * Optional error message. If supplied, the group will be displayed in an
@@ -33,12 +33,12 @@ type ChoiceComponentProps = {|
33
33
  /**
34
34
  * Optional label for the field.
35
35
  */
36
- label?: string,
36
+ label?: React.Node,
37
37
 
38
38
  /**
39
39
  * Optional description for the field.
40
40
  */
41
- description?: string,
41
+ description?: React.Node,
42
42
 
43
43
  /**
44
44
  * Unique identifier attached to the HTML input element. If used, need to
package/src/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  // @flow
2
2
  import Checkbox from "./components/checkbox.js";
3
- import Radio from "./components/radio.js";
4
3
  import Choice from "./components/choice.js";
5
4
  import CheckboxGroup from "./components/checkbox-group.js";
6
5
  import RadioGroup from "./components/radio-group.js";
@@ -9,7 +8,6 @@ import LabeledTextField from "./components/labeled-text-field.js";
9
8
 
10
9
  export {
11
10
  Checkbox,
12
- Radio,
13
11
  Choice,
14
12
  CheckboxGroup,
15
13
  RadioGroup,