@primer-io/primer-js 0.1.4 → 0.1.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.
- package/dist/custom-elements.json +820 -452
- package/dist/jsx/index.d.ts +8 -6
- package/dist/primer-loader.d.ts +96 -38
- package/dist/primer-loader.js +472 -291
- package/dist/vscode.html-custom-data.json +11 -5
- package/dist/web-types.json +16 -10
- package/package.json +1 -1
package/dist/jsx/index.d.ts
CHANGED
|
@@ -62,14 +62,14 @@ type BaseEvents = {};
|
|
|
62
62
|
|
|
63
63
|
export type PrimerCheckoutComponentProps = {
|
|
64
64
|
/** */
|
|
65
|
-
|
|
65
|
+
customStyles?: string;
|
|
66
66
|
/** */
|
|
67
|
-
|
|
67
|
+
clientToken?: string;
|
|
68
68
|
/** */
|
|
69
69
|
options?: PrimerCheckoutOptions;
|
|
70
70
|
/** Whether the component has completed initialization and loading
|
|
71
71
|
This is used to control the CSS-only loader visibility */
|
|
72
|
-
|
|
72
|
+
_jsInitialized?: boolean;
|
|
73
73
|
/** */
|
|
74
74
|
jsInitialized?: boolean;
|
|
75
75
|
/** */
|
|
@@ -354,7 +354,9 @@ export type ShowOtherPaymentsComponentProps = {
|
|
|
354
354
|
};
|
|
355
355
|
|
|
356
356
|
export type VaultManagerComponentProps = {
|
|
357
|
-
/**
|
|
357
|
+
/** Animation duration override */
|
|
358
|
+
animationDuration?: number;
|
|
359
|
+
/** */
|
|
358
360
|
addEventListener?: <K extends keyof VaultManagerEventMap>(
|
|
359
361
|
type: K,
|
|
360
362
|
listener: (ev: VaultManagerEventMap[K]) => void,
|
|
@@ -366,8 +368,7 @@ export type VaultManagerComponentProps = {
|
|
|
366
368
|
listener: (ev: VaultManagerEventMap[K]) => void,
|
|
367
369
|
options?: boolean | AddEventListenerOptions,
|
|
368
370
|
) => void;
|
|
369
|
-
/**
|
|
370
|
-
Contains vault-related functionality and state */
|
|
371
|
+
/** */
|
|
371
372
|
vaultManagerContext?: VaultManagerContext;
|
|
372
373
|
};
|
|
373
374
|
|
|
@@ -1001,6 +1002,7 @@ export type CustomElements = {
|
|
|
1001
1002
|
* Uses the VaultManagerController for display formatting
|
|
1002
1003
|
* Now supports selection via the simplified button checked state
|
|
1003
1004
|
* Enhanced with smooth transitions between edit and payment modes
|
|
1005
|
+
* Always renders the primer-button for consistent UI and improved accessibility
|
|
1004
1006
|
* ---
|
|
1005
1007
|
*
|
|
1006
1008
|
*
|
package/dist/primer-loader.d.ts
CHANGED
|
@@ -2364,6 +2364,37 @@ export type KlarnaCategoriesContext = {
|
|
|
2364
2364
|
categories: KlarnaPaymentMethodCategory[];
|
|
2365
2365
|
isLoading: boolean;
|
|
2366
2366
|
};
|
|
2367
|
+
export type ReducerCallbacks<State, _Action extends {
|
|
2368
|
+
type: string;
|
|
2369
|
+
}> = {
|
|
2370
|
+
[K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
|
|
2371
|
+
};
|
|
2372
|
+
export type TypedReducer<State, Action extends {
|
|
2373
|
+
type: string;
|
|
2374
|
+
}, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
|
|
2375
|
+
declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
|
|
2376
|
+
type: string;
|
|
2377
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
|
|
2378
|
+
protected host: Host;
|
|
2379
|
+
protected stateHandler: (state: State) => void;
|
|
2380
|
+
private _dispatcher;
|
|
2381
|
+
constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
|
|
2382
|
+
get currentState(): Readonly<State>;
|
|
2383
|
+
protected dispatch(action: Action): void;
|
|
2384
|
+
protected setCallbacks(callbacks: Partial<Callbacks>): void;
|
|
2385
|
+
hostConnected(): void;
|
|
2386
|
+
hostDisconnected(): void;
|
|
2387
|
+
}
|
|
2388
|
+
declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
|
|
2389
|
+
protected host: Host;
|
|
2390
|
+
private _controllers;
|
|
2391
|
+
constructor(host: Host);
|
|
2392
|
+
addController<State, Action extends {
|
|
2393
|
+
type: string;
|
|
2394
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
|
|
2395
|
+
hostConnected(): void;
|
|
2396
|
+
hostDisconnected(): void;
|
|
2397
|
+
}
|
|
2367
2398
|
/**
|
|
2368
2399
|
* Options for initializing the Vault Manager
|
|
2369
2400
|
*/
|
|
@@ -2378,9 +2409,10 @@ export interface VaultManagerInitOptions {
|
|
|
2378
2409
|
export interface VaultManagerState {
|
|
2379
2410
|
enabled: boolean;
|
|
2380
2411
|
isLoading: boolean;
|
|
2412
|
+
isUpdating: boolean;
|
|
2381
2413
|
vaultedPaymentMethods: VaultedPaymentMethod[];
|
|
2382
2414
|
cvvRecapture: boolean;
|
|
2383
|
-
createCvvInput
|
|
2415
|
+
createCvvInput: ((options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>) | null;
|
|
2384
2416
|
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
2385
2417
|
startVaultedPaymentFlow: (options?: {
|
|
2386
2418
|
cvv?: string;
|
|
@@ -2397,10 +2429,9 @@ export interface VaultManagerItemState {
|
|
|
2397
2429
|
selectedVaultedPaymentMethod: VaultedPaymentMethod | null;
|
|
2398
2430
|
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
2399
2431
|
}
|
|
2400
|
-
declare class VaultManagerController
|
|
2401
|
-
|
|
2402
|
-
private
|
|
2403
|
-
private _vaultItemState;
|
|
2432
|
+
declare class VaultManagerController extends CompositeStateController<PrimerCheckoutType> {
|
|
2433
|
+
private coreController;
|
|
2434
|
+
private itemController;
|
|
2404
2435
|
private _vaultManager;
|
|
2405
2436
|
private _options;
|
|
2406
2437
|
constructor(host: PrimerCheckoutType);
|
|
@@ -2414,23 +2445,17 @@ declare class VaultManagerController implements ReactiveController {
|
|
|
2414
2445
|
set vaultManager(vaultManager: HeadlessVaultManager | null);
|
|
2415
2446
|
get options(): VaultManagerInitOptions | null;
|
|
2416
2447
|
set options(options: VaultManagerInitOptions | null);
|
|
2448
|
+
get vaultManagerState(): Readonly<VaultManagerState>;
|
|
2449
|
+
get vaultItemState(): Readonly<VaultManagerItemState>;
|
|
2417
2450
|
/**
|
|
2418
2451
|
* Lifecycle method called when the host disconnects
|
|
2419
2452
|
*/
|
|
2420
2453
|
hostDisconnected(): void;
|
|
2421
|
-
/**
|
|
2422
|
-
* Dispatches an action to update the core vault state
|
|
2423
|
-
*/
|
|
2424
|
-
private dispatchVaultManager;
|
|
2425
|
-
/**
|
|
2426
|
-
* Dispatches an action to update the CVV state
|
|
2427
|
-
* Separate dispatch method to handle CVV state independently
|
|
2428
|
-
*/
|
|
2429
|
-
private dispatchVaultItem;
|
|
2430
2454
|
/**
|
|
2431
2455
|
* Fetch vaulted payment methods from the server
|
|
2432
2456
|
*/
|
|
2433
|
-
fetchVaultedPaymentMethods(): Promise<VaultedPaymentMethod[]>;
|
|
2457
|
+
fetchVaultedPaymentMethods(initialLoad?: boolean): Promise<VaultedPaymentMethod[]>;
|
|
2458
|
+
createCvvInput(options: CardSecurityCodeInputOptions): Promise<CvvInput | null>;
|
|
2434
2459
|
/**
|
|
2435
2460
|
* Delete a vaulted payment method by ID
|
|
2436
2461
|
*/
|
|
@@ -2498,13 +2523,33 @@ declare class SDKContextController implements ReactiveController {
|
|
|
2498
2523
|
setComputedStyles(value: CSSStyleDeclaration): void;
|
|
2499
2524
|
setVaultManagerCvv(value: VaultItemContext): void;
|
|
2500
2525
|
}
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2526
|
+
export type SdkStateAction = {
|
|
2527
|
+
type: "START_PROCESSING";
|
|
2528
|
+
} | {
|
|
2529
|
+
type: "START_LOADING";
|
|
2530
|
+
} | {
|
|
2531
|
+
type: "COMPLETE_PROCESSING";
|
|
2532
|
+
} | {
|
|
2533
|
+
type: "STOP_PROCESSING";
|
|
2534
|
+
} | {
|
|
2535
|
+
type: "SET_ERROR";
|
|
2536
|
+
payload: Error;
|
|
2537
|
+
} | {
|
|
2538
|
+
type: "SET_FAILURE";
|
|
2539
|
+
payload: {
|
|
2540
|
+
code: string;
|
|
2541
|
+
message: string;
|
|
2542
|
+
details?: Record<string, unknown>;
|
|
2543
|
+
};
|
|
2544
|
+
} | {
|
|
2545
|
+
type: "COMPLETE_LOADING";
|
|
2546
|
+
} | {
|
|
2547
|
+
type: "RESET";
|
|
2548
|
+
} | {
|
|
2549
|
+
type: "RESET_ERROR";
|
|
2550
|
+
};
|
|
2551
|
+
declare class SdkStateController extends ReactiveStateController<PrimerCheckoutType, SdkState, SdkStateAction, null> {
|
|
2504
2552
|
constructor(host: PrimerCheckoutType);
|
|
2505
|
-
hostConnected(): void;
|
|
2506
|
-
private reducer;
|
|
2507
|
-
private dispatch;
|
|
2508
2553
|
startLoading(): void;
|
|
2509
2554
|
startProcessing(): void;
|
|
2510
2555
|
stopProcessing(): void;
|
|
@@ -2513,8 +2558,8 @@ declare class SdkStateController implements ReactiveController {
|
|
|
2513
2558
|
setError(error: Error): void;
|
|
2514
2559
|
setFailure(code: string, message: string, details?: Record<string, unknown>): void;
|
|
2515
2560
|
reset(): void;
|
|
2561
|
+
resetError(): void;
|
|
2516
2562
|
forceCompleteLoading(): void;
|
|
2517
|
-
get state(): SdkState;
|
|
2518
2563
|
}
|
|
2519
2564
|
export interface PrimerCheckoutType extends ReactiveControllerHost, LitElement {
|
|
2520
2565
|
requestUpdate: ReactiveControllerHost["requestUpdate"];
|
|
@@ -3222,7 +3267,7 @@ declare class PrimerKlarnaComponent extends LitElement {
|
|
|
3222
3267
|
renderSelectedCategory(): Promise<void>;
|
|
3223
3268
|
selectCategory(category: string): void;
|
|
3224
3269
|
updated(changedProperties: Map<string, unknown>): void;
|
|
3225
|
-
renderCategorySelection():
|
|
3270
|
+
renderCategorySelection(): TemplateResult<1>;
|
|
3226
3271
|
renderExpandedContent(): TemplateResult<1>;
|
|
3227
3272
|
render(): typeof nothing | TemplateResult<1> | undefined;
|
|
3228
3273
|
}
|
|
@@ -3332,6 +3377,11 @@ declare class RedirectPaymentComponent extends LitElement {
|
|
|
3332
3377
|
sdkState: SdkStateContext;
|
|
3333
3378
|
headlessUtils: HeadlessUnitilsContext;
|
|
3334
3379
|
private _paymentMethodManagerTask;
|
|
3380
|
+
/**
|
|
3381
|
+
* Based on packages/primer-sdk-web/src/payment-methods/Button.tsx
|
|
3382
|
+
* Should be replaced once we align on a better solution across all platforms.
|
|
3383
|
+
*/
|
|
3384
|
+
private _legacyGetButtonLabel;
|
|
3335
3385
|
private _getAssetsTask;
|
|
3336
3386
|
private _setupTasks;
|
|
3337
3387
|
startRedirectPayment(): void;
|
|
@@ -4016,15 +4066,9 @@ export interface VaultManagerEventMap {
|
|
|
4016
4066
|
*/
|
|
4017
4067
|
declare class VaultManagerComponent extends LitElement {
|
|
4018
4068
|
static styles: CSSResult[];
|
|
4019
|
-
|
|
4020
|
-
* Strongly typed event declarations
|
|
4021
|
-
*/
|
|
4069
|
+
constructor();
|
|
4022
4070
|
addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
|
|
4023
4071
|
removeEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
|
|
4024
|
-
/**
|
|
4025
|
-
* The vault manager core context from the SDK
|
|
4026
|
-
* Contains vault-related functionality and state
|
|
4027
|
-
*/
|
|
4028
4072
|
vaultManagerContext: VaultManagerContext;
|
|
4029
4073
|
/**
|
|
4030
4074
|
* Whether we're in edit mode
|
|
@@ -4042,6 +4086,14 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4042
4086
|
* Error message if something goes wrong
|
|
4043
4087
|
*/
|
|
4044
4088
|
private errorMessage;
|
|
4089
|
+
/**
|
|
4090
|
+
* Animation duration override
|
|
4091
|
+
*/
|
|
4092
|
+
animationDuration: number;
|
|
4093
|
+
/**
|
|
4094
|
+
* Get base animation configuration with current settings
|
|
4095
|
+
*/
|
|
4096
|
+
private getAnimationConfig;
|
|
4045
4097
|
/**
|
|
4046
4098
|
* Toggle edit mode handler
|
|
4047
4099
|
*/
|
|
@@ -4071,13 +4123,24 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4071
4123
|
*/
|
|
4072
4124
|
private getPaymentMethodName;
|
|
4073
4125
|
/**
|
|
4074
|
-
* Render
|
|
4126
|
+
* Render loading overlay with spinner when isUpdating is true
|
|
4127
|
+
*/
|
|
4128
|
+
private renderLoadingOverlay;
|
|
4129
|
+
/**
|
|
4130
|
+
* Render delete confirmation content
|
|
4075
4131
|
*/
|
|
4076
4132
|
private renderDeleteConfirmation;
|
|
4077
4133
|
/**
|
|
4078
|
-
* Render a payment method item
|
|
4134
|
+
* Render a payment method item with appropriate animations
|
|
4079
4135
|
*/
|
|
4080
4136
|
private renderPaymentMethodItem;
|
|
4137
|
+
/**
|
|
4138
|
+
* Render the payment method list with submit button
|
|
4139
|
+
*/
|
|
4140
|
+
private renderPaymentMethodList;
|
|
4141
|
+
/**
|
|
4142
|
+
* Main render method
|
|
4143
|
+
*/
|
|
4081
4144
|
render(): typeof nothing | TemplateResult<1>;
|
|
4082
4145
|
}
|
|
4083
4146
|
/**
|
|
@@ -4085,6 +4148,7 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4085
4148
|
* Uses the VaultManagerController for display formatting
|
|
4086
4149
|
* Now supports selection via the simplified button checked state
|
|
4087
4150
|
* Enhanced with smooth transitions between edit and payment modes
|
|
4151
|
+
* Always renders the primer-button for consistent UI and improved accessibility
|
|
4088
4152
|
*/
|
|
4089
4153
|
declare class VaultPaymentMethodItemComponent extends LitElement {
|
|
4090
4154
|
static styles: CSSResult[];
|
|
@@ -4357,16 +4421,10 @@ declare global {
|
|
|
4357
4421
|
*/
|
|
4358
4422
|
declare class ShowOtherPaymentsComponent extends LitElement {
|
|
4359
4423
|
static styles: CSSResult[];
|
|
4360
|
-
private isShowingOtherPayments;
|
|
4361
4424
|
/**
|
|
4362
4425
|
* Consume the vault manager context to interact with vault state
|
|
4363
4426
|
*/
|
|
4364
4427
|
vaultManager: VaultManagerContext;
|
|
4365
|
-
/**
|
|
4366
|
-
* Handle expanded state change events from the collapsable component
|
|
4367
|
-
* Syncs the collapsable UI state with the vault manager state
|
|
4368
|
-
*/
|
|
4369
|
-
private handleExpandedChanged;
|
|
4370
4428
|
render(): typeof nothing | TemplateResult<1>;
|
|
4371
4429
|
}
|
|
4372
4430
|
declare global {
|