@primer-io/primer-js 0.0.1 → 0.0.3
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/LICENSE.md +28 -0
- package/README.md +146 -0
- package/dist/custom-elements.json +8122 -0
- package/dist/jsx/index.d.ts +528 -0
- package/dist/primer-loader.d.ts +3249 -0
- package/dist/primer-loader.js +1 -0
- package/dist/vscode.html-custom-data.json +343 -0
- package/dist/web-types.json +835 -0
- package/package.json +9 -7
|
@@ -0,0 +1,3249 @@
|
|
|
1
|
+
export type CardNetwork = {
|
|
2
|
+
displayName: string;
|
|
3
|
+
network: string;
|
|
4
|
+
iconUrl: string;
|
|
5
|
+
};
|
|
6
|
+
export type CardNetworksContext = {
|
|
7
|
+
detectedCardNetwork: CardNetwork | null;
|
|
8
|
+
selectableCardNetworks: CardNetwork[];
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A CSSResult or native CSSStyleSheet.
|
|
13
|
+
*
|
|
14
|
+
* In browsers that support constructible CSS style sheets, CSSStyleSheet
|
|
15
|
+
* object can be used for styling along side CSSResult from the `css`
|
|
16
|
+
* template tag.
|
|
17
|
+
*/
|
|
18
|
+
export type CSSResultOrNative = CSSResult | CSSStyleSheet;
|
|
19
|
+
export type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;
|
|
20
|
+
/**
|
|
21
|
+
* A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.
|
|
22
|
+
*/
|
|
23
|
+
export type CSSResultGroup = CSSResultOrNative | CSSResultArray;
|
|
24
|
+
declare class CSSResult {
|
|
25
|
+
["_$cssResult$"]: boolean;
|
|
26
|
+
readonly cssText: string;
|
|
27
|
+
private _styleSheet?;
|
|
28
|
+
private _strings;
|
|
29
|
+
private constructor();
|
|
30
|
+
get styleSheet(): CSSStyleSheet | undefined;
|
|
31
|
+
toString(): string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @license
|
|
35
|
+
* Copyright 2021 Google LLC
|
|
36
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* An object that can host Reactive Controllers and call their lifecycle
|
|
40
|
+
* callbacks.
|
|
41
|
+
*/
|
|
42
|
+
export interface ReactiveControllerHost {
|
|
43
|
+
/**
|
|
44
|
+
* Adds a controller to the host, which sets up the controller's lifecycle
|
|
45
|
+
* methods to be called with the host's lifecycle.
|
|
46
|
+
*/
|
|
47
|
+
addController(controller: ReactiveController): void;
|
|
48
|
+
/**
|
|
49
|
+
* Removes a controller from the host.
|
|
50
|
+
*/
|
|
51
|
+
removeController(controller: ReactiveController): void;
|
|
52
|
+
/**
|
|
53
|
+
* Requests a host update which is processed asynchronously. The update can
|
|
54
|
+
* be waited on via the `updateComplete` property.
|
|
55
|
+
*/
|
|
56
|
+
requestUpdate(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Returns a Promise that resolves when the host has completed updating.
|
|
59
|
+
* The Promise value is a boolean that is `true` if the element completed the
|
|
60
|
+
* update without triggering another update. The Promise result is `false` if
|
|
61
|
+
* a property was set inside `updated()`. If the Promise is rejected, an
|
|
62
|
+
* exception was thrown during the update.
|
|
63
|
+
*
|
|
64
|
+
* @return A promise of a boolean that indicates if the update resolved
|
|
65
|
+
* without triggering another update.
|
|
66
|
+
*/
|
|
67
|
+
readonly updateComplete: Promise<boolean>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* A Reactive Controller is an object that enables sub-component code
|
|
71
|
+
* organization and reuse by aggregating the state, behavior, and lifecycle
|
|
72
|
+
* hooks related to a single feature.
|
|
73
|
+
*
|
|
74
|
+
* Controllers are added to a host component, or other object that implements
|
|
75
|
+
* the `ReactiveControllerHost` interface, via the `addController()` method.
|
|
76
|
+
* They can hook their host components's lifecycle by implementing one or more
|
|
77
|
+
* of the lifecycle callbacks, or initiate an update of the host component by
|
|
78
|
+
* calling `requestUpdate()` on the host.
|
|
79
|
+
*/
|
|
80
|
+
export interface ReactiveController {
|
|
81
|
+
/**
|
|
82
|
+
* Called when the host is connected to the component tree. For custom
|
|
83
|
+
* element hosts, this corresponds to the `connectedCallback()` lifecycle,
|
|
84
|
+
* which is only called when the component is connected to the document.
|
|
85
|
+
*/
|
|
86
|
+
hostConnected?(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Called when the host is disconnected from the component tree. For custom
|
|
89
|
+
* element hosts, this corresponds to the `disconnectedCallback()` lifecycle,
|
|
90
|
+
* which is called the host or an ancestor component is disconnected from the
|
|
91
|
+
* document.
|
|
92
|
+
*/
|
|
93
|
+
hostDisconnected?(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Called during the client-side host update, just before the host calls
|
|
96
|
+
* its own update.
|
|
97
|
+
*
|
|
98
|
+
* Code in `update()` can depend on the DOM as it is not called in
|
|
99
|
+
* server-side rendering.
|
|
100
|
+
*/
|
|
101
|
+
hostUpdate?(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Called after a host update, just before the host calls firstUpdated and
|
|
104
|
+
* updated. It is not called in server-side rendering.
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
hostUpdated?(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Converts property values to and from attribute values.
|
|
111
|
+
*/
|
|
112
|
+
export interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {
|
|
113
|
+
/**
|
|
114
|
+
* Called to convert an attribute value to a property
|
|
115
|
+
* value.
|
|
116
|
+
*/
|
|
117
|
+
fromAttribute?(value: string | null, type?: TypeHint): Type;
|
|
118
|
+
/**
|
|
119
|
+
* Called to convert a property value to an attribute
|
|
120
|
+
* value.
|
|
121
|
+
*
|
|
122
|
+
* It returns unknown instead of string, to be compatible with
|
|
123
|
+
* https://github.com/WICG/trusted-types (and similar efforts).
|
|
124
|
+
*/
|
|
125
|
+
toAttribute?(value: Type, type?: TypeHint): unknown;
|
|
126
|
+
}
|
|
127
|
+
export type AttributeConverter<Type = unknown, TypeHint = unknown> = ComplexAttributeConverter<Type> | ((value: string | null, type?: TypeHint) => Type);
|
|
128
|
+
/**
|
|
129
|
+
* Defines options for a property accessor.
|
|
130
|
+
*/
|
|
131
|
+
export interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {
|
|
132
|
+
/**
|
|
133
|
+
* When set to `true`, indicates the property is internal private state. The
|
|
134
|
+
* property should not be set by users. When using TypeScript, this property
|
|
135
|
+
* should be marked as `private` or `protected`, and it is also a common
|
|
136
|
+
* practice to use a leading `_` in the name. The property is not added to
|
|
137
|
+
* `observedAttributes`.
|
|
138
|
+
*/
|
|
139
|
+
readonly state?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Indicates how and whether the property becomes an observed attribute.
|
|
142
|
+
* If the value is `false`, the property is not added to `observedAttributes`.
|
|
143
|
+
* If true or absent, the lowercased property name is observed (e.g. `fooBar`
|
|
144
|
+
* becomes `foobar`). If a string, the string value is observed (e.g
|
|
145
|
+
* `attribute: 'foo-bar'`).
|
|
146
|
+
*/
|
|
147
|
+
readonly attribute?: boolean | string;
|
|
148
|
+
/**
|
|
149
|
+
* Indicates the type of the property. This is used only as a hint for the
|
|
150
|
+
* `converter` to determine how to convert the attribute
|
|
151
|
+
* to/from a property.
|
|
152
|
+
*/
|
|
153
|
+
readonly type?: TypeHint;
|
|
154
|
+
/**
|
|
155
|
+
* Indicates how to convert the attribute to/from a property. If this value
|
|
156
|
+
* is a function, it is used to convert the attribute value a the property
|
|
157
|
+
* value. If it's an object, it can have keys for `fromAttribute` and
|
|
158
|
+
* `toAttribute`. If no `toAttribute` function is provided and
|
|
159
|
+
* `reflect` is set to `true`, the property value is set directly to the
|
|
160
|
+
* attribute. A default `converter` is used if none is provided; it supports
|
|
161
|
+
* `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,
|
|
162
|
+
* when a property changes and the converter is used to update the attribute,
|
|
163
|
+
* the property is never updated again as a result of the attribute changing,
|
|
164
|
+
* and vice versa.
|
|
165
|
+
*/
|
|
166
|
+
readonly converter?: AttributeConverter<Type, TypeHint>;
|
|
167
|
+
/**
|
|
168
|
+
* Indicates if the property should reflect to an attribute.
|
|
169
|
+
* If `true`, when the property is set, the attribute is set using the
|
|
170
|
+
* attribute name determined according to the rules for the `attribute`
|
|
171
|
+
* property option and the value of the property converted using the rules
|
|
172
|
+
* from the `converter` property option.
|
|
173
|
+
*/
|
|
174
|
+
readonly reflect?: boolean;
|
|
175
|
+
/**
|
|
176
|
+
* A function that indicates if a property should be considered changed when
|
|
177
|
+
* it is set. The function should take the `newValue` and `oldValue` and
|
|
178
|
+
* return `true` if an update should be requested.
|
|
179
|
+
*/
|
|
180
|
+
hasChanged?(value: Type, oldValue: Type): boolean;
|
|
181
|
+
/**
|
|
182
|
+
* Indicates whether an accessor will be created for this property. By
|
|
183
|
+
* default, an accessor will be generated for this property that requests an
|
|
184
|
+
* update when set. If this flag is `true`, no accessor will be created, and
|
|
185
|
+
* it will be the user's responsibility to call
|
|
186
|
+
* `this.requestUpdate(propertyName, oldValue)` to request an update when
|
|
187
|
+
* the property changes.
|
|
188
|
+
*/
|
|
189
|
+
readonly noAccessor?: boolean;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Map of properties to PropertyDeclaration options. For each property an
|
|
193
|
+
* accessor is made, and the property is processed according to the
|
|
194
|
+
* PropertyDeclaration options.
|
|
195
|
+
*/
|
|
196
|
+
export interface PropertyDeclarations {
|
|
197
|
+
readonly [key: string]: PropertyDeclaration;
|
|
198
|
+
}
|
|
199
|
+
export type PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;
|
|
200
|
+
/**
|
|
201
|
+
* A Map of property keys to values.
|
|
202
|
+
*
|
|
203
|
+
* Takes an optional type parameter T, which when specified as a non-any,
|
|
204
|
+
* non-unknown type, will make the Map more strongly-typed, associating the map
|
|
205
|
+
* keys with their corresponding value type on T.
|
|
206
|
+
*
|
|
207
|
+
* Use `PropertyValues<this>` when overriding ReactiveElement.update() and
|
|
208
|
+
* other lifecycle methods in order to get stronger type-checking on keys
|
|
209
|
+
* and values.
|
|
210
|
+
*/
|
|
211
|
+
export type PropertyValues<T = any> = T extends object ? PropertyValueMap<T> : Map<PropertyKey, unknown>;
|
|
212
|
+
/**
|
|
213
|
+
* Do not use, instead prefer {@linkcode PropertyValues}.
|
|
214
|
+
*/
|
|
215
|
+
export interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {
|
|
216
|
+
get<K extends keyof T>(k: K): T[K] | undefined;
|
|
217
|
+
set<K extends keyof T>(key: K, value: T[K]): this;
|
|
218
|
+
has<K extends keyof T>(k: K): boolean;
|
|
219
|
+
delete<K extends keyof T>(k: K): boolean;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* A string representing one of the supported dev mode warning categories.
|
|
223
|
+
*/
|
|
224
|
+
export type WarningKind = "change-in-update" | "migration" | "async-perform-update";
|
|
225
|
+
export type Initializer = (element: ReactiveElement) => void;
|
|
226
|
+
declare global {
|
|
227
|
+
interface SymbolConstructor {
|
|
228
|
+
readonly metadata: unique symbol;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
declare global {
|
|
232
|
+
var litPropertyMetadata: WeakMap<object, Map<PropertyKey, PropertyDeclaration>>;
|
|
233
|
+
}
|
|
234
|
+
declare abstract class ReactiveElement extends HTMLElement implements ReactiveControllerHost {
|
|
235
|
+
/**
|
|
236
|
+
* Read or set all the enabled warning categories for this class.
|
|
237
|
+
*
|
|
238
|
+
* This property is only used in development builds.
|
|
239
|
+
*
|
|
240
|
+
* @nocollapse
|
|
241
|
+
* @category dev-mode
|
|
242
|
+
*/
|
|
243
|
+
static enabledWarnings?: WarningKind[];
|
|
244
|
+
/**
|
|
245
|
+
* Enable the given warning category for this class.
|
|
246
|
+
*
|
|
247
|
+
* This method only exists in development builds, so it should be accessed
|
|
248
|
+
* with a guard like:
|
|
249
|
+
*
|
|
250
|
+
* ```ts
|
|
251
|
+
* // Enable for all ReactiveElement subclasses
|
|
252
|
+
* ReactiveElement.enableWarning?.('migration');
|
|
253
|
+
*
|
|
254
|
+
* // Enable for only MyElement and subclasses
|
|
255
|
+
* MyElement.enableWarning?.('migration');
|
|
256
|
+
* ```
|
|
257
|
+
*
|
|
258
|
+
* @nocollapse
|
|
259
|
+
* @category dev-mode
|
|
260
|
+
*/
|
|
261
|
+
static enableWarning?: (warningKind: WarningKind) => void;
|
|
262
|
+
/**
|
|
263
|
+
* Disable the given warning category for this class.
|
|
264
|
+
*
|
|
265
|
+
* This method only exists in development builds, so it should be accessed
|
|
266
|
+
* with a guard like:
|
|
267
|
+
*
|
|
268
|
+
* ```ts
|
|
269
|
+
* // Disable for all ReactiveElement subclasses
|
|
270
|
+
* ReactiveElement.disableWarning?.('migration');
|
|
271
|
+
*
|
|
272
|
+
* // Disable for only MyElement and subclasses
|
|
273
|
+
* MyElement.disableWarning?.('migration');
|
|
274
|
+
* ```
|
|
275
|
+
*
|
|
276
|
+
* @nocollapse
|
|
277
|
+
* @category dev-mode
|
|
278
|
+
*/
|
|
279
|
+
static disableWarning?: (warningKind: WarningKind) => void;
|
|
280
|
+
/**
|
|
281
|
+
* Adds an initializer function to the class that is called during instance
|
|
282
|
+
* construction.
|
|
283
|
+
*
|
|
284
|
+
* This is useful for code that runs against a `ReactiveElement`
|
|
285
|
+
* subclass, such as a decorator, that needs to do work for each
|
|
286
|
+
* instance, such as setting up a `ReactiveController`.
|
|
287
|
+
*
|
|
288
|
+
* ```ts
|
|
289
|
+
* const myDecorator = (target: typeof ReactiveElement, key: string) => {
|
|
290
|
+
* target.addInitializer((instance: ReactiveElement) => {
|
|
291
|
+
* // This is run during construction of the element
|
|
292
|
+
* new MyController(instance);
|
|
293
|
+
* });
|
|
294
|
+
* }
|
|
295
|
+
* ```
|
|
296
|
+
*
|
|
297
|
+
* Decorating a field will then cause each instance to run an initializer
|
|
298
|
+
* that adds a controller:
|
|
299
|
+
*
|
|
300
|
+
* ```ts
|
|
301
|
+
* class MyElement extends LitElement {
|
|
302
|
+
* @myDecorator foo;
|
|
303
|
+
* }
|
|
304
|
+
* ```
|
|
305
|
+
*
|
|
306
|
+
* Initializers are stored per-constructor. Adding an initializer to a
|
|
307
|
+
* subclass does not add it to a superclass. Since initializers are run in
|
|
308
|
+
* constructors, initializers will run in order of the class hierarchy,
|
|
309
|
+
* starting with superclasses and progressing to the instance's class.
|
|
310
|
+
*
|
|
311
|
+
* @nocollapse
|
|
312
|
+
*/
|
|
313
|
+
static addInitializer(initializer: Initializer): void;
|
|
314
|
+
static _initializers?: Initializer[];
|
|
315
|
+
/**
|
|
316
|
+
* Maps attribute names to properties; for example `foobar` attribute to
|
|
317
|
+
* `fooBar` property. Created lazily on user subclasses when finalizing the
|
|
318
|
+
* class.
|
|
319
|
+
* @nocollapse
|
|
320
|
+
*/
|
|
321
|
+
private static __attributeToPropertyMap;
|
|
322
|
+
/**
|
|
323
|
+
* Marks class as having been finalized, which includes creating properties
|
|
324
|
+
* from `static properties`, but does *not* include all properties created
|
|
325
|
+
* from decorators.
|
|
326
|
+
* @nocollapse
|
|
327
|
+
*/
|
|
328
|
+
protected static finalized: true | undefined;
|
|
329
|
+
/**
|
|
330
|
+
* Memoized list of all element properties, including any superclass
|
|
331
|
+
* properties. Created lazily on user subclasses when finalizing the class.
|
|
332
|
+
*
|
|
333
|
+
* @nocollapse
|
|
334
|
+
* @category properties
|
|
335
|
+
*/
|
|
336
|
+
static elementProperties: PropertyDeclarationMap;
|
|
337
|
+
/**
|
|
338
|
+
* User-supplied object that maps property names to `PropertyDeclaration`
|
|
339
|
+
* objects containing options for configuring reactive properties. When
|
|
340
|
+
* a reactive property is set the element will update and render.
|
|
341
|
+
*
|
|
342
|
+
* By default properties are public fields, and as such, they should be
|
|
343
|
+
* considered as primarily settable by element users, either via attribute or
|
|
344
|
+
* the property itself.
|
|
345
|
+
*
|
|
346
|
+
* Generally, properties that are changed by the element should be private or
|
|
347
|
+
* protected fields and should use the `state: true` option. Properties
|
|
348
|
+
* marked as `state` do not reflect from the corresponding attribute
|
|
349
|
+
*
|
|
350
|
+
* However, sometimes element code does need to set a public property. This
|
|
351
|
+
* should typically only be done in response to user interaction, and an event
|
|
352
|
+
* should be fired informing the user; for example, a checkbox sets its
|
|
353
|
+
* `checked` property when clicked and fires a `changed` event. Mutating
|
|
354
|
+
* public properties should typically not be done for non-primitive (object or
|
|
355
|
+
* array) properties. In other cases when an element needs to manage state, a
|
|
356
|
+
* private property set with the `state: true` option should be used. When
|
|
357
|
+
* needed, state properties can be initialized via public properties to
|
|
358
|
+
* facilitate complex interactions.
|
|
359
|
+
* @nocollapse
|
|
360
|
+
* @category properties
|
|
361
|
+
*/
|
|
362
|
+
static properties: PropertyDeclarations;
|
|
363
|
+
/**
|
|
364
|
+
* Memoized list of all element styles.
|
|
365
|
+
* Created lazily on user subclasses when finalizing the class.
|
|
366
|
+
* @nocollapse
|
|
367
|
+
* @category styles
|
|
368
|
+
*/
|
|
369
|
+
static elementStyles: Array<CSSResultOrNative>;
|
|
370
|
+
/**
|
|
371
|
+
* Array of styles to apply to the element. The styles should be defined
|
|
372
|
+
* using the {@linkcode css} tag function, via constructible stylesheets, or
|
|
373
|
+
* imported from native CSS module scripts.
|
|
374
|
+
*
|
|
375
|
+
* Note on Content Security Policy:
|
|
376
|
+
*
|
|
377
|
+
* Element styles are implemented with `<style>` tags when the browser doesn't
|
|
378
|
+
* support adopted StyleSheets. To use such `<style>` tags with the style-src
|
|
379
|
+
* CSP directive, the style-src value must either include 'unsafe-inline' or
|
|
380
|
+
* `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated
|
|
381
|
+
* nonce.
|
|
382
|
+
*
|
|
383
|
+
* To provide a nonce to use on generated `<style>` elements, set
|
|
384
|
+
* `window.litNonce` to a server-generated nonce in your page's HTML, before
|
|
385
|
+
* loading application code:
|
|
386
|
+
*
|
|
387
|
+
* ```html
|
|
388
|
+
* <script>
|
|
389
|
+
* // Generated and unique per request:
|
|
390
|
+
* window.litNonce = 'a1b2c3d4';
|
|
391
|
+
* </script>
|
|
392
|
+
* ```
|
|
393
|
+
* @nocollapse
|
|
394
|
+
* @category styles
|
|
395
|
+
*/
|
|
396
|
+
static styles?: CSSResultGroup;
|
|
397
|
+
/**
|
|
398
|
+
* Returns a list of attributes corresponding to the registered properties.
|
|
399
|
+
* @nocollapse
|
|
400
|
+
* @category attributes
|
|
401
|
+
*/
|
|
402
|
+
static get observedAttributes(): string[];
|
|
403
|
+
private __instanceProperties?;
|
|
404
|
+
/**
|
|
405
|
+
* Creates a property accessor on the element prototype if one does not exist
|
|
406
|
+
* and stores a {@linkcode PropertyDeclaration} for the property with the
|
|
407
|
+
* given options. The property setter calls the property's `hasChanged`
|
|
408
|
+
* property option or uses a strict identity check to determine whether or not
|
|
409
|
+
* to request an update.
|
|
410
|
+
*
|
|
411
|
+
* This method may be overridden to customize properties; however,
|
|
412
|
+
* when doing so, it's important to call `super.createProperty` to ensure
|
|
413
|
+
* the property is setup correctly. This method calls
|
|
414
|
+
* `getPropertyDescriptor` internally to get a descriptor to install.
|
|
415
|
+
* To customize what properties do when they are get or set, override
|
|
416
|
+
* `getPropertyDescriptor`. To customize the options for a property,
|
|
417
|
+
* implement `createProperty` like this:
|
|
418
|
+
*
|
|
419
|
+
* ```ts
|
|
420
|
+
* static createProperty(name, options) {
|
|
421
|
+
* options = Object.assign(options, {myOption: true});
|
|
422
|
+
* super.createProperty(name, options);
|
|
423
|
+
* }
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @nocollapse
|
|
427
|
+
* @category properties
|
|
428
|
+
*/
|
|
429
|
+
static createProperty(name: PropertyKey, options?: PropertyDeclaration): void;
|
|
430
|
+
/**
|
|
431
|
+
* Returns a property descriptor to be defined on the given named property.
|
|
432
|
+
* If no descriptor is returned, the property will not become an accessor.
|
|
433
|
+
* For example,
|
|
434
|
+
*
|
|
435
|
+
* ```ts
|
|
436
|
+
* class MyElement extends LitElement {
|
|
437
|
+
* static getPropertyDescriptor(name, key, options) {
|
|
438
|
+
* const defaultDescriptor =
|
|
439
|
+
* super.getPropertyDescriptor(name, key, options);
|
|
440
|
+
* const setter = defaultDescriptor.set;
|
|
441
|
+
* return {
|
|
442
|
+
* get: defaultDescriptor.get,
|
|
443
|
+
* set(value) {
|
|
444
|
+
* setter.call(this, value);
|
|
445
|
+
* // custom action.
|
|
446
|
+
* },
|
|
447
|
+
* configurable: true,
|
|
448
|
+
* enumerable: true
|
|
449
|
+
* }
|
|
450
|
+
* }
|
|
451
|
+
* }
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* @nocollapse
|
|
455
|
+
* @category properties
|
|
456
|
+
*/
|
|
457
|
+
protected static getPropertyDescriptor(name: PropertyKey, key: string | symbol, options: PropertyDeclaration): PropertyDescriptor | undefined;
|
|
458
|
+
/**
|
|
459
|
+
* Returns the property options associated with the given property.
|
|
460
|
+
* These options are defined with a `PropertyDeclaration` via the `properties`
|
|
461
|
+
* object or the `@property` decorator and are registered in
|
|
462
|
+
* `createProperty(...)`.
|
|
463
|
+
*
|
|
464
|
+
* Note, this method should be considered "final" and not overridden. To
|
|
465
|
+
* customize the options for a given property, override
|
|
466
|
+
* {@linkcode createProperty}.
|
|
467
|
+
*
|
|
468
|
+
* @nocollapse
|
|
469
|
+
* @final
|
|
470
|
+
* @category properties
|
|
471
|
+
*/
|
|
472
|
+
static getPropertyOptions(name: PropertyKey): PropertyDeclaration<unknown, unknown>;
|
|
473
|
+
static [Symbol.metadata]: object & Record<PropertyKey, unknown>;
|
|
474
|
+
/**
|
|
475
|
+
* Initializes static own properties of the class used in bookkeeping
|
|
476
|
+
* for element properties, initializers, etc.
|
|
477
|
+
*
|
|
478
|
+
* Can be called multiple times by code that needs to ensure these
|
|
479
|
+
* properties exist before using them.
|
|
480
|
+
*
|
|
481
|
+
* This method ensures the superclass is finalized so that inherited
|
|
482
|
+
* property metadata can be copied down.
|
|
483
|
+
* @nocollapse
|
|
484
|
+
*/
|
|
485
|
+
private static __prepare;
|
|
486
|
+
/**
|
|
487
|
+
* Finishes setting up the class so that it's ready to be registered
|
|
488
|
+
* as a custom element and instantiated.
|
|
489
|
+
*
|
|
490
|
+
* This method is called by the ReactiveElement.observedAttributes getter.
|
|
491
|
+
* If you override the observedAttributes getter, you must either call
|
|
492
|
+
* super.observedAttributes to trigger finalization, or call finalize()
|
|
493
|
+
* yourself.
|
|
494
|
+
*
|
|
495
|
+
* @nocollapse
|
|
496
|
+
*/
|
|
497
|
+
protected static finalize(): void;
|
|
498
|
+
/**
|
|
499
|
+
* Options used when calling `attachShadow`. Set this property to customize
|
|
500
|
+
* the options for the shadowRoot; for example, to create a closed
|
|
501
|
+
* shadowRoot: `{mode: 'closed'}`.
|
|
502
|
+
*
|
|
503
|
+
* Note, these options are used in `createRenderRoot`. If this method
|
|
504
|
+
* is customized, options should be respected if possible.
|
|
505
|
+
* @nocollapse
|
|
506
|
+
* @category rendering
|
|
507
|
+
*/
|
|
508
|
+
static shadowRootOptions: ShadowRootInit;
|
|
509
|
+
/**
|
|
510
|
+
* Takes the styles the user supplied via the `static styles` property and
|
|
511
|
+
* returns the array of styles to apply to the element.
|
|
512
|
+
* Override this method to integrate into a style management system.
|
|
513
|
+
*
|
|
514
|
+
* Styles are deduplicated preserving the _last_ instance in the list. This
|
|
515
|
+
* is a performance optimization to avoid duplicated styles that can occur
|
|
516
|
+
* especially when composing via subclassing. The last item is kept to try
|
|
517
|
+
* to preserve the cascade order with the assumption that it's most important
|
|
518
|
+
* that last added styles override previous styles.
|
|
519
|
+
*
|
|
520
|
+
* @nocollapse
|
|
521
|
+
* @category styles
|
|
522
|
+
*/
|
|
523
|
+
protected static finalizeStyles(styles?: CSSResultGroup): Array<CSSResultOrNative>;
|
|
524
|
+
/**
|
|
525
|
+
* Node or ShadowRoot into which element DOM should be rendered. Defaults
|
|
526
|
+
* to an open shadowRoot.
|
|
527
|
+
* @category rendering
|
|
528
|
+
*/
|
|
529
|
+
readonly renderRoot: HTMLElement | DocumentFragment;
|
|
530
|
+
/**
|
|
531
|
+
* Returns the property name for the given attribute `name`.
|
|
532
|
+
* @nocollapse
|
|
533
|
+
*/
|
|
534
|
+
private static __attributeNameForProperty;
|
|
535
|
+
private __updatePromise;
|
|
536
|
+
/**
|
|
537
|
+
* True if there is a pending update as a result of calling `requestUpdate()`.
|
|
538
|
+
* Should only be read.
|
|
539
|
+
* @category updates
|
|
540
|
+
*/
|
|
541
|
+
isUpdatePending: boolean;
|
|
542
|
+
/**
|
|
543
|
+
* Is set to `true` after the first update. The element code cannot assume
|
|
544
|
+
* that `renderRoot` exists before the element `hasUpdated`.
|
|
545
|
+
* @category updates
|
|
546
|
+
*/
|
|
547
|
+
hasUpdated: boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Properties that should be reflected when updated.
|
|
550
|
+
*/
|
|
551
|
+
private __reflectingProperties?;
|
|
552
|
+
/**
|
|
553
|
+
* Name of currently reflecting property
|
|
554
|
+
*/
|
|
555
|
+
private __reflectingProperty;
|
|
556
|
+
/**
|
|
557
|
+
* Set of controllers.
|
|
558
|
+
*/
|
|
559
|
+
private __controllers?;
|
|
560
|
+
constructor();
|
|
561
|
+
/**
|
|
562
|
+
* Internal only override point for customizing work done when elements
|
|
563
|
+
* are constructed.
|
|
564
|
+
*/
|
|
565
|
+
private __initialize;
|
|
566
|
+
/**
|
|
567
|
+
* Registers a `ReactiveController` to participate in the element's reactive
|
|
568
|
+
* update cycle. The element automatically calls into any registered
|
|
569
|
+
* controllers during its lifecycle callbacks.
|
|
570
|
+
*
|
|
571
|
+
* If the element is connected when `addController()` is called, the
|
|
572
|
+
* controller's `hostConnected()` callback will be immediately called.
|
|
573
|
+
* @category controllers
|
|
574
|
+
*/
|
|
575
|
+
addController(controller: ReactiveController): void;
|
|
576
|
+
/**
|
|
577
|
+
* Removes a `ReactiveController` from the element.
|
|
578
|
+
* @category controllers
|
|
579
|
+
*/
|
|
580
|
+
removeController(controller: ReactiveController): void;
|
|
581
|
+
/**
|
|
582
|
+
* Fixes any properties set on the instance before upgrade time.
|
|
583
|
+
* Otherwise these would shadow the accessor and break these properties.
|
|
584
|
+
* The properties are stored in a Map which is played back after the
|
|
585
|
+
* constructor runs. Note, on very old versions of Safari (<=9) or Chrome
|
|
586
|
+
* (<=41), properties created for native platform properties like (`id` or
|
|
587
|
+
* `name`) may not have default values set in the element constructor. On
|
|
588
|
+
* these browsers native properties appear on instances and therefore their
|
|
589
|
+
* default value will overwrite any element default (e.g. if the element sets
|
|
590
|
+
* this.id = 'id' in the constructor, the 'id' will become '' since this is
|
|
591
|
+
* the native platform default).
|
|
592
|
+
*/
|
|
593
|
+
private __saveInstanceProperties;
|
|
594
|
+
/**
|
|
595
|
+
* Returns the node into which the element should render and by default
|
|
596
|
+
* creates and returns an open shadowRoot. Implement to customize where the
|
|
597
|
+
* element's DOM is rendered. For example, to render into the element's
|
|
598
|
+
* childNodes, return `this`.
|
|
599
|
+
*
|
|
600
|
+
* @return Returns a node into which to render.
|
|
601
|
+
* @category rendering
|
|
602
|
+
*/
|
|
603
|
+
protected createRenderRoot(): HTMLElement | DocumentFragment;
|
|
604
|
+
/**
|
|
605
|
+
* On first connection, creates the element's renderRoot, sets up
|
|
606
|
+
* element styling, and enables updating.
|
|
607
|
+
* @category lifecycle
|
|
608
|
+
*/
|
|
609
|
+
connectedCallback(): void;
|
|
610
|
+
/**
|
|
611
|
+
* Note, this method should be considered final and not overridden. It is
|
|
612
|
+
* overridden on the element instance with a function that triggers the first
|
|
613
|
+
* update.
|
|
614
|
+
* @category updates
|
|
615
|
+
*/
|
|
616
|
+
protected enableUpdating(_requestedUpdate: boolean): void;
|
|
617
|
+
/**
|
|
618
|
+
* Allows for `super.disconnectedCallback()` in extensions while
|
|
619
|
+
* reserving the possibility of making non-breaking feature additions
|
|
620
|
+
* when disconnecting at some point in the future.
|
|
621
|
+
* @category lifecycle
|
|
622
|
+
*/
|
|
623
|
+
disconnectedCallback(): void;
|
|
624
|
+
/**
|
|
625
|
+
* Synchronizes property values when attributes change.
|
|
626
|
+
*
|
|
627
|
+
* Specifically, when an attribute is set, the corresponding property is set.
|
|
628
|
+
* You should rarely need to implement this callback. If this method is
|
|
629
|
+
* overridden, `super.attributeChangedCallback(name, _old, value)` must be
|
|
630
|
+
* called.
|
|
631
|
+
*
|
|
632
|
+
* See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)
|
|
633
|
+
* on MDN for more information about the `attributeChangedCallback`.
|
|
634
|
+
* @category attributes
|
|
635
|
+
*/
|
|
636
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
637
|
+
private __propertyToAttribute;
|
|
638
|
+
/**
|
|
639
|
+
* Requests an update which is processed asynchronously. This should be called
|
|
640
|
+
* when an element should update based on some state not triggered by setting
|
|
641
|
+
* a reactive property. In this case, pass no arguments. It should also be
|
|
642
|
+
* called when manually implementing a property setter. In this case, pass the
|
|
643
|
+
* property `name` and `oldValue` to ensure that any configured property
|
|
644
|
+
* options are honored.
|
|
645
|
+
*
|
|
646
|
+
* @param name name of requesting property
|
|
647
|
+
* @param oldValue old value of requesting property
|
|
648
|
+
* @param options property options to use instead of the previously
|
|
649
|
+
* configured options
|
|
650
|
+
* @category updates
|
|
651
|
+
*/
|
|
652
|
+
requestUpdate(name?: PropertyKey, oldValue?: unknown, options?: PropertyDeclaration): void;
|
|
653
|
+
/**
|
|
654
|
+
* Sets up the element to asynchronously update.
|
|
655
|
+
*/
|
|
656
|
+
private __enqueueUpdate;
|
|
657
|
+
/**
|
|
658
|
+
* Schedules an element update. You can override this method to change the
|
|
659
|
+
* timing of updates by returning a Promise. The update will await the
|
|
660
|
+
* returned Promise, and you should resolve the Promise to allow the update
|
|
661
|
+
* to proceed. If this method is overridden, `super.scheduleUpdate()`
|
|
662
|
+
* must be called.
|
|
663
|
+
*
|
|
664
|
+
* For instance, to schedule updates to occur just before the next frame:
|
|
665
|
+
*
|
|
666
|
+
* ```ts
|
|
667
|
+
* override protected async scheduleUpdate(): Promise<unknown> {
|
|
668
|
+
* await new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
669
|
+
* super.scheduleUpdate();
|
|
670
|
+
* }
|
|
671
|
+
* ```
|
|
672
|
+
* @category updates
|
|
673
|
+
*/
|
|
674
|
+
protected scheduleUpdate(): void | Promise<unknown>;
|
|
675
|
+
/**
|
|
676
|
+
* Performs an element update. Note, if an exception is thrown during the
|
|
677
|
+
* update, `firstUpdated` and `updated` will not be called.
|
|
678
|
+
*
|
|
679
|
+
* Call `performUpdate()` to immediately process a pending update. This should
|
|
680
|
+
* generally not be needed, but it can be done in rare cases when you need to
|
|
681
|
+
* update synchronously.
|
|
682
|
+
*
|
|
683
|
+
* @category updates
|
|
684
|
+
*/
|
|
685
|
+
protected performUpdate(): void;
|
|
686
|
+
/**
|
|
687
|
+
* Invoked before `update()` to compute values needed during the update.
|
|
688
|
+
*
|
|
689
|
+
* Implement `willUpdate` to compute property values that depend on other
|
|
690
|
+
* properties and are used in the rest of the update process.
|
|
691
|
+
*
|
|
692
|
+
* ```ts
|
|
693
|
+
* willUpdate(changedProperties) {
|
|
694
|
+
* // only need to check changed properties for an expensive computation.
|
|
695
|
+
* if (changedProperties.has('firstName') || changedProperties.has('lastName')) {
|
|
696
|
+
* this.sha = computeSHA(`${this.firstName} ${this.lastName}`);
|
|
697
|
+
* }
|
|
698
|
+
* }
|
|
699
|
+
*
|
|
700
|
+
* render() {
|
|
701
|
+
* return html`SHA: ${this.sha}`;
|
|
702
|
+
* }
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
705
|
+
* @category updates
|
|
706
|
+
*/
|
|
707
|
+
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
708
|
+
private __markUpdated;
|
|
709
|
+
/**
|
|
710
|
+
* Returns a Promise that resolves when the element has completed updating.
|
|
711
|
+
* The Promise value is a boolean that is `true` if the element completed the
|
|
712
|
+
* update without triggering another update. The Promise result is `false` if
|
|
713
|
+
* a property was set inside `updated()`. If the Promise is rejected, an
|
|
714
|
+
* exception was thrown during the update.
|
|
715
|
+
*
|
|
716
|
+
* To await additional asynchronous work, override the `getUpdateComplete`
|
|
717
|
+
* method. For example, it is sometimes useful to await a rendered element
|
|
718
|
+
* before fulfilling this Promise. To do this, first await
|
|
719
|
+
* `super.getUpdateComplete()`, then any subsequent state.
|
|
720
|
+
*
|
|
721
|
+
* @return A promise of a boolean that resolves to true if the update completed
|
|
722
|
+
* without triggering another update.
|
|
723
|
+
* @category updates
|
|
724
|
+
*/
|
|
725
|
+
get updateComplete(): Promise<boolean>;
|
|
726
|
+
/**
|
|
727
|
+
* Override point for the `updateComplete` promise.
|
|
728
|
+
*
|
|
729
|
+
* It is not safe to override the `updateComplete` getter directly due to a
|
|
730
|
+
* limitation in TypeScript which means it is not possible to call a
|
|
731
|
+
* superclass getter (e.g. `super.updateComplete.then(...)`) when the target
|
|
732
|
+
* language is ES5 (https://github.com/microsoft/TypeScript/issues/338).
|
|
733
|
+
* This method should be overridden instead. For example:
|
|
734
|
+
*
|
|
735
|
+
* ```ts
|
|
736
|
+
* class MyElement extends LitElement {
|
|
737
|
+
* override async getUpdateComplete() {
|
|
738
|
+
* const result = await super.getUpdateComplete();
|
|
739
|
+
* await this._myChild.updateComplete;
|
|
740
|
+
* return result;
|
|
741
|
+
* }
|
|
742
|
+
* }
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @return A promise of a boolean that resolves to true if the update completed
|
|
746
|
+
* without triggering another update.
|
|
747
|
+
* @category updates
|
|
748
|
+
*/
|
|
749
|
+
protected getUpdateComplete(): Promise<boolean>;
|
|
750
|
+
/**
|
|
751
|
+
* Controls whether or not `update()` should be called when the element requests
|
|
752
|
+
* an update. By default, this method always returns `true`, but this can be
|
|
753
|
+
* customized to control when to update.
|
|
754
|
+
*
|
|
755
|
+
* @param _changedProperties Map of changed properties with old values
|
|
756
|
+
* @category updates
|
|
757
|
+
*/
|
|
758
|
+
protected shouldUpdate(_changedProperties: PropertyValues): boolean;
|
|
759
|
+
/**
|
|
760
|
+
* Updates the element. This method reflects property values to attributes.
|
|
761
|
+
* It can be overridden to render and keep updated element DOM.
|
|
762
|
+
* Setting properties inside this method will *not* trigger
|
|
763
|
+
* another update.
|
|
764
|
+
*
|
|
765
|
+
* @param _changedProperties Map of changed properties with old values
|
|
766
|
+
* @category updates
|
|
767
|
+
*/
|
|
768
|
+
protected update(_changedProperties: PropertyValues): void;
|
|
769
|
+
/**
|
|
770
|
+
* Invoked whenever the element is updated. Implement to perform
|
|
771
|
+
* post-updating tasks via DOM APIs, for example, focusing an element.
|
|
772
|
+
*
|
|
773
|
+
* Setting properties inside this method will trigger the element to update
|
|
774
|
+
* again after this update cycle completes.
|
|
775
|
+
*
|
|
776
|
+
* @param _changedProperties Map of changed properties with old values
|
|
777
|
+
* @category updates
|
|
778
|
+
*/
|
|
779
|
+
protected updated(_changedProperties: PropertyValues): void;
|
|
780
|
+
/**
|
|
781
|
+
* Invoked when the element is first updated. Implement to perform one time
|
|
782
|
+
* work on the element after update.
|
|
783
|
+
*
|
|
784
|
+
* ```ts
|
|
785
|
+
* firstUpdated() {
|
|
786
|
+
* this.renderRoot.getElementById('my-text-area').focus();
|
|
787
|
+
* }
|
|
788
|
+
* ```
|
|
789
|
+
*
|
|
790
|
+
* Setting properties inside this method will trigger the element to update
|
|
791
|
+
* again after this update cycle completes.
|
|
792
|
+
*
|
|
793
|
+
* @param _changedProperties Map of changed properties with old values
|
|
794
|
+
* @category updates
|
|
795
|
+
*/
|
|
796
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
797
|
+
}
|
|
798
|
+
declare const HTML_RESULT = 1;
|
|
799
|
+
declare const SVG_RESULT = 2;
|
|
800
|
+
declare const MATHML_RESULT = 3;
|
|
801
|
+
export type ResultType = typeof HTML_RESULT | typeof SVG_RESULT | typeof MATHML_RESULT;
|
|
802
|
+
/**
|
|
803
|
+
* The return type of the template tag functions, {@linkcode html} and
|
|
804
|
+
* {@linkcode svg} when it hasn't been compiled by @lit-labs/compiler.
|
|
805
|
+
*
|
|
806
|
+
* A `TemplateResult` object holds all the information about a template
|
|
807
|
+
* expression required to render it: the template strings, expression values,
|
|
808
|
+
* and type of template (html or svg).
|
|
809
|
+
*
|
|
810
|
+
* `TemplateResult` objects do not create any DOM on their own. To create or
|
|
811
|
+
* update DOM you need to render the `TemplateResult`. See
|
|
812
|
+
* [Rendering](https://lit.dev/docs/components/rendering) for more information.
|
|
813
|
+
*
|
|
814
|
+
*/
|
|
815
|
+
export type UncompiledTemplateResult<T extends ResultType = ResultType> = {
|
|
816
|
+
["_$litType$"]: T;
|
|
817
|
+
strings: TemplateStringsArray;
|
|
818
|
+
values: unknown[];
|
|
819
|
+
};
|
|
820
|
+
/**
|
|
821
|
+
* The return type of the template tag functions, {@linkcode html} and
|
|
822
|
+
* {@linkcode svg}.
|
|
823
|
+
*
|
|
824
|
+
* A `TemplateResult` object holds all the information about a template
|
|
825
|
+
* expression required to render it: the template strings, expression values,
|
|
826
|
+
* and type of template (html or svg).
|
|
827
|
+
*
|
|
828
|
+
* `TemplateResult` objects do not create any DOM on their own. To create or
|
|
829
|
+
* update DOM you need to render the `TemplateResult`. See
|
|
830
|
+
* [Rendering](https://lit.dev/docs/components/rendering) for more information.
|
|
831
|
+
*
|
|
832
|
+
* In Lit 4, this type will be an alias of
|
|
833
|
+
* MaybeCompiledTemplateResult, so that code will get type errors if it assumes
|
|
834
|
+
* that Lit templates are not compiled. When deliberately working with only
|
|
835
|
+
* one, use either {@linkcode CompiledTemplateResult} or
|
|
836
|
+
* {@linkcode UncompiledTemplateResult} explicitly.
|
|
837
|
+
*/
|
|
838
|
+
export type TemplateResult<T extends ResultType = ResultType> = UncompiledTemplateResult<T>;
|
|
839
|
+
export type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;
|
|
840
|
+
declare const nothing: unique symbol;
|
|
841
|
+
/**
|
|
842
|
+
* Object specifying options for controlling lit-html rendering. Note that
|
|
843
|
+
* while `render` may be called multiple times on the same `container` (and
|
|
844
|
+
* `renderBefore` reference node) to efficiently update the rendered content,
|
|
845
|
+
* only the options passed in during the first render are respected during
|
|
846
|
+
* the lifetime of renders to that unique `container` + `renderBefore`
|
|
847
|
+
* combination.
|
|
848
|
+
*/
|
|
849
|
+
export interface RenderOptions {
|
|
850
|
+
/**
|
|
851
|
+
* An object to use as the `this` value for event listeners. It's often
|
|
852
|
+
* useful to set this to the host component rendering a template.
|
|
853
|
+
*/
|
|
854
|
+
host?: object;
|
|
855
|
+
/**
|
|
856
|
+
* A DOM node before which to render content in the container.
|
|
857
|
+
*/
|
|
858
|
+
renderBefore?: ChildNode | null;
|
|
859
|
+
/**
|
|
860
|
+
* Node used for cloning the template (`importNode` will be called on this
|
|
861
|
+
* node). This controls the `ownerDocument` of the rendered DOM, along with
|
|
862
|
+
* any inherited context. Defaults to the global `document`.
|
|
863
|
+
*/
|
|
864
|
+
creationScope?: {
|
|
865
|
+
importNode(node: Node, deep?: boolean): Node;
|
|
866
|
+
};
|
|
867
|
+
/**
|
|
868
|
+
* The initial connected state for the top-level part being rendered. If no
|
|
869
|
+
* `isConnected` option is set, `AsyncDirective`s will be connected by
|
|
870
|
+
* default. Set to `false` if the initial render occurs in a disconnected tree
|
|
871
|
+
* and `AsyncDirective`s should see `isConnected === false` for their initial
|
|
872
|
+
* render. The `part.setConnected()` method must be used subsequent to initial
|
|
873
|
+
* render to change the connected state of the part.
|
|
874
|
+
*/
|
|
875
|
+
isConnected?: boolean;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* @description Defines the API version that the SDK should use.
|
|
879
|
+
* - `"legacy"`: Uses the older API version with existing behaviors.
|
|
880
|
+
* - `"2.4"`: Uses the new API version with updated functionalities.
|
|
881
|
+
*
|
|
882
|
+
* If this value is not set, the SDK will default to the predefined version,
|
|
883
|
+
* ensuring backward compatibility.
|
|
884
|
+
*/
|
|
885
|
+
export type APIVersionOption = "legacy" | "2.4";
|
|
886
|
+
declare const PaymentInstrumentType: {
|
|
887
|
+
readonly WORLDPAY_IDEAL: "WORLDPAY_IDEAL";
|
|
888
|
+
readonly AUTOMATED_CLEARING_HOUSE: "AUTOMATED_CLEARING_HOUSE";
|
|
889
|
+
readonly ADYEN_KLARNA: "ADYEN_KLARNA";
|
|
890
|
+
readonly ADYEN_BANCONTACT_CARD: "ADYEN_BANCONTACT_CARD";
|
|
891
|
+
readonly PAY_NL_KAARTDIRECT: "PAY_NL_KAARTDIRECT";
|
|
892
|
+
readonly ADYEN_EPS: "ADYEN_EPS";
|
|
893
|
+
readonly ADYEN_BANCONTACT_PAYCONIQ: "ADYEN_BANCONTACT_PAYCONIQ";
|
|
894
|
+
readonly OMISE_PROMPTPAY: "OMISE_PROMPTPAY";
|
|
895
|
+
readonly OMISE_TRUEMONEY: "OMISE_TRUEMONEY";
|
|
896
|
+
readonly ADYEN_MULTIBANCO: "ADYEN_MULTIBANCO";
|
|
897
|
+
readonly PACYPAY_WECHAT: "PACYPAY_WECHAT";
|
|
898
|
+
readonly PACYPAY_ALIPAY: "PACYPAY_ALIPAY";
|
|
899
|
+
readonly ADYEN_MBWAY: "ADYEN_MBWAY";
|
|
900
|
+
readonly XENDIT_DANA: "XENDIT_DANA";
|
|
901
|
+
readonly XENDIT_SHOPEEPAY: "XENDIT_SHOPEEPAY";
|
|
902
|
+
readonly ADYEN_PAYSHOP: "ADYEN_PAYSHOP";
|
|
903
|
+
readonly ADYEN_PAYTRAIL: "ADYEN_PAYTRAIL";
|
|
904
|
+
readonly CLEARPAY: "CLEARPAY";
|
|
905
|
+
readonly RAPYD_FAST: "RAPYD_FAST";
|
|
906
|
+
readonly RAPYD_PROMPTPAY: "RAPYD_PROMPTPAY";
|
|
907
|
+
readonly RAPYD_GCASH: "RAPYD_GCASH";
|
|
908
|
+
readonly RAPYD_POLI: "RAPYD_POLI";
|
|
909
|
+
readonly RAPYD_GRABPAY: "RAPYD_GRABPAY";
|
|
910
|
+
readonly PRIMER_PAYPAL: "PRIMER_PAYPAL";
|
|
911
|
+
readonly TWOC2P: "TWOC2P";
|
|
912
|
+
readonly NETS: "NETS";
|
|
913
|
+
readonly STRIPE_ACH: "STRIPE_ACH";
|
|
914
|
+
readonly STRIPE_GIROPAY: "STRIPE_GIROPAY";
|
|
915
|
+
readonly MOLLIE_GIROPAY: "MOLLIE_GIROPAY";
|
|
916
|
+
readonly MOLLIE_EPS: "MOLLIE_EPS";
|
|
917
|
+
readonly PAY_NL_EPS: "PAY_NL_EPS";
|
|
918
|
+
readonly PAY_NL_P24: "PAY_NL_P24";
|
|
919
|
+
readonly MOLLIE_P24: "MOLLIE_P24";
|
|
920
|
+
readonly MOLLIE_SOFORT: "MOLLIE_SOFORT";
|
|
921
|
+
readonly COINBASE: "COINBASE";
|
|
922
|
+
readonly OPENNODE: "OPENNODE";
|
|
923
|
+
readonly MOLLIE_GIFT_CARD: "MOLLIE_GIFTCARD";
|
|
924
|
+
readonly XFERS_PAYNOW: "XFERS_PAYNOW";
|
|
925
|
+
readonly CARD: "PAYMENT_CARD";
|
|
926
|
+
readonly APPLE_PAY: "APPLE_PAY";
|
|
927
|
+
readonly GOOGLE_PAY: "GOOGLE_PAY";
|
|
928
|
+
readonly PAYPAL: "PAYPAL_ORDER";
|
|
929
|
+
readonly PAYPAL_VAULTED: "PAYPAL_BILLING_AGREEMENT";
|
|
930
|
+
readonly GO_CARDLESS: "GOCARDLESS";
|
|
931
|
+
readonly PAY_NL_IDEAL: "PAY_NL_IDEAL";
|
|
932
|
+
readonly PAY_NL_SOFORT_BANKING: "PAY_NL_SOFORT_BANKING";
|
|
933
|
+
readonly PAY_NL_BANCONTACT: "PAY_NL_BANCONTACT";
|
|
934
|
+
readonly PAY_NL_PAYPAL: "PAY_NL_PAYPAL";
|
|
935
|
+
readonly PAY_NL_CREDIT_TRANSFER: "PAY_NL_CREDIT_TRANSFER";
|
|
936
|
+
readonly PAY_NL_DIRECT_DEBIT: "PAY_NL_DIRECT_DEBIT";
|
|
937
|
+
readonly PAY_NL_GIROPAY: "PAY_NL_GIROPAY";
|
|
938
|
+
readonly PAY_NL_PAYCONIQ: "PAY_NL_PAYCONIQ";
|
|
939
|
+
readonly HOOLAH: "HOOLAH";
|
|
940
|
+
readonly ADYEN_BLIK: "ADYEN_BLIK";
|
|
941
|
+
readonly ADYEN_VIPPS: "ADYEN_VIPPS";
|
|
942
|
+
readonly ADYEN_GIROPAY: "ADYEN_GIROPAY";
|
|
943
|
+
readonly ADYEN_SOFORT: "ADYEN_SOFORT";
|
|
944
|
+
readonly ADYEN_IDEAL: "ADYEN_IDEAL";
|
|
945
|
+
readonly ADYEN_TRUSTLY: "ADYEN_TRUSTLY";
|
|
946
|
+
readonly ADYEN_ALIPAY: "ADYEN_ALIPAY";
|
|
947
|
+
readonly ADYEN_TWINT: "ADYEN_TWINT";
|
|
948
|
+
readonly ADYEN_MOBILEPAY: "ADYEN_MOBILEPAY";
|
|
949
|
+
readonly MOLLIE_BANCONTACT: "MOLLIE_BANCONTACT";
|
|
950
|
+
readonly MOLLIE_IDEAL: "MOLLIE_IDEAL";
|
|
951
|
+
readonly BUCKAROO_GIROPAY: "BUCKAROO_GIROPAY";
|
|
952
|
+
readonly BUCKAROO_EPS: "BUCKAROO_EPS";
|
|
953
|
+
readonly BUCKAROO_SOFORT: "BUCKAROO_SOFORT";
|
|
954
|
+
readonly BUCKAROO_BANCONTACT: "BUCKAROO_BANCONTACT";
|
|
955
|
+
readonly BUCKAROO_IDEAL: "BUCKAROO_IDEAL";
|
|
956
|
+
readonly ATOME: "ATOME";
|
|
957
|
+
readonly KLARNA_CUSTOMER_TOKEN: "KLARNA_CUSTOMER_TOKEN";
|
|
958
|
+
};
|
|
959
|
+
export type PaymentInstrumentType = (typeof PaymentInstrumentType)[keyof typeof PaymentInstrumentType];
|
|
960
|
+
declare const PaymentMethodType: {
|
|
961
|
+
readonly WORLDPAY_IDEAL: "WORLDPAY_IDEAL";
|
|
962
|
+
readonly STRIPE_ACH: "STRIPE_ACH";
|
|
963
|
+
readonly STRIPE_IDEAL: "STRIPE_IDEAL";
|
|
964
|
+
readonly ADYEN_KLARNA: "ADYEN_KLARNA";
|
|
965
|
+
readonly ADYEN_BANCONTACT_CARD: "ADYEN_BANCONTACT_CARD";
|
|
966
|
+
readonly PAY_NL_KAARTDIRECT: "PAY_NL_KAARTDIRECT";
|
|
967
|
+
readonly ADYEN_EPS: "ADYEN_EPS";
|
|
968
|
+
readonly ADYEN_BANCONTACT_PAYCONIQ: "ADYEN_BANCONTACT_PAYCONIQ";
|
|
969
|
+
readonly OMISE_PROMPTPAY: "OMISE_PROMPTPAY";
|
|
970
|
+
readonly OMISE_TRUEMONEY: "OMISE_TRUEMONEY";
|
|
971
|
+
readonly ADYEN_MULTIBANCO: "ADYEN_MULTIBANCO";
|
|
972
|
+
readonly PACYPAY_WECHAT: "PACYPAY_WECHAT";
|
|
973
|
+
readonly PACYPAY_ALIPAY: "PACYPAY_ALIPAY";
|
|
974
|
+
readonly ADYEN_MBWAY: "ADYEN_MBWAY";
|
|
975
|
+
readonly XENDIT_DANA: "XENDIT_DANA";
|
|
976
|
+
readonly XENDIT_SHOPEEPAY: "XENDIT_SHOPEEPAY";
|
|
977
|
+
readonly ADYEN_PAYSHOP: "ADYEN_PAYSHOP";
|
|
978
|
+
readonly ADYEN_PAYTRAIL: "ADYEN_PAYTRAIL";
|
|
979
|
+
readonly CLEARPAY: "CLEARPAY";
|
|
980
|
+
readonly RAPYD_FAST: "RAPYD_FAST";
|
|
981
|
+
readonly RAPYD_PROMPTPAY: "RAPYD_PROMPTPAY";
|
|
982
|
+
readonly RAPYD_GCASH: "RAPYD_GCASH";
|
|
983
|
+
readonly RAPYD_POLI: "RAPYD_POLI";
|
|
984
|
+
readonly RAPYD_GRABPAY: "RAPYD_GRABPAY";
|
|
985
|
+
readonly PRIMER_PAYPAL: "PRIMER_PAYPAL";
|
|
986
|
+
readonly TWOC2P: "TWOC2P";
|
|
987
|
+
readonly NETS: "NETS";
|
|
988
|
+
readonly STRIPE_GIROPAY: "STRIPE_GIROPAY";
|
|
989
|
+
readonly MOLLIE_GIROPAY: "MOLLIE_GIROPAY";
|
|
990
|
+
readonly MOLLIE_EPS: "MOLLIE_EPS";
|
|
991
|
+
readonly PAY_NL_EPS: "PAY_NL_EPS";
|
|
992
|
+
readonly PAY_NL_P24: "PAY_NL_P24";
|
|
993
|
+
readonly MOLLIE_P24: "MOLLIE_P24";
|
|
994
|
+
readonly MOLLIE_SOFORT: "MOLLIE_SOFORT";
|
|
995
|
+
readonly COINBASE: "COINBASE";
|
|
996
|
+
readonly OPENNODE: "OPENNODE";
|
|
997
|
+
readonly MOLLIE_GIFT_CARD: "MOLLIE_GIFTCARD";
|
|
998
|
+
readonly XFERS_PAYNOW: "XFERS_PAYNOW";
|
|
999
|
+
readonly PAYMENT_CARD: "PAYMENT_CARD";
|
|
1000
|
+
readonly APPLE_PAY: "APPLE_PAY";
|
|
1001
|
+
readonly GOOGLE_PAY: "GOOGLE_PAY";
|
|
1002
|
+
readonly PAYPAL: "PAYPAL";
|
|
1003
|
+
readonly GO_CARDLESS: "GOCARDLESS";
|
|
1004
|
+
readonly KLARNA: "KLARNA";
|
|
1005
|
+
readonly PAY_NL_IDEAL: "PAY_NL_IDEAL";
|
|
1006
|
+
readonly PAY_NL_SOFORT_BANKING: "PAY_NL_SOFORT_BANKING";
|
|
1007
|
+
readonly PAY_NL_BANCONTACT: "PAY_NL_BANCONTACT";
|
|
1008
|
+
readonly PAY_NL_PAYPAL: "PAY_NL_PAYPAL";
|
|
1009
|
+
readonly PAY_NL_CREDIT_TRANSFER: "PAY_NL_CREDIT_TRANSFER";
|
|
1010
|
+
readonly PAY_NL_DIRECT_DEBIT: "PAY_NL_DIRECT_DEBIT";
|
|
1011
|
+
readonly PAY_NL_GIROPAY: "PAY_NL_GIROPAY";
|
|
1012
|
+
readonly PAY_NL_PAYCONIQ: "PAY_NL_PAYCONIQ";
|
|
1013
|
+
readonly HOOLAH: "HOOLAH";
|
|
1014
|
+
readonly ADYEN_BLIK: "ADYEN_BLIK";
|
|
1015
|
+
readonly ADYEN_MOBILEPAY: "ADYEN_MOBILEPAY";
|
|
1016
|
+
readonly ADYEN_VIPPS: "ADYEN_VIPPS";
|
|
1017
|
+
readonly ADYEN_GIROPAY: "ADYEN_GIROPAY";
|
|
1018
|
+
readonly ADYEN_SOFORT: "ADYEN_SOFORT";
|
|
1019
|
+
readonly ADYEN_IDEAL: "ADYEN_IDEAL";
|
|
1020
|
+
readonly ADYEN_TRUSTLY: "ADYEN_TRUSTLY";
|
|
1021
|
+
readonly ADYEN_ALIPAY: "ADYEN_ALIPAY";
|
|
1022
|
+
readonly ADYEN_TWINT: "ADYEN_TWINT";
|
|
1023
|
+
readonly ADYEN_BANK_TRANSFER: "ADYEN_BANK_TRANSFER";
|
|
1024
|
+
readonly MOLLIE_BANCONTACT: "MOLLIE_BANCONTACT";
|
|
1025
|
+
readonly MOLLIE_IDEAL: "MOLLIE_IDEAL";
|
|
1026
|
+
readonly BUCKAROO_GIROPAY: "BUCKAROO_GIROPAY";
|
|
1027
|
+
readonly BUCKAROO_EPS: "BUCKAROO_EPS";
|
|
1028
|
+
readonly BUCKAROO_SOFORT: "BUCKAROO_SOFORT";
|
|
1029
|
+
readonly BUCKAROO_BANCONTACT: "BUCKAROO_BANCONTACT";
|
|
1030
|
+
readonly BUCKAROO_IDEAL: "BUCKAROO_IDEAL";
|
|
1031
|
+
readonly ATOME: "ATOME";
|
|
1032
|
+
};
|
|
1033
|
+
export type PaymentMethodType = (typeof PaymentMethodType)[keyof typeof PaymentMethodType];
|
|
1034
|
+
declare const TokenType: {
|
|
1035
|
+
readonly SINGLE_USE: "SINGLE_USE";
|
|
1036
|
+
readonly MULTI_USE: "MULTI_USE";
|
|
1037
|
+
};
|
|
1038
|
+
export type TokenType = (typeof TokenType)[keyof typeof TokenType];
|
|
1039
|
+
export type MessageSeverity = "ERROR" | "DEBUG" | "WARN" | "INFO";
|
|
1040
|
+
export interface BorderStyle {
|
|
1041
|
+
borderStyle?: string;
|
|
1042
|
+
borderColor?: number | string;
|
|
1043
|
+
borderWidth?: number | string;
|
|
1044
|
+
}
|
|
1045
|
+
export interface TextAlignmentStyle {
|
|
1046
|
+
textAlign?: string;
|
|
1047
|
+
}
|
|
1048
|
+
export interface TextStyle {
|
|
1049
|
+
color?: string;
|
|
1050
|
+
fontFamily?: string;
|
|
1051
|
+
fontWeight?: string;
|
|
1052
|
+
fontSize?: string;
|
|
1053
|
+
fontSmoothing?: string;
|
|
1054
|
+
lineHeight?: string;
|
|
1055
|
+
textTransform?: string;
|
|
1056
|
+
letterSpacing?: string;
|
|
1057
|
+
}
|
|
1058
|
+
export interface BlockStyle extends BorderStyle {
|
|
1059
|
+
background?: string;
|
|
1060
|
+
borderRadius?: number | string;
|
|
1061
|
+
boxShadow?: string;
|
|
1062
|
+
}
|
|
1063
|
+
export type LogoColor = "DARK" | "LIGHT" | "COLORED";
|
|
1064
|
+
export interface LoadingScreenStyle {
|
|
1065
|
+
color?: string;
|
|
1066
|
+
}
|
|
1067
|
+
export interface BaseInputStyle extends TextStyle, BlockStyle {
|
|
1068
|
+
height?: number | string;
|
|
1069
|
+
paddingHorizontal?: number;
|
|
1070
|
+
}
|
|
1071
|
+
export interface InputStyle extends BaseInputStyle {
|
|
1072
|
+
hover?: BaseInputStyle;
|
|
1073
|
+
focus?: BaseInputStyle;
|
|
1074
|
+
placeholder?: BaseInputStyle;
|
|
1075
|
+
webkitAutofill?: BaseInputStyle;
|
|
1076
|
+
selection?: BaseInputStyle;
|
|
1077
|
+
}
|
|
1078
|
+
export interface BaseSubmitButtonStyle extends TextStyle, BlockStyle {
|
|
1079
|
+
}
|
|
1080
|
+
export interface SubmitButtonStyle extends BaseSubmitButtonStyle {
|
|
1081
|
+
hover?: BaseSubmitButtonStyle;
|
|
1082
|
+
focus?: BaseSubmitButtonStyle;
|
|
1083
|
+
}
|
|
1084
|
+
export interface SubmitButtonStyles {
|
|
1085
|
+
base?: SubmitButtonStyle;
|
|
1086
|
+
disabled?: SubmitButtonStyle;
|
|
1087
|
+
loading?: SubmitButtonStyle;
|
|
1088
|
+
}
|
|
1089
|
+
export interface InputStyles {
|
|
1090
|
+
base?: InputStyle;
|
|
1091
|
+
error?: InputStyle;
|
|
1092
|
+
}
|
|
1093
|
+
export interface BaseSavedPaymentMethodButtonStyle extends TextStyle, BlockStyle {
|
|
1094
|
+
}
|
|
1095
|
+
export interface SavedPaymentMethodButtonStyle extends BaseSavedPaymentMethodButtonStyle {
|
|
1096
|
+
hover?: BaseSavedPaymentMethodButtonStyle;
|
|
1097
|
+
focus?: BaseSavedPaymentMethodButtonStyle;
|
|
1098
|
+
}
|
|
1099
|
+
export interface SavedPaymentMethodButtonStyles {
|
|
1100
|
+
base?: SavedPaymentMethodButtonStyle;
|
|
1101
|
+
selected?: SavedPaymentMethodButtonStyle;
|
|
1102
|
+
}
|
|
1103
|
+
export interface ShowMorePaymentMethodsButtonStyles {
|
|
1104
|
+
base?: TextStyle;
|
|
1105
|
+
disabled?: TextStyle;
|
|
1106
|
+
}
|
|
1107
|
+
export interface DirectDebitMandateStyle {
|
|
1108
|
+
header?: TextStyle;
|
|
1109
|
+
label?: TextStyle;
|
|
1110
|
+
content?: TextStyle;
|
|
1111
|
+
creditorDetails?: TextStyle;
|
|
1112
|
+
}
|
|
1113
|
+
export interface DirectDebitSuccessStyle {
|
|
1114
|
+
icon?: {
|
|
1115
|
+
color?: string;
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
export interface PaymentMethodButtonStyle extends BlockStyle {
|
|
1119
|
+
height?: number;
|
|
1120
|
+
minHeight?: number;
|
|
1121
|
+
maxHeight?: number;
|
|
1122
|
+
primaryText?: TextStyle;
|
|
1123
|
+
logoColor?: LogoColor;
|
|
1124
|
+
marginTop?: string;
|
|
1125
|
+
}
|
|
1126
|
+
export interface BackButtonStyle {
|
|
1127
|
+
color?: string;
|
|
1128
|
+
}
|
|
1129
|
+
export interface EditButtonStyle {
|
|
1130
|
+
color?: string;
|
|
1131
|
+
background?: string;
|
|
1132
|
+
}
|
|
1133
|
+
export interface SeparatorStyle {
|
|
1134
|
+
color?: string;
|
|
1135
|
+
}
|
|
1136
|
+
export interface ErrorMessageStyle extends BlockStyle, TextStyle {
|
|
1137
|
+
color?: string;
|
|
1138
|
+
}
|
|
1139
|
+
export interface FormSpacings {
|
|
1140
|
+
betweenLabelAndInput?: string;
|
|
1141
|
+
betweenInputs?: string;
|
|
1142
|
+
}
|
|
1143
|
+
export interface FontFace$1 {
|
|
1144
|
+
fontFamily?: string;
|
|
1145
|
+
src?: string;
|
|
1146
|
+
unicodeRange?: string;
|
|
1147
|
+
fontVariant?: string;
|
|
1148
|
+
fontFeatureSettings?: string;
|
|
1149
|
+
fontVariationSettings?: string;
|
|
1150
|
+
fontStretch?: string;
|
|
1151
|
+
fontWeight?: string;
|
|
1152
|
+
fontStyle?: string;
|
|
1153
|
+
}
|
|
1154
|
+
export interface Stylesheet {
|
|
1155
|
+
href: string;
|
|
1156
|
+
}
|
|
1157
|
+
export interface VaultMenuStyle {
|
|
1158
|
+
editButton?: EditButtonStyle & TextStyle;
|
|
1159
|
+
item?: {
|
|
1160
|
+
label?: TextStyle;
|
|
1161
|
+
actionButton?: TextStyle;
|
|
1162
|
+
confirmButton?: BlockStyle & TextStyle;
|
|
1163
|
+
};
|
|
1164
|
+
}
|
|
1165
|
+
export interface NetworkErrorStyles {
|
|
1166
|
+
button?: {
|
|
1167
|
+
base: BlockStyle & TextStyle;
|
|
1168
|
+
};
|
|
1169
|
+
}
|
|
1170
|
+
export interface ProcessingIndicatorStyle {
|
|
1171
|
+
color?: string;
|
|
1172
|
+
}
|
|
1173
|
+
export interface CheckoutStyle {
|
|
1174
|
+
fontFaces?: Array<FontFace$1>;
|
|
1175
|
+
stylesheets?: Array<Stylesheet>;
|
|
1176
|
+
loadingScreen?: LoadingScreenStyle;
|
|
1177
|
+
input?: InputStyles;
|
|
1178
|
+
inputLabel?: TextStyle;
|
|
1179
|
+
inputErrorText?: TextStyle & TextAlignmentStyle;
|
|
1180
|
+
formSpacings?: FormSpacings;
|
|
1181
|
+
showMorePaymentMethodsButton?: ShowMorePaymentMethodsButtonStyles;
|
|
1182
|
+
networkError?: NetworkErrorStyles;
|
|
1183
|
+
submitButton?: SubmitButtonStyles;
|
|
1184
|
+
vaultTitle?: TextStyle;
|
|
1185
|
+
savedPaymentMethodButton?: SavedPaymentMethodButtonStyles;
|
|
1186
|
+
paymentMethodButton?: PaymentMethodButtonStyle;
|
|
1187
|
+
errorMessage?: ErrorMessageStyle;
|
|
1188
|
+
smallPrint?: TextStyle;
|
|
1189
|
+
directDebit?: {
|
|
1190
|
+
mandate?: DirectDebitMandateStyle;
|
|
1191
|
+
success?: DirectDebitSuccessStyle;
|
|
1192
|
+
};
|
|
1193
|
+
vaultMenu?: VaultMenuStyle;
|
|
1194
|
+
backButton?: BackButtonStyle;
|
|
1195
|
+
separator?: SeparatorStyle;
|
|
1196
|
+
processingIndicator?: ProcessingIndicatorStyle;
|
|
1197
|
+
focusCheckoutOnInit?: boolean;
|
|
1198
|
+
}
|
|
1199
|
+
export interface IVaultedPaymentMethod<T, U extends PaymentInstrumentType> {
|
|
1200
|
+
id: string;
|
|
1201
|
+
analyticsId: string;
|
|
1202
|
+
paymentInstrumentData: T;
|
|
1203
|
+
paymentInstrumentType: U;
|
|
1204
|
+
threeDSecureAuthentication: ThreeDSAuthenticationData | null;
|
|
1205
|
+
vaultData: VaultData | null;
|
|
1206
|
+
userDescription?: string;
|
|
1207
|
+
}
|
|
1208
|
+
export type VaultedPaymentMethod = IVaultedPaymentMethod<any, any>;
|
|
1209
|
+
declare enum ProductType {
|
|
1210
|
+
DIGITAL = "DIGITAL",
|
|
1211
|
+
PHYSICAL = "PHYSICAL",
|
|
1212
|
+
SHIPPING_FEE = "SHIPPING_FEE"
|
|
1213
|
+
}
|
|
1214
|
+
export interface ClientSessionLineItem {
|
|
1215
|
+
amount: number;
|
|
1216
|
+
description: string;
|
|
1217
|
+
discountAmount?: number;
|
|
1218
|
+
itemId: string;
|
|
1219
|
+
name?: string;
|
|
1220
|
+
productType?: ProductType;
|
|
1221
|
+
quantity: number;
|
|
1222
|
+
taxAmount?: number;
|
|
1223
|
+
taxCode?: string;
|
|
1224
|
+
}
|
|
1225
|
+
export interface ClientSessionShipping {
|
|
1226
|
+
amount: number;
|
|
1227
|
+
methodId?: string;
|
|
1228
|
+
methodName?: string;
|
|
1229
|
+
methodDescription?: string;
|
|
1230
|
+
}
|
|
1231
|
+
export interface ClientSessionFeeItem {
|
|
1232
|
+
type?: string;
|
|
1233
|
+
description?: string;
|
|
1234
|
+
amount: number;
|
|
1235
|
+
}
|
|
1236
|
+
export interface ClientSessionAddress {
|
|
1237
|
+
firstName?: string;
|
|
1238
|
+
lastName?: string;
|
|
1239
|
+
addressLine1?: string;
|
|
1240
|
+
addressLine2?: string;
|
|
1241
|
+
city?: string;
|
|
1242
|
+
state?: string;
|
|
1243
|
+
countryCode?: string;
|
|
1244
|
+
postalCode?: string;
|
|
1245
|
+
}
|
|
1246
|
+
export interface ClientSession {
|
|
1247
|
+
orderId?: string;
|
|
1248
|
+
currencyCode?: string;
|
|
1249
|
+
lineItems?: ClientSessionLineItem[];
|
|
1250
|
+
totalAmount?: number;
|
|
1251
|
+
customerId?: string;
|
|
1252
|
+
orderDetails?: {
|
|
1253
|
+
countryCode?: string;
|
|
1254
|
+
shipping?: ClientSessionShipping;
|
|
1255
|
+
fees?: ClientSessionFeeItem[];
|
|
1256
|
+
};
|
|
1257
|
+
customer?: {
|
|
1258
|
+
emailAddress?: string;
|
|
1259
|
+
mobileNumber?: string;
|
|
1260
|
+
firstName?: string;
|
|
1261
|
+
lastName?: string;
|
|
1262
|
+
billingAddress?: ClientSessionAddress;
|
|
1263
|
+
shippingAddress?: ClientSessionAddress;
|
|
1264
|
+
taxId?: string;
|
|
1265
|
+
nationalDocumentId?: string;
|
|
1266
|
+
};
|
|
1267
|
+
paymentMethod?: {
|
|
1268
|
+
options?: Record<string, any>;
|
|
1269
|
+
orderedAllowedCardNetworks?: string[];
|
|
1270
|
+
vaultOnSuccess?: boolean;
|
|
1271
|
+
};
|
|
1272
|
+
}
|
|
1273
|
+
export interface BackgroundColor {
|
|
1274
|
+
colored: string;
|
|
1275
|
+
dark: string;
|
|
1276
|
+
light: string;
|
|
1277
|
+
}
|
|
1278
|
+
export interface IconUrl {
|
|
1279
|
+
colored: string;
|
|
1280
|
+
dark: string;
|
|
1281
|
+
light: string;
|
|
1282
|
+
}
|
|
1283
|
+
declare enum CheckoutUXFlow {
|
|
1284
|
+
CHECKOUT = "CHECKOUT",
|
|
1285
|
+
HEADLESS_CHECKOUT = "HEADLESS_CHECKOUT",
|
|
1286
|
+
MANAGE_PAYMENT_METHODS = "MANAGE_PAYMENT_METHODS"
|
|
1287
|
+
}
|
|
1288
|
+
export type SecureInputOptions = {
|
|
1289
|
+
ariaLabel?: string;
|
|
1290
|
+
container: string;
|
|
1291
|
+
id?: string;
|
|
1292
|
+
name: string;
|
|
1293
|
+
placeholder?: string;
|
|
1294
|
+
placement?: "append" | "prepend";
|
|
1295
|
+
properties?: any;
|
|
1296
|
+
style?: CheckoutStyle;
|
|
1297
|
+
allowedCharactersMap?: Record<string, string>;
|
|
1298
|
+
};
|
|
1299
|
+
export type SecureInputListener = (...args: unknown[]) => void;
|
|
1300
|
+
export type CardSecurityCodeInputOptions = Omit<SecureInputOptions, "allowedCharactersMap" | "name"> & {
|
|
1301
|
+
cardNetwork?: string;
|
|
1302
|
+
name?: string;
|
|
1303
|
+
};
|
|
1304
|
+
export type CvvInput = {
|
|
1305
|
+
frame: HTMLIFrameElement | null;
|
|
1306
|
+
readonly metadata: {
|
|
1307
|
+
readonly errorCode: string | null;
|
|
1308
|
+
readonly error: string | null;
|
|
1309
|
+
readonly valid: boolean;
|
|
1310
|
+
readonly active: boolean;
|
|
1311
|
+
readonly dirty: boolean;
|
|
1312
|
+
readonly touched: boolean;
|
|
1313
|
+
readonly submitted: boolean;
|
|
1314
|
+
};
|
|
1315
|
+
focus(): void;
|
|
1316
|
+
blur(): void;
|
|
1317
|
+
addListener(event: "change" | "blur" | "focus", listener: SecureInputListener): (() => void) | undefined;
|
|
1318
|
+
addEventListener(event: "change" | "blur" | "focus", listener: SecureInputListener): (() => void) | undefined;
|
|
1319
|
+
removeListener(event: "change" | "blur" | "focus", listener: SecureInputListener): void;
|
|
1320
|
+
name: string;
|
|
1321
|
+
valueToken: string;
|
|
1322
|
+
remove: () => void;
|
|
1323
|
+
};
|
|
1324
|
+
export type CvvInputOptions = CardSecurityCodeInputOptions;
|
|
1325
|
+
export interface HeadlessVaultManager {
|
|
1326
|
+
fetchVaultedPaymentMethods(): Promise<VaultedPaymentMethod[]>;
|
|
1327
|
+
deleteVaultedPaymentMethod(id: string): Promise<void>;
|
|
1328
|
+
startPaymentFlow(id: string, data?: {
|
|
1329
|
+
cvv?: string;
|
|
1330
|
+
}): Promise<void>;
|
|
1331
|
+
createCvvInput(options: CvvInputOptions): Promise<CvvInput | null>;
|
|
1332
|
+
}
|
|
1333
|
+
declare enum PaymentFlow {
|
|
1334
|
+
DEFAULT = "DEFAULT",
|
|
1335
|
+
PREFER_VAULT = "PREFER_VAULT"
|
|
1336
|
+
}
|
|
1337
|
+
declare enum ThreeDSecureStatus {
|
|
1338
|
+
SUCCESS = "AUTH_SUCCESS",
|
|
1339
|
+
FAILED = "AUTH_FAILED",
|
|
1340
|
+
SKIPPED = "SKIPPED",
|
|
1341
|
+
CHALLENGE = "CHALLENGE"
|
|
1342
|
+
}
|
|
1343
|
+
declare enum ErrorCode {
|
|
1344
|
+
INITIALIZATION_ERROR = "INITIALIZATION_ERROR",
|
|
1345
|
+
NO_PAYMENT_METHODS = "NO_PAYMENT_METHODS",
|
|
1346
|
+
PRIMER_TEARDOWN = "PRIMER_TEARDOWN",
|
|
1347
|
+
PRIMER_SERVER_ERROR = "PRIMER_SERVER_ERROR",
|
|
1348
|
+
THREE_DS_AUTH_FAILED = "THREE_DS_AUTH_FAILED",
|
|
1349
|
+
TOKENIZATION_ERROR = "TOKENIZATION_ERROR",
|
|
1350
|
+
DUPLICATE_PAYMENT_METHOD_ERROR = "DUPLICATE_PAYMENT_METHOD_ERROR",
|
|
1351
|
+
CARD_NUMBER_ERROR = "CARD_NUMBER_ERROR",
|
|
1352
|
+
PAYMENT_METHOD_NOT_SETUP = "PAYMENT_METHOD_NOT_SETUP",
|
|
1353
|
+
PAYMENT_METHOD_NOT_PROVIDED = "PAYMENT_METHOD_NOT_PROVIDED",
|
|
1354
|
+
PAYMENT_METHOD_NOT_COMPATIBLE = "PAYMENT_METHOD_NOT_COMPATIBLE",
|
|
1355
|
+
RESUME_ERROR = "RESUME_ERROR",
|
|
1356
|
+
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
1357
|
+
PAYMENT_FAILED = "PAYMENT_FAILED",
|
|
1358
|
+
PAYMENT_CREATION_ABORTED = "PAYMENT_CREATION_ABORTED",
|
|
1359
|
+
PAYMENT_CREATION_DISABLED = "PAYMENT_CREATION_DISABLED",
|
|
1360
|
+
CLIENT_SESSION_UPDATE_ERROR = "CLIENT_SESSION_UPDATE_ERROR",
|
|
1361
|
+
INVALID_ARGUMENT = "INVALID_ARGUMENT",
|
|
1362
|
+
VAULT_FETCH = "VAULT_FETCH",
|
|
1363
|
+
VAULT_DELETE = "VAULT_DELETE",
|
|
1364
|
+
HEADLESS_VAULT_MANAGER_VALIDATION = "HEADLESS_VAULT_MANAGER_VALIDATION",
|
|
1365
|
+
CARD_FORM_VALIDATION_UNEXPECTED_FIELD = "CARD_FORM_VALIDATION_UNEXPECTED_FIELD",
|
|
1366
|
+
MISSING_FIRST_NAME_OR_LAST_NAME = "MISSING_FIRST_NAME_OR_LAST_NAME",
|
|
1367
|
+
MISSING_EMAIL_ADDRESS = "MISSING_EMAIL_ADDRESS",
|
|
1368
|
+
INVALID_FLOW = "INVALID_FLOW"
|
|
1369
|
+
}
|
|
1370
|
+
declare class SDKError extends Error {
|
|
1371
|
+
isReported: boolean;
|
|
1372
|
+
constructor(message: string, isReported?: boolean);
|
|
1373
|
+
static from(error: unknown, isReported?: boolean): SDKError;
|
|
1374
|
+
markAsReported(): void;
|
|
1375
|
+
}
|
|
1376
|
+
export interface ErrorOptions$1<T = any> {
|
|
1377
|
+
message: string;
|
|
1378
|
+
diagnosticsId?: string;
|
|
1379
|
+
severity?: MessageSeverity;
|
|
1380
|
+
errorId?: string;
|
|
1381
|
+
data?: T;
|
|
1382
|
+
isFromDeveloper?: boolean;
|
|
1383
|
+
}
|
|
1384
|
+
declare class PrimerClientError<T = any> extends SDKError {
|
|
1385
|
+
readonly code: ErrorCode;
|
|
1386
|
+
readonly diagnosticsId: string | null;
|
|
1387
|
+
readonly data?: T;
|
|
1388
|
+
readonly isFromDeveloper: boolean;
|
|
1389
|
+
static fromErrorCode(code: ErrorCode, options: ErrorOptions$1): PrimerClientError;
|
|
1390
|
+
constructor(code: ErrorCode, options: ErrorOptions$1<T>);
|
|
1391
|
+
}
|
|
1392
|
+
export interface CardMetadata {
|
|
1393
|
+
/** @deprecated Use onCardNetworksChange instead. */
|
|
1394
|
+
type: CardNetwork$1 | null;
|
|
1395
|
+
/** @deprecated Use onCardNetworksChange instead. */
|
|
1396
|
+
possibleTypes: string[];
|
|
1397
|
+
cvvLength: number;
|
|
1398
|
+
cardNumberLength: number;
|
|
1399
|
+
}
|
|
1400
|
+
export type PaymentMethodData$1 = AdyenMultibancoPaymentData;
|
|
1401
|
+
export type AdyenMultibancoPaymentData = {
|
|
1402
|
+
paymentMethodType: typeof PaymentMethodType.ADYEN_MULTIBANCO;
|
|
1403
|
+
reference: string;
|
|
1404
|
+
expiresAt: string;
|
|
1405
|
+
entity: string;
|
|
1406
|
+
};
|
|
1407
|
+
export interface PositionalConfig {
|
|
1408
|
+
container: string | Element;
|
|
1409
|
+
}
|
|
1410
|
+
export interface ApplePayOptions extends PositionalConfig {
|
|
1411
|
+
buttonType?: "plain" | "buy" | "set-up" | "donate" | "check-out" | "book" | "subscribe";
|
|
1412
|
+
buttonStyle?: "white" | "white-outline" | "black";
|
|
1413
|
+
/**
|
|
1414
|
+
* @deprecated Add `postalAddress` to `billingOptions.requiredBillingContactFields` instead.
|
|
1415
|
+
*/
|
|
1416
|
+
captureBillingAddress?: boolean;
|
|
1417
|
+
billingOptions?: ApplePayBillingOptions;
|
|
1418
|
+
shippingOptions?: ApplePayShippingOptions;
|
|
1419
|
+
}
|
|
1420
|
+
export interface ApplePayBillingOptions {
|
|
1421
|
+
requiredBillingContactFields?: RequiredContactFields[];
|
|
1422
|
+
}
|
|
1423
|
+
export interface ApplePayShippingOptions {
|
|
1424
|
+
requiredShippingContactFields?: RequiredContactFields[];
|
|
1425
|
+
requireShippingMethod?: boolean;
|
|
1426
|
+
}
|
|
1427
|
+
export type RequiredContactFields = "emailAddress" | "name" | "phoneNumber" | "postalAddress" | "phoneticName";
|
|
1428
|
+
export interface DirectDebitOptions {
|
|
1429
|
+
customerCountryCode: Alpha2CountryCode;
|
|
1430
|
+
companyName: string;
|
|
1431
|
+
companyAddress: string;
|
|
1432
|
+
customerName?: string;
|
|
1433
|
+
customerEmail?: string;
|
|
1434
|
+
customerAddressLine1?: string;
|
|
1435
|
+
customerAddressLine2?: string;
|
|
1436
|
+
customerCity?: string;
|
|
1437
|
+
customerPostalCode?: string;
|
|
1438
|
+
iban?: string;
|
|
1439
|
+
submitButtonLabels?: {
|
|
1440
|
+
form?: Label;
|
|
1441
|
+
mandate: Label;
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
export type GooglePayButtonType =
|
|
1445
|
+
/** @deprecated Set buttonSizeMode to fill instead */
|
|
1446
|
+
"long"
|
|
1447
|
+
/** @deprecated Set buttonSizeMode to static instead */
|
|
1448
|
+
| "short" | "book" | "buy" | "checkout" | "donate" | "order" | "pay" | "plain" | "subscribe";
|
|
1449
|
+
export type GooglePayButtonColor = "default" | "black" | "white";
|
|
1450
|
+
export type GooglePayButtonSizeMode = "fill" | "static";
|
|
1451
|
+
export interface GooglePayShippingAddressParameters {
|
|
1452
|
+
phoneNumberRequired?: boolean;
|
|
1453
|
+
}
|
|
1454
|
+
export interface GooglePayOptions extends PositionalConfig {
|
|
1455
|
+
buttonType?: GooglePayButtonType;
|
|
1456
|
+
buttonColor?: GooglePayButtonColor;
|
|
1457
|
+
buttonSizeMode?: GooglePayButtonSizeMode;
|
|
1458
|
+
onClick?: () => void;
|
|
1459
|
+
captureBillingAddress?: boolean;
|
|
1460
|
+
shippingAddressParameters?: GooglePayShippingAddressParameters;
|
|
1461
|
+
emailRequired?: boolean;
|
|
1462
|
+
requireShippingMethod?: boolean;
|
|
1463
|
+
shadowRoot?: boolean;
|
|
1464
|
+
}
|
|
1465
|
+
export interface PayPalOptions extends PositionalConfig {
|
|
1466
|
+
buttonColor?: "gold" | "blue" | "silver" | "white" | "black";
|
|
1467
|
+
buttonShape?: "pill" | "rect";
|
|
1468
|
+
buttonSize?: "small" | "medium" | "large" | "responsive";
|
|
1469
|
+
buttonHeight?: number;
|
|
1470
|
+
buttonLabel?: "checkout" | "credit" | "pay" | "buynow" | "paypal" | "installment";
|
|
1471
|
+
buttonTagline?: boolean;
|
|
1472
|
+
paymentFlow?: PaymentFlow;
|
|
1473
|
+
onClick?: () => void;
|
|
1474
|
+
}
|
|
1475
|
+
export interface SubmitButtonOptions {
|
|
1476
|
+
amountVisible?: boolean;
|
|
1477
|
+
useBuiltInButton?: boolean;
|
|
1478
|
+
onVisible?: (isVisible: boolean, context: {
|
|
1479
|
+
currentSceneId: string;
|
|
1480
|
+
previousSceneId?: string;
|
|
1481
|
+
}) => void;
|
|
1482
|
+
onContentChange?: (content: string, context: {
|
|
1483
|
+
currentSceneId: string;
|
|
1484
|
+
}) => void;
|
|
1485
|
+
onDisable?: (isDisabled: boolean, context: {
|
|
1486
|
+
currentSceneId: string;
|
|
1487
|
+
}) => void;
|
|
1488
|
+
onLoading?: (isLoading: boolean, context: {
|
|
1489
|
+
currentSceneId: string;
|
|
1490
|
+
}) => void;
|
|
1491
|
+
}
|
|
1492
|
+
export interface ProcessingIndicatorOptions {
|
|
1493
|
+
visible?: boolean;
|
|
1494
|
+
}
|
|
1495
|
+
export interface FormOptions {
|
|
1496
|
+
inputLabelsVisible?: boolean;
|
|
1497
|
+
}
|
|
1498
|
+
export type CardPreferredFlow = "DEDICATED_SCENE" | "EMBEDDED_IN_HOME";
|
|
1499
|
+
export interface CheckoutCardOptions {
|
|
1500
|
+
cardholderName?: {
|
|
1501
|
+
/**
|
|
1502
|
+
* Only works if the cardholder name is visible
|
|
1503
|
+
*/
|
|
1504
|
+
required?: boolean;
|
|
1505
|
+
/**
|
|
1506
|
+
* @deprecated Set it on your Dashboard
|
|
1507
|
+
*/
|
|
1508
|
+
visible?: boolean;
|
|
1509
|
+
placeholder?: Label;
|
|
1510
|
+
};
|
|
1511
|
+
cardNumber?: {
|
|
1512
|
+
placeholder?: Label;
|
|
1513
|
+
};
|
|
1514
|
+
expiryDate?: {
|
|
1515
|
+
placeholder?: Label;
|
|
1516
|
+
};
|
|
1517
|
+
cvv?: {
|
|
1518
|
+
placeholder?: Label;
|
|
1519
|
+
};
|
|
1520
|
+
preferredFlow?: CardPreferredFlow;
|
|
1521
|
+
}
|
|
1522
|
+
export interface ErrorMessageOptions {
|
|
1523
|
+
disabled?: boolean;
|
|
1524
|
+
onErrorMessageShow?: (message: string) => void;
|
|
1525
|
+
onErrorMessageHide?: () => void;
|
|
1526
|
+
}
|
|
1527
|
+
declare enum SuccessScreenType {
|
|
1528
|
+
PAYMENT_METHOD = "PAYMENT_METHOD",
|
|
1529
|
+
CHECK = "CHECK"
|
|
1530
|
+
}
|
|
1531
|
+
export interface StripeAchCustomerDetails {
|
|
1532
|
+
emailAddress: string;
|
|
1533
|
+
firstName: string;
|
|
1534
|
+
lastName: string;
|
|
1535
|
+
}
|
|
1536
|
+
export interface StripeOptions {
|
|
1537
|
+
publishableKey: string;
|
|
1538
|
+
}
|
|
1539
|
+
export interface StripeOptionsDropInWithFullMandateText extends StripeOptions {
|
|
1540
|
+
mandateData: {
|
|
1541
|
+
fullMandateText: string;
|
|
1542
|
+
merchantName?: never;
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
export interface StripeOptionsDropInTextProvidedByPrimer extends StripeOptions {
|
|
1546
|
+
mandateData: {
|
|
1547
|
+
merchantName: string;
|
|
1548
|
+
fullMandateText?: never;
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
export type StripeOptionsDropIn = StripeOptionsDropInWithFullMandateText | StripeOptionsDropInTextProvidedByPrimer;
|
|
1552
|
+
type CardNetwork$1 = "american-express" | "diners-club" | "discover" | "elo" | "hiper" | "hipercard" | "interac" | "jcb" | "maestro" | "mastercard" | "mir" | "unionpay" | "private-label" | "visa";
|
|
1553
|
+
export interface CustomizablePaymentMethodButton {
|
|
1554
|
+
logoSrc: string;
|
|
1555
|
+
background: string;
|
|
1556
|
+
logoAlt?: string;
|
|
1557
|
+
text?: string;
|
|
1558
|
+
}
|
|
1559
|
+
export type KlarnaPaymentCategoryType = "pay_now" | "pay_later" | "pay_over_time";
|
|
1560
|
+
export interface KlarnaButtonOptions {
|
|
1561
|
+
text?: string;
|
|
1562
|
+
}
|
|
1563
|
+
export interface AdyenKlarnaOptions {
|
|
1564
|
+
buttonOptions?: KlarnaButtonOptions;
|
|
1565
|
+
}
|
|
1566
|
+
export interface KlarnaOptions {
|
|
1567
|
+
paymentFlow?: PaymentFlow;
|
|
1568
|
+
recurringPaymentDescription?: string;
|
|
1569
|
+
allowedPaymentCategories?: KlarnaPaymentCategoryType[];
|
|
1570
|
+
buttonOptions?: KlarnaButtonOptions;
|
|
1571
|
+
}
|
|
1572
|
+
export type SupportedLocale = string;
|
|
1573
|
+
export type Alpha2CountryCode = string;
|
|
1574
|
+
export type Alpha3CurrencyCode = string;
|
|
1575
|
+
export type Label<T extends Record<string, unknown> = Record<string, unknown>> = string | ((options: {
|
|
1576
|
+
locale: SupportedLocale;
|
|
1577
|
+
} | T) => string);
|
|
1578
|
+
export type ResumeToken = {
|
|
1579
|
+
resumeToken: string;
|
|
1580
|
+
paymentId?: string;
|
|
1581
|
+
};
|
|
1582
|
+
export interface InputValidationError {
|
|
1583
|
+
name: string;
|
|
1584
|
+
error: string;
|
|
1585
|
+
message: string;
|
|
1586
|
+
}
|
|
1587
|
+
export interface Validation {
|
|
1588
|
+
valid: boolean;
|
|
1589
|
+
validationErrors: InputValidationError[];
|
|
1590
|
+
error?: string;
|
|
1591
|
+
}
|
|
1592
|
+
export interface ExternalPayerInfo {
|
|
1593
|
+
externalPayerId: string;
|
|
1594
|
+
firstName?: string;
|
|
1595
|
+
lastName?: string;
|
|
1596
|
+
email?: string;
|
|
1597
|
+
}
|
|
1598
|
+
export interface CustomerAddress {
|
|
1599
|
+
firstName?: string;
|
|
1600
|
+
lastName?: string;
|
|
1601
|
+
addressLine1?: string;
|
|
1602
|
+
addressLine2?: string;
|
|
1603
|
+
addressLine3?: string;
|
|
1604
|
+
city?: string;
|
|
1605
|
+
state?: string;
|
|
1606
|
+
countryCode?: Alpha2CountryCode;
|
|
1607
|
+
postalCode?: string;
|
|
1608
|
+
}
|
|
1609
|
+
export interface MonetaryAmount {
|
|
1610
|
+
value: number | string;
|
|
1611
|
+
currency: Alpha3CurrencyCode;
|
|
1612
|
+
}
|
|
1613
|
+
export interface ThreeDSecureOrderDetails {
|
|
1614
|
+
amount: MonetaryAmount;
|
|
1615
|
+
email: string;
|
|
1616
|
+
billingAddress: CustomerAddress;
|
|
1617
|
+
orderId: string;
|
|
1618
|
+
}
|
|
1619
|
+
export interface ThreeDSVerificationOptions {
|
|
1620
|
+
token: string;
|
|
1621
|
+
container: string;
|
|
1622
|
+
order: ThreeDSecureOrderDetails;
|
|
1623
|
+
testScenario?: string;
|
|
1624
|
+
onChallengeStart?: () => void;
|
|
1625
|
+
onChallengeEnd?: () => void;
|
|
1626
|
+
}
|
|
1627
|
+
export interface ThreeDSAuthenticationData {
|
|
1628
|
+
responseCode: ThreeDSecureStatus;
|
|
1629
|
+
reasonCode?: string;
|
|
1630
|
+
reasonText?: string;
|
|
1631
|
+
protocolVersion: string;
|
|
1632
|
+
challengeIssued: boolean;
|
|
1633
|
+
}
|
|
1634
|
+
export interface VaultData {
|
|
1635
|
+
customerId: string;
|
|
1636
|
+
}
|
|
1637
|
+
export interface PaymentCardDetails {
|
|
1638
|
+
last4Digits: string;
|
|
1639
|
+
cardholderName: string;
|
|
1640
|
+
network: string;
|
|
1641
|
+
}
|
|
1642
|
+
export interface PayPalBillingAgreementDetails {
|
|
1643
|
+
paypalBillingAgreementId: string;
|
|
1644
|
+
externalPayerInfo?: ExternalPayerInfo;
|
|
1645
|
+
shippingAddress?: CustomerAddress;
|
|
1646
|
+
}
|
|
1647
|
+
export interface GoCardlessDetails {
|
|
1648
|
+
gocardlessMandateId: string;
|
|
1649
|
+
}
|
|
1650
|
+
export interface IPaymentMethodToken<T, U extends PaymentInstrumentType> {
|
|
1651
|
+
token: string;
|
|
1652
|
+
analyticsId: string;
|
|
1653
|
+
tokenType: TokenType;
|
|
1654
|
+
paymentInstrumentData: T;
|
|
1655
|
+
paymentInstrumentType: U;
|
|
1656
|
+
threeDSecureAuthentication: ThreeDSAuthenticationData | null;
|
|
1657
|
+
vaultData: VaultData | null;
|
|
1658
|
+
}
|
|
1659
|
+
export type PaymentCardToken = IPaymentMethodToken<PaymentCardDetails, typeof PaymentInstrumentType.CARD>;
|
|
1660
|
+
export type PayPalBillingAgreementToken = IPaymentMethodToken<PayPalBillingAgreementDetails, typeof PaymentInstrumentType.PAYPAL_VAULTED>;
|
|
1661
|
+
export type GoCardlessToken = IPaymentMethodToken<GoCardlessDetails, typeof PaymentInstrumentType.GO_CARDLESS>;
|
|
1662
|
+
export type IdealPayToken = IPaymentMethodToken<Record<string, never>, typeof PaymentInstrumentType.PAY_NL_IDEAL>;
|
|
1663
|
+
export type PaymentMethodToken = PaymentCardToken | PayPalBillingAgreementToken | GoCardlessToken | IdealPayToken | IPaymentMethodToken<any, any>;
|
|
1664
|
+
export type CheckSuccessScreenOptions = {
|
|
1665
|
+
type: SuccessScreenType.CHECK;
|
|
1666
|
+
title: Label;
|
|
1667
|
+
};
|
|
1668
|
+
export type PaymentMethodSuccessScreenOptions = {
|
|
1669
|
+
type: SuccessScreenType.PAYMENT_METHOD;
|
|
1670
|
+
};
|
|
1671
|
+
export type SuccessScreenOptions = /* No success screen will be displayed */ false | /* Show the default success screen of the payment method*/ undefined | CheckSuccessScreenOptions | PaymentMethodSuccessScreenOptions;
|
|
1672
|
+
export type VaultOptions = {
|
|
1673
|
+
visible?: boolean;
|
|
1674
|
+
deletionDisabled?: boolean;
|
|
1675
|
+
};
|
|
1676
|
+
export type TransitionType = "SLIDE_UP" | "SLIDE_DOWN" | "SLIDE_HORIZONTAL";
|
|
1677
|
+
export type SceneTransitionOptions = {
|
|
1678
|
+
type: TransitionType;
|
|
1679
|
+
duration: number;
|
|
1680
|
+
isRtlLocale?: boolean;
|
|
1681
|
+
};
|
|
1682
|
+
export type SceneOptions = {
|
|
1683
|
+
onEntering?: (sceneId: string) => void;
|
|
1684
|
+
transition?: SceneTransitionOptions | false;
|
|
1685
|
+
};
|
|
1686
|
+
export type RedirectOptions = {
|
|
1687
|
+
returnUrl?: string;
|
|
1688
|
+
/**
|
|
1689
|
+
* default: false
|
|
1690
|
+
*/
|
|
1691
|
+
forceRedirect?: boolean;
|
|
1692
|
+
};
|
|
1693
|
+
export type AdvancedOptions = {
|
|
1694
|
+
platform?: "STANDALONE" | "MAGENTO";
|
|
1695
|
+
};
|
|
1696
|
+
export type PaymentMethodAction = "PAYMENT_METHOD_SELECTED" | "PAYMENT_METHOD_UNSELECTED";
|
|
1697
|
+
export type PaymentHandling = "AUTO" | "MANUAL";
|
|
1698
|
+
export type Payment = {
|
|
1699
|
+
id: string;
|
|
1700
|
+
orderId: string;
|
|
1701
|
+
paymentMethodData?: PaymentMethodData$1;
|
|
1702
|
+
};
|
|
1703
|
+
export interface onBeforePaymentCreateHandler {
|
|
1704
|
+
continuePaymentCreation: () => void;
|
|
1705
|
+
abortPaymentCreation: () => void;
|
|
1706
|
+
}
|
|
1707
|
+
export interface OnCheckoutFailHandler {
|
|
1708
|
+
showErrorMessage: (errorMessage?: string) => void;
|
|
1709
|
+
}
|
|
1710
|
+
export interface PaymentHandlers {
|
|
1711
|
+
onBeforePaymentCreate?: (data: {
|
|
1712
|
+
paymentMethodType?: PaymentMethodType;
|
|
1713
|
+
}, handler: onBeforePaymentCreateHandler) => void;
|
|
1714
|
+
onPaymentCreationStart?: () => void;
|
|
1715
|
+
onCheckoutComplete?: (data: {
|
|
1716
|
+
payment: Payment | null;
|
|
1717
|
+
}) => void;
|
|
1718
|
+
onCheckoutFail?: (error: PrimerClientError, data: {
|
|
1719
|
+
payment?: Payment;
|
|
1720
|
+
}, handler: OnCheckoutFailHandler | undefined) => void;
|
|
1721
|
+
}
|
|
1722
|
+
export type OnTokenizeShouldStart = (data: {
|
|
1723
|
+
paymentMethodType?: PaymentMethodType;
|
|
1724
|
+
}) => boolean | Promise<boolean>;
|
|
1725
|
+
export type OnTokenizeDidNotStart = (reason: string) => void;
|
|
1726
|
+
export type OnTokenizeStart = () => void;
|
|
1727
|
+
export type OnTokenizeError = (error: PrimerClientError) => void;
|
|
1728
|
+
export interface OnTokenizeSuccessHandler {
|
|
1729
|
+
handleSuccess(): any;
|
|
1730
|
+
handleFailure(errorMessage?: string): any;
|
|
1731
|
+
continueWithNewClientToken(clientToken: string): any;
|
|
1732
|
+
}
|
|
1733
|
+
export type OnTokenizeSuccess = (data: PaymentMethodToken, handler: OnTokenizeSuccessHandler) => void | Promise<void>;
|
|
1734
|
+
export interface OnResumeSuccessHandler {
|
|
1735
|
+
handleSuccess(): any;
|
|
1736
|
+
handleFailure(errorMessage?: string): any;
|
|
1737
|
+
continueWithNewClientToken(clientToken: string): any;
|
|
1738
|
+
}
|
|
1739
|
+
export type OnResumeSuccess = (data: ResumeToken, handler: OnResumeSuccessHandler) => void;
|
|
1740
|
+
export type onResumeError = (error: PrimerClientError) => void;
|
|
1741
|
+
export type OnResumePending = (paymentMethodData: PaymentMethodData$1) => void;
|
|
1742
|
+
export interface TokenizationHandlers {
|
|
1743
|
+
onTokenizeShouldStart?: OnTokenizeShouldStart;
|
|
1744
|
+
onTokenizeDidNotStart?: OnTokenizeDidNotStart;
|
|
1745
|
+
onTokenizeStart?: OnTokenizeStart;
|
|
1746
|
+
onTokenizeSuccess?: OnTokenizeSuccess;
|
|
1747
|
+
onTokenizeError?: OnTokenizeError;
|
|
1748
|
+
onResumeSuccess?: OnResumeSuccess;
|
|
1749
|
+
onResumePending?: OnResumePending;
|
|
1750
|
+
onResumeError?: onResumeError;
|
|
1751
|
+
}
|
|
1752
|
+
export interface PaymentMethodHandlers {
|
|
1753
|
+
onPaymentMethodAction?: (paymentMethodAction: PaymentMethodAction, { paymentMethodType, }: {
|
|
1754
|
+
paymentMethodType: PaymentMethodType | string | null;
|
|
1755
|
+
}) => void;
|
|
1756
|
+
}
|
|
1757
|
+
export interface ClientSessionHandlers {
|
|
1758
|
+
onClientSessionUpdate?: (clientSession: ClientSession) => void;
|
|
1759
|
+
onBeforeClientSessionUpdate?: () => void;
|
|
1760
|
+
}
|
|
1761
|
+
export interface VaultManagerOptions extends WithAllowedCardNetworks {
|
|
1762
|
+
container: string | Element;
|
|
1763
|
+
locale?: SupportedLocale;
|
|
1764
|
+
vaultOnly?: boolean;
|
|
1765
|
+
deletionDisabled?: boolean;
|
|
1766
|
+
style?: CheckoutStyle;
|
|
1767
|
+
scene?: SceneOptions;
|
|
1768
|
+
errorMessage?: ErrorMessageOptions;
|
|
1769
|
+
form?: FormOptions;
|
|
1770
|
+
submitButton?: SubmitButtonOptions;
|
|
1771
|
+
processingIndicator?: ProcessingIndicatorOptions;
|
|
1772
|
+
card?: CheckoutCardOptions;
|
|
1773
|
+
threeDSecure?: ThreeDSVerificationOptions;
|
|
1774
|
+
giftCard?: CustomizablePaymentMethodButton;
|
|
1775
|
+
directDebit?: DirectDebitOptions;
|
|
1776
|
+
paypal?: Omit<PayPalOptions, "container">;
|
|
1777
|
+
onTokenizeShouldStart?: OnTokenizeShouldStart;
|
|
1778
|
+
onTokenizeDidNotStart?: OnTokenizeDidNotStart;
|
|
1779
|
+
onTokenizeStart?: () => void;
|
|
1780
|
+
onTokenizeSuccess?: (data: PaymentMethodToken) => void;
|
|
1781
|
+
onTokenizeError?: (message: PrimerClientError) => void;
|
|
1782
|
+
apiVersion?: APIVersionOption;
|
|
1783
|
+
}
|
|
1784
|
+
export interface UniversalCheckoutOptions extends TokenizationHandlers, PaymentHandlers, PaymentMethodHandlers, ClientSessionHandlers, WithAllowedCardNetworks {
|
|
1785
|
+
uxFlow?: CheckoutUXFlow.CHECKOUT;
|
|
1786
|
+
container: string | Element;
|
|
1787
|
+
locale?: SupportedLocale;
|
|
1788
|
+
style?: CheckoutStyle;
|
|
1789
|
+
scene?: SceneOptions;
|
|
1790
|
+
vault?: VaultOptions;
|
|
1791
|
+
submitButton?: SubmitButtonOptions;
|
|
1792
|
+
processingIndicator?: ProcessingIndicatorOptions;
|
|
1793
|
+
errorMessage?: ErrorMessageOptions;
|
|
1794
|
+
successScreen?: SuccessScreenOptions;
|
|
1795
|
+
form?: FormOptions;
|
|
1796
|
+
allowedPaymentMethods?: PaymentMethodType[];
|
|
1797
|
+
card?: CheckoutCardOptions;
|
|
1798
|
+
redirect?: RedirectOptions;
|
|
1799
|
+
paypal?: Omit<PayPalOptions, "container">;
|
|
1800
|
+
googlePay?: Omit<GooglePayOptions, "container">;
|
|
1801
|
+
applePay?: Omit<ApplePayOptions, "container">;
|
|
1802
|
+
adyenKlarna?: AdyenKlarnaOptions;
|
|
1803
|
+
klarna?: KlarnaOptions;
|
|
1804
|
+
directDebit?: DirectDebitOptions;
|
|
1805
|
+
giftCard?: CustomizablePaymentMethodButton;
|
|
1806
|
+
stripe?: StripeOptionsDropIn;
|
|
1807
|
+
paymentHandling?: PaymentHandling;
|
|
1808
|
+
advanced?: AdvancedOptions;
|
|
1809
|
+
clientSessionCachingEnabled?: boolean;
|
|
1810
|
+
apiVersion?: APIVersionOption;
|
|
1811
|
+
}
|
|
1812
|
+
export interface HeadlessUniversalCheckoutOptions extends TokenizationHandlers, PaymentHandlers, PaymentMethodHandlers, ClientSessionHandlers, WithAllowedCardNetworks {
|
|
1813
|
+
style?: CheckoutStyle;
|
|
1814
|
+
paymentHandling?: PaymentHandling;
|
|
1815
|
+
locale?: SupportedLocale;
|
|
1816
|
+
card?: CheckoutCardOptions;
|
|
1817
|
+
redirect?: RedirectOptions;
|
|
1818
|
+
paypal?: Omit<PayPalOptions, "container">;
|
|
1819
|
+
googlePay?: Omit<GooglePayOptions, "container">;
|
|
1820
|
+
applePay?: Omit<ApplePayOptions, "container">;
|
|
1821
|
+
adyenKlarna?: AdyenKlarnaOptions;
|
|
1822
|
+
klarna?: KlarnaOptions;
|
|
1823
|
+
directDebit?: DirectDebitOptions;
|
|
1824
|
+
giftCard?: CustomizablePaymentMethodButton;
|
|
1825
|
+
stripe?: StripeOptions;
|
|
1826
|
+
onAvailablePaymentMethodsLoad: (paymentMethods: PaymentMethodInfo[]) => void;
|
|
1827
|
+
clientSessionCachingEnabled?: boolean;
|
|
1828
|
+
apiVersion?: APIVersionOption;
|
|
1829
|
+
}
|
|
1830
|
+
export type WithAllowedCardNetworks = {
|
|
1831
|
+
/** @deprecated Use `orderedAllowedCardNetworks` on your Primer Dashboard instead. */
|
|
1832
|
+
allowedCardNetworks?: CardNetwork$1[];
|
|
1833
|
+
};
|
|
1834
|
+
export interface PrimerCheckout {
|
|
1835
|
+
teardown(): void;
|
|
1836
|
+
submit(): void;
|
|
1837
|
+
setPaymentCreationEnabled(isEnabled: boolean): void;
|
|
1838
|
+
setTokenizationEnabled(isEnabled: boolean): void;
|
|
1839
|
+
refreshClientSession(): Promise<boolean>;
|
|
1840
|
+
/**
|
|
1841
|
+
* @deprecated The method should not be used
|
|
1842
|
+
*/
|
|
1843
|
+
setClientToken(): Promise<boolean>;
|
|
1844
|
+
}
|
|
1845
|
+
export type EventListener$1 = (event?: Event) => void;
|
|
1846
|
+
declare enum EventTypes {
|
|
1847
|
+
CHANGE = "change",
|
|
1848
|
+
ERROR = "error",
|
|
1849
|
+
FOCUS = "focus",
|
|
1850
|
+
BLUR = "blur",
|
|
1851
|
+
CLICK = "click",
|
|
1852
|
+
CLOSE = "close"
|
|
1853
|
+
}
|
|
1854
|
+
export interface HeadlessHostedInputOptions {
|
|
1855
|
+
placeholder?: string;
|
|
1856
|
+
ariaLabel?: string;
|
|
1857
|
+
style?: CheckoutStyle;
|
|
1858
|
+
}
|
|
1859
|
+
export interface IHeadlessHostedInput {
|
|
1860
|
+
getOptions(): HeadlessHostedInputOptions;
|
|
1861
|
+
setOptions(options: HeadlessHostedInputOptions): void;
|
|
1862
|
+
render(container: string | Element | null, options: HeadlessHostedInputOptions): Promise<void>;
|
|
1863
|
+
addEventListener(event: EventTypes, callback: EventListener$1): void;
|
|
1864
|
+
focus(): void;
|
|
1865
|
+
blur(): void;
|
|
1866
|
+
setDisabled(status: boolean): void;
|
|
1867
|
+
}
|
|
1868
|
+
export interface ICardPaymentMethodManager {
|
|
1869
|
+
createHostedInputs(): {
|
|
1870
|
+
cardNumberInput: IHeadlessHostedInput;
|
|
1871
|
+
expiryInput: IHeadlessHostedInput;
|
|
1872
|
+
cvvInput: IHeadlessHostedInput;
|
|
1873
|
+
};
|
|
1874
|
+
setCardholderName(cardholderName: string): void;
|
|
1875
|
+
removeHostedInputs(): void;
|
|
1876
|
+
submit(values?: CardPaymentMethodSubmitValues): Promise<void>;
|
|
1877
|
+
validate(): Promise<Validation>;
|
|
1878
|
+
reset(): void;
|
|
1879
|
+
}
|
|
1880
|
+
export type CardPaymentMethodSubmitValues = {
|
|
1881
|
+
cardNetwork?: string;
|
|
1882
|
+
};
|
|
1883
|
+
export interface PayPalStyles {
|
|
1884
|
+
buttonColor?: "gold" | "blue" | "silver" | "white" | "black";
|
|
1885
|
+
buttonShape?: "pill" | "rect";
|
|
1886
|
+
buttonSize?: "small" | "medium" | "large" | "responsive";
|
|
1887
|
+
buttonHeight?: number;
|
|
1888
|
+
buttonLabel?: "checkout" | "credit" | "pay" | "buynow" | "paypal" | "installment";
|
|
1889
|
+
buttonTagline?: boolean;
|
|
1890
|
+
}
|
|
1891
|
+
export interface GooglePayStyles {
|
|
1892
|
+
buttonType?: "long" | "short";
|
|
1893
|
+
buttonColor?: "default" | "black" | "white";
|
|
1894
|
+
shadowRoot?: boolean;
|
|
1895
|
+
}
|
|
1896
|
+
export interface ApplePayStyles {
|
|
1897
|
+
buttonType?: "plain" | "buy" | "set-up" | "donate" | "check-out" | "book" | "subscribe";
|
|
1898
|
+
buttonHeight?: number;
|
|
1899
|
+
buttonStyle?: "white" | "white-outline" | "black";
|
|
1900
|
+
}
|
|
1901
|
+
export interface HeadlessButtonRenderOptions {
|
|
1902
|
+
style?: GooglePayStyles | PayPalStyles | ApplePayStyles | Record<string, unknown>;
|
|
1903
|
+
}
|
|
1904
|
+
export interface IHeadlessPaymentMethodButton {
|
|
1905
|
+
render(containerId: string | Element, options: HeadlessButtonRenderOptions): Promise<void>;
|
|
1906
|
+
setDisabled(disabled: boolean): Promise<void>;
|
|
1907
|
+
clean(): void;
|
|
1908
|
+
focus(): void;
|
|
1909
|
+
blur(): void;
|
|
1910
|
+
addEventListener(event: EventTypes, callback: EventListener$1): void;
|
|
1911
|
+
}
|
|
1912
|
+
export interface INativePaymentMethodManager {
|
|
1913
|
+
createButton(): IHeadlessPaymentMethodButton;
|
|
1914
|
+
}
|
|
1915
|
+
export interface IRedirectPaymentMethodManager {
|
|
1916
|
+
start(): Promise<void>;
|
|
1917
|
+
addEventListener(event: EventTypes, callback: EventListener$1): void;
|
|
1918
|
+
}
|
|
1919
|
+
export interface IFormWithRedirectPaymentMethodManager<T> {
|
|
1920
|
+
start(): any;
|
|
1921
|
+
submit(data: T): any;
|
|
1922
|
+
}
|
|
1923
|
+
export interface IKlarnaPaymentMethodManager {
|
|
1924
|
+
start(paymentPayload: KlarnaPaymentPayload): Promise<KlarnaPaymentResponse>;
|
|
1925
|
+
renderCategory(renderCategoryDetails: RenderCategoryDetails): Promise<void>;
|
|
1926
|
+
addEventListener(event: EventTypes, callback: EventListener$1): void;
|
|
1927
|
+
getPaymentMethod(): void;
|
|
1928
|
+
}
|
|
1929
|
+
export interface IAchPaymentMethodManager {
|
|
1930
|
+
start(paymentDetails: StripeAchCustomerDetails): Promise<Validation | void>;
|
|
1931
|
+
collectBankAccountDetails(): Promise<void>;
|
|
1932
|
+
confirmMandate(): Promise<void>;
|
|
1933
|
+
declineMandate(): Promise<void>;
|
|
1934
|
+
getPaymentMethod(): void;
|
|
1935
|
+
}
|
|
1936
|
+
declare enum HeadlessManagerType {
|
|
1937
|
+
CARD = "CARD",
|
|
1938
|
+
NATIVE = "NATIVE",
|
|
1939
|
+
REDIRECT = "REDIRECT",
|
|
1940
|
+
FORM_WITH_REDIRECT = "FORM_WITH_REDIRECT",
|
|
1941
|
+
KLARNA = "KLARNA",
|
|
1942
|
+
ACH = "ACH"
|
|
1943
|
+
}
|
|
1944
|
+
export type PaymentMethodInfo = {
|
|
1945
|
+
type: PaymentMethodType;
|
|
1946
|
+
managerType: HeadlessManagerType;
|
|
1947
|
+
};
|
|
1948
|
+
export type ButtonPaymentMethodAsset = {
|
|
1949
|
+
backgroundColor: BackgroundColor;
|
|
1950
|
+
iconUrl: IconUrl;
|
|
1951
|
+
/**
|
|
1952
|
+
* @deprecated The property should not be used. Please use displayName or buttonText instead
|
|
1953
|
+
*/
|
|
1954
|
+
paymentMethodName?: string;
|
|
1955
|
+
buttonText?: string;
|
|
1956
|
+
displayName?: string;
|
|
1957
|
+
};
|
|
1958
|
+
export interface IAssetsManager {
|
|
1959
|
+
getCardNetworkAsset(cardNetwork: string): Promise<CardNetworkAsset>;
|
|
1960
|
+
getPaymentMethodAsset(type: PaymentMethodType): Promise<ButtonPaymentMethodAsset | null>;
|
|
1961
|
+
}
|
|
1962
|
+
export type CardNetworkAsset = {
|
|
1963
|
+
cardUrl: string;
|
|
1964
|
+
displayName: string;
|
|
1965
|
+
};
|
|
1966
|
+
export interface CardPaymentMethodManagerOptions {
|
|
1967
|
+
/** @deprecated Use onCardNetworksChange instead. */
|
|
1968
|
+
onCardMetadataChange?: (metadata: CardMetadata) => void;
|
|
1969
|
+
onCardNetworksChange?: (event: CardNetworkChangeEvent) => void;
|
|
1970
|
+
onCardNetworksLoading?: () => void;
|
|
1971
|
+
}
|
|
1972
|
+
export type CardNetworkChangeEvent = {
|
|
1973
|
+
detectedCardNetworks: CardNetworks;
|
|
1974
|
+
selectableCardNetworks?: CardNetworks;
|
|
1975
|
+
source: "REMOTE" | "LOCAL" | "LOCAL_FALLBACK";
|
|
1976
|
+
};
|
|
1977
|
+
export type CardNetworks = {
|
|
1978
|
+
items: CardNetworkDetails[];
|
|
1979
|
+
preferred?: CardNetworkDetails;
|
|
1980
|
+
};
|
|
1981
|
+
export type CardNetworkDetails = CardNetworkInfo & {
|
|
1982
|
+
allowed: boolean;
|
|
1983
|
+
};
|
|
1984
|
+
export type CardNetworkInfo = {
|
|
1985
|
+
displayName: string;
|
|
1986
|
+
network: string;
|
|
1987
|
+
};
|
|
1988
|
+
export type BankIssuer = {
|
|
1989
|
+
id: string;
|
|
1990
|
+
name: string;
|
|
1991
|
+
iconUrl: string;
|
|
1992
|
+
disabled: boolean;
|
|
1993
|
+
};
|
|
1994
|
+
export interface FormWithRedirectConfiguration {
|
|
1995
|
+
bankIssuers?: BankIssuer[];
|
|
1996
|
+
error?: PrimerClientError | Error;
|
|
1997
|
+
}
|
|
1998
|
+
export interface FormWithRedirectPaymentMethodManagerOptions {
|
|
1999
|
+
onConfigurationLoad?: (payload: FormWithRedirectConfiguration) => void;
|
|
2000
|
+
}
|
|
2001
|
+
export interface KlarnaPaymentMethodManagerOptions {
|
|
2002
|
+
onPaymentMethodCategoriesChange?: (paymentMethodCategories: KlarnaPaymentMethodCategory[]) => void;
|
|
2003
|
+
}
|
|
2004
|
+
export interface AchPaymentMethodManagerOptions {
|
|
2005
|
+
onCollectBankAccountDetailsComplete?: () => void;
|
|
2006
|
+
}
|
|
2007
|
+
export type KlarnaPaymentMethodCategory = {
|
|
2008
|
+
id: string;
|
|
2009
|
+
name: string;
|
|
2010
|
+
descriptiveAssetUrl: string;
|
|
2011
|
+
standardAssetUrl: string;
|
|
2012
|
+
};
|
|
2013
|
+
export type KlarnaPaymentPayload = {
|
|
2014
|
+
paymentMethodCategoryId: string;
|
|
2015
|
+
};
|
|
2016
|
+
export type KlarnaPaymentResponse = {
|
|
2017
|
+
outcome: "APPROVED" | "DENIED";
|
|
2018
|
+
};
|
|
2019
|
+
export type RenderCategoryDetails = {
|
|
2020
|
+
containerId: string | Element;
|
|
2021
|
+
paymentMethodCategoryId: string;
|
|
2022
|
+
onHeightChange: (height: number) => void;
|
|
2023
|
+
};
|
|
2024
|
+
export type PaymentMethodManagerOptions = CardPaymentMethodManagerOptions | FormWithRedirectPaymentMethodManagerOptions | KlarnaPaymentMethodManagerOptions;
|
|
2025
|
+
export interface PrimerHeadlessCheckout {
|
|
2026
|
+
createPaymentMethodManager(type: "PAYMENT_CARD", options?: PaymentMethodManagerOptions): Promise<ICardPaymentMethodManager | null>;
|
|
2027
|
+
createPaymentMethodManager(type: "PAYPAL" | "GOOGLE_PAY" | "APPLE_PAY", options?: PaymentMethodManagerOptions): Promise<INativePaymentMethodManager | null>;
|
|
2028
|
+
createPaymentMethodManager(type: "ADYEN_IDEAL", options?: FormWithRedirectPaymentMethodManagerOptions): Promise<IFormWithRedirectPaymentMethodManager<BankIssuer> | null>;
|
|
2029
|
+
createPaymentMethodManager(type: "STRIPE_ACH", options?: AchPaymentMethodManagerOptions): Promise<IAchPaymentMethodManager | null>;
|
|
2030
|
+
createPaymentMethodManager(type: "KLARNA", options?: PaymentMethodManagerOptions): Promise<IKlarnaPaymentMethodManager | null>;
|
|
2031
|
+
createPaymentMethodManager(type: PaymentMethodType, options?: PaymentMethodManagerOptions): Promise<IRedirectPaymentMethodManager | null>;
|
|
2032
|
+
createVaultManager(): HeadlessVaultManager;
|
|
2033
|
+
/**
|
|
2034
|
+
* @deprecated
|
|
2035
|
+
* The options should be set on the `createHeadless` second parameter instead:
|
|
2036
|
+
* ```
|
|
2037
|
+
* Primer.createHeadless('clientToken', options);
|
|
2038
|
+
* ```
|
|
2039
|
+
*/
|
|
2040
|
+
configure: (options: Omit<HeadlessUniversalCheckoutOptions, "clientSessionCachingEnabled">) => void;
|
|
2041
|
+
getAssetsManager(): IAssetsManager;
|
|
2042
|
+
start: () => Promise<void>;
|
|
2043
|
+
refreshClientSession(): Promise<boolean>;
|
|
2044
|
+
}
|
|
2045
|
+
export interface PrimerVaultManager {
|
|
2046
|
+
teardown(): void;
|
|
2047
|
+
submit(): void;
|
|
2048
|
+
}
|
|
2049
|
+
declare const Primer: {
|
|
2050
|
+
SDK_VERSION: string;
|
|
2051
|
+
createHeadless: (clientToken: string, options?: HeadlessUniversalCheckoutOptions | undefined) => Promise<Promise<PrimerHeadlessCheckout>>;
|
|
2052
|
+
showUniversalCheckout: (clientToken: string, options?: UniversalCheckoutOptions | undefined) => Promise<Promise<PrimerCheckout>>;
|
|
2053
|
+
showVaultManager: (clientToken: string, options?: VaultManagerOptions | undefined) => Promise<Promise<PrimerVaultManager>>;
|
|
2054
|
+
preloadPrimer: () => Promise<void>;
|
|
2055
|
+
};
|
|
2056
|
+
export type JSONSafe<T> = T extends (...args: any[]) => any ? never : T extends symbol ? never : T extends bigint ? never : T extends Array<infer U> ? JSONSafe<U>[] : T extends object ? {
|
|
2057
|
+
[K in keyof T as JSONSafe<T[K]> extends never ? never : K]: JSONSafe<T[K]>;
|
|
2058
|
+
} : T;
|
|
2059
|
+
export type PrimerCheckoutOptions = JSONSafe<HeadlessUniversalCheckoutOptions>;
|
|
2060
|
+
declare global {
|
|
2061
|
+
interface Window {
|
|
2062
|
+
Primer: typeof Primer;
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
export type InitializedPaymentAssets = {
|
|
2066
|
+
displayName: string;
|
|
2067
|
+
backgroundColor?: BackgroundColor;
|
|
2068
|
+
buttonText: string;
|
|
2069
|
+
iconUrl?: IconUrl;
|
|
2070
|
+
};
|
|
2071
|
+
export type InitializedManager = {
|
|
2072
|
+
type: typeof PaymentMethodType.STRIPE_ACH;
|
|
2073
|
+
manager: IAchPaymentMethodManager;
|
|
2074
|
+
} | {
|
|
2075
|
+
type: typeof PaymentMethodType.PAYMENT_CARD;
|
|
2076
|
+
manager: ICardPaymentMethodManager;
|
|
2077
|
+
} | {
|
|
2078
|
+
type: typeof PaymentMethodType.KLARNA;
|
|
2079
|
+
manager: IKlarnaPaymentMethodManager;
|
|
2080
|
+
} | {
|
|
2081
|
+
type: RedirectPaymentMethodTypes;
|
|
2082
|
+
manager: IRedirectPaymentMethodManager;
|
|
2083
|
+
} | {
|
|
2084
|
+
type: typeof PaymentMethodType.PAYPAL | typeof PaymentMethodType.GOOGLE_PAY | typeof PaymentMethodType.APPLE_PAY;
|
|
2085
|
+
manager: INativePaymentMethodManager;
|
|
2086
|
+
};
|
|
2087
|
+
export type ManagerByType<T extends PaymentMethodType> = Extract<InitializedManager, {
|
|
2088
|
+
type: T;
|
|
2089
|
+
}>;
|
|
2090
|
+
export interface InitializedManagersMap extends Map<PaymentMethodType, InitializedManager> {
|
|
2091
|
+
get<T extends PaymentMethodType>(key: T): ManagerByType<T> | undefined;
|
|
2092
|
+
}
|
|
2093
|
+
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>;
|
|
2094
|
+
export type RedirectPaymentMethod = {
|
|
2095
|
+
type: RedirectPaymentMethodTypes;
|
|
2096
|
+
managerType: HeadlessManagerType.REDIRECT;
|
|
2097
|
+
assets: InitializedPaymentAssets;
|
|
2098
|
+
};
|
|
2099
|
+
export type InitializedPaymentMethod = {
|
|
2100
|
+
type: typeof PaymentMethodType.STRIPE_ACH;
|
|
2101
|
+
managerType: HeadlessManagerType.ACH;
|
|
2102
|
+
assets: InitializedPaymentAssets;
|
|
2103
|
+
} | {
|
|
2104
|
+
type: typeof PaymentMethodType.PAYMENT_CARD;
|
|
2105
|
+
managerType: HeadlessManagerType.CARD;
|
|
2106
|
+
assets: null;
|
|
2107
|
+
} | {
|
|
2108
|
+
type: typeof PaymentMethodType.KLARNA;
|
|
2109
|
+
managerType: HeadlessManagerType.KLARNA;
|
|
2110
|
+
assets: InitializedPaymentAssets;
|
|
2111
|
+
} | {
|
|
2112
|
+
type: typeof PaymentMethodType.PAYPAL;
|
|
2113
|
+
managerType: HeadlessManagerType.NATIVE;
|
|
2114
|
+
assets: null;
|
|
2115
|
+
} | {
|
|
2116
|
+
type: typeof PaymentMethodType.GOOGLE_PAY;
|
|
2117
|
+
managerType: HeadlessManagerType.NATIVE;
|
|
2118
|
+
assets: null;
|
|
2119
|
+
} | {
|
|
2120
|
+
type: typeof PaymentMethodType.APPLE_PAY;
|
|
2121
|
+
managerType: HeadlessManagerType.NATIVE;
|
|
2122
|
+
assets: null;
|
|
2123
|
+
} | RedirectPaymentMethod;
|
|
2124
|
+
export type PaymentMethodByType<T extends PaymentMethodType> = Extract<InitializedPaymentMethod, {
|
|
2125
|
+
type: T;
|
|
2126
|
+
}>;
|
|
2127
|
+
export interface InitializedPaymentMethodMap extends Map<PaymentMethodType, InitializedPaymentMethod> {
|
|
2128
|
+
get<T extends PaymentMethodType>(key: T): PaymentMethodByType<T> | undefined;
|
|
2129
|
+
}
|
|
2130
|
+
declare class PaymentsObject {
|
|
2131
|
+
private readonly _methods;
|
|
2132
|
+
constructor(map: InitializedPaymentMethodMap);
|
|
2133
|
+
get<T extends RedirectPaymentMethodTypes>(type: T): RedirectPaymentMethod | undefined;
|
|
2134
|
+
get<T extends (typeof PaymentMethodType)[keyof typeof PaymentMethodType]>(type: T): PaymentMethodByType<T> | undefined;
|
|
2135
|
+
toArray(): InitializedPaymentMethod[];
|
|
2136
|
+
size(): number;
|
|
2137
|
+
}
|
|
2138
|
+
export type SdkStateContext = {
|
|
2139
|
+
isSuccessful: boolean;
|
|
2140
|
+
isProcessing: boolean;
|
|
2141
|
+
error?: Error;
|
|
2142
|
+
isLoading?: boolean;
|
|
2143
|
+
failure?: {
|
|
2144
|
+
code: string;
|
|
2145
|
+
message: string;
|
|
2146
|
+
details?: Record<string, unknown>;
|
|
2147
|
+
};
|
|
2148
|
+
};
|
|
2149
|
+
export interface CardSubmitSuccessPayload {
|
|
2150
|
+
result: unknown;
|
|
2151
|
+
}
|
|
2152
|
+
export interface CardSubmitErrorsPayload {
|
|
2153
|
+
errors: unknown | InputValidationError[];
|
|
2154
|
+
}
|
|
2155
|
+
export interface PrimerEvents {
|
|
2156
|
+
"primer-state-changed": CustomEvent<SdkStateContext>;
|
|
2157
|
+
"primer-payment-methods-updated": CustomEvent<PaymentsObject>;
|
|
2158
|
+
"primer-checkout-initialized": CustomEvent<PrimerHeadlessCheckout>;
|
|
2159
|
+
"primer-card-network-change": CustomEvent<CardNetworksContext>;
|
|
2160
|
+
"primer-card-submit-success": CustomEvent<CardSubmitSuccessPayload>;
|
|
2161
|
+
"primer-card-submit-errors": CustomEvent<CardSubmitErrorsPayload>;
|
|
2162
|
+
}
|
|
2163
|
+
declare class PrimerEventsController implements ReactiveController {
|
|
2164
|
+
host: ReactiveControllerHost & LitElement;
|
|
2165
|
+
constructor(host: ReactiveControllerHost & LitElement);
|
|
2166
|
+
hostConnected(): void;
|
|
2167
|
+
/**
|
|
2168
|
+
* Dispatch a custom event using the unified naming pattern.
|
|
2169
|
+
* Ensures that every event bubbles and crosses shadow DOM boundaries.
|
|
2170
|
+
*
|
|
2171
|
+
* @param type - The event name as defined in PrimerEvents.
|
|
2172
|
+
* @param detail - The payload for the event.
|
|
2173
|
+
*/
|
|
2174
|
+
dispatchEvent<K extends keyof PrimerEvents>(type: K, detail: PrimerEvents[K]["detail"]): void;
|
|
2175
|
+
dispatchSdkState(sdkState: SdkStateContext): void;
|
|
2176
|
+
dispatchPaymentMethods(paymentMethods: PaymentsObject): void;
|
|
2177
|
+
dispatchCheckoutInitialized(checkoutInstance: PrimerHeadlessCheckout): void;
|
|
2178
|
+
dispatchCardNetworkChange(network: CardNetworksContext): void;
|
|
2179
|
+
dispatchFormSubmitSuccess(result: unknown): void;
|
|
2180
|
+
dispatchFormSubmitErrors(errors: unknown): void;
|
|
2181
|
+
}
|
|
2182
|
+
declare class SdkStateController implements ReactiveController {
|
|
2183
|
+
host: PrimerCheckoutType;
|
|
2184
|
+
private _state;
|
|
2185
|
+
constructor(host: PrimerCheckoutType);
|
|
2186
|
+
hostConnected(): void;
|
|
2187
|
+
private reducer;
|
|
2188
|
+
private dispatch;
|
|
2189
|
+
startLoading(): void;
|
|
2190
|
+
startProcessing(): void;
|
|
2191
|
+
completeProcessing(): void;
|
|
2192
|
+
completeLoading(): void;
|
|
2193
|
+
setError(error: Error): void;
|
|
2194
|
+
setFailure(code: string, message: string, details?: Record<string, unknown>): void;
|
|
2195
|
+
reset(): void;
|
|
2196
|
+
get state(): SdkStateContext;
|
|
2197
|
+
}
|
|
2198
|
+
export interface PrimerCheckoutType extends ReactiveControllerHost, LitElement {
|
|
2199
|
+
requestUpdate: ReactiveControllerHost["requestUpdate"];
|
|
2200
|
+
customStyles: string;
|
|
2201
|
+
clientToken: string;
|
|
2202
|
+
options: PrimerCheckoutOptions;
|
|
2203
|
+
sdkContextController: SDKContextController;
|
|
2204
|
+
sdkStateController: SdkStateController;
|
|
2205
|
+
primerEventsController: PrimerEventsController;
|
|
2206
|
+
}
|
|
2207
|
+
declare class SDKContextController implements ReactiveController {
|
|
2208
|
+
host: PrimerCheckoutType;
|
|
2209
|
+
private sdkStateProvider;
|
|
2210
|
+
private paymentMethodsProvider;
|
|
2211
|
+
private paymentManagerProvider;
|
|
2212
|
+
private cardNetworksContext;
|
|
2213
|
+
constructor(host: PrimerCheckoutType);
|
|
2214
|
+
hostConnected(): void;
|
|
2215
|
+
/**
|
|
2216
|
+
* Updates the SDK state context.
|
|
2217
|
+
* @param value The new SDK state.
|
|
2218
|
+
*/
|
|
2219
|
+
setSdkState(value: SdkStateContext): void;
|
|
2220
|
+
/**
|
|
2221
|
+
* Updates the payment methods context.
|
|
2222
|
+
* @param value The new payment methods data.
|
|
2223
|
+
*/
|
|
2224
|
+
setPaymentMethods(value: PaymentsObject): void;
|
|
2225
|
+
/**
|
|
2226
|
+
* Updates the payment manager context.
|
|
2227
|
+
* @param value The new payment manager mapping.
|
|
2228
|
+
*/
|
|
2229
|
+
setPaymentManagers(value: InitializedManagersMap): void;
|
|
2230
|
+
setCardNetworks(value: CardNetworksContext): void;
|
|
2231
|
+
}
|
|
2232
|
+
declare class StyleProcessingController implements ReactiveController {
|
|
2233
|
+
host: ReactiveControllerHost & LitElement;
|
|
2234
|
+
private static cssVarCache;
|
|
2235
|
+
constructor(host: ReactiveControllerHost & LitElement);
|
|
2236
|
+
/**
|
|
2237
|
+
* Processes the customStyles JSON string.
|
|
2238
|
+
* Expected JSON contains only CSS variable properties in camelCase.
|
|
2239
|
+
* @param jsonString The JSON string representing custom styles.
|
|
2240
|
+
*/
|
|
2241
|
+
processCustomStyles(jsonString: string): void;
|
|
2242
|
+
/**
|
|
2243
|
+
* Validates a CSS property name to ensure it follows expected patterns.
|
|
2244
|
+
* @param property The CSS property name to validate.
|
|
2245
|
+
* @returns boolean True if the property name is considered valid.
|
|
2246
|
+
*/
|
|
2247
|
+
private isValidCssProperty;
|
|
2248
|
+
/**
|
|
2249
|
+
* Validates a CSS value to ensure it only contains safe, expected characters.
|
|
2250
|
+
* Allowed characters include alphanumerics, whitespace, and common CSS punctuation.
|
|
2251
|
+
* This helps prevent CSS injection attacks.
|
|
2252
|
+
*
|
|
2253
|
+
* @param value The CSS value to validate.
|
|
2254
|
+
* @returns boolean True if the value is considered valid.
|
|
2255
|
+
*/
|
|
2256
|
+
private isValidCssValue;
|
|
2257
|
+
/**
|
|
2258
|
+
* Gets the CSS variable name for a camelCase property key.
|
|
2259
|
+
* Uses caching for performance.
|
|
2260
|
+
*
|
|
2261
|
+
* @param key The camelCase property key
|
|
2262
|
+
* @returns The CSS variable name (kebab-case with -- prefix)
|
|
2263
|
+
*/
|
|
2264
|
+
private getCssVarName;
|
|
2265
|
+
/**
|
|
2266
|
+
* Transforms a styles object into CSS variables and applies them to the host element.
|
|
2267
|
+
* Each key (in camelCase) is converted into a kebab-case CSS variable prefixed with '--'.
|
|
2268
|
+
* Only valid CSS properties and values are applied.
|
|
2269
|
+
*
|
|
2270
|
+
* @param styles An object with style keys and corresponding CSS values.
|
|
2271
|
+
*/
|
|
2272
|
+
private applyStyles;
|
|
2273
|
+
/**
|
|
2274
|
+
* Removes a specific CSS variable from the host element
|
|
2275
|
+
* @param key The camelCase property key to remove
|
|
2276
|
+
*/
|
|
2277
|
+
removeStyle(key: string): void;
|
|
2278
|
+
/**
|
|
2279
|
+
* Removes all custom styles from the host element
|
|
2280
|
+
*/
|
|
2281
|
+
clearAllStyles(): void;
|
|
2282
|
+
/**
|
|
2283
|
+
* Optional cleanup when the host is disconnected
|
|
2284
|
+
*/
|
|
2285
|
+
hostDisconnected(): void;
|
|
2286
|
+
}
|
|
2287
|
+
declare const sourceLocale = `en`;
|
|
2288
|
+
declare const targetLocales = [
|
|
2289
|
+
`ar`,
|
|
2290
|
+
`bg`,
|
|
2291
|
+
`ca`,
|
|
2292
|
+
`cs`,
|
|
2293
|
+
`da`,
|
|
2294
|
+
`de`,
|
|
2295
|
+
`el`,
|
|
2296
|
+
`en-GB`,
|
|
2297
|
+
`es`,
|
|
2298
|
+
`es-AR`,
|
|
2299
|
+
`es-MX`,
|
|
2300
|
+
`et-EE`,
|
|
2301
|
+
`fi-FI`,
|
|
2302
|
+
`fr`,
|
|
2303
|
+
`he`,
|
|
2304
|
+
`hr`,
|
|
2305
|
+
`hu`,
|
|
2306
|
+
`id`,
|
|
2307
|
+
`it`,
|
|
2308
|
+
`ja`,
|
|
2309
|
+
`ko`,
|
|
2310
|
+
`lt`,
|
|
2311
|
+
`lt-LT`,
|
|
2312
|
+
`lv`,
|
|
2313
|
+
`lv-LV`,
|
|
2314
|
+
`ms`,
|
|
2315
|
+
`nb`,
|
|
2316
|
+
`nl`,
|
|
2317
|
+
`nl_NL`,
|
|
2318
|
+
`pl`,
|
|
2319
|
+
`pt`,
|
|
2320
|
+
`pt-BR`,
|
|
2321
|
+
`ro`,
|
|
2322
|
+
`ru`,
|
|
2323
|
+
`sk`,
|
|
2324
|
+
`sl`,
|
|
2325
|
+
`sr-RS`,
|
|
2326
|
+
`sv`,
|
|
2327
|
+
`th`,
|
|
2328
|
+
`tr`,
|
|
2329
|
+
`uk-UA`,
|
|
2330
|
+
`vi`,
|
|
2331
|
+
`zf`,
|
|
2332
|
+
`zh-CN`,
|
|
2333
|
+
`zh-HK`,
|
|
2334
|
+
`zh-TW`,
|
|
2335
|
+
] as const;
|
|
2336
|
+
export type LocaleCode = typeof sourceLocale | (typeof targetLocales)[number];
|
|
2337
|
+
declare class PrimerCheckoutComponent extends LitElement implements PrimerCheckoutType {
|
|
2338
|
+
static styles: CSSResult[];
|
|
2339
|
+
customStyles: string;
|
|
2340
|
+
clientToken: string;
|
|
2341
|
+
options: PrimerCheckoutOptions;
|
|
2342
|
+
disableLoader: boolean;
|
|
2343
|
+
defaultSlot: HTMLSlotElement;
|
|
2344
|
+
private hasAssignedContent;
|
|
2345
|
+
locale?: LocaleCode;
|
|
2346
|
+
private onSlotChange;
|
|
2347
|
+
sdkContextController: SDKContextController;
|
|
2348
|
+
sdkStateController: SdkStateController;
|
|
2349
|
+
primerEventsController: PrimerEventsController;
|
|
2350
|
+
styleProcessingController: StyleProcessingController;
|
|
2351
|
+
constructor();
|
|
2352
|
+
attributeChangedCallback(attrName: string, oldVal: string, newVal: string): void;
|
|
2353
|
+
willUpdate(changedProperties: PropertyValues): void;
|
|
2354
|
+
render(): TemplateResult;
|
|
2355
|
+
addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: PrimerCheckoutComponent, ev: HTMLElementEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
2356
|
+
addEventListener<K extends keyof ShadowRootEventMap>(type: K, listener: (this: PrimerCheckoutComponent, ev: ShadowRootEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
2357
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: PrimerCheckoutComponent, ev: DocumentEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
2358
|
+
addEventListener<K extends keyof PrimerEvents>(type: K, listener: (this: PrimerCheckoutComponent, ev: PrimerEvents[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
2359
|
+
}
|
|
2360
|
+
/**
|
|
2361
|
+
* Size options for the spinner component
|
|
2362
|
+
*/
|
|
2363
|
+
export type SpinnerSize = "small" | "medium" | "large";
|
|
2364
|
+
declare class SpinnerComponent extends LitElement {
|
|
2365
|
+
/**
|
|
2366
|
+
* Color of the spinner
|
|
2367
|
+
* Defaults to the design system loader color
|
|
2368
|
+
*/
|
|
2369
|
+
color: string;
|
|
2370
|
+
/**
|
|
2371
|
+
* Size of the spinner
|
|
2372
|
+
* Available values: 'small', 'medium', 'large' or a custom number as string
|
|
2373
|
+
*/
|
|
2374
|
+
size: SpinnerSize | string;
|
|
2375
|
+
/**
|
|
2376
|
+
* Whether to use compact mode (minimal margins)
|
|
2377
|
+
* Useful when embedding in inputs
|
|
2378
|
+
*/
|
|
2379
|
+
compact: boolean;
|
|
2380
|
+
static styles: CSSResult[];
|
|
2381
|
+
/**
|
|
2382
|
+
* Get the actual size value in pixels
|
|
2383
|
+
*/
|
|
2384
|
+
private getSize;
|
|
2385
|
+
render(): TemplateResult<1>;
|
|
2386
|
+
}
|
|
2387
|
+
declare global {
|
|
2388
|
+
interface HTMLElementTagNameMap {
|
|
2389
|
+
"primer-spinner": SpinnerComponent;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
declare class InputWrapperComponent extends LitElement {
|
|
2393
|
+
static styles: CSSResult[];
|
|
2394
|
+
focusWithin: boolean;
|
|
2395
|
+
hasError: boolean;
|
|
2396
|
+
private inputSlot;
|
|
2397
|
+
/**
|
|
2398
|
+
* Event handler for click events on the input slot wrapper.
|
|
2399
|
+
* Does one of the following:
|
|
2400
|
+
* 1. If a primer-input is found inside, focus it directly
|
|
2401
|
+
* 2. Otherwise, dispatch a wrapper-click event for hosted inputs to handle
|
|
2402
|
+
*/
|
|
2403
|
+
private handleWrapperClick;
|
|
2404
|
+
/**
|
|
2405
|
+
* Finds the first primer-input element inside the input slot
|
|
2406
|
+
* @returns The primer-input element or null if not found
|
|
2407
|
+
*/
|
|
2408
|
+
private findSlottedPrimerInput;
|
|
2409
|
+
render(): TemplateResult<1>;
|
|
2410
|
+
}
|
|
2411
|
+
declare global {
|
|
2412
|
+
interface HTMLElementTagNameMap {
|
|
2413
|
+
"primer-input-wrapper": InputWrapperComponent;
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
declare class InputLabelComponent extends LitElement {
|
|
2417
|
+
static styles: CSSResult[];
|
|
2418
|
+
/**
|
|
2419
|
+
* ID of the form control this label is associated with
|
|
2420
|
+
*/
|
|
2421
|
+
for: string;
|
|
2422
|
+
/**
|
|
2423
|
+
* Whether the label should appear disabled
|
|
2424
|
+
*/
|
|
2425
|
+
disabled: boolean;
|
|
2426
|
+
render(): TemplateResult<1>;
|
|
2427
|
+
}
|
|
2428
|
+
declare global {
|
|
2429
|
+
interface HTMLElementTagNameMap {
|
|
2430
|
+
"primer-input-label": InputLabelComponent;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
declare class ButtonComponent extends LitElement {
|
|
2434
|
+
static styles: CSSResult[];
|
|
2435
|
+
variant: "primary" | "secondary" | "tertiary";
|
|
2436
|
+
disabled: boolean;
|
|
2437
|
+
buttonType: "button" | "submit" | "reset";
|
|
2438
|
+
render(): TemplateResult<1>;
|
|
2439
|
+
}
|
|
2440
|
+
declare global {
|
|
2441
|
+
interface HTMLElementTagNameMap {
|
|
2442
|
+
"primer-button": ButtonComponent;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
declare class InputErrorComponent extends LitElement {
|
|
2446
|
+
static styles: CSSResult[];
|
|
2447
|
+
/**
|
|
2448
|
+
* ID of the form control this error message is associated with
|
|
2449
|
+
*/
|
|
2450
|
+
for: string;
|
|
2451
|
+
/**
|
|
2452
|
+
* Whether the error is currently active/visible
|
|
2453
|
+
*/
|
|
2454
|
+
active: boolean;
|
|
2455
|
+
render(): TemplateResult<1>;
|
|
2456
|
+
}
|
|
2457
|
+
declare global {
|
|
2458
|
+
interface HTMLElementTagNameMap {
|
|
2459
|
+
"primer-input-error": InputErrorComponent;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
export type IconName = keyof typeof icons;
|
|
2463
|
+
declare const icons: Record<string, SVGTemplateResult>;
|
|
2464
|
+
declare class PrimerIconComponent extends LitElement {
|
|
2465
|
+
static styles: CSSResult[];
|
|
2466
|
+
color: string;
|
|
2467
|
+
size: "lg" | "sm";
|
|
2468
|
+
/** The name of the icon to draw - available names can be found under library.ts file */
|
|
2469
|
+
name?: IconName;
|
|
2470
|
+
render(): TemplateResult<1>;
|
|
2471
|
+
}
|
|
2472
|
+
declare global {
|
|
2473
|
+
interface HTMLElementTagNameMap {
|
|
2474
|
+
"primer-icon": PrimerIconComponent;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
declare class PrimerCheckoutStateComponent extends LitElement {
|
|
2478
|
+
static styles: CSSResult[];
|
|
2479
|
+
type: "complete" | "failure";
|
|
2480
|
+
description?: string;
|
|
2481
|
+
render(): TemplateResult<1>;
|
|
2482
|
+
}
|
|
2483
|
+
declare global {
|
|
2484
|
+
interface HTMLElementTagNameMap {
|
|
2485
|
+
"primer-checkout-state": PrimerCheckoutStateComponent;
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Input types supported by this component
|
|
2490
|
+
*/
|
|
2491
|
+
export type InputType = "text" | "password" | "email" | "number" | "tel" | "url" | "search" | "date" | "time" | "datetime-local" | "month" | "week" | "color";
|
|
2492
|
+
/**
|
|
2493
|
+
* Custom events dispatched by this component
|
|
2494
|
+
*/
|
|
2495
|
+
export type InputEventMap = {
|
|
2496
|
+
input: CustomEvent<string>;
|
|
2497
|
+
change: CustomEvent<string>;
|
|
2498
|
+
focus: FocusEvent;
|
|
2499
|
+
blur: FocusEvent;
|
|
2500
|
+
invalid: Event;
|
|
2501
|
+
};
|
|
2502
|
+
declare class InputComponent extends LitElement {
|
|
2503
|
+
static styles: CSSResult[];
|
|
2504
|
+
private inputElement;
|
|
2505
|
+
value: string;
|
|
2506
|
+
placeholder: string;
|
|
2507
|
+
disabled: boolean;
|
|
2508
|
+
name: string;
|
|
2509
|
+
type: InputType;
|
|
2510
|
+
required: boolean;
|
|
2511
|
+
readonly: boolean;
|
|
2512
|
+
pattern: string;
|
|
2513
|
+
minlength?: number;
|
|
2514
|
+
maxlength?: number;
|
|
2515
|
+
min: string;
|
|
2516
|
+
max: string;
|
|
2517
|
+
step: string;
|
|
2518
|
+
autocomplete: string;
|
|
2519
|
+
id: string;
|
|
2520
|
+
private hasFocus;
|
|
2521
|
+
private hasError;
|
|
2522
|
+
/**
|
|
2523
|
+
* Handles input events and dispatches a custom event with the current value
|
|
2524
|
+
*/
|
|
2525
|
+
private handleInput;
|
|
2526
|
+
/**
|
|
2527
|
+
* Handles change events and dispatches a custom event with the committed value
|
|
2528
|
+
*/
|
|
2529
|
+
private handleChange;
|
|
2530
|
+
/**
|
|
2531
|
+
* Handles focus events and updates internal state
|
|
2532
|
+
*/
|
|
2533
|
+
private handleFocus;
|
|
2534
|
+
/**
|
|
2535
|
+
* Handles blur events and updates internal state
|
|
2536
|
+
*/
|
|
2537
|
+
private handleBlur;
|
|
2538
|
+
/**
|
|
2539
|
+
* Handles invalid events and updates internal state
|
|
2540
|
+
*/
|
|
2541
|
+
private handleInvalid;
|
|
2542
|
+
/**
|
|
2543
|
+
* Focus the input element
|
|
2544
|
+
* @param options Optional focus options
|
|
2545
|
+
*/
|
|
2546
|
+
focus(options?: FocusOptions): void;
|
|
2547
|
+
/**
|
|
2548
|
+
* Remove focus from the input element
|
|
2549
|
+
*/
|
|
2550
|
+
blur(): void;
|
|
2551
|
+
/**
|
|
2552
|
+
* Select all text in the input element
|
|
2553
|
+
*/
|
|
2554
|
+
select(): void;
|
|
2555
|
+
/**
|
|
2556
|
+
* Set the selection range of the input element
|
|
2557
|
+
*/
|
|
2558
|
+
setSelectionRange(start: number, end: number, direction?: "forward" | "backward" | "none"): void;
|
|
2559
|
+
/**
|
|
2560
|
+
* Get the validity state of the input element
|
|
2561
|
+
*/
|
|
2562
|
+
get validity(): ValidityState;
|
|
2563
|
+
/**
|
|
2564
|
+
* Get the validation message of the input element
|
|
2565
|
+
*/
|
|
2566
|
+
get validationMessage(): string;
|
|
2567
|
+
/**
|
|
2568
|
+
* Check if the input element is valid
|
|
2569
|
+
*/
|
|
2570
|
+
checkValidity(): boolean;
|
|
2571
|
+
/**
|
|
2572
|
+
* Report the validity of the input element
|
|
2573
|
+
*/
|
|
2574
|
+
reportValidity(): boolean;
|
|
2575
|
+
render(): TemplateResult<1>;
|
|
2576
|
+
/**
|
|
2577
|
+
* Type safe event dispatcher - allows consumers to use proper types
|
|
2578
|
+
* when listening to events from this component
|
|
2579
|
+
*/
|
|
2580
|
+
addEventListener<K extends keyof InputEventMap>(type: K, listener: (ev: InputEventMap[K]) => void, options?: boolean | AddEventListenerOptions): void;
|
|
2581
|
+
/**
|
|
2582
|
+
* Type safe event dispatcher removal
|
|
2583
|
+
*/
|
|
2584
|
+
removeEventListener<K extends keyof InputEventMap>(type: K, listener: (ev: InputEventMap[K]) => void, options?: boolean | EventListenerOptions): void;
|
|
2585
|
+
}
|
|
2586
|
+
declare global {
|
|
2587
|
+
interface HTMLElementTagNameMap {
|
|
2588
|
+
"primer-input": InputComponent;
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
declare class PaymentMethodComponent extends LitElement {
|
|
2592
|
+
static styles: CSSResult[];
|
|
2593
|
+
type: PaymentMethodType | undefined;
|
|
2594
|
+
paymentMethods: PaymentsObject | null;
|
|
2595
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
2596
|
+
}
|
|
2597
|
+
declare global {
|
|
2598
|
+
interface HTMLElementTagNameMap {
|
|
2599
|
+
"primer-payment-method": PaymentMethodComponent;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
declare class RedirectPaymentComponent extends LitElement {
|
|
2603
|
+
static styles: CSSResult[];
|
|
2604
|
+
paymentMethod: InitializedPaymentMethod | undefined;
|
|
2605
|
+
paymentManagers: InitializedManagersMap;
|
|
2606
|
+
sdkState: SdkStateContext | undefined;
|
|
2607
|
+
private _paymentMethodManagerTask;
|
|
2608
|
+
startRedirectPayment(): void;
|
|
2609
|
+
render(): symbol | TemplateResult<1> | undefined;
|
|
2610
|
+
}
|
|
2611
|
+
declare global {
|
|
2612
|
+
interface HTMLElementTagNameMap {
|
|
2613
|
+
"primer-redirect-payment": RedirectPaymentComponent;
|
|
2614
|
+
}
|
|
2615
|
+
}
|
|
2616
|
+
declare class PrimerMainComponent extends LitElement {
|
|
2617
|
+
static styles: CSSResult[];
|
|
2618
|
+
private hasAssignedContent;
|
|
2619
|
+
/**
|
|
2620
|
+
* Inline slotchange event listener.
|
|
2621
|
+
* Uses assignedNodes with flatten to detect if the slot has any nodes.
|
|
2622
|
+
*/
|
|
2623
|
+
private onSlotChange;
|
|
2624
|
+
paymentMethods: PaymentsObject | null;
|
|
2625
|
+
sdkState: SdkStateContext | undefined;
|
|
2626
|
+
render(): TemplateResult<1>;
|
|
2627
|
+
}
|
|
2628
|
+
declare global {
|
|
2629
|
+
interface HTMLElementTagNameMap {
|
|
2630
|
+
"primer-main": PrimerMainComponent;
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
declare class NativePaymentComponent extends LitElement {
|
|
2634
|
+
static styles: CSSResult[];
|
|
2635
|
+
paymentMethod: InitializedPaymentMethod | undefined;
|
|
2636
|
+
paymentManagers: InitializedManagersMap;
|
|
2637
|
+
private _buttonId;
|
|
2638
|
+
private loadManagerTask;
|
|
2639
|
+
constructor();
|
|
2640
|
+
/**
|
|
2641
|
+
* Calculates the button height based on CSS variables
|
|
2642
|
+
* Mirrors the calculation used in the host styles
|
|
2643
|
+
*/
|
|
2644
|
+
private calculateButtonHeight;
|
|
2645
|
+
/**
|
|
2646
|
+
* Creates render options with appropriate styles based on payment method type
|
|
2647
|
+
*/
|
|
2648
|
+
private createRenderOptions;
|
|
2649
|
+
protected updated(changedProperties: PropertyValues): void;
|
|
2650
|
+
render(): symbol | TemplateResult<1> | undefined;
|
|
2651
|
+
}
|
|
2652
|
+
declare global {
|
|
2653
|
+
interface HTMLElementTagNameMap {
|
|
2654
|
+
"primer-native-payment": NativePaymentComponent;
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
declare class CardFormComponent extends LitElement {
|
|
2658
|
+
static styles: CSSResult[];
|
|
2659
|
+
/**
|
|
2660
|
+
* Tracks whether custom content has been provided via slot
|
|
2661
|
+
*/
|
|
2662
|
+
private hasAssignedContent;
|
|
2663
|
+
private selectedCardNetwork;
|
|
2664
|
+
/**
|
|
2665
|
+
* Payment managers injected from context
|
|
2666
|
+
*/
|
|
2667
|
+
paymentManagers: InitializedManagersMap;
|
|
2668
|
+
/**
|
|
2669
|
+
* Context provider for card form data
|
|
2670
|
+
*/
|
|
2671
|
+
private readonly cardFormProvider;
|
|
2672
|
+
/**
|
|
2673
|
+
* Events controller for dispatching form events
|
|
2674
|
+
*/
|
|
2675
|
+
private readonly eventsController;
|
|
2676
|
+
/**
|
|
2677
|
+
* Task to set up the card form with hosted inputs
|
|
2678
|
+
*/
|
|
2679
|
+
private readonly setupCardFormTask;
|
|
2680
|
+
connectedCallback(): void;
|
|
2681
|
+
disconnectedCallback(): void;
|
|
2682
|
+
/**
|
|
2683
|
+
* Handles click events from slotted content.
|
|
2684
|
+
* Supports both native <button> and custom <primer-button> elements.
|
|
2685
|
+
*/
|
|
2686
|
+
private handleSlotButtonClick;
|
|
2687
|
+
/**
|
|
2688
|
+
* Handles direct submit events from child components
|
|
2689
|
+
* This is a backup method to catch all possible submission events
|
|
2690
|
+
*/
|
|
2691
|
+
private handleDirectSubmit;
|
|
2692
|
+
/**
|
|
2693
|
+
* Determines if a button is a submit button based on its attributes
|
|
2694
|
+
*/
|
|
2695
|
+
private isSubmitButton;
|
|
2696
|
+
/**
|
|
2697
|
+
* Handles slot change events to detect custom content
|
|
2698
|
+
*/
|
|
2699
|
+
private onSlotChange;
|
|
2700
|
+
/**
|
|
2701
|
+
* Handles the card form submission.
|
|
2702
|
+
* Validates the form and dispatches either a submit success or errors event.
|
|
2703
|
+
*/
|
|
2704
|
+
private submitCardPayment;
|
|
2705
|
+
/**
|
|
2706
|
+
* Event handler for form submission
|
|
2707
|
+
* Handles both native form submissions and custom events
|
|
2708
|
+
*/
|
|
2709
|
+
private handleFormSubmit;
|
|
2710
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
2711
|
+
}
|
|
2712
|
+
export interface CardFormContext {
|
|
2713
|
+
cardNumberInput: IHeadlessHostedInput;
|
|
2714
|
+
expiryInput: IHeadlessHostedInput;
|
|
2715
|
+
cvvInput: IHeadlessHostedInput;
|
|
2716
|
+
setCardholderName: (val: string) => void;
|
|
2717
|
+
setCardNetwork: (val: string) => void;
|
|
2718
|
+
validate: () => Promise<Validation>;
|
|
2719
|
+
submit: (values?: CardPaymentMethodSubmitValues) => Promise<void>;
|
|
2720
|
+
errors?: Validation["validationErrors"];
|
|
2721
|
+
}
|
|
2722
|
+
/**
|
|
2723
|
+
* A shared type that ensures the host of a HostedInputController contains
|
|
2724
|
+
* the required properties for proper hosted input handling.
|
|
2725
|
+
*/
|
|
2726
|
+
export interface HostedInputHost extends ReactiveControllerHost, LitElement {
|
|
2727
|
+
cardFormContext: CardFormContext | null;
|
|
2728
|
+
/** A string for the input placeholder. */
|
|
2729
|
+
placeholder: string;
|
|
2730
|
+
/** An accessible label for the input. */
|
|
2731
|
+
ariaLabel: string;
|
|
2732
|
+
/** The label for the input. */
|
|
2733
|
+
label: string;
|
|
2734
|
+
requestUpdate: ReactiveControllerHost["requestUpdate"];
|
|
2735
|
+
}
|
|
2736
|
+
export interface TaskFunctionOptions {
|
|
2737
|
+
signal: AbortSignal;
|
|
2738
|
+
}
|
|
2739
|
+
export type TaskFunction<D extends ReadonlyArray<unknown>, R = unknown> = (args: D, options: TaskFunctionOptions) => R | typeof initialState | Promise<R | typeof initialState>;
|
|
2740
|
+
export type ArgsFunction<D extends ReadonlyArray<unknown>> = () => D;
|
|
2741
|
+
declare const TaskStatus: {
|
|
2742
|
+
readonly INITIAL: 0;
|
|
2743
|
+
readonly PENDING: 1;
|
|
2744
|
+
readonly COMPLETE: 2;
|
|
2745
|
+
readonly ERROR: 3;
|
|
2746
|
+
};
|
|
2747
|
+
declare const initialState: unique symbol;
|
|
2748
|
+
export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
|
|
2749
|
+
export type StatusRenderer<R> = {
|
|
2750
|
+
initial?: () => unknown;
|
|
2751
|
+
pending?: () => unknown;
|
|
2752
|
+
complete?: (value: R) => unknown;
|
|
2753
|
+
error?: (error: unknown) => unknown;
|
|
2754
|
+
};
|
|
2755
|
+
export interface TaskConfig<T extends ReadonlyArray<unknown>, R> {
|
|
2756
|
+
task: TaskFunction<T, R>;
|
|
2757
|
+
args?: ArgsFunction<T>;
|
|
2758
|
+
/**
|
|
2759
|
+
* Determines if the task is run automatically when arguments change after a
|
|
2760
|
+
* host update. Default to `true`.
|
|
2761
|
+
*
|
|
2762
|
+
* If `true`, the task checks arguments during the host update (after
|
|
2763
|
+
* `willUpdate()` and before `update()` in Lit) and runs if they change. For
|
|
2764
|
+
* a task to see argument changes they must be done in `willUpdate()` or
|
|
2765
|
+
* earlier. The host element can see task status changes caused by its own
|
|
2766
|
+
* current update.
|
|
2767
|
+
*
|
|
2768
|
+
* If `'afterUpdate'`, the task checks arguments and runs _after_ the host
|
|
2769
|
+
* update. This means that the task can see host changes done in update, such
|
|
2770
|
+
* as rendered DOM. The host element can not see task status changes caused
|
|
2771
|
+
* by its own update, so the task must trigger a second host update to make
|
|
2772
|
+
* those changes renderable.
|
|
2773
|
+
*
|
|
2774
|
+
* Note: `'afterUpdate'` is unlikely to be SSR compatible in the future.
|
|
2775
|
+
*
|
|
2776
|
+
* If `false`, the task is not run automatically, and must be run with the
|
|
2777
|
+
* {@linkcode run} method.
|
|
2778
|
+
*/
|
|
2779
|
+
autoRun?: boolean | "afterUpdate";
|
|
2780
|
+
/**
|
|
2781
|
+
* A function that determines if the current arg and previous args arrays are
|
|
2782
|
+
* equal. If the argsEqual function returns true, the task will not auto-run.
|
|
2783
|
+
*
|
|
2784
|
+
* The default is {@linkcode shallowArrayEquals}. {@linkcode deepArrayEquals}
|
|
2785
|
+
* is also available.
|
|
2786
|
+
*/
|
|
2787
|
+
argsEqual?: (oldArgs: T, newArgs: T) => boolean;
|
|
2788
|
+
/**
|
|
2789
|
+
* If initialValue is provided, the task is initialized to the COMPLETE
|
|
2790
|
+
* status and the value is set to initialData.
|
|
2791
|
+
*
|
|
2792
|
+
* Initial args should be coherent with the initialValue, since they are
|
|
2793
|
+
* assumed to be the args that would produce that value. When autoRun is
|
|
2794
|
+
* `true` the task will not auto-run again until the args change.
|
|
2795
|
+
*/
|
|
2796
|
+
initialValue?: R;
|
|
2797
|
+
onComplete?: (value: R) => unknown;
|
|
2798
|
+
onError?: (error: unknown) => unknown;
|
|
2799
|
+
}
|
|
2800
|
+
declare class Task<const T extends ReadonlyArray<unknown> = ReadonlyArray<unknown>, const R = unknown> {
|
|
2801
|
+
private _previousArgs?;
|
|
2802
|
+
private _task;
|
|
2803
|
+
private _argsFn?;
|
|
2804
|
+
private _argsEqual;
|
|
2805
|
+
private _callId;
|
|
2806
|
+
private _host;
|
|
2807
|
+
private _value?;
|
|
2808
|
+
private _error?;
|
|
2809
|
+
private _abortController?;
|
|
2810
|
+
private _onComplete?;
|
|
2811
|
+
private _onError?;
|
|
2812
|
+
private _status;
|
|
2813
|
+
/**
|
|
2814
|
+
* Determines if the task is run automatically when arguments change after a
|
|
2815
|
+
* host update. Default to `true`.
|
|
2816
|
+
*
|
|
2817
|
+
* @see {@link TaskConfig.autoRun} for more information.
|
|
2818
|
+
*/
|
|
2819
|
+
autoRun: boolean | "afterUpdate";
|
|
2820
|
+
/**
|
|
2821
|
+
* A Promise that resolve when the current task run is complete.
|
|
2822
|
+
*
|
|
2823
|
+
* If a new task run is started while a previous run is pending, the Promise
|
|
2824
|
+
* is kept and only resolved when the new run is completed.
|
|
2825
|
+
*/
|
|
2826
|
+
get taskComplete(): Promise<R>;
|
|
2827
|
+
private _resolveTaskComplete?;
|
|
2828
|
+
private _rejectTaskComplete?;
|
|
2829
|
+
private _taskComplete?;
|
|
2830
|
+
constructor(host: ReactiveControllerHost, task: TaskConfig<T, R>);
|
|
2831
|
+
constructor(host: ReactiveControllerHost, task: TaskFunction<T, R>, args?: ArgsFunction<T>);
|
|
2832
|
+
hostUpdate(): void;
|
|
2833
|
+
hostUpdated(): void;
|
|
2834
|
+
private _getArgs;
|
|
2835
|
+
/**
|
|
2836
|
+
* Determines if the task should run when it's triggered because of a
|
|
2837
|
+
* host update, and runs the task if it should.
|
|
2838
|
+
*
|
|
2839
|
+
* A task should run when its arguments change from the previous run, based on
|
|
2840
|
+
* the args equality function.
|
|
2841
|
+
*
|
|
2842
|
+
* This method is side-effectful: it stores the new args as the previous args.
|
|
2843
|
+
*/
|
|
2844
|
+
private _performTask;
|
|
2845
|
+
/**
|
|
2846
|
+
* Runs a task manually.
|
|
2847
|
+
*
|
|
2848
|
+
* This can be useful for running tasks in response to events as opposed to
|
|
2849
|
+
* automatically running when host element state changes.
|
|
2850
|
+
*
|
|
2851
|
+
* @param args an optional set of arguments to use for this task run. If args
|
|
2852
|
+
* is not given, the args function is called to get the arguments for
|
|
2853
|
+
* this run.
|
|
2854
|
+
*/
|
|
2855
|
+
run(args?: T): Promise<void>;
|
|
2856
|
+
/**
|
|
2857
|
+
* Aborts the currently pending task run by aborting the AbortSignal
|
|
2858
|
+
* passed to the task function.
|
|
2859
|
+
*
|
|
2860
|
+
* Aborting a task does nothing if the task is not running: ie, in the
|
|
2861
|
+
* complete, error, or initial states.
|
|
2862
|
+
*
|
|
2863
|
+
* Aborting a task does not automatically cancel the task function. The task
|
|
2864
|
+
* function must be written to accept the AbortSignal and either forward it
|
|
2865
|
+
* to other APIs like `fetch()`, or handle cancellation manually by using
|
|
2866
|
+
* [`signal.throwIfAborted()`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/throwIfAborted}
|
|
2867
|
+
* or the
|
|
2868
|
+
* [`abort`]{@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/abort_event}
|
|
2869
|
+
* event.
|
|
2870
|
+
*
|
|
2871
|
+
* @param reason The reason for aborting. Passed to
|
|
2872
|
+
* `AbortController.abort()`.
|
|
2873
|
+
*/
|
|
2874
|
+
abort(reason?: unknown): void;
|
|
2875
|
+
/**
|
|
2876
|
+
* The result of the previous task run, if it resolved.
|
|
2877
|
+
*
|
|
2878
|
+
* Is `undefined` if the task has not run yet, or if the previous run errored.
|
|
2879
|
+
*/
|
|
2880
|
+
get value(): R | undefined;
|
|
2881
|
+
/**
|
|
2882
|
+
* The error from the previous task run, if it rejected.
|
|
2883
|
+
*
|
|
2884
|
+
* Is `undefined` if the task has not run yet, or if the previous run
|
|
2885
|
+
* completed successfully.
|
|
2886
|
+
*/
|
|
2887
|
+
get error(): unknown;
|
|
2888
|
+
get status(): TaskStatus;
|
|
2889
|
+
render<T extends StatusRenderer<R>>(renderer: T): MaybeReturnType<T["initial"]> | MaybeReturnType<T["pending"]> | MaybeReturnType<T["complete"]> | MaybeReturnType<T["error"]>;
|
|
2890
|
+
}
|
|
2891
|
+
export type MaybeReturnType<F> = F extends (...args: never[]) => infer R ? R : undefined;
|
|
2892
|
+
/**
|
|
2893
|
+
* Available input types for hosted inputs.
|
|
2894
|
+
*/
|
|
2895
|
+
export type HostedInputType = "cardNumber" | "cvv" | "expire" | "cardholderName";
|
|
2896
|
+
/**
|
|
2897
|
+
* Configuration for the hosted input controller.
|
|
2898
|
+
*/
|
|
2899
|
+
export interface HostedInputConfig {
|
|
2900
|
+
/** Differentiates the input type. */
|
|
2901
|
+
type: HostedInputType;
|
|
2902
|
+
/** Selector for the container element where the input should be rendered. */
|
|
2903
|
+
containerSelector: string;
|
|
2904
|
+
/**
|
|
2905
|
+
* Optional callback for handling input events (e.g. for CardFormName).
|
|
2906
|
+
*/
|
|
2907
|
+
onInput?: (value: string) => void;
|
|
2908
|
+
}
|
|
2909
|
+
/**
|
|
2910
|
+
* Possible input source types that can be returned by getHostedInput
|
|
2911
|
+
*/
|
|
2912
|
+
export type InputSource = IHeadlessHostedInput | "cardholderName" | undefined;
|
|
2913
|
+
declare class HostedInputController<T extends HostedInputHost> implements ReactiveController {
|
|
2914
|
+
private _isFocused;
|
|
2915
|
+
private _hostedInput;
|
|
2916
|
+
private _standardInput;
|
|
2917
|
+
private readonly host;
|
|
2918
|
+
private readonly config;
|
|
2919
|
+
/**
|
|
2920
|
+
* Task to set up the hosted input.
|
|
2921
|
+
*/
|
|
2922
|
+
readonly setupTask: Task<[
|
|
2923
|
+
InputSource
|
|
2924
|
+
], boolean | typeof initialState>;
|
|
2925
|
+
constructor(host: T, config: HostedInputConfig);
|
|
2926
|
+
/**
|
|
2927
|
+
* Focuses the input, whether it's a hosted input or standard input
|
|
2928
|
+
*/
|
|
2929
|
+
focusInput(): void;
|
|
2930
|
+
/**
|
|
2931
|
+
* Returns the hosted input from the card form context based on the type.
|
|
2932
|
+
* For 'cardholderName', no hosted input is provided so we return a fallback indicator.
|
|
2933
|
+
*/
|
|
2934
|
+
private getHostedInput;
|
|
2935
|
+
/**
|
|
2936
|
+
* Sets up the hosted input.
|
|
2937
|
+
* If a hosted input is provided, it renders it into the target container.
|
|
2938
|
+
* Otherwise (e.g. for cardholderName), it creates a standard input element.
|
|
2939
|
+
*/
|
|
2940
|
+
private setupHostedInput;
|
|
2941
|
+
/**
|
|
2942
|
+
* Gets the target container element from the host's render root
|
|
2943
|
+
*/
|
|
2944
|
+
private getTargetContainer;
|
|
2945
|
+
/**
|
|
2946
|
+
* Sets up a standard input element for non-hosted input types
|
|
2947
|
+
*/
|
|
2948
|
+
private setupStandardInput;
|
|
2949
|
+
/**
|
|
2950
|
+
* Sets up event listeners for standard input elements
|
|
2951
|
+
*/
|
|
2952
|
+
private setupInputEventListeners;
|
|
2953
|
+
/**
|
|
2954
|
+
* Sets up a hosted iframe input for iframe-based input types
|
|
2955
|
+
*/
|
|
2956
|
+
private setupHostedIframeInput;
|
|
2957
|
+
/** Exposes the current focus state. */
|
|
2958
|
+
get isFocused(): boolean;
|
|
2959
|
+
hostConnected(): void;
|
|
2960
|
+
hostDisconnected(): void;
|
|
2961
|
+
}
|
|
2962
|
+
/**
|
|
2963
|
+
* Translation configuration object
|
|
2964
|
+
*/
|
|
2965
|
+
export type TranslationConfig = {
|
|
2966
|
+
id: string;
|
|
2967
|
+
defaultMessage: string;
|
|
2968
|
+
};
|
|
2969
|
+
/**
|
|
2970
|
+
* Configuration for abstract input component
|
|
2971
|
+
*/
|
|
2972
|
+
export interface InputComponentConfig {
|
|
2973
|
+
/** The component's hosted input type */
|
|
2974
|
+
inputType: HostedInputType;
|
|
2975
|
+
/** ID selector for the container where the input will be rendered */
|
|
2976
|
+
containerSelector: string;
|
|
2977
|
+
/** Error name to match in the card form context */
|
|
2978
|
+
errorName: string;
|
|
2979
|
+
/** Translation keys for default values */
|
|
2980
|
+
translations: {
|
|
2981
|
+
label: TranslationConfig | string;
|
|
2982
|
+
placeholder?: TranslationConfig | string;
|
|
2983
|
+
ariaLabel?: TranslationConfig | string;
|
|
2984
|
+
};
|
|
2985
|
+
/** Optional input handler for non-hosted inputs */
|
|
2986
|
+
onInput?: (value: string) => void;
|
|
2987
|
+
}
|
|
2988
|
+
declare abstract class AbstractCardInputComponent extends LitElement implements HostedInputHost {
|
|
2989
|
+
cardFormContext: CardFormContext | null;
|
|
2990
|
+
/** Tracks which properties were explicitly set by the user */
|
|
2991
|
+
protected readonly _userAssignedProps: Set<string>;
|
|
2992
|
+
/** Internal storage for property values */
|
|
2993
|
+
protected _internalLabel: string;
|
|
2994
|
+
protected _internalPlaceholder: string;
|
|
2995
|
+
protected _internalAriaLabel: string;
|
|
2996
|
+
/** Configuration for this input component */
|
|
2997
|
+
protected abstract readonly config: InputComponentConfig;
|
|
2998
|
+
/** Hosted input controller */
|
|
2999
|
+
protected readonly hostedInputController: HostedInputController<HostedInputHost>;
|
|
3000
|
+
/**
|
|
3001
|
+
* Gets a translated or static string value from the translation config
|
|
3002
|
+
*/
|
|
3003
|
+
private getTranslatedValue;
|
|
3004
|
+
/**
|
|
3005
|
+
* The input label text.
|
|
3006
|
+
* Falls back to localized default if not explicitly set.
|
|
3007
|
+
*/
|
|
3008
|
+
get label(): string;
|
|
3009
|
+
set label(value: string);
|
|
3010
|
+
/**
|
|
3011
|
+
* The input placeholder text.
|
|
3012
|
+
* Falls back to localized default if not explicitly set.
|
|
3013
|
+
* When explicitly set to empty string, no placeholder will be displayed.
|
|
3014
|
+
*/
|
|
3015
|
+
get placeholder(): string;
|
|
3016
|
+
set placeholder(value: string);
|
|
3017
|
+
/**
|
|
3018
|
+
* The input aria-label attribute.
|
|
3019
|
+
* Falls back to localized default if not explicitly set.
|
|
3020
|
+
*/
|
|
3021
|
+
get ariaLabel(): string;
|
|
3022
|
+
set ariaLabel(value: string);
|
|
3023
|
+
constructor();
|
|
3024
|
+
/**
|
|
3025
|
+
* Initialize the controller after the component has been constructed
|
|
3026
|
+
* and the config is available
|
|
3027
|
+
*/
|
|
3028
|
+
protected childUpdated(): void;
|
|
3029
|
+
/**
|
|
3030
|
+
* Handler for wrapper-click event from InputWrapper component
|
|
3031
|
+
* This is still needed for hosted iframe inputs
|
|
3032
|
+
*/
|
|
3033
|
+
private handleWrapperClick;
|
|
3034
|
+
/**
|
|
3035
|
+
* Common rendering logic for all card input components
|
|
3036
|
+
*/
|
|
3037
|
+
protected renderInput(): TemplateResult<1> | typeof nothing;
|
|
3038
|
+
}
|
|
3039
|
+
declare class InputCardNumberComponent extends AbstractCardInputComponent {
|
|
3040
|
+
static styles: CSSResult[];
|
|
3041
|
+
/**
|
|
3042
|
+
* Configuration for this input component
|
|
3043
|
+
*/
|
|
3044
|
+
protected readonly config: InputComponentConfig;
|
|
3045
|
+
constructor();
|
|
3046
|
+
/**
|
|
3047
|
+
* Handle network selection from the network selector component
|
|
3048
|
+
*/
|
|
3049
|
+
private handleNetworkSelected;
|
|
3050
|
+
/**
|
|
3051
|
+
* Override the renderInput method to include the network selector
|
|
3052
|
+
*/
|
|
3053
|
+
protected renderInput(): TemplateResult<1> | typeof nothing;
|
|
3054
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
3055
|
+
}
|
|
3056
|
+
declare global {
|
|
3057
|
+
interface HTMLElementTagNameMap {
|
|
3058
|
+
"primer-input-card-number": InputCardNumberComponent;
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
declare class InputCvvComponent extends AbstractCardInputComponent {
|
|
3062
|
+
static styles: CSSResult[];
|
|
3063
|
+
protected readonly config: InputComponentConfig;
|
|
3064
|
+
constructor();
|
|
3065
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
3066
|
+
}
|
|
3067
|
+
declare global {
|
|
3068
|
+
interface HTMLElementTagNameMap {
|
|
3069
|
+
"primer-input-cvv": InputCvvComponent;
|
|
3070
|
+
}
|
|
3071
|
+
}
|
|
3072
|
+
declare class InputCardExpiryComponent extends AbstractCardInputComponent {
|
|
3073
|
+
static styles: CSSResult[];
|
|
3074
|
+
protected readonly config: InputComponentConfig;
|
|
3075
|
+
constructor();
|
|
3076
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
3077
|
+
}
|
|
3078
|
+
declare global {
|
|
3079
|
+
interface HTMLElementTagNameMap {
|
|
3080
|
+
"primer-input-card-expiry": InputCardExpiryComponent;
|
|
3081
|
+
}
|
|
3082
|
+
}
|
|
3083
|
+
declare class InputCardHolderNameComponent extends AbstractCardInputComponent {
|
|
3084
|
+
static styles: CSSResult[];
|
|
3085
|
+
protected readonly config: InputComponentConfig;
|
|
3086
|
+
constructor();
|
|
3087
|
+
private handleInput;
|
|
3088
|
+
render(): TemplateResult<1> | typeof nothing;
|
|
3089
|
+
}
|
|
3090
|
+
declare global {
|
|
3091
|
+
interface HTMLElementTagNameMap {
|
|
3092
|
+
"primer-input-card-holder-name": InputCardHolderNameComponent;
|
|
3093
|
+
}
|
|
3094
|
+
}
|
|
3095
|
+
declare class CardFormSubmitComponent extends LitElement {
|
|
3096
|
+
static styles: CSSResult[];
|
|
3097
|
+
private readonly _userAssignedProps;
|
|
3098
|
+
private _internalButtonText;
|
|
3099
|
+
/**
|
|
3100
|
+
* The button text to display.
|
|
3101
|
+
* Falls back to localized default if not explicitly set.
|
|
3102
|
+
*/
|
|
3103
|
+
get buttonText(): string;
|
|
3104
|
+
set buttonText(value: string);
|
|
3105
|
+
/**
|
|
3106
|
+
* The button variant to use.
|
|
3107
|
+
* @default "primary"
|
|
3108
|
+
*/
|
|
3109
|
+
variant: string;
|
|
3110
|
+
/**
|
|
3111
|
+
* Whether the button is disabled.
|
|
3112
|
+
* @default false
|
|
3113
|
+
*/
|
|
3114
|
+
disabled: boolean;
|
|
3115
|
+
private handleClick;
|
|
3116
|
+
render(): TemplateResult<1>;
|
|
3117
|
+
}
|
|
3118
|
+
declare global {
|
|
3119
|
+
interface HTMLElementTagNameMap {
|
|
3120
|
+
"primer-card-form-submit": CardFormSubmitComponent;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
declare class CardNetworkSelectorComponent extends LitElement {
|
|
3124
|
+
static styles: CSSResult[];
|
|
3125
|
+
/**
|
|
3126
|
+
* Card networks context from provider
|
|
3127
|
+
*/
|
|
3128
|
+
cardNetworks: CardNetworksContext | null;
|
|
3129
|
+
private selectedCardNetwork;
|
|
3130
|
+
/**
|
|
3131
|
+
* Internal state to track if dropdown is open
|
|
3132
|
+
*/
|
|
3133
|
+
private isDropdownOpen;
|
|
3134
|
+
/**
|
|
3135
|
+
* Index of the currently focused network in the dropdown
|
|
3136
|
+
*/
|
|
3137
|
+
private focusedNetworkIndex;
|
|
3138
|
+
/**
|
|
3139
|
+
* Tracks if keyboard navigation is being used
|
|
3140
|
+
*/
|
|
3141
|
+
private isKeyboardNavigation;
|
|
3142
|
+
/**
|
|
3143
|
+
* Reference to the dropdown button
|
|
3144
|
+
*/
|
|
3145
|
+
private buttonRef;
|
|
3146
|
+
/**
|
|
3147
|
+
* Reference to the dropdown container
|
|
3148
|
+
*/
|
|
3149
|
+
private dropdownRef;
|
|
3150
|
+
/**
|
|
3151
|
+
* Reference to network option elements
|
|
3152
|
+
*/
|
|
3153
|
+
private networkOptionRefs;
|
|
3154
|
+
/**
|
|
3155
|
+
* Toggle the dropdown state
|
|
3156
|
+
*/
|
|
3157
|
+
private toggleDropdown;
|
|
3158
|
+
/**
|
|
3159
|
+
* Get selectable networks from context
|
|
3160
|
+
*/
|
|
3161
|
+
private getSelectableNetworks;
|
|
3162
|
+
/**
|
|
3163
|
+
* Get detected network from context
|
|
3164
|
+
*/
|
|
3165
|
+
private getDetectedNetwork;
|
|
3166
|
+
/**
|
|
3167
|
+
* Get the index of the currently selected network
|
|
3168
|
+
*/
|
|
3169
|
+
private getSelectedNetworkIndex;
|
|
3170
|
+
/**
|
|
3171
|
+
* Handle network selection
|
|
3172
|
+
*/
|
|
3173
|
+
private selectNetwork;
|
|
3174
|
+
/**
|
|
3175
|
+
* Handle click outside to close dropdown
|
|
3176
|
+
*/
|
|
3177
|
+
private handleClickOutside;
|
|
3178
|
+
/**
|
|
3179
|
+
* Handle mouse movement to disable keyboard navigation mode
|
|
3180
|
+
*/
|
|
3181
|
+
private handleMouseMove;
|
|
3182
|
+
/**
|
|
3183
|
+
* Handle keydown events for keyboard navigation
|
|
3184
|
+
*/
|
|
3185
|
+
private handleKeyDown;
|
|
3186
|
+
/**
|
|
3187
|
+
* Focus the current network option
|
|
3188
|
+
*/
|
|
3189
|
+
private focusNetworkOption;
|
|
3190
|
+
/**
|
|
3191
|
+
* Save reference to network option element
|
|
3192
|
+
*/
|
|
3193
|
+
private setNetworkOptionRef;
|
|
3194
|
+
/**
|
|
3195
|
+
* Lifecycle: Add document event listener when connected
|
|
3196
|
+
*/
|
|
3197
|
+
connectedCallback(): void;
|
|
3198
|
+
/**
|
|
3199
|
+
* Lifecycle: Remove document event listener when disconnected
|
|
3200
|
+
*/
|
|
3201
|
+
disconnectedCallback(): void;
|
|
3202
|
+
render(): TemplateResult<1>;
|
|
3203
|
+
}
|
|
3204
|
+
declare global {
|
|
3205
|
+
interface HTMLElementTagNameMap {
|
|
3206
|
+
"primer-card-network-selector": CardNetworkSelectorComponent;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
declare global {
|
|
3210
|
+
interface HTMLElementTagNameMap {
|
|
3211
|
+
"primer-card-form": CardFormComponent;
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
declare class PrimerCheckoutCompleteComponent extends LitElement {
|
|
3215
|
+
render(): TemplateResult<1>;
|
|
3216
|
+
}
|
|
3217
|
+
declare global {
|
|
3218
|
+
interface HTMLElementTagNameMap {
|
|
3219
|
+
"primer-checkout-complete": PrimerCheckoutCompleteComponent;
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
export interface HeadlessSDKState {
|
|
3223
|
+
isProcessing: boolean;
|
|
3224
|
+
isSuccessful: boolean;
|
|
3225
|
+
isFailure: boolean;
|
|
3226
|
+
error?: Error | undefined;
|
|
3227
|
+
}
|
|
3228
|
+
declare class PrimerCheckoutFailureComponent extends LitElement {
|
|
3229
|
+
sdkState: HeadlessSDKState | undefined;
|
|
3230
|
+
render(): TemplateResult<1>;
|
|
3231
|
+
}
|
|
3232
|
+
declare global {
|
|
3233
|
+
interface HTMLElementTagNameMap {
|
|
3234
|
+
"primer-checkout-failure": PrimerCheckoutFailureComponent;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
declare global {
|
|
3238
|
+
interface HTMLElementTagNameMap {
|
|
3239
|
+
"primer-checkout": PrimerCheckoutComponent;
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
type PaymentsObject$1 = PaymentsObject;
|
|
3243
|
+
export declare function loadPrimer(): Promise<void>;
|
|
3244
|
+
|
|
3245
|
+
export {
|
|
3246
|
+
PaymentsObject$1 as PaymentsObject,
|
|
3247
|
+
};
|
|
3248
|
+
|
|
3249
|
+
export {};
|