@digigov/form 0.8.4 → 0.8.5
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/CHANGELOG.md +9 -1
- package/Field/utils.js +1 -0
- package/FieldArray/FieldArray.stories.playwright.json +168 -0
- package/FieldArray/__stories__/Default.js +3 -5
- package/FieldArray/__stories__/WithExactLength.js +3 -5
- package/FieldArray/index.js +1 -0
- package/FieldObject/index.js +1 -2
- package/{FormBuilder.d.ts → FormBuilder/FormBuilder.d.ts} +0 -0
- package/{FormBuilder.js → FormBuilder/FormBuilder.js} +0 -0
- package/FormBuilder/FormBuilder.mdx +271 -0
- package/FormBuilder/FormBuilder.stories.d.ts +7 -0
- package/FormBuilder/FormBuilder.stories.js +30 -0
- package/FormBuilder/__stories__/Default.d.ts +2 -0
- package/FormBuilder/__stories__/Default.js +45 -0
- package/FormBuilder/index.d.ts +2 -0
- package/FormBuilder/index.js +11 -0
- package/MultiplicityField/MultiplicityField.mdx +148 -0
- package/MultiplicityField/__stories__/Default.js +3 -5
- package/MultiplicityField/__stories__/WithExactLength.js +3 -5
- package/MultiplicityField/__stories__/WithMaxLength.js +3 -5
- package/MultiplicityField/__stories__/WithMinAndMaxLength.js +3 -5
- package/MultiplicityField/__stories__/WithMinLength.js +3 -5
- package/Questions/Step/StepArrayReview.js +2 -2
- package/Questions/__snapshots__/index.spec.tsx.snap +649 -449
- package/Questions/index.mdx +0 -187
- package/create-simple-form.mdx +515 -0
- package/es/Field/utils.js +1 -0
- package/es/FieldArray/FieldArray.stories.playwright.json +168 -0
- package/es/FieldArray/__stories__/Default.js +3 -5
- package/es/FieldArray/__stories__/WithExactLength.js +3 -5
- package/es/FieldArray/index.js +1 -0
- package/es/FieldObject/index.js +1 -2
- package/es/{FormBuilder.js → FormBuilder/FormBuilder.js} +0 -0
- package/es/FormBuilder/FormBuilder.mdx +271 -0
- package/es/FormBuilder/FormBuilder.stories.js +6 -0
- package/es/FormBuilder/__stories__/Default.js +25 -0
- package/es/FormBuilder/index.js +2 -0
- package/es/MultiplicityField/MultiplicityField.mdx +148 -0
- package/es/MultiplicityField/__stories__/Default.js +3 -5
- package/es/MultiplicityField/__stories__/WithExactLength.js +3 -5
- package/es/MultiplicityField/__stories__/WithMaxLength.js +3 -5
- package/es/MultiplicityField/__stories__/WithMinAndMaxLength.js +3 -5
- package/es/MultiplicityField/__stories__/WithMinLength.js +3 -5
- package/es/Questions/Step/StepArrayReview.js +1 -1
- package/es/Questions/__snapshots__/index.spec.tsx.snap +649 -449
- package/es/Questions/index.mdx +0 -187
- package/es/create-simple-form.mdx +515 -0
- package/es/index.mdx +37 -199
- package/es/inputs/Checkboxes/Checkboxes.stories.js +6 -0
- package/es/inputs/Checkboxes/__stories__/Default.js +43 -0
- package/es/inputs/DateInput/DateInput.stories.js +6 -0
- package/es/inputs/DateInput/__stories__/Default.js +44 -0
- package/es/inputs/Input/Input.stories.js +13 -0
- package/es/inputs/Input/__stories__/AFM.js +25 -0
- package/es/inputs/Input/__stories__/Boolean.js +26 -0
- package/es/inputs/Input/__stories__/Default.js +26 -0
- package/es/inputs/Input/__stories__/IBAN.js +26 -0
- package/es/inputs/Input/__stories__/Integer.js +26 -0
- package/es/inputs/Input/__stories__/MobilePhone.js +25 -0
- package/es/inputs/Input/__stories__/PhoneNumber.js +25 -0
- package/es/inputs/Input/__stories__/PostalCode.js +28 -0
- package/es/inputs/Input/index.mdx +0 -2
- package/es/inputs/Label/Label.stories.js +6 -0
- package/es/inputs/Label/__stories__/Default.js +30 -0
- package/es/inputs/Radio/Radio.stories.js +6 -0
- package/es/inputs/Radio/__stories__/Default.js +48 -0
- package/es/inputs/Select/Select.stories.js +6 -0
- package/es/inputs/Select/__stories__/Default.js +54 -0
- package/es/installation.mdx +72 -0
- package/es/registry.js +129 -0
- package/esm/Field/utils.js +1 -0
- package/esm/FieldArray/FieldArray.stories.playwright.json +168 -0
- package/esm/FieldArray/__stories__/Default.js +3 -5
- package/esm/FieldArray/__stories__/WithExactLength.js +3 -5
- package/esm/FieldArray/index.js +1 -0
- package/esm/FieldObject/index.js +1 -2
- package/esm/{FormBuilder.js → FormBuilder/FormBuilder.js} +0 -0
- package/esm/FormBuilder/FormBuilder.mdx +271 -0
- package/esm/FormBuilder/FormBuilder.stories.js +6 -0
- package/esm/FormBuilder/__stories__/Default.js +25 -0
- package/esm/FormBuilder/index.js +2 -0
- package/esm/MultiplicityField/MultiplicityField.mdx +148 -0
- package/esm/MultiplicityField/__stories__/Default.js +3 -5
- package/esm/MultiplicityField/__stories__/WithExactLength.js +3 -5
- package/esm/MultiplicityField/__stories__/WithMaxLength.js +3 -5
- package/esm/MultiplicityField/__stories__/WithMinAndMaxLength.js +3 -5
- package/esm/MultiplicityField/__stories__/WithMinLength.js +3 -5
- package/esm/Questions/Step/StepArrayReview.js +1 -1
- package/esm/Questions/__snapshots__/index.spec.tsx.snap +649 -449
- package/esm/Questions/index.mdx +0 -187
- package/esm/create-simple-form.mdx +515 -0
- package/esm/index.js +1 -1
- package/esm/index.mdx +37 -199
- package/esm/inputs/Checkboxes/Checkboxes.stories.js +6 -0
- package/esm/inputs/Checkboxes/__stories__/Default.js +43 -0
- package/esm/inputs/DateInput/DateInput.stories.js +6 -0
- package/esm/inputs/DateInput/__stories__/Default.js +44 -0
- package/esm/inputs/Input/Input.stories.js +13 -0
- package/esm/inputs/Input/__stories__/AFM.js +25 -0
- package/esm/inputs/Input/__stories__/Boolean.js +26 -0
- package/esm/inputs/Input/__stories__/Default.js +26 -0
- package/esm/inputs/Input/__stories__/IBAN.js +26 -0
- package/esm/inputs/Input/__stories__/Integer.js +26 -0
- package/esm/inputs/Input/__stories__/MobilePhone.js +25 -0
- package/esm/inputs/Input/__stories__/PhoneNumber.js +25 -0
- package/esm/inputs/Input/__stories__/PostalCode.js +28 -0
- package/esm/inputs/Input/index.mdx +0 -2
- package/esm/inputs/Label/Label.stories.js +6 -0
- package/esm/inputs/Label/__stories__/Default.js +30 -0
- package/esm/inputs/Radio/Radio.stories.js +6 -0
- package/esm/inputs/Radio/__stories__/Default.js +48 -0
- package/esm/inputs/Select/Select.stories.js +6 -0
- package/esm/inputs/Select/__stories__/Default.js +54 -0
- package/esm/installation.mdx +72 -0
- package/esm/registry.js +129 -0
- package/index.mdx +37 -199
- package/inputs/Checkboxes/Checkboxes.stories.d.ts +7 -0
- package/inputs/Checkboxes/Checkboxes.stories.js +30 -0
- package/inputs/Checkboxes/__stories__/Default.d.ts +2 -0
- package/inputs/Checkboxes/__stories__/Default.js +63 -0
- package/inputs/DateInput/DateInput.stories.d.ts +7 -0
- package/inputs/DateInput/DateInput.stories.js +30 -0
- package/inputs/DateInput/__stories__/Default.d.ts +2 -0
- package/inputs/DateInput/__stories__/Default.js +64 -0
- package/inputs/Input/Input.stories.d.ts +14 -0
- package/inputs/Input/Input.stories.js +128 -0
- package/inputs/Input/__stories__/AFM.d.ts +2 -0
- package/inputs/Input/__stories__/AFM.js +45 -0
- package/inputs/Input/__stories__/Boolean.d.ts +2 -0
- package/inputs/Input/__stories__/Boolean.js +46 -0
- package/inputs/Input/__stories__/Default.d.ts +2 -0
- package/inputs/Input/__stories__/Default.js +46 -0
- package/inputs/Input/__stories__/IBAN.d.ts +2 -0
- package/inputs/Input/__stories__/IBAN.js +46 -0
- package/inputs/Input/__stories__/Integer.d.ts +2 -0
- package/inputs/Input/__stories__/Integer.js +46 -0
- package/inputs/Input/__stories__/MobilePhone.d.ts +2 -0
- package/inputs/Input/__stories__/MobilePhone.js +45 -0
- package/inputs/Input/__stories__/PhoneNumber.d.ts +2 -0
- package/inputs/Input/__stories__/PhoneNumber.js +45 -0
- package/inputs/Input/__stories__/PostalCode.d.ts +2 -0
- package/inputs/Input/__stories__/PostalCode.js +48 -0
- package/inputs/Input/index.mdx +0 -2
- package/inputs/Label/Label.stories.d.ts +7 -0
- package/inputs/Label/Label.stories.js +30 -0
- package/inputs/Label/__stories__/Default.d.ts +2 -0
- package/inputs/Label/__stories__/Default.js +50 -0
- package/inputs/Radio/Radio.stories.d.ts +7 -0
- package/inputs/Radio/Radio.stories.js +30 -0
- package/inputs/Radio/__stories__/Default.d.ts +2 -0
- package/inputs/Radio/__stories__/Default.js +68 -0
- package/inputs/Select/Select.stories.d.ts +7 -0
- package/inputs/Select/Select.stories.js +30 -0
- package/inputs/Select/__stories__/Default.d.ts +2 -0
- package/inputs/Select/__stories__/Default.js +74 -0
- package/installation.mdx +72 -0
- package/package.json +6 -6
- package/registry.d.ts +59 -0
- package/registry.js +198 -0
- package/types.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Change Log - @digigov/form
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 27 Sep 2022 10:00:49 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.8.5
|
|
6
|
+
Tue, 27 Sep 2022 10:00:49 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- consider all custom inline inputs as controlled
|
|
11
|
+
- increase the range of accepted react version specified in peerDependencies
|
|
4
12
|
|
|
5
13
|
## 0.8.4
|
|
6
14
|
Wed, 21 Sep 2022 14:27:06 GMT
|
package/Field/utils.js
CHANGED
|
@@ -75,6 +75,7 @@ function calculateField(children, field, componentRegistry) {
|
|
|
75
75
|
|
|
76
76
|
if (children) {
|
|
77
77
|
calculatedField.component = children;
|
|
78
|
+
calculatedField.controlled = true;
|
|
78
79
|
} else if (typeof field.component === 'function') {// leave as is
|
|
79
80
|
} else if (!field.component && !field.type) {
|
|
80
81
|
var _fieldComponentRegist;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "4",
|
|
3
|
+
"stories": {
|
|
4
|
+
"digigov-form-fieldarray--default": {
|
|
5
|
+
"actionSets": [
|
|
6
|
+
{
|
|
7
|
+
"actions": [
|
|
8
|
+
{
|
|
9
|
+
"name": "click",
|
|
10
|
+
"args": {
|
|
11
|
+
"selector": "html>body>div:nth-child(5)>form>div:nth-child(2)>fieldset>button"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"name": "click",
|
|
16
|
+
"args": {
|
|
17
|
+
"selector": "html>body>div:nth-child(5)>form>button"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "waitForSelector",
|
|
22
|
+
"args": {
|
|
23
|
+
"selector": "text=Το πεδίο πρέπει να έχει τουλάχιστον 2 εγγραφές. Προσθέστε μια ακόμα επιλέγοντας την απάντηση «Ναι» στην επόμενη ερώτηση.",
|
|
24
|
+
"options": {
|
|
25
|
+
"state": "visible"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "click",
|
|
31
|
+
"args": {
|
|
32
|
+
"selector": "html>body>div:nth-child(5)>form>div:nth-child(2)>fieldset>button",
|
|
33
|
+
"options": {
|
|
34
|
+
"clickCount": 2
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "click",
|
|
40
|
+
"args": {
|
|
41
|
+
"selector": "text=Συνέχεια"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "waitForSelector",
|
|
46
|
+
"args": {
|
|
47
|
+
"selector": "text=Το πεδίο είναι υποχρεωτικό.",
|
|
48
|
+
"options": {
|
|
49
|
+
"state": "visible"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "type",
|
|
55
|
+
"args": {
|
|
56
|
+
"selector": "html>body>div:nth-child(5)>form>div:nth-child(3)>label>input",
|
|
57
|
+
"text": "2107474274"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "click",
|
|
62
|
+
"args": {
|
|
63
|
+
"selector": "html>body>div:nth-child(5)>form>button"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"id": "iMmV-vvS4iNn",
|
|
68
|
+
"title": "Add new items to FieldArray"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"digigov-form-fieldarray--with-exact-length": {
|
|
73
|
+
"actionSets": [
|
|
74
|
+
{
|
|
75
|
+
"actions": [
|
|
76
|
+
{
|
|
77
|
+
"name": "click",
|
|
78
|
+
"args": {
|
|
79
|
+
"selector": "text=Προσθήκη συνυπογράφοντα"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "type",
|
|
84
|
+
"args": {
|
|
85
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 1\") .govgr-field:has-text(\"ΑΦΜ\") input",
|
|
86
|
+
"text": "094536469"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "type",
|
|
91
|
+
"args": {
|
|
92
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 1\") .govgr-field:has-text(\"Όνομα\") input",
|
|
93
|
+
"text": "Γιάννης"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "type",
|
|
98
|
+
"args": {
|
|
99
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 1\") .govgr-field:has-text(\"Επώνυμο\") input",
|
|
100
|
+
"text": "Δόες"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "click",
|
|
105
|
+
"args": {
|
|
106
|
+
"selector": "html>body>div:nth-child(5)>form>button"
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "type",
|
|
111
|
+
"args": {
|
|
112
|
+
"selector": ".govgr-field:has-text(\"Πεδίο 2\") input",
|
|
113
|
+
"text": "2107474274"
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "click",
|
|
118
|
+
"args": {
|
|
119
|
+
"selector": "text=Συνέχεια"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"name": "click",
|
|
124
|
+
"args": {
|
|
125
|
+
"selector": "text=Προσθήκη συνυπογράφοντα"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "click",
|
|
130
|
+
"args": {
|
|
131
|
+
"selector": "text=Συνέχεια"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"name": "type",
|
|
136
|
+
"args": {
|
|
137
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 2\") .govgr-field:has-text(\"ΑΦΜ\") input",
|
|
138
|
+
"text": "094536469"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
"name": "type",
|
|
143
|
+
"args": {
|
|
144
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 2\") .govgr-field:has-text(\"Όνομα\") input",
|
|
145
|
+
"text": "Γιάννης"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "type",
|
|
150
|
+
"args": {
|
|
151
|
+
"selector": ".govgr-fieldset:has-text(\"Συνυπογράφοντας 2\") .govgr-field:has-text(\"Επώνυμο\") input",
|
|
152
|
+
"text": "Δόες"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
"name": "click",
|
|
157
|
+
"args": {
|
|
158
|
+
"selector": "html>body>div:nth-child(5)>form>button"
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"id": "RbhRN0ZiUB7C",
|
|
163
|
+
"title": "Add an exact length of items to FieldArray"
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -11,7 +11,7 @@ exports.Default = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
|
|
16
16
|
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
17
17
|
|
|
@@ -90,9 +90,7 @@ var fields = [{
|
|
|
90
90
|
var _ref = /*#__PURE__*/_react["default"].createElement(_core.Button, null, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
91
91
|
|
|
92
92
|
var Default = function Default() {
|
|
93
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
94
|
-
fallback: "loading"
|
|
95
|
-
}, /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
93
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
96
94
|
onSubmit: function onSubmit(data) {
|
|
97
95
|
debugger;
|
|
98
96
|
console.log(data);
|
|
@@ -103,7 +101,7 @@ var Default = function Default() {
|
|
|
103
101
|
name: "multiplicity"
|
|
104
102
|
}, fields[1])), /*#__PURE__*/_react["default"].createElement(_form.Field, (0, _extends2["default"])({
|
|
105
103
|
name: "phonenumber"
|
|
106
|
-
}, fields[2])), _ref)
|
|
104
|
+
}, fields[2])), _ref);
|
|
107
105
|
};
|
|
108
106
|
|
|
109
107
|
exports.Default = Default;
|
|
@@ -11,7 +11,7 @@ exports.WithExactLength = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
14
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
|
|
16
16
|
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
17
17
|
|
|
@@ -89,9 +89,7 @@ var fields = [{
|
|
|
89
89
|
var _ref = /*#__PURE__*/_react["default"].createElement(_core.Button, null, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
90
90
|
|
|
91
91
|
var WithExactLength = function WithExactLength() {
|
|
92
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
93
|
-
fallback: "loading"
|
|
94
|
-
}, /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
92
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
95
93
|
onSubmit: function onSubmit(data) {
|
|
96
94
|
debugger;
|
|
97
95
|
console.log(data);
|
|
@@ -102,7 +100,7 @@ var WithExactLength = function WithExactLength() {
|
|
|
102
100
|
name: "multiplicity"
|
|
103
101
|
}, fields[1])), /*#__PURE__*/_react["default"].createElement(_form.Field, (0, _extends2["default"])({
|
|
104
102
|
name: "phonenumber"
|
|
105
|
-
}, fields[2])), _ref)
|
|
103
|
+
}, fields[2])), _ref);
|
|
106
104
|
};
|
|
107
105
|
|
|
108
106
|
exports.WithExactLength = WithExactLength;
|
package/FieldArray/index.js
CHANGED
|
@@ -60,6 +60,7 @@ var FieldArray = function FieldArray(_ref) {
|
|
|
60
60
|
}, /*#__PURE__*/_react["default"].createElement(_Fieldset2["default"], null, /*#__PURE__*/_react["default"].createElement(_Fieldset.FieldsetLabel, null, "\u03A3\u03C5\u03BD\u03C5\u03C0\u03BF\u03B3\u03C1\u03AC\u03C6\u03BF\u03BD\u03C4\u03B1\u03C2 ", index + 1), /*#__PURE__*/_react["default"].createElement(_FieldObject["default"], (0, _extends2["default"])({
|
|
61
61
|
name: "".concat(name, ".").concat(index),
|
|
62
62
|
error: Array.isArray(error) && error[index],
|
|
63
|
+
formState: formState,
|
|
63
64
|
register: register,
|
|
64
65
|
control: control
|
|
65
66
|
}, (_customField$extra = customField.extra) === null || _customField$extra === void 0 ? void 0 : _customField$extra.of)), /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
package/FieldObject/index.js
CHANGED
|
@@ -31,7 +31,6 @@ var FieldObject = function FieldObject(_ref) {
|
|
|
31
31
|
var name = _ref.name,
|
|
32
32
|
label = _ref.label,
|
|
33
33
|
extra = _ref.extra,
|
|
34
|
-
error = _ref.error,
|
|
35
34
|
control = _ref.control,
|
|
36
35
|
register = _ref.register,
|
|
37
36
|
reset = _ref.reset,
|
|
@@ -50,7 +49,7 @@ var FieldObject = function FieldObject(_ref) {
|
|
|
50
49
|
register: register,
|
|
51
50
|
reset: reset,
|
|
52
51
|
field: field,
|
|
53
|
-
error:
|
|
52
|
+
error: formState.errors && formState.errors[field.key],
|
|
54
53
|
formState: formState
|
|
55
54
|
});
|
|
56
55
|
}));
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: FormBuilder
|
|
3
|
+
title: FormBuilder
|
|
4
|
+
sidebar_label: FormBuilder
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
`FormBuilder` is a React component that provides an easy way to efficiently create reusable form page. Forms are a flexible mechanism for collecting user input because there are suitable widgets for entering many different types of data, including text boxes, checkboxes, radio buttons, dropdowns and so on for submission to a server. Actually when we use `stepForm` for building step-forms all we do is to render `FormBuilder` component.
|
|
8
|
+
|
|
9
|
+
`stepForm` component:
|
|
10
|
+
|
|
11
|
+
<Story packageName="@digigov/form" component="FormBuilder" story="Default.tsx" />
|
|
12
|
+
|
|
13
|
+
### Importing and using FormBuilder Component
|
|
14
|
+
|
|
15
|
+
To import `FormBuilder` component simply import it from `'@digigov/form`.
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
|
|
19
|
+
import {FormBuilder} from '@digigov/form';
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Now you can use the current component inisde of your component
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import BasicLayout, {
|
|
27
|
+
Top,
|
|
28
|
+
Content,
|
|
29
|
+
Main,
|
|
30
|
+
Bottom,
|
|
31
|
+
} from '@digigov/ui/layouts/Basic';
|
|
32
|
+
import {FormBuilder} from '@digigov/form';
|
|
33
|
+
|
|
34
|
+
export default function MyComponent({ props }) {
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<BasicLayout>
|
|
38
|
+
.
|
|
39
|
+
.
|
|
40
|
+
<Content>
|
|
41
|
+
<Main>
|
|
42
|
+
.
|
|
43
|
+
.
|
|
44
|
+
<FormBuilder></FormBuilder>
|
|
45
|
+
.
|
|
46
|
+
.
|
|
47
|
+
</Main>
|
|
48
|
+
</Content>
|
|
49
|
+
<Bottom>
|
|
50
|
+
<GovGRFooter />
|
|
51
|
+
</Bottom>
|
|
52
|
+
</BasicLayout>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Props
|
|
59
|
+
|
|
60
|
+
`FormBuilder` component accepts several arguments as input props.
|
|
61
|
+
|
|
62
|
+
| Name | Type | Default | Description |
|
|
63
|
+
| ------------- | :-----------: | :-----------: | :-----------: |
|
|
64
|
+
| children | node | | allow you to pass components as data. |
|
|
65
|
+
| steps | array | | an array which includes each step-form format data |
|
|
66
|
+
| name | string | | the name of the step. |
|
|
67
|
+
| title | string | | the title from each step |
|
|
68
|
+
| fields | array | | an array of object fields which they describe each field for each step-form |
|
|
69
|
+
| key | string | | the key value of the input field |
|
|
70
|
+
| label | object | | an object prop which describes the label primary and the secondary name of the field |
|
|
71
|
+
| primary | string | | the name of te field |
|
|
72
|
+
| required | boolean | false | describes the validation of the field |
|
|
73
|
+
| submitButton | boolean | false | if true, it creates a button to continue to the next step |
|
|
74
|
+
| type | string | | describes the format of each field, e.x `type:'string'` is a simple input format field |
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Field types
|
|
79
|
+
|
|
80
|
+
Below are demostrated some examples for each type of field
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
### FormBuilder implementation
|
|
84
|
+
|
|
85
|
+
The examples above are implemented by using the code below
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
|
|
89
|
+
import React, { useState } from 'react';
|
|
90
|
+
import BasicLayout, {
|
|
91
|
+
Top,
|
|
92
|
+
Content,
|
|
93
|
+
Main,
|
|
94
|
+
Bottom,
|
|
95
|
+
} from '@digigov/ui/layouts/Basic';
|
|
96
|
+
import Header, { HeaderTitle } from '@digigov/ui/app/Header';
|
|
97
|
+
import GovGRLogo from '@digigov/ui/govgr/Logo';
|
|
98
|
+
import GovGRFooter from '@digigov/ui/govgr/Footer';
|
|
99
|
+
import Button from '@digigov/ui/core/Button';
|
|
100
|
+
import PageTitle, {
|
|
101
|
+
PageTitleSection,
|
|
102
|
+
PageTitleCaption,
|
|
103
|
+
PageTitleHeading,
|
|
104
|
+
} from '@digigov/ui/app/PageTitle';
|
|
105
|
+
import BackButton from '@digigov/ui/core/Button/BackButton';
|
|
106
|
+
import FormBuilder, { Fieldset, FieldsetLabel, Field } from '@digigov/form';
|
|
107
|
+
import { useTranslation } from '@digigov/ui/app';
|
|
108
|
+
|
|
109
|
+
const FIELDS = [
|
|
110
|
+
{
|
|
111
|
+
key: 'phone',
|
|
112
|
+
label: {
|
|
113
|
+
primary: 'Mobile phone',
|
|
114
|
+
secondary: 'A valid mobile number, eg. +306988848888',
|
|
115
|
+
},
|
|
116
|
+
required: true,
|
|
117
|
+
type: 'mobile_phone',
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: 'choice_single',
|
|
121
|
+
label: { primary: 'Is this true or not' },
|
|
122
|
+
type: 'choice:single',
|
|
123
|
+
required: true,
|
|
124
|
+
extra: {
|
|
125
|
+
options: [
|
|
126
|
+
{
|
|
127
|
+
label: { primary: 'Yes' },
|
|
128
|
+
value: 'yes',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: { primary: 'No', secondary: 'Explanation about no option' },
|
|
132
|
+
value: 'no',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
key: 'choice_single_notitle',
|
|
139
|
+
type: 'choice:single',
|
|
140
|
+
extra: {
|
|
141
|
+
options: [
|
|
142
|
+
{
|
|
143
|
+
label: { primary: 'One' },
|
|
144
|
+
value: '1',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
label: { primary: 'Two' },
|
|
148
|
+
value: '2',
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
key: 'choice_multiple',
|
|
155
|
+
label: 'Select from below',
|
|
156
|
+
type: 'choice:multiple',
|
|
157
|
+
extra: {
|
|
158
|
+
options: [
|
|
159
|
+
{
|
|
160
|
+
label: { primary: 'Choice 1', secondary: 'Choice 1 explanation' },
|
|
161
|
+
value: 'choice_1',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
label: { primary: 'Choice 2' },
|
|
165
|
+
value: 'choice_2',
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
key: 'choice_single_select',
|
|
172
|
+
label: 'Select from below',
|
|
173
|
+
type: 'choice:single',
|
|
174
|
+
extra: {
|
|
175
|
+
options: [
|
|
176
|
+
{
|
|
177
|
+
label: { primary: 'Choice 1', secondary: 'Choice 1 explanation' },
|
|
178
|
+
value: 'choice_1',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: { primary: 'Choice 2 lenghty explanation without reason' },
|
|
182
|
+
value: 'choice_2',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
component: 'Select',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
key: 'number',
|
|
190
|
+
label: { primary: 'A positive number' },
|
|
191
|
+
required: true,
|
|
192
|
+
width: '100px',
|
|
193
|
+
type: 'int',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
key: 'string',
|
|
197
|
+
label: null,
|
|
198
|
+
width: '100px',
|
|
199
|
+
required: true,
|
|
200
|
+
type: 'string',
|
|
201
|
+
},
|
|
202
|
+
];
|
|
203
|
+
const initialValues = {
|
|
204
|
+
phone: '6988888888',
|
|
205
|
+
choice_multiple: ['choice_2'],
|
|
206
|
+
string: 'default content',
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
const useStyles = makeStyles(
|
|
210
|
+
{
|
|
211
|
+
top: { minHeight: '75px' },
|
|
212
|
+
main: {},
|
|
213
|
+
side: {},
|
|
214
|
+
},
|
|
215
|
+
{ name: 'MuiSite' }
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
export default function Index() {
|
|
219
|
+
const styles = useStyles();
|
|
220
|
+
const [data, setData] = useState(null);
|
|
221
|
+
const { t } = useTranslation();
|
|
222
|
+
return (
|
|
223
|
+
<BasicLayout>
|
|
224
|
+
<Top className={styles.top}>
|
|
225
|
+
<Header>
|
|
226
|
+
<GovGRLogo />
|
|
227
|
+
<HeaderTitle>Service name</HeaderTitle>
|
|
228
|
+
</Header>
|
|
229
|
+
</Top>
|
|
230
|
+
<Content>
|
|
231
|
+
<Main className={styles.main}>
|
|
232
|
+
<BackButton>{t('button.back')}</BackButton>
|
|
233
|
+
<PageTitle>
|
|
234
|
+
<PageTitleSection>
|
|
235
|
+
<PageTitleCaption>Before we start</PageTitleCaption>
|
|
236
|
+
</PageTitleSection>
|
|
237
|
+
<PageTitleHeading>Submit a form</PageTitleHeading>
|
|
238
|
+
</PageTitle>
|
|
239
|
+
<FormBuilder
|
|
240
|
+
fields={FIELDS}
|
|
241
|
+
onSubmit={setData}
|
|
242
|
+
initial={initialValues}
|
|
243
|
+
>
|
|
244
|
+
<Fieldset>
|
|
245
|
+
<FieldsetLabel>This is a fieldset</FieldsetLabel>
|
|
246
|
+
{FIELDS.map((field) => (
|
|
247
|
+
<Field key={field.key} name={field.key} />
|
|
248
|
+
))}
|
|
249
|
+
</Fieldset>
|
|
250
|
+
<Button type="submit">{t('button.continue')}</Button>
|
|
251
|
+
</FormBuilder>
|
|
252
|
+
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
|
|
253
|
+
</Main>
|
|
254
|
+
</Content>
|
|
255
|
+
<Bottom>
|
|
256
|
+
<GovGRFooter />
|
|
257
|
+
</Bottom>
|
|
258
|
+
</BasicLayout>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
var _exportNames = {};
|
|
9
|
+
exports["default"] = void 0;
|
|
10
|
+
|
|
11
|
+
var _FormBuilder = _interopRequireDefault(require("@digigov/form/FormBuilder"));
|
|
12
|
+
|
|
13
|
+
var _Default = require("@digigov/form/FormBuilder/__stories__/Default");
|
|
14
|
+
|
|
15
|
+
Object.keys(_Default).forEach(function (key) {
|
|
16
|
+
if (key === "default" || key === "__esModule") return;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
+
if (key in exports && exports[key] === _Default[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _Default[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
var _default = {
|
|
27
|
+
title: 'Digigov Form/FormBuilder',
|
|
28
|
+
component: _FormBuilder["default"]
|
|
29
|
+
};
|
|
30
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports["default"] = exports.Default = void 0;
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _form = _interopRequireWildcard(require("@digigov/form"));
|
|
15
|
+
|
|
16
|
+
var _core = require("@digigov/ui/core");
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
var _ref = /*#__PURE__*/_react["default"].createElement(_core.Button, {
|
|
23
|
+
type: "submit"
|
|
24
|
+
}, "\u03A3\u03C5\u03BD\u03AD\u03C7\u03B5\u03B9\u03B1");
|
|
25
|
+
|
|
26
|
+
var Default = function Default() {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
|
28
|
+
onSubmit: function onSubmit(data) {
|
|
29
|
+
debugger;
|
|
30
|
+
console.log(data);
|
|
31
|
+
}
|
|
32
|
+
}, /*#__PURE__*/_react["default"].createElement(_form.Field, {
|
|
33
|
+
key: "business-title",
|
|
34
|
+
name: "business-title",
|
|
35
|
+
type: "string",
|
|
36
|
+
label: {
|
|
37
|
+
primary: 'Όνομα επιχείρησης'
|
|
38
|
+
},
|
|
39
|
+
required: true
|
|
40
|
+
}), _ref);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.Default = Default;
|
|
44
|
+
var _default = Default;
|
|
45
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _FormBuilder = require("@digigov/form/FormBuilder/FormBuilder");
|
|
9
|
+
|
|
10
|
+
var _default = _FormBuilder.FormBuilder;
|
|
11
|
+
exports["default"] = _default;
|