@primer-io/primer-js 1.0.3 → 1.0.5

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.
@@ -91,8 +91,6 @@ This is used to control the CSS-only loader visibility */
91
91
  /** */
92
92
  vaultManagerController?: VaultManagerController;
93
93
  /** */
94
- cardNetworkController?: CardNetworkController;
95
- /** */
96
94
  achPaymentEventsController?: AchPaymentEventsController;
97
95
  /** */
98
96
  headlessSdkController?: HeadlessSdkController;
@@ -419,6 +417,8 @@ export type PortalDialogComponentProps = {
419
417
  /** */
420
418
  showCloseButton?: boolean;
421
419
  /** */
420
+ darkMode?: boolean;
421
+ /** */
422
422
  onOpen?: () => void | undefined;
423
423
  /** */
424
424
  onContentRendered?: () => void | undefined;
@@ -461,6 +461,8 @@ export type RedirectPaymentComponentProps = {
461
461
  sdkState?: SdkStateContextType;
462
462
  /** */
463
463
  headlessUtils?: HeadlessUtilsContextType;
464
+ /** */
465
+ clientOptions?: ClientOptionsContextType | undefined;
464
466
  };
465
467
 
466
468
  export type ShowOtherPaymentsComponentProps = {
@@ -1325,6 +1325,7 @@ export interface HeadlessUniversalCheckoutOptions {
1325
1325
  }) => void;
1326
1326
  onPaymentCreationStart?: () => void;
1327
1327
  onPaymentMethodAction?: (data: "PAYMENT_METHOD_SELECTED" | "PAYMENT_METHOD_UNSELECTED", handler: {
1328
+ payment?: Payment;
1328
1329
  paymentMethodType: PaymentMethodType | null;
1329
1330
  }) => void;
1330
1331
  onClientSessionUpdate?: (clientSession: ClientSession) => void;
@@ -1545,6 +1546,27 @@ export interface PrimerCheckoutOptions {
1545
1546
  requireShippingMethod?: boolean;
1546
1547
  };
1547
1548
  };
1549
+ /**
1550
+ * Options for using gift cards as a payment method
1551
+ */
1552
+ giftCard?: {
1553
+ /**
1554
+ * The source URL of the button logo.
1555
+ */
1556
+ logoSrc: string;
1557
+ /**
1558
+ * The background color of the button.
1559
+ */
1560
+ background: string;
1561
+ /**
1562
+ * An alternative text for the button logo.
1563
+ */
1564
+ logoAlt?: string;
1565
+ /**
1566
+ * The text to display on the button.
1567
+ */
1568
+ text?: string;
1569
+ };
1548
1570
  /**
1549
1571
  * Configuration options for Google Pay button and payment flow.
1550
1572
  *
@@ -1927,37 +1949,14 @@ export interface AssetsConfig {
1927
1949
  name: string;
1928
1950
  iconUrl: string;
1929
1951
  }
1930
- export type ReducerCallbacks<State, _Action extends {
1931
- type: string;
1932
- }> = {
1933
- [K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
1952
+ export type AnalyticsContextType = AnalyticsUtils | null;
1953
+ export type EventsContextType = PrimerEventsController | null;
1954
+ export type HeadlessUtilsContextType = HeadlessSDKUtilities | null;
1955
+ export type ConfigurationContextType = ClientConfiguration | null;
1956
+ export type KlarnaCategoriesContextType = {
1957
+ categories: KlarnaPaymentMethodCategory[];
1958
+ isLoading: boolean;
1934
1959
  };
1935
- export type TypedReducer<State, Action extends {
1936
- type: string;
1937
- }, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
1938
- declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
1939
- type: string;
1940
- }, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
1941
- protected host: Host;
1942
- protected stateHandler: (state: State) => void;
1943
- private _dispatcher;
1944
- constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
1945
- get currentState(): Readonly<State>;
1946
- protected dispatch(action: Action): void;
1947
- protected setCallbacks(callbacks: Partial<Callbacks>): void;
1948
- hostConnected(): void;
1949
- hostDisconnected(): void;
1950
- }
1951
- declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
1952
- protected host: Host;
1953
- private _controllers;
1954
- constructor(host: Host);
1955
- addController<State, Action extends {
1956
- type: string;
1957
- }, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
1958
- hostConnected(): void;
1959
- hostDisconnected(): void;
1960
- }
1961
1960
  /**
1962
1961
  * Options for initializing the Vault Manager
1963
1962
  */
