@amos.com/amos-js 0.2.0 → 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 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 |
@@ -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`)
@@ -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"]`.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/amos-js",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.ts CHANGED
@@ -51,6 +51,7 @@ export {
51
51
  } from "./payment-method-form";
52
52
  export type {
53
53
  Appearance,
54
+ AppearanceLabels,
54
55
  Message,
55
56
  ThemeVariable,
56
57
  } from "./types";
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
  /**