@digigov/react-core 0.3.1 → 0.5.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/Button/index.d.ts +5 -1
- package/Button/index.js +4 -2
- package/CHANGELOG.md +36 -1
- package/CallToAction/index.js +11 -4
- package/Card/__snapshots__/index.test.tsx.snap +21 -5
- package/Card/index.d.ts +4 -3
- package/Card/index.js +4 -3
- package/Card/index.test.js +10 -2
- package/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
- package/CheckboxConditional/index.d.ts +1 -1
- package/CheckboxConditional/index.js +2 -6
- package/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
- package/CheckboxItem/index.d.ts +5 -5
- package/CheckboxItem/index.js +6 -6
- package/Container/index.d.ts +10 -2
- package/Container/index.js +9 -5
- package/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
- package/DateInputItem/index.d.ts +12 -2
- package/DateInputItem/index.js +7 -4
- package/DateInputItem/index.test.js +9 -0
- package/Field/__snapshots__/index.test.tsx.snap +35 -0
- package/Field/index.d.ts +13 -0
- package/{FormGroup → Field}/index.js +6 -6
- package/{FormGroup → Field}/index.test.d.ts +0 -0
- package/Field/index.test.js +31 -0
- package/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
- package/FieldsetLegend/index.d.ts +4 -4
- package/FieldsetLegend/index.js +9 -8
- package/FieldsetLegend/index.test.js +48 -144
- package/FileUpload/index.d.ts +3 -3
- package/FileUpload/index.js +3 -3
- package/FooterImage/index.d.ts +1 -1
- package/GovGRLogo/index.js +1 -1
- package/Grid/index.d.ts +1 -1
- package/Header/index.js +1 -1
- package/HellenicRepublicLogo/index.d.ts +1 -1
- package/Hidden/index.d.ts +17 -0
- package/Hidden/index.js +47 -0
- package/Hidden/index.test.d.ts +1 -0
- package/Hidden/index.test.js +49 -0
- package/Label/index.d.ts +1 -6
- package/Label/index.js +3 -5
- package/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
- package/LabelTitle/index.d.ts +19 -0
- package/LabelTitle/index.js +41 -0
- package/LabelTitle/index.test.d.ts +1 -0
- package/LabelTitle/index.test.js +91 -0
- package/Masthead/index.js +3 -7
- package/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
- package/RadioConditional/index.d.ts +15 -0
- package/RadioConditional/index.js +42 -0
- package/RadioConditional/index.test.d.ts +1 -0
- package/RadioConditional/index.test.js +23 -0
- package/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
- package/RadioItem/index.d.ts +5 -5
- package/RadioItem/index.js +6 -6
- package/Select/index.d.ts +1 -1
- package/Table/index.d.ts +1 -1
- package/TextArea/index.d.ts +1 -1
- package/TextInput/index.d.ts +1 -1
- package/es/Button/index.js +4 -2
- package/es/CallToAction/index.js +11 -4
- package/es/Card/__snapshots__/index.test.tsx.snap +21 -5
- package/es/Card/index.js +4 -3
- package/es/Card/index.test.js +10 -2
- package/es/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
- package/es/CheckboxConditional/index.js +2 -6
- package/es/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
- package/es/CheckboxItem/index.js +6 -6
- package/es/Container/index.js +9 -5
- package/es/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
- package/es/DateInputItem/index.js +7 -4
- package/es/DateInputItem/index.test.js +9 -0
- package/es/Field/__snapshots__/index.test.tsx.snap +35 -0
- package/es/{FormGroup → Field}/index.js +4 -4
- package/es/Field/index.test.js +25 -0
- package/es/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
- package/es/FieldsetLegend/index.js +9 -8
- package/es/FieldsetLegend/index.test.js +48 -139
- package/es/FileUpload/index.js +3 -3
- package/es/GovGRLogo/index.js +1 -1
- package/es/Header/index.js +1 -1
- package/es/Hidden/index.js +32 -0
- package/es/Hidden/index.test.js +43 -0
- package/es/Label/index.js +3 -5
- package/es/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
- package/es/LabelTitle/index.js +26 -0
- package/es/LabelTitle/index.test.js +85 -0
- package/es/Masthead/index.js +2 -7
- package/es/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
- package/es/RadioConditional/index.js +27 -0
- package/es/RadioConditional/index.test.js +17 -0
- package/es/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
- package/es/RadioItem/index.js +6 -6
- package/es/index.js +4 -1
- package/esm/Button/index.js +4 -2
- package/esm/CallToAction/index.js +11 -4
- package/esm/Card/__snapshots__/index.test.tsx.snap +21 -5
- package/esm/Card/index.js +4 -3
- package/esm/Card/index.test.js +10 -2
- package/esm/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
- package/esm/CheckboxConditional/index.js +2 -6
- package/esm/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
- package/esm/CheckboxItem/index.js +6 -6
- package/esm/Container/index.js +9 -5
- package/esm/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
- package/esm/DateInputItem/index.js +7 -4
- package/esm/DateInputItem/index.test.js +9 -0
- package/esm/Field/__snapshots__/index.test.tsx.snap +35 -0
- package/esm/{FormGroup → Field}/index.js +4 -4
- package/esm/Field/index.test.js +25 -0
- package/esm/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
- package/esm/FieldsetLegend/index.js +9 -8
- package/esm/FieldsetLegend/index.test.js +48 -139
- package/esm/FileUpload/index.js +3 -3
- package/esm/GovGRLogo/index.js +1 -1
- package/esm/Header/index.js +1 -1
- package/esm/Hidden/index.js +32 -0
- package/esm/Hidden/index.test.js +43 -0
- package/esm/Label/index.js +3 -5
- package/esm/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
- package/esm/LabelTitle/index.js +26 -0
- package/esm/LabelTitle/index.test.js +85 -0
- package/esm/Masthead/index.js +2 -7
- package/esm/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
- package/esm/RadioConditional/index.js +27 -0
- package/esm/RadioConditional/index.test.js +17 -0
- package/esm/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
- package/esm/RadioItem/index.js +6 -6
- package/esm/index.js +5 -2
- package/index.d.ts +4 -1
- package/index.js +31 -7
- package/package.json +2 -2
- package/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
- package/FormGroup/index.d.ts +0 -13
- package/FormGroup/index.test.js +0 -31
- package/es/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
- package/es/FormGroup/index.test.js +0 -25
- package/esm/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
- package/esm/FormGroup/index.test.js +0 -25
package/es/Container/index.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
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 = ["cols", "fullWidth", "className", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Container
|
|
8
|
+
* Use Container as a wrapper.
|
|
9
9
|
*/
|
|
10
10
|
export var Container = /*#__PURE__*/React.forwardRef(function Container(_ref, ref) {
|
|
11
|
-
var
|
|
11
|
+
var _ref$cols = _ref.cols,
|
|
12
|
+
cols = _ref$cols === void 0 ? true : _ref$cols,
|
|
13
|
+
_ref$fullWidth = _ref.fullWidth,
|
|
14
|
+
fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
|
|
15
|
+
className = _ref.className,
|
|
12
16
|
children = _ref.children,
|
|
13
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
14
18
|
|
|
15
19
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
16
20
|
ref: ref,
|
|
17
|
-
className: clsx(className,
|
|
21
|
+
className: clsx(className, !fullWidth && 'govgr-width-container', fullWidth && 'govgr-full-width-container')
|
|
18
22
|
}, props), /*#__PURE__*/React.createElement("div", _extends({
|
|
19
|
-
className: clsx(
|
|
23
|
+
className: clsx(cols && 'govgr-main-wrapper')
|
|
20
24
|
}, props), children));
|
|
21
25
|
});
|
|
22
26
|
export default Container;
|
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`renders the DateInputItem with name and width===4 props 1`] = `
|
|
4
|
+
<ForwardRef(DateInputItem)
|
|
5
|
+
name="date-input"
|
|
6
|
+
width={4}
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
className="govgr-date-input__item"
|
|
10
|
+
>
|
|
11
|
+
<label
|
|
12
|
+
className="govgr-label"
|
|
13
|
+
>
|
|
14
|
+
hello
|
|
15
|
+
<input
|
|
16
|
+
className="govgr-input--width-4 govgr-input"
|
|
17
|
+
inputMode="numeric"
|
|
18
|
+
name="date-input"
|
|
19
|
+
pattern="[0-9]*"
|
|
20
|
+
type="text"
|
|
21
|
+
/>
|
|
22
|
+
</label>
|
|
23
|
+
</div>
|
|
24
|
+
</ForwardRef(DateInputItem)>
|
|
25
|
+
`;
|
|
26
|
+
|
|
3
27
|
exports[`renders the DateInputItem with name prop 1`] = `
|
|
4
28
|
<ForwardRef(DateInputItem)
|
|
5
29
|
name="date-input"
|
|
@@ -11,14 +35,14 @@ exports[`renders the DateInputItem with name prop 1`] = `
|
|
|
11
35
|
className="govgr-label"
|
|
12
36
|
>
|
|
13
37
|
hello
|
|
38
|
+
<input
|
|
39
|
+
className="govgr-input--width-2 govgr-input"
|
|
40
|
+
inputMode="numeric"
|
|
41
|
+
name="date-input"
|
|
42
|
+
pattern="[0-9]*"
|
|
43
|
+
type="text"
|
|
44
|
+
/>
|
|
14
45
|
</label>
|
|
15
|
-
<input
|
|
16
|
-
className="govgr-input govgr-input--width-2"
|
|
17
|
-
inputMode="numeric"
|
|
18
|
-
name="date-input"
|
|
19
|
-
pattern="[0-9]*"
|
|
20
|
-
type="text"
|
|
21
|
-
/>
|
|
22
46
|
</div>
|
|
23
47
|
</ForwardRef(DateInputItem)>
|
|
24
48
|
`;
|
|
@@ -32,13 +56,13 @@ exports[`renders the DateInputItem with no props 1`] = `
|
|
|
32
56
|
className="govgr-label"
|
|
33
57
|
>
|
|
34
58
|
hello
|
|
59
|
+
<input
|
|
60
|
+
className="govgr-input--width-2 govgr-input"
|
|
61
|
+
inputMode="numeric"
|
|
62
|
+
pattern="[0-9]*"
|
|
63
|
+
type="text"
|
|
64
|
+
/>
|
|
35
65
|
</label>
|
|
36
|
-
<input
|
|
37
|
-
className="govgr-input govgr-input--width-2"
|
|
38
|
-
inputMode="numeric"
|
|
39
|
-
pattern="[0-9]*"
|
|
40
|
-
type="text"
|
|
41
|
-
/>
|
|
42
66
|
</div>
|
|
43
67
|
</ForwardRef(DateInputItem)>
|
|
44
68
|
`;
|
|
@@ -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", "className", "children"];
|
|
3
|
+
var _excluded = ["name", "width", "error", "className", "children"];
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
|
|
@@ -11,6 +11,9 @@ import clsx from 'clsx';
|
|
|
11
11
|
*/
|
|
12
12
|
export var DateInputItem = /*#__PURE__*/React.forwardRef(function DateInputItem(_ref, ref) {
|
|
13
13
|
var name = _ref.name,
|
|
14
|
+
_ref$width = _ref.width,
|
|
15
|
+
width = _ref$width === void 0 ? 2 : _ref$width,
|
|
16
|
+
error = _ref.error,
|
|
14
17
|
className = _ref.className,
|
|
15
18
|
children = _ref.children,
|
|
16
19
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -20,12 +23,12 @@ export var DateInputItem = /*#__PURE__*/React.forwardRef(function DateInputItem(
|
|
|
20
23
|
className: clsx(className, true && 'govgr-date-input__item')
|
|
21
24
|
}, props), /*#__PURE__*/React.createElement("label", {
|
|
22
25
|
className: clsx(true && 'govgr-label')
|
|
23
|
-
}, children
|
|
26
|
+
}, children, /*#__PURE__*/React.createElement("input", {
|
|
24
27
|
type: "text",
|
|
25
28
|
pattern: "[0-9]*",
|
|
26
29
|
inputMode: "numeric",
|
|
27
30
|
name: name,
|
|
28
|
-
className: clsx(true &&
|
|
29
|
-
}));
|
|
31
|
+
className: clsx(error === true && 'govgr-error-input', width === 2 && 'govgr-input--width-2', width === 4 && 'govgr-input--width-4', true && 'govgr-input')
|
|
32
|
+
})));
|
|
30
33
|
});
|
|
31
34
|
export default DateInputItem;
|
|
@@ -14,4 +14,13 @@ var _ref2 = /*#__PURE__*/React.createElement(DateInputItem, {
|
|
|
14
14
|
|
|
15
15
|
it('renders the DateInputItem with name prop', function () {
|
|
16
16
|
expect(mount(_ref2)).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _ref3 = /*#__PURE__*/React.createElement(DateInputItem, {
|
|
20
|
+
width: 4,
|
|
21
|
+
name: 'date-input'
|
|
22
|
+
}, "hello");
|
|
23
|
+
|
|
24
|
+
it('renders the DateInputItem with name and width===4 props', function () {
|
|
25
|
+
expect(mount(_ref3)).toMatchSnapshot();
|
|
17
26
|
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`renders the Field with error=false 1`] = `
|
|
4
|
+
<ForwardRef(Field)
|
|
5
|
+
error={false}
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="govgr-field"
|
|
9
|
+
>
|
|
10
|
+
hello
|
|
11
|
+
</div>
|
|
12
|
+
</ForwardRef(Field)>
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
exports[`renders the Field with error=true 1`] = `
|
|
16
|
+
<ForwardRef(Field)
|
|
17
|
+
error={true}
|
|
18
|
+
>
|
|
19
|
+
<div
|
|
20
|
+
className="govgr-field__error govgr-field"
|
|
21
|
+
>
|
|
22
|
+
hello
|
|
23
|
+
</div>
|
|
24
|
+
</ForwardRef(Field)>
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`renders the Field with no props 1`] = `
|
|
28
|
+
<ForwardRef(Field)>
|
|
29
|
+
<div
|
|
30
|
+
className="govgr-field"
|
|
31
|
+
>
|
|
32
|
+
hello
|
|
33
|
+
</div>
|
|
34
|
+
</ForwardRef(Field)>
|
|
35
|
+
`;
|
|
@@ -5,9 +5,9 @@ import React from 'react';
|
|
|
5
5
|
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Field component wraps form components such as Checkbox TextInput TextArea etc.
|
|
9
9
|
*/
|
|
10
|
-
export var
|
|
10
|
+
export var Field = /*#__PURE__*/React.forwardRef(function Field(_ref, ref) {
|
|
11
11
|
var error = _ref.error,
|
|
12
12
|
className = _ref.className,
|
|
13
13
|
children = _ref.children,
|
|
@@ -15,7 +15,7 @@ export var FormGroup = /*#__PURE__*/React.forwardRef(function FormGroup(_ref, re
|
|
|
15
15
|
|
|
16
16
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
17
17
|
ref: ref,
|
|
18
|
-
className: clsx(className, error === true && 'govgr-
|
|
18
|
+
className: clsx(className, error === true && 'govgr-field__error', true && 'govgr-field')
|
|
19
19
|
}, props), children);
|
|
20
20
|
});
|
|
21
|
-
export default
|
|
21
|
+
export default Field;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { mount } from 'enzyme';
|
|
3
|
+
import Field from '@digigov/react-core/Field';
|
|
4
|
+
|
|
5
|
+
var _ref = /*#__PURE__*/React.createElement(Field, null, "hello");
|
|
6
|
+
|
|
7
|
+
it('renders the Field with no props', function () {
|
|
8
|
+
expect(mount(_ref)).toMatchSnapshot();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
var _ref2 = /*#__PURE__*/React.createElement(Field, {
|
|
12
|
+
error: true
|
|
13
|
+
}, "hello");
|
|
14
|
+
|
|
15
|
+
it('renders the Field with error=true', function () {
|
|
16
|
+
expect(mount(_ref2)).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _ref3 = /*#__PURE__*/React.createElement(Field, {
|
|
20
|
+
error: false
|
|
21
|
+
}, "hello");
|
|
22
|
+
|
|
23
|
+
it('renders the Field with error=false', function () {
|
|
24
|
+
expect(mount(_ref3)).toMatchSnapshot();
|
|
25
|
+
});
|