@primer-io/primer-js 0.1.4 → 0.1.6
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 +3636 -1814
- package/dist/jsx/index.d.ts +11 -7
- package/dist/primer-loader.d.ts +110 -38
- package/dist/primer-loader.js +485 -295
- package/dist/primer-react-wrappers.js +2370 -0
- package/dist/vscode.html-custom-data.json +15 -6
- package/dist/web-types.json +29 -15
- package/package.json +23 -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
|
/** */
|
|
@@ -101,7 +101,7 @@ export type ButtonComponentProps = {
|
|
|
101
101
|
When true, the button will display a spinner and be disabled */
|
|
102
102
|
loading?: boolean;
|
|
103
103
|
/** */
|
|
104
|
-
|
|
104
|
+
type?: "button" | "submit" | "reset";
|
|
105
105
|
/** Selection state of the button
|
|
106
106
|
- default: Not checked
|
|
107
107
|
- checked: Button is checked */
|
|
@@ -274,6 +274,8 @@ export type AchPaymentComponentProps = {
|
|
|
274
274
|
};
|
|
275
275
|
|
|
276
276
|
export type CardFormComponentProps = {
|
|
277
|
+
/** */
|
|
278
|
+
"hide-labels"?: boolean;
|
|
277
279
|
/** Payment managers injected from context */
|
|
278
280
|
paymentManagers?: InitializedManagersMap;
|
|
279
281
|
};
|
|
@@ -354,7 +356,9 @@ export type ShowOtherPaymentsComponentProps = {
|
|
|
354
356
|
};
|
|
355
357
|
|
|
356
358
|
export type VaultManagerComponentProps = {
|
|
357
|
-
/**
|
|
359
|
+
/** Animation duration override */
|
|
360
|
+
animationDuration?: number;
|
|
361
|
+
/** */
|
|
358
362
|
addEventListener?: <K extends keyof VaultManagerEventMap>(
|
|
359
363
|
type: K,
|
|
360
364
|
listener: (ev: VaultManagerEventMap[K]) => void,
|
|
@@ -366,8 +370,7 @@ export type VaultManagerComponentProps = {
|
|
|
366
370
|
listener: (ev: VaultManagerEventMap[K]) => void,
|
|
367
371
|
options?: boolean | AddEventListenerOptions,
|
|
368
372
|
) => void;
|
|
369
|
-
/**
|
|
370
|
-
Contains vault-related functionality and state */
|
|
373
|
+
/** */
|
|
371
374
|
vaultManagerContext?: VaultManagerContext;
|
|
372
375
|
};
|
|
373
376
|
|
|
@@ -1001,6 +1004,7 @@ export type CustomElements = {
|
|
|
1001
1004
|
* Uses the VaultManagerController for display formatting
|
|
1002
1005
|
* Now supports selection via the simplified button checked state
|
|
1003
1006
|
* Enhanced with smooth transitions between edit and payment modes
|
|
1007
|
+
* Always renders the primer-button for consistent UI and improved accessibility
|
|
1004
1008
|
* ---
|
|
1005
1009
|
*
|
|
1006
1010
|
*
|
package/dist/primer-loader.d.ts
CHANGED
|
@@ -2319,6 +2319,13 @@ export declare class InitializedPayments {
|
|
|
2319
2319
|
toArray(): InitializedPaymentMethod[];
|
|
2320
2320
|
size(): number;
|
|
2321
2321
|
}
|
|
2322
|
+
export interface OnCheckoutCompletePayload {
|
|
2323
|
+
payment: Payment | null;
|
|
2324
|
+
}
|
|
2325
|
+
export interface OnCheckoutFailurePayload {
|
|
2326
|
+
error: PrimerClientError;
|
|
2327
|
+
payment?: Payment;
|
|
2328
|
+
}
|
|
2322
2329
|
export interface CardSubmitSuccessPayload {
|
|
2323
2330
|
result: unknown;
|
|
2324
2331
|
}
|
|
@@ -2330,6 +2337,8 @@ export interface PrimeAchErrorPayload {
|
|
|
2330
2337
|
}
|
|
2331
2338
|
export interface PrimerEvents {
|
|
2332
2339
|
"primer-state-changed": CustomEvent<SdkStateContext>;
|
|
2340
|
+
"primer-oncheckout-complete": CustomEvent<OnCheckoutCompletePayload>;
|
|
2341
|
+
"primer-oncheckout-failure": CustomEvent<OnCheckoutFailurePayload>;
|
|
2333
2342
|
"primer-payment-methods-updated": CustomEvent<InitializedPayments>;
|
|
2334
2343
|
"primer-checkout-initialized": CustomEvent<PrimerHeadlessCheckout>;
|
|
2335
2344
|
"primer-card-network-change": CustomEvent<CardNetworksContext>;
|
|
@@ -2356,6 +2365,8 @@ declare class PrimerEventsController implements ReactiveController {
|
|
|
2356
2365
|
dispatchPaymentMethods(paymentMethods: InitializedPayments): void;
|
|
2357
2366
|
dispatchCheckoutInitialized(checkoutInstance: PrimerHeadlessCheckout): void;
|
|
2358
2367
|
dispatchCardNetworkChange(network: CardNetworksContext): void;
|
|
2368
|
+
dispatchOnCheckoutComplete(payment: Payment | null): void;
|
|
2369
|
+
dispatchOnCheckoutFailure(error: PrimerClientError, payment?: Payment): void;
|
|
2359
2370
|
dispatchFormSubmitSuccess(result: unknown): void;
|
|
2360
2371
|
dispatchFormSubmitErrors(errors: unknown): void;
|
|
2361
2372
|
}
|
|
@@ -2364,6 +2375,37 @@ export type KlarnaCategoriesContext = {
|
|
|
2364
2375
|
categories: KlarnaPaymentMethodCategory[];
|
|
2365
2376
|
isLoading: boolean;
|
|
2366
2377
|
};
|
|
2378
|
+
export type ReducerCallbacks<State, _Action extends {
|
|
2379
|
+
type: string;
|
|
2380
|
+
}> = {
|
|
2381
|
+
[K in keyof State]?: State[K] extends (...args: unknown[]) => unknown ? State[K] : never;
|
|
2382
|
+
};
|
|
2383
|
+
export type TypedReducer<State, Action extends {
|
|
2384
|
+
type: string;
|
|
2385
|
+
}, Callbacks> = (state: State, action: Action, callbacks: Callbacks) => State;
|
|
2386
|
+
declare abstract class ReactiveStateController<Host extends ReactiveControllerHost, State, Action extends {
|
|
2387
|
+
type: string;
|
|
2388
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null> implements ReactiveController {
|
|
2389
|
+
protected host: Host;
|
|
2390
|
+
protected stateHandler: (state: State) => void;
|
|
2391
|
+
private _dispatcher;
|
|
2392
|
+
constructor(host: Host, initialState: State, reducer: TypedReducer<State, Action, Callbacks>, initialCallbacks: Callbacks, stateHandler?: (state: State) => void);
|
|
2393
|
+
get currentState(): Readonly<State>;
|
|
2394
|
+
protected dispatch(action: Action): void;
|
|
2395
|
+
protected setCallbacks(callbacks: Partial<Callbacks>): void;
|
|
2396
|
+
hostConnected(): void;
|
|
2397
|
+
hostDisconnected(): void;
|
|
2398
|
+
}
|
|
2399
|
+
declare class CompositeStateController<Host extends ReactiveControllerHost> implements ReactiveController {
|
|
2400
|
+
protected host: Host;
|
|
2401
|
+
private _controllers;
|
|
2402
|
+
constructor(host: Host);
|
|
2403
|
+
addController<State, Action extends {
|
|
2404
|
+
type: string;
|
|
2405
|
+
}, Callbacks = ReducerCallbacks<State, Action> | null>(controller: ReactiveStateController<Host, State, Action, Callbacks>): void;
|
|
2406
|
+
hostConnected(): void;
|
|
2407
|
+
hostDisconnected(): void;
|
|
2408
|
+
}
|
|
2367
2409
|
/**
|
|
2368
2410
|
* Options for initializing the Vault Manager
|
|
2369
2411
|
*/
|
|
@@ -2378,9 +2420,10 @@ export interface VaultManagerInitOptions {
|
|
|
2378
2420
|
export interface VaultManagerState {
|
|
2379
2421
|
enabled: boolean;
|
|
2380
2422
|
isLoading: boolean;
|
|
2423
|
+
isUpdating: boolean;
|
|
2381
2424
|
vaultedPaymentMethods: VaultedPaymentMethod[];
|
|
2382
2425
|
cvvRecapture: boolean;
|
|
2383
|
-
createCvvInput
|
|
2426
|
+
createCvvInput: ((options: CardSecurityCodeInputOptions) => Promise<CvvInput | null>) | null;
|
|
2384
2427
|
deleteVaultedPaymentMethod: (paymentMethodId: string) => Promise<void>;
|
|
2385
2428
|
startVaultedPaymentFlow: (options?: {
|
|
2386
2429
|
cvv?: string;
|
|
@@ -2397,10 +2440,9 @@ export interface VaultManagerItemState {
|
|
|
2397
2440
|
selectedVaultedPaymentMethod: VaultedPaymentMethod | null;
|
|
2398
2441
|
setSelectedVaultedPaymentMethod: (paymentMethod: VaultedPaymentMethod | null) => void;
|
|
2399
2442
|
}
|
|
2400
|
-
declare class VaultManagerController
|
|
2401
|
-
|
|
2402
|
-
private
|
|
2403
|
-
private _vaultItemState;
|
|
2443
|
+
declare class VaultManagerController extends CompositeStateController<PrimerCheckoutType> {
|
|
2444
|
+
private coreController;
|
|
2445
|
+
private itemController;
|
|
2404
2446
|
private _vaultManager;
|
|
2405
2447
|
private _options;
|
|
2406
2448
|
constructor(host: PrimerCheckoutType);
|
|
@@ -2414,23 +2456,17 @@ declare class VaultManagerController implements ReactiveController {
|
|
|
2414
2456
|
set vaultManager(vaultManager: HeadlessVaultManager | null);
|
|
2415
2457
|
get options(): VaultManagerInitOptions | null;
|
|
2416
2458
|
set options(options: VaultManagerInitOptions | null);
|
|
2459
|
+
get vaultManagerState(): Readonly<VaultManagerState>;
|
|
2460
|
+
get vaultItemState(): Readonly<VaultManagerItemState>;
|
|
2417
2461
|
/**
|
|
2418
2462
|
* Lifecycle method called when the host disconnects
|
|
2419
2463
|
*/
|
|
2420
2464
|
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
2465
|
/**
|
|
2431
2466
|
* Fetch vaulted payment methods from the server
|
|
2432
2467
|
*/
|
|
2433
|
-
fetchVaultedPaymentMethods(): Promise<VaultedPaymentMethod[]>;
|
|
2468
|
+
fetchVaultedPaymentMethods(initialLoad?: boolean): Promise<VaultedPaymentMethod[]>;
|
|
2469
|
+
createCvvInput(options: CardSecurityCodeInputOptions): Promise<CvvInput | null>;
|
|
2434
2470
|
/**
|
|
2435
2471
|
* Delete a vaulted payment method by ID
|
|
2436
2472
|
*/
|
|
@@ -2498,13 +2534,33 @@ declare class SDKContextController implements ReactiveController {
|
|
|
2498
2534
|
setComputedStyles(value: CSSStyleDeclaration): void;
|
|
2499
2535
|
setVaultManagerCvv(value: VaultItemContext): void;
|
|
2500
2536
|
}
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2537
|
+
export type SdkStateAction = {
|
|
2538
|
+
type: "START_PROCESSING";
|
|
2539
|
+
} | {
|
|
2540
|
+
type: "START_LOADING";
|
|
2541
|
+
} | {
|
|
2542
|
+
type: "COMPLETE_PROCESSING";
|
|
2543
|
+
} | {
|
|
2544
|
+
type: "STOP_PROCESSING";
|
|
2545
|
+
} | {
|
|
2546
|
+
type: "SET_ERROR";
|
|
2547
|
+
payload: Error;
|
|
2548
|
+
} | {
|
|
2549
|
+
type: "SET_FAILURE";
|
|
2550
|
+
payload: {
|
|
2551
|
+
code: string;
|
|
2552
|
+
message: string;
|
|
2553
|
+
details?: Record<string, unknown>;
|
|
2554
|
+
};
|
|
2555
|
+
} | {
|
|
2556
|
+
type: "COMPLETE_LOADING";
|
|
2557
|
+
} | {
|
|
2558
|
+
type: "RESET";
|
|
2559
|
+
} | {
|
|
2560
|
+
type: "RESET_ERROR";
|
|
2561
|
+
};
|
|
2562
|
+
declare class SdkStateController extends ReactiveStateController<PrimerCheckoutType, SdkState, SdkStateAction, null> {
|
|
2504
2563
|
constructor(host: PrimerCheckoutType);
|
|
2505
|
-
hostConnected(): void;
|
|
2506
|
-
private reducer;
|
|
2507
|
-
private dispatch;
|
|
2508
2564
|
startLoading(): void;
|
|
2509
2565
|
startProcessing(): void;
|
|
2510
2566
|
stopProcessing(): void;
|
|
@@ -2513,8 +2569,8 @@ declare class SdkStateController implements ReactiveController {
|
|
|
2513
2569
|
setError(error: Error): void;
|
|
2514
2570
|
setFailure(code: string, message: string, details?: Record<string, unknown>): void;
|
|
2515
2571
|
reset(): void;
|
|
2572
|
+
resetError(): void;
|
|
2516
2573
|
forceCompleteLoading(): void;
|
|
2517
|
-
get state(): SdkState;
|
|
2518
2574
|
}
|
|
2519
2575
|
export interface PrimerCheckoutType extends ReactiveControllerHost, LitElement {
|
|
2520
2576
|
requestUpdate: ReactiveControllerHost["requestUpdate"];
|
|
@@ -3222,7 +3278,7 @@ declare class PrimerKlarnaComponent extends LitElement {
|
|
|
3222
3278
|
renderSelectedCategory(): Promise<void>;
|
|
3223
3279
|
selectCategory(category: string): void;
|
|
3224
3280
|
updated(changedProperties: Map<string, unknown>): void;
|
|
3225
|
-
renderCategorySelection():
|
|
3281
|
+
renderCategorySelection(): TemplateResult<1>;
|
|
3226
3282
|
renderExpandedContent(): TemplateResult<1>;
|
|
3227
3283
|
render(): typeof nothing | TemplateResult<1> | undefined;
|
|
3228
3284
|
}
|
|
@@ -3332,6 +3388,11 @@ declare class RedirectPaymentComponent extends LitElement {
|
|
|
3332
3388
|
sdkState: SdkStateContext;
|
|
3333
3389
|
headlessUtils: HeadlessUnitilsContext;
|
|
3334
3390
|
private _paymentMethodManagerTask;
|
|
3391
|
+
/**
|
|
3392
|
+
* Based on packages/primer-sdk-web/src/payment-methods/Button.tsx
|
|
3393
|
+
* Should be replaced once we align on a better solution across all platforms.
|
|
3394
|
+
*/
|
|
3395
|
+
private _legacyGetButtonLabel;
|
|
3335
3396
|
private _getAssetsTask;
|
|
3336
3397
|
private _setupTasks;
|
|
3337
3398
|
startRedirectPayment(): void;
|
|
@@ -3394,6 +3455,8 @@ declare global {
|
|
|
3394
3455
|
*/
|
|
3395
3456
|
declare class CardFormComponent extends LitElement {
|
|
3396
3457
|
static styles: CSSResult[];
|
|
3458
|
+
hideLabels: boolean;
|
|
3459
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
3397
3460
|
/**
|
|
3398
3461
|
* Tracks whether custom content has been provided via slot
|
|
3399
3462
|
*/
|
|
@@ -3456,6 +3519,7 @@ export interface CardFormContext {
|
|
|
3456
3519
|
validate: () => Promise<Validation>;
|
|
3457
3520
|
submit: (values?: CardPaymentMethodSubmitValues) => Promise<void>;
|
|
3458
3521
|
errors?: Validation["validationErrors"];
|
|
3522
|
+
hideLabels?: boolean;
|
|
3459
3523
|
}
|
|
3460
3524
|
/**
|
|
3461
3525
|
* A shared type that ensures the host of a HostedInputController contains
|
|
@@ -4016,15 +4080,9 @@ export interface VaultManagerEventMap {
|
|
|
4016
4080
|
*/
|
|
4017
4081
|
declare class VaultManagerComponent extends LitElement {
|
|
4018
4082
|
static styles: CSSResult[];
|
|
4019
|
-
|
|
4020
|
-
* Strongly typed event declarations
|
|
4021
|
-
*/
|
|
4083
|
+
constructor();
|
|
4022
4084
|
addEventListener: <K extends keyof VaultManagerEventMap>(type: K, listener: (ev: VaultManagerEventMap[K]) => void, options?: boolean | AddEventListenerOptions) => void;
|
|
4023
4085
|
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
4086
|
vaultManagerContext: VaultManagerContext;
|
|
4029
4087
|
/**
|
|
4030
4088
|
* Whether we're in edit mode
|
|
@@ -4042,6 +4100,14 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4042
4100
|
* Error message if something goes wrong
|
|
4043
4101
|
*/
|
|
4044
4102
|
private errorMessage;
|
|
4103
|
+
/**
|
|
4104
|
+
* Animation duration override
|
|
4105
|
+
*/
|
|
4106
|
+
animationDuration: number;
|
|
4107
|
+
/**
|
|
4108
|
+
* Get base animation configuration with current settings
|
|
4109
|
+
*/
|
|
4110
|
+
private getAnimationConfig;
|
|
4045
4111
|
/**
|
|
4046
4112
|
* Toggle edit mode handler
|
|
4047
4113
|
*/
|
|
@@ -4071,13 +4137,24 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4071
4137
|
*/
|
|
4072
4138
|
private getPaymentMethodName;
|
|
4073
4139
|
/**
|
|
4074
|
-
* Render
|
|
4140
|
+
* Render loading overlay with spinner when isUpdating is true
|
|
4141
|
+
*/
|
|
4142
|
+
private renderLoadingOverlay;
|
|
4143
|
+
/**
|
|
4144
|
+
* Render delete confirmation content
|
|
4075
4145
|
*/
|
|
4076
4146
|
private renderDeleteConfirmation;
|
|
4077
4147
|
/**
|
|
4078
|
-
* Render a payment method item
|
|
4148
|
+
* Render a payment method item with appropriate animations
|
|
4079
4149
|
*/
|
|
4080
4150
|
private renderPaymentMethodItem;
|
|
4151
|
+
/**
|
|
4152
|
+
* Render the payment method list with submit button
|
|
4153
|
+
*/
|
|
4154
|
+
private renderPaymentMethodList;
|
|
4155
|
+
/**
|
|
4156
|
+
* Main render method
|
|
4157
|
+
*/
|
|
4081
4158
|
render(): typeof nothing | TemplateResult<1>;
|
|
4082
4159
|
}
|
|
4083
4160
|
/**
|
|
@@ -4085,6 +4162,7 @@ declare class VaultManagerComponent extends LitElement {
|
|
|
4085
4162
|
* Uses the VaultManagerController for display formatting
|
|
4086
4163
|
* Now supports selection via the simplified button checked state
|
|
4087
4164
|
* Enhanced with smooth transitions between edit and payment modes
|
|
4165
|
+
* Always renders the primer-button for consistent UI and improved accessibility
|
|
4088
4166
|
*/
|
|
4089
4167
|
declare class VaultPaymentMethodItemComponent extends LitElement {
|
|
4090
4168
|
static styles: CSSResult[];
|
|
@@ -4357,16 +4435,10 @@ declare global {
|
|
|
4357
4435
|
*/
|
|
4358
4436
|
declare class ShowOtherPaymentsComponent extends LitElement {
|
|
4359
4437
|
static styles: CSSResult[];
|
|
4360
|
-
private isShowingOtherPayments;
|
|
4361
4438
|
/**
|
|
4362
4439
|
* Consume the vault manager context to interact with vault state
|
|
4363
4440
|
*/
|
|
4364
4441
|
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
4442
|
render(): typeof nothing | TemplateResult<1>;
|
|
4371
4443
|
}
|
|
4372
4444
|
declare global {
|