@ozura/elements 1.3.1-next.74 → 1.3.1-next.76

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.
@@ -1,5 +1,5 @@
1
1
  import { OzElement } from './OzElement';
2
- import { ElementType, BankElementType, ElementOptions, VaultOptions, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse } from '../types';
2
+ import { ElementType, BankElementType, ElementOptions, VaultOptions, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, FieldStatesSnapshot } from '../types';
3
3
  /**
4
4
  * The main entry point for OzElements. Creates and manages iframe-based
5
5
  * card input elements that keep raw card data isolated from the merchant page.
@@ -33,6 +33,7 @@ export declare class OzVault {
33
33
  private tokenizeResolvers;
34
34
  private bankTokenizeResolvers;
35
35
  private completionState;
36
+ private fieldStates;
36
37
  private tokenizerFrame;
37
38
  private tokenizerWindow;
38
39
  private tokenizerReady;
@@ -131,6 +132,14 @@ export declare class OzVault {
131
132
  get isBankComplete(): boolean;
132
133
  /** True iff the set is non-empty and every element has reported complete-and-valid. */
133
134
  private allComplete;
135
+ /**
136
+ * Snapshot of every created field's latest state, keyed by element type.
137
+ * Card and bank fields are combined (their type keys never collide). Useful for
138
+ * gating UI, rendering per-field errors, or showing the card brand without
139
+ * wiring an onChange listener per element. Returns shallow copies so callers
140
+ * cannot mutate the vault's internal state.
141
+ */
142
+ getFieldStates(): FieldStatesSnapshot;
134
143
  /**
135
144
  * `true` while a `createToken()` or `createBankToken()` call is in progress
136
145
  * (including the transparent wax-key refresh phase). Use this to keep the pay
@@ -92,6 +92,21 @@ export interface ElementChangeEvent {
92
92
  /** Human-readable error when valid is false and the field has been touched */
93
93
  error?: string;
94
94
  }
95
+ export interface FieldState {
96
+ empty: boolean;
97
+ complete: boolean;
98
+ valid: boolean;
99
+ /** Present when valid is false and the field has been touched. */
100
+ error?: string;
101
+ /** Card brand — cardNumber field only. */
102
+ cardBrand?: string;
103
+ }
104
+ /**
105
+ * Snapshot of every created field's latest state, keyed by element type. Only
106
+ * fields that have been created are present; each is present from creation,
107
+ * starting at { empty:true, complete:false, valid:false } until first change.
108
+ */
109
+ export type FieldStatesSnapshot = Partial<Record<ElementType | BankElementType, FieldState>>;
95
110
  export type ElementType = 'cardNumber' | 'cvv' | 'expirationDate';
96
111
  /** Bank account element types. */
97
112
  export type BankElementType = 'accountNumber' | 'routingNumber';
@@ -24,7 +24,7 @@
24
24
  * ```
25
25
  */
26
26
  import { type Ref, type PropType, type ComputedRef } from 'vue';
27
- import type { ElementOptions, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, FontSource, Appearance } from '../types';
27
+ import type { ElementOptions, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, FontSource, Appearance, FieldStatesSnapshot } from '../types';
28
28
  export interface OzElementsProps {
29
29
  /** Omit when using a test vault key from a Test project at ozuravault.com.
30
30
  * Required for production vault keys. */
@@ -253,6 +253,18 @@ export interface UseOzElementsReturn {
253
253
  * @throws {Error} if called outside an <OzElements> provider
254
254
  */
255
255
  export declare function useOzElements(): UseOzElementsReturn;
256
+ /**
257
+ * Reactive snapshot of every created field's state, keyed by element type
258
+ * (e.g. `cardNumber`, `cvv`, `accountNumber`). Each entry is
259
+ * `{ empty, complete, valid, error?, cardBrand? }`. Recomputes whenever any
260
+ * field fires a change event.
261
+ *
262
+ * @throws if called outside an `<OzElements>` provider tree.
263
+ * @example
264
+ * const fields = useFieldStates();
265
+ * // fields.value.cvv?.error
266
+ */
267
+ export declare function useFieldStates(): ComputedRef<FieldStatesSnapshot>;
256
268
  /** Props accepted by all individual field components (OzCardNumber, OzExpiry, OzCvv, etc.). */
257
269
  export interface OzFieldProps {
258
270
  placeholder?: string;
@@ -359,4 +371,4 @@ export declare const OzBankRoutingNumber: import("vue").DefineComponent<{
359
371
  style: import("../types").ElementStyleConfig | undefined;
360
372
  disabled: boolean;
361
373
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
362
- export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, } from '../types';
374
+ export type { ElementChangeEvent, TokenizeOptions, TokenResponse, BankTokenizeOptions, BankTokenResponse, Appearance, FontSource, FieldState, FieldStatesSnapshot, } from '../types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozura/elements",
3
- "version": "1.3.1-next.74",
3
+ "version": "1.3.1-next.76",
4
4
  "description": "PCI-compliant card tokenization SDK for the Ozura Vault — collect card data in iframe-isolated fields and tokenize without PCI scope",
5
5
  "main": "dist/oz-elements.umd.js",
6
6
  "module": "dist/oz-elements.esm.js",