@tempoxyz/ds 0.3.10 → 0.3.13
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 +7 -6
- package/dist/docs/AGENTS.md +12 -0
- package/dist/docs/index.md +145 -0
- package/dist/docs/marketing/introduction/getting-started.md +241 -0
- package/dist/docs/product/components/accordion.md +489 -0
- package/dist/docs/product/components/address-card.md +147 -0
- package/dist/docs/product/components/agent-logo.md +194 -0
- package/dist/docs/product/components/alert-dialog.md +631 -0
- package/dist/docs/product/components/alert.md +448 -0
- package/dist/docs/product/components/amount-input.md +305 -0
- package/dist/docs/product/components/amount.md +794 -0
- package/dist/docs/product/components/app-shell.md +559 -0
- package/dist/docs/product/components/asset-chip.md +294 -0
- package/dist/docs/product/components/autocomplete.md +620 -0
- package/dist/docs/product/components/avatar.md +321 -0
- package/dist/docs/product/components/badge.md +339 -0
- package/dist/docs/product/components/badged-logo.md +116 -0
- package/dist/docs/product/components/banner.md +379 -0
- package/dist/docs/product/components/bar-chart.md +208 -0
- package/dist/docs/product/components/breadcrumbs.md +380 -0
- package/dist/docs/product/components/button-group.md +286 -0
- package/dist/docs/product/components/button.md +650 -0
- package/dist/docs/product/components/calendar.md +375 -0
- package/dist/docs/product/components/callout.md +96 -0
- package/dist/docs/product/components/checkbox-group.md +521 -0
- package/dist/docs/product/components/checkbox.md +467 -0
- package/dist/docs/product/components/choice-group.md +516 -0
- package/dist/docs/product/components/choicebox.md +641 -0
- package/dist/docs/product/components/code.md +100 -0
- package/dist/docs/product/components/combobox.md +939 -0
- package/dist/docs/product/components/container.md +257 -0
- package/dist/docs/product/components/copy-button.md +642 -0
- package/dist/docs/product/components/date-picker.md +514 -0
- package/dist/docs/product/components/dialog.md +1332 -0
- package/dist/docs/product/components/drawer.md +966 -0
- package/dist/docs/product/components/empty.md +340 -0
- package/dist/docs/product/components/field.md +570 -0
- package/dist/docs/product/components/fieldset.md +398 -0
- package/dist/docs/product/components/frame.md +434 -0
- package/dist/docs/product/components/gauge.md +299 -0
- package/dist/docs/product/components/get-started-visual.md +117 -0
- package/dist/docs/product/components/grid.md +288 -0
- package/dist/docs/product/components/hero-visual.md +155 -0
- package/dist/docs/product/components/hex.md +487 -0
- package/dist/docs/product/components/icon-tile.md +292 -0
- package/dist/docs/product/components/identicon.md +371 -0
- package/dist/docs/product/components/inline.md +233 -0
- package/dist/docs/product/components/inset.md +225 -0
- package/dist/docs/product/components/kbd.md +423 -0
- package/dist/docs/product/components/list-group.md +981 -0
- package/dist/docs/product/components/loading-dots.md +237 -0
- package/dist/docs/product/components/menu.md +934 -0
- package/dist/docs/product/components/native-select.md +204 -0
- package/dist/docs/product/components/network-logo.md +248 -0
- package/dist/docs/product/components/number-field.md +543 -0
- package/dist/docs/product/components/otp-field.md +616 -0
- package/dist/docs/product/components/pagination.md +516 -0
- package/dist/docs/product/components/popover.md +544 -0
- package/dist/docs/product/components/progress.md +388 -0
- package/dist/docs/product/components/qr.md +314 -0
- package/dist/docs/product/components/radio-group.md +528 -0
- package/dist/docs/product/components/secret-value.md +406 -0
- package/dist/docs/product/components/select.md +751 -0
- package/dist/docs/product/components/separator.md +379 -0
- package/dist/docs/product/components/sidebar-menu.md +922 -0
- package/dist/docs/product/components/skeleton.md +517 -0
- package/dist/docs/product/components/slider.md +539 -0
- package/dist/docs/product/components/snippet.md +424 -0
- package/dist/docs/product/components/spinner.md +216 -0
- package/dist/docs/product/components/split-bar.md +139 -0
- package/dist/docs/product/components/split-button.md +464 -0
- package/dist/docs/product/components/stack.md +299 -0
- package/dist/docs/product/components/status-chip.md +226 -0
- package/dist/docs/product/components/status-indicator.md +119 -0
- package/dist/docs/product/components/status-row.md +174 -0
- package/dist/docs/product/components/stepper.md +451 -0
- package/dist/docs/product/components/success-hero.md +157 -0
- package/dist/docs/product/components/surface.md +639 -0
- package/dist/docs/product/components/switch.md +472 -0
- package/dist/docs/product/components/table.md +967 -0
- package/dist/docs/product/components/tabs.md +627 -0
- package/dist/docs/product/components/tempo-logo.md +185 -0
- package/dist/docs/product/components/text-input.md +624 -0
- package/dist/docs/product/components/textarea.md +352 -0
- package/dist/docs/product/components/toast.md +535 -0
- package/dist/docs/product/components/token-logo.md +371 -0
- package/dist/docs/product/components/token.md +247 -0
- package/dist/docs/product/components/tooltip.md +490 -0
- package/dist/docs/product/components/verification-code.md +116 -0
- package/dist/docs/product/components/visual.md +249 -0
- package/dist/docs/product/components.md +203 -0
- package/dist/docs/product/foundations/accessibility.md +377 -0
- package/dist/docs/product/foundations/agents.md +150 -0
- package/dist/docs/product/foundations/color.md +522 -0
- package/dist/docs/product/foundations/content/tone.md +194 -0
- package/dist/docs/product/foundations/content/voice.md +194 -0
- package/dist/docs/product/foundations/content/writing-style.md +406 -0
- package/dist/docs/product/foundations/iconography.md +282 -0
- package/dist/docs/product/foundations/intent.md +360 -0
- package/dist/docs/product/foundations/layout.md +508 -0
- package/dist/docs/product/foundations/linter.md +496 -0
- package/dist/docs/product/foundations/motion.md +151 -0
- package/dist/docs/product/foundations/radius-and-padding.md +86 -0
- package/dist/docs/product/foundations/typography.md +266 -0
- package/dist/docs/product/introduction/faq.md +133 -0
- package/dist/docs/product/introduction/getting-started.md +377 -0
- package/dist/docs/product/patterns/blockchain-values.md +709 -0
- package/dist/docs/product/patterns/dashboards.md +638 -0
- package/dist/docs/product/patterns/destructive-actions.md +626 -0
- package/dist/docs/product/patterns/empty-states.md +612 -0
- package/dist/docs/product/patterns/errors-and-validation.md +808 -0
- package/dist/docs/product/patterns/feedback-and-status.md +518 -0
- package/dist/docs/product/patterns/forms.md +679 -0
- package/dist/docs/product/patterns/loading.md +630 -0
- package/dist/docs/product/patterns/navigation.md +397 -0
- package/dist/docs/product/patterns/payments.md +765 -0
- package/dist/docs/product/patterns/responsive-layout.md +997 -0
- package/dist/docs/product/patterns/tables-and-lists.md +964 -0
- package/dist/docs/product/products/tempo-console.md +671 -0
- package/dist/docs/product/products/tempo-performance.md +437 -0
- package/dist/docs/product/products/tempo-wallet.md +438 -0
- package/dist/marketing/index.d.ts +4 -0
- package/dist/marketing/index.d.ts.map +1 -0
- package/dist/marketing/index.js +4 -0
- package/dist/marketing/index.js.map +1 -0
- package/dist/marketing/index.js.zyzz.json +1 -0
- package/dist/marketing/vars.d.ts +907 -0
- package/dist/marketing/vars.d.ts.map +1 -0
- package/dist/marketing/vars.js +15 -0
- package/dist/marketing/vars.js.map +1 -0
- package/dist/marketing/vars.js.zyzz.json +1 -0
- package/dist/marketing/zyzz.config.d.ts +4512 -0
- package/dist/marketing/zyzz.config.d.ts.map +1 -0
- package/dist/marketing/zyzz.config.js +63 -0
- package/dist/marketing/zyzz.config.js.map +1 -0
- package/dist/marketing/zyzz.config.js.zyzz.json +1 -0
- package/dist/oxlint/index.d.ts +12 -1
- package/dist/oxlint/index.d.ts.map +1 -1
- package/dist/oxlint/index.js +39 -1
- package/dist/oxlint/index.js.map +1 -1
- package/dist/oxlint/internal/Docs.d.ts +9 -0
- package/dist/oxlint/internal/Docs.d.ts.map +1 -0
- package/dist/oxlint/internal/Docs.js +15 -0
- package/dist/oxlint/internal/Docs.js.map +1 -0
- package/dist/oxlint/internal/Imports.d.ts +1 -1
- package/dist/oxlint/internal/Imports.d.ts.map +1 -1
- package/dist/oxlint/internal/Imports.js +2 -0
- package/dist/oxlint/internal/Imports.js.map +1 -1
- package/dist/oxlint/internal/Styles.d.ts +40 -0
- package/dist/oxlint/internal/Styles.d.ts.map +1 -0
- package/dist/oxlint/internal/Styles.js +194 -0
- package/dist/oxlint/internal/Styles.js.map +1 -0
- package/dist/oxlint/internal/Tokens.d.ts +16 -0
- package/dist/oxlint/internal/Tokens.d.ts.map +1 -0
- package/dist/oxlint/internal/Tokens.js +39 -0
- package/dist/oxlint/internal/Tokens.js.map +1 -0
- package/dist/oxlint/rules/NoCrossSurface.d.ts +2 -2
- package/dist/oxlint/rules/NoCrossSurface.js +3 -3
- package/dist/oxlint/rules/NoCrossSurface.js.map +1 -1
- package/dist/oxlint/rules/NoCustomValues.d.ts +11 -0
- package/dist/oxlint/rules/NoCustomValues.d.ts.map +1 -0
- package/dist/oxlint/rules/NoCustomValues.js +150 -0
- package/dist/oxlint/rules/NoCustomValues.js.map +1 -0
- package/dist/oxlint/rules/NoSingleKeyShortcuts.d.ts +11 -0
- package/dist/oxlint/rules/NoSingleKeyShortcuts.d.ts.map +1 -0
- package/dist/oxlint/rules/NoSingleKeyShortcuts.js +158 -0
- package/dist/oxlint/rules/NoSingleKeyShortcuts.js.map +1 -0
- package/dist/oxlint/rules/PreferComponent.d.ts +3 -2
- package/dist/oxlint/rules/PreferComponent.d.ts.map +1 -1
- package/dist/oxlint/rules/PreferComponent.js +11 -4
- package/dist/oxlint/rules/PreferComponent.js.map +1 -1
- package/dist/oxlint/rules/PreferLayout.d.ts +9 -0
- package/dist/oxlint/rules/PreferLayout.d.ts.map +1 -0
- package/dist/oxlint/rules/PreferLayout.js +90 -0
- package/dist/oxlint/rules/PreferLayout.js.map +1 -0
- package/dist/oxlint/rules/PreferProgress.d.ts +9 -0
- package/dist/oxlint/rules/PreferProgress.d.ts.map +1 -0
- package/dist/oxlint/rules/PreferProgress.js +43 -0
- package/dist/oxlint/rules/PreferProgress.js.map +1 -0
- package/dist/oxlint/rules/PreferSurface.d.ts +9 -0
- package/dist/oxlint/rules/PreferSurface.d.ts.map +1 -0
- package/dist/oxlint/rules/PreferSurface.js +55 -0
- package/dist/oxlint/rules/PreferSurface.js.map +1 -0
- package/dist/oxlint/rules/RequireAccessibleName.d.ts.map +1 -1
- package/dist/oxlint/rules/RequireAccessibleName.js +3 -1
- package/dist/oxlint/rules/RequireAccessibleName.js.map +1 -1
- package/dist/oxlint/rules/RequireScrollRegion.d.ts +11 -0
- package/dist/oxlint/rules/RequireScrollRegion.d.ts.map +1 -0
- package/dist/oxlint/rules/RequireScrollRegion.js +71 -0
- package/dist/oxlint/rules/RequireScrollRegion.js.map +1 -0
- package/dist/web/icons/index.js.zyzz.json +1 -0
- package/package.json +6 -1
- package/src/marketing/README.md +21 -0
- package/src/marketing/index.ts +3 -0
- package/src/marketing/vars.ts +751 -0
- package/src/marketing/zyzz.config.ts +376 -0
- package/src/oxlint/index.ts +40 -1
- package/src/oxlint/internal/Docs.ts +18 -0
- package/src/oxlint/internal/Imports.ts +2 -1
- package/src/oxlint/internal/Styles.ts +240 -0
- package/src/oxlint/internal/Tokens.ts +43 -0
- package/src/oxlint/rules/NoCrossSurface.ts +3 -3
- package/src/oxlint/rules/NoCustomValues.ts +170 -0
- package/src/oxlint/rules/NoSingleKeyShortcuts.ts +190 -0
- package/src/oxlint/rules/PreferComponent.ts +11 -4
- package/src/oxlint/rules/PreferLayout.ts +96 -0
- package/src/oxlint/rules/PreferProgress.ts +49 -0
- package/src/oxlint/rules/PreferSurface.ts +70 -0
- package/src/oxlint/rules/RequireAccessibleName.ts +3 -1
- package/src/oxlint/rules/RequireScrollRegion.ts +92 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# AmountInput
|
|
2
|
+
|
|
3
|
+
Accepts a decimal amount, such as a payment or transfer value.
|
|
4
|
+
|
|
5
|
+
[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/AmountInput.tsx)
|
|
6
|
+
|
|
7
|
+
Figma: [Inputs/Amount Input](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-1389) (`AmountInput.Root`)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
An amount input is a filled card with the label, the amount in heading-size digits, a token chip, and the balance. It keeps the value as a raw string and rejects input that is not a non-negative decimal.
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
15
|
+
### Basic
|
|
16
|
+
|
|
17
|
+
Place the `Field.Label`, a [Token](token.md), and a `Field.Description` inside `AmountInput.Root`. They take their own rows above and below the amount.
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
21
|
+
|
|
22
|
+
export const fill = true
|
|
23
|
+
export function Demo() {
|
|
24
|
+
return (
|
|
25
|
+
<Field.Root {...styles.field()}>
|
|
26
|
+
<AmountInput.Root>
|
|
27
|
+
<Field.Label>You send</Field.Label>
|
|
28
|
+
<AmountInput.Control placeholder="0.00" />
|
|
29
|
+
<Token address="0x20c0000000000000000000000000000000000000" symbol="pathUSD" />
|
|
30
|
+
<Field.Description>Balance 2,480.32</Field.Description>
|
|
31
|
+
</AmountInput.Root>
|
|
32
|
+
</Field.Root>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
namespace styles {
|
|
37
|
+
export const field = style({ maxWidth: '24rem !custom' })
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/AmountInput/Basic.tsx)
|
|
42
|
+
|
|
43
|
+
## Anatomy
|
|
44
|
+
|
|
45
|
+
Import the component and assemble its parts.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { AmountInput, Token } from '@tempoxyz/ds'
|
|
49
|
+
|
|
50
|
+
<AmountInput.Root>
|
|
51
|
+
<AmountInput.Control />
|
|
52
|
+
</AmountInput.Root>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Guidelines
|
|
56
|
+
|
|
57
|
+
### When to Use
|
|
58
|
+
|
|
59
|
+
* Enter a money or token amount, such as for Send, Convert, or Add funds.
|
|
60
|
+
* Put it first in a dialog body, above the recipient field.
|
|
61
|
+
|
|
62
|
+
### When Not to Use
|
|
63
|
+
|
|
64
|
+
* Use [NumberField](number-field.md) for whole quantities adjusted in steps, such as webhook retries.
|
|
65
|
+
* Use [TextInput](text-input.md) for identifiers with digits, such as a 0x address or a bank account number.
|
|
66
|
+
* Use [OtpField](otp-field.md) for one-time verification codes.
|
|
67
|
+
* Use [Amount](amount.md) to show a read-only value, such as a balance or a network fee.
|
|
68
|
+
|
|
69
|
+
### Name the Token Beside the Digits
|
|
70
|
+
|
|
71
|
+
Put a [Token](token.md) after `AmountInput.Control`. Give it `readOnly` when the token is fixed, and pass it to a picker trigger's `render` when the token can change.
|
|
72
|
+
|
|
73
|
+
**Do:** Name the token beside the amount with a [Token](token.md).
|
|
74
|
+
|
|
75
|
+
```tsx
|
|
76
|
+
/**
|
|
77
|
+
* Do example for "Name the Token Beside the Digits" on the AmountInput page.
|
|
78
|
+
* Name the token beside the amount with a `Token`.
|
|
79
|
+
* @module
|
|
80
|
+
*/
|
|
81
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
82
|
+
|
|
83
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
84
|
+
export function Demo() {
|
|
85
|
+
return (
|
|
86
|
+
<Field.Root {...styles.field()}>
|
|
87
|
+
<AmountInput.Root defaultValue="120.50">
|
|
88
|
+
<Field.Label>Amount</Field.Label>
|
|
89
|
+
<AmountInput.Control placeholder="0.00" />
|
|
90
|
+
<Token readOnly symbol="PathUSD" />
|
|
91
|
+
</AmountInput.Root>
|
|
92
|
+
</Field.Root>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
namespace styles {
|
|
97
|
+
export const field = style({ width: '100% !custom' })
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Don't:** Leave the token to the page around the card.
|
|
102
|
+
|
|
103
|
+
```tsx
|
|
104
|
+
/**
|
|
105
|
+
* Don't example for "Name the Token Beside the Digits" on the AmountInput page.
|
|
106
|
+
* Don't leave the token to the page around the card.
|
|
107
|
+
* @module
|
|
108
|
+
*/
|
|
109
|
+
import { AmountInput, Field, style } from '@tempoxyz/ds'
|
|
110
|
+
|
|
111
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
112
|
+
export function Demo() {
|
|
113
|
+
return (
|
|
114
|
+
<Field.Root {...styles.field()}>
|
|
115
|
+
<AmountInput.Root defaultValue="120.50">
|
|
116
|
+
<Field.Label>Amount</Field.Label>
|
|
117
|
+
<AmountInput.Control placeholder="0.00" />
|
|
118
|
+
</AmountInput.Root>
|
|
119
|
+
</Field.Root>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
namespace styles {
|
|
124
|
+
export const field = style({ width: '100% !custom' })
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Show the Available Balance
|
|
129
|
+
|
|
130
|
+
Put the spendable balance in a `Field.Description` inside the card, such as Balance: 250.00 USDC, with the decimals and token code used elsewhere in the product.
|
|
131
|
+
|
|
132
|
+
**Do:** Show the spendable balance in the card, below the amount.
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
/**
|
|
136
|
+
* Do example for "Show the Available Balance" on the AmountInput page.
|
|
137
|
+
* Show the spendable balance in the card, below the amount.
|
|
138
|
+
* @module
|
|
139
|
+
*/
|
|
140
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
141
|
+
|
|
142
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
143
|
+
export function Demo() {
|
|
144
|
+
return (
|
|
145
|
+
<Field.Root {...styles.field()}>
|
|
146
|
+
<AmountInput.Root>
|
|
147
|
+
<Field.Label>Amount</Field.Label>
|
|
148
|
+
<AmountInput.Control placeholder="0.00" />
|
|
149
|
+
<Token readOnly symbol="USDC" />
|
|
150
|
+
<Field.Description>Balance: 250.00 USDC</Field.Description>
|
|
151
|
+
</AmountInput.Root>
|
|
152
|
+
</Field.Root>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
namespace styles {
|
|
157
|
+
export const field = style({ width: '100% !custom' })
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Don't:** Leave the balance to another part of the page.
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
/**
|
|
165
|
+
* Don't example for "Show the Available Balance" on the AmountInput page.
|
|
166
|
+
* Don't leave the balance to another part of the page.
|
|
167
|
+
* @module
|
|
168
|
+
*/
|
|
169
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
170
|
+
|
|
171
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
172
|
+
export function Demo() {
|
|
173
|
+
return (
|
|
174
|
+
<Field.Root {...styles.field()}>
|
|
175
|
+
<AmountInput.Root>
|
|
176
|
+
<Field.Label>Amount</Field.Label>
|
|
177
|
+
<AmountInput.Control placeholder="0.00" />
|
|
178
|
+
<Token readOnly symbol="USDC" />
|
|
179
|
+
</AmountInput.Root>
|
|
180
|
+
</Field.Root>
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
namespace styles {
|
|
185
|
+
export const field = style({ width: '100% !custom' })
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Explain Invalid Amounts in Text
|
|
190
|
+
|
|
191
|
+
The root allows any number of fraction digits. Check the value against the token's decimals, such as 6 for USDC, and against the balance. Set `invalid` on the `Field.Root` and add a `Field.Error` that names the limit.
|
|
192
|
+
|
|
193
|
+
* **Separator:** A period or a lone comma separates decimals, so `1,5` is `1.5` and `0,250` is `0.250`. A lone comma groups thousands when one to three digits without a leading zero precede it and three follow it, as in `1,250`. Several commas group thousands. With both separators, the last one separates decimals, so `1.250,50` is `1250.50`.
|
|
194
|
+
* **Value:** Keep the raw string from `onValueChange`. Convert it with exact decimal math, not floating-point numbers.
|
|
195
|
+
|
|
196
|
+
**Do:** Name the limit in a `Field.Error`, such as the token's decimals.
|
|
197
|
+
|
|
198
|
+
```tsx
|
|
199
|
+
/**
|
|
200
|
+
* Do example for "Explain Invalid Amounts in Text" on the AmountInput page.
|
|
201
|
+
* Name the limit in a `Field.Error`, such as the token's decimals.
|
|
202
|
+
* @module
|
|
203
|
+
*/
|
|
204
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
205
|
+
|
|
206
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
207
|
+
export function Demo() {
|
|
208
|
+
return (
|
|
209
|
+
<Field.Root invalid {...styles.field()}>
|
|
210
|
+
<AmountInput.Root defaultValue="12.5000001" invalid>
|
|
211
|
+
<Field.Label>Amount</Field.Label>
|
|
212
|
+
<AmountInput.Control />
|
|
213
|
+
<Token readOnly symbol="USDC" />
|
|
214
|
+
<Field.Error match>Enter an amount with up to 6 decimal places.</Field.Error>
|
|
215
|
+
</AmountInput.Root>
|
|
216
|
+
</Field.Root>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
namespace styles {
|
|
221
|
+
export const field = style({ width: '100% !custom' })
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Don't:** Rely on the red fill alone.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
/**
|
|
229
|
+
* Don't example for "Explain Invalid Amounts in Text" on the AmountInput page.
|
|
230
|
+
* Don't rely on the red fill alone.
|
|
231
|
+
* @module
|
|
232
|
+
*/
|
|
233
|
+
import { AmountInput, Field, style, Token } from '@tempoxyz/ds'
|
|
234
|
+
|
|
235
|
+
/** Renders the static preview, which the guideline card shows inert. */
|
|
236
|
+
export function Demo() {
|
|
237
|
+
return (
|
|
238
|
+
<Field.Root invalid {...styles.field()}>
|
|
239
|
+
<AmountInput.Root defaultValue="12.5000001" invalid>
|
|
240
|
+
<Field.Label>Amount</Field.Label>
|
|
241
|
+
<AmountInput.Control />
|
|
242
|
+
<Token readOnly symbol="USDC" />
|
|
243
|
+
</AmountInput.Root>
|
|
244
|
+
</Field.Root>
|
|
245
|
+
)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
namespace styles {
|
|
249
|
+
export const field = style({ width: '100% !custom' })
|
|
250
|
+
}
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Stack Two Cards for a Conversion
|
|
254
|
+
|
|
255
|
+
For a conversion, place a From card and a To card one above the other, with a small arrow [Button](button.md) between them that swaps the two.
|
|
256
|
+
|
|
257
|
+
## Content
|
|
258
|
+
|
|
259
|
+
* **Label:** Use You send and You receive on a send or convert screen, and Amount in other forms.
|
|
260
|
+
* **Balance:** Write Balance and the amount, such as Balance 2,480.32.
|
|
261
|
+
|
|
262
|
+
## Accessibility
|
|
263
|
+
|
|
264
|
+
`AmountInput` renders a native text input for decimal amounts inside the card.
|
|
265
|
+
|
|
266
|
+
### Semantics
|
|
267
|
+
|
|
268
|
+
* **AmountInput.Control (textbox):** A text input with a decimal keypad. Name it with `Field.Label`, or `aria-label` if no label fits.
|
|
269
|
+
* **Animated Digits (aria-hidden):** Decorative. Screen readers read the value from the input, not from the morphing digits.
|
|
270
|
+
* **Invalid (aria-invalid):** Set `invalid` on the root, or on the `Field.Root`, to fill the card red and mark the input.
|
|
271
|
+
* **Reduced Motion (prefers-reduced-motion):** The digits stop morphing and change at once. The nudge on an invalid amount doesn't play.
|
|
272
|
+
|
|
273
|
+
### Keyboard
|
|
274
|
+
|
|
275
|
+
* **Move to the TextInput (Tab):** Moves focus to the input, then to the token chip when it is a button.
|
|
276
|
+
* **Ignore Other Keys (Letters):** Keystrokes that don't form a non-negative decimal leave the value unchanged.
|
|
277
|
+
|
|
278
|
+
The ignored keystrokes have no announcement. State the accepted format, such as the decimal limit, in the description.
|
|
279
|
+
|
|
280
|
+
### Your Responsibilities
|
|
281
|
+
|
|
282
|
+
* **Label the Field (Field.Label):** Give the field a visible label, and name the token in the chip or the description.
|
|
283
|
+
* **Explain Invalid Amounts (Field.Error):** Say what is allowed, such as "Enter up to 250.00 USDC", not only with the red fill.
|
|
284
|
+
|
|
285
|
+
## Related
|
|
286
|
+
|
|
287
|
+
[Amount](amount.md)
|
|
288
|
+
|
|
289
|
+
Use for displaying amounts.
|
|
290
|
+
|
|
291
|
+
[Field](field.md)
|
|
292
|
+
|
|
293
|
+
Use for the label, balance, and error.
|
|
294
|
+
|
|
295
|
+
[NumberField](number-field.md)
|
|
296
|
+
|
|
297
|
+
Use for stepped quantities.
|
|
298
|
+
|
|
299
|
+
[Token](token.md)
|
|
300
|
+
|
|
301
|
+
Use for the token pill beside the amount.
|
|
302
|
+
|
|
303
|
+
[Payments](../patterns/payments.md)
|
|
304
|
+
|
|
305
|
+
Covers send, review, and confirmation flows.
|