@primer-io/primer-js 0.1.8 → 0.2.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.
Files changed (58) hide show
  1. package/dist/chunks/{ar.5AY75F5J.js → ar.6MRFCKX4.js} +1 -1
  2. package/dist/chunks/{bg.2EL2HTYI.js → bg.HRSMU7Y5.js} +1 -1
  3. package/dist/chunks/{ca.WZI7CBFW.js → ca.3FSHJL7U.js} +1 -1
  4. package/dist/chunks/chunk.I6YWTZRK.js +1 -0
  5. package/dist/chunks/{cs.GBLLNC3E.js → cs.WAO4WFS3.js} +1 -1
  6. package/dist/chunks/{da.CDEFQG44.js → da.4OFYGDVA.js} +1 -1
  7. package/dist/chunks/{de.UHURA2HV.js → de.3FZS52IN.js} +1 -1
  8. package/dist/chunks/{el.BY5NGYDF.js → el.A4R7VG5T.js} +1 -1
  9. package/dist/chunks/en-GB.ILZ7SXSW.js +1 -0
  10. package/dist/chunks/en.7GZJA7MN.js +1 -0
  11. package/dist/chunks/{es-AR.EYNC6EAZ.js → es-AR.QKHDL4JV.js} +1 -1
  12. package/dist/chunks/{es-MX.OIO2YURF.js → es-MX.GG7MJMG2.js} +1 -1
  13. package/dist/chunks/{es.CNNIJYLX.js → es.FEZ6BF3S.js} +1 -1
  14. package/dist/chunks/{et-EE.4ZF6CLB6.js → et-EE.FJLPTMF3.js} +1 -1
  15. package/dist/chunks/{fi-FI.4ZXWRRYI.js → fi-FI.DM5R27A5.js} +1 -1
  16. package/dist/chunks/{fr.TZM5I4K2.js → fr.YZV52NTA.js} +1 -1
  17. package/dist/chunks/{he.DWEZBG4A.js → he.6SCF3XZZ.js} +1 -1
  18. package/dist/chunks/{hr.BV4PC324.js → hr.PPDZ7AAS.js} +1 -1
  19. package/dist/chunks/{hu.MTEKSS3J.js → hu.6WOPSGLW.js} +1 -1
  20. package/dist/chunks/{id.SJSTOPSC.js → id.NS22WGWL.js} +1 -1
  21. package/dist/chunks/{it.IISTMHN5.js → it.42TO3R4G.js} +1 -1
  22. package/dist/chunks/{ja.IBQ3ID5C.js → ja.UEGHEUAP.js} +1 -1
  23. package/dist/chunks/{ko.KZVQLI4V.js → ko.HTMDY6RY.js} +1 -1
  24. package/dist/chunks/{lt-LT.RKBB7CZ6.js → lt-LT.4U3GBQTQ.js} +1 -1
  25. package/dist/chunks/{lt.TLM7OCXP.js → lt.73ME4TDM.js} +1 -1
  26. package/dist/chunks/{lv-LV.H5TJC2T4.js → lv-LV.JRWO2BF6.js} +1 -1
  27. package/dist/chunks/{lv.G4SRVBAC.js → lv.KROS45TV.js} +1 -1
  28. package/dist/chunks/{ms.ATTITA66.js → ms.HE3SWJFQ.js} +1 -1
  29. package/dist/chunks/{nb.5EE7XOA7.js → nb.TR6TEKBY.js} +1 -1
  30. package/dist/chunks/{nl.TY2SYTKZ.js → nl.V5QP6OXL.js} +1 -1
  31. package/dist/chunks/{nl_NL.GB5BQ5PG.js → nl_NL.FCVWIF3Y.js} +1 -1
  32. package/dist/chunks/{pl.5PRBSG4K.js → pl.DQZDG7LR.js} +1 -1
  33. package/dist/chunks/{pt-BR.5XRZB5WW.js → pt-BR.CR4ROBVE.js} +1 -1
  34. package/dist/chunks/{pt.TA5H5JUJ.js → pt.JRWVFJPX.js} +1 -1
  35. package/dist/chunks/{ro.PSZKGHRP.js → ro.NRMWYY3F.js} +1 -1
  36. package/dist/chunks/{ru.3QZY7ZIT.js → ru.OWSKHXVO.js} +1 -1
  37. package/dist/chunks/{sk.FAQFYLGM.js → sk.YGBRNNWT.js} +1 -1
  38. package/dist/chunks/{sl.QRSCQXJP.js → sl.IRTDTNTP.js} +1 -1
  39. package/dist/chunks/{sr-RS.TKMMG7FK.js → sr-RS.AWGLHKVE.js} +1 -1
  40. package/dist/chunks/{sv.HZ3E6V5F.js → sv.O4BXFGNF.js} +1 -1
  41. package/dist/chunks/{th.AY6M42B4.js → th.GZCEBRT2.js} +1 -1
  42. package/dist/chunks/{tr.TFKBPYMO.js → tr.ZDILMEEO.js} +1 -1
  43. package/dist/chunks/{uk-UA.3TU67RSI.js → uk-UA.JUUBOEW3.js} +1 -1
  44. package/dist/chunks/{vi.NLXELMXV.js → vi.IN7CFTLL.js} +1 -1
  45. package/dist/chunks/zf.YT47ULXR.js +1 -0
  46. package/dist/chunks/{zh-CN.VEOQJ3EU.js → zh-CN.RBRAS4RP.js} +1 -1
  47. package/dist/chunks/{zh-HK.ZEXSW7FF.js → zh-HK.4CK7LBWM.js} +1 -1
  48. package/dist/chunks/{zh-TW.MMVWEQMZ.js → zh-TW.374TMWNJ.js} +1 -1
  49. package/dist/custom-elements.json +2237 -3279
  50. package/dist/primer-loader.d.ts +1087 -756
  51. package/dist/primer-loader.js +780 -1025
  52. package/dist/primer-react-wrappers.js +426 -671
  53. package/dist/web-types.json +1 -1
  54. package/package.json +8 -1
  55. package/dist/chunks/chunk.G45OCYEN.js +0 -1
  56. package/dist/chunks/en-GB.UBLLAUVW.js +0 -1
  57. package/dist/chunks/en.BKAVPUID.js +0 -1
  58. package/dist/chunks/zf.U5XPENNR.js +0 -1
@@ -198,6 +198,24 @@ export interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {
198
198
  * the property changes.
199
199
  */
200
200
  readonly noAccessor?: boolean;
201
+ /**
202
+ * When `true`, uses the initial value of the property as the default value,
203
+ * which changes how attributes are handled:
204
+ * - The initial value does *not* reflect, even if the `reflect` option is `true`.
205
+ * Subsequent changes to the property will reflect, even if they are equal to the
206
+ * default value.
207
+ * - When the attribute is removed, the property is set to the default value
208
+ * - The initial value will not trigger an old value in the `changedProperties` map
209
+ * argument to update lifecycle methods.
210
+ *
211
+ * When set, properties must be initialized, either with a field initializer, or an
212
+ * assignment in the constructor. Not initializing the property may lead to
213
+ * improper handling of subsequent property assignments.
214
+ *
215
+ * While this behavior is opt-in, most properties that reflect to attributes should
216
+ * use `useDefault: true` so that their initial values do not reflect.
217
+ */
218
+ useDefault?: boolean;
201
219
  }
202
220
  /**
203
221
  * Map of properties to PropertyDeclaration options. For each property an
@@ -556,6 +574,11 @@ declare abstract class ReactiveElement extends HTMLElement implements ReactiveCo
556
574
  * @category updates
557
575
  */
558
576
  hasUpdated: boolean;
577
+ /**
578
+ * Records property default values when the
579
+ * `useDefault` option is used.
580
+ */
581
+ private __defaultValues?;
559
582
  /**
560
583
  * Properties that should be reflected when updated.
561
584
  */
@@ -593,13 +616,7 @@ declare abstract class ReactiveElement extends HTMLElement implements ReactiveCo
593
616
  * Fixes any properties set on the instance before upgrade time.
594
617
  * Otherwise these would shadow the accessor and break these properties.
595
618
  * The properties are stored in a Map which is played back after the
596
- * constructor runs. Note, on very old versions of Safari (<=9) or Chrome
597
- * (<=41), properties created for native platform properties like (`id` or
598
- * `name`) may not have default values set in the element constructor. On
599
- * these browsers native properties appear on instances and therefore their
600
- * default value will overwrite any element default (e.g. if the element sets
601
- * this.id = 'id' in the constructor, the 'id' will become '' since this is
602
- * the native platform default).
619
+ * constructor runs.
603
620
  */
604
621
  private __saveInstanceProperties;
605
622
  /**
@@ -640,7 +657,7 @@ declare abstract class ReactiveElement extends HTMLElement implements ReactiveCo
640
657
  * overridden, `super.attributeChangedCallback(name, _old, value)` must be
641
658
  * called.
642
659
  *
643
- * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)
660
+ * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes)
644
661
  * on MDN for more information about the `attributeChangedCallback`.
645
662
  * @category attributes
646
663
  */
@@ -2252,59 +2269,133 @@ declare global {
2252
2269
  Primer: typeof Primer;
2253
2270
  }
2254
2271
  }
2272
+ declare const PaymentMethodType$1: {
2273
+ readonly WORLDPAY_IDEAL: "WORLDPAY_IDEAL";
2274
+ readonly STRIPE_ACH: "STRIPE_ACH";
2275
+ readonly STRIPE_IDEAL: "STRIPE_IDEAL";
2276
+ readonly ADYEN_KLARNA: "ADYEN_KLARNA";
2277
+ readonly ADYEN_BANCONTACT_CARD: "ADYEN_BANCONTACT_CARD";
2278
+ readonly PAY_NL_KAARTDIRECT: "PAY_NL_KAARTDIRECT";
2279
+ readonly ADYEN_EPS: "ADYEN_EPS";
2280
+ readonly ADYEN_BANCONTACT_PAYCONIQ: "ADYEN_BANCONTACT_PAYCONIQ";
2281
+ readonly OMISE_PROMPTPAY: "OMISE_PROMPTPAY";
2282
+ readonly OMISE_TRUEMONEY: "OMISE_TRUEMONEY";
2283
+ readonly ADYEN_MULTIBANCO: "ADYEN_MULTIBANCO";
2284
+ readonly PACYPAY_WECHAT: "PACYPAY_WECHAT";
2285
+ readonly PACYPAY_ALIPAY: "PACYPAY_ALIPAY";
2286
+ readonly ADYEN_MBWAY: "ADYEN_MBWAY";
2287
+ readonly XENDIT_DANA: "XENDIT_DANA";
2288
+ readonly XENDIT_SHOPEEPAY: "XENDIT_SHOPEEPAY";
2289
+ readonly ADYEN_PAYSHOP: "ADYEN_PAYSHOP";
2290
+ readonly ADYEN_PAYTRAIL: "ADYEN_PAYTRAIL";
2291
+ readonly CLEARPAY: "CLEARPAY";
2292
+ readonly RAPYD_FAST: "RAPYD_FAST";
2293
+ readonly RAPYD_PROMPTPAY: "RAPYD_PROMPTPAY";
2294
+ readonly RAPYD_GCASH: "RAPYD_GCASH";
2295
+ readonly RAPYD_POLI: "RAPYD_POLI";
2296
+ readonly RAPYD_GRABPAY: "RAPYD_GRABPAY";
2297
+ readonly PRIMER_PAYPAL: "PRIMER_PAYPAL";
2298
+ readonly TWOC2P: "TWOC2P";
2299
+ readonly NETS: "NETS";
2300
+ readonly STRIPE_GIROPAY: "STRIPE_GIROPAY";
2301
+ readonly MOLLIE_GIROPAY: "MOLLIE_GIROPAY";
2302
+ readonly MOLLIE_EPS: "MOLLIE_EPS";
2303
+ readonly PAY_NL_EPS: "PAY_NL_EPS";
2304
+ readonly PAY_NL_P24: "PAY_NL_P24";
2305
+ readonly MOLLIE_P24: "MOLLIE_P24";
2306
+ readonly MOLLIE_SOFORT: "MOLLIE_SOFORT";
2307
+ readonly COINBASE: "COINBASE";
2308
+ readonly OPENNODE: "OPENNODE";
2309
+ readonly MOLLIE_GIFT_CARD: "MOLLIE_GIFTCARD";
2310
+ readonly XFERS_PAYNOW: "XFERS_PAYNOW";
2311
+ readonly PAYMENT_CARD: "PAYMENT_CARD";
2312
+ readonly APPLE_PAY: "APPLE_PAY";
2313
+ readonly GOOGLE_PAY: "GOOGLE_PAY";
2314
+ readonly PAYPAL: "PAYPAL";
2315
+ readonly GO_CARDLESS: "GOCARDLESS";
2316
+ readonly KLARNA: "KLARNA";
2317
+ readonly PAY_NL_IDEAL: "PAY_NL_IDEAL";
2318
+ readonly PAY_NL_SOFORT_BANKING: "PAY_NL_SOFORT_BANKING";
2319
+ readonly PAY_NL_BANCONTACT: "PAY_NL_BANCONTACT";
2320
+ readonly PAY_NL_PAYPAL: "PAY_NL_PAYPAL";
2321
+ readonly PAY_NL_CREDIT_TRANSFER: "PAY_NL_CREDIT_TRANSFER";
2322
+ readonly PAY_NL_DIRECT_DEBIT: "PAY_NL_DIRECT_DEBIT";
2323
+ readonly PAY_NL_GIROPAY: "PAY_NL_GIROPAY";
2324
+ readonly PAY_NL_PAYCONIQ: "PAY_NL_PAYCONIQ";
2325
+ readonly HOOLAH: "HOOLAH";
2326
+ readonly ADYEN_BLIK: "ADYEN_BLIK";
2327
+ readonly ADYEN_MOBILEPAY: "ADYEN_MOBILEPAY";
2328
+ readonly ADYEN_VIPPS: "ADYEN_VIPPS";
2329
+ readonly ADYEN_GIROPAY: "ADYEN_GIROPAY";
2330
+ readonly ADYEN_SOFORT: "ADYEN_SOFORT";
2331
+ readonly ADYEN_IDEAL: "ADYEN_IDEAL";
2332
+ readonly ADYEN_TRUSTLY: "ADYEN_TRUSTLY";
2333
+ readonly ADYEN_ALIPAY: "ADYEN_ALIPAY";
2334
+ readonly ADYEN_TWINT: "ADYEN_TWINT";
2335
+ readonly ADYEN_BANK_TRANSFER: "ADYEN_BANK_TRANSFER";
2336
+ readonly MOLLIE_BANCONTACT: "MOLLIE_BANCONTACT";
2337
+ readonly MOLLIE_IDEAL: "MOLLIE_IDEAL";
2338
+ readonly BUCKAROO_GIROPAY: "BUCKAROO_GIROPAY";
2339
+ readonly BUCKAROO_EPS: "BUCKAROO_EPS";
2340
+ readonly BUCKAROO_SOFORT: "BUCKAROO_SOFORT";
2341
+ readonly BUCKAROO_BANCONTACT: "BUCKAROO_BANCONTACT";
2342
+ readonly BUCKAROO_IDEAL: "BUCKAROO_IDEAL";
2343
+ readonly ATOME: "ATOME";
2344
+ };
2345
+ type PaymentMethodType$1 = (typeof PaymentMethodType$1)[keyof typeof PaymentMethodType$1];
2255
2346
  export type InitializedManager = {
2256
- type: typeof PaymentMethodType.STRIPE_ACH;
2347
+ type: typeof PaymentMethodType$1.STRIPE_ACH;
2257
2348
  manager: IAchPaymentMethodManager;
2258
2349
  } | {
2259
- type: typeof PaymentMethodType.PAYMENT_CARD;
2350
+ type: typeof PaymentMethodType$1.PAYMENT_CARD;
2260
2351
  manager: ICardPaymentMethodManager;
2261
2352
  } | {
2262
- type: typeof PaymentMethodType.KLARNA;
2353
+ type: typeof PaymentMethodType$1.KLARNA;
2263
2354
  manager: IKlarnaPaymentMethodManager;
2264
2355
  } | {
2265
2356
  type: RedirectPaymentMethodTypes;
2266
2357
  manager: IRedirectPaymentMethodManager;
2267
2358
  } | {
2268
- type: typeof PaymentMethodType.PAYPAL | typeof PaymentMethodType.GOOGLE_PAY | typeof PaymentMethodType.APPLE_PAY;
2359
+ type: typeof PaymentMethodType$1.PAYPAL | typeof PaymentMethodType$1.GOOGLE_PAY | typeof PaymentMethodType$1.APPLE_PAY;
2269
2360
  manager: INativePaymentMethodManager;
2270
2361
  };
