@digigov/react-core 0.21.0 → 0.21.1

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.
@@ -14,11 +14,13 @@ exports[`renders the RadioItem value props 1`] = `
14
14
  <ForwardRef(Base)
15
15
  as="input"
16
16
  className="govgr-radios__input"
17
+ disabled={false}
17
18
  type="radio"
18
19
  value="someValue"
19
20
  >
20
21
  <input
21
22
  className="govgr-radios__input"
23
+ disabled={false}
22
24
  type="radio"
23
25
  value="someValue"
24
26
  />
@@ -28,6 +30,34 @@ exports[`renders the RadioItem value props 1`] = `
28
30
  </ForwardRef(RadioItem)>
29
31
  `;
30
32
 
33
+ exports[`renders the RadioItem with disabled prop 1`] = `
34
+ <ForwardRef(RadioItem)
35
+ disabled={true}
36
+ >
37
+ <div
38
+ className="govgr-radios__item"
39
+ >
40
+ <label
41
+ className="govgr-radios__label--disabled govgr-label govgr-radios__label"
42
+ >
43
+ hello
44
+ <ForwardRef(Base)
45
+ as="input"
46
+ className="govgr-radios__input"
47
+ disabled={true}
48
+ type="radio"
49
+ >
50
+ <input
51
+ className="govgr-radios__input"
52
+ disabled={true}
53
+ type="radio"
54
+ />
55
+ </ForwardRef(Base)>
56
+ </label>
57
+ </div>
58
+ </ForwardRef(RadioItem)>
59
+ `;
60
+
31
61
  exports[`renders the RadioItem with name props 1`] = `
32
62
  <ForwardRef(RadioItem)
33
63
  name="name"
@@ -42,11 +72,13 @@ exports[`renders the RadioItem with name props 1`] = `
42
72
  <ForwardRef(Base)
43
73
  as="input"
44
74
  className="govgr-radios__input"
75
+ disabled={false}
45
76
  name="name"
46
77
  type="radio"
47
78
  >
48
79
  <input
49
80
  className="govgr-radios__input"
81
+ disabled={false}
50
82
  name="name"
51
83
  type="radio"
52
84
  />
@@ -71,12 +103,48 @@ exports[`renders the RadioItem with name and value props 1`] = `
71
103
  <ForwardRef(Base)
72
104
  as="input"
73
105
  className="govgr-radios__input"
106
+ disabled={false}
107
+ name="name"
108
+ type="radio"
109
+ value="someValue"
110
+ >
111
+ <input
112
+ className="govgr-radios__input"
113
+ disabled={false}
114
+ name="name"
115
+ type="radio"
116
+ value="someValue"
117
+ />
118
+ </ForwardRef(Base)>
119
+ </label>
120
+ </div>
121
+ </ForwardRef(RadioItem)>
122
+ `;
123
+
124
+ exports[`renders the RadioItem with name disabled and value props 1`] = `
125
+ <ForwardRef(RadioItem)
126
+ disabled={true}
127
+ name="name"
128
+ value="someValue"
129
+ >
130
+ <div
131
+ className="govgr-radios__item"
132
+ >
133
+ <label
134
+ className="govgr-radios__label--disabled govgr-label govgr-radios__label"
135
+ >
136
+ hello
137
+ <ForwardRef(Base)
138
+ as="input"
139
+ className="govgr-radios__input"
140
+ disabled={true}
74
141
  name="name"
75
142
  type="radio"
76
143
  value="someValue"
77
144
  >
78
145
  <input
79
146
  className="govgr-radios__input"
147
+ disabled={true}
80
148
  name="name"
81
149
  type="radio"
82
150
  value="someValue"
@@ -99,10 +167,12 @@ exports[`renders the RadioItem with no props 1`] = `
99
167
  <ForwardRef(Base)
100
168
  as="input"
101
169
  className="govgr-radios__input"
170
+ disabled={false}
102
171
  type="radio"
103
172
  >
104
173
  <input
105
174
  className="govgr-radios__input"
175
+ disabled={false}
106
176
  type="radio"
107
177
  />
108
178
  </ForwardRef(Base)>
@@ -26,3 +26,17 @@ it('renders the RadioItem with name and value props', () => {
26
26
  )
27
27
  ).toMatchSnapshot();
28
28
  });
29
+
30
+ it('renders the RadioItem with disabled prop', () => {
31
+ expect(mount(<RadioItem disabled>hello</RadioItem>)).toMatchSnapshot();
32
+ });
33
+
34
+ it('renders the RadioItem with name disabled and value props', () => {
35
+ expect(
36
+ mount(
37
+ <RadioItem name={'name'} value={'someValue'} disabled>
38
+ hello
39
+ </RadioItem>
40
+ )
41
+ ).toMatchSnapshot();
42
+ });
@@ -12,13 +12,21 @@ export interface RadioItemProps extends BaseProps<'input'> {
12
12
  * Value property is optional and it specifies the value of an <input> element.
13
13
  */
14
14
  value?: string;
15
+ /**
16
+ * disabled prop disables the radio input.
17
+ * disabled property is optional and it is false by default.
18
+ */
19
+ disabled?: boolean;
15
20
  }
16
21
  /**
17
22
  * RadioItem component is used for display radio buttons.
18
23
  * RadioItem component must be included inside Radio component, as a children component.
19
24
  */
20
25
  export const RadioItem = React.forwardRef<HTMLInputElement, RadioItemProps>(
21
- function RadioItem({ name, value, className, children, ...props }, ref) {
26
+ function RadioItem(
27
+ { name, value, className, disabled = false, children, ...props },
28
+ ref
29
+ ) {
22
30
  return (
23
31
  <div
24
32
  className={clsx(className, {
@@ -28,6 +36,7 @@ export const RadioItem = React.forwardRef<HTMLInputElement, RadioItemProps>(
28
36
  <label
29
37
  className={clsx({
30
38
  'govgr-label govgr-radios__label': true,
39
+ 'govgr-radios__label--disabled': disabled === true,
31
40
  })}
32
41
  >
33
42
  {children}
@@ -40,6 +49,7 @@ export const RadioItem = React.forwardRef<HTMLInputElement, RadioItemProps>(
40
49
  className={clsx({
41
50
  'govgr-radios__input': true,
42
51
  })}
52
+ disabled={disabled}
43
53
  {...props}
44
54
  />
45
55
  </label>