@digigov/react-core 0.4.0 → 0.5.2

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 (119) hide show
  1. package/Button/index.d.ts +5 -1
  2. package/Button/index.js +4 -2
  3. package/CHANGELOG.md +33 -1
  4. package/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
  5. package/CheckboxConditional/index.d.ts +1 -1
  6. package/CheckboxConditional/index.js +2 -6
  7. package/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
  8. package/CheckboxItem/index.d.ts +5 -5
  9. package/CheckboxItem/index.js +6 -6
  10. package/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
  11. package/DateInputItem/index.d.ts +12 -2
  12. package/DateInputItem/index.js +7 -4
  13. package/DateInputItem/index.test.js +9 -0
  14. package/Field/__snapshots__/index.test.tsx.snap +35 -0
  15. package/Field/index.d.ts +13 -0
  16. package/{FormGroup → Field}/index.js +6 -6
  17. package/{FormGroup → Field}/index.test.d.ts +0 -0
  18. package/Field/index.test.js +31 -0
  19. package/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
  20. package/FieldsetLegend/index.d.ts +4 -4
  21. package/FieldsetLegend/index.js +9 -8
  22. package/FieldsetLegend/index.test.js +48 -144
  23. package/FileUpload/index.d.ts +3 -3
  24. package/FileUpload/index.js +3 -3
  25. package/FooterImage/index.d.ts +1 -1
  26. package/GovGRLogo/index.js +1 -1
  27. package/Grid/index.d.ts +1 -1
  28. package/Header/index.js +1 -1
  29. package/HellenicRepublicLogo/index.d.ts +1 -1
  30. package/Hidden/index.d.ts +17 -0
  31. package/Hidden/index.js +47 -0
  32. package/Hidden/index.test.d.ts +1 -0
  33. package/Hidden/index.test.js +49 -0
  34. package/Label/index.d.ts +1 -6
  35. package/Label/index.js +3 -5
  36. package/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
  37. package/LabelTitle/index.d.ts +19 -0
  38. package/LabelTitle/index.js +41 -0
  39. package/LabelTitle/index.test.d.ts +1 -0
  40. package/LabelTitle/index.test.js +91 -0
  41. package/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
  42. package/RadioConditional/index.d.ts +15 -0
  43. package/RadioConditional/index.js +42 -0
  44. package/RadioConditional/index.test.d.ts +1 -0
  45. package/RadioConditional/index.test.js +23 -0
  46. package/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
  47. package/RadioItem/index.d.ts +5 -5
  48. package/RadioItem/index.js +6 -6
  49. package/Select/index.d.ts +1 -1
  50. package/TextArea/index.d.ts +1 -1
  51. package/TextInput/index.d.ts +1 -1
  52. package/es/Button/index.js +4 -2
  53. package/es/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
  54. package/es/CheckboxConditional/index.js +2 -6
  55. package/es/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
  56. package/es/CheckboxItem/index.js +6 -6
  57. package/es/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
  58. package/es/DateInputItem/index.js +7 -4
  59. package/es/DateInputItem/index.test.js +9 -0
  60. package/es/Field/__snapshots__/index.test.tsx.snap +35 -0
  61. package/es/{FormGroup → Field}/index.js +4 -4
  62. package/es/Field/index.test.js +25 -0
  63. package/es/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
  64. package/es/FieldsetLegend/index.js +9 -8
  65. package/es/FieldsetLegend/index.test.js +48 -139
  66. package/es/FileUpload/index.js +3 -3
  67. package/es/GovGRLogo/index.js +1 -1
  68. package/es/Header/index.js +1 -1
  69. package/es/Hidden/index.js +32 -0
  70. package/es/Hidden/index.test.js +43 -0
  71. package/es/Label/index.js +3 -5
  72. package/es/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
  73. package/es/LabelTitle/index.js +26 -0
  74. package/es/LabelTitle/index.test.js +85 -0
  75. package/es/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
  76. package/es/RadioConditional/index.js +27 -0
  77. package/es/RadioConditional/index.test.js +17 -0
  78. package/es/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
  79. package/es/RadioItem/index.js +6 -6
  80. package/es/index.js +4 -1
  81. package/esm/Button/index.js +4 -2
  82. package/esm/CheckboxConditional/__snapshots__/index.test.tsx.snap +2 -11
  83. package/esm/CheckboxConditional/index.js +2 -6
  84. package/esm/CheckboxItem/__snapshots__/index.test.tsx.snap +14 -14
  85. package/esm/CheckboxItem/index.js +6 -6
  86. package/esm/DateInputItem/__snapshots__/index.test.tsx.snap +37 -13
  87. package/esm/DateInputItem/index.js +7 -4
  88. package/esm/DateInputItem/index.test.js +9 -0
  89. package/esm/Field/__snapshots__/index.test.tsx.snap +35 -0
  90. package/esm/{FormGroup → Field}/index.js +4 -4
  91. package/esm/Field/index.test.js +25 -0
  92. package/esm/FieldsetLegend/__snapshots__/index.test.tsx.snap +102 -876
  93. package/esm/FieldsetLegend/index.js +9 -8
  94. package/esm/FieldsetLegend/index.test.js +48 -139
  95. package/esm/FileUpload/index.js +3 -3
  96. package/esm/GovGRLogo/index.js +1 -1
  97. package/esm/Header/index.js +1 -1
  98. package/esm/Hidden/index.js +32 -0
  99. package/esm/Hidden/index.test.js +43 -0
  100. package/esm/Label/index.js +3 -5
  101. package/esm/LabelTitle/__snapshots__/index.test.tsx.snap +133 -0
  102. package/esm/LabelTitle/index.js +26 -0
  103. package/esm/LabelTitle/index.test.js +85 -0
  104. package/esm/RadioConditional/__snapshots__/index.test.tsx.snap +39 -0
  105. package/esm/RadioConditional/index.js +27 -0
  106. package/esm/RadioConditional/index.test.js +17 -0
  107. package/esm/RadioItem/__snapshots__/index.test.tsx.snap +20 -20
  108. package/esm/RadioItem/index.js +6 -6
  109. package/esm/index.js +5 -2
  110. package/index.d.ts +4 -1
  111. package/index.js +31 -7
  112. package/package.json +2 -2
  113. package/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
  114. package/FormGroup/index.d.ts +0 -13
  115. package/FormGroup/index.test.js +0 -31
  116. package/es/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
  117. package/es/FormGroup/index.test.js +0 -25
  118. package/esm/FormGroup/__snapshots__/index.test.tsx.snap +0 -35
  119. package/esm/FormGroup/index.test.js +0 -25
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders the Blockquote with name prop 1`] = `
4
+ <ForwardRef(RadioConditional)
5
+ name="some-name"
6
+ >
7
+ <div
8
+ className="govgr-radios__conditional"
9
+ >
10
+ <div
11
+ className="govgr-field"
12
+ >
13
+ <label
14
+ className="govgr-label"
15
+ >
16
+ hello
17
+ </label>
18
+ </div>
19
+ </div>
20
+ </ForwardRef(RadioConditional)>
21
+ `;
22
+
23
+ exports[`renders the Blockquote with no props 1`] = `
24
+ <ForwardRef(RadioConditional)>
25
+ <div
26
+ className="govgr-radios__conditional"
27
+ >
28
+ <div
29
+ className="govgr-field"
30
+ >
31
+ <label
32
+ className="govgr-label"
33
+ >
34
+ hello
35
+ </label>
36
+ </div>
37
+ </div>
38
+ </ForwardRef(RadioConditional)>
39
+ `;
@@ -0,0 +1,27 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["name", "className", "children"];
4
+ import React from 'react';
5
+ import clsx from 'clsx';
6
+
7
+ /**
8
+ * RadioConditional asks the user a related question when they select a particular radios,
9
+ * so they only see the question when it’s relevant to them.
10
+ * RadioConditional must be used inside Radio component
11
+ */
12
+ export var RadioConditional = /*#__PURE__*/React.forwardRef(function RadioConditional(_ref, ref) {
13
+ var name = _ref.name,
14
+ className = _ref.className,
15
+ children = _ref.children,
16
+ props = _objectWithoutProperties(_ref, _excluded);
17
+
18
+ return /*#__PURE__*/React.createElement("div", _extends({
19
+ ref: ref,
20
+ className: clsx(className, true && 'govgr-radios__conditional')
21
+ }, props), /*#__PURE__*/React.createElement("div", {
22
+ className: clsx(true && 'govgr-field')
23
+ }, /*#__PURE__*/React.createElement("label", {
24
+ className: clsx(true && 'govgr-label')
25
+ }, children)));
26
+ });
27
+ export default RadioConditional;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { mount } from 'enzyme';
3
+ import RadioConditional from '@digigov/react-core/RadioConditional';
4
+
5
+ var _ref = /*#__PURE__*/React.createElement(RadioConditional, null, "hello");
6
+
7
+ it('renders the Blockquote with no props', function () {
8
+ expect(mount(_ref)).toMatchSnapshot();
9
+ });
10
+
11
+ var _ref2 = /*#__PURE__*/React.createElement(RadioConditional, {
12
+ name: 'some-name'
13
+ }, "hello");
14
+
15
+ it('renders the Blockquote with name prop', function () {
16
+ expect(mount(_ref2)).toMatchSnapshot();
17
+ });
@@ -7,15 +7,15 @@ exports[`renders the RadioItem value props 1`] = `
7
7
  <div
