@basis-theory/basis-theory-js 1.27.0 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BasisTheory.d.ts +3 -2
- package/BasisTheory.js +1 -4
- package/package.json +1 -1
- package/types/elements/elements.d.ts +5 -5
- package/types/elements/events.d.ts +9 -4
package/BasisTheory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AtomicBanks as ElementsAtomicBanks, AtomicCards as ElementsAtomicCards, BasisTheoryElements, CardElement,
|
|
1
|
+
import type { AtomicBanks as ElementsAtomicBanks, AtomicCards as ElementsAtomicCards, BasisTheoryElements, CardElement, CreateCardElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from '@/types/elements';
|
|
2
2
|
import type { TokenizeData } from '@/types/models';
|
|
3
3
|
import type { Applications, AtomicBanks, AtomicCards, BasisTheory as IBasisTheory, BasisTheoryInit, Logs, Permissions, ReactorFormulas, Reactors, RequestOptions, Tenants, Tokens, BasisTheoryInitOptions, BasisTheoryInitOptionsWithElements, BasisTheoryInitOptionsWithoutElements } from '@/types/sdk';
|
|
4
4
|
export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, BasisTheoryElements {
|
|
@@ -17,7 +17,8 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
|
|
|
17
17
|
private _permissions?;
|
|
18
18
|
init(apiKey: string, options?: BasisTheoryInitOptionsWithoutElements): Promise<IBasisTheory>;
|
|
19
19
|
init(apiKey: string, options: BasisTheoryInitOptionsWithElements): Promise<IBasisTheory & BasisTheoryElements>;
|
|
20
|
-
createElement(type:
|
|
20
|
+
createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
|
|
21
|
+
createElement(type: 'text', options: CreateTextElementOptions): TextElement;
|
|
21
22
|
tokenize(tokens: TokenizeData & ElementsTokenizeData, options?: RequestOptions): Promise<TokenizeData>;
|
|
22
23
|
private loadElements;
|
|
23
24
|
get initOptions(): Required<BasisTheoryInitOptions>;
|
package/BasisTheory.js
CHANGED
|
@@ -131,10 +131,7 @@ class BasisTheory {
|
|
|
131
131
|
createElement(type, options) {
|
|
132
132
|
if (!this._elements) {
|
|
133
133
|
throw new Error(_constants.ELEMENTS_INIT_ERROR_MESSAGE);
|
|
134
|
-
}
|
|
135
|
-
// the underlying elements function called will be the same, no matter the
|
|
136
|
-
// element type
|
|
137
|
-
|
|
134
|
+
}
|
|
138
135
|
|
|
139
136
|
return this._elements.createElement(type, options);
|
|
140
137
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { ElementEventListener, EventType, Subscription } from './events';
|
|
1
|
+
import type { ElementEventListener, EventType, Subscription, TextElementEvents, CardElementEvents } from './events';
|
|
2
2
|
import type { CreateCardElementOptions, CreateTextElementOptions, UpdateCardElementOptions, UpdateTextElementOptions } from './options';
|
|
3
3
|
import type { AtomicBanks, AtomicCards, Tokenize, Tokens } from './services';
|
|
4
|
-
interface BaseElement<UpdateOptions> {
|
|
4
|
+
interface BaseElement<UpdateOptions, ElementEvents> {
|
|
5
5
|
readonly mounted: boolean;
|
|
6
6
|
mount(selector: string): Promise<void>;
|
|
7
7
|
update(options: UpdateOptions): Promise<void>;
|
|
8
8
|
clear(): void;
|
|
9
9
|
unmount(): void;
|
|
10
|
-
on<T extends EventType>(eventType: T, listener: ElementEventListener<T>): Subscription;
|
|
10
|
+
on<T extends EventType>(eventType: T, listener: ElementEventListener<ElementEvents, T>): Subscription;
|
|
11
11
|
}
|
|
12
|
-
declare type CardElement = BaseElement<UpdateCardElementOptions>;
|
|
13
|
-
declare type TextElement = BaseElement<UpdateTextElementOptions>;
|
|
12
|
+
declare type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents>;
|
|
13
|
+
declare type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents>;
|
|
14
14
|
interface BasisTheoryElements extends Tokenize {
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated use {@link tokens} or {@link tokenize}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldError, ListenableKey, Targeted } from './shared';
|
|
1
|
+
import type { Brand, FieldError, ListenableKey, Targeted } from './shared';
|
|
2
2
|
declare type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown';
|
|
3
3
|
interface BaseEvent<T extends EventType> {
|
|
4
4
|
type: T;
|
|
@@ -9,20 +9,25 @@ declare type ChangeEvent = BaseEvent<'change'> & {
|
|
|
9
9
|
complete: boolean;
|
|
10
10
|
errors?: FieldError[];
|
|
11
11
|
};
|
|
12
|
+
declare type CardChangeEvent = ChangeEvent & {
|
|
13
|
+
cardBrand: Brand;
|
|
14
|
+
};
|
|
12
15
|
declare type InputFocusEvent = BaseEvent<'focus'> & Targeted;
|
|
13
16
|
declare type InputBlurEvent = BaseEvent<'blur'> & Targeted;
|
|
14
17
|
declare type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
|
|
15
18
|
key: ListenableKey;
|
|
16
19
|
} & Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey'>;
|
|
17
|
-
declare type
|
|
20
|
+
declare type BaseElementEvents = ReadyEvent | InputFocusEvent | InputBlurEvent | InputKeydownEvent;
|
|
21
|
+
declare type TextElementEvents = BaseElementEvents | ChangeEvent;
|
|
22
|
+
declare type CardElementEvents = BaseElementEvents | CardChangeEvent;
|
|
18
23
|
/**
|
|
19
24
|
* Utility type that helps find a Union type based on a `type` property
|
|
20
25
|
*/
|
|
21
26
|
declare type FindByType<Union, Type> = Union extends {
|
|
22
27
|
type: Type;
|
|
23
28
|
} ? Union : never;
|
|
24
|
-
declare type ElementEventListener<
|
|
29
|
+
declare type ElementEventListener<Events, Type> = (event: FindByType<Events, Type>) => void;
|
|
25
30
|
interface Subscription {
|
|
26
31
|
unsubscribe(): void;
|
|
27
32
|
}
|
|
28
|
-
export type { EventType, BaseEvent, ReadyEvent, ChangeEvent, InputFocusEvent, InputBlurEvent, InputKeydownEvent,
|
|
33
|
+
export type { EventType, BaseEvent, ReadyEvent, ChangeEvent, CardChangeEvent, InputFocusEvent, InputBlurEvent, InputKeydownEvent, BaseElementEvents, TextElementEvents, CardElementEvents, ElementEventListener, Subscription, };
|