2271
- export type ManagerByType<T extends PaymentMethodType> = Extract<InitializedManager, {
2362
+ export type ManagerByType<T extends PaymentMethodType$1> = Extract<InitializedManager, {
2272
2363
  type: T;
2273
2364
  }>;
2274
- export interface InitializedManagersMap extends Map<PaymentMethodType, InitializedManager> {
2275
- get<T extends PaymentMethodType>(key: T): ManagerByType<T> | undefined;
2365
+ export interface InitializedManagersMap extends Map<PaymentMethodType$1, InitializedManager> {
2366
+ get<T extends PaymentMethodType$1>(key: T): ManagerByType<T> | undefined;
2276
2367
  }
2277
- export type RedirectPaymentMethodTypes = Exclude<PaymentMethodType, typeof PaymentMethodType.STRIPE_ACH | typeof PaymentMethodType.PAYMENT_CARD | typeof PaymentMethodType.KLARNA | typeof PaymentMethodType.PAYPAL | typeof PaymentMethodType.GOOGLE_PAY | typeof PaymentMethodType.APPLE_PAY>;
2278
- export type DynamicPaymentMethodTypes = typeof PaymentMethodType.STRIPE_ACH;
2279
- export type NativePaymentMethodTypes = typeof PaymentMethodType.PAYPAL | typeof PaymentMethodType.GOOGLE_PAY | typeof PaymentMethodType.APPLE_PAY;
2368
+ export type RedirectPaymentMethodTypes = Exclude<PaymentMethodType$1, typeof PaymentMethodType$1.STRIPE_ACH | typeof PaymentMethodType$1.PAYMENT_CARD | typeof PaymentMethodType$1.KLARNA | typeof PaymentMethodType$1.PAYPAL | typeof PaymentMethodType$1.GOOGLE_PAY | typeof PaymentMethodType$1.APPLE_PAY>;
2369
+ export type DynamicPaymentMethodTypes = typeof PaymentMethodType$1.STRIPE_ACH;
2370
+ export type NativePaymentMethodTypes = typeof PaymentMethodType$1.PAYPAL | typeof PaymentMethodType$1.GOOGLE_PAY | typeof PaymentMethodType$1.APPLE_PAY;
2280
2371
  export type RedirectPaymentMethod = {
2281
2372
  type: RedirectPaymentMethodTypes;
2282
2373
  managerType: HeadlessManagerType.REDIRECT;
2283
2374
  };
2284
2375
  export type InitializedPaymentMethod = {
2285
- type: typeof PaymentMethodType.STRIPE_ACH;
2376
+ type: typeof PaymentMethodType$1.STRIPE_ACH;
2286
2377
  managerType: HeadlessManagerType.ACH;
2287
2378
  } | {
2288
- type: typeof PaymentMethodType.PAYMENT_CARD;
2379
+ type: typeof PaymentMethodType$1.PAYMENT_CARD;
2289
2380
  managerType: HeadlessManagerType.CARD;
2290
2381
  } | {
2291
- type: typeof PaymentMethodType.KLARNA;
2382
+ type: typeof PaymentMethodType$1.KLARNA;
2292
2383
  managerType: HeadlessManagerType.KLARNA;
2293
2384
  } | {
2294
- type: typeof PaymentMethodType.PAYPAL;
2385
+ type: typeof PaymentMethodType$1.PAYPAL;
2295
2386
  managerType: HeadlessManagerType.NATIVE;
2296
2387
  } | {
2297
- type: typeof PaymentMethodType.GOOGLE_PAY;
2388
+ type: typeof PaymentMethodType$1.GOOGLE_PAY;
2298
2389
  managerType: HeadlessManagerType.NATIVE;
2299
2390
  } | {
2300
- type: typeof PaymentMethodType.APPLE_PAY;
2391
+ type: typeof PaymentMethodType$1.APPLE_PAY;
2301
2392
  managerType: HeadlessManagerType.NATIVE;
2302
2393
  } | RedirectPaymentMethod;
2303
- export type PaymentMethodByType<T extends PaymentMethodType> = Extract<InitializedPaymentMethod, {
2394
+ export type PaymentMethodByType<T extends PaymentMethodType$1> = Extract<InitializedPaymentMethod, {
2304
2395
  type: T;
2305
2396
  }>;
2306
- export interface InitializedPaymentMethodMap extends Map<PaymentMethodType, InitializedPaymentMethod> {
2307
- get<T extends PaymentMethodType>(key: T): PaymentMethodByType<T> | undefined;
2397
+ export interface InitializedPaymentMethodMap extends Map<PaymentMethodType$1, InitializedPaymentMethod> {
2398
+ get<T extends PaymentMethodType$1>(key: T): PaymentMethodByType<T> | undefined;
2308
2399
  }
2309
2400
  export interface AssetsConfig {
2310
2401
  backgroundColor: string;
@@ -2315,16 +2406,69 @@ export declare class InitializedPayments {
2315
2406
  private readonly _methods;
2316
2407
  constructor(map: InitializedPaymentMethodMap);
2317
2408
  get<T extends RedirectPaymentMethodTypes>(type: T): RedirectPaymentMethod | undefined;
2318
- get<T extends (typeof PaymentMethodType)[keyof typeof PaymentMethodType]>(type: T): PaymentMethodByType<T> | undefined;
2409
+ get<T extends (typeof PaymentMethodType$1)[keyof typeof PaymentMethodType$1]>(type: T): PaymentMethodByType<T> | undefined;
2319
2410
  toArray(): InitializedPaymentMethod[];
2320
2411
  size(): number;
2321
2412
  }
2322
- export interface OnCheckoutCompletePayload {
2413
+ export interface PaymentData {
2414
+ paymentMethodType: string;
2415
+ }
2416
+ export interface PrepareHandler {
2417
+ continuePaymentCreation: () => void;
2418
+ abortPaymentCreation: () => void;
2419
+ }
2420
+ export interface PaymentCompleteData {
2323
2421
  payment: Payment | null;
2422
+ status: "success" | "pending" | "error";
2423
+ error?: PrimerClientError;
2324
2424
  }
2325
- export interface OnCheckoutFailurePayload {
2326
- error: PrimerClientError;
2327
- payment?: Payment;
2425
+ /**
2426
+ * PrimerJS is a wrapper class that provides a stable API for interfacing with the Primer SDK
2427
+ * while hiding direct access to the legacy headless instance.
2428
+ */
2429
+ export declare class PrimerJS {
2430
+ private headlessInstance;
2431
+ private paymentMethods;
2432
+ onPaymentStart?: () => void;
2433
+ onPaymentPrepare?: (data: PaymentData, handler: PrepareHandler) => void;
2434
+ onPaymentComplete?: (data: PaymentCompleteData) => void;
2435
+ constructor(headlessInstance: PrimerHeadlessCheckout);
2436
+ /**
2437
+ * Set the initialized payment methods
2438
+ * @internal - This is only used internally by the SDK
2439
+ */
2440
+ setPaymentMethods(methods: InitializedPayments): void;
2441
+ /**
2442
+ * Refetches a new client session from merchant backend.
2443
+ */
2444
+ refreshSession(): Promise<void>;
2445
+ /**
2446
+ * Returns the cached list of payment methods.
2447
+ */
2448
+ getPaymentMethods(): PaymentMethodInfo[];
2449
+ /**
2450
+ * Internal method to handle the onPaymentStart callback
2451
+ * @internal - This is only used internally by the SDK
2452
+ */
2453
+ handlePaymentStart(): void;
2454
+ /**
2455
+ * Internal method to handle the onBeforePaymentCreate callback and transform it to onPaymentPrepare
2456
+ * @internal - This is only used internally by the SDK
2457
+ */
2458
+ handleBeforePaymentCreate(data: PaymentData, originalHandler: {
2459
+ continuePaymentCreation: () => void;
2460
+ abortPaymentCreation: () => void;
2461
+ }): void;
2462
+ /**
2463
+ * Internal method to handle payment completion (success)
2464
+ * @internal - This is only used internally by the SDK
2465
+ */
2466
+ handlePaymentComplete(payment: Payment | null): void;
2467
+ /**
2468
+ * Internal method to handle payment failure
2469
+ * @internal - This is only used internally by the SDK
2470
+ */
2471
+ handlePaymentFailure(error: PrimerClientError, payment?: Payment): void;
2328
2472
  }
2329
2473
  export interface CardSubmitSuccessPayload {
2330
2474
  result: unknown;
@@ -2336,14 +2480,12 @@ export interface PrimeAchErrorPayload {
2336
2480
  error: Error;
2337
2481
  }
2338
2482
  export interface PrimerEvents {
2339
- "primer-state-changed": CustomEvent<SdkStateContext>;
2340
- "primer-oncheckout-complete": CustomEvent<OnCheckoutCompletePayload>;
2341
- "primer-oncheckout-failure": CustomEvent<OnCheckoutFailurePayload>;
2342
- "primer-payment-methods-updated": CustomEvent<InitializedPayments>;
2343
- "primer-checkout-initialized": CustomEvent<PrimerHeadlessCheckout>;
2344
- "primer-card-network-change": CustomEvent<CardNetworksContext>;
2345
- "primer-card-submit-success": CustomEvent<CardSubmitSuccessPayload>;
2346
- "primer-card-submit-errors": CustomEvent<CardSubmitErrorsPayload>;
2483
+ "primer:state-change": CustomEvent<SdkStateContext>;
2484
+ "primer:methods-update": CustomEvent<InitializedPayments>;
2485
+ "primer:ready": CustomEvent<PrimerJS>;
2486
+ "primer:card-network-change": CustomEvent<CardNetworksContext>;
2487
+ "primer:card-success": CustomEvent<CardSubmitSuccessPayload>;
2488
+ "primer:card-error": CustomEvent<CardSubmitErrorsPayload>;
2347
2489
  "primer-ach-error": CustomEvent<PrimeAchErrorPayload>;
2348
2490
  "primer-ach-bank-details-collected": CustomEvent;
2349
2491
  "primer-ach-mandate-confirmed": CustomEvent;
@@ -2363,10 +2505,8 @@ declare class PrimerEventsController implements ReactiveController {
2363
2505
  dispatchEvent<K extends keyof PrimerEvents>(type: K, detail: PrimerEvents[K]["detail"]): void;
2364
2506
  dispatchSdkState(sdkState: SdkStateContext): void;
2365
2507
  dispatchPaymentMethods(paymentMethods: InitializedPayments): void;
2366
- dispatchCheckoutInitialized(checkoutInstance: PrimerHeadlessCheckout): void;
2508
+ dispatchCheckoutInitialized(checkoutInstance: PrimerJS): void;
2367
2509
  dispatchCardNetworkChange(network: CardNetworksContext): void;
2368
- dispatchOnCheckoutComplete(payment: Payment | null): void;
2369
- dispatchOnCheckoutFailure(error: PrimerClientError, payment?: Payment): void;
2370
2510
  dispatchFormSubmitSuccess(result: unknown): void;
2371
2511
  dispatchFormSubmitErrors(errors: unknown): void;
2372
2512
  }
@@ -2659,6 +2799,146 @@ declare class StyleProcessingController implements ReactiveController {
2659
2799
  */
2660
2800
  hostDisconnected(): void;
2661
2801
  }
2802
+ interface ReactiveControllerHost$1 {
2803
+ /**
2804
+ * Adds a controller to the host, which sets up the controller's lifecycle
2805
+ * methods to be called with the host's lifecycle.
2806
+ */
2807
+ addController(controller: ReactiveController$1): void;
2808
+ /**
2809
+ * Removes a controller from the host.
2810
+ */
2811
+ removeController(controller: ReactiveController$1): void;
2812
+ /**
2813
+ * Requests a host update which is processed asynchronously. The update can
2814
+ * be waited on via the `updateComplete` property.
2815
+ */
2816
+ requestUpdate(): void;
2817
+ /**
2818
+ * Returns a Promise that resolves when the host has completed updating.
2819
+ * The Promise value is a boolean that is `true` if the element completed the
2820
+ * update without triggering another update. The Promise result is `false` if
2821
+ * a property was set inside `updated()`. If the Promise is rejected, an
2822
+ * exception was thrown during the update.
2823
+ *
2824
+ * @return A promise of a boolean that indicates if the update resolved
2825
+ * without triggering another update.
2826
+ */
2827
+ readonly updateComplete: Promise<boolean>;
2828
+ }
2829
+ interface ReactiveController$1 {
2830
+ /**
2831
+ * Called when the host is connected to the component tree. For custom
2832
+ * element hosts, this corresponds to the `connectedCallback()` lifecycle,
2833
+ * which is only called when the component is connected to the document.
2834
+ */
2835
+ hostConnected?(): void;
2836
+ /**
2837
+ * Called when the host is disconnected from the component tree. For custom
2838
+ * element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
2839
+ * which is called the host or an ancestor component is disconnected from the
2840
+ * document.
2841
+ */
2842
+ hostDisconnected?(): void;
2843
+ /**
2844
+ * Called during the client-side host update, just before the host calls
2845
+ * its own update.
2846
+ *
2847
+ * Code in `update()` can depend on the DOM as it is not called in
2848
+ * server-side rendering.
2849
+ */
2850
+ hostUpdate?(): void;
2851
+ /**
2852
+ * Called after a host update, just before the host calls firstUpdated and
2853
+ * updated. It is not called in server-side rendering.
2854
+ *
2855
+ */
2856
+ hostUpdated?(): void;
2857
+ }
2858
+ interface ComplexAttributeConverter$1<Type = unknown, TypeHint = unknown> {
2859
+ /**
2860
+ * Called to convert an attribute value to a property
2861
+ * value.
2862
+ */
2863
+ fromAttribute?(value: string | null, type?: TypeHint): Type;
2864
+ /**
2865
+ * Called to convert a property value to an attribute
2866
+ * value.
2867
+ *
2868
+ * It returns unknown instead of string, to be compatible with
2869
+ * https://github.com/WICG/trusted-types (and similar efforts).
2870
+ */
2871
+ toAttribute?(value: Type, type?: TypeHint): unknown;
2872
+ }
2873
+ type AttributeConverter$1<Type = unknown, TypeHint = unknown> = ComplexAttributeConverter$1<Type> | ((value: string | null, type?: TypeHint) => Type);
2874
+ interface PropertyDeclaration$1<Type = unknown, TypeHint = unknown> {
2875
+ /**
2876
+ * When set to `true`, indicates the property is internal private state. The
2877
+ * property should not be set by users. When using TypeScript, this property
2878
+ * should be marked as `private` or `protected`, and it is also a common
2879
+ * practice to use a leading `_` in the name. The property is not added to
2880
+ * `observedAttributes`.
2881
+ */
2882
+ readonly state?: boolean;
2883
+ /**
2884
+ * Indicates how and whether the property becomes an observed attribute.
2885
+ * If the value is `false`, the property is not added to `observedAttributes`.
2886
+ * If true or absent, the lowercased property name is observed (e.g. `fooBar`
2887
+ * becomes `foobar`). If a string, the string value is observed (e.g
2888
+ * `attribute: 'foo-bar'`).
2889
+ */
2890
+ readonly attribute?: boolean | string;
2891
+ /**
2892
+ * Indicates the type of the property. This is used only as a hint for the
2893
+ * `converter` to determine how to convert the attribute
2894
+ * to/from a property.
2895
+ */
2896
+ readonly type?: TypeHint;
2897
+ /**
2898
+ * Indicates how to convert the attribute to/from a property. If this value
2899
+ * is a function, it is used to convert the attribute value a the property
2900
+ * value. If it's an object, it can have keys for `fromAttribute` and
2901
+ * `toAttribute`. If no `toAttribute` function is provided and
2902
+ * `reflect` is set to `true`, the property value is set directly to the
2903
+ * attribute. A default `converter` is used if none is provided; it supports
2904
+ * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,
2905
+ * when a property changes and the converter is used to update the attribute,
2906
+ * the property is never updated again as a result of the attribute changing,
2907
+ * and vice versa.
2908
+ */
2909
+ readonly converter?: AttributeConverter$1<Type, TypeHint>;
2910
+ /**
2911
+ * Indicates if the property should reflect to an attribute.
2912
+ * If `true`, when the property is set, the attribute is set using the
2913
+ * attribute name determined according to the rules for the `attribute`
2914
+ * property option and the value of the property converted using the rules
2915
+ * from the `converter` property option.
2916
+ */
2917
+ readonly reflect?: boolean;
2918
+ /**
2919
+ * A function that indicates if a property should be considered changed when
2920
+ * it is set. The function should take the `newValue` and `oldValue` and
2921
+ * return `true` if an update should be requested.
2922
+ */
2923
+ hasChanged?(value: Type, oldValue: Type): boolean;
2924
+ /**
2925
+ * Indicates whether an accessor will be created for this property. By
2926
+ * default, an accessor will be generated for this property that requests an
2927
+ * update when set. If this flag is `true`, no accessor will be created, and
2928
+ * it will be the user's responsibility to call
2929
+ * `this.requestUpdate(propertyName, oldValue)` to request an update when
2930
+ * the property changes.
2931
+ */
2932
+ readonly noAccessor?: boolean;
2933
+ }
2934
+ declare global {
2935
+ interface SymbolConstructor {
2936
+ readonly metadata: unique symbol;
2937
+ }
2938
+ }
2939
+ declare global {
2940
+ var litPropertyMetadata: WeakMap<object, Map<PropertyKey, PropertyDeclaration$1>>;
2941
+ }
2662
2942
  declare const sourceLocale = `en`;
2663
2943
  declare const targetLocales = [
2664
2944
  `ar`,
@@ -3290,7 +3570,7 @@ declare global {
3290
3570
  export type PaymentMethodsContext = InitializedPayments | null;
3291
3571
  declare class PaymentMethodComponent extends LitElement {
3292
3572
  static styles: CSSResult[];
3293
- type: PaymentMethodType | undefined;
3573
+ type: PaymentMethodType$1 | undefined;
3294
3574
  paymentMethods: PaymentMethodsContext;
3295
3575
  render(): typeof nothing | TemplateResult<1>;
3296
3576
  }
@@ -3403,519 +3683,293 @@ declare global {
3403
3683
  "primer-redirect-payment": RedirectPaymentComponent;
3404
3684
  }
3405
3685
  }
3406
- declare class PrimerMainComponent extends LitElement {
3407
- static styles: CSSResult[];
3408
- private hasAssignedContent;
3409
- /**
3410
- * Inline slotchange event listener.
3411
- * Uses assignedNodes with flatten to detect if the slot has any nodes.
3412
- */
3413
- private onSlotChange;
3414
- paymentMethods: PaymentMethodsContext;
3415
- sdkState: SdkStateContext;
3416
- render(): TemplateResult<1>;
3417
- }
3418
- declare global {
3419
- interface HTMLElementTagNameMap {
3420
- "primer-main": PrimerMainComponent;
3421
- }
3422
- }
3423
3686
  /**
3424
- * Component for rendering native payment buttons (Apple Pay, Google Pay, PayPal)
3425
- * with proper height calculations based on design system variables.
3687
+ * Events emitted by the vault manager components
3426
3688
  */
3427
- declare class NativePaymentComponent extends LitElement {
3428
- static styles: CSSResult[];
3429
- paymentMethod: InitializedPaymentMethod | undefined;
3430
- paymentManagers: InitializedManagersMap;
3431
- computedStyles: CSSStyleDeclaration | null;
3432
- private _buttonId;
3433
- private loadManagerTask;
3434
- constructor();
3435
- /**
3436
- * Calculates the button height based on CSS variables
3437
- * Mirrors the calculation used in the host styles
3438
- */
3439
- private calculateButtonHeight;
3440
- /**
3441
- * Creates render options with appropriate styles based on payment method type
3442
- */
3443
- private createRenderOptions;
3444
- protected updated(changedProperties: PropertyValues): void;
3445
- render(): symbol | TemplateResult<1> | undefined;
3446
- }
3447
- declare global {
3448
- interface HTMLElementTagNameMap {
3449
- "primer-native-payment": NativePaymentComponent;
3450
- }
3689
+ export interface VaultManagerEvents {
3690
+ deletePaymentMethod: CustomEvent<string>;
3691
+ cancelDelete: CustomEvent<void>;
3692
+ confirmDelete: CustomEvent<void>;
3693
+ toggleEditMode: CustomEvent<boolean>;
3694
+ closeError: CustomEvent<void>;
3695
+ vaultPaymentError: CustomEvent<{
3696
+ error: Error | unknown;
3697
+ }>;
3451
3698
  }
3452
3699
  /**
3453
- * CardFormComponent serves as a container for card input components.
3454
- * It handles form submission, validation, and provides context to child components.
3700
+ * Declare the event map for strict typing of events
3455
3701
  */
3456
- declare class CardFormComponent extends LitElement {
3457
- static styles: CSSResult[];
3458
- hideLabels: boolean;
3459
- updated(changedProperties: Map<string, unknown>): void;
3460
- /**
3461
- * Tracks whether custom content has been provided via slot
3462
- */
3463
- private hasAssignedContent;
3464
- private selectedCardNetwork;
3465
- /**
3466
- * Payment managers injected from context
3467
- */
3468
- paymentManagers: InitializedManagersMap;
3469
- /**
3470
- * Context provider for card form data
3471
- */
3472
- private readonly cardFormProvider;
3473
- /**
3474
- * Events controller for dispatching form events
3475
- */
3476
- private readonly eventsController;
3477
- /**
3478
- * Task to set up the card form with hosted inputs
3479
- */
3480
- private readonly setupCardFormTask;
3481
- connectedCallback(): void;
3482
- disconnectedCallback(): void;
3483
- /**
3484
- * Handles click events from slotted content.
3485
- * Supports both native <button> and custom <primer-button> elements.
3486
- */
3487
- private handleSlotButtonClick;
3488
- /**
3489
- * Handles direct submit events from child components
3490
- * This is a backup method to catch all possible submission events
3491
- */
3492
- private handleDirectSubmit;
3493
- /**
3494
- * Determines if a button is a submit button based on its attributes
3495
- */
3496
- private isSubmitButton;
3497
- /**
3498
- * Handles slot change events to detect custom content
3499
- */
3500
- private onSlotChange;
3501
- /**
3502
- * Handles the card form submission.
3503
- * Validates the form and dispatches either a submit success or errors event.
3504
- */
3505
- private submitCardPayment;
3506
- /**
3507
- * Event handler for form submission
3508
- * Handles both native form submissions and custom events
3509
- */
3510
- private handleFormSubmit;
3511
- render(): typeof nothing | TemplateResult<1>;
3512
- }
3513
- export interface CardFormContext {
3514
- cardNumberInput: IHeadlessHostedInput;
3515
- expiryInput: IHeadlessHostedInput;
3516
- cvvInput: IHeadlessHostedInput;
3517
- setCardholderName: (val: string) => void;
3518
- setCardNetwork: (val: string) => void;
3519
- validate: () => Promise<Validation>;
3520
- submit: (values?: CardPaymentMethodSubmitValues) => Promise<void>;
3521
- errors?: Validation["validationErrors"];
3522
- hideLabels?: boolean;
3702
+ export interface VaultManagerEventMap {
3703
+ "delete-payment-method": VaultManagerEvents["deletePaymentMethod"];
3704
+ "cancel-delete": VaultManagerEvents["cancelDelete"];
3705
+ "confirm-delete": VaultManagerEvents["confirmDelete"];
3706
+ "toggle-edit-mode": VaultManagerEvents["toggleEditMode"];
3707
+ "close-error": VaultManagerEvents["closeError"];
3708
+ "primer-vault-payment-error": VaultManagerEvents["vaultPaymentError"];
3523
3709
  }
3524
3710
  /**
3525
- * A shared type that ensures the host of a HostedInputController contains
3526
- * the required properties for proper hosted input handling.
3711
+ * VaultManagerComponent - displays and manages saved payment methods
3527
3712
  */
3528
- export interface HostedInputHost extends ReactiveControllerHost, LitElement {
3529
- cardFormContext: CardFormContext | null;
3530
- computedStyles: CSSStyleDeclaration | null;
3531
- /** A string for the input placeholder. */
3532
- placeholder: string;
3533
- /** An accessible label for the input. */
3534
- ariaLabel: string;
3535
- /** The label for the input. */
3536
- label: string;
3537
- requestUpdate: ReactiveControllerHost["requestUpdate"];
3538
- }
3539
- export interface TaskFunctionOptions {
3540
- signal: AbortSignal;
3541
- }
3542
- export type TaskFunction<D extends ReadonlyArray<unknown>, R = unknown> = (args: D, options: TaskFunctionOptions) => R | typeof initialState | Promise<R | typeof initialState>;
3543
- export type ArgsFunction<D extends ReadonlyArray<unknown>> = () => D;
3544
- declare const TaskStatus: {
3545
- readonly INITIAL: 0;
3546
- readonly PENDING: 1;
3547
- readonly COMPLETE: 2;
3548
- readonly ERROR: 3;
3549
- };
3550
- declare const initialState: unique symbol;
3551
- export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
3552
- export type StatusRenderer<R> = {
3553
- initial?: () => unknown;
3554
- pending?: () => unknown;
3555
- complete?: (value: R) => unknown;
3556
- error?: (error: unknown) => unknown;
3557
- };
3558
- export interface TaskConfig<T extends ReadonlyArray<unknown>, R> {
3559
- task: TaskFunction<T, R>;
3560
- args?: ArgsFunction<T>;
3561
- /**
3562
- * Determines if the task is run automatically when arguments change after a
3563
- * host update. Default to `true`.
3564
- *
3565
- * If `true`, the task checks arguments during the host update (after
3566
- * `willUpdate()` and before `update()` in Lit) and runs if they change. For
3567
- * a task to see argument changes they must be done in `willUpdate()` or
3568
- * earlier. The host element can see task status changes caused by its own
3569
- * current update.
3570
- *
3571
- * If `'afterUpdate'`, the task checks arguments and runs _after_ the host
3572
- * update. This means that the task can see host changes done in update, such
3573
- * as rendered DOM. The host element can not see task status changes caused
3574
- * by its own update, so the task must trigger a second host update to make
3575
- * those changes renderable.
3576
- *
3577
- * Note: `'afterUpdate'` is unlikely to be SSR compatible in the future.
3578
- *
3579
- * If `false`, the task is not run automatically, and must be run with the
3580
- * {@linkcode run} method.
3581
- */
3582
- autoRun?: boolean | "afterUpdate";
3713
+ declare class VaultManagerComponent extends LitElement {
3714
+ static styles: CSSResult[];
3715
+ constructor();
3716
+ addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3717
+ removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3718
+ vaultManagerContext: VaultManagerContext;
3583
3719
  /**
3584
- * A function that determines if the current arg and previous args arrays are
3585
- * equal. If the argsEqual function returns true, the task will not auto-run.
3586
- *
3587
- * The default is {@linkcode shallowArrayEquals}. {@linkcode deepArrayEquals}
3588
- * is also available.
3720
+ * Whether we're in edit mode
3589
3721
  */
3590
- argsEqual?: (oldArgs: T, newArgs: T) => boolean;
3722
+ private isEditMode;
3591
3723
  /**
3592
- * If initialValue is provided, the task is initialized to the COMPLETE
3593
- * status and the value is set to initialData.
3594
- *
3595
- * Initial args should be coherent with the initialValue, since they are
3596
- * assumed to be the args that would produce that value. When autoRun is
3597
- * `true` the task will not auto-run again until the args change.
3724
+ * Payment method being deleted
3598
3725
  */
3599
- initialValue?: R;
3600
- onComplete?: (value: R) => unknown;
3601
- onError?: (error: unknown) => unknown;
3602
- }
3603
- declare class Task<const T extends ReadonlyArray<unknown> = ReadonlyArray<unknown>, const R = unknown> {
3604
- private _previousArgs?;
3605
- private _task;
3606
- private _argsFn?;
3607
- private _argsEqual;
3608
- private _callId;
3609
- private _host;
3610
- private _value?;
3611
- private _error?;
3612
- private _abortController?;
3613
- private _onComplete?;
3614
- private _onError?;
3615
- private _status;
3726
+ private deletePaymentMethodId;
3616
3727
  /**
3617
- * Determines if the task is run automatically when arguments change after a
3618
- * host update. Default to `true`.
3619
- *
3620
- * @see {@link TaskConfig.autoRun} for more information.
3728
+ * Whether a delete operation is in progress
3621
3729
  */
3622
- autoRun: boolean | "afterUpdate";
3730
+ private isDeleting;
3623
3731
  /**
3624
- * A Promise that resolve when the current task run is complete.
3625
- *
3626
- * If a new task run is started while a previous run is pending, the Promise
3627
- * is kept and only resolved when the new run is completed.
3732
+ * Error message if something goes wrong
3628
3733
  */
3629
- get taskComplete(): Promise<R>;
3630
- private _resolveTaskComplete?;
3631
- private _rejectTaskComplete?;
3632
- private _taskComplete?;
3633
- constructor(host: ReactiveControllerHost, task: TaskConfig<T, R>);
3634
- constructor(host: ReactiveControllerHost, task: TaskFunction<T, R>, args?: ArgsFunction<T>);
3635
- hostUpdate(): void;
3636
- hostUpdated(): void;
3637
- private _getArgs;
3734
+ private errorMessage;
3638
3735
  /**
3639
- * Determines if the task should run when it's triggered because of a
3640
- * host update, and runs the task if it should.
3641
- *
3642
- * A task should run when its arguments change from the previous run, based on
3643
- * the args equality function.
3644
- *
3645
- * This method is side-effectful: it stores the new args as the previous args.
3736
+ * Animation duration override
3646
3737
  */
3647
- private _performTask;
3738
+ animationDuration: number;
3648
3739
  /**
3649
- * Runs a task manually.
3650
- *
3651
- * This can be useful for running tasks in response to events as opposed to
3652
- * automatically running when host element state changes.
3653
- *
3654
- * @param args an optional set of arguments to use for this task run. If args
3655
- * is not given, the args function is called to get the arguments for
3656
- * this run.
3740
+ * Get base animation configuration with current settings
3657
3741
  */
3658
- run(args?: T): Promise<void>;
3742
+ private getAnimationConfig;
3659
3743
  /**
3660
- * Aborts the currently pending task run by aborting the AbortSignal
3661
- * passed to the task function.
3662
- *
3663
- * Aborting a task does nothing if the task is not running: ie, in the
3664
- * complete, error, or initial states.
3665
- *
3666
- * Aborting a task does not automatically cancel the task function. The task
3667
- * function must be written to accept the AbortSignal and either forward it
3668
- * to other APIs like `fetch()`, or handle cancellation manually by using
3669
- * [`signal.throwIfAborted()`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted}
3670
- * or the
3671
- * [`abort`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort_event}
3672
- * event.
3673
- *
3674
- * @param reason The reason for aborting. Passed to
3675
- * `AbortController.abort()`.
3744
+ * Toggle edit mode handler
3676
3745
  */
3677
- abort(reason?: unknown): void;
3746
+ private handleToggleEditMode;
3678
3747
  /**
3679
- * The result of the previous task run, if it resolved.
3680
- *
3681
- * Is `undefined` if the task has not run yet, or if the previous run errored.
3748
+ * Handle delete click from payment method item
3682
3749
  */
3683
- get value(): R | undefined;
3750
+ private handleDeletePaymentMethod;
3684
3751
  /**
3685
- * The error from the previous task run, if it rejected.
3686
- *
3687
- * Is `undefined` if the task has not run yet, or if the previous run
3688
- * completed successfully.
3752
+ * Cancel delete operation
3689
3753
  */
3690
- get error(): unknown;
3691
- get status(): TaskStatus;
3692
- render<T extends StatusRenderer<R>>(renderer: T): MaybeReturnType<T["initial"]> | MaybeReturnType<T["pending"]> | MaybeReturnType<T["complete"]> | MaybeReturnType<T["error"]>;
3693
- }
3694
- export type MaybeReturnType<F> = F extends (...args: never[]) => infer R ? R : undefined;
3695
- /**
3696
- * Available input types for hosted inputs.
3697
- */
3698
- export type HostedInputType = "cardNumber" | "cvv" | "expire" | "cardholderName";
3699
- /**
3700
- * Configuration for the hosted input controller.
3701
- */
3702
- export interface HostedInputConfig {
3703
- /** Differentiates the input type. */
3704
- type: HostedInputType;
3705
- /** Selector for the container element where the input should be rendered. */
3706
- containerSelector: string;
3754
+ private handleCancelDelete;
3707
3755
  /**
3708
- * Optional callback for handling input events (e.g. for CardFormName).
3756
+ * Confirm and process payment method deletion
3709
3757
  */
3710
- onInput?: (value: string) => void;
3711
- }
3712
- /**
3713
- * Possible input source types that can be returned by getHostedInput
3714
- */
3715
- export type InputSource = IHeadlessHostedInput | "cardholderName" | undefined;
3716
- declare class HostedInputController<T extends HostedInputHost> implements ReactiveController {
3717
- private _isFocused;
3718
- private _meta;
3719
- private _hostedInput;
3720
- private _standardInput;
3721
- private readonly host;
3722
- private readonly config;
3758
+ private handleConfirmDelete;
3723
3759
  /**
3724
- * Task to set up the hosted input.
3760
+ * Handle payment error events
3725
3761
  */
3726
- readonly setupTask: Task<[
3727
- InputSource
3728
- ], boolean | typeof initialState>;
3729
- constructor(host: T, config: HostedInputConfig);
3762
+ private handlePaymentError;
3730
3763
  /**
3731
- * Focuses the input, whether it's a hosted input or standard input
3764
+ * Handle closing error message
3732
3765
  */
3733
- focusInput(): void;
3766
+ private handleCloseError;
3734
3767
  /**
3735
- * Returns the hosted input from the card form context based on the type.
3736
- * For 'cardholderName', no hosted input is provided so we return a fallback indicator.
3768
+ * Get payment method display name for the given ID
3737
3769
  */
3738
- private getHostedInput;
3770
+ private getPaymentMethodName;
3739
3771
  /**
3740
- * Sets up the hosted input.
3741
- * If a hosted input is provided, it renders it into the target container.
3742
- * Otherwise (e.g. for cardholderName), it creates a standard input element.
3772
+ * Render loading overlay with spinner when isUpdating is true
3743
3773
  */
3744
- private setupHostedInput;
3774
+ private renderLoadingOverlay;
3745
3775
  /**
3746
- * Gets the target container element from the host's render root
3776
+ * Render delete confirmation content
3747
3777
  */
3748
- private getTargetContainer;
3778
+ private renderDeleteConfirmation;
3749
3779
  /**
3750
- * Sets up a standard input element for non-hosted input types
3780
+ * Render a payment method item with appropriate animations
3751
3781
  */
3752
- private setupStandardInput;
3782
+ private renderPaymentMethodItem;
3753
3783
  /**
3754
- * Sets up event listeners for standard input elements
3784
+ * Render the payment method list with submit button
3755
3785
  */
3756
- private setupInputEventListeners;
3786
+ private renderPaymentMethodList;
3757
3787
  /**
3758
- * Sets up a hosted iframe input for iframe-based input types
3788
+ * Main render method
3759
3789
  */
3760
- private setupHostedIframeInput;
3761
- /** Exposes the current focus state. */
3762
- get isFocused(): boolean;
3763
- /** Exposes the current metadata state. */
3764
- get meta(): InputMetadata;
3765
- hostConnected(): void;
3766
- hostDisconnected(): void;
3790
+ render(): typeof nothing | TemplateResult<1>;
3767
3791
  }
3768
3792
  /**
3769
- * Translation configuration object
3770
- */
3771
- export type TranslationConfig = {
3772
- id: string;
3773
- defaultMessage: string;
3774
- };
3775
- /**
3776
- * Configuration for abstract input component
3793
+ * VaultPaymentMethodItemComponent - displays a single payment method
3794
+ * Uses the VaultManagerController for display formatting
3795
+ * Now supports selection via the simplified button checked state
3796
+ * Enhanced with smooth transitions between edit and payment modes
3797
+ * Always renders the primer-button for consistent UI and improved accessibility
3777
3798
  */
3778
- export interface InputComponentConfig {
3779
- /** The component's hosted input type */
3780
- inputType: HostedInputType;
3781
- /** ID selector for the container where the input will be rendered */
3782
- containerSelector: string;
3783
- /** Error name to match in the card form context */
3784
- errorName: string;
3785
- /** Translation keys for default values */
3786
- translations: {
3787
- label: TranslationConfig | string;
3788
- placeholder?: TranslationConfig | string;
3789
- ariaLabel?: TranslationConfig | string;
3790
- };
3791
- /** Optional input handler for non-hosted inputs */
3792
- onInput?: (value: string) => void;
3793
- }
3794
- declare abstract class AbstractCardInputComponent extends LitElement implements HostedInputHost {
3795
- cardFormContext: CardFormContext | null;
3796
- computedStyles: CSSStyleDeclaration | null;
3797
- /** Tracks which properties were explicitly set by the user */
3798
- protected readonly _userAssignedProps: Set<string>;
3799
- /** Internal storage for property values */
3800
- protected _internalLabel: string;
3801
- protected _internalPlaceholder: string;
3802
- protected _internalAriaLabel: string;
3803
- /** Configuration for this input component */
3804
- protected abstract readonly config: InputComponentConfig;
3805
- /** Hosted input controller */
3806
- protected readonly hostedInputController: HostedInputController<HostedInputHost>;
3799
+ declare class VaultPaymentMethodItemComponent extends LitElement {
3800
+ static styles: CSSResult[];
3807
3801
  /**
3808
- * Gets a translated or static string value from the translation config
3802
+ * Strongly typed event declarations
3809
3803
  */
3810
- private getTranslatedValue;
3804
+ addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3805
+ removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3811
3806
  /**
3812
- * The input label text.
3813
- * Falls back to localized default if not explicitly set.
3807
+ * Consume the vault manager context
3814
3808
  */
3815
- get label(): string;
3816
- set label(value: string);
3809
+ vaultManagerContext: VaultManagerContext;
3810
+ vaultItemContext: VaultItemContext;
3811
+ headlessUtils: HeadlessUnitilsContext;
3817
3812
  /**
3818
- * The input placeholder text.
3819
- * Falls back to localized default if not explicitly set.
3820
- * When explicitly set to empty string, no placeholder will be displayed.
3813
+ * The payment method to display
3821
3814
  */
3822
- get placeholder(): string;
3823
- set placeholder(value: string);
3815
+ paymentMethod: VaultedPaymentMethod | null;
3816
+ /**
3817
+ * Whether the component is in edit mode
3818
+ */
3819
+ isEditMode: boolean;
3820
+ private _getAssetsTask;
3824
3821
  /**
3825
- * The input aria-label attribute.
3826
- * Falls back to localized default if not explicitly set.
3822
+ * Check if this payment method is currently selected in the context
3827
3823
  */
3828
- get ariaLabel(): string;
3829
- set ariaLabel(value: string);
3830
- constructor();
3824
+ private isSelected;
3831
3825
  /**
3832
- * Initialize the controller after the component has been constructed
3833
- * and the config is available
3826
+ * Handle when the button is clicked
3827
+ * This is used to select the payment method and deselect others
3834
3828
  */
3835
- protected childUpdated(): void;
3829
+ private handleClick;
3836
3830
  /**
3837
- * Handler for wrapper-click event from InputWrapper component
3838
- * This is still needed for hosted iframe inputs
3831
+ * Dispatch delete event
3839
3832
  */
3840
- private handleWrapperClick;
3833
+ private handleDeleteClick;
3841
3834
  /**
3842
- * Get the error code from the hosted input controller when the input is submitted or touched
3843
- *
3844
- * Can be used instead of the error returned by the `validate()` method since internally `primer-sdk-web`
3845
- * uses the same logic to compute the error code
3846
- *
3847
- * @returns {string|null}
3835
+ * Builds the common content template shared between modes
3848
3836
  */
3849
- getError(): string | null;
3837
+ private renderPaymentMethodContent;
3850
3838
  /**
3851
- * Common rendering logic for all card input components
3839
+ * Render method
3852
3840
  */
3853
- protected renderInput(): typeof nothing | TemplateResult<1>;
3841
+ render(): symbol | TemplateResult<1> | undefined;
3842
+ }
3843
+ declare global {
3844
+ interface HTMLElementTagNameMap {
3845
+ "primer-vault-payment-method-item": VaultPaymentMethodItemComponent;
3846
+ }
3854
3847
  }
3855
3848
  /**
3856
- * Card number input component with dynamic card network detection and selection
3849
+ * VaultManagerHeaderComponent - displays the header for the vault manager
3857
3850
  */
3858
- declare class InputCardNumberComponent extends AbstractCardInputComponent {
3851
+ declare class VaultManagerHeaderComponent extends LitElement {
3859
3852
  static styles: CSSResult[];
3860
3853
  /**
3861
- * Configuration for this input component
3854
+ * Strongly typed event declarations
3862
3855
  */
3863
- protected readonly config: InputComponentConfig;
3864
- constructor();
3856
+ addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3857
+ removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3865
3858
  /**
3866
- * Handle network selection from the network selector component
3859
+ * Whether we're in edit mode
3867
3860
  */
3868
- private handleNetworkSelected;
3861
+ isEditMode: boolean;
3869
3862
  /**
3870
- * Override the renderInput method to include the network selector
3863
+ * Whether we have payment methods to edit
3871
3864
  */
3872
- protected renderInput(): typeof nothing | TemplateResult<1>;
3873
- render(): typeof nothing | TemplateResult<1>;
3865
+ hasPaymentMethods: boolean;
3866
+ /**
3867
+ * Toggle edit mode
3868
+ */
3869
+ private toggleEditMode;
3870
+ /**
3871
+ * Render method
3872
+ */
3873
+ protected render(): TemplateResult<1>;
3874
3874
  }
3875
3875
  declare global {
3876
3876
  interface HTMLElementTagNameMap {
3877
- "primer-input-card-number": InputCardNumberComponent;
3877
+ "primer-vault-manager-header": VaultManagerHeaderComponent;
3878
3878
  }
3879
3879
  }
3880
- declare class InputCvvComponent extends AbstractCardInputComponent {
3880
+ /**
3881
+ * VaultDeleteConfirmationComponent - displays confirmation UI for deleting a payment method
3882
+ */
3883
+ declare class VaultDeleteConfirmationComponent extends LitElement {
3881
3884
  static styles: CSSResult[];
3882
- protected readonly config: InputComponentConfig;
3883
- constructor();
3884
- render(): typeof nothing | TemplateResult<1>;
3885
+ /**
3886
+ * Strongly typed event declarations
3887
+ */
3888
+ addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3889
+ removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3890
+ /**
3891
+ * Whether a delete operation is in progress
3892
+ */
3893
+ isDeleting: boolean;
3894
+ /**
3895
+ * The ID of the payment method being deleted
3896
+ */
3897
+ paymentMethodId: string;
3898
+ /**
3899
+ * Payment method name to display in confirmation
3900
+ */
3901
+ paymentMethodName: string;
3902
+ /**
3903
+ * Consume the vault manager context to access payment method info
3904
+ */
3905
+ vaultManager: VaultManagerContext;
3906
+ /**
3907
+ * Handle confirm click
3908
+ */
3909
+ private handleConfirmClick;
3910
+ /**
3911
+ * Handle cancel click
3912
+ */
3913
+ private handleCancelClick;
3914
+ /**
3915
+ * Render method
3916
+ */
3917
+ protected render(): TemplateResult<1>;
3885
3918
  }
3886
3919
  declare global {
3887
3920
  interface HTMLElementTagNameMap {
3888
- "primer-input-cvv": InputCvvComponent;
3921
+ "primer-vault-delete-confirmation": VaultDeleteConfirmationComponent;
3889
3922
  }
3890
3923
  }
3891
- declare class InputCardExpiryComponent extends AbstractCardInputComponent {
3924
+ /**
3925
+ * VaultEmptyStateComponent - displays when no payment methods are available
3926
+ */
3927
+ declare class VaultEmptyStateComponent extends LitElement {
3892
3928
  static styles: CSSResult[];
3893
- protected readonly config: InputComponentConfig;
3894
- constructor();
3895
- render(): typeof nothing | TemplateResult<1>;
3929
+ /**
3930
+ * Render method
3931
+ */
3932
+ protected render(): TemplateResult<1>;
3896
3933
  }
3897
3934
  declare global {
3898
3935
  interface HTMLElementTagNameMap {
3899
- "primer-input-card-expiry": InputCardExpiryComponent;
3936
+ "primer-vault-empty-state": VaultEmptyStateComponent;
3900
3937
  }
3901
3938
  }
3902
- declare class InputCardHolderNameComponent extends AbstractCardInputComponent {
3939
+ /**
3940
+ * VaultErrorMessageComponent - displays error messages with improved visuals
3941
+ */
3942
+ declare class VaultErrorMessageComponent extends LitElement {
3903
3943
  static styles: CSSResult[];
3904
- protected readonly config: InputComponentConfig;
3905
- constructor();
3906
- private handleInput;
3907
- render(): typeof nothing | TemplateResult<1>;
3944
+ /**
3945
+ * Strongly typed event declarations
3946
+ */
3947
+ addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3948
+ removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
3949
+ /**
3950
+ * The error message to display
3951
+ */
3952
+ errorMessage: string;
3953
+ /**
3954
+ * Handle dismiss click
3955
+ */
3956
+ private handleDismiss;
3957
+ /**
3958
+ * Render method
3959
+ */
3960
+ protected render(): TemplateResult<1>;
3908
3961
  }
3909
3962
  declare global {
3910
3963
  interface HTMLElementTagNameMap {
3911
- "primer-input-card-holder-name": InputCardHolderNameComponent;
3964
+ "primer-vault-error-message": VaultErrorMessageComponent;
3912
3965
  }
3913
3966
  }
3914
3967
  /**
3915
- * A form submit button component for card forms.
3968
+ * A submit button component for vault payment flows.
3916
3969
  * Provides a consistent submit button with translation support.
3970
+ * Integrates with the vault manager context to handle payment submission.
3917
3971
  */
3918
- declare class CardFormSubmitComponent extends LitElement {
3972
+ declare class VaultPaymentSubmitComponent extends LitElement {
3919
3973
  static styles: CSSResult[];
3920
3974
  private readonly _userAssignedProps;
3921
3975
  private _internalButtonText;
@@ -3926,8 +3980,10 @@ declare class CardFormSubmitComponent extends LitElement {
3926
3980
  get buttonText(): string;
3927
3981
  set buttonText(value: string);
3928
3982
  headlessInstance: HeadlessUnitilsContext;
3929
- clientOptions: ClientOptionsContext;
3930
3983
  sdkState: SdkStateContext;
3984
+ vaultItemContext: VaultItemContext;
3985
+ vaultManager: VaultManagerContext;
3986
+ clientOptions: PrimerCheckoutOptions | null;
3931
3987
  /**
3932
3988
  * The button variant to use.
3933
3989
  * @default "primary"
@@ -3935,409 +3991,599 @@ declare class CardFormSubmitComponent extends LitElement {
3935
3991
  variant: string;
3936
3992
  /**
3937
3993
  * Whether the button is disabled.
3994
+ * This property allows external disabling of the button
3995
+ * regardless of the context state.
3938
3996
  * @default false
3939
3997
  */
3940
3998
  disabled: boolean;
3999
+ /**
4000
+ * Handle button click event.
4001
+ * Prevents default form submission and triggers the vault payment flow.
4002
+ */
3941
4003
  private handleClick;
4004
+ /**
4005
+ * Computed property to determine if the button should be disabled
4006
+ */
4007
+ private get isButtonDisabled();
3942
4008
  render(): TemplateResult<1>;
3943
4009
  }
3944
4010
  declare global {
3945
4011
  interface HTMLElementTagNameMap {
3946
- "primer-card-form-submit": CardFormSubmitComponent;
4012
+ "primer-vault-payment-submit": VaultPaymentSubmitComponent;
3947
4013
  }
3948
4014
  }
3949
4015
  /**
3950
- * Component for displaying and selecting card networks
3951
- * Uses context directly rather than properties
3952
- *
3953
- * @fires network-selected - Dispatched when a network is selected with the network name as detail
4016
+ * CVV Input component for vault payment methods
4017
+ * Renders a secure iframe for CVV input when required by the selected payment method
4018
+ * Uses dedicated CVV context to minimize re-renders
3954
4019
  */
3955
- declare class CardNetworkSelectorComponent extends LitElement {
4020
+ declare class VaultCvvInputComponent extends LitElement {
3956
4021
  static styles: CSSResult[];
3957
4022
  /**
3958
- * Card networks context from provider
3959
- */
3960
- cardNetworks: CardNetworksContext;
3961
- headlessUtils: HeadlessUnitilsContext;
3962
- private selectedCardNetwork;
3963
- /**
3964
- * Internal state to track if dropdown is open
3965
- */
3966
- private isDropdownOpen;
3967
- /**
3968
- * Index of the currently focused network in the dropdown
3969
- */
3970
- private focusedNetworkIndex;
3971
- /**
3972
- * Tracks if keyboard navigation is being used
3973
- */
3974
- private isKeyboardNavigation;
3975
- /**
3976
- * Reference to the dropdown button
4023
+ * Form context for checking form dirty state
3977
4024
  */
3978
- private buttonRef;
4025
+ vaultManagerFormContext: VaultManagerContext;
3979
4026
  /**
3980
- * Reference to the dropdown container
4027
+ * CVV-specific context for dedicated CVV handling
4028
+ * Separated to minimize re-renders on frequent CVV input changes
3981
4029
  */
3982
- private dropdownRef;
4030
+ vaultManagerCvvContext: VaultItemContext;
4031
+ computedStyles: CSSStyleDeclaration | null;
4032
+ paymentMethod: PaymentCardVaultedMethod | null;
4033
+ private cvvError;
4034
+ private cvvInputIsDirty;
4035
+ private cvvInputIsBlurred;
4036
+ private cvvInput;
3983
4037
  /**
3984
- * Reference to network option elements
4038
+ * Unique ID for the CVV input container
3985
4039
  */
3986
- private networkOptionRefs;
4040
+ private readonly cvvContainerId;
4041
+ private _setupCVVIframe;
4042
+ constructor();
4043
+ disconnectedCallback(): void;
3987
4044
  /**
3988
- * Toggle the dropdown state
4045
+ * Update CVV metadata in the context when input changes
3989
4046
  */
3990
- private toggleDropdown;
3991
- private getNetworkIconUrl;
4047
+ onCvvInputChange(): void;
4048
+ onBlur(): void;
3992
4049
  /**
3993
- * Get selectable networks from context
4050
+ * Main render method
3994
4051
  */
3995
- private getSelectableNetworks;
4052
+ protected render(): symbol | TemplateResult<1> | undefined;
4053
+ }
4054
+ declare global {
4055
+ interface HTMLElementTagNameMap {
4056
+ "primer-vault-cvv-input": VaultCvvInputComponent;
4057
+ }
4058
+ }
4059
+ declare global {
4060
+ interface HTMLElementTagNameMap {
4061
+ "primer-vault-manager": VaultManagerComponent;
4062
+ }
4063
+ }
4064
+ /**
4065
+ * CardFormComponent serves as a container for card input components.
4066
+ * It handles form submission, validation, and provides context to child components.
4067
+ */
4068
+ declare class CardFormComponent extends LitElement {
4069
+ static styles: CSSResult[];
4070
+ hideLabels: boolean;
4071
+ updated(changedProperties: Map<string, unknown>): void;
3996
4072
  /**
3997
- * Get detected network from context
4073
+ * Tracks whether custom content has been provided via slot
3998
4074
  */
3999
- private getDetectedNetwork;
4075
+ private hasAssignedContent;
4076
+ private selectedCardNetwork;
4000
4077
  /**
4001
- * Get the index of the currently selected network
4078
+ * Payment managers injected from context
4002
4079
  */
4003
- private getSelectedNetworkIndex;
4080
+ paymentManagers: InitializedManagersMap;
4004
4081
  /**
4005
- * Handle network selection
4082
+ * Context provider for card form data
4006
4083
  */
4007
- private selectNetwork;
4084
+ private readonly cardFormProvider;
4008
4085
  /**
4009
- * Handle click outside to close dropdown
4086
+ * Events controller for dispatching form events
4010
4087
  */
4011
- private handleClickOutside;
4088
+ private readonly eventsController;
4012
4089
  /**
4013
- * Handle mouse movement to disable keyboard navigation mode
4090
+ * Task to set up the card form with hosted inputs
4014
4091
  */
4015
- private handleMouseMove;
4092
+ private readonly setupCardFormTask;
4093
+ connectedCallback(): void;
4094
+ disconnectedCallback(): void;
4016
4095
  /**
4017
- * Handle keydown events for keyboard navigation
4096
+ * Handles click events from slotted content.
4097
+ * Supports both native <button> and custom <primer-button> elements.
4018
4098
  */
4019
- private handleKeyDown;
4099
+ private handleSlotButtonClick;
4020
4100
  /**
4021
- * Focus the current network option
4101
+ * Handles direct submit events from child components
4102
+ * This is a backup method to catch all possible submission events
4022
4103
  */
4023
- private focusNetworkOption;
4104
+ private handleDirectSubmit;
4024
4105
  /**
4025
- * Save reference to network option element
4106
+ * Determines if a button is a submit button based on its attributes
4026
4107
  */
4027
- private setNetworkOptionRef;
4108
+ private isSubmitButton;
4028
4109
  /**
4029
- * Attach event listener to the component for keydown events
4030
- * and to document for click outside and mousemove
4110
+ * Handles slot change events to detect custom content
4031
4111
  */
4032
- connectedCallback(): void;
4112
+ private onSlotChange;
4033
4113
  /**
4034
- * Handle document-level keydown events, but only when dropdown is open
4035
- * This allows keyboard navigation to continue working
4114
+ * Handles the card form submission.
4115
+ * Validates the form and dispatches either a submit success or errors event.
4036
4116
  */
4037
- private handleDocumentKeyDown;
4117
+ private submitCardPayment;
4038
4118
  /**
4039
- * Lifecycle: Remove all event listeners when disconnected
4119
+ * Event handler for form submission
4120
+ * Handles both native form submissions and custom events
4040
4121
  */
4041
- disconnectedCallback(): void;
4042
- render(): TemplateResult<1>;
4043
- }
4044
- declare global {
4045
- interface HTMLElementTagNameMap {
4046
- "primer-card-network-selector": CardNetworkSelectorComponent;
4047
- }
4048
- }
4049
- declare global {
4050
- interface HTMLElementTagNameMap {
4051
- "primer-card-form": CardFormComponent;
4052
- }
4122
+ private handleFormSubmit;
4123
+ render(): typeof nothing | TemplateResult<1>;
4053
4124
  }
4054
- /**
4055
- * Events emitted by the vault manager components
4056
- */
4057
- export interface VaultManagerEvents {
4058
- deletePaymentMethod: CustomEvent<string>;
4059
- cancelDelete: CustomEvent<void>;
4060
- confirmDelete: CustomEvent<void>;
4061
- toggleEditMode: CustomEvent<boolean>;
4062
- closeError: CustomEvent<void>;
4063
- vaultPaymentError: CustomEvent<{
4064
- error: Error | unknown;
4065
- }>;
4125
+ export interface CardFormContext {
4126
+ cardNumberInput: IHeadlessHostedInput;
4127
+ expiryInput: IHeadlessHostedInput;
4128
+ cvvInput: IHeadlessHostedInput;
4129
+ setCardholderName: (val: string) => void;
4130
+ setCardNetwork: (val: string) => void;
4131
+ validate: () => Promise<Validation>;
4132
+ submit: (values?: CardPaymentMethodSubmitValues) => Promise<void>;
4133
+ errors?: Validation["validationErrors"];
4134
+ hideLabels?: boolean;
4066
4135
  }
4067
4136
  /**
4068
- * Declare the event map for strict typing of events
4137
+ * A shared type that ensures the host of a HostedInputController contains
4138
+ * the required properties for proper hosted input handling.
4069
4139
  */
4070
- export interface VaultManagerEventMap {
4071
- "delete-payment-method": VaultManagerEvents["deletePaymentMethod"];
4072
- "cancel-delete": VaultManagerEvents["cancelDelete"];
4073
- "confirm-delete": VaultManagerEvents["confirmDelete"];
4074
- "toggle-edit-mode": VaultManagerEvents["toggleEditMode"];
4075
- "close-error": VaultManagerEvents["closeError"];
4076
- "primer-vault-payment-error": VaultManagerEvents["vaultPaymentError"];
4140
+ export interface HostedInputHost extends ReactiveControllerHost, LitElement {
4141
+ cardFormContext: CardFormContext | null;
4142
+ computedStyles: CSSStyleDeclaration | null;
4143
+ /** A string for the input placeholder. */
4144
+ placeholder: string;
4145
+ /** An accessible label for the input. */
4146
+ ariaLabel: string;
4147
+ /** The label for the input. */
4148
+ label: string;
4149
+ requestUpdate: ReactiveControllerHost["requestUpdate"];
4077
4150
  }
4078
- /**
4079
- * VaultManagerComponent - displays and manages saved payment methods
4080
- */
4081
- declare class VaultManagerComponent extends LitElement {
4082
- static styles: CSSResult[];
4083
- constructor();
4084
- addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4085
- removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4086
- vaultManagerContext: VaultManagerContext;
4151
+ interface ReactiveControllerHost$1 {
4087
4152
  /**
4088
- * Whether we're in edit mode
4153
+ * Adds a controller to the host, which sets up the controller's lifecycle
4154
+ * methods to be called with the host's lifecycle.
4089
4155
  */
4090
- private isEditMode;
4156
+ addController(controller: ReactiveController$1): void;
4091
4157
  /**
4092
- * Payment method being deleted
4158
+ * Removes a controller from the host.
4093
4159
  */
4094
- private deletePaymentMethodId;
4160
+ removeController(controller: ReactiveController$1): void;
4095
4161
  /**
4096
- * Whether a delete operation is in progress
4162
+ * Requests a host update which is processed asynchronously. The update can
4163
+ * be waited on via the `updateComplete` property.
4097
4164
  */
4098
- private isDeleting;
4165
+ requestUpdate(): void;
4099
4166
  /**
4100
- * Error message if something goes wrong
4167
+ * Returns a Promise that resolves when the host has completed updating.
4168
+ * The Promise value is a boolean that is `true` if the element completed the
4169
+ * update without triggering another update. The Promise result is `false` if
4170
+ * a property was set inside `updated()`. If the Promise is rejected, an
4171
+ * exception was thrown during the update.
4172
+ *
4173
+ * @return A promise of a boolean that indicates if the update resolved
4174
+ * without triggering another update.
4101
4175
  */
4102
- private errorMessage;
4176
+ readonly updateComplete: Promise<boolean>;
4177
+ }
4178
+ interface ReactiveController$1 {
4103
4179
  /**
4104
- * Animation duration override
4180
+ * Called when the host is connected to the component tree. For custom
4181
+ * element hosts, this corresponds to the `connectedCallback()` lifecycle,
4182
+ * which is only called when the component is connected to the document.
4105
4183
  */
4106
- animationDuration: number;
4184
+ hostConnected?(): void;
4107
4185
  /**
4108
- * Get base animation configuration with current settings
4186
+ * Called when the host is disconnected from the component tree. For custom
4187
+ * element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
4188
+ * which is called the host or an ancestor component is disconnected from the
4189
+ * document.
4109
4190
  */
4110
- private getAnimationConfig;
4191
+ hostDisconnected?(): void;
4111
4192
  /**
4112
- * Toggle edit mode handler
4193
+ * Called during the client-side host update, just before the host calls
4194
+ * its own update.
4195
+ *
4196
+ * Code in `update()` can depend on the DOM as it is not called in
4197
+ * server-side rendering.
4113
4198
  */
4114
- private handleToggleEditMode;
4199
+ hostUpdate?(): void;
4115
4200
  /**
4116
- * Handle delete click from payment method item
4201
+ * Called after a host update, just before the host calls firstUpdated and
4202
+ * updated. It is not called in server-side rendering.
4203
+ *
4117
4204
  */
4118
- private handleDeletePaymentMethod;
4205
+ hostUpdated?(): void;
4206
+ }
4207
+ export interface TaskFunctionOptions {
4208
+ signal: AbortSignal;
4209
+ }
4210
+ export type TaskFunction<D extends ReadonlyArray<unknown>, R = unknown> = (args: D, options: TaskFunctionOptions) => R | typeof initialState | Promise<R | typeof initialState>;
4211
+ export type ArgsFunction<D extends ReadonlyArray<unknown>> = () => D;
4212
+ declare const TaskStatus: {
4213
+ readonly INITIAL: 0;
4214
+ readonly PENDING: 1;
4215
+ readonly COMPLETE: 2;
4216
+ readonly ERROR: 3;
4217
+ };
4218
+ declare const initialState: unique symbol;
4219
+ export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
4220
+ export type StatusRenderer<R> = {
4221
+ initial?: () => unknown;
4222
+ pending?: () => unknown;
4223
+ complete?: (value: R) => unknown;
4224
+ error?: (error: unknown) => unknown;
4225
+ };
4226
+ export interface TaskConfig<T extends ReadonlyArray<unknown>, R> {
4227
+ task: TaskFunction<T, R>;
4228
+ args?: ArgsFunction<T>;
4119
4229
  /**
4120
- * Cancel delete operation
4230
+ * Determines if the task is run automatically when arguments change after a
4231
+ * host update. Default to `true`.
4232
+ *
4233
+ * If `true`, the task checks arguments during the host update (after
4234
+ * `willUpdate()` and before `update()` in Lit) and runs if they change. For
4235
+ * a task to see argument changes they must be done in `willUpdate()` or
4236
+ * earlier. The host element can see task status changes caused by its own
4237
+ * current update.
4238
+ *
4239
+ * If `'afterUpdate'`, the task checks arguments and runs _after_ the host
4240
+ * update. This means that the task can see host changes done in update, such
4241
+ * as rendered DOM. The host element can not see task status changes caused
4242
+ * by its own update, so the task must trigger a second host update to make
4243
+ * those changes renderable.
4244
+ *
4245
+ * Note: `'afterUpdate'` is unlikely to be SSR compatible in the future.
4246
+ *
4247
+ * If `false`, the task is not run automatically, and must be run with the
4248
+ * {@linkcode run} method.
4121
4249
  */
4122
- private handleCancelDelete;
4250
+ autoRun?: boolean | "afterUpdate";
4123
4251
  /**
4124
- * Confirm and process payment method deletion
4252
+ * A function that determines if the current arg and previous args arrays are
4253
+ * equal. If the argsEqual function returns true, the task will not auto-run.
4254
+ *
4255
+ * The default is {@linkcode shallowArrayEquals}. {@linkcode deepArrayEquals}
4256
+ * is also available.
4125
4257
  */
4126
- private handleConfirmDelete;
4258
+ argsEqual?: (oldArgs: T, newArgs: T) => boolean;
4127
4259
  /**
4128
- * Handle payment error events
4260
+ * If initialValue is provided, the task is initialized to the COMPLETE
4261
+ * status and the value is set to initialData.
4262
+ *
4263
+ * Initial args should be coherent with the initialValue, since they are
4264
+ * assumed to be the args that would produce that value. When autoRun is
4265
+ * `true` the task will not auto-run again until the args change.
4129
4266
  */
4130
- private handlePaymentError;
4267
+ initialValue?: R;
4268
+ onComplete?: (value: R) => unknown;
4269
+ onError?: (error: unknown) => unknown;
4270
+ }
4271
+ declare class Task<const T extends ReadonlyArray<unknown> = ReadonlyArray<unknown>, const R = unknown> {
4272
+ private _previousArgs?;
4273
+ private _task;
4274
+ private _argsFn?;
4275
+ private _argsEqual;
4276
+ private _callId;
4277
+ private _host;
4278
+ private _value?;
4279
+ private _error?;
4280
+ private _abortController?;
4281
+ private _onComplete?;
4282
+ private _onError?;
4283
+ private _status;
4131
4284
  /**
4132
- * Handle closing error message
4285
+ * Determines if the task is run automatically when arguments change after a
4286
+ * host update. Default to `true`.
4287
+ *
4288
+ * @see {@link TaskConfig.autoRun} for more information.
4133
4289
  */
4134
- private handleCloseError;
4290
+ autoRun: boolean | "afterUpdate";
4135
4291
  /**
4136
- * Get payment method display name for the given ID
4292
+ * A Promise that resolve when the current task run is complete.
4293
+ *
4294
+ * If a new task run is started while a previous run is pending, the Promise
4295
+ * is kept and only resolved when the new run is completed.
4137
4296
  */
4138
- private getPaymentMethodName;
4297
+ get taskComplete(): Promise<R>;
4298
+ private _resolveTaskComplete?;
4299
+ private _rejectTaskComplete?;
4300
+ private _taskComplete?;
4301
+ constructor(host: ReactiveControllerHost$1, task: TaskConfig<T, R>);
4302
+ constructor(host: ReactiveControllerHost$1, task: TaskFunction<T, R>, args?: ArgsFunction<T>);
4303
+ hostUpdate(): void;
4304
+ hostUpdated(): void;
4305
+ private _getArgs;
4139
4306
  /**
4140
- * Render loading overlay with spinner when isUpdating is true
4307
+ * Determines if the task should run when it's triggered because of a
4308
+ * host update, and runs the task if it should.
4309
+ *
4310
+ * A task should run when its arguments change from the previous run, based on
4311
+ * the args equality function.
4312
+ *
4313
+ * This method is side-effectful: it stores the new args as the previous args.
4141
4314
  */
4142
- private renderLoadingOverlay;
4315
+ private _performTask;
4143
4316
  /**
4144
- * Render delete confirmation content
4317
+ * Runs a task manually.
4318
+ *
4319
+ * This can be useful for running tasks in response to events as opposed to
4320
+ * automatically running when host element state changes.
4321
+ *
4322
+ * @param args an optional set of arguments to use for this task run. If args
4323
+ * is not given, the args function is called to get the arguments for
4324
+ * this run.
4145
4325
  */
4146
- private renderDeleteConfirmation;
4326
+ run(args?: T): Promise<void>;
4147
4327
  /**
4148
- * Render a payment method item with appropriate animations
4328
+ * Aborts the currently pending task run by aborting the AbortSignal
4329
+ * passed to the task function.
4330
+ *
4331
+ * Aborting a task does nothing if the task is not running: ie, in the
4332
+ * complete, error, or initial states.
4333
+ *
4334
+ * Aborting a task does not automatically cancel the task function. The task
4335
+ * function must be written to accept the AbortSignal and either forward it
4336
+ * to other APIs like `fetch()`, or handle cancellation manually by using
4337
+ * [`signal.throwIfAborted()`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted}
4338
+ * or the
4339
+ * [`abort`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort_event}
4340
+ * event.
4341
+ *
4342
+ * @param reason The reason for aborting. Passed to
4343
+ * `AbortController.abort()`.
4149
4344
  */
4150
- private renderPaymentMethodItem;
4345
+ abort(reason?: unknown): void;
4151
4346
  /**
4152
- * Render the payment method list with submit button
4347
+ * The result of the previous task run, if it resolved.
4348
+ *
4349
+ * Is `undefined` if the task has not run yet, or if the previous run errored.
4153
4350
  */
4154
- private renderPaymentMethodList;
4351
+ get value(): R | undefined;
4155
4352
  /**
4156
- * Main render method
4353
+ * The error from the previous task run, if it rejected.
4354
+ *
4355
+ * Is `undefined` if the task has not run yet, or if the previous run
4356
+ * completed successfully.
4157
4357
  */
4158
- render(): typeof nothing | TemplateResult<1>;
4358
+ get error(): unknown;
4359
+ get status(): TaskStatus;
4360
+ render<T extends StatusRenderer<R>>(renderer: T): MaybeReturnType<T["initial"]> | MaybeReturnType<T["pending"]> | MaybeReturnType<T["complete"]> | MaybeReturnType<T["error"]>;
4159
4361
  }
4362
+ export type MaybeReturnType<F> = F extends (...args: never[]) => infer R ? R : undefined;
4160
4363
  /**
4161
- * VaultPaymentMethodItemComponent - displays a single payment method
4162
- * Uses the VaultManagerController for display formatting
4163
- * Now supports selection via the simplified button checked state
4164
- * Enhanced with smooth transitions between edit and payment modes
4165
- * Always renders the primer-button for consistent UI and improved accessibility
4364
+ * Available input types for hosted inputs.
4166
4365
  */
4167
- declare class VaultPaymentMethodItemComponent extends LitElement {
4168
- static styles: CSSResult[];
4366
+ export type HostedInputType = "cardNumber" | "cvv" | "expire" | "cardholderName";
4367
+ /**
4368
+ * Configuration for the hosted input controller.
4369
+ */
4370
+ export interface HostedInputConfig {
4371
+ /** Differentiates the input type. */
4372
+ type: HostedInputType;
4373
+ /** Selector for the container element where the input should be rendered. */
4374
+ containerSelector: string;
4169
4375
  /**
4170
- * Strongly typed event declarations
4376
+ * Optional callback for handling input events (e.g. for CardFormName).
4171
4377
  */
4172
- addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4173
- removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4378
+ onInput?: (value: string) => void;
4379
+ }
4380
+ /**
4381
+ * Possible input source types that can be returned by getHostedInput
4382
+ */
4383
+ export type InputSource = IHeadlessHostedInput | "cardholderName" | undefined;
4384
+ declare class HostedInputController<T extends HostedInputHost> implements ReactiveController {
4385
+ private _isFocused;
4386
+ private _meta;
4387
+ private _hostedInput;
4388
+ private _standardInput;
4389
+ private readonly host;
4390
+ private readonly config;
4174
4391
  /**
4175
- * Consume the vault manager context
4392
+ * Task to set up the hosted input.
4176
4393
  */
4177
- vaultManagerContext: VaultManagerContext;
4178
- vaultItemContext: VaultItemContext;
4179
- headlessUtils: HeadlessUnitilsContext;
4394
+ readonly setupTask: Task<[
4395
+ InputSource
4396
+ ], boolean | typeof initialState>;
4397
+ constructor(host: T, config: HostedInputConfig);
4180
4398
  /**
4181
- * The payment method to display
4399
+ * Focuses the input, whether it's a hosted input or standard input
4182
4400
  */
4183
- paymentMethod: VaultedPaymentMethod | null;
4401
+ focusInput(): void;
4184
4402
  /**
4185
- * Whether the component is in edit mode
4403
+ * Returns the hosted input from the card form context based on the type.
4404
+ * For 'cardholderName', no hosted input is provided so we return a fallback indicator.
4186
4405
  */
4187
- isEditMode: boolean;
4188
- private _getAssetsTask;
4406
+ private getHostedInput;
4189
4407
  /**
4190
- * Check if this payment method is currently selected in the context
4408
+ * Sets up the hosted input.
4409
+ * If a hosted input is provided, it renders it into the target container.
4410
+ * Otherwise (e.g. for cardholderName), it creates a standard input element.
4191
4411
  */
4192
- private isSelected;
4412
+ private setupHostedInput;
4193
4413
  /**
4194
- * Handle when the button is clicked
4195
- * This is used to select the payment method and deselect others
4414
+ * Gets the target container element from the host's render root
4196
4415
  */
4197
- private handleClick;
4416
+ private getTargetContainer;
4198
4417
  /**
4199
- * Dispatch delete event
4418
+ * Sets up a standard input element for non-hosted input types
4200
4419
  */
4201
- private handleDeleteClick;
4420
+ private setupStandardInput;
4202
4421
  /**
4203
- * Builds the common content template shared between modes
4422
+ * Sets up event listeners for standard input elements
4204
4423
  */
4205
- private renderPaymentMethodContent;
4424
+ private setupInputEventListeners;
4206
4425
  /**
4207
- * Render method
4426
+ * Sets up a hosted iframe input for iframe-based input types
4208
4427
  */
4209
- render(): symbol | TemplateResult<1> | undefined;
4210
- }
4211
- declare global {
4212
- interface HTMLElementTagNameMap {
4213
- "primer-vault-payment-method-item": VaultPaymentMethodItemComponent;
4214
- }
4428
+ private setupHostedIframeInput;
4429
+ /** Exposes the current focus state. */
4430
+ get isFocused(): boolean;
4431
+ /** Exposes the current metadata state. */
4432
+ get meta(): InputMetadata;
4433
+ hostConnected(): void;
4434
+ hostDisconnected(): void;
4215
4435
  }
4216
4436
  /**
4217
- * VaultManagerHeaderComponent - displays the header for the vault manager
4437
+ * Translation configuration object
4218
4438
  */
4219
- declare class VaultManagerHeaderComponent extends LitElement {
4220
- static styles: CSSResult[];
4221
- /**
4222
- * Strongly typed event declarations
4223
- */
4224
- addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4225
- removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4226
- /**
4227
- * Whether we're in edit mode
4228
- */
4229
- isEditMode: boolean;
4439
+ export type TranslationConfig = {
4440
+ id: string;
4441
+ defaultMessage: string;
4442
+ };
4443
+ /**
4444
+ * Configuration for abstract input component
4445
+ */
4446
+ export interface InputComponentConfig {
4447
+ /** The component's hosted input type */
4448
+ inputType: HostedInputType;
4449
+ /** ID selector for the container where the input will be rendered */
4450
+ containerSelector: string;
4451
+ /** Error name to match in the card form context */
4452
+ errorName: string;
4453
+ /** Translation keys for default values */
4454
+ translations: {
4455
+ label: TranslationConfig | string;
4456
+ placeholder?: TranslationConfig | string;
4457
+ ariaLabel?: TranslationConfig | string;
4458
+ };
4459
+ /** Optional input handler for non-hosted inputs */
4460
+ onInput?: (value: string) => void;
4461
+ }
4462
+ declare abstract class AbstractCardInputComponent extends LitElement implements HostedInputHost {
4463
+ cardFormContext: CardFormContext | null;
4464
+ computedStyles: CSSStyleDeclaration | null;
4465
+ /** Tracks which properties were explicitly set by the user */
4466
+ protected readonly _userAssignedProps: Set<string>;
4467
+ /** Internal storage for property values */
4468
+ protected _internalLabel: string;
4469
+ protected _internalPlaceholder: string;
4470
+ protected _internalAriaLabel: string;
4471
+ /** Configuration for this input component */
4472
+ protected abstract readonly config: InputComponentConfig;
4473
+ /** Hosted input controller */
4474
+ protected readonly hostedInputController: HostedInputController<HostedInputHost>;
4230
4475
  /**
4231
- * Whether we have payment methods to edit
4476
+ * Gets a translated or static string value from the translation config
4232
4477
  */
4233
- hasPaymentMethods: boolean;
4478
+ private getTranslatedValue;
4234
4479
  /**
4235
- * Toggle edit mode
4480
+ * The input label text.
4481
+ * Falls back to localized default if not explicitly set.
4236
4482
  */
4237
- private toggleEditMode;
4483
+ get label(): string;
4484
+ set label(value: string);
4238
4485
  /**
4239
- * Render method
4486
+ * The input placeholder text.
4487
+ * Falls back to localized default if not explicitly set.
4488
+ * When explicitly set to empty string, no placeholder will be displayed.
4240
4489
  */
4241
- protected render(): TemplateResult<1>;
4242
- }
4243
- declare global {
4244
- interface HTMLElementTagNameMap {
4245
- "primer-vault-manager-header": VaultManagerHeaderComponent;
4246
- }
4247
- }
4248
- /**
4249
- * VaultDeleteConfirmationComponent - displays confirmation UI for deleting a payment method
4250
- */
4251
- declare class VaultDeleteConfirmationComponent extends LitElement {
4252
- static styles: CSSResult[];
4490
+ get placeholder(): string;
4491
+ set placeholder(value: string);
4253
4492
  /**
4254
- * Strongly typed event declarations
4493
+ * The input aria-label attribute.
4494
+ * Falls back to localized default if not explicitly set.
4255
4495
  */
4256
- addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4257
- removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4496
+ get ariaLabel(): string;
4497
+ set ariaLabel(value: string);
4498
+ constructor();
4258
4499
  /**
4259
- * Whether a delete operation is in progress
4500
+ * Initialize the controller after the component has been constructed
4501
+ * and the config is available
4260
4502
  */
4261
- isDeleting: boolean;
4503
+ protected childUpdated(): void;
4262
4504
  /**
4263
- * The ID of the payment method being deleted
4505
+ * Handler for wrapper-click event from InputWrapper component
4506
+ * This is still needed for hosted iframe inputs
4264
4507
  */
4265
- paymentMethodId: string;
4508
+ private handleWrapperClick;
4266
4509
  /**
4267
- * Payment method name to display in confirmation
4510
+ * Get the error code from the hosted input controller when the input is submitted or touched
4511
+ *
4512
+ * Can be used instead of the error returned by the `validate()` method since internally `primer-sdk-web`
4513
+ * uses the same logic to compute the error code
4514
+ *
4515
+ * @returns {string|null}
4268
4516
  */
4269
- paymentMethodName: string;
4517
+ getError(): string | null;
4270
4518
  /**
4271
- * Consume the vault manager context to access payment method info
4519
+ * Common rendering logic for all card input components
4272
4520
  */
4273
- vaultManager: VaultManagerContext;
4521
+ protected renderInput(): typeof nothing | TemplateResult<1>;
4522
+ }
4523
+ /**
4524
+ * Card number input component with dynamic card network detection and selection
4525
+ */
4526
+ declare class InputCardNumberComponent extends AbstractCardInputComponent {
4527
+ static styles: CSSResult[];
4274
4528
  /**
4275
- * Handle confirm click
4529
+ * Configuration for this input component
4276
4530
  */
4277
- private handleConfirmClick;
4531
+ protected readonly config: InputComponentConfig;
4532
+ constructor();
4278
4533
  /**
4279
- * Handle cancel click
4534
+ * Handle network selection from the network selector component
4280
4535
  */
4281
- private handleCancelClick;
4536
+ private handleNetworkSelected;
4282
4537
  /**
4283
- * Render method
4538
+ * Override the renderInput method to include the network selector
4284
4539
  */
4285
- protected render(): TemplateResult<1>;
4540
+ protected renderInput(): typeof nothing | TemplateResult<1>;
4541
+ render(): typeof nothing | TemplateResult<1>;
4286
4542
  }
4287
4543
  declare global {
4288
4544
  interface HTMLElementTagNameMap {
4289
- "primer-vault-delete-confirmation": VaultDeleteConfirmationComponent;
4545
+ "primer-input-card-number": InputCardNumberComponent;
4290
4546
  }
4291
4547
  }
4292
- /**
4293
- * VaultEmptyStateComponent - displays when no payment methods are available
4294
- */
4295
- declare class VaultEmptyStateComponent extends LitElement {
4548
+ declare class InputCvvComponent extends AbstractCardInputComponent {
4296
4549
  static styles: CSSResult[];
4297
- /**
4298
- * Render method
4299
- */
4300
- protected render(): TemplateResult<1>;
4550
+ protected readonly config: InputComponentConfig;
4551
+ constructor();
4552
+ render(): typeof nothing | TemplateResult<1>;
4301
4553
  }
4302
4554
  declare global {
4303
4555
  interface HTMLElementTagNameMap {
4304
- "primer-vault-empty-state": VaultEmptyStateComponent;
4556
+ "primer-input-cvv": InputCvvComponent;
4305
4557
  }
4306
4558
  }
4307
- /**
4308
- * VaultErrorMessageComponent - displays error messages with improved visuals
4309
- */
4310
- declare class VaultErrorMessageComponent extends LitElement {
4559
+ declare class InputCardExpiryComponent extends AbstractCardInputComponent {
4311
4560
  static styles: CSSResult[];
4312
- /**
4313
- * Strongly typed event declarations
4314
- */
4315
- addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4316
- removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
4317
- /**
4318
- * The error message to display
4319
- */
4320
- errorMessage: string;
4321
- /**
4322
- * Handle dismiss click
4323
- */
4324
- private handleDismiss;
4325
- /**
4326
- * Render method
4327
- */
4328
- protected render(): TemplateResult<1>;
4561
+ protected readonly config: InputComponentConfig;
4562
+ constructor();
4563
+ render(): typeof nothing | TemplateResult<1>;
4329
4564
  }
4330
4565
  declare global {
4331
4566
  interface HTMLElementTagNameMap {
4332
- "primer-vault-error-message": VaultErrorMessageComponent;
4567
+ "primer-input-card-expiry": InputCardExpiryComponent;
4568
+ }
4569
+ }
4570
+ declare class InputCardHolderNameComponent extends AbstractCardInputComponent {
4571
+ static styles: CSSResult[];
4572
+ protected readonly config: InputComponentConfig;
4573
+ constructor();
4574
+ private handleInput;
4575
+ render(): typeof nothing | TemplateResult<1>;
4576
+ }
4577
+ declare global {
4578
+ interface HTMLElementTagNameMap {
4579
+ "primer-input-card-holder-name": InputCardHolderNameComponent;
4333
4580
  }
4334
4581
  }
4335
4582
  /**
4336
- * A submit button component for vault payment flows.
4583
+ * A form submit button component for card forms.
4337
4584
  * Provides a consistent submit button with translation support.
4338
- * Integrates with the vault manager context to handle payment submission.
4339
4585
  */
4340
- declare class VaultPaymentSubmitComponent extends LitElement {
4586
+ declare class CardFormSubmitComponent extends LitElement {
4341
4587
  static styles: CSSResult[];
4342
4588
  private readonly _userAssignedProps;
4343
4589
  private _internalButtonText;
@@ -4348,10 +4594,8 @@ declare class VaultPaymentSubmitComponent extends LitElement {
4348
4594
  get buttonText(): string;
4349
4595
  set buttonText(value: string);
4350
4596
  headlessInstance: HeadlessUnitilsContext;
4597
+ clientOptions: ClientOptionsContext;
4351
4598
  sdkState: SdkStateContext;
4352
- vaultItemContext: VaultItemContext;
4353
- vaultManager: VaultManagerContext;
4354
- clientOptions: PrimerCheckoutOptions | null;
4355
4599
  /**
4356
4600
  * The button variant to use.
4357
4601
  * @default "primary"
@@ -4359,74 +4603,120 @@ declare class VaultPaymentSubmitComponent extends LitElement {
4359
4603
  variant: string;
4360
4604
  /**
4361
4605
  * Whether the button is disabled.
4362
- * This property allows external disabling of the button
4363
- * regardless of the context state.
4364
4606
  * @default false
4365
4607
  */
4366
4608
  disabled: boolean;
4367
- /**
4368
- * Handle button click event.
4369
- * Prevents default form submission and triggers the vault payment flow.
4370
- */
4371
4609
  private handleClick;
4372
- /**
4373
- * Computed property to determine if the button should be disabled
4374
- */
4375
- private get isButtonDisabled();
4376
4610
  render(): TemplateResult<1>;
4377
4611
  }
4378
4612
  declare global {
4379
4613
  interface HTMLElementTagNameMap {
4380
- "primer-vault-payment-submit": VaultPaymentSubmitComponent;
4614
+ "primer-card-form-submit": CardFormSubmitComponent;
4381
4615
  }
4382
4616
  }
4383
4617
  /**
4384
- * CVV Input component for vault payment methods
4385
- * Renders a secure iframe for CVV input when required by the selected payment method
4386
- * Uses dedicated CVV context to minimize re-renders
4618
+ * Component for displaying and selecting card networks
4619
+ * Uses context directly rather than properties
4620
+ *
4621
+ * @fires network-selected - Dispatched when a network is selected with the network name as detail
4387
4622
  */
4388
- declare class VaultCvvInputComponent extends LitElement {
4623
+ declare class CardNetworkSelectorComponent extends LitElement {
4389
4624
  static styles: CSSResult[];
4390
4625
  /**
4391
- * Form context for checking form dirty state
4626
+ * Card networks context from provider
4392
4627
  */
4393
- vaultManagerFormContext: VaultManagerContext;
4628
+ cardNetworks: CardNetworksContext;
4629
+ headlessUtils: HeadlessUnitilsContext;
4630
+ private selectedCardNetwork;
4394
4631
  /**
4395
- * CVV-specific context for dedicated CVV handling
4396
- * Separated to minimize re-renders on frequent CVV input changes
4632
+ * Internal state to track if dropdown is open
4397
4633
  */
4398
- vaultManagerCvvContext: VaultItemContext;
4399
- computedStyles: CSSStyleDeclaration | null;
4400
- paymentMethod: PaymentCardVaultedMethod | null;
4401
- private cvvError;
4402
- private cvvInputIsDirty;
4403
- private cvvInputIsBlurred;
4404
- private cvvInput;
4634
+ private isDropdownOpen;
4405
4635
  /**
4406
- * Unique ID for the CVV input container
4636
+ * Index of the currently focused network in the dropdown
4407
4637
  */
4408
- private readonly cvvContainerId;
4409
- private _setupCVVIframe;
4410
- constructor();
4411
- disconnectedCallback(): void;
4638
+ private focusedNetworkIndex;
4412
4639
  /**
4413
- * Update CVV metadata in the context when input changes
4640
+ * Tracks if keyboard navigation is being used
4414
4641
  */
4415
- onCvvInputChange(): void;
4416
- onBlur(): void;
4642
+ private isKeyboardNavigation;
4417
4643
  /**
4418
- * Main render method
4644
+ * Reference to the dropdown button
4419
4645
  */
4420
- protected render(): symbol | TemplateResult<1> | undefined;
4646
+ private buttonRef;
4647
+ /**
4648
+ * Reference to the dropdown container
4649
+ */
4650
+ private dropdownRef;
4651
+ /**
4652
+ * Reference to network option elements
4653
+ */
4654
+ private networkOptionRefs;
4655
+ /**
4656
+ * Toggle the dropdown state
4657
+ */
4658
+ private toggleDropdown;
4659
+ private getNetworkIconUrl;
4660
+ /**
4661
+ * Get selectable networks from context
4662
+ */
4663
+ private getSelectableNetworks;
4664
+ /**
4665
+ * Get detected network from context
4666
+ */
4667
+ private getDetectedNetwork;
4668
+ /**
4669
+ * Get the index of the currently selected network
4670
+ */
4671
+ private getSelectedNetworkIndex;
4672
+ /**
4673
+ * Handle network selection
4674
+ */
4675
+ private selectNetwork;
4676
+ /**
4677
+ * Handle click outside to close dropdown
4678
+ */
4679
+ private handleClickOutside;
4680
+ /**
4681
+ * Handle mouse movement to disable keyboard navigation mode
4682
+ */
4683
+ private handleMouseMove;
4684
+ /**
4685
+ * Handle keydown events for keyboard navigation
4686
+ */
4687
+ private handleKeyDown;
4688
+ /**
4689
+ * Focus the current network option
4690
+ */
4691
+ private focusNetworkOption;
4692
+ /**
4693
+ * Save reference to network option element
4694
+ */
4695
+ private setNetworkOptionRef;
4696
+ /**
4697
+ * Attach event listener to the component for keydown events
4698
+ * and to document for click outside and mousemove
4699
+ */
4700
+ connectedCallback(): void;
4701
+ /**
4702
+ * Handle document-level keydown events, but only when dropdown is open
4703
+ * This allows keyboard navigation to continue working
4704
+ */
4705
+ private handleDocumentKeyDown;
4706
+ /**
4707
+ * Lifecycle: Remove all event listeners when disconnected
4708
+ */
4709
+ disconnectedCallback(): void;
4710
+ render(): TemplateResult<1>;
4421
4711
  }
4422
4712
  declare global {
4423
4713
  interface HTMLElementTagNameMap {
4424
- "primer-vault-cvv-input": VaultCvvInputComponent;
4714
+ "primer-card-network-selector": CardNetworkSelectorComponent;
4425
4715
  }
4426
4716
  }
4427
4717
  declare global {
4428
4718
  interface HTMLElementTagNameMap {
4429
- "primer-vault-manager": VaultManagerComponent;
4719
+ "primer-card-form": CardFormComponent;
4430
4720
  }
4431
4721
  }
4432
4722
  /**
@@ -4446,6 +4736,35 @@ declare global {
4446
4736
  "primer-show-other-payments": ShowOtherPaymentsComponent;
4447
4737
  }
4448
4738
  }
4739
+ /**
4740
+ * Component for rendering native payment buttons (Apple Pay, Google Pay, PayPal)
4741
+ * with proper height calculations based on design system variables.
4742
+ */
4743
+ declare class NativePaymentComponent extends LitElement {
4744
+ static styles: CSSResult[];
4745
+ paymentMethod: InitializedPaymentMethod | undefined;
4746
+ paymentManagers: InitializedManagersMap;
4747
+ computedStyles: CSSStyleDeclaration | null;
4748
+ private _buttonId;
4749
+ private loadManagerTask;
4750
+ constructor();
4751
+ /**
4752
+ * Calculates the button height based on CSS variables
4753
+ * Mirrors the calculation used in the host styles
4754
+ */
4755
+ private calculateButtonHeight;
4756
+ /**
4757
+ * Creates render options with appropriate styles based on payment method type
4758
+ */
4759
+ private createRenderOptions;
4760
+ protected updated(changedProperties: PropertyValues): void;
4761
+ render(): symbol | TemplateResult<1> | undefined;
4762
+ }
4763
+ declare global {
4764
+ interface HTMLElementTagNameMap {
4765
+ "primer-native-payment": NativePaymentComponent;
4766
+ }
4767
+ }
4449
4768
  declare class PrimerCheckoutCompleteComponent extends LitElement {
4450
4769
  render(): TemplateResult<1>;
4451
4770
  }
@@ -4493,16 +4812,28 @@ declare global {
4493
4812
  "primer-error-message-container": ErrorMessageContainerComponent;
4494
4813
  }
4495
4814
  }
4815
+ declare class PrimerMainComponent extends LitElement {
4816
+ static styles: CSSResult[];
4817
+ private hasAssignedContent;
4818
+ /**
4819
+ * Inline slotchange event listener.
4820
+ * Uses assignedNodes with flatten to detect if the slot has any nodes.
4821
+ */
4822
+ private onSlotChange;
4823
+ paymentMethods: PaymentMethodsContext;
4824
+ sdkState: SdkStateContext;
4825
+ render(): TemplateResult<1>;
4826
+ }
4827
+ declare global {
4828
+ interface HTMLElementTagNameMap {
4829
+ "primer-main": PrimerMainComponent;
4830
+ }
4831
+ }
4496
4832
  /**
4497
4833
  * Main function to load the Primer SDK with all required dependencies and styles
4498
4834
  * @returns {Promise<void>} A promise that resolves when loading is complete
4499
4835
  */
4500
4836
  export declare function loadPrimer(): Promise<void>;
4501
- declare global {
4502
- interface HTMLElementTagNameMap {
4503
- "primer-checkout": PrimerCheckoutComponent;
4504
- }
4505
- }
4506
4837
 
4507
4838
  export {
4508
4839
  AchPaymentComponent as AchPayment,