8
8
  className="govgr-radios__item"
9
9
  >
10
- <input
11
- className="govgr-radios__input"
12
- type="radio"
13
- value="someValue"
14
- />
15
10
  <label
16
11
  className="govgr-label govgr-radios__label"
17
12
  >
18
13
  hello
14
+ <input
15
+ className="govgr-radios__input"
16
+ type="radio"
17
+ value="someValue"
18
+ />
19
19
  </label>
20
20
  </div>
21
21
  </ForwardRef(RadioItem)>
@@ -28,15 +28,15 @@ exports[`renders the RadioItem with name props 1`] = `
28
28
  <div
29
29
  className="govgr-radios__item"
30
30
  >
31
- <input
32
- className="govgr-radios__input"
33
- name="name"
34
- type="radio"
35
- />
36
31
  <label
37
32
  className="govgr-label govgr-radios__label"
38
33
  >
39
34
  hello
35
+ <input
36
+ className="govgr-radios__input"
37
+ name="name"
38
+ type="radio"
39
+ />
40
40
  </label>
41
41
  </div>
42
42
  </ForwardRef(RadioItem)>
@@ -50,16 +50,16 @@ exports[`renders the RadioItem with name and value props 1`] = `
50
50
  <div
51
51
  className="govgr-radios__item"
