Skip to content

Commit f40063b

Browse files
committed
chore(*): add updated angular package to the packages folder
1 parent 6634e72 commit f40063b

File tree

48 files changed

+7615
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+7615
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# FirebaseuiAngular
2+
3+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.1.0.
4+
5+
## Code scaffolding
6+
7+
Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8+
9+
```bash
10+
ng generate component component-name
11+
```
12+
13+
For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14+
15+
```bash
16+
ng generate --help
17+
```
18+
19+
## Building
20+
21+
To build the library, run:
22+
23+
```bash
24+
ng build firebaseui-angular
25+
```
26+
27+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28+
29+
### Publishing the Library
30+
31+
Once the project is built, you can publish your library by following these steps:
32+
33+
1. Navigate to the `dist` directory:
34+
```bash
35+
cd dist/firebaseui-angular
36+
```
37+
38+
2. Run the `npm publish` command to publish your library to the npm registry:
39+
```bash
40+
npm publish
41+
```
42+
43+
## Running unit tests
44+
45+
To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
46+
47+
```bash
48+
ng test
49+
```
50+
51+
## Running end-to-end tests
52+
53+
For end-to-end (e2e) testing, run:
54+
55+
```bash
56+
ng e2e
57+
```
58+
59+
Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
60+
61+
## Additional Resources
62+
63+
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../dist/firebaseui-angular",
4+
"lib": {
5+
"entryFile": "src/public-api.ts"
6+
},
7+
"allowedNonPeerDependencies": [
8+
"@firebase-ui/core",
9+
"@firebase-ui/styles",
10+
"@tanstack/angular-form",
11+
"nanostores",
12+
"tslib",
13+
"zod"
14+
]
15+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "@firebase-ui/angular",
3+
"version": "0.0.1",
4+
"files": [
5+
"dist"
6+
],
7+
"main": "./dist/fesm2022/firebase-ui-angular.mjs",
8+
"module": "./dist/fesm2022/firebase-ui-angular.mjs",
9+
"typings": "./dist/index.d.ts",
10+
"exports": {
11+
".": {
12+
"types": "./dist/index.d.ts",
13+
"default": "./dist/fesm2022/firebase-ui-angular.mjs"
14+
}
15+
},
16+
"scripts": {
17+
"build": "ng-packagr -p ng-package.json",
18+
"publish:tags": "sh -c 'TAG=\"${npm_package_name}@${npm_package_version}\"; git tag --list \"$TAG\" | grep . || git tag \"$TAG\"; git push origin \"$TAG\"'",
19+
"release": "pnpm pack --pack-destination ../../releases/"
20+
},
21+
"peerDependencies": {
22+
"@angular/common": "^19.1.0",
23+
"@angular/core": "^19.1.0",
24+
"@firebase-ui/core": "https://github.com/firebase/firebaseui-web/raw/refs/heads/v7-alpha/releases/firebase-ui-core-0.0.1.tgz",
25+
"@firebase-ui/translations": "https://github.com/firebase/firebaseui-web/raw/refs/heads/v7-alpha/releases/firebase-ui-translations-0.0.1.tgz"
26+
},
27+
"dependencies": {
28+
"@tanstack/angular-form": "^1.1.0",
29+
"nanostores": "^0.11.3",
30+
"tslib": "^2.3.0",
31+
"zod": "^3.24.1"
32+
},
33+
"sideEffects": false,
34+
"devDependencies": {
35+
"@angular/fire": "^19.1.0",
36+
"@angular/forms": "^19.2.11",
37+
"@angular/router": "^19.2.11",
38+
"ng-packagr": "^19.1.0",
39+
"rxjs": "^7.8.2"
40+
}
41+
}
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { Component, inject, Input, OnInit } from '@angular/core';
18+
import { CommonModule } from '@angular/common';
19+
import { injectForm, TanStackField } from '@tanstack/angular-form';
20+
import { FirebaseUI } from '../../../provider';
21+
import { ButtonComponent } from '../../../components/button/button.component';
22+
import { TermsAndPrivacyComponent } from '../../../components/terms-and-privacy/terms-and-privacy.component';
23+
import {
24+
createEmailLinkFormSchema,
25+
FirebaseUIError,
26+
completeEmailLinkSignIn,
27+
sendSignInLinkToEmail,
28+
} from '@firebase-ui/core';
29+
import { firstValueFrom } from 'rxjs';
30+
31+
@Component({
32+
selector: 'fui-email-link-form',
33+
standalone: true,
34+
imports: [
35+
CommonModule,
36+
TanStackField,
37+
ButtonComponent,
38+
TermsAndPrivacyComponent,
39+
],
40+
template: `
41+
<div *ngIf="emailSent" class="fui-form">
42+
{{ emailSentMessage | async }}
43+
</div>
44+
<form *ngIf="!emailSent" (submit)="handleSubmit($event)" class="fui-form">
45+
<fieldset>
46+
<ng-container [tanstackField]="form" name="email" #email="field">
47+
<label [for]="email.api.name">
48+
<span>{{ emailLabel | async }}</span>
49+
<input
50+
type="email"
51+
[id]="email.api.name"
52+
[name]="email.api.name"
53+
[value]="email.api.state.value"
54+
(blur)="email.api.handleBlur()"
55+
(input)="email.api.handleChange($any($event).target.value)"
56+
[attr.aria-invalid]="!!email.api.state.meta.errors.length"
57+
/>
58+
<span
59+
role="alert"
60+
aria-live="polite"
61+
class="fui-form__error"
62+
*ngIf="!!email.api.state.meta.errors.length"
63+
>
64+
{{ email.api.state.meta.errors.join(', ') }}
65+
</span>
66+
</label>
67+
</ng-container>
68+
</fieldset>
69+
70+
<fui-terms-and-privacy></fui-terms-and-privacy>
71+
72+
<fieldset>
73+
<fui-button type="submit">
74+
{{ sendSignInLinkLabel | async }}
75+
</fui-button>
76+
<div class="fui-form__error" *ngIf="formError">{{ formError }}</div>
77+
</fieldset>
78+
</form>
79+
`,
80+
})
81+
export class EmailLinkFormComponent implements OnInit {
82+
private ui = inject(FirebaseUI);
83+
84+
formError: string | null = null;
85+
emailSent = false;
86+
private formSchema: any;
87+
private config: any;
88+
89+
form = injectForm({
90+
defaultValues: {
91+
email: '',
92+
},
93+
});
94+
95+
async ngOnInit() {
96+
try {
97+
this.config = await firstValueFrom(this.ui.config());
98+
99+
this.formSchema = createEmailLinkFormSchema(this.config?.translations);
100+
101+
this.form.update({
102+
validators: {
103+
onSubmit: this.formSchema,
104+
onBlur: this.formSchema,
105+
},
106+
});
107+
108+
this.completeSignIn();
109+
} catch (error) {
110+
this.formError = await firstValueFrom(
111+
this.ui.translation('errors', 'unknownError')
112+
);
113+
}
114+
}
115+
116+
private async completeSignIn() {
117+
try {
118+
await completeEmailLinkSignIn(await firstValueFrom(this.ui.config()), window.location.href);
119+
} catch (error) {
120+
if (error instanceof FirebaseUIError) {
121+
this.formError = error.message;
122+
}
123+
}
124+
}
125+
126+
async handleSubmit(event: SubmitEvent) {
127+
event.preventDefault();
128+
event.stopPropagation();
129+
130+
const email = this.form.state.values.email;
131+
132+
if (!email) {
133+
return;
134+
}
135+
136+
await this.sendSignInLink(email);
137+
}
138+
139+
async sendSignInLink(email: string) {
140+
this.formError = null;
141+
142+
try {
143+
const validationResult = this.formSchema.safeParse({
144+
email,
145+
});
146+
147+
if (!validationResult.success) {
148+
const validationErrors = validationResult.error.format();
149+
150+
if (validationErrors.email?._errors?.length) {
151+
this.formError = validationErrors.email._errors[0];
152+
return;
153+
}
154+
155+
this.formError = await firstValueFrom(
156+
this.ui.translation('errors', 'unknownError')
157+
);
158+
return;
159+
}
160+
161+
await sendSignInLinkToEmail(await firstValueFrom(this.ui.config()), email);
162+
163+
this.emailSent = true;
164+
} catch (error) {
165+
if (error instanceof FirebaseUIError) {
166+
this.formError = error.message;
167+
return;
168+
}
169+
170+
this.formError = await firstValueFrom(
171+
this.ui.translation('errors', 'unknownError')
172+
);
173+
}
174+
}
175+
176+
get emailLabel() {
177+
return this.ui.translation('labels', 'emailAddress');
178+
}
179+
180+
get sendSignInLinkLabel() {
181+
return this.ui.translation('labels', 'sendSignInLink');
182+
}
183+
184+
get emailSentMessage() {
185+
return this.ui.translation('messages', 'signInLinkSent');
186+
}
187+
}

0 commit comments

Comments
 (0)