@forgeroute/ui 0.4.45 → 0.4.47
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/fesm2022/forgeroute-ui-stripe.mjs +56 -19
- package/fesm2022/forgeroute-ui-stripe.mjs.map +1 -1
- package/fesm2022/forgeroute-ui.mjs +209 -121
- package/fesm2022/forgeroute-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/forgeroute-ui-stripe.d.ts +11 -0
- package/types/forgeroute-ui.d.ts +60 -16
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, PLATFORM_ID, ViewEncapsulation, computed, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, InjectionToken, Injector, PLATFORM_ID, ViewEncapsulation, afterNextRender, computed, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
3
3
|
import { DOCUMENT, NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
4
4
|
import { AlertComponent, BadgeComponent, ButtonComponent, DetailCardComponent, FormRowComponent, FormSectionComponent, ModalComponent, SkeletonComponent, StackComponent, TextComponent, TextInputComponent } from "@forgeroute/ui";
|
|
5
5
|
import * as i1 from "@angular/forms";
|
|
@@ -3023,6 +3023,8 @@ function stripeConnectNotice(outcome) {
|
|
|
3023
3023
|
var StripeConnectComponent = class StripeConnectComponent {
|
|
3024
3024
|
constructor() {
|
|
3025
3025
|
this.destroyRef = inject(DestroyRef);
|
|
3026
|
+
this.injector = inject(Injector);
|
|
3027
|
+
this.host = inject(ElementRef);
|
|
3026
3028
|
this.createAccount = input(null, ...ngDevMode ? [{ debugName: "createAccount" }] : /* istanbul ignore next */ []);
|
|
3027
3029
|
this.getStatus = input(null, ...ngDevMode ? [{ debugName: "getStatus" }] : /* istanbul ignore next */ []);
|
|
3028
3030
|
this.accountId = model(null, ...ngDevMode ? [{ debugName: "accountId" }] : /* istanbul ignore next */ []);
|
|
@@ -3041,6 +3043,19 @@ var StripeConnectComponent = class StripeConnectComponent {
|
|
|
3041
3043
|
this.loading = model(false, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
|
|
3042
3044
|
this.navigateTab = input(null, ...ngDevMode ? [{ debugName: "navigateTab" }] : /* istanbul ignore next */ []);
|
|
3043
3045
|
this.visible = computed(() => !!this.accountId() || this.showWhenNoAccount(), ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
|
|
3046
|
+
this.state = computed(() => !this.accountId() ? "none" : this.complete() ? "complete" : this.detailsSubmitted() ? "verifying" : "incomplete", ...ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []);
|
|
3047
|
+
this.liveText = computed(() => {
|
|
3048
|
+
if (!this.visible()) return "";
|
|
3049
|
+
const text = {
|
|
3050
|
+
none: "Stripe account not connected.",
|
|
3051
|
+
incomplete: "Account setup incomplete.",
|
|
3052
|
+
verifying: "Stripe is verifying your account.",
|
|
3053
|
+
complete: "Account setup complete."
|
|
3054
|
+
}[this.state()];
|
|
3055
|
+
return this.loading() ? `${text} Loading.` : text;
|
|
3056
|
+
}, ...ngDevMode ? [{ debugName: "liveText" }] : /* istanbul ignore next */ []);
|
|
3057
|
+
this.acted = false;
|
|
3058
|
+
this.lastState = this.state();
|
|
3044
3059
|
this.flow = new StripeConnectFlow({
|
|
3045
3060
|
createAccount: () => this.createAccount(),
|
|
3046
3061
|
getStatus: () => this.getStatus(),
|
|
@@ -3055,6 +3070,15 @@ var StripeConnectComponent = class StripeConnectComponent {
|
|
|
3055
3070
|
navigate: (url) => this.navigateCurrentTab(url),
|
|
3056
3071
|
destroyRef: this.destroyRef
|
|
3057
3072
|
});
|
|
3073
|
+
effect(() => {
|
|
3074
|
+
const state = this.state();
|
|
3075
|
+
if (this.loading()) return;
|
|
3076
|
+
const changed = state !== this.lastState;
|
|
3077
|
+
this.lastState = state;
|
|
3078
|
+
const focusIt = changed && this.acted && this.visible();
|
|
3079
|
+
this.acted = false;
|
|
3080
|
+
if (focusIt) afterNextRender(() => this.host.nativeElement.querySelector(".sc-state")?.focus(), { injector: this.injector });
|
|
3081
|
+
});
|
|
3058
3082
|
if (typeof document !== "undefined") {
|
|
3059
3083
|
const onVisible = () => {
|
|
3060
3084
|
if (document.visibilityState !== "visible" || !this.flow.tabOpened || !this.refreshOnReturn() || this.loading()) return;
|
|
@@ -3066,13 +3090,22 @@ var StripeConnectComponent = class StripeConnectComponent {
|
|
|
3066
3090
|
}
|
|
3067
3091
|
}
|
|
3068
3092
|
start() {
|
|
3093
|
+
const run = this.canRun(this.createAccount());
|
|
3069
3094
|
this.flow.start();
|
|
3095
|
+
this.acted ||= run;
|
|
3070
3096
|
}
|
|
3071
3097
|
check() {
|
|
3098
|
+
const run = this.canRun(this.getStatus());
|
|
3072
3099
|
this.flow.check();
|
|
3100
|
+
this.acted ||= run;
|
|
3073
3101
|
}
|
|
3074
3102
|
resume() {
|
|
3103
|
+
const run = this.canRun(this.getStatus());
|
|
3075
3104
|
this.flow.resume();
|
|
3105
|
+
this.acted ||= run;
|
|
3106
|
+
}
|
|
3107
|
+
canRun(call) {
|
|
3108
|
+
return !!call && !this.loading() && !this.disabled();
|
|
3076
3109
|
}
|
|
3077
3110
|
openDashboard() {
|
|
3078
3111
|
window.open(this.dashboardUrl(), "_blank", "noopener,noreferrer");
|
|
@@ -3222,6 +3255,8 @@ var StripeConnectComponent = class StripeConnectComponent {
|
|
|
3222
3255
|
},
|
|
3223
3256
|
ngImport: i0,
|
|
3224
3257
|
template: `
|
|
3258
|
+
<!-- Persistent live region: present before the state changes, so every new state is announced (and "Loading" while a request runs). -->
|
|
3259
|
+
<div class="sc-sr" role="status" aria-live="polite" aria-atomic="true" data-testid="connect-live">{{ liveText() }}</div>
|
|
3225
3260
|
@if (visible()) {
|
|
3226
3261
|
@if (bare()) {
|
|
3227
3262
|
<ng-container *ngTemplateOutlet="body" />
|
|
@@ -3234,42 +3269,42 @@ var StripeConnectComponent = class StripeConnectComponent {
|
|
|
3234
3269
|
|
|
3235
3270
|
<ng-template #body>
|
|
3236
3271
|
@if (!accountId()) {
|
|
3237
|
-
<ui-stack gap="sm" data-testid="connect-status-none">
|
|
3272
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-none" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3238
3273
|
<strong class="sc-title">{{ startTitle() }}</strong>
|
|
3239
3274
|
<ui-text size="sm" [text]="startText()" />
|
|
3240
3275
|
<ui-stack direction="horizontal">
|
|
3241
|
-
<ui-button variant="primary" size="sm" data-testid="connect-start-button" [disabled]="
|
|
3276
|
+
<ui-button variant="primary" size="sm" data-testid="connect-start-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">Loading...</span><span class="sc-sr">{{ startLabel() }}, opens in a new tab, busy</span>} @else { {{ startLabel() }}<span class="sc-sr">, opens in a new tab</span>}</ui-button>
|
|
3242
3277
|
</ui-stack>
|
|
3243
3278
|
</ui-stack>
|
|
3244
3279
|
} @else if (complete()) {
|
|
3245
|
-
<ui-stack gap="sm" data-testid="connect-status-complete">
|
|
3280
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-complete">
|
|
3246
3281
|
<strong class="sc-title">Account setup complete</strong>
|
|
3247
3282
|
<ui-text size="sm" tone="muted" [text]="'Account ID: ' + accountId()" />
|
|
3248
3283
|
<ui-stack direction="horizontal">
|
|
3249
|
-
<ui-button variant="secondary" size="sm" data-testid="connect-dashboard-button" (click)="openDashboard()">View Stripe Dashboard</ui-button>
|
|
3284
|
+
<ui-button variant="secondary" size="sm" data-testid="connect-dashboard-button" (click)="openDashboard()">View Stripe Dashboard<span class="sc-sr">, opens in a new tab</span></ui-button>
|
|
3250
3285
|
</ui-stack>
|
|
3251
3286
|
</ui-stack>
|
|
3252
3287
|
} @else if (detailsSubmitted()) {
|
|
3253
|
-
<ui-stack gap="sm" data-testid="connect-status-verifying">
|
|
3288
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-verifying" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3254
3289
|
<strong class="sc-title">Stripe is verifying your account</strong>
|
|
3255
3290
|
<ui-text size="sm" text="Your setup has been submitted. Stripe is reviewing your information — this usually takes a few minutes. Payment collection will be enabled automatically once approved." />
|
|
3256
3291
|
<ui-stack direction="horizontal">
|
|
3257
|
-
<ui-button variant="primary" size="sm" data-testid="connect-check-status-button" [disabled]="
|
|
3292
|
+
<ui-button variant="primary" size="sm" data-testid="connect-check-status-button" [disabled]="disabled()" (click)="check()">@if (loading()) {<span aria-hidden="true">Checking...</span><span class="sc-sr">Check Status, busy</span>} @else {Check Status}</ui-button>
|
|
3258
3293
|
</ui-stack>
|
|
3259
3294
|
</ui-stack>
|
|
3260
3295
|
} @else {
|
|
3261
|
-
<ui-stack gap="sm" data-testid="connect-status-incomplete">
|
|
3296
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-incomplete" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3262
3297
|
<span class="sc-badge"><ui-badge label="Account setup incomplete" variant="red" data-testid="connect-incomplete-badge" /></span>
|
|
3263
3298
|
<ui-text size="sm" text="Complete your Stripe account setup to start collecting payments from customers." />
|
|
3264
3299
|
<ui-stack direction="horizontal">
|
|
3265
|
-
<ui-button variant="primary" size="sm" data-testid="connect-complete-setup-button" [disabled]="
|
|
3300
|
+
<ui-button variant="primary" size="sm" data-testid="connect-complete-setup-button" [disabled]="disabled()" (click)="resume()">@if (loading()) {<span aria-hidden="true">Loading...</span><span class="sc-sr">Complete Setup, opens in a new tab, busy</span>} @else {Complete Setup<span class="sc-sr">, opens in a new tab</span>}</ui-button>
|
|
3266
3301
|
</ui-stack>
|
|
3267
3302
|
</ui-stack>
|
|
3268
3303
|
}
|
|
3269
3304
|
</ng-template>
|
|
3270
3305
|
`,
|
|
3271
3306
|
isInline: true,
|
|
3272
|
-
styles: ["ui-stripe-connect{display:block;min-width:0}ui-stripe-connect .sc-badge{display:flex}ui-stripe-connect .sc-title{font-size:.9375rem;font-weight:600;color:#1e293b}\n"],
|
|
3307
|
+
styles: ["ui-stripe-connect{display:block;min-width:0}ui-stripe-connect .sc-badge{display:flex}ui-stripe-connect .sc-title{font-size:.9375rem;font-weight:600;color:#1e293b}ui-stripe-connect .sc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"],
|
|
3273
3308
|
dependencies: [
|
|
3274
3309
|
{
|
|
3275
3310
|
kind: "directive",
|
|
@@ -3409,6 +3444,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3409
3444
|
TextComponent
|
|
3410
3445
|
],
|
|
3411
3446
|
template: `
|
|
3447
|
+
<!-- Persistent live region: present before the state changes, so every new state is announced (and "Loading" while a request runs). -->
|
|
3448
|
+
<div class="sc-sr" role="status" aria-live="polite" aria-atomic="true" data-testid="connect-live">{{ liveText() }}</div>
|
|
3412
3449
|
@if (visible()) {
|
|
3413
3450
|
@if (bare()) {
|
|
3414
3451
|
<ng-container *ngTemplateOutlet="body" />
|
|
@@ -3421,42 +3458,42 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
3421
3458
|
|
|
3422
3459
|
<ng-template #body>
|
|
3423
3460
|
@if (!accountId()) {
|
|
3424
|
-
<ui-stack gap="sm" data-testid="connect-status-none">
|
|
3461
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-none" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3425
3462
|
<strong class="sc-title">{{ startTitle() }}</strong>
|
|
3426
3463
|
<ui-text size="sm" [text]="startText()" />
|
|
3427
3464
|
<ui-stack direction="horizontal">
|
|
3428
|
-
<ui-button variant="primary" size="sm" data-testid="connect-start-button" [disabled]="
|
|
3465
|
+
<ui-button variant="primary" size="sm" data-testid="connect-start-button" [disabled]="disabled()" (click)="start()">@if (loading()) {<span aria-hidden="true">Loading...</span><span class="sc-sr">{{ startLabel() }}, opens in a new tab, busy</span>} @else { {{ startLabel() }}<span class="sc-sr">, opens in a new tab</span>}</ui-button>
|
|
3429
3466
|
</ui-stack>
|
|
3430
3467
|
</ui-stack>
|
|
3431
3468
|
} @else if (complete()) {
|
|
3432
|
-
<ui-stack gap="sm" data-testid="connect-status-complete">
|
|
3469
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-complete">
|
|
3433
3470
|
<strong class="sc-title">Account setup complete</strong>
|
|
3434
3471
|
<ui-text size="sm" tone="muted" [text]="'Account ID: ' + accountId()" />
|
|
3435
3472
|
<ui-stack direction="horizontal">
|
|
3436
|
-
<ui-button variant="secondary" size="sm" data-testid="connect-dashboard-button" (click)="openDashboard()">View Stripe Dashboard</ui-button>
|
|
3473
|
+
<ui-button variant="secondary" size="sm" data-testid="connect-dashboard-button" (click)="openDashboard()">View Stripe Dashboard<span class="sc-sr">, opens in a new tab</span></ui-button>
|
|
3437
3474
|
</ui-stack>
|
|
3438
3475
|
</ui-stack>
|
|
3439
3476
|
} @else if (detailsSubmitted()) {
|
|
3440
|
-
<ui-stack gap="sm" data-testid="connect-status-verifying">
|
|
3477
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-verifying" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3441
3478
|
<strong class="sc-title">Stripe is verifying your account</strong>
|
|
3442
3479
|
<ui-text size="sm" text="Your setup has been submitted. Stripe is reviewing your information — this usually takes a few minutes. Payment collection will be enabled automatically once approved." />
|
|
3443
3480
|
<ui-stack direction="horizontal">
|
|
3444
|
-
<ui-button variant="primary" size="sm" data-testid="connect-check-status-button" [disabled]="
|
|
3481
|
+
<ui-button variant="primary" size="sm" data-testid="connect-check-status-button" [disabled]="disabled()" (click)="check()">@if (loading()) {<span aria-hidden="true">Checking...</span><span class="sc-sr">Check Status, busy</span>} @else {Check Status}</ui-button>
|
|
3445
3482
|
</ui-stack>
|
|
3446
3483
|
</ui-stack>
|
|
3447
3484
|
} @else {
|
|
3448
|
-
<ui-stack gap="sm" data-testid="connect-status-incomplete">
|
|
3485
|
+
<ui-stack gap="sm" class="sc-state" tabindex="-1" data-testid="connect-status-incomplete" [attr.aria-busy]="loading() ? 'true' : null">
|
|
3449
3486
|
<span class="sc-badge"><ui-badge label="Account setup incomplete" variant="red" data-testid="connect-incomplete-badge" /></span>
|
|
3450
3487
|
<ui-text size="sm" text="Complete your Stripe account setup to start collecting payments from customers." />
|
|
3451
3488
|
<ui-stack direction="horizontal">
|
|
3452
|
-
<ui-button variant="primary" size="sm" data-testid="connect-complete-setup-button" [disabled]="
|
|
3489
|
+
<ui-button variant="primary" size="sm" data-testid="connect-complete-setup-button" [disabled]="disabled()" (click)="resume()">@if (loading()) {<span aria-hidden="true">Loading...</span><span class="sc-sr">Complete Setup, opens in a new tab, busy</span>} @else {Complete Setup<span class="sc-sr">, opens in a new tab</span>}</ui-button>
|
|
3453
3490
|
</ui-stack>
|
|
3454
3491
|
</ui-stack>
|
|
3455
3492
|
}
|
|
3456
3493
|
</ng-template>
|
|
3457
3494
|
`,
|
|
3458
3495
|
encapsulation: ViewEncapsulation.None,
|
|
3459
|
-
styles: ["ui-stripe-connect{display:block;min-width:0}ui-stripe-connect .sc-badge{display:flex}ui-stripe-connect .sc-title{font-size:.9375rem;font-weight:600;color:#1e293b}\n"]
|
|
3496
|
+
styles: ["ui-stripe-connect{display:block;min-width:0}ui-stripe-connect .sc-badge{display:flex}ui-stripe-connect .sc-title{font-size:.9375rem;font-weight:600;color:#1e293b}ui-stripe-connect .sc-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}\n"]
|
|
3460
3497
|
}]
|
|
3461
3498
|
}],
|
|
3462
3499
|
ctorParameters: () => [],
|