52
52
  >
53
- <input
54
- className="govgr-radios__input"
55
- name="name"
56
- type="radio"
57
- value="someValue"
58
- />
59
53
  <label
60
54
  className="govgr-label govgr-radios__label"
61
55
  >
62
56
  hello
57
+ <input
58
+ className="govgr-radios__input"
59
+ name="name"
60
+ type="radio"
61
+ value="someValue"
62
+ />
63
63
  </label>
64
64
  </div>
65
65
  </ForwardRef(RadioItem)>
@@ -70,14 +70,14 @@ exports[`renders the RadioItem with no props 1`] = `
70
70
  <div
71
71
  className="govgr-radios__item"
72
72
  >
73
- <input
74
- className="govgr-radios__input"
75
- type="radio"
76
- />
77
73
  <label
78
74
  className="govgr-label govgr-radios__label"
79
75
  >
80
76
  hello
77
+ <input
78
+ className="govgr-radios__input"
79
+ type="radio"
80
+ />
81
81
  </label>
82
82
  </div>
83
83
  </ForwardRef(RadioItem)>
@@ -15,16 +15,16 @@ export var RadioItem = /*#__PURE__*/React.forwardRef(function RadioItem(_ref, re
15
15
  children = _ref.children,
16
16
  props = _objectWithoutProperties(_ref, _excluded);
17
17
 
18
- return /*#__PURE__*/React.createElement("div", _extends({
19
- ref: ref,
18
+ return /*#__PURE__*/React.createElement("div", {
20
19
  className: clsx(className, true && 'govgr-radios__item')
21
- }, props), /*#__PURE__*/React.createElement("input", {
20
+ }, /*#__PURE__*/React.createElement("label", {
21
+ className: clsx(true && 'govgr-label govgr-radios__label')
22
+ }, children, /*#__PURE__*/React.createElement("input", _extends({
23
+ ref: ref,
22
24
  type: "radio",
23
25
  name: name,
24
26
  value: value,
25
27
  className: clsx(true && 'govgr-radios__input')
26
- }), /*#__PURE__*/React.createElement("label", {
27
- className: clsx(true && 'govgr-label govgr-radios__label')
28
- }, children));
28
+ }, props))));
29
29
  });
30
30
  export default RadioItem;
package/es/index.js CHANGED
@@ -52,7 +52,7 @@ export { default as FooterMeta } from '@digigov/react-core/FooterMeta';
52
52
  export { default as FooterMetaItem } from '@digigov/react-core/FooterMetaItem';
53
53
  export { default as FooterNavigation } from '@digigov/react-core/FooterNavigation';
54
54
  export { default as FooterSection } from '@digigov/react-core/FooterSection';
55
- export { default as FormGroup } from '@digigov/react-core/FormGroup';
55
+ export { default as Field } from '@digigov/react-core/Field';
56
56
  export { default as GovGRFooter } from '@digigov/react-core/GovGRFooter';
57
57
  export { default as GovGRLogo } from '@digigov/react-core/GovGRLogo';
58
58
  export { default as Grid } from '@digigov/react-core/Grid';
@@ -66,8 +66,10 @@ export { default as HeaderTitle } from '@digigov/react-core/HeaderTitle';
66
66
  export { default as Heading } from '@digigov/react-core/Heading';
67
67
  export { default as HeadingCaption } from '@digigov/react-core/HeadingCaption';
68
68
  export { default as HellenicRepublicLogo } from '@digigov/react-core/HellenicRepublicLogo';
69
+ export { default as Hidden } from '@digigov/react-core/Hidden';
69
70
  export { default as Hint } from '@digigov/react-core/Hint';
70
71
  export { default as Label } from '@digigov/react-core/Label';
72
+ export { default as LabelTitle } from '@digigov/react-core/LabelTitle';
71
73
  export { default as Layout } from '@digigov/react-core/Layout';
72
74
  export { default as Link } from '@digigov/react-core/Link';
73
75
  export { default as List } from '@digigov/react-core/List';
@@ -96,6 +98,7 @@ export { default as PhaseBannerTag } from '@digigov/react-core/PhaseBannerTag';
96
98
  export { default as PhaseBannerText } from '@digigov/react-core/PhaseBannerText';
97
99
  export { default as Radio } from '@digigov/react-core/Radio';
98
100
  export { default as RadioItem } from '@digigov/react-core/RadioItem';
101
+ export { default as RadioConditional } from '@digigov/react-core/RadioConditional';
99
102
  export { default as SectionBreak } from '@digigov/react-core/SectionBreak';
100
103
  export { default as Select } from '@digigov/react-core/Select';
101
104
  export { default as SelectOption } from '@digigov/react-core/SelectOption';
@@ -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 = ["color", "disabled", "className", "children"];
3
+ var _excluded = ["color", "variant", "disabled", "className", "children"];
4
4
  import React from 'react';
5
5
  import clsx from 'clsx';
6
6
 
@@ -10,6 +10,8 @@ import clsx from 'clsx';
10
10
  export var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
11
11
  var _ref$color = _ref.color,
12
12
  color = _ref$color === void 0 ? 'primary' : _ref$color,
13
+ _ref$variant = _ref.variant,
14
+ variant = _ref$variant === void 0 ? 'button' : _ref$variant,
13
15
  disabled = _ref.disabled,
14
16
  className = _ref.className,
15
17
  children = _ref.children,
@@ -18,7 +20,7 @@ export var Button = /*#__PURE__*/React.forwardRef(function Button(_ref, ref) {
18
20
  return /*#__PURE__*/React.createElement("button", _extends({
19
21
  disabled: disabled,
20
22
  ref: ref,
21
- className: clsx(className, color === 'secondary' && 'govgr-btn-secondary', color === 'primary' && 'govgr-btn-primary', color === 'warning' && 'govgr-btn-warning', disabled === true && 'govgr-btn-disabled', true && 'govgr-btn')
23
+ className: clsx(className, variant === 'button' && [color === 'secondary' && 'govgr-btn-secondary', color === 'primary' && 'govgr-btn-primary', color === 'warning' && 'govgr-btn-warning', disabled === true && 'govgr-btn-disabled', 'govgr-btn'], variant === 'link' && 'govgr-link')
22
24
  }, props), children);
23
25
  });
24
26
  export default Button;
@@ -8,18 +8,13 @@ exports[`renders the Blockquote with name prop 1`] = `
8
8
  className="govgr-checkboxes__conditional"
