@abraracs/better-shopify-wc-mcp 1.0.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 +110 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +325 -0
- package/docs/avatar.md +481 -0
- package/docs/badge.md +266 -0
- package/docs/banner.md +350 -0
- package/docs/box.md +618 -0
- package/docs/button.md +604 -0
- package/docs/buttongroup.md +251 -0
- package/docs/checkbox.md +346 -0
- package/docs/chip.md +261 -0
- package/docs/choicelist.md +416 -0
- package/docs/clickable.md +703 -0
- package/docs/clickablechip.md +377 -0
- package/docs/colorfield.md +416 -0
- package/docs/colorpicker.md +152 -0
- package/docs/datefield.md +706 -0
- package/docs/datepicker.md +443 -0
- package/docs/divider.md +263 -0
- package/docs/dropzone.md +331 -0
- package/docs/emailfield.md +377 -0
- package/docs/grid.md +1246 -0
- package/docs/heading.md +201 -0
- package/docs/icon.md +295 -0
- package/docs/image.md +517 -0
- package/docs/link.md +456 -0
- package/docs/menu.md +331 -0
- package/docs/modal.md +640 -0
- package/docs/moneyfield.md +385 -0
- package/docs/numberfield.md +393 -0
- package/docs/orderedlist.md +224 -0
- package/docs/page.md +319 -0
- package/docs/paragraph.md +333 -0
- package/docs/passwordfield.md +381 -0
- package/docs/popover.md +419 -0
- package/docs/querycontainer.md +121 -0
- package/docs/searchfield.md +319 -0
- package/docs/section.md +267 -0
- package/docs/select.md +449 -0
- package/docs/spinner.md +121 -0
- package/docs/stack.md +748 -0
- package/docs/switch.md +365 -0
- package/docs/table.md +805 -0
- package/docs/text.md +339 -0
- package/docs/textarea.md +328 -0
- package/docs/textfield.md +425 -0
- package/docs/thumbnail.md +245 -0
- package/docs/tooltip.md +130 -0
- package/docs/unorderedlist.md +135 -0
- package/docs/urlfield.md +314 -0
- package/package.json +43 -0
package/docs/dropzone.md
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: DropZone
|
|
3
|
+
description: >-
|
|
4
|
+
Lets users upload files through drag-and-drop functionality into a designated
|
|
5
|
+
area on a page, or by activating a button.
|
|
6
|
+
api_name: app-home
|
|
7
|
+
source_url:
|
|
8
|
+
html: 'https://shopify.dev/docs/api/app-home/polaris-web-components/forms/dropzone'
|
|
9
|
+
md: >-
|
|
10
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/dropzone.md
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# DropZone
|
|
14
|
+
|
|
15
|
+
Lets users upload files through drag-and-drop functionality into a designated area on a page, or by activating a button.
|
|
16
|
+
|
|
17
|
+
## Properties
|
|
18
|
+
|
|
19
|
+
* accept
|
|
20
|
+
|
|
21
|
+
string
|
|
22
|
+
|
|
23
|
+
Default: ''
|
|
24
|
+
|
|
25
|
+
A string representing the types of files that are accepted by the drop zone. This string is a comma-separated list of unique file type specifiers which can be one of the following:
|
|
26
|
+
|
|
27
|
+
* A file extension starting with a period (".") character (e.g. .jpg, .pdf, .doc)
|
|
28
|
+
* A valid MIME type string with no extensions
|
|
29
|
+
|
|
30
|
+
If omitted, all file types are accepted.
|
|
31
|
+
|
|
32
|
+
* accessibilityLabel
|
|
33
|
+
|
|
34
|
+
string
|
|
35
|
+
|
|
36
|
+
A label that describes the purpose or contents of the item. When set, it will be announced to buyers using assistive technologies and will provide them with more context.
|
|
37
|
+
|
|
38
|
+
* disabled
|
|
39
|
+
|
|
40
|
+
boolean
|
|
41
|
+
|
|
42
|
+
Default: false
|
|
43
|
+
|
|
44
|
+
Disables the field, disallowing any interaction.
|
|
45
|
+
|
|
46
|
+
* error
|
|
47
|
+
|
|
48
|
+
string
|
|
49
|
+
|
|
50
|
+
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
|
|
51
|
+
|
|
52
|
+
* files
|
|
53
|
+
|
|
54
|
+
File\[]
|
|
55
|
+
|
|
56
|
+
Default: \[]
|
|
57
|
+
|
|
58
|
+
An array of File objects representing the files currently selected by the user.
|
|
59
|
+
|
|
60
|
+
This property is read-only and cannot be directly modified. To clear the selected files, set the `value` prop to an empty string or null.
|
|
61
|
+
|
|
62
|
+
* label
|
|
63
|
+
|
|
64
|
+
string
|
|
65
|
+
|
|
66
|
+
Content to use as the field label.
|
|
67
|
+
|
|
68
|
+
* labelAccessibilityVisibility
|
|
69
|
+
|
|
70
|
+
"visible" | "exclusive"
|
|
71
|
+
|
|
72
|
+
Default: 'visible'
|
|
73
|
+
|
|
74
|
+
Changes the visibility of the component's label.
|
|
75
|
+
|
|
76
|
+
* `visible`: the label is visible to all users.
|
|
77
|
+
* `exclusive`: the label is visually hidden but remains in the accessibility tree.
|
|
78
|
+
|
|
79
|
+
* multiple
|
|
80
|
+
|
|
81
|
+
boolean
|
|
82
|
+
|
|
83
|
+
Default: false
|
|
84
|
+
|
|
85
|
+
Whether multiple files can be selected or dropped at once.
|
|
86
|
+
|
|
87
|
+
* name
|
|
88
|
+
|
|
89
|
+
string
|
|
90
|
+
|
|
91
|
+
An identifier for the field that is unique within the nearest containing form.
|
|
92
|
+
|
|
93
|
+
* required
|
|
94
|
+
|
|
95
|
+
boolean
|
|
96
|
+
|
|
97
|
+
Default: false
|
|
98
|
+
|
|
99
|
+
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the `error` property.
|
|
100
|
+
|
|
101
|
+
* value
|
|
102
|
+
|
|
103
|
+
string
|
|
104
|
+
|
|
105
|
+
Default: ''
|
|
106
|
+
|
|
107
|
+
This sets the input value for a file type, which cannot be set programatically, so it can only be reset.
|
|
108
|
+
|
|
109
|
+
## Events
|
|
110
|
+
|
|
111
|
+
Learn more about [registering events](https://shopify.dev/docs/api/app-home/using-polaris-components#event-handling).
|
|
112
|
+
|
|
113
|
+
* change
|
|
114
|
+
|
|
115
|
+
CallbackEventListener\<typeof tagName>
|
|
116
|
+
|
|
117
|
+
* droprejected
|
|
118
|
+
|
|
119
|
+
CallbackEventListener\<typeof tagName>
|
|
120
|
+
|
|
121
|
+
* input
|
|
122
|
+
|
|
123
|
+
CallbackEventListener\<typeof tagName>
|
|
124
|
+
|
|
125
|
+
### CallbackEventListener
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
(EventListener & {
|
|
129
|
+
(event: CallbackEvent<T>): void;
|
|
130
|
+
}) | null
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### CallbackEvent
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
Event & {
|
|
137
|
+
currentTarget: HTMLElementTagNameMap[T];
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Slots
|
|
142
|
+
|
|
143
|
+
* children
|
|
144
|
+
|
|
145
|
+
HTMLElement
|
|
146
|
+
|
|
147
|
+
Content to include inside the DropZone container
|
|
148
|
+
|
|
149
|
+
Examples
|
|
150
|
+
|
|
151
|
+
### Examples
|
|
152
|
+
|
|
153
|
+
* #### Code
|
|
154
|
+
|
|
155
|
+
##### jsx
|
|
156
|
+
|
|
157
|
+
```jsx
|
|
158
|
+
<s-drop-zone
|
|
159
|
+
label="Upload"
|
|
160
|
+
accessibilityLabel="Upload image of type jpg, png, or gif"
|
|
161
|
+
accept=".jpg,.png,.gif"
|
|
162
|
+
multiple
|
|
163
|
+
onInput={(event) => console.log('onInput', event.currentTarget?.value)}
|
|
164
|
+
onChange={(event) => console.log('onChange', event.currentTarget?.value)}
|
|
165
|
+
onDropRejected={(event) => console.log('onDropRejected', event.currentTarget?.value)}
|
|
166
|
+
/>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
##### html
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<s-drop-zone
|
|
173
|
+
label="Upload"
|
|
174
|
+
accessibilityLabel="Upload image of type jpg, png, or gif"
|
|
175
|
+
accept=".jpg,.png,.gif"
|
|
176
|
+
multiple
|
|
177
|
+
onInput="console.log('onInput', event.currentTarget?.value)"
|
|
178
|
+
onChange="console.log('onChange', event.currentTarget?.value)"
|
|
179
|
+
onDropRejected="console.log('onDropRejected', event.currentTarget?.value)"
|
|
180
|
+
></s-drop-zone>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
* #### Basic usage
|
|
184
|
+
|
|
185
|
+
##### Description
|
|
186
|
+
|
|
187
|
+
Demonstrates a basic drop zone that allows multiple file uploads with a simple label.
|
|
188
|
+
|
|
189
|
+
##### jsx
|
|
190
|
+
|
|
191
|
+
```jsx
|
|
192
|
+
<s-drop-zone label="Drop files to upload" multiple />
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
##### html
|
|
196
|
+
|
|
197
|
+
```html
|
|
198
|
+
<s-drop-zone label="Drop files to upload" multiple></s-drop-zone>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
* #### Image upload
|
|
202
|
+
|
|
203
|
+
##### Description
|
|
204
|
+
|
|
205
|
+
Shows a drop zone configured specifically for uploading multiple image files.
|
|
206
|
+
|
|
207
|
+
##### jsx
|
|
208
|
+
|
|
209
|
+
```jsx
|
|
210
|
+
<s-drop-zone accept="image/*" label="Upload images" multiple />
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
##### html
|
|
214
|
+
|
|
215
|
+
```html
|
|
216
|
+
<s-drop-zone accept="image/*" label="Upload images" multiple></s-drop-zone>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
* #### With required field
|
|
220
|
+
|
|
221
|
+
##### Description
|
|
222
|
+
|
|
223
|
+
Illustrates a drop zone when the file upload is required.
|
|
224
|
+
|
|
225
|
+
##### jsx
|
|
226
|
+
|
|
227
|
+
```jsx
|
|
228
|
+
<s-drop-zone name="file" required label="Upload file" />
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
##### html
|
|
232
|
+
|
|
233
|
+
```html
|
|
234
|
+
<s-drop-zone name="file" required label="Upload file"></s-drop-zone>
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
* #### Disabled state
|
|
238
|
+
|
|
239
|
+
##### Description
|
|
240
|
+
|
|
241
|
+
Displays a drop zone in a disabled state, preventing file uploads.
|
|
242
|
+
|
|
243
|
+
##### jsx
|
|
244
|
+
|
|
245
|
+
```jsx
|
|
246
|
+
<s-drop-zone label="Upload not available" disabled />
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
##### html
|
|
250
|
+
|
|
251
|
+
```html
|
|
252
|
+
<s-drop-zone label="Upload not available" disabled></s-drop-zone>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
* #### File type restrictions
|
|
256
|
+
|
|
257
|
+
##### Description
|
|
258
|
+
|
|
259
|
+
Demonstrates restricting file uploads to specific document types like PDF and DOC.
|
|
260
|
+
|
|
261
|
+
##### jsx
|
|
262
|
+
|
|
263
|
+
```jsx
|
|
264
|
+
<s-drop-zone
|
|
265
|
+
accept=".pdf,.doc,.docx"
|
|
266
|
+
label="Upload documents"
|
|
267
|
+
multiple
|
|
268
|
+
/>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
##### html
|
|
272
|
+
|
|
273
|
+
```html
|
|
274
|
+
<s-drop-zone
|
|
275
|
+
accept=".pdf,.doc,.docx"
|
|
276
|
+
label="Upload documents"
|
|
277
|
+
multiple
|
|
278
|
+
></s-drop-zone>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
* #### With error state
|
|
282
|
+
|
|
283
|
+
##### Description
|
|
284
|
+
|
|
285
|
+
Shows a drop zone with an error message, useful for indicating file upload validation issues.
|
|
286
|
+
|
|
287
|
+
##### jsx
|
|
288
|
+
|
|
289
|
+
```jsx
|
|
290
|
+
<s-drop-zone
|
|
291
|
+
label="Upload file"
|
|
292
|
+
error="File size must be less than 5mb"
|
|
293
|
+
/>
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
##### html
|
|
297
|
+
|
|
298
|
+
```html
|
|
299
|
+
<s-drop-zone
|
|
300
|
+
label="Upload file"
|
|
301
|
+
error="File size must be less than 5mb"
|
|
302
|
+
></s-drop-zone>
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
* #### With accessibility options
|
|
306
|
+
|
|
307
|
+
##### Description
|
|
308
|
+
|
|
309
|
+
Illustrates advanced accessibility configuration for the drop zone, including custom accessibility labels.
|
|
310
|
+
|
|
311
|
+
##### jsx
|
|
312
|
+
|
|
313
|
+
```jsx
|
|
314
|
+
<s-drop-zone
|
|
315
|
+
label="Upload files"
|
|
316
|
+
accessibilityLabel="Upload files using drag and drop or file selector"
|
|
317
|
+
labelAccessibilityVisibility="exclusive"
|
|
318
|
+
multiple
|
|
319
|
+
/>
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
##### html
|
|
323
|
+
|
|
324
|
+
```html
|
|
325
|
+
<s-drop-zone
|
|
326
|
+
label="Upload files"
|
|
327
|
+
accessibilityLabel="Upload files using drag and drop or file selector"
|
|
328
|
+
labelAccessibilityVisibility="exclusive"
|
|
329
|
+
multiple
|
|
330
|
+
></s-drop-zone>
|
|
331
|
+
```
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: EmailField
|
|
3
|
+
description: Let users enter email addresses with optimized keyboard settings.
|
|
4
|
+
api_name: app-home
|
|
5
|
+
source_url:
|
|
6
|
+
html: >-
|
|
7
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/emailfield
|
|
8
|
+
md: >-
|
|
9
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/emailfield.md
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# EmailField
|
|
13
|
+
|
|
14
|
+
Let users enter email addresses with optimized keyboard settings.
|
|
15
|
+
|
|
16
|
+
## Properties
|
|
17
|
+
|
|
18
|
+
* autocomplete
|
|
19
|
+
|
|
20
|
+
"on" | "off" | EmailAutocompleteField | \`section-${string} email\` | \`section-${string} home email\` | \`section-${string} mobile email\` | \`section-${string} fax email\` | \`section-${string} pager email\` | "shipping email" | "shipping home email" | "shipping mobile email" | "shipping fax email" | "shipping pager email" | "billing email" | "billing home email" | "billing mobile email" | "billing fax email" | "billing pager email" | \`section-${string} shipping email\` | \`section-${string} shipping home email\` | \`section-${string} shipping mobile email\` | \`section-${string} shipping fax email\` | \`section-${string} shipping pager email\` | \`section-${string} billing email\` | \`section-${string} billing home email\` | \`section-${string} billing mobile email\` | \`section-${string} billing fax email\` | \`section-${string} billing pager email\`
|
|
21
|
+
|
|
22
|
+
Default: 'on' for everything else
|
|
23
|
+
|
|
24
|
+
A hint as to the intended content of the field.
|
|
25
|
+
|
|
26
|
+
When set to `on` (the default), this property indicates that the field should support autofill, but you do not have any more semantic information on the intended contents.
|
|
27
|
+
|
|
28
|
+
When set to `off`, you are indicating that this field contains sensitive information, or contents that are never saved, like one-time codes.
|
|
29
|
+
|
|
30
|
+
Alternatively, you can provide value which describes the specific data you would like to be entered into this field during autofill.
|
|
31
|
+
|
|
32
|
+
* defaultValue
|
|
33
|
+
|
|
34
|
+
string
|
|
35
|
+
|
|
36
|
+
The default value for the field.
|
|
37
|
+
|
|
38
|
+
* details
|
|
39
|
+
|
|
40
|
+
string
|
|
41
|
+
|
|
42
|
+
Additional text to provide context or guidance for the field. This text is displayed along with the field and its label to offer more information or instructions to the user.
|
|
43
|
+
|
|
44
|
+
This will also be exposed to screen reader users.
|
|
45
|
+
|
|
46
|
+
* disabled
|
|
47
|
+
|
|
48
|
+
boolean
|
|
49
|
+
|
|
50
|
+
Default: false
|
|
51
|
+
|
|
52
|
+
Disables the field, disallowing any interaction.
|
|
53
|
+
|
|
54
|
+
* error
|
|
55
|
+
|
|
56
|
+
string
|
|
57
|
+
|
|
58
|
+
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
|
|
59
|
+
|
|
60
|
+
* id
|
|
61
|
+
|
|
62
|
+
string
|
|
63
|
+
|
|
64
|
+
A unique identifier for the element.
|
|
65
|
+
|
|
66
|
+
* label
|
|
67
|
+
|
|
68
|
+
string
|
|
69
|
+
|
|
70
|
+
Content to use as the field label.
|
|
71
|
+
|
|
72
|
+
* labelAccessibilityVisibility
|
|
73
|
+
|
|
74
|
+
"visible" | "exclusive"
|
|
75
|
+
|
|
76
|
+
Default: 'visible'
|
|
77
|
+
|
|
78
|
+
Changes the visibility of the component's label.
|
|
79
|
+
|
|
80
|
+
* `visible`: the label is visible to all users.
|
|
81
|
+
* `exclusive`: the label is visually hidden but remains in the accessibility tree.
|
|
82
|
+
|
|
83
|
+
* maxLength
|
|
84
|
+
|
|
85
|
+
number
|
|
86
|
+
|
|
87
|
+
Default: Infinity
|
|
88
|
+
|
|
89
|
+
Specifies the maximum number of characters allowed.
|
|
90
|
+
|
|
91
|
+
* minLength
|
|
92
|
+
|
|
93
|
+
number
|
|
94
|
+
|
|
95
|
+
Default: 0
|
|
96
|
+
|
|
97
|
+
Specifies the min number of characters allowed.
|
|
98
|
+
|
|
99
|
+
* name
|
|
100
|
+
|
|
101
|
+
string
|
|
102
|
+
|
|
103
|
+
An identifier for the field that is unique within the nearest containing form.
|
|
104
|
+
|
|
105
|
+
* placeholder
|
|
106
|
+
|
|
107
|
+
string
|
|
108
|
+
|
|
109
|
+
A short hint that describes the expected value of the field.
|
|
110
|
+
|
|
111
|
+
* readOnly
|
|
112
|
+
|
|
113
|
+
boolean
|
|
114
|
+
|
|
115
|
+
Default: false
|
|
116
|
+
|
|
117
|
+
The field cannot be edited by the user. It is focusable will be announced by screen readers.
|
|
118
|
+
|
|
119
|
+
* required
|
|
120
|
+
|
|
121
|
+
boolean
|
|
122
|
+
|
|
123
|
+
Default: false
|
|
124
|
+
|
|
125
|
+
Whether the field needs a value. This requirement adds semantic value to the field, but it will not cause an error to appear automatically. If you want to present an error when this field is empty, you can do so with the `error` property.
|
|
126
|
+
|
|
127
|
+
* value
|
|
128
|
+
|
|
129
|
+
string
|
|
130
|
+
|
|
131
|
+
The current value for the field. If omitted, the field will be empty.
|
|
132
|
+
|
|
133
|
+
### EmailAutocompleteField
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
'email' | 'home email' | 'mobile email' | 'fax email' | 'pager email'
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Events
|
|
140
|
+
|
|
141
|
+
Learn more about [registering events](https://shopify.dev/docs/api/app-home/using-polaris-components#event-handling).
|
|
142
|
+
|
|
143
|
+
* blur
|
|
144
|
+
|
|
145
|
+
CallbackEventListener<'input'>
|
|
146
|
+
|
|
147
|
+
* change
|
|
148
|
+
|
|
149
|
+
CallbackEventListener<'input'>
|
|
150
|
+
|
|
151
|
+
* focus
|
|
152
|
+
|
|
153
|
+
CallbackEventListener<'input'>
|
|
154
|
+
|
|
155
|
+
* input
|
|
156
|
+
|
|
157
|
+
CallbackEventListener<'input'>
|
|
158
|
+
|
|
159
|
+
### CallbackEventListener
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
(EventListener & {
|
|
163
|
+
(event: CallbackEvent<T>): void;
|
|
164
|
+
}) | null
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### CallbackEvent
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
Event & {
|
|
171
|
+
currentTarget: HTMLElementTagNameMap[T];
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Examples
|
|
176
|
+
|
|
177
|
+
### Examples
|
|
178
|
+
|
|
179
|
+
* #### Code
|
|
180
|
+
|
|
181
|
+
##### jsx
|
|
182
|
+
|
|
183
|
+
```jsx
|
|
184
|
+
<s-email-field
|
|
185
|
+
label="Email"
|
|
186
|
+
placeholder="bernadette.lapresse@jadedpixel.com"
|
|
187
|
+
details="Used for sending notifications"
|
|
188
|
+
/>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
##### html
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<s-email-field
|
|
195
|
+
label="Email"
|
|
196
|
+
placeholder="bernadette.lapresse@jadedpixel.com"
|
|
197
|
+
details="Used for sending notifications"
|
|
198
|
+
></s-email-field>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
* #### Basic usage
|
|
202
|
+
|
|
203
|
+
##### Description
|
|
204
|
+
|
|
205
|
+
Demonstrates a simple email field with a label and required attribute, showing the most fundamental way to use the EmailField component.
|
|
206
|
+
|
|
207
|
+
##### jsx
|
|
208
|
+
|
|
209
|
+
```jsx
|
|
210
|
+
<s-stack gap="base">
|
|
211
|
+
<s-email-field label="Email address" required />
|
|
212
|
+
</s-stack>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
##### html
|
|
216
|
+
|
|
217
|
+
```html
|
|
218
|
+
<s-stack gap="base">
|
|
219
|
+
<s-email-field label="Email address" required></s-email-field>
|
|
220
|
+
</s-stack>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
* #### With error and help text
|
|
224
|
+
|
|
225
|
+
##### Description
|
|
226
|
+
|
|
227
|
+
Showcases an email field with additional details and an error message, illustrating how to provide contextual information and validation feedback.
|
|
228
|
+
|
|
229
|
+
##### jsx
|
|
230
|
+
|
|
231
|
+
```jsx
|
|
232
|
+
<s-stack gap="base">
|
|
233
|
+
<s-email-field
|
|
234
|
+
label="Contact email"
|
|
235
|
+
details="We'll send your order confirmation here"
|
|
236
|
+
error="Please enter a valid email address"
|
|
237
|
+
required
|
|
238
|
+
/>
|
|
239
|
+
</s-stack>
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
##### html
|
|
243
|
+
|
|
244
|
+
```html
|
|
245
|
+
<s-stack gap="base">
|
|
246
|
+
<s-email-field
|
|
247
|
+
label="Contact email"
|
|
248
|
+
details="We'll send your order confirmation here"
|
|
249
|
+
error="Please enter a valid email address"
|
|
250
|
+
required
|
|
251
|
+
></s-email-field>
|
|
252
|
+
</s-stack>
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
* #### Optional field with placeholder
|
|
256
|
+
|
|
257
|
+
##### Description
|
|
258
|
+
|
|
259
|
+
Illustrates an optional email field with a placeholder text and help text, demonstrating a common pattern for collecting alternative contact information.
|
|
260
|
+
|
|
261
|
+
##### jsx
|
|
262
|
+
|
|
263
|
+
```jsx
|
|
264
|
+
<s-stack gap="base">
|
|
265
|
+
<s-email-field
|
|
266
|
+
label="Alternate email"
|
|
267
|
+
placeholder="secondary@example.com"
|
|
268
|
+
details="Additional email for notifications"
|
|
269
|
+
/>
|
|
270
|
+
</s-stack>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
##### html
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<s-stack gap="base">
|
|
277
|
+
<s-email-field
|
|
278
|
+
label="Alternate email"
|
|
279
|
+
placeholder="secondary@example.com"
|
|
280
|
+
details="Additional email for notifications"
|
|
281
|
+
></s-email-field>
|
|
282
|
+
</s-stack>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
* #### Read-only display
|
|
286
|
+
|
|
287
|
+
##### Description
|
|
288
|
+
|
|
289
|
+
Shows how to render an email field in a read-only state, useful for displaying existing email addresses that cannot be modified.
|
|
290
|
+
|
|
291
|
+
##### jsx
|
|
292
|
+
|
|
293
|
+
```jsx
|
|
294
|
+
<s-stack gap="base">
|
|
295
|
+
<s-email-field
|
|
296
|
+
label="Account email"
|
|
297
|
+
value="user@example.com"
|
|
298
|
+
readOnly
|
|
299
|
+
/>
|
|
300
|
+
</s-stack>
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
##### html
|
|
304
|
+
|
|
305
|
+
```html
|
|
306
|
+
<s-stack gap="base">
|
|
307
|
+
<s-email-field
|
|
308
|
+
label="Account email"
|
|
309
|
+
value="user@example.com"
|
|
310
|
+
readOnly
|
|
311
|
+
></s-email-field>
|
|
312
|
+
</s-stack>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
* #### With length constraints
|
|
316
|
+
|
|
317
|
+
##### Description
|
|
318
|
+
|
|
319
|
+
Demonstrates setting minimum and maximum length constraints for the email input, providing additional validation beyond the standard email format check.
|
|
320
|
+
|
|
321
|
+
##### jsx
|
|
322
|
+
|
|
323
|
+
```jsx
|
|
324
|
+
<s-stack gap="base">
|
|
325
|
+
<s-email-field
|
|
326
|
+
label="Business email"
|
|
327
|
+
minLength={5}
|
|
328
|
+
maxLength={100}
|
|
329
|
+
required
|
|
330
|
+
/>
|
|
331
|
+
</s-stack>
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
##### html
|
|
335
|
+
|
|
336
|
+
```html
|
|
337
|
+
<s-stack gap="base">
|
|
338
|
+
<s-email-field
|
|
339
|
+
label="Business email"
|
|
340
|
+
minLength="5"
|
|
341
|
+
maxLength="100"
|
|
342
|
+
required
|
|
343
|
+
></s-email-field>
|
|
344
|
+
</s-stack>
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
* #### Email validation
|
|
348
|
+
|
|
349
|
+
##### Description
|
|
350
|
+
|
|
351
|
+
Interactive example showing real-time email validation with error messages that update as the user types.
|
|
352
|
+
|
|
353
|
+
##### jsx
|
|
354
|
+
|
|
355
|
+
```jsx
|
|
356
|
+
const [email, setEmail] = useState('invalid-email');
|
|
357
|
+
const [error, setError] = useState('Please enter a valid email address');
|
|
358
|
+
|
|
359
|
+
return (
|
|
360
|
+
<s-section>
|
|
361
|
+
<s-stack gap="base" justifyContent="start">
|
|
362
|
+
<s-text-field label="Name" />
|
|
363
|
+
<s-email-field
|
|
364
|
+
label="Contact email"
|
|
365
|
+
details="We'll send your order confirmation here"
|
|
366
|
+
value={email}
|
|
367
|
+
error={error}
|
|
368
|
+
required
|
|
369
|
+
onInput={(e) => {
|
|
370
|
+
setEmail(e.currentTarget.value);
|
|
371
|
+
setError(/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.currentTarget.value) ? '' : 'Please enter a valid email address');
|
|
372
|
+
}}
|
|
373
|
+
/>
|
|
374
|
+
</s-stack>
|
|
375
|
+
</s-section>
|
|
376
|
+
)
|
|
377
|
+
```
|