diff --git a/.changeset/proud-books-rush.md b/.changeset/proud-books-rush.md new file mode 100644 index 00000000..1a7127f9 --- /dev/null +++ b/.changeset/proud-books-rush.md @@ -0,0 +1,5 @@ +--- +'@flatfile/angular-sdk': minor +--- + +Allow overriding the default loading component in Angular by assigning a custom TemplateRef to the ISpace['loading'] property. This enables users to replace the default loading spinner with their own loading template. diff --git a/packages/angular/angular-sdk/src/lib/sdk/space.component.html b/packages/angular/angular-sdk/src/lib/sdk/space.component.html index 595bc339..3163ba45 100644 --- a/packages/angular/angular-sdk/src/lib/sdk/space.component.html +++ b/packages/angular/angular-sdk/src/lib/sdk/space.component.html @@ -1,14 +1,22 @@ -
- +
+ + -
- +
+
-
+

Something Went Wrong

-

- {{this.error.message}} +

+ {{ error.message }}

diff --git a/packages/angular/angular-sdk/src/lib/sdk/space.component.ts b/packages/angular/angular-sdk/src/lib/sdk/space.component.ts index c6ea879a..589377b8 100644 --- a/packages/angular/angular-sdk/src/lib/sdk/space.component.ts +++ b/packages/angular/angular-sdk/src/lib/sdk/space.component.ts @@ -1,16 +1,23 @@ -import { Component, Input, OnInit } from '@angular/core' +import { + ChangeDetectorRef, + Component, + Input, + OnChanges, + OnInit, + SimpleChanges, +} from '@angular/core' +import { Flatfile } from '@flatfile/api' import { type ISpace, + InitialResourceData, type ReusedSpaceWithAccessToken, type SimpleOnboarding, createWorkbookFromSheet, initNewSpace, - InitialResourceData, } from '@flatfile/embedded-utils' import getSpace from '../../utils/getSpace' import { SpaceFramePropsType } from './space-frame/spaceFrame.component' import { SpaceService } from './space.service' -import { Flatfile } from '@flatfile/api' type ReusedOrOnboarding = ReusedSpaceWithAccessToken | SimpleOnboarding @@ -19,7 +26,7 @@ type ReusedOrOnboarding = ReusedSpaceWithAccessToken | SimpleOnboarding templateUrl: './space.component.html', styleUrls: ['./space.component.scss'], }) -export class Space implements OnInit { +export class Space implements OnInit, OnChanges { @Input() spaceProps!: ISpace @Input() openDirectly: boolean = false @@ -30,7 +37,10 @@ export class Space implements OnInit { loading: boolean = false closeInstance: boolean = false - constructor(private readonly appService: SpaceService) {} + constructor( + private readonly appService: SpaceService, + private readonly changeDetectorRef: ChangeDetectorRef + ) {} async ngOnInit() { if (!this.spaceProps) throw new Error('Please define the space props') @@ -44,6 +54,16 @@ export class Space implements OnInit { } } + ngOnChanges(changes: SimpleChanges): void { + if ('spaceProps' in changes && !changes['spaceProps'].firstChange) { + this.spaceProps = { + ...this.spaceProps, + ...changes['spaceProps'].currentValue, + } + this.changeDetectorRef.markForCheck() + } + } + handleCloseInstance() { this.closeInstance = true } @@ -91,6 +111,7 @@ export class Space implements OnInit { } initSpace = async (spaceProps: ReusedOrOnboarding) => { + this.changeDetectorRef.markForCheck() this.closeInstance = false try { @@ -128,6 +149,8 @@ export class Space implements OnInit { this.loading = false this.error = error as Error throw error + } finally { + this.changeDetectorRef.markForCheck() } } }