9
9
  >
10
10
  <div
11
- className="govgr-form-group"
11
+ className="govgr-field"
12
12
  >
13
13
  <label
14
14
  className="govgr-label"
15
15
  >
16
16
  hello
17
17
  </label>
18
- <input
19
- className="govgr-input govgr-!-width-one-third"
20
- name="some-name"
21
- type="text"
22
- />
23
18
  </div>
24
19
  </div>
25
20
  </ForwardRef(CheckboxConditional)>
@@ -31,17 +26,13 @@ exports[`renders the Blockquote with no props 1`] = `
31
26
  className="govgr-checkboxes__conditional"
32
27
  >
33
28
  <div
34
- className="govgr-form-group"
29
+ className="govgr-field"
35
30
  >
36
31
  <label
37
32
  className="govgr-label"
38
33
  >
39
34
  hello
40
35
  </label>
41
- <input
42
- className="govgr-input govgr-!-width-one-third"
43
- type="text"
44
- />
45
36
  </div>
46
37
  </div>
47
38
  </ForwardRef(CheckboxConditional)>
@@ -19,13 +19,9 @@ export var CheckboxConditional = /*#__PURE__*/React.forwardRef(function Checkbox
19
19
  ref: ref,
20
20
  className: clsx(className, true && 'govgr-checkboxes__conditional')
21
21
  }, props), /*#__PURE__*/React.createElement("div", {
22
- className: clsx(true && 'govgr-form-group')
22
+ className: clsx(true && 'govgr-field')
23
23
  }, /*#__PURE__*/React.createElement("label", {
24
24
  className: clsx(true && 'govgr-label')
25
- }, children), /*#__PURE__*/React.createElement("input", {
26
- type: "text",
27
- name: name,
28
- className: clsx(true && 'govgr-input govgr-!-width-one-third')
29
- })));
25
+ }, children)));
30
26
  });
31
27
  export default CheckboxConditional;
@@ -7,15 +7,15 @@ exports[`renders the CheckboxItem with \`name\` prop 1`] = `
7
7
  <div
8
8
  className="govgr-checkboxes__item"
9
9
  >
10
- <input
11
- className="govgr-checkboxes__input"
12
- name="example"
13
- type="checkbox"
14
- />
15
10
  <label
16
11
  className="govgr-label govgr-checkboxes__label"
17
12
  >
18
13
  hello
14
+ <input
15
+ className="govgr-checkboxes__input"
16
+ name="example"
17
+ type="checkbox"
18
+ />
19
19
  </label>
20
20
  </div>
21
21
  </ForwardRef(CheckboxItem)>
@@ -28,15 +28,15 @@ exports[`renders the CheckboxItem with \`value\` prop 1`] = `
28
28
  <div
29
29
  className="govgr-checkboxes__item"
30
30
  >
31
- <input
32
- className="govgr-checkboxes__input"
33
- type="checkbox"
34
- value="example"
35
- />
36
31
  <label
37
32
  className="govgr-label govgr-checkboxes__label"
38
33
  >
39
34
  hello
35
+ <input
36
+ className="govgr-checkboxes__input"
37
+ type="checkbox"
38
+ value="example"
39
+ />
40
40
  </label>
41
41
  </div>
42
42
  </ForwardRef(CheckboxItem)>
@@ -47,14 +47,14 @@ exports[`renders the CheckboxItem with no props 1`] = `
47
47
  <div