@@ -1996,6 +1995,158 @@ export interface VaultManagerItemState {
1996
1995
  selectedVaultedPaymentMethod: VaultedPaymentMethod | null;
1997
1996
  setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
1998
1997
  }
1998
+ /**
1999
+ * Context for core vault manager functionality
2000
+ * Contains properties that don't change frequently and relate to vault functionality
2001
+ */
2002
+ export type VaultManagerContextType = VaultManagerState | null;
2003
+ /**
2004
+ * Context for vault manager CVV-specific state
2005
+ * Contains properties specifically related to CVV input functionality
2006
+ * Further separated to minimize re-renders related to frequently changing CVV input state
2007
+ */
2008
+ export type VaultItemContextType = VaultManagerItemState | null;
2009
+ declare class SDKContextController implements ReactiveController {
2010
+ host: PrimerCheckoutType;
2011
+ private sdkStateProvider;
2012
+ private paymentMethodsProvider;
2013
+ private paymentManagerProvider;
2014
+ private cardNetworksContext;
2015
+ private vaultManagerProvider;
2016
+ private vaultManagerCvvProvider;
2017
+ private clientOptionsContext;
2018
+ private headlessUtilsProvider;
2019
+ private configurationProvider;
2020
+ private klarnaCategoriesProvider;
2021
+ private computedStylesProvider;
2022
+ private analyticsProvider;
2023
+ private eventsProvider;
2024
+ constructor(host: PrimerCheckoutType);
2025
+ hostConnected(): void;
2026
+ /**
2027
+ * Updates the SDK state context.
2028
+ * @param value The new SDK state.
2029
+ */
2030
+ setSdkState(value: SdkStateContextType): void;
2031
+ /**
2032
+ * Updates the payment methods context.
2033
+ * @param value The new payment methods data.
2034
+ */
2035
+ setPaymentMethods(value: InitializedPaymentMethod[]): void;
2036
+ /**
2037
+ * Updates the payment manager context.
2038
+ * @param value The new payment manager mapping.
2039
+ */
2040
+ setPaymentManagers(value: InitializedManagersMap): void;
2041
+ setCardNetworks(value: CardNetworksContextType): void;
2042
+ setCardNetworksLoadingFalse(): void;
2043
+ setVaultManager(value: VaultManagerContextType): void;
2044
+ setKlarnaCategories(value: KlarnaCategoriesContextType): void;
2045
+ setClientOptions(value: PrimerCheckoutOptions | null): void;
2046
+ setHeadlessUtils(value: HeadlessUtilsContextType): void;
2047
+ setConfiguration(value: ConfigurationContextType): void;
2048
+ setAnalyticsUtils(value: AnalyticsContextType): void;
2049
+ getAnalyticsUtils(): AnalyticsContextType | undefined;
2050
+ setComputedStyles(value: CSSStyleDeclaration): void;
2051
+ setVaultManagerCvv(value: VaultItemContextType): void;
2052
+ /**
2053
+ * Updates the events context.
2054
+ * @param value The new events controller.
2055
+ */
2056
+ setEventsController(value: EventsContextType): void;
2057
+ }
2058
+ export type ReducerCallbacks<State, _Action extends {
2059
+ type: string;
2060
+ }> = {
2061
+ [K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
2062
+ };
2063
+ export type TypedReducer<State, Action extends {
2064
+ type: string;
2065
+ }, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
2066
+ declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
2067
+ type: string;
2068
+ }, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
2069
+ protected host: Host;
2070
+ protected stateHandler: (state: State) => void;
2071
+ private _dispatcher;
2072
+ constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
2073
+ get currentState(): Readonly<State>;
2074
+ protected dispatch(action: Action): void;
2075
+ protected setCallbacks(callbacks: Partial<Callbacks>): void;
2076
+ hostConnected(): void;
2077
+ hostDisconnected(): void;
2078
+ }
2079
+ declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
2080
+ protected host: Host;
2081
+ private _controllers;
2082
+ constructor(host: Host);
2083
+ addController<State, Action extends {
2084
+ type: string;
2085
+ }, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
2086
+ hostConnected(): void;
2087
+ hostDisconnected(): void;
2088
+ }
2089
+ export type SdkStateAction = {
2090
+ type: "SET_LOADING";
2091
+ payload: boolean;
2092
+ } | {
2093
+ type: "SET_PROCESSING";
2094
+ payload: boolean;
2095
+ } | {
2096
+ type: "SET_SUCCESS";
2097
+ payload: boolean;
2098
+ } | {
2099
+ type: "SET_PRIMER_JS_ERROR";
2100
+ payload: Error | null;
2101
+ } | {
2102
+ type: "SET_PAYMENT_FAILURE";
2103
+ payload: {
2104
+ code: string;
2105
+ message: string;
2106
+ diagnosticsId?: string | null;
2107
+ data?: Record<string, unknown>;
2108
+ } | null;
2109
+ } | {
2110
+ type: "COMPLETE_PROCESSING";
2111
+ } | {
2112
+ type: "RESET";
2113
+ };
2114
+ declare class SdkStateController extends ReactiveStateController<PrimerCheckoutType, SdkState, SdkStateAction, null> {
2115
+ constructor(host: PrimerCheckoutType);
2116
+ setLoading(loading: boolean): void;
2117
+ setProcessing(processing: boolean): void;
2118
+ setSuccess(success: boolean): void;
2119
+ setPrimerJsError(error: Error | null): void;
2120
+ setPaymentFailure(failure: {
2121
+ code: string;
2122
+ message: string;
2123
+ diagnosticsId?: string | null;
2124
+ data?: Record<string, unknown>;
2125
+ } | null): void;
2126
+ completeProcessing(): void;
2127
+ reset(): void;
2128
+ startLoading(): void;
2129
+ completeLoading(): void;
2130
+ startProcessing(): void;
2131
+ stopProcessing(): void;
2132
+ resetError(): void;
2133
+ forceCompleteLoading(): void;
2134
+ }
2135
+ /**
2136
+ * PrimerCheckoutType defines the interface for the primer-checkout component implementation.
2137
+ * This includes both the properties and controllers needed for internal functionality.
2138
+ */
2139
+ export interface PrimerCheckoutType extends ReactiveControllerHost, LitElement {
2140
+ requestUpdate: ReactiveControllerHost["requestUpdate"];
2141
+ customStyles: string;
2142
+ clientToken: string;
2143
+ options: PrimerCheckoutOptions;
2144
+ sdkContextController: SDKContextController;
2145
+ sdkStateController: SdkStateController;
2146
+ primerEventsController: PrimerEventsController;
2147
+ vaultManagerController: VaultManagerController;
2148
+ primerJS?: PrimerJS;
2149
+ }
1999
2150
  declare class VaultManagerController extends CompositeStateController<PrimerCheckoutType> {
2000
2151
  private coreController;
2001
2152
  private itemController;
@@ -2441,6 +2592,7 @@ export interface PrimerEvents {
2441
2592
  timestamp: number;
2442
2593
  }>;
2443
2594
  "primer:payment-cancel": CustomEvent<{
2595
+ payment?: PaymentSummary;
2444
2596
  paymentMethodType: PaymentMethodType | null;
2445
2597
  timestamp: number;
2446
2598
  }>;
@@ -2480,6 +2632,7 @@ declare class PrimerEventsController implements ReactiveController {
2480
2632
  dispatchFormSubmitErrors(errors: InputValidationError[]): void;
2481
2633
  dispatchPaymentCancel(data: {
2482
2634
  paymentMethodType: PaymentMethodType | null;
2635
+ payment?: Payment;
2483
2636
  }): void;
2484
2637
  /**
2485
2638
  * Handle external card submit events and forward them through the event system.
@@ -2564,157 +2717,6 @@ declare class PrimerEventsController implements ReactiveController {
2564
2717
  */
2565
2718
  dispatchShowOtherPaymentsToggled(expanded: boolean): void;
2566
2719
  }
2567
- export type AnalyticsContextType = AnalyticsUtils | null;
2568
- export type EventsContextType = PrimerEventsController | null;
2569
- export type HeadlessUtilsContextType = HeadlessSDKUtilities | null;
2570
- export type ConfigurationContextType = ClientConfiguration | null;
2571
- export type KlarnaCategoriesContextType = {
2572
- categories: KlarnaPaymentMethodCategory[];
2573
- isLoading: boolean;
2574
- };
2575
- /**
2576
- * Context for core vault manager functionality
2577
- * Contains properties that don't change frequently and relate to vault functionality
2578
- */
2579
- export type VaultManagerContextType = VaultManagerState | null;
2580
- /**
2581
- * Context for vault manager CVV-specific state
2582
- * Contains properties specifically related to CVV input functionality
2583
- * Further separated to minimize re-renders related to frequently changing CVV input state
2584
- */
2585
- export type VaultItemContextType = VaultManagerItemState | null;
2586
- declare class SDKContextController implements ReactiveController {
2587
- host: PrimerCheckoutType;
2588
- private sdkStateProvider;
2589
- private paymentMethodsProvider;
2590
- private paymentManagerProvider;
2591
- private cardNetworksContext;
2592
- private vaultManagerProvider;
2593
- private vaultManagerCvvProvider;
2594
- private clientOptionsContext;
2595
- private headlessUtilsProvider;
2596
- private configurationProvider;
2597
- private klarnaCategoriesProvider;
2598
- private computedStylesProvider;
2599
- private analyticsProvider;
2600
- private eventsProvider;
2601
- constructor(host: PrimerCheckoutType);
2602
- hostConnected(): void;
2603
- /**
2604
- * Updates the SDK state context.
2605
- * @param value The new SDK state.
2606
- */
2607
- setSdkState(value: SdkStateContextType): void;
2608
- /**
2609
- * Updates the payment methods context.
2610
- * @param value The new payment methods data.
2611
- */
2612
- setPaymentMethods(value: InitializedPaymentMethod[]): void;
2613
- /**
2614
- * Updates the payment manager context.
2615
- * @param value The new payment manager mapping.
2616
- */
2617
- setPaymentManagers(value: InitializedManagersMap): void;
2618
- setCardNetworks(value: CardNetworksContextType): void;
2619
- setVaultManager(value: VaultManagerContextType): void;
2620
- setKlarnaCategories(value: KlarnaCategoriesContextType): void;
2621
- setClientOptions(value: PrimerCheckoutOptions | null): void;
2622
- setHeadlessUtils(value: HeadlessUtilsContextType): void;
2623
- setConfiguration(value: ConfigurationContextType): void;
2624
- setAnalyticsUtils(value: AnalyticsContextType): void;
2625
- getAnalyticsUtils(): AnalyticsContextType | undefined;
2626
- setComputedStyles(value: CSSStyleDeclaration): void;
2627
- setVaultManagerCvv(value: VaultItemContextType): void;
2628
- /**
2629
- * Updates the events context.
2630
- * @param value The new events controller.
2631
- */
2632
- setEventsController(value: EventsContextType): void;
2633
- }
2634
- export type SdkStateAction = {
2635
- type: "SET_LOADING";
2636
- payload: boolean;
2637
- } | {
2638
- type: "SET_PROCESSING";
2639
- payload: boolean;
2640
- } | {
2641
- type: "SET_SUCCESS";
2642
- payload: boolean;
2643
- } | {
2644
- type: "SET_PRIMER_JS_ERROR";
2645
- payload: Error | null;
2646
- } | {
2647
- type: "SET_PAYMENT_FAILURE";
2648
- payload: {
2649
- code: string;
2650
- message: string;
2651
- diagnosticsId?: string | null;
2652
- data?: Record<string, unknown>;
2653
- } | null;
2654
- } | {
2655
- type: "COMPLETE_PROCESSING";
2656
- } | {
2657
- type: "RESET";
2658
- };
2659
- declare class SdkStateController extends ReactiveStateController<PrimerCheckoutType, SdkState, SdkStateAction, null> {
2660
- constructor(host: PrimerCheckoutType);
2661
- setLoading(loading: boolean): void;
2662
- setProcessing(processing: boolean): void;
2663
- setSuccess(success: boolean): void;
2664
- setPrimerJsError(error: Error | null): void;
2665
- setPaymentFailure(failure: {
2666
- code: string;
2667
- message: string;
2668
- diagnosticsId?: string | null;
2669
- data?: Record<string, unknown>;
2670
- } | null): void;
2671
- completeProcessing(): void;
2672
- reset(): void;
2673
- startLoading(): void;
2674
- completeLoading(): void;
2675
- startProcessing(): void;
2676
- stopProcessing(): void;
2677
- resetError(): void;
2678
- forceCompleteLoading(): void;
2679
- }
2680
- /**
2681
- * PrimerCheckoutType defines the interface for the primer-checkout component implementation.
2682
- * This includes both the properties and controllers needed for internal functionality.
2683
- */
2684
- export interface PrimerCheckoutType extends ReactiveControllerHost, LitElement {
2685
- requestUpdate: ReactiveControllerHost["requestUpdate"];
2686
- customStyles: string;
2687
- clientToken: string;
2688
- options: PrimerCheckoutOptions;
2689
- sdkContextController: SDKContextController;
2690
- sdkStateController: SdkStateController;
2691
- primerEventsController: PrimerEventsController;
2692
- vaultManagerController: VaultManagerController;
2693
- cardNetworkController: CardNetworkController;
2694
- primerJS?: PrimerJS;
2695
- }
2696
- declare class CardNetworkController implements ReactiveController {
2697
- private host;
2698
- constructor(host: PrimerCheckoutType);
2699
- hostConnected(): void;
2700
- /**
2701
- * Sets the card networks to loading state
2702
- */
2703
- setCardNetworksLoading(): void;
2704
- /**
2705
- * Updates card networks state and dispatches events
2706
- *
2707
- * @param cardNetworks - The new card networks context
2708
- */
2709
- private updateCardNetworksState;
2710
- /**
2711
- * Processes a card network change event
2712
- *
2713
- * @param event - The card network change event
2714
- */
2715
- processCardNetworkChangeEvent(event: CardNetworkChangeEvent): void;
2716
- processBinDataAvailableEvent(event: BinDataAvailableEvent): void;
2717
- }
2718
2720
  declare class StyleProcessingController implements ReactiveController {
2719
2721
  host: ReactiveControllerHost & LitElement;
2720
2722
  private static cssVarCache;
@@ -2863,6 +2865,12 @@ declare class HeadlessSdkController implements ReactiveController {
2863
2865
  type: PaymentMethodType;
2864
2866
  manager: IRedirectPaymentMethodManager;
2865
2867
  } | null>;
2868
+ /**
2869
+ * Updates card networks state and dispatches events
2870
+ *
2871
+ * @param cardNetworks - The new card networks context
2872
+ */
2873
+ private updateCardNetworksState;
2866
2874
  }
2867
2875
  declare global {
2868
2876
  interface HTMLElementTagNameMap {
@@ -2912,6 +2920,7 @@ export declare class PrimerCheckoutComponent extends LitElement implements Prime
2912
2920
  private hasAssignedContent;
2913
2921
  private _loadingTimeoutId;
2914
2922
  private _eventListenerController;
2923
+ private _classObserver;
2915
2924
  locale: LocaleCode;
2916
2925
  private onSlotChange;
2917
2926
  sdkContextController: SDKContextController;
@@ -2919,7 +2928,6 @@ export declare class PrimerCheckoutComponent extends LitElement implements Prime
2919
2928
  primerEventsController: PrimerEventsController;
2920
2929
  styleProcessingController: StyleProcessingController;
2921
2930
  vaultManagerController: VaultManagerController;
2922
- cardNetworkController: CardNetworkController;
2923
2931
  achPaymentEventsController: AchPaymentEventsController;
2924
2932
  headlessSdkController: HeadlessSdkController;
2925
2933
  constructor();
@@ -3866,6 +3874,7 @@ declare class RedirectPaymentComponent extends LitElement {
3866
3874
  paymentManagers: InitializedManagersMap;
3867
3875
  sdkState: SdkStateContextType;
3868
3876
  headlessUtils: HeadlessUtilsContextType;
3877
+ clientOptions: ClientOptionsContextType | undefined;
3869
3878
  private _paymentMethodManagerTask;
3870
3879
  /**
3871
3880
  * Based on packages/primer-sdk-web/src/payment-methods/Button.tsx
@@ -4044,6 +4053,7 @@ declare class PortalDialogComponent extends LitElement {
4044
4053
  static styles: import("lit").CSSResult[];
4045
4054
  size: "flex" | "large";
4046
4055
  showCloseButton: boolean;
4056
+ darkMode: boolean;
4047
4057
  onOpen?: () => void;
4048
4058
  onContentRendered?: () => void;
4049
4059
  cta?: {
@@ -4820,6 +4830,7 @@ declare class HostedInputController<T extends HostedInputHost> implements Reacti
4820
4830
  setSubmitted(submitted: boolean): void;
4821
4831
  hostConnected(): void;
4822
4832
  hostDisconnected(): void;
4833
+ hostUpdate(): void;
4823
4834
  /**
4824
4835
  * Registers this controller with the card form context for centralized management
4825
4836
  */