@amos.com/amos-js 0.1.2 → 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 +17 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/types.d.ts +15 -1
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/types.ts +27 -0
package/README.md
CHANGED
|
@@ -167,11 +167,12 @@ In short, your app orchestrates the payment flow, while sensitive payment data s
|
|
|
167
167
|
|
|
168
168
|
## Appearance
|
|
169
169
|
|
|
170
|
-
Every mount function (and the `attach*Listeners` helpers) accepts an optional `appearance` option that controls the look of the iframe UI. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings. You can update appearance after page load via the controller's `update({ appearance })` method.
|
|
170
|
+
Every mount function (and the `attach*Listeners` helpers) accepts an optional `appearance` option that controls the look of the iframe UI. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting for field label placement. You can update appearance after page load via the controller's `update({ appearance })` method.
|
|
171
171
|
|
|
172
172
|
```ts
|
|
173
173
|
form.update({
|
|
174
174
|
appearance: {
|
|
175
|
+
labels: "floating",
|
|
175
176
|
themeVariables: {
|
|
176
177
|
"--primary": "oklch(0.5 0.2 240)",
|
|
177
178
|
"--radius": "0.25rem",
|
|
@@ -182,6 +183,18 @@ form.update({
|
|
|
182
183
|
|
|
183
184
|
Only the variables you provide are sent; omitted variables keep their defaults.
|
|
184
185
|
|
|
186
|
+
### Label placement
|
|
187
|
+
|
|
188
|
+
Set `labels` to control how field labels are rendered in card and bank account forms:
|
|
189
|
+
|
|
190
|
+
| Value | Behavior |
|
|
191
|
+
| ----- | -------- |
|
|
192
|
+
| `above` (default) | Label text above each input |
|
|
193
|
+
| `floating` | Label inside the control; moves up when focused or filled |
|
|
194
|
+
| `placeholder` | No visible label; placeholder and `aria-label` only |
|
|
195
|
+
|
|
196
|
+
Radio groups (e.g. account type) always use an above-style group label regardless of this setting.
|
|
197
|
+
|
|
185
198
|
### Available theme variables
|
|
186
199
|
|
|
187
200
|
| Variable | Purpose | Default |
|
|
@@ -198,6 +211,8 @@ Only the variables you provide are sent; omitted variables keep their defaults.
|
|
|
198
211
|
| `--destructive` | Error/invalid state borders and icons | `oklch(0.577 0.245 27.325)` |
|
|
199
212
|
| `--border` | General border color | `oklch(0.922 0 0)` |
|
|
200
213
|
| `--input` | Input field border color | `oklch(0.922 0 0)` |
|
|
214
|
+
| `--input-background` | Input field background fill | `var(--background)` |
|
|
215
|
+
| `--input-height` | Height of text inputs and form controls | `2.25rem` |
|
|
201
216
|
| `--ring` | Focus ring and outline color | `oklch(0.708 0 0)` |
|
|
202
217
|
| `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
|
|
203
218
|
|
|
@@ -214,7 +229,7 @@ Mount the secure credit-card payment method form into a container element (an `H
|
|
|
214
229
|
|
|
215
230
|
**Optional `options`:**
|
|
216
231
|
|
|
217
|
-
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string
|
|
232
|
+
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`)
|
|
218
233
|
- `additionalFields` (`{ cardholderName: boolean }`, defaults to `{ cardholderName: false }`)
|
|
219
234
|
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: PaymentIntent) => void`)
|
|
220
235
|
- `onSetupIntentConfirmationSucceeded` (`(setupIntent: SetupIntent) => void`)
|
package/dist/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type { AmosBankAccountPaymentMethodFormOptions, AmosCreditCardPaymentMeth
|
|
|
7
7
|
export { mountAmosBankAccountPaymentMethodForm, mountAmosCreditCardPaymentMethodForm, mountAmosGooglePayButton, } from './mount';
|
|
8
8
|
export type { CreditCardAdditionalFields, PaymentMethodFormController, PaymentMethodFormListenerOptions, } from './payment-method-form';
|
|
9
9
|
export { attachPaymentMethodFormListeners, getBankAccountFormInitialHeight, getBankAccountFormSrc, getCreditCardFormInitialHeight, getCreditCardFormSrc, } from './payment-method-form';
|
|
10
|
-
export type { Appearance, Message, ThemeVariable, } from './types';
|
|
10
|
+
export type { Appearance, AppearanceLabels, Message, ThemeVariable, } from './types';
|
|
11
11
|
export { createMessage } from './types';
|
|
12
12
|
/**
|
|
13
13
|
* Convenience alias for `components["schemas"]["CreateCustomerInput"]`.
|
package/dist/src/types.d.ts
CHANGED
|
@@ -4,12 +4,26 @@ import { components } from '@amos.com/node';
|
|
|
4
4
|
* Amos iframe UI. Only the variables you provide are sent; omitted
|
|
5
5
|
* variables keep their defaults.
|
|
6
6
|
*/
|
|
7
|
-
export type ThemeVariable = "--background" | "--foreground" | "--primary" | "--primary-foreground" | "--secondary" | "--secondary-foreground" | "--muted-foreground" | "--accent" | "--accent-foreground" | "--destructive" | "--border" | "--input" | "--ring" | "--radius";
|
|
7
|
+
export type ThemeVariable = "--background" | "--foreground" | "--primary" | "--primary-foreground" | "--secondary" | "--secondary-foreground" | "--muted-foreground" | "--accent" | "--accent-foreground" | "--destructive" | "--border" | "--input" | "--input-background" | "--input-height" | "--ring" | "--radius";
|
|
8
|
+
/**
|
|
9
|
+
* Placement of field labels in payment method forms.
|
|
10
|
+
*
|
|
11
|
+
* - `above` — label text is rendered above the control (default).
|
|
12
|
+
* - `floating` — label sits inside the control and shrinks when focused or filled.
|
|
13
|
+
* - `placeholder` — no visible label; use placeholder text and `aria-label` only.
|
|
14
|
+
*/
|
|
15
|
+
export type AppearanceLabels = "above" | "floating" | "placeholder";
|
|
8
16
|
/**
|
|
9
17
|
* Appearance overrides for the embedded Amos iframe UI.
|
|
10
18
|
*/
|
|
11
19
|
export type Appearance = {
|
|
12
20
|
themeVariables?: Partial<Record<ThemeVariable, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* Field label placement for card and bank account forms.
|
|
23
|
+
*
|
|
24
|
+
* @default "above"
|
|
25
|
+
*/
|
|
26
|
+
labels?: AppearanceLabels;
|
|
13
27
|
};
|
|
14
28
|
/**
|
|
15
29
|
* Typed `postMessage` payloads exchanged between the host page and the
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -79,6 +79,18 @@ export type ThemeVariable =
|
|
|
79
79
|
* Default: oklch(0.922 0 0)
|
|
80
80
|
*/
|
|
81
81
|
| "--input"
|
|
82
|
+
/*
|
|
83
|
+
* Input field background fill. Falls back to `--background` when unset.
|
|
84
|
+
*
|
|
85
|
+
* Default: var(--background)
|
|
86
|
+
*/
|
|
87
|
+
| "--input-background"
|
|
88
|
+
/*
|
|
89
|
+
* Height of text inputs and form controls (e.g. `2.25rem`, `48px`).
|
|
90
|
+
*
|
|
91
|
+
* Default: 2.25rem
|
|
92
|
+
*/
|
|
93
|
+
| "--input-height"
|
|
82
94
|
/*
|
|
83
95
|
* Focus ring and outline color for inputs and buttons.
|
|
84
96
|
*
|
|
@@ -92,11 +104,26 @@ export type ThemeVariable =
|
|
|
92
104
|
*/
|
|
93
105
|
| "--radius";
|
|
94
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Placement of field labels in payment method forms.
|
|
109
|
+
*
|
|
110
|
+
* - `above` — label text is rendered above the control (default).
|
|
111
|
+
* - `floating` — label sits inside the control and shrinks when focused or filled.
|
|
112
|
+
* - `placeholder` — no visible label; use placeholder text and `aria-label` only.
|
|
113
|
+
*/
|
|
114
|
+
export type AppearanceLabels = "above" | "floating" | "placeholder";
|
|
115
|
+
|
|
95
116
|
/**
|
|
96
117
|
* Appearance overrides for the embedded Amos iframe UI.
|
|
97
118
|
*/
|
|
98
119
|
export type Appearance = {
|
|
99
120
|
themeVariables?: Partial<Record<ThemeVariable, string>>;
|
|
121
|
+
/**
|
|
122
|
+
* Field label placement for card and bank account forms.
|
|
123
|
+
*
|
|
124
|
+
* @default "above"
|
|
125
|
+
*/
|
|
126
|
+
labels?: AppearanceLabels;
|
|
100
127
|
};
|
|
101
128
|
|
|
102
129
|
/**
|