@benbraide/inlinejs-stripe 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/inlinejs-stripe.js +77 -10
- package/dist/inlinejs-stripe.min.js +1 -1
- package/lib/common/components/detail.d.ts +3 -1
- package/lib/common/components/detail.js +3 -1
- package/lib/common/components/field.d.ts +6 -1
- package/lib/common/components/field.js +18 -6
- package/lib/common/components/payment-method.d.ts +3 -1
- package/lib/common/components/payment-method.js +2 -0
- package/lib/common/components/stripe.d.ts +5 -1
- package/lib/common/components/stripe.js +54 -3
- package/lib/common/types.d.ts +4 -0
- package/lib/esm/components/detail.d.ts +3 -1
- package/lib/esm/components/detail.js +3 -1
- package/lib/esm/components/field.d.ts +6 -1
- package/lib/esm/components/field.js +18 -6
- package/lib/esm/components/payment-method.d.ts +3 -1
- package/lib/esm/components/payment-method.js +2 -0
- package/lib/esm/components/stripe.d.ts +5 -1
- package/lib/esm/components/stripe.js +54 -3
- package/lib/esm/types.d.ts +4 -0
- package/package.json +1 -1
package/dist/inlinejs-stripe.js
CHANGED
@@ -7311,6 +7311,8 @@ class StripeDetailElement extends inlinejs_element_1.CustomElement {
|
|
7311
7311
|
WaitReady() {
|
7312
7312
|
return Promise.resolve();
|
7313
7313
|
}
|
7314
|
+
AddChangeListener(listener) { }
|
7315
|
+
RemoveChangeListener(listener) { }
|
7314
7316
|
ToggleFocus(focused) {
|
7315
7317
|
const input = this.GetInput_();
|
7316
7318
|
input && (focused ? input.focus() : input.blur());
|
@@ -7321,7 +7323,7 @@ class StripeDetailElement extends inlinejs_element_1.CustomElement {
|
|
7321
7323
|
}
|
7322
7324
|
AddDetails(details) {
|
7323
7325
|
const input = this.GetInput_();
|
7324
|
-
if (!this.name || (!input && !this.value)) {
|
7326
|
+
if (!this.name || (!(input === null || input === void 0 ? void 0 : input.value) && !this.value)) {
|
7325
7327
|
return;
|
7326
7328
|
}
|
7327
7329
|
details.billingDetails = (details.billingDetails || {});
|
@@ -7388,7 +7390,10 @@ class StripeFieldElement extends inlinejs_element_1.CustomElement {
|
|
7388
7390
|
super();
|
7389
7391
|
this.stripeField_ = null;
|
7390
7392
|
this.isReady_ = false;
|
7393
|
+
this.isComplete_ = false;
|
7394
|
+
this.lastError_ = null;
|
7391
7395
|
this.readyWaiters_ = new Array();
|
7396
|
+
this.changeListeners = new Array();
|
7392
7397
|
this.stripe = null;
|
7393
7398
|
this.options = null;
|
7394
7399
|
this.type = '';
|
@@ -7401,6 +7406,13 @@ class StripeFieldElement extends inlinejs_element_1.CustomElement {
|
|
7401
7406
|
this.isReady_ ? resolve() : this.readyWaiters_.push(() => resolve());
|
7402
7407
|
});
|
7403
7408
|
}
|
7409
|
+
AddChangeListener(listener) {
|
7410
|
+
this.changeListeners.push(listener);
|
7411
|
+
}
|
7412
|
+
RemoveChangeListener(listener) {
|
7413
|
+
const index = this.changeListeners.indexOf(listener);
|
7414
|
+
(index >= 0) && this.changeListeners.splice(index, 1);
|
7415
|
+
}
|
7404
7416
|
ToggleFocus(focused) {
|
7405
7417
|
var _a, _b;
|
7406
7418
|
(this.stripeField_ && (focused ? (_a = this.stripeField_) === null || _a === void 0 ? void 0 : _a.focus() : (_b = this.stripeField_) === null || _b === void 0 ? void 0 : _b.blur()));
|
@@ -7446,23 +7458,25 @@ class StripeFieldElement extends inlinejs_element_1.CustomElement {
|
|
7446
7458
|
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
7447
7459
|
});
|
7448
7460
|
this.stripeField_.on('change', (event) => {
|
7449
|
-
|
7450
|
-
|
7461
|
+
if (((event === null || event === void 0 ? void 0 : event.error) || null) !== this.lastError_) {
|
7462
|
+
this.lastError_ = ((event === null || event === void 0 ? void 0 : event.error) || null);
|
7451
7463
|
(0, inlinejs_1.EvaluateLater)({
|
7452
7464
|
componentId: this.componentId_,
|
7453
7465
|
contextElement: this,
|
7454
7466
|
expression: this.onerrors,
|
7455
7467
|
disableFunctionCall: false,
|
7456
|
-
})(undefined, [], { error:
|
7468
|
+
})(undefined, [this.lastError_], { error: this.lastError_ });
|
7469
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('error', this.lastError_)));
|
7457
7470
|
}
|
7458
|
-
|
7471
|
+
if (((event === null || event === void 0 ? void 0 : event.complete) || false) != this.isComplete_) {
|
7472
|
+
this.isComplete_ = ((event === null || event === void 0 ? void 0 : event.complete) || false);
|
7459
7473
|
(0, inlinejs_1.EvaluateLater)({
|
7460
7474
|
componentId: this.componentId_,
|
7461
7475
|
contextElement: this,
|
7462
7476
|
expression: this.oncomplete,
|
7463
7477
|
disableFunctionCall: false,
|
7464
|
-
})();
|
7465
|
-
|
7478
|
+
})(undefined, [this.isComplete_], { complete: this.isComplete_ });
|
7479
|
+
this.changeListeners.forEach(listener => (0, inlinejs_1.JournalTry)(() => listener('complete', this.isComplete_)));
|
7466
7480
|
}
|
7467
7481
|
});
|
7468
7482
|
this.stripeField_.mount(this);
|
@@ -7533,6 +7547,8 @@ class StripePaymentMenthodElement extends inlinejs_element_1.CustomElement {
|
|
7533
7547
|
WaitReady() {
|
7534
7548
|
return Promise.resolve();
|
7535
7549
|
}
|
7550
|
+
AddChangeListener(listener) { }
|
7551
|
+
RemoveChangeListener(listener) { }
|
7536
7552
|
ToggleFocus(focused) { }
|
7537
7553
|
Reset() { }
|
7538
7554
|
AddDetails(details) {
|
@@ -7590,11 +7606,15 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
7590
7606
|
this.fields_ = null;
|
7591
7607
|
this.readyFields_ = null;
|
7592
7608
|
this.instanceWaiters_ = new Array();
|
7609
|
+
this.completeFields_ = null;
|
7610
|
+
this.errorFields_ = null;
|
7593
7611
|
this.options = null;
|
7594
7612
|
this.publicKey = '';
|
7595
7613
|
this.onready = '';
|
7614
|
+
this.oncomplete = '';
|
7615
|
+
this.onerrors = '';
|
7596
7616
|
this.defer = false;
|
7597
|
-
this.
|
7617
|
+
this.focusnext = false;
|
7598
7618
|
}
|
7599
7619
|
AddStripeField(field) {
|
7600
7620
|
this.fields_ = (this.fields_ || []);
|
@@ -7613,13 +7633,54 @@ class StripeElement extends inlinejs_element_1.CustomElement {
|
|
7613
7633
|
this.readyWaiters_.splice(0).forEach(waiter => (0, inlinejs_1.JournalTry)(waiter));
|
7614
7634
|
});
|
7615
7635
|
});
|
7636
|
+
field.AddChangeListener((type, data) => {
|
7637
|
+
if (type === 'complete') {
|
7638
|
+
let changed = false;
|
7639
|
+
this.completeFields_ = (this.completeFields_ || []);
|
7640
|
+
if (data && !this.completeFields_.includes(field)) {
|
7641
|
+
this.completeFields_.push(field);
|
7642
|
+
changed = !!(this.readyFields_ && this.completeFields_.length == this.readyFields_.length);
|
7643
|
+
}
|
7644
|
+
else if (!data && this.completeFields_.includes(field)) {
|
7645
|
+
this.completeFields_ = this.completeFields_.filter(x => x !== field);
|
7646
|
+
changed = (this.completeFields_.length == 0);
|
7647
|
+
}
|
7648
|
+
changed && this.oncomplete && (0, inlinejs_1.EvaluateLater)({
|
7649
|
+
componentId: this.componentId_,
|
7650
|
+
contextElement: this,
|
7651
|
+
expression: this.oncomplete,
|
7652
|
+
disableFunctionCall: false,
|
7653
|
+
})(undefined, [!!data], { complete: !!data });
|
7654
|
+
!!data && this.focusnext && this.FocusNextField(field);
|
7655
|
+
}
|
7656
|
+
else if (type === 'error') {
|
7657
|
+
let changed = false;
|
7658
|
+
this.errorFields_ = (this.errorFields_ || []);
|
7659
|
+
this.errorFields_.push(field);
|
7660
|
+
this.errorFields_ = (this.errorFields_ || []);
|
7661
|
+
if (data && !this.errorFields_.includes(field)) {
|
7662
|
+
this.errorFields_.push(field);
|
7663
|
+
changed = (this.errorFields_.length == 1);
|
7664
|
+
}
|
7665
|
+
else if (!data && this.errorFields_.includes(field)) {
|
7666
|
+
this.errorFields_ = this.errorFields_.filter(x => x !== field);
|
7667
|
+
changed = (this.errorFields_.length == 0);
|
7668
|
+
}
|
7669
|
+
changed && this.onerrors && (0, inlinejs_1.EvaluateLater)({
|
7670
|
+
componentId: this.componentId_,
|
7671
|
+
contextElement: this,
|
7672
|
+
expression: this.onerrors,
|
7673
|
+
disableFunctionCall: false,
|
7674
|
+
})(undefined, [data], { error: data });
|
7675
|
+
}
|
7676
|
+
});
|
7616
7677
|
}
|
7617
7678
|
RemoveStripeField(field) {
|
7618
7679
|
this.fields_ && (this.fields_ = this.fields_.filter(x => x !== field));
|
7619
7680
|
this.readyFields_ && (this.readyFields_ = this.readyFields_.filter(x => x !== field));
|
7620
7681
|
}
|
7621
7682
|
FocusNextField(field) {
|
7622
|
-
if (this.
|
7683
|
+
if (this.fields_) {
|
7623
7684
|
const index = this.fields_.indexOf(field);
|
7624
7685
|
(index >= 0 && index < this.fields_.length - 1) && this.fields_[index + 1].ToggleFocus(true);
|
7625
7686
|
}
|
@@ -7708,12 +7769,18 @@ __decorate([
|
|
7708
7769
|
__decorate([
|
7709
7770
|
(0, inlinejs_element_1.Property)({ type: 'string' })
|
7710
7771
|
], StripeElement.prototype, "onready", void 0);
|
7772
|
+
__decorate([
|
7773
|
+
(0, inlinejs_element_1.Property)({ type: 'string' })
|
7774
|
+
], StripeElement.prototype, "oncomplete", void 0);
|
7775
|
+
__decorate([
|
7776
|
+
(0, inlinejs_element_1.Property)({ type: 'string' })
|
7777
|
+
], StripeElement.prototype, "onerrors", void 0);
|
7711
7778
|
__decorate([
|
7712
7779
|
(0, inlinejs_element_1.Property)({ type: 'boolean' })
|
7713
7780
|
], StripeElement.prototype, "defer", void 0);
|
7714
7781
|
__decorate([
|
7715
7782
|
(0, inlinejs_element_1.Property)({ type: 'boolean' })
|
7716
|
-
], StripeElement.prototype, "
|
7783
|
+
], StripeElement.prototype, "focusnext", void 0);
|
7717
7784
|
exports.StripeElement = StripeElement;
|
7718
7785
|
function StripeElementCompact() {
|
7719
7786
|
(0, inlinejs_element_1.RegisterCustomElement)(StripeElement, 'stripe');
|