@benbraide/inlinejs-stripe 2.0.5 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/inlinejs-stripe.js +4695 -4311
- package/dist/inlinejs-stripe.min.js +1 -1
- package/lib/common/components/field.d.ts +1 -0
- package/lib/common/components/field.js +3 -0
- package/lib/common/components/generic-field.d.ts +1 -0
- package/lib/common/components/generic-field.js +3 -0
- package/lib/common/components/stripe.d.ts +1 -0
- package/lib/common/components/stripe.js +10 -2
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.js +1 -0
- package/lib/common/types.d.ts +1 -0
- package/lib/esm/components/field.d.ts +1 -0
- package/lib/esm/components/field.js +3 -0
- package/lib/esm/components/generic-field.d.ts +1 -0
- package/lib/esm/components/generic-field.js +3 -0
- package/lib/esm/components/stripe.d.ts +1 -0
- package/lib/esm/components/stripe.js +10 -2
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types.d.ts +1 -0
- package/package.json +4 -3
@@ -32,6 +32,7 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
32
32
|
this.fields_ = null;
|
33
33
|
this.readyFields_ = null;
|
34
34
|
this.instanceWaiters_ = new Array();
|
35
|
+
this.interactiveFields_ = null;
|
35
36
|
this.completeFields_ = null;
|
36
37
|
this.errorFields_ = null;
|
37
38
|
this.options = null;
|
@@ -48,6 +49,10 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
48
49
|
field.WaitReady().then(() => {
|
49
50
|
this.readyFields_ = (this.readyFields_ || []);
|
50
51
|
this.readyFields_.push(field);
|
52
|
+
if (field.IsInteractive()) {
|
53
|
+
this.interactiveFields_ = (this.interactiveFields_ || []);
|
54
|
+
this.interactiveFields_.push(field);
|
55
|
+
}
|
51
56
|
(this.fields_ && this.readyFields_ && this.fields_.length <= this.readyFields_.length) && (0, inlinejs_1.JournalTry)(() => {
|
52
57
|
this.isReady_ = true;
|
53
58
|
this.onready && (0, inlinejs_1.EvaluateLater)({
|
@@ -65,11 +70,11 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
65
70
|
this.completeFields_ = (this.completeFields_ || []);
|
66
71
|
if (data && !this.completeFields_.includes(field)) {
|
67
72
|
this.completeFields_.push(field);
|
68
|
-
changed = !!(this.
|
73
|
+
changed = !!(this.interactiveFields_ && this.completeFields_.length == this.interactiveFields_.length);
|
69
74
|
}
|
70
75
|
else if (!data && this.completeFields_.includes(field)) {
|
71
76
|
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
72
|
-
changed = !!(this.
|
77
|
+
changed = !!(this.interactiveFields_ && (this.completeFields_.length == (this.interactiveFields_.length - 1)));
|
73
78
|
}
|
74
79
|
changed && this.oncomplete && (0, inlinejs_1.EvaluateLater)({
|
75
80
|
componentId: this.componentId_,
|
@@ -104,6 +109,9 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
104
109
|
RemoveStripeField(field) {
|
105
110
|
this.fields_ && (this.fields_ = this.fields_.filter(x => x !== field));
|
106
111
|
this.readyFields_ && (this.readyFields_ = this.readyFields_.filter(x => x !== field));
|
112
|
+
this.interactiveFields_ && (this.interactiveFields_ = this.interactiveFields_.filter(x => x !== field));
|
113
|
+
this.completeFields_ && (this.completeFields_ = this.completeFields_.filter(x => x !== field));
|
114
|
+
this.errorFields_ && (this.errorFields_ = this.errorFields_.filter(x => x !== field));
|
107
115
|
}
|
108
116
|
FocusNextField(field) {
|
109
117
|
if (this.fields_) {
|
package/lib/common/index.d.ts
CHANGED
package/lib/common/index.js
CHANGED
@@ -18,4 +18,5 @@ __exportStar(require("./components/stripe"), exports);
|
|
18
18
|
__exportStar(require("./components/field"), exports);
|
19
19
|
__exportStar(require("./components/detail"), exports);
|
20
20
|
__exportStar(require("./components/payment-method"), exports);
|
21
|
+
__exportStar(require("./directive/stripe"), exports);
|
21
22
|
__exportStar(require("./entry"), exports);
|
package/lib/common/types.d.ts
CHANGED
@@ -6,6 +6,7 @@ export interface IStripePaymentDetails {
|
|
6
6
|
export declare type StripeFieldChangeType = 'error' | 'complete';
|
7
7
|
export declare type StripeFieldChangeHandlerType = (type: StripeFieldChangeType, data: any) => void;
|
8
8
|
export interface IStripeField {
|
9
|
+
IsInteractive(): boolean;
|
9
10
|
WaitReady(): Promise<void>;
|
10
11
|
AddChangeListener(listener: StripeFieldChangeHandlerType): void;
|
11
12
|
RemoveChangeListener(listener: StripeFieldChangeHandlerType): void;
|
@@ -15,6 +15,7 @@ export declare class StripeFieldElement extends StripeGenericField {
|
|
15
15
|
oncomplete: string;
|
16
16
|
onerrors: string;
|
17
17
|
constructor();
|
18
|
+
IsInteractive(): boolean;
|
18
19
|
WaitReady(): Promise<void>;
|
19
20
|
AddChangeListener(listener: StripeFieldChangeHandlerType): void;
|
20
21
|
RemoveChangeListener(listener: StripeFieldChangeHandlerType): void;
|
@@ -33,6 +33,9 @@ export class StripeFieldElement extends StripeGenericField {
|
|
33
33
|
this.oncomplete = '';
|
34
34
|
this.onerrors = '';
|
35
35
|
}
|
36
|
+
IsInteractive() {
|
37
|
+
return true;
|
38
|
+
}
|
36
39
|
WaitReady() {
|
37
40
|
return new Promise(resolve => {
|
38
41
|
this.isReady_ ? resolve() : this.readyWaiters_.push(() => resolve());
|
@@ -3,6 +3,7 @@ import { CustomElement } from "@benbraide/inlinejs-element";
|
|
3
3
|
import { IStripeElement, IStripeField, IStripePaymentDetails, StripeFieldChangeHandlerType } from "../types";
|
4
4
|
export declare class StripeGenericField extends CustomElement implements IStripeField {
|
5
5
|
stripe: IStripeElement | null;
|
6
|
+
IsInteractive(): boolean;
|
6
7
|
WaitReady(): Promise<void>;
|
7
8
|
AddChangeListener(listener: StripeFieldChangeHandlerType): void;
|
8
9
|
RemoveChangeListener(listener: StripeFieldChangeHandlerType): void;
|
@@ -12,6 +12,7 @@ export declare class StripeElement extends CustomElement implements IStripeEleme
|
|
12
12
|
protected fields_: Array<IStripeField> | null;
|
13
13
|
protected readyFields_: Array<IStripeField> | null;
|
14
14
|
protected instanceWaiters_: (() => void)[];
|
15
|
+
protected interactiveFields_: Array<IStripeField> | null;
|
15
16
|
protected completeFields_: Array<IStripeField> | null;
|
16
17
|
protected errorFields_: Array<IStripeField> | null;
|
17
18
|
options: stripe.elements.ElementsOptions | null;
|
@@ -29,6 +29,7 @@ export class StripeElement extends CustomElement {
|
|
29
29
|
this.fields_ = null;
|
30
30
|
this.readyFields_ = null;
|
31
31
|
this.instanceWaiters_ = new Array();
|
32
|
+
this.interactiveFields_ = null;
|
32
33
|
this.completeFields_ = null;
|
33
34
|
this.errorFields_ = null;
|
34
35
|
this.options = null;
|
@@ -45,6 +46,10 @@ export class StripeElement extends CustomElement {
|
|
45
46
|
field.WaitReady().then(() => {
|
46
47
|
this.readyFields_ = (this.readyFields_ || []);
|
47
48
|
this.readyFields_.push(field);
|
49
|
+
if (field.IsInteractive()) {
|
50
|
+
this.interactiveFields_ = (this.interactiveFields_ || []);
|
51
|
+
this.interactiveFields_.push(field);
|
52
|
+
}
|
48
53
|
(this.fields_ && this.readyFields_ && this.fields_.length <= this.readyFields_.length) && JournalTry(() => {
|
49
54
|
this.isReady_ = true;
|
50
55
|
this.onready && EvaluateLater({
|
@@ -62,11 +67,11 @@ export class StripeElement extends CustomElement {
|
|
62
67
|
this.completeFields_ = (this.completeFields_ || []);
|
63
68
|
if (data && !this.completeFields_.includes(field)) {
|
64
69
|
this.completeFields_.push(field);
|
65
|
-
changed = !!(this.
|
70
|
+
changed = !!(this.interactiveFields_ && this.completeFields_.length == this.interactiveFields_.length);
|
66
71
|
}
|
67
72
|
else if (!data && this.completeFields_.includes(field)) {
|
68
73
|
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
69
|
-
changed = !!(this.
|
74
|
+
changed = !!(this.interactiveFields_ && (this.completeFields_.length == (this.interactiveFields_.length - 1)));
|
70
75
|
}
|
71
76
|
changed && this.oncomplete && EvaluateLater({
|
72
77
|
componentId: this.componentId_,
|
@@ -101,6 +106,9 @@ export class StripeElement extends CustomElement {
|
|
101
106
|
RemoveStripeField(field) {
|
102
107
|
this.fields_ && (this.fields_ = this.fields_.filter(x => x !== field));
|
103
108
|
this.readyFields_ && (this.readyFields_ = this.readyFields_.filter(x => x !== field));
|
109
|
+
this.interactiveFields_ && (this.interactiveFields_ = this.interactiveFields_.filter(x => x !== field));
|
110
|
+
this.completeFields_ && (this.completeFields_ = this.completeFields_.filter(x => x !== field));
|
111
|
+
this.errorFields_ && (this.errorFields_ = this.errorFields_.filter(x => x !== field));
|
104
112
|
}
|
105
113
|
FocusNextField(field) {
|
106
114
|
if (this.fields_) {
|
package/lib/esm/index.d.ts
CHANGED
package/lib/esm/index.js
CHANGED
package/lib/esm/types.d.ts
CHANGED
@@ -6,6 +6,7 @@ export interface IStripePaymentDetails {
|
|
6
6
|
export declare type StripeFieldChangeType = 'error' | 'complete';
|
7
7
|
export declare type StripeFieldChangeHandlerType = (type: StripeFieldChangeType, data: any) => void;
|
8
8
|
export interface IStripeField {
|
9
|
+
IsInteractive(): boolean;
|
9
10
|
WaitReady(): Promise<void>;
|
10
11
|
AddChangeListener(listener: StripeFieldChangeHandlerType): void;
|
11
12
|
RemoveChangeListener(listener: StripeFieldChangeHandlerType): void;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@benbraide/inlinejs-stripe",
|
3
|
-
"version": "2.0
|
3
|
+
"version": "2.1.0",
|
4
4
|
"description": "Run javascript code by embedding them in your HTML using the element as context.",
|
5
5
|
"main": "./lib/common/index.js",
|
6
6
|
"module": "./lib/esm/index.js",
|
@@ -48,13 +48,14 @@
|
|
48
48
|
"jsdom": "^16.6.0",
|
49
49
|
"jsdom-global": "^3.0.2",
|
50
50
|
"mocha": "^9.0.0",
|
51
|
+
"terser-webpack-plugin": "^5.3.10",
|
51
52
|
"ts-loader": "^9.2.3",
|
52
53
|
"ts-node": "^10.0.0",
|
53
54
|
"webpack": "^5.41.0"
|
54
55
|
},
|
55
56
|
"dependencies": {
|
56
|
-
"@benbraide/inlinejs": "^1.1
|
57
|
-
"@benbraide/inlinejs-element": "^2.0
|
57
|
+
"@benbraide/inlinejs": "^1.2.1",
|
58
|
+
"@benbraide/inlinejs-element": "^2.1.0",
|
58
59
|
"webpack-cli": "^4.7.2"
|
59
60
|
}
|
60
61
|
}
|