@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
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MoneyField
|
|
3
|
+
description: >-
|
|
4
|
+
Collect monetary values from users with built-in currency formatting and
|
|
5
|
+
validation.
|
|
6
|
+
api_name: app-home
|
|
7
|
+
source_url:
|
|
8
|
+
html: >-
|
|
9
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/moneyfield
|
|
10
|
+
md: >-
|
|
11
|
+
https://shopify.dev/docs/api/app-home/polaris-web-components/forms/moneyfield.md
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# MoneyField
|
|
15
|
+
|
|
16
|
+
Collect monetary values from users with built-in currency formatting and validation.
|
|
17
|
+
|
|
18
|
+
## Properties
|
|
19
|
+
|
|
20
|
+
* autocomplete
|
|
21
|
+
|
|
22
|
+
string
|
|
23
|
+
|
|
24
|
+
Default: 'on' for everything else
|
|
25
|
+
|
|
26
|
+
A hint as to the intended content of the field.
|
|
27
|
+
|
|
28
|
+
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.
|
|
29
|
+
|
|
30
|
+
When set to `off`, you are indicating that this field contains sensitive information, or contents that are never saved, like one-time codes.
|
|
31
|
+
|
|
32
|
+
Alternatively, you can provide value which describes the specific data you would like to be entered into this field during autofill.
|
|
33
|
+
|
|
34
|
+
* defaultValue
|
|
35
|
+
|
|
36
|
+
string
|
|
37
|
+
|
|
38
|
+
The default value for the field.
|
|
39
|
+
|
|
40
|
+
* details
|
|
41
|
+
|
|
42
|
+
string
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
This will also be exposed to screen reader users.
|
|
47
|
+
|
|
48
|
+
* disabled
|
|
49
|
+
|
|
50
|
+
boolean
|
|
51
|
+
|
|
52
|
+
Default: false
|
|
53
|
+
|
|
54
|
+
Disables the field, disallowing any interaction.
|
|
55
|
+
|
|
56
|
+
* error
|
|
57
|
+
|
|
58
|
+
string
|
|
59
|
+
|
|
60
|
+
Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.
|
|
61
|
+
|
|
62
|
+
* id
|
|
63
|
+
|
|
64
|
+
string
|
|
65
|
+
|
|
66
|
+
A unique identifier for the element.
|
|
67
|
+
|
|
68
|
+
* label
|
|
69
|
+
|
|
70
|
+
string
|
|
71
|
+
|
|
72
|
+
Content to use as the field label.
|
|
73
|
+
|
|
74
|
+
* labelAccessibilityVisibility
|
|
75
|
+
|
|
76
|
+
"visible" | "exclusive"
|
|
77
|
+
|
|
78
|
+
Default: 'visible'
|
|
79
|
+
|
|
80
|
+
Changes the visibility of the component's label.
|
|
81
|
+
|
|
82
|
+
* `visible`: the label is visible to all users.
|
|
83
|
+
* `exclusive`: the label is visually hidden but remains in the accessibility tree.
|
|
84
|
+
|
|
85
|
+
* max
|
|
86
|
+
|
|
87
|
+
number
|
|
88
|
+
|
|
89
|
+
Default: Infinity
|
|
90
|
+
|
|
91
|
+
The highest decimal or integer to be accepted for the field. When used with `step` the value will round down to the max number.
|
|
92
|
+
|
|
93
|
+
Note: a user will still be able to use the keyboard to input a number higher than the max. It is up to the developer to add appropriate validation.
|
|
94
|
+
|
|
95
|
+
* min
|
|
96
|
+
|
|
97
|
+
number
|
|
98
|
+
|
|
99
|
+
Default: -Infinity
|
|
100
|
+
|
|
101
|
+
The lowest decimal or integer to be accepted for the field. When used with `step` the value will round up to the min number.
|
|
102
|
+
|
|
103
|
+
Note: a user will still be able to use the keyboard to input a number lower than the min. It is up to the developer to add appropriate validation.
|
|
104
|
+
|
|
105
|
+
* name
|
|
106
|
+
|
|
107
|
+
string
|
|
108
|
+
|
|
109
|
+
An identifier for the field that is unique within the nearest containing form.
|
|
110
|
+
|
|
111
|
+
* placeholder
|
|
112
|
+
|
|
113
|
+
string
|
|
114
|
+
|
|
115
|
+
A short hint that describes the expected value of the field.
|
|
116
|
+
|
|
117
|
+
* readOnly
|
|
118
|
+
|
|
119
|
+
boolean
|
|
120
|
+
|
|
121
|
+
Default: false
|
|
122
|
+
|
|
123
|
+
The field cannot be edited by the user. It is focusable will be announced by screen readers.
|
|
124
|
+
|
|
125
|
+
* required
|
|
126
|
+
|
|
127
|
+
boolean
|
|
128
|
+
|
|
129
|
+
Default: false
|
|
130
|
+
|
|
131
|
+
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.
|
|
132
|
+
|
|
133
|
+
* value
|
|
134
|
+
|
|
135
|
+
string
|
|
136
|
+
|
|
137
|
+
The current value for the field. If omitted, the field will be empty.
|
|
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-money-field
|
|
185
|
+
label="Regional Price"
|
|
186
|
+
placeholder="99.99"
|
|
187
|
+
details="Recommended price for the European market"
|
|
188
|
+
/>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
##### html
|
|
192
|
+
|
|
193
|
+
```html
|
|
194
|
+
<s-money-field
|
|
195
|
+
label="Regional Price"
|
|
196
|
+
placeholder="99.99"
|
|
197
|
+
details="Recommended price for the European market"
|
|
198
|
+
></s-money-field>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
* #### Basic usage
|
|
202
|
+
|
|
203
|
+
##### Description
|
|
204
|
+
|
|
205
|
+
Demonstrates a simple money field with a label, initial value, and numeric constraints.
|
|
206
|
+
|
|
207
|
+
##### jsx
|
|
208
|
+
|
|
209
|
+
```jsx
|
|
210
|
+
<s-money-field
|
|
211
|
+
label="Price"
|
|
212
|
+
value="19.99"
|
|
213
|
+
min={0}
|
|
214
|
+
max={1000}
|
|
215
|
+
/>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
##### html
|
|
219
|
+
|
|
220
|
+
```html
|
|
221
|
+
<s-money-field
|
|
222
|
+
label="Price"
|
|
223
|
+
value="19.99"
|
|
224
|
+
min="0"
|
|
225
|
+
max="1000"
|
|
226
|
+
></s-money-field>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
* #### With validation limits
|
|
230
|
+
|
|
231
|
+
##### Description
|
|
232
|
+
|
|
233
|
+
Showcases a money field with explicit minimum and maximum value limits, and a detailed description for user guidance.
|
|
234
|
+
|
|
235
|
+
##### jsx
|
|
236
|
+
|
|
237
|
+
```jsx
|
|
238
|
+
<s-money-field
|
|
239
|
+
label="Discount amount"
|
|
240
|
+
value="5.00"
|
|
241
|
+
min={0}
|
|
242
|
+
max={100}
|
|
243
|
+
details="Enter discount amount between $0 and $100"
|
|
244
|
+
/>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
##### html
|
|
248
|
+
|
|
249
|
+
```html
|
|
250
|
+
<s-money-field
|
|
251
|
+
label="Discount amount"
|
|
252
|
+
value="5.00"
|
|
253
|
+
min="0"
|
|
254
|
+
max="100"
|
|
255
|
+
details="Enter discount amount between $0 and $100"
|
|
256
|
+
></s-money-field>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
* #### Basic field
|
|
260
|
+
|
|
261
|
+
##### Description
|
|
262
|
+
|
|
263
|
+
Illustrates a money field demonstrating basic error handling and validation.
|
|
264
|
+
|
|
265
|
+
##### jsx
|
|
266
|
+
|
|
267
|
+
```jsx
|
|
268
|
+
<s-money-field
|
|
269
|
+
label="Product cost"
|
|
270
|
+
value="29.99"
|
|
271
|
+
min={0.01}
|
|
272
|
+
error="Product cost is required"
|
|
273
|
+
/>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
##### html
|
|
277
|
+
|
|
278
|
+
```html
|
|
279
|
+
<s-money-field
|
|
280
|
+
label="Product cost"
|
|
281
|
+
value="29.99"
|
|
282
|
+
min="0.01"
|
|
283
|
+
error="Product cost is required"
|
|
284
|
+
></s-money-field>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
* #### Currency formatting with form integration
|
|
288
|
+
|
|
289
|
+
##### Description
|
|
290
|
+
|
|
291
|
+
Displays multiple money fields in a vertical stack, showing how to integrate multiple currency inputs in a form with varied details and constraints.
|
|
292
|
+
|
|
293
|
+
##### jsx
|
|
294
|
+
|
|
295
|
+
```jsx
|
|
296
|
+
<s-stack direction="block" gap="base">
|
|
297
|
+
<s-money-field
|
|
298
|
+
label="Price"
|
|
299
|
+
value="0.00"
|
|
300
|
+
min={0.01}
|
|
301
|
+
max={99999.99}
|
|
302
|
+
details="Customers will see this price"
|
|
303
|
+
/>
|
|
304
|
+
|
|
305
|
+
<s-money-field
|
|
306
|
+
label="Compare at price"
|
|
307
|
+
value=""
|
|
308
|
+
min={0}
|
|
309
|
+
max={99999.99}
|
|
310
|
+
details="Show customers the original price when on sale"
|
|
311
|
+
/>
|
|
312
|
+
|
|
313
|
+
<s-money-field
|
|
314
|
+
label="Cost per item"
|
|
315
|
+
value=""
|
|
316
|
+
min={0}
|
|
317
|
+
max={99999.99}
|
|
318
|
+
details="Customers won't see this"
|
|
319
|
+
/>
|
|
320
|
+
</s-stack>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
##### html
|
|
324
|
+
|
|
325
|
+
```html
|
|
326
|
+
<s-stack direction="block" gap="base">
|
|
327
|
+
<s-money-field
|
|
328
|
+
label="Price"
|
|
329
|
+
value="0.00"
|
|
330
|
+
min="0.01"
|
|
331
|
+
max="99999.99"
|
|
332
|
+
details="Customers will see this price"
|
|
333
|
+
></s-money-field>
|
|
334
|
+
|
|
335
|
+
<s-money-field
|
|
336
|
+
label="Compare at price"
|
|
337
|
+
value=""
|
|
338
|
+
min="0"
|
|
339
|
+
max="99999.99"
|
|
340
|
+
details="Show customers the original price when on sale"
|
|
341
|
+
></s-money-field>
|
|
342
|
+
|
|
343
|
+
<s-money-field
|
|
344
|
+
label="Cost per item"
|
|
345
|
+
value=""
|
|
346
|
+
min="0"
|
|
347
|
+
max="99999.99"
|
|
348
|
+
details="Customers won't see this"
|
|
349
|
+
></s-money-field>
|
|
350
|
+
</s-stack>
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
* #### Money field validation
|
|
354
|
+
|
|
355
|
+
##### Description
|
|
356
|
+
|
|
357
|
+
Interactive example showing real-time validation with min/max limits and dynamic error messages.
|
|
358
|
+
|
|
359
|
+
##### jsx
|
|
360
|
+
|
|
361
|
+
```jsx
|
|
362
|
+
const [amount, setAmount] = useState('150');
|
|
363
|
+
const [error, setError] = useState('Value must be no more than $100');
|
|
364
|
+
|
|
365
|
+
return (
|
|
366
|
+
<s-section>
|
|
367
|
+
<s-stack gap="base" justifyContent="start">
|
|
368
|
+
<s-text-field label="Product name" />
|
|
369
|
+
<s-money-field
|
|
370
|
+
label="Discount amount"
|
|
371
|
+
value={amount}
|
|
372
|
+
min={0}
|
|
373
|
+
max={100}
|
|
374
|
+
details="Enter discount amount between $0 and $100"
|
|
375
|
+
error={error}
|
|
376
|
+
onInput={(e) => {
|
|
377
|
+
setAmount(e.currentTarget.value);
|
|
378
|
+
const val = parseFloat(e.currentTarget.value);
|
|
379
|
+
setError(val > e.currentTarget.max ? 'Value must be no more than $100' : val < e.currentTarget.min ? 'Value must be at least $0' : '');
|
|
380
|
+
}}
|
|
381
|
+
/>
|
|
382
|
+
</s-stack>
|
|
383
|
+
</s-section>
|
|
384
|
+
)
|
|
385
|
+
```
|