48
48
  className="govgr-checkboxes__item"
49
49
  >
50
- <input
51
- className="govgr-checkboxes__input"
52
- type="checkbox"
53
- />
54
50
  <label
55
51
  className="govgr-label govgr-checkboxes__label"
56
52
  >
57
53
  hello
54
+ <input
55
+ className="govgr-checkboxes__input"
56
+ type="checkbox"
57
+ />
58
58
  </label>
59
59
  </div>
60
60
  </ForwardRef(CheckboxItem)>
@@ -16,16 +16,16 @@ export var CheckboxItem = /*#__PURE__*/React.forwardRef(function CheckboxItem(_r
16
16
  children = _ref.children,
17
17
  props = _objectWithoutProperties(_ref, _excluded);
18
18
 
19
- return /*#__PURE__*/React.createElement("div", _extends({
20
- ref: ref,
19
+ return /*#__PURE__*/React.createElement("div", {
21
20
  className: clsx(className, true && 'govgr-checkboxes__item')
22
- }, props), /*#__PURE__*/React.createElement("input", {
21
+ }, /*#__PURE__*/React.createElement("label", {
22
+ className: clsx(true && 'govgr-label govgr-checkboxes__label')
23
+ }, children, /*#__PURE__*/React.createElement("input", _extends({
24
+ ref: ref,
23
25
  type: "checkbox",
24
26
  name: name,
25
27
  value: value,
26
28
  className: clsx(true && 'govgr-checkboxes__input')
27
- }), /*#__PURE__*/React.createElement("label", {
28
- className: clsx(true && 'govgr-label govgr-checkboxes__label')
29
- }, children));
29
+ }, props))));
30
30
  });
31
31
  export default CheckboxItem;
@@ -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), /*#__PURE__*/React.createElement("input", {
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 && ['govgr-input', 'govgr-input--width-2'])
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
- * FormGroup component wraps components such as Checkbox.
8
+ * Field component wraps form components such as Checkbox TextInput TextArea etc.
9
9
  */
10
- export var FormGroup = /*#__PURE__*/React.forwardRef(function FormGroup(_ref, ref) {
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-form-group__error', true && 'govgr-form-group')
18
+ className: clsx(className, error === true && 'govgr-field__error', true && 'govgr-field')
19
19
  }, props), children);
20
20
  });
21
- export default FormGroup;
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
+ });