@digigov/react-core 0.20.1 → 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.
- package/AccordionSection/index.d.ts +6 -1
- package/AccordionSection/index.js +4 -2
- package/CHANGELOG.md +15 -1
- package/CheckboxItem/__snapshots__/index.test.tsx.snap +68 -0
- package/CheckboxItem/index.d.ts +5 -0
- package/CheckboxItem/index.js +6 -3
- package/CheckboxItem/index.test.js +18 -0
- package/RadioItem/__snapshots__/index.test.tsx.snap +70 -0
- package/RadioItem/index.d.ts +5 -0
- package/RadioItem/index.js +6 -3
- package/RadioItem/index.test.js +18 -0
- package/TableBody/index.d.ts +6 -1
- package/TableBody/index.js +5 -3
- package/TableRow/index.d.ts +6 -1
- package/TableRow/index.js +5 -3
- package/Unpurge/index.js +1 -1
- package/es/AccordionSection/index.js +4 -2
- package/es/CheckboxItem/__snapshots__/index.test.tsx.snap +68 -0
- package/es/CheckboxItem/index.js +6 -3
- package/es/CheckboxItem/index.test.js +18 -0
- package/es/RadioItem/__snapshots__/index.test.tsx.snap +70 -0
- package/es/RadioItem/index.js +6 -3
- package/es/RadioItem/index.test.js +18 -0
- package/es/TableBody/index.js +5 -3
- package/es/TableRow/index.js +5 -3
- package/es/Unpurge/index.js +1 -1
- package/esm/AccordionSection/index.js +4 -2
- package/esm/CheckboxItem/__snapshots__/index.test.tsx.snap +68 -0
- package/esm/CheckboxItem/index.js +6 -3
- package/esm/CheckboxItem/index.test.js +18 -0
- package/esm/RadioItem/__snapshots__/index.test.tsx.snap +70 -0
- package/esm/RadioItem/index.js +6 -3
- package/esm/RadioItem/index.test.js +18 -0
- package/esm/TableBody/index.js +5 -3
- package/esm/TableRow/index.js +5 -3
- package/esm/Unpurge/index.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/src/AccordionSection/index.tsx +11 -1
- package/src/CheckboxItem/__snapshots__/index.test.tsx.snap +68 -0
- package/src/CheckboxItem/index.test.tsx +14 -0
- package/src/CheckboxItem/index.tsx +11 -1
- package/src/RadioItem/__snapshots__/index.test.tsx.snap +70 -0
- package/src/RadioItem/index.test.tsx +14 -0
- package/src/RadioItem/index.tsx +11 -1
- package/src/TableBody/index.tsx +13 -2
- package/src/TableRow/index.tsx +9 -2
- package/src/Unpurge/index.tsx +35 -5
|
@@ -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)>
|
package/esm/RadioItem/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["name", "value", "className", "children"];
|
|
3
|
+
var _excluded = ["name", "value", "className", "disabled", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import Base from '@digigov/react-core/Base';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -13,20 +13,23 @@ export var RadioItem = /*#__PURE__*/React.forwardRef(function RadioItem(_ref, re
|
|
|
13
13
|
var name = _ref.name,
|
|
14
14
|
value = _ref.value,
|
|
15
15
|
className = _ref.className,
|
|
16
|
+
_ref$disabled = _ref.disabled,
|
|
17
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
16
18
|
children = _ref.children,
|
|
17
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
20
|
|
|
19
21
|
return /*#__PURE__*/React.createElement("div", {
|
|
20
22
|
className: clsx(className, true && 'govgr-radios__item')
|
|
21
23
|
}, /*#__PURE__*/React.createElement("label", {
|
|
22
|
-
className: clsx(true && 'govgr-label govgr-radios__label')
|
|
24
|
+
className: clsx(disabled === true && 'govgr-radios__label--disabled', true && 'govgr-label govgr-radios__label')
|
|
23
25
|
}, children, /*#__PURE__*/React.createElement(Base, _extends({
|
|
24
26
|
as: "input",
|
|
25
27
|
ref: ref,
|
|
26
28
|
type: "radio",
|
|
27
29
|
name: name,
|
|
28
30
|
value: value,
|
|
29
|
-
className: clsx(true && 'govgr-radios__input')
|
|
31
|
+
className: clsx(true && 'govgr-radios__input'),
|
|
32
|
+
disabled: disabled
|
|
30
33
|
}, props))));
|
|
31
34
|
});
|
|
32
35
|
export default RadioItem;
|
|
@@ -31,4 +31,22 @@ var _ref4 = /*#__PURE__*/React.createElement(RadioItem, {
|
|
|
31
31
|
|
|
32
32
|
it('renders the RadioItem with name and value props', function () {
|
|
33
33
|
expect(mount(_ref4)).toMatchSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
var _ref5 = /*#__PURE__*/React.createElement(RadioItem, {
|
|
37
|
+
disabled: true
|
|
38
|
+
}, "hello");
|
|
39
|
+
|
|
40
|
+
it('renders the RadioItem with disabled prop', function () {
|
|
41
|
+
expect(mount(_ref5)).toMatchSnapshot();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
var _ref6 = /*#__PURE__*/React.createElement(RadioItem, {
|
|
45
|
+
name: 'name',
|
|
46
|
+
value: 'someValue',
|
|
47
|
+
disabled: true
|
|
48
|
+
}, "hello");
|
|
49
|
+
|
|
50
|
+
it('renders the RadioItem with name disabled and value props', function () {
|
|
51
|
+
expect(mount(_ref6)).toMatchSnapshot();
|
|
34
52
|
});
|
package/esm/TableBody/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "children"];
|
|
3
|
+
var _excluded = ["verticalAlign", "className", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import Base from '@digigov/react-core/Base';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -9,14 +9,16 @@ import clsx from 'clsx';
|
|
|
9
9
|
* Use TableBody inside the Table component to provide for the table data.
|
|
10
10
|
*/
|
|
11
11
|
export var TableBody = /*#__PURE__*/React.forwardRef(function TableBody(_ref, ref) {
|
|
12
|
-
var
|
|
12
|
+
var _ref$verticalAlign = _ref.verticalAlign,
|
|
13
|
+
verticalAlign = _ref$verticalAlign === void 0 ? 'middle' : _ref$verticalAlign,
|
|
14
|
+
className = _ref.className,
|
|
13
15
|
children = _ref.children,
|
|
14
16
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
17
|
|
|
16
18
|
return /*#__PURE__*/React.createElement(Base, _extends({
|
|
17
19
|
as: "tbody",
|
|
18
20
|
ref: ref,
|
|
19
|
-
className: clsx(className, true && 'govgr-table__body')
|
|
21
|
+
className: clsx(className, verticalAlign === 'bottom' && 'govgr-table__body--vertical-bottom', verticalAlign === 'top' && 'govgr-table__body--vertical-top', true && 'govgr-table__body')
|
|
20
22
|
}, props), children);
|
|
21
23
|
});
|
|
22
24
|
export default TableBody;
|
package/esm/TableRow/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["className", "children"];
|
|
3
|
+
var _excluded = ["warning", "className", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import Base from '@digigov/react-core/Base';
|
|
6
6
|
import clsx from 'clsx';
|
|
@@ -9,14 +9,16 @@ import clsx from 'clsx';
|
|
|
9
9
|
* Use TableRow inside the Table component to provide a new row to the table.
|
|
10
10
|
*/
|
|
11
11
|
export var TableRow = /*#__PURE__*/React.forwardRef(function TableRow(_ref, ref) {
|
|
12
|
-
var
|
|
12
|
+
var _ref$warning = _ref.warning,
|
|
13
|
+
warning = _ref$warning === void 0 ? false : _ref$warning,
|
|
14
|
+
className = _ref.className,
|
|
13
15
|
children = _ref.children,
|
|
14
16
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
15
17
|
|
|
16
18
|
return /*#__PURE__*/React.createElement(Base, _extends({
|
|
17
19
|
as: "tr",
|
|
18
20
|
ref: ref,
|
|
19
|
-
className: clsx(className, true && 'govgr-table__row')
|
|
21
|
+
className: clsx(className, warning && 'govgr-table__row--warning', true && 'govgr-table__row')
|
|
20
22
|
}, props), children);
|
|
21
23
|
});
|
|
22
24
|
export default TableRow;
|
package/esm/Unpurge/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
function Unpurge() {
|
|
4
4
|
return /*#__PURE__*/React.createElement("div", {
|
|
5
|
-
className: "\n govgr-m-0 \n govgr-mt-0 \n govgr-mb-0 \n govgr-mr-0 \n govgr-ml-0 \n govgr-p-0 \n govgr-pt-0 \n govgr-pb-0 \n govgr-pr-0 \n govgr-pl-0 \n govgr-m-1 \n govgr-mt-1 \n govgr-mb-1 \n govgr-mr-1 \n govgr-ml-1 \n govgr-p-1 \n govgr-pt-1 \n govgr-pb-1 \n govgr-pr-1 \n govgr-pl-1 \n govgr-m-2 \n govgr-mt-2 \n govgr-mb-2 \n govgr-mr-2 \n govgr-ml-2 \n govgr-p-2 \n govgr-pt-2 \n govgr-pb-2 \n govgr-pr-2 \n govgr-pl-2 \n govgr-m-3 \n govgr-mt-3 \n govgr-mb-3 \n govgr-mr-3 \n govgr-ml-3 \n govgr-p-3 \n govgr-pt-3 \n govgr-pb-3 \n govgr-pr-3 \n govgr-pl-3 \n govgr-m-4 \n govgr-mt-4 \n govgr-mb-4 \n govgr-mr-4 \n govgr-ml-4 \n govgr-p-4 \n govgr-pt-4 \n govgr-pb-4 \n govgr-pr-4 \n govgr-pl-4 \n govgr-m-5 \n govgr-mt-5 \n govgr-mb-5 \n govgr-mr-5 \n govgr-ml-5 \n govgr-p-5 \n govgr-pt-5 \n govgr-pb-5 \n govgr-pr-5 \n govgr-pl-5 \n govgr-m-6 \n govgr-mt-6 \n govgr-mb-6 \n govgr-mr-6 \n govgr-ml-6 \n govgr-p-6 \n govgr-pt-6 \n govgr-pb-6 \n govgr-pr-6 \n govgr-pl-6 \n govgr-m-7 \n govgr-mt-7 \n govgr-mb-7 \n govgr-mr-7 \n govgr-ml-7 \n govgr-p-7 \n govgr-pt-7 \n govgr-pb-7 \n govgr-pr-7 \n govgr-pl-7 \n govgr-m-8 \n govgr-mt-8 \n govgr-mb-8 \n govgr-mr-8 \n govgr-ml-8 \n govgr-
|
|
5
|
+
className: "\n govgr-m-0 \n govgr-mt-0 \n govgr-mb-0 \n govgr-mr-0 \n govgr-ml-0 \n govgr-p-0 \n govgr-pt-0 \n govgr-pb-0 \n govgr-pr-0 \n govgr-pl-0 \n govgr-m-1 \n govgr-mt-1 \n govgr-mb-1 \n govgr-mr-1 \n govgr-ml-1 \n govgr-p-1 \n govgr-pt-1 \n govgr-pb-1 \n govgr-pr-1 \n govgr-pl-1 \n govgr-m-2 \n govgr-mt-2 \n govgr-mb-2 \n govgr-mr-2 \n govgr-ml-2 \n govgr-p-2 \n govgr-pt-2 \n govgr-pb-2 \n govgr-pr-2 \n govgr-pl-2 \n govgr-m-3 \n govgr-mt-3 \n govgr-mb-3 \n govgr-mr-3 \n govgr-ml-3 \n govgr-p-3 \n govgr-pt-3 \n govgr-pb-3 \n govgr-pr-3 \n govgr-pl-3 \n govgr-m-4 \n govgr-mt-4 \n govgr-mb-4 \n govgr-mr-4 \n govgr-ml-4 \n govgr-p-4 \n govgr-pt-4 \n govgr-pb-4 \n govgr-pr-4 \n govgr-pl-4 \n govgr-m-5 \n govgr-mt-5 \n govgr-mb-5 \n govgr-mr-5 \n govgr-ml-5 \n govgr-p-5 \n govgr-pt-5 \n govgr-pb-5 \n govgr-pr-5 \n govgr-pl-5 \n govgr-m-6 \n govgr-mt-6 \n govgr-mb-6 \n govgr-mr-6 \n govgr-ml-6 \n govgr-p-6 \n govgr-pt-6 \n govgr-pb-6 \n govgr-pr-6 \n govgr-pl-6 \n govgr-m-7 \n govgr-mt-7 \n govgr-mb-7 \n govgr-mr-7 \n govgr-ml-7 \n govgr-p-7 \n govgr-pt-7 \n govgr-pb-7 \n govgr-pr-7 \n govgr-pl-7 \n govgr-m-8 \n govgr-mt-8 \n govgr-mb-8 \n govgr-mr-8 \n govgr-ml-8 \n govgr-m-9 \n govgr-mt-9 \n govgr-mb-9 \n govgr-mr-9 \n govgr-ml-9 \n govgr-m-10 \n govgr-mt-10 \n govgr-mb-10 \n govgr-mr-10 \n govgr-ml-10 \n govgr-m-11 \n govgr-mt-11 \n govgr-mb-11 \n govgr-mr-11 \n govgr-ml-11 \n govgr-m-12 \n govgr-mt-12 \n govgr-mb-12 \n govgr-mr-12 \n govgr-ml-12 \n govgr-p-8 \n govgr-pt-8 \n govgr-pb-8 \n govgr-pr-8 \n govgr-pl-8 \n govgr-p-9 \n govgr-pt-9 \n govgr-pb-9 \n govgr-pr-9 \n govgr-pl-9 \n govgr-p-10\n govgr-pt-10\n govgr-pb-10\n govgr-pr-10\n govgr-pl-10\n govgr-p-11\n govgr-pt-11\n govgr-pb-11\n govgr-pr-11\n govgr-pl-11\n govgr-p-12\n govgr-pt-12\n govgr-pb-12\n govgr-pr-12\n govgr-pl-12\n govgr-print-hidden\n "
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
|
package/esm/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/react-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.1",
|
|
4
4
|
"description": "@digigov react core components",
|
|
5
5
|
"author": "GRNET Developers <devs@lists.grnet.gr>",
|
|
6
6
|
"license": "BSD-2-Clause",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"directory": "dist"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"@digigov/css": "0.
|
|
14
|
+
"@digigov/css": "0.33.1",
|
|
15
15
|
"clsx": "1.1.1",
|
|
16
16
|
"react": "^16.8.0 || ^17.0.0",
|
|
17
17
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
@@ -7,6 +7,12 @@ export interface AccordionSectionProps extends BaseProps<'details'> {
|
|
|
7
7
|
* Add this prop when an AccordionSection should be open.
|
|
8
8
|
*/
|
|
9
9
|
open?: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* border is optional. The default value is true.
|
|
13
|
+
* In order to remove top and bottom border, change this value to false.
|
|
14
|
+
*/
|
|
15
|
+
border?: boolean;
|
|
10
16
|
}
|
|
11
17
|
/**
|
|
12
18
|
* AccordionSection should be inside the Accordion component.
|
|
@@ -17,13 +23,17 @@ export interface AccordionSectionProps extends BaseProps<'details'> {
|
|
|
17
23
|
export const AccordionSection = React.forwardRef<
|
|
18
24
|
HTMLDetailsElement,
|
|
19
25
|
AccordionSectionProps
|
|
20
|
-
>(function AccordionSection(
|
|
26
|
+
>(function AccordionSection(
|
|
27
|
+
{ className, border = true, children, ...props },
|
|
28
|
+
ref
|
|
29
|
+
) {
|
|
21
30
|
return (
|
|
22
31
|
<Base
|
|
23
32
|
as="details"
|
|
24
33
|
ref={ref}
|
|
25
34
|
className={clsx(className, {
|
|
26
35
|
'govgr-accordion__section': true,
|
|
36
|
+
'govgr-accordion__section--no-border': !border,
|
|
27
37
|
})}
|
|
28
38
|
{...props}
|
|
29
39
|
>
|
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`renders the CheckboxItem with \`disabled\` prop 1`] = `
|
|
4
|
+
<ForwardRef(CheckboxItem)
|
|
5
|
+
disabled={true}
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="govgr-checkboxes__item"
|
|
9
|
+
>
|
|
10
|
+
<label
|
|
11
|
+
className="govgr-checkboxes__label--disabled govgr-label govgr-checkboxes__label"
|
|
12
|
+
>
|
|
13
|
+
hello
|
|
14
|
+
<ForwardRef(Base)
|
|
15
|
+
as="input"
|
|
16
|
+
className="govgr-checkboxes__input"
|
|
17
|
+
disabled={true}
|
|
18
|
+
type="checkbox"
|
|
19
|
+
>
|
|
20
|
+
<input
|
|
21
|
+
className="govgr-checkboxes__input"
|
|
22
|
+
disabled={true}
|
|
23
|
+
type="checkbox"
|
|
24
|
+
/>
|
|
25
|
+
</ForwardRef(Base)>
|
|
26
|
+
</label>
|
|
27
|
+
</div>
|
|
28
|
+
</ForwardRef(CheckboxItem)>
|
|
29
|
+
`;
|
|
30
|
+
|
|
3
31
|
exports[`renders the CheckboxItem with \`name\` prop 1`] = `
|
|
4
32
|
<ForwardRef(CheckboxItem)
|
|
5
33
|
name="example"
|
|
@@ -14,13 +42,49 @@ exports[`renders the CheckboxItem with \`name\` prop 1`] = `
|
|
|
14
42
|
<ForwardRef(Base)
|
|
15
43
|
as="input"
|
|
16
44
|
className="govgr-checkboxes__input"
|
|
45
|
+
disabled={false}
|
|
46
|
+
name="example"
|
|
47
|
+
type="checkbox"
|
|
48
|
+
>
|
|
49
|
+
<input
|
|
50
|
+
className="govgr-checkboxes__input"
|
|
51
|
+
disabled={false}
|
|
52
|
+
name="example"
|
|
53
|
+
type="checkbox"
|
|
54
|
+
/>
|
|
55
|
+
</ForwardRef(Base)>
|
|
56
|
+
</label>
|
|
57
|
+
</div>
|
|
58
|
+
</ForwardRef(CheckboxItem)>
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
exports[`renders the CheckboxItem with \`value\` \`name\` and \`disabled\` props 1`] = `
|
|
62
|
+
<ForwardRef(CheckboxItem)
|
|
63
|
+
disabled={true}
|
|
64
|
+
name="example"
|
|
65
|
+
value="example"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
className="govgr-checkboxes__item"
|
|
69
|
+
>
|
|
70
|
+
<label
|
|
71
|
+
className="govgr-checkboxes__label--disabled govgr-label govgr-checkboxes__label"
|
|
72
|
+
>
|
|
73
|
+
hello
|
|
74
|
+
<ForwardRef(Base)
|
|
75
|
+
as="input"
|
|
76
|
+
className="govgr-checkboxes__input"
|
|
77
|
+
disabled={true}
|
|
17
78
|
name="example"
|
|
18
79
|
type="checkbox"
|
|
80
|
+
value="example"
|
|
19
81
|
>
|
|
20
82
|
<input
|
|
21
83
|
className="govgr-checkboxes__input"
|
|
84
|
+
disabled={true}
|
|
22
85
|
name="example"
|
|
23
86
|
type="checkbox"
|
|
87
|
+
value="example"
|
|
24
88
|
/>
|
|
25
89
|
</ForwardRef(Base)>
|
|
26
90
|
</label>
|
|
@@ -42,11 +106,13 @@ exports[`renders the CheckboxItem with \`value\` prop 1`] = `
|
|
|
42
106
|
<ForwardRef(Base)
|
|
43
107
|
as="input"
|
|
44
108
|
className="govgr-checkboxes__input"
|
|
109
|
+
disabled={false}
|
|
45
110
|
type="checkbox"
|
|
46
111
|
value="example"
|
|
47
112
|
>
|
|
48
113
|
<input
|
|
49
114
|
className="govgr-checkboxes__input"
|
|
115
|
+
disabled={false}
|
|
50
116
|
type="checkbox"
|
|
51
117
|
value="example"
|
|
52
118
|
/>
|
|
@@ -68,10 +134,12 @@ exports[`renders the CheckboxItem with no props 1`] = `
|
|
|
68
134
|
<ForwardRef(Base)
|
|
69
135
|
as="input"
|
|
70
136
|
className="govgr-checkboxes__input"
|
|
137
|
+
disabled={false}
|
|
71
138
|
type="checkbox"
|
|
72
139
|
>
|
|
73
140
|
<input
|
|
74
141
|
className="govgr-checkboxes__input"
|
|
142
|
+
disabled={false}
|
|
75
143
|
type="checkbox"
|
|
76
144
|
/>
|
|
77
145
|
</ForwardRef(Base)>
|
|
@@ -17,3 +17,17 @@ it('renders the CheckboxItem with `value` prop', () => {
|
|
|
17
17
|
mount(<CheckboxItem value="example">hello</CheckboxItem>)
|
|
18
18
|
).toMatchSnapshot();
|
|
19
19
|
});
|
|
20
|
+
|
|
21
|
+
it('renders the CheckboxItem with `disabled` prop', () => {
|
|
22
|
+
expect(mount(<CheckboxItem disabled>hello</CheckboxItem>)).toMatchSnapshot();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('renders the CheckboxItem with `value` `name` and `disabled` props', () => {
|
|
26
|
+
expect(
|
|
27
|
+
mount(
|
|
28
|
+
<CheckboxItem value="example" name="example" disabled>
|
|
29
|
+
hello
|
|
30
|
+
</CheckboxItem>
|
|
31
|
+
)
|
|
32
|
+
).toMatchSnapshot();
|
|
33
|
+
});
|
|
@@ -12,6 +12,11 @@ export interface CheckboxItemProps 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 checkbox input.
|
|
17
|
+
* disabled property is optional and it is false by default.
|
|
18
|
+
*/
|
|
19
|
+
disabled?: boolean;
|
|
15
20
|
}
|
|
16
21
|
/**
|
|
17
22
|
* Details for the CheckboxItem.
|
|
@@ -21,7 +26,10 @@ export interface CheckboxItemProps extends BaseProps<'input'> {
|
|
|
21
26
|
export const CheckboxItem = React.forwardRef<
|
|
22
27
|
HTMLInputElement,
|
|
23
28
|
CheckboxItemProps
|
|
24
|
-
>(function CheckboxItem(
|
|
29
|
+
>(function CheckboxItem(
|
|
30
|
+
{ name, value, className, disabled = false, children, ...props },
|
|
31
|
+
ref
|
|
32
|
+
) {
|
|
25
33
|
return (
|
|
26
34
|
<div
|
|
27
35
|
className={clsx(className, {
|
|
@@ -31,6 +39,7 @@ export const CheckboxItem = React.forwardRef<
|
|
|
31
39
|
<label
|
|
32
40
|
className={clsx({
|
|
33
41
|
'govgr-label govgr-checkboxes__label': true,
|
|
42
|
+
'govgr-checkboxes__label--disabled': disabled === true,
|
|
34
43
|
})}
|
|
35
44
|
>
|
|
36
45
|
{children}
|
|
@@ -43,6 +52,7 @@ export const CheckboxItem = React.forwardRef<
|
|
|
43
52
|
className={clsx({
|
|
44
53
|
'govgr-checkboxes__input': true,
|
|
45
54
|
})}
|
|
55
|
+
disabled={disabled}
|
|
46
56
|
{...props}
|
|
47
57
|
/>
|
|
48
58
|
</label>
|
|
@@ -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
|
+
});
|
package/src/RadioItem/index.tsx
CHANGED
|
@@ -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(
|
|
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>
|