@axdspub/axiom-ui-forms 0.2.10 → 0.3.0
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/README.md +272 -272
- package/library/axiom-ui-forms.d.ts +107 -33
- package/library/esm/_virtual/index10.js +2 -2
- package/library/esm/_virtual/index12.js +2 -6
- package/library/esm/_virtual/index12.js.map +1 -1
- package/library/esm/_virtual/index13.js +2 -6
- package/library/esm/_virtual/index13.js.map +1 -1
- package/library/esm/_virtual/index14.js +2 -2
- package/library/esm/_virtual/index15.js +2 -2
- package/library/esm/_virtual/index3.js +2 -2
- package/library/esm/_virtual/index3.js.map +1 -1
- package/library/esm/_virtual/index4.js +2 -2
- package/library/esm/_virtual/index6.js +2 -2
- package/library/esm/_virtual/index7.js +6 -2
- package/library/esm/_virtual/index7.js.map +1 -1
- package/library/esm/_virtual/index8.js +6 -2
- package/library/esm/_virtual/index8.js.map +1 -1
- package/library/esm/_virtual/index9.js +2 -2
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js +1 -1
- package/library/esm/node_modules/@axdspub/axiom-ui-utilities/library/index.js.map +1 -1
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js +23 -1
- package/library/esm/node_modules/@radix-ui/react-icons/dist/react-icons.esm.js.map +1 -1
- package/library/esm/node_modules/ajv/dist/compile/codegen/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/compile/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/core/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -1
- package/library/esm/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
- package/library/esm/node_modules/fast-uri/index.js +1 -1
- package/library/esm/node_modules/hast-util-to-jsx-runtime/lib/index.js +1 -1
- package/library/esm/node_modules/jotai/esm/react.js +135 -0
- package/library/esm/node_modules/jotai/esm/react.js.map +1 -0
- package/library/esm/node_modules/jotai/esm/vanilla/internals.js +551 -0
- package/library/esm/node_modules/jotai/esm/vanilla/internals.js.map +1 -0
- package/library/esm/node_modules/jotai/esm/vanilla.js +111 -0
- package/library/esm/node_modules/jotai/esm/vanilla.js.map +1 -0
- package/library/esm/node_modules/json-schema-traverse/index.js +1 -1
- package/library/esm/node_modules/react-router/dist/development/chunk-HA7DTUK3.js +1 -1
- package/library/esm/node_modules/unified/lib/index.js +1 -1
- package/library/esm/src/Form/Components/FieldCreator.js +19 -4
- package/library/esm/src/Form/Components/FieldCreator.js.map +1 -1
- package/library/esm/src/Form/Components/FieldLabel.js +1 -1
- package/library/esm/src/Form/Components/FieldLabel.js.map +1 -1
- package/library/esm/src/Form/Components/InlineMarkdown.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Boolean.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Constant.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Date.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/DateTime.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeoJSON.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeoJSONInputLoader.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Geometry.js +1 -1
- package/library/esm/src/Form/Components/Inputs/Geometry.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/GeometryInputLoader.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/JSON.js +64 -33
- package/library/esm/src/Form/Components/Inputs/JSON.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/JSONInputLoader.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/LongString.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Number.js +34 -9
- package/library/esm/src/Form/Components/Inputs/Number.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Object.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/OneOfInput.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/RadioGroup.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/SingleSelect.js +2 -1
- package/library/esm/src/Form/Components/Inputs/SingleSelect.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/String.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/Time.js.map +1 -1
- package/library/esm/src/Form/Components/Inputs/index.js +11 -0
- package/library/esm/src/Form/Components/Inputs/index.js.map +1 -0
- package/library/esm/src/Form/Components/Inputs/inputMap.js.map +1 -1
- package/library/esm/src/Form/Creator/FormContextProvider.js.map +1 -1
- package/library/esm/src/Form/Creator/FormCreator.js +17 -8
- package/library/esm/src/Form/Creator/FormCreator.js.map +1 -1
- package/library/esm/src/Form/Creator/FormFields.js.map +1 -1
- package/library/esm/src/Form/Creator/FormHeader.js.map +1 -1
- package/library/esm/src/Form/Creator/FormSection.js.map +1 -1
- package/library/esm/src/Form/Creator/FormSectionContextProvider.js.map +1 -1
- package/library/esm/src/Form/Creator/NavElement.js.map +1 -1
- package/library/esm/src/Form/Creator/Page.js +39 -6
- package/library/esm/src/Form/Creator/Page.js.map +1 -1
- package/library/esm/src/Form/Creator/Wizard.js +78 -21
- package/library/esm/src/Form/Creator/Wizard.js.map +1 -1
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js +3 -3
- package/library/esm/src/Form/Manage/CopyableJSONOutput.js.map +1 -1
- package/library/esm/src/library.js +9 -14
- package/library/esm/src/library.js.map +1 -1
- package/library/esm/src/utils/getters.js +33 -3
- package/library/esm/src/utils/getters.js.map +1 -1
- package/library/esm/src/utils/manipulators.js +80 -3
- package/library/esm/src/utils/manipulators.js.map +1 -1
- package/library/esm/src/utils/resolveRefs.js +44 -0
- package/library/esm/src/utils/resolveRefs.js.map +1 -0
- package/library/esm/src/utils/responsive/layoutState.js +18 -0
- package/library/esm/src/utils/responsive/layoutState.js.map +1 -0
- package/library/esm/src/utils/schemaToFormHelpers.js +157 -39
- package/library/esm/src/utils/schemaToFormHelpers.js.map +1 -1
- package/library/esm/src/utils/validators.js +4 -2
- package/library/esm/src/utils/validators.js.map +1 -1
- package/package.json +131 -129
- package/library/esm/src/Form/resolveRefs.js +0 -26
- package/library/esm/src/Form/resolveRefs.js.map +0 -1
package/README.md
CHANGED
@@ -1,272 +1,272 @@
|
|
1
|
-
React library that allows:
|
2
|
-
- Creation of forms using a json config file
|
3
|
-
- Creation of forms using a [json schema draft 7](https://json-schema.org/draft-07/json-schema-release-notes), with selective overrides using json config
|
4
|
-
- To do:
|
5
|
-
- allow addition of new form types and UI components by consuming library
|
6
|
-
- allow schema version 4 and draft 6
|
7
|
-
- support schema `required`
|
8
|
-
- support version 7 `if`/`then`/`else`
|
9
|
-
- support version 7 `readOnly`
|
10
|
-
- support version 7 `writeOnly`
|
11
|
-
|
12
|
-
|
13
|
-
.
|
14
|
-
|
15
|
-
# [Examples](https://axiom-ui-forms.srv.axds.co/)
|
16
|
-
|
17
|
-
## Create a form using a config
|
18
|
-
|
19
|
-
Test form config [here](https://axiom-ui-forms.srv.axds.co/). Note: currently, forms with wizards or pages require that the parent route includes `*` (only tested with `react-router-dom@7`). Todo: make url navigation on form optional.
|
20
|
-
|
21
|
-
```json
|
22
|
-
{
|
23
|
-
"id": "example",
|
24
|
-
"label": "Example form",
|
25
|
-
"description": "This is just an example",
|
26
|
-
"fields": [
|
27
|
-
{
|
28
|
-
"id": "title",
|
29
|
-
"type": "text",
|
30
|
-
"label": "Title"
|
31
|
-
},
|
32
|
-
{
|
33
|
-
"id": "description",
|
34
|
-
"type": "long_text",
|
35
|
-
"label": "Description"
|
36
|
-
},
|
37
|
-
{
|
38
|
-
"id": "favorites",
|
39
|
-
"type": "text",
|
40
|
-
"label": "List your favorite things",
|
41
|
-
"multiple": true
|
42
|
-
},
|
43
|
-
{
|
44
|
-
"id": "agree",
|
45
|
-
"type": "boolean",
|
46
|
-
"label": "Do you agree?"
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"id": "signature",
|
50
|
-
"type": "text",
|
51
|
-
"label": "Sign your name then",
|
52
|
-
"conditions": { "dependsOn": "agree" }
|
53
|
-
}
|
54
|
-
]
|
55
|
-
}
|
56
|
-
```
|
57
|
-
|
58
|
-
```ts
|
59
|
-
import React, {type ReactElement} from 'react'
|
60
|
-
import { FormCreator, type IForm, type IFormValues } from '@axdspub/axiom-ui-forms'
|
61
|
-
|
62
|
-
export default ExampleForm = ({formConfig}: {formConfig: IForm}): ReactElement => {
|
63
|
-
const formValueState = React.useState<IFormValues>({})
|
64
|
-
const [formValues] = formValueState
|
65
|
-
useEffect(()=>{
|
66
|
-
// respond to change in formValues
|
67
|
-
},[formValues])
|
68
|
-
|
69
|
-
return (
|
70
|
-
<FormCreator form={formConfig} formValueState={formValueState} />
|
71
|
-
)
|
72
|
-
}
|
73
|
-
|
74
|
-
```
|
75
|
-
|
76
|
-
## Config to create a form with wizard steps using config.
|
77
|
-
Example [here](https://axiom-ui-forms.srv.axds.co/?tab=config&form=uQAEYmlkZ2V4YW1wbGVlbGFiZWxsRXhhbXBsZSBmb3Jta2Rlc2NyaXB0aW9ud1RoaXMgaXMganVzdCBhbiBleGFtcGxlbHdpemFyZF9zdGVwc4O5AARiaWRlaW50cm9lbGFiZWxsSW50cm9kdWN0aW9uZW9yZGVyAGZmaWVsZHOCuQADYmlkZXRpdGxlZHR5cGVkdGV4dGVsYWJlbGVUaXRsZbkAA2JpZGtkZXNjcmlwdGlvbmR0eXBlaWxvbmdfdGV4dGVsYWJlbGtEZXNjcmlwdGlvbrkABGJpZGNtYXBlbGFiZWxmU3RlcCAyZW9yZGVyAWZmaWVsZHOBuQADYmlkY21hcGR0eXBlZ2dlb2pzb25lbGFiZWxoTG9jYXRpb265AARiaWRlYWJvdXRlbGFiZWxuQWJvdXQgeW91cnNlbGZlb3JkZXICZXBhZ2VzgrkAA2JpZGlmYXZvcml0ZXNlbGFiZWxpRmF2b3JpdGVzZmZpZWxkc4G5AARiaWRuZmF2b3JpdGVzX2xpc3RkdHlwZWR0ZXh0ZWxhYmVseBlMaXN0IHlvdXIgZmF2b3JpdGUgdGhpbmdzaG11bHRpcGxl9bkAA2JpZGRzaWduZWxhYmVsaVNpZ25hdHVyZWZmaWVsZHOCuQADYmlkZWFncmVlZHR5cGVnYm9vbGVhbmVsYWJlbG1EbyB5b3UgYWdyZWU%2FuQADYmlkaXNpZ25hdHVyZWR0eXBlZHRleHRlbGFiZWxzU2lnbiB5b3VyIG5hbWUgdGhlbg%3D%3D).
|
78
|
-
|
79
|
-
```json
|
80
|
-
{
|
81
|
-
"id": "example",
|
82
|
-
"label": "Example form",
|
83
|
-
"description": "This is just an example",
|
84
|
-
"wizard_steps":[
|
85
|
-
{
|
86
|
-
"id":"intro",
|
87
|
-
"label":"Introduction",
|
88
|
-
"order": 0,
|
89
|
-
"fields":[
|
90
|
-
{
|
91
|
-
"id": "title",
|
92
|
-
"type": "text",
|
93
|
-
"label": "Title"
|
94
|
-
},
|
95
|
-
{
|
96
|
-
"id": "description",
|
97
|
-
"type": "long_text",
|
98
|
-
"label": "Description"
|
99
|
-
}
|
100
|
-
]
|
101
|
-
|
102
|
-
},
|
103
|
-
{
|
104
|
-
"id": "map",
|
105
|
-
"label": "Step 2",
|
106
|
-
"order": 1,
|
107
|
-
"fields": [
|
108
|
-
{
|
109
|
-
"id": "map",
|
110
|
-
"type": "geojson",
|
111
|
-
"label": "Location"
|
112
|
-
}
|
113
|
-
]
|
114
|
-
},
|
115
|
-
{
|
116
|
-
"id": "about",
|
117
|
-
"label": "About yourself",
|
118
|
-
"order": 2,
|
119
|
-
"pages":[
|
120
|
-
{
|
121
|
-
"id": "favorites",
|
122
|
-
"label": "Favorites",
|
123
|
-
"fields": [
|
124
|
-
{
|
125
|
-
"id": "favorites_list",
|
126
|
-
"type": "text",
|
127
|
-
"label": "List your favorite things",
|
128
|
-
"multiple": true
|
129
|
-
}
|
130
|
-
]
|
131
|
-
},
|
132
|
-
{
|
133
|
-
"id":"sign",
|
134
|
-
"label": "Signature",
|
135
|
-
"fields": [
|
136
|
-
{
|
137
|
-
"id": "agree",
|
138
|
-
"type": "boolean",
|
139
|
-
"label": "Do you agree?"
|
140
|
-
},
|
141
|
-
{
|
142
|
-
"id": "signature",
|
143
|
-
"type": "text",
|
144
|
-
"label": "Sign your name then"
|
145
|
-
}
|
146
|
-
]
|
147
|
-
}
|
148
|
-
]
|
149
|
-
|
150
|
-
}
|
151
|
-
|
152
|
-
]
|
153
|
-
}
|
154
|
-
|
155
|
-
```
|
156
|
-
|
157
|
-
|
158
|
-
# Create a form using a schema
|
159
|
-
|
160
|
-
Test schema to form [here](https://axiom-ui-forms.srv.axds.co/schema-to-form)
|
161
|
-
|
162
|
-
```json
|
163
|
-
{
|
164
|
-
"$id": "/test/schema",
|
165
|
-
"type": "object",
|
166
|
-
"properties": {
|
167
|
-
"label": {
|
168
|
-
"type": "string",
|
169
|
-
"maxLength": 100
|
170
|
-
},
|
171
|
-
"description": {
|
172
|
-
"type": "string"
|
173
|
-
},
|
174
|
-
"agree": {
|
175
|
-
"type": "boolean",
|
176
|
-
},
|
177
|
-
"signature": {
|
178
|
-
"type": "string"
|
179
|
-
}
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
```
|
184
|
-
|
185
|
-
Coming soon...
|
186
|
-
```json
|
187
|
-
{
|
188
|
-
"$id": "/test/schema",
|
189
|
-
"type": "object",
|
190
|
-
"required": [
|
191
|
-
"label",
|
192
|
-
"description",
|
193
|
-
"agree"
|
194
|
-
],
|
195
|
-
"properties": {
|
196
|
-
"label": {
|
197
|
-
"type": "string",
|
198
|
-
"maxLength": 100
|
199
|
-
},
|
200
|
-
"description": {
|
201
|
-
"type": "string"
|
202
|
-
},
|
203
|
-
"agree": {
|
204
|
-
"type": "boolean"
|
205
|
-
}
|
206
|
-
},
|
207
|
-
"dependentSchemas": {
|
208
|
-
"agree": {
|
209
|
-
"properties": {
|
210
|
-
"signature": {
|
211
|
-
"type": "string",
|
212
|
-
"maxLength": 100
|
213
|
-
}
|
214
|
-
}
|
215
|
-
}
|
216
|
-
}
|
217
|
-
}
|
218
|
-
```
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
```ts
|
223
|
-
import React, {type ReactElement} from 'react'
|
224
|
-
import { FormCreator, type IForm, type IFormValues } from '@axdspub/axiom-ui-forms'
|
225
|
-
import { type JSONSchema7 } from 'json-schema'
|
226
|
-
|
227
|
-
export default ExampleForm = ({schema}:{schema: JSONSchema7 }): ReactElement => {
|
228
|
-
const formValueState = React.useState<IFormValues>({})
|
229
|
-
const [formValues] = formValueState
|
230
|
-
useEffect(()=>{
|
231
|
-
// respond to change in formValues
|
232
|
-
},[formValues])
|
233
|
-
const errors = validateSchema(schema)
|
234
|
-
const formConfig = errors === null
|
235
|
-
? schemaToFormObject(schema)
|
236
|
-
: null
|
237
|
-
|
238
|
-
return (
|
239
|
-
<>{
|
240
|
-
errors !== null
|
241
|
-
? <p>Schema errors: {{errors}}</p>
|
242
|
-
: <FormCreator form={formConfig} formValueState={} >
|
243
|
-
}</>
|
244
|
-
|
245
|
-
)
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
```
|
250
|
-
|
251
|
-
|
252
|
-
# Create a form using a schema, and modify it with a form config
|
253
|
-
|
254
|
-
Coming soon
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
# Testing build locally
|
259
|
-
|
260
|
-
```bash
|
261
|
-
npm i spa-http-server -g
|
262
|
-
npm run build
|
263
|
-
cd build
|
264
|
-
http-server --push-state -p 8091 -o
|
265
|
-
```
|
266
|
-
|
267
|
-
# Publish version to NPM
|
268
|
-
|
269
|
-
```bash
|
270
|
-
npm login --scope=@axdspub
|
271
|
-
npm publish --access public
|
272
|
-
```
|
1
|
+
React library that allows:
|
2
|
+
- Creation of forms using a json config file
|
3
|
+
- Creation of forms using a [json schema draft 7](https://json-schema.org/draft-07/json-schema-release-notes), with selective overrides using json config
|
4
|
+
- To do:
|
5
|
+
- allow addition of new form types and UI components by consuming library
|
6
|
+
- allow schema version 4 and draft 6
|
7
|
+
- support schema `required`
|
8
|
+
- support version 7 `if`/`then`/`else`
|
9
|
+
- support version 7 `readOnly`
|
10
|
+
- support version 7 `writeOnly`
|
11
|
+
|
12
|
+
|
13
|
+
.
|
14
|
+
|
15
|
+
# [Examples](https://axiom-ui-forms.srv.axds.co/)
|
16
|
+
|
17
|
+
## Create a form using a config
|
18
|
+
|
19
|
+
Test form config [here](https://axiom-ui-forms.srv.axds.co/). Note: currently, forms with wizards or pages require that the parent route includes `*` (only tested with `react-router-dom@7`). Todo: make url navigation on form optional.
|
20
|
+
|
21
|
+
```json
|
22
|
+
{
|
23
|
+
"id": "example",
|
24
|
+
"label": "Example form",
|
25
|
+
"description": "This is just an example",
|
26
|
+
"fields": [
|
27
|
+
{
|
28
|
+
"id": "title",
|
29
|
+
"type": "text",
|
30
|
+
"label": "Title"
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"id": "description",
|
34
|
+
"type": "long_text",
|
35
|
+
"label": "Description"
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": "favorites",
|
39
|
+
"type": "text",
|
40
|
+
"label": "List your favorite things",
|
41
|
+
"multiple": true
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"id": "agree",
|
45
|
+
"type": "boolean",
|
46
|
+
"label": "Do you agree?"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"id": "signature",
|
50
|
+
"type": "text",
|
51
|
+
"label": "Sign your name then",
|
52
|
+
"conditions": { "dependsOn": "agree" }
|
53
|
+
}
|
54
|
+
]
|
55
|
+
}
|
56
|
+
```
|
57
|
+
|
58
|
+
```ts
|
59
|
+
import React, {type ReactElement} from 'react'
|
60
|
+
import { FormCreator, type IForm, type IFormValues } from '@axdspub/axiom-ui-forms'
|
61
|
+
|
62
|
+
export default ExampleForm = ({formConfig}: {formConfig: IForm}): ReactElement => {
|
63
|
+
const formValueState = React.useState<IFormValues>({})
|
64
|
+
const [formValues] = formValueState
|
65
|
+
useEffect(()=>{
|
66
|
+
// respond to change in formValues
|
67
|
+
},[formValues])
|
68
|
+
|
69
|
+
return (
|
70
|
+
<FormCreator form={formConfig} formValueState={formValueState} />
|
71
|
+
)
|
72
|
+
}
|
73
|
+
|
74
|
+
```
|
75
|
+
|
76
|
+
## Config to create a form with wizard steps using config.
|
77
|
+
Example [here](https://axiom-ui-forms.srv.axds.co/?tab=config&form=uQAEYmlkZ2V4YW1wbGVlbGFiZWxsRXhhbXBsZSBmb3Jta2Rlc2NyaXB0aW9ud1RoaXMgaXMganVzdCBhbiBleGFtcGxlbHdpemFyZF9zdGVwc4O5AARiaWRlaW50cm9lbGFiZWxsSW50cm9kdWN0aW9uZW9yZGVyAGZmaWVsZHOCuQADYmlkZXRpdGxlZHR5cGVkdGV4dGVsYWJlbGVUaXRsZbkAA2JpZGtkZXNjcmlwdGlvbmR0eXBlaWxvbmdfdGV4dGVsYWJlbGtEZXNjcmlwdGlvbrkABGJpZGNtYXBlbGFiZWxmU3RlcCAyZW9yZGVyAWZmaWVsZHOBuQADYmlkY21hcGR0eXBlZ2dlb2pzb25lbGFiZWxoTG9jYXRpb265AARiaWRlYWJvdXRlbGFiZWxuQWJvdXQgeW91cnNlbGZlb3JkZXICZXBhZ2VzgrkAA2JpZGlmYXZvcml0ZXNlbGFiZWxpRmF2b3JpdGVzZmZpZWxkc4G5AARiaWRuZmF2b3JpdGVzX2xpc3RkdHlwZWR0ZXh0ZWxhYmVseBlMaXN0IHlvdXIgZmF2b3JpdGUgdGhpbmdzaG11bHRpcGxl9bkAA2JpZGRzaWduZWxhYmVsaVNpZ25hdHVyZWZmaWVsZHOCuQADYmlkZWFncmVlZHR5cGVnYm9vbGVhbmVsYWJlbG1EbyB5b3UgYWdyZWU%2FuQADYmlkaXNpZ25hdHVyZWR0eXBlZHRleHRlbGFiZWxzU2lnbiB5b3VyIG5hbWUgdGhlbg%3D%3D).
|
78
|
+
|
79
|
+
```json
|
80
|
+
{
|
81
|
+
"id": "example",
|
82
|
+
"label": "Example form",
|
83
|
+
"description": "This is just an example",
|
84
|
+
"wizard_steps":[
|
85
|
+
{
|
86
|
+
"id":"intro",
|
87
|
+
"label":"Introduction",
|
88
|
+
"order": 0,
|
89
|
+
"fields":[
|
90
|
+
{
|
91
|
+
"id": "title",
|
92
|
+
"type": "text",
|
93
|
+
"label": "Title"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"id": "description",
|
97
|
+
"type": "long_text",
|
98
|
+
"label": "Description"
|
99
|
+
}
|
100
|
+
]
|
101
|
+
|
102
|
+
},
|
103
|
+
{
|
104
|
+
"id": "map",
|
105
|
+
"label": "Step 2",
|
106
|
+
"order": 1,
|
107
|
+
"fields": [
|
108
|
+
{
|
109
|
+
"id": "map",
|
110
|
+
"type": "geojson",
|
111
|
+
"label": "Location"
|
112
|
+
}
|
113
|
+
]
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"id": "about",
|
117
|
+
"label": "About yourself",
|
118
|
+
"order": 2,
|
119
|
+
"pages":[
|
120
|
+
{
|
121
|
+
"id": "favorites",
|
122
|
+
"label": "Favorites",
|
123
|
+
"fields": [
|
124
|
+
{
|
125
|
+
"id": "favorites_list",
|
126
|
+
"type": "text",
|
127
|
+
"label": "List your favorite things",
|
128
|
+
"multiple": true
|
129
|
+
}
|
130
|
+
]
|
131
|
+
},
|
132
|
+
{
|
133
|
+
"id":"sign",
|
134
|
+
"label": "Signature",
|
135
|
+
"fields": [
|
136
|
+
{
|
137
|
+
"id": "agree",
|
138
|
+
"type": "boolean",
|
139
|
+
"label": "Do you agree?"
|
140
|
+
},
|
141
|
+
{
|
142
|
+
"id": "signature",
|
143
|
+
"type": "text",
|
144
|
+
"label": "Sign your name then"
|
145
|
+
}
|
146
|
+
]
|
147
|
+
}
|
148
|
+
]
|
149
|
+
|
150
|
+
}
|
151
|
+
|
152
|
+
]
|
153
|
+
}
|
154
|
+
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
# Create a form using a schema
|
159
|
+
|
160
|
+
Test schema to form [here](https://axiom-ui-forms.srv.axds.co/schema-to-form)
|
161
|
+
|
162
|
+
```json
|
163
|
+
{
|
164
|
+
"$id": "/test/schema",
|
165
|
+
"type": "object",
|
166
|
+
"properties": {
|
167
|
+
"label": {
|
168
|
+
"type": "string",
|
169
|
+
"maxLength": 100
|
170
|
+
},
|
171
|
+
"description": {
|
172
|
+
"type": "string"
|
173
|
+
},
|
174
|
+
"agree": {
|
175
|
+
"type": "boolean",
|
176
|
+
},
|
177
|
+
"signature": {
|
178
|
+
"type": "string"
|
179
|
+
}
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
```
|
184
|
+
|
185
|
+
Coming soon...
|
186
|
+
```json
|
187
|
+
{
|
188
|
+
"$id": "/test/schema",
|
189
|
+
"type": "object",
|
190
|
+
"required": [
|
191
|
+
"label",
|
192
|
+
"description",
|
193
|
+
"agree"
|
194
|
+
],
|
195
|
+
"properties": {
|
196
|
+
"label": {
|
197
|
+
"type": "string",
|
198
|
+
"maxLength": 100
|
199
|
+
},
|
200
|
+
"description": {
|
201
|
+
"type": "string"
|
202
|
+
},
|
203
|
+
"agree": {
|
204
|
+
"type": "boolean"
|
205
|
+
}
|
206
|
+
},
|
207
|
+
"dependentSchemas": {
|
208
|
+
"agree": {
|
209
|
+
"properties": {
|
210
|
+
"signature": {
|
211
|
+
"type": "string",
|
212
|
+
"maxLength": 100
|
213
|
+
}
|
214
|
+
}
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
```
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
```ts
|
223
|
+
import React, {type ReactElement} from 'react'
|
224
|
+
import { FormCreator, type IForm, type IFormValues } from '@axdspub/axiom-ui-forms'
|
225
|
+
import { type JSONSchema7 } from 'json-schema'
|
226
|
+
|
227
|
+
export default ExampleForm = ({schema}:{schema: JSONSchema7 }): ReactElement => {
|
228
|
+
const formValueState = React.useState<IFormValues>({})
|
229
|
+
const [formValues] = formValueState
|
230
|
+
useEffect(()=>{
|
231
|
+
// respond to change in formValues
|
232
|
+
},[formValues])
|
233
|
+
const errors = validateSchema(schema)
|
234
|
+
const formConfig = errors === null
|
235
|
+
? schemaToFormObject(schema)
|
236
|
+
: null
|
237
|
+
|
238
|
+
return (
|
239
|
+
<>{
|
240
|
+
errors !== null
|
241
|
+
? <p>Schema errors: {{errors}}</p>
|
242
|
+
: <FormCreator form={formConfig} formValueState={} >
|
243
|
+
}</>
|
244
|
+
|
245
|
+
)
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
# Create a form using a schema, and modify it with a form config
|
253
|
+
|
254
|
+
Coming soon
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
# Testing build locally
|
259
|
+
|
260
|
+
```bash
|
261
|
+
npm i spa-http-server -g
|
262
|
+
npm run build
|
263
|
+
cd build
|
264
|
+
http-server --push-state -p 8091 -o
|
265
|
+
```
|
266
|
+
|
267
|
+
# Publish version to NPM
|
268
|
+
|
269
|
+
```bash
|
270
|
+
npm login --scope=@axdspub
|
271
|
+
npm publish --access public
|
272
|
+
```
|