@amos.com/amos-js 0.2.0 → 0.3.1
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 +16 -3
- package/dist/src/index.d.ts +1 -1
- package/dist/src/messaging.d.ts +4 -2
- package/dist/src/types.d.ts +14 -0
- package/package.json +1 -1
- package/src/index.ts +1 -0
- package/src/messaging.ts +4 -2
- package/src/types.ts +15 -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",
|
|
@@ -180,7 +181,19 @@ form.update({
|
|
|
180
181
|
});
|
|
181
182
|
```
|
|
182
183
|
|
|
183
|
-
Only the variables you
|
|
184
|
+
`themeVariables` uses a **replace** model: each update that includes `themeVariables` sets the full override set. Only the variables you list are overridden; unlisted variables revert to iframe defaults. Omit `themeVariables` to leave existing overrides unchanged.
|
|
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.
|
|
184
197
|
|
|
185
198
|
### Available theme variables
|
|
186
199
|
|
|
@@ -216,7 +229,7 @@ Mount the secure credit-card payment method form into a container element (an `H
|
|
|
216
229
|
|
|
217
230
|
**Optional `options`:**
|
|
218
231
|
|
|
219
|
-
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string
|
|
232
|
+
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`)
|
|
220
233
|
- `additionalFields` (`{ cardholderName: boolean }`, defaults to `{ cardholderName: false }`)
|
|
221
234
|
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: PaymentIntent) => void`)
|
|
222
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/messaging.d.ts
CHANGED
|
@@ -10,8 +10,10 @@ export declare function sendParentReadyMessage(iframe: Iframe): void;
|
|
|
10
10
|
/**
|
|
11
11
|
* Push appearance overrides into the embedded iframe.
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* Uses a replace model for `themeVariables`: each message that includes
|
|
14
|
+
* `themeVariables` sets the full override set. Only the listed variables
|
|
15
|
+
* are overridden; unlisted variables revert to iframe defaults. Omit
|
|
16
|
+
* `themeVariables` entirely to leave existing overrides unchanged.
|
|
15
17
|
*/
|
|
16
18
|
export declare function updateAppearance({ iframe, appearance, }: {
|
|
17
19
|
iframe: Iframe;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -5,11 +5,25 @@ import { components } from '@amos.com/node';
|
|
|
5
5
|
* variables keep their defaults.
|
|
6
6
|
*/
|
|
7
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/messaging.ts
CHANGED
|
@@ -19,8 +19,10 @@ export function sendParentReadyMessage(iframe: Iframe): void {
|
|
|
19
19
|
/**
|
|
20
20
|
* Push appearance overrides into the embedded iframe.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* Uses a replace model for `themeVariables`: each message that includes
|
|
23
|
+
* `themeVariables` sets the full override set. Only the listed variables
|
|
24
|
+
* are overridden; unlisted variables revert to iframe defaults. Omit
|
|
25
|
+
* `themeVariables` entirely to leave existing overrides unchanged.
|
|
24
26
|
*/
|
|
25
27
|
export function updateAppearance({
|
|
26
28
|
iframe,
|
package/src/types.ts
CHANGED
|
@@ -104,11 +104,26 @@ export type ThemeVariable =
|
|
|
104
104
|
*/
|
|
105
105
|
| "--radius";
|
|
106
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
|
+
|
|
107
116
|
/**
|
|
108
117
|
* Appearance overrides for the embedded Amos iframe UI.
|
|
109
118
|
*/
|
|
110
119
|
export type Appearance = {
|
|
111
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;
|
|
112
127
|
};
|
|
113
128
|
|
|
114
129
|
/**
|