-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvtex.store-form.d.ts
241 lines (233 loc) · 6.59 KB
/
vtex.store-form.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import { Block } from '.'
declare global {
namespace JSX {
interface IntrinsicElements {
/**
* Top level block in which you will specify which entity and schema from Master Data will be used for building the form.
* It provides context to all its 8 children blocks.
*
* @see {@link https://developers.vtex.com/docs/apps/vtex.store-form}
*/
form: Block<{
/**
* @required
* The [entity](https://help.vtex.com/tutorial/creating-data-entity--tutorials_1265) in Master Data where the document will be saved.
*
* @default undefined
*/
entity: string
/**
* @required
* The JSON schema name that will be used.
* The schema name is set in the API's request to create it in Master Data.
*
* @default undefined
*/
schema: string
}>
/**
* Renders a field in the form.
*
* @see {@link https://developers.vtex.com/docs/apps/vtex.store-form}
*/
'form-input': Block<
| InputCheckbox
| InputDropdown
| InputRadiogroup
| InputTextarea
| InputText
| InputUpload
>
/**
* Renders different form blocks (such as `form-input.radiogroup` and `form-input.text`) according to each schema's sub-properties type.
*
* @see {@link https://developers.vtex.com/docs/apps/vtex.store-form}
*/
'form-field-group': Block<{
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/address`) in which the form block inputs should be validated against.
* Note that since you are configuring a `form-field-group` block, the path must not include a schema's sub-property, only a schema's property.
*
* @default undefined
*/
pointer: string
/**
* Redefines how the `form-field-groups` block should render each sub-properties declared in the JSON schema path defined in `pointer`.
* As said previously, the `form-field-groups` already does that by itself, but you can overwrite the sub-properties types through a schema and so redefine how each form block will be rendered.
*
* @default undefined
*/
uiSchema?: UISchema
}>
/**
* Renders a button to submit the user form content.
*
* @see {@link https://developers.vtex.com/docs/apps/vtex.store-form}
*/
'form-submit': Block
/**
* Accepts an array of blocks that will be rendered when the form is successfully submitted.
* Any children block is valid.
*
* @see {@link https://developers.vtex.com/docs/apps/vtex.store-form}
*/
'form-success': Block
}
}
}
type InputCheckbox = {
/**
* Renders a checkbox field in the form.
*/
$type: 'checkbox'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/firstName`) in which the form block inputs should be validated against.
*
* @default undefined
*/
pointer: string
/**
* @required
* Field's name when rendered.
*
* @default Property's title
*/
label: string
}
type InputDropdown = {
/**
* Renders a dropdown field in the form.
*/
$type: 'dropdown'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/firstName`) in which the form block inputs should be validated against.
*
* @default undefined
*/
pointer: string
/**
* @required
* Field's name when rendered.
*
* @default Property's title
*/
label: string
}
type InputRadiogroup = {
/**
* Renders a radio buttons field in the form.
*/
$type: 'radiogroup'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/firstName`) in which the form block inputs should be validated against.
*
* @default undefined
*/
pointer: string
/**
* @required
* Field's name when rendered.
*
* @default Property's title
*/
label: string
}
type InputTextarea = {
/**
* Renders a big text field in the form.
*/
$type: 'textarea'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/firstName`) in which the form block inputs should be validated against.
*
* @default undefined
*/
pointer: string
/**
* @required
* Field's name when rendered.
*
* @default Property's title
*/
label: string
/**
* Placeholder for the textarea input.
*
* @default undefined
*/
placeholder?: string
}
type InputText = {
/**
* Renders a small text field in the form which has few available characters.
*/
$type: 'text'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/firstName`) in which the form block inputs should be validated against.
*
* @default undefined
*/
pointer: string
/**
* Defines which type of a text field should be rendered: `input`: renders a normal text field.
* `hidden`: does not render any text field.
* It should be used in scenarios in which you want to pre-define a field value to be submitted to the form but that shouldn't be visible (and therefore editable) to users.
* `password`: renders a password text field.
*
* @default "input"
*/
inputType?: 'input' | 'hidden' | 'password'
/**
* Field's name when rendered.
*
* @default Property's title
*/
label: string
/**
* Placeholder for the text input.
*
* @default undefined
*/
placeholder?: string
}
type InputUpload = {
/**
* Renders an `Upload` field in the form.
*/
$type: 'upload'
/**
* @required
* JSON schema pointer i.e. the JSON schema path (for example: `#/properties/address`) in which the form block inputs should be validated against.
* Note that since you are configuring a `form-field-group` block, the path must not include a schema's sub-property, only a schema's property.
*
* @default undefined
*/
pointer: string
/**
* By default the upload input just accept image and PDF format files.
* If you want to customize it, you can pass the format type that you want following this pattern: `*.TYPEFILE`.
* You can [read more about the `accept` field](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept).
*/
accept?: string
}
type UISchema = {
type:
| 'default'
| 'radio'
| 'select'
| 'input'
| 'hidden'
| 'password'
| 'textArea'
| 'checkbox'
| 'upload'
properties: {
[k: string]: UISchema
}
}