sweetalert2 / ngx-sweetalert2

Declarative, reactive, and template-driven SweetAlert2 integration for Angular
MIT License
652 stars 94 forks source link

Support for Angular 18 #263

Closed mattia1208 closed 2 months ago

mattia1208 commented 3 months ago

Add support for Angular 18

liqMats commented 3 months ago

+1

kfirufk commented 3 months ago

just in case it helps anyone, adding importProvidersFrom([SweetAlert2Module.forRoot()]) to app.config.ts is enough to work with it in angular 18 with standalone components.

fernando24j commented 2 months ago

just in case it helps anyone, adding importProvidersFrom([SweetAlert2Module.forRoot()]) to app.config.ts is enough to work with it in angular 18 with standalone components.

The build also works? or only on development mode?

md-redwan-hossain commented 2 months ago

I can't even install the package in angular 18. The following error is thrown.

npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: erp-agrosol-frontend@0.0.1
npm error Found: @angular/common@18.0.4
npm error node_modules/@angular/common
npm error   @angular/common@"^18.0.0" from the root project
npm error
npm error Could not resolve dependency:
npm error peer @angular/common@"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from @sweetalert2/ngx-sweetalert2@12.3.0
npm error node_modules/@sweetalert2/ngx-sweetalert2
npm error   @sweetalert2/ngx-sweetalert2@"*" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
Hemszz commented 2 months ago

npm warn ERESOLVE overriding peer dependency npm warn While resolving: @sweetalert2/ngx-sweetalert2@12.3.0 npm warn Found: @angular/common@18.0.4 npm warn node_modules/@angular/common npm warn @angular/common@"^18.0.4" from the root project npm warn 9 more (@angular/cdk, @angular/forms, ...) npm warn npm warn Could not resolve dependency: npm warn peer @angular/common@"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from @sweetalert2/ngx-sweetalert2@12.3.0 npm warn node_modules/@sweetalert2/ngx-sweetalert2 npm warn @sweetalert2/ngx-sweetalert2@"12.3.0" from the root project npm warn npm warn Conflicting peer dependency: @angular/common@17.3.11 npm warn node_modules/@angular/common npm warn peer @angular/common@"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from @sweetalert2/ngx-sweetalert2@12.3.0 npm warn node_modules/@sweetalert2/ngx-sweetalert2 npm warn @sweetalert2/ngx-sweetalert2@"12.3.0" from the root project npm warn ERESOLVE overriding peer dependency npm warn While resolving: @sweetalert2/ngx-sweetalert2@12.3.0 npm warn Found: @angular/core@18.0.4 npm warn node_modules/@angular/core npm warn @angular/core@"^18.0.4" from the root project npm warn 15 more (@angular/animations, @angular/cdk, @angular/common, ...) npm warn npm warn Could not resolve dependency: npm warn peer @angular/core@"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from @sweetalert2/ngx-sweetalert2@12.3.0 npm warn node_modules/@sweetalert2/ngx-sweetalert2 npm warn @sweetalert2/ngx-sweetalert2@"12.3.0" from the root project npm warn npm warn Conflicting peer dependency: @angular/core@17.3.11 npm warn node_modules/@angular/core npm warn peer @angular/core@"^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from @sweetalert2/ngx-sweetalert2@12.3.0 npm warn node_modules/@sweetalert2/ngx-sweetalert2 npm warn @sweetalert2/ngx-sweetalert2@"12.3.0" from the root project

When would the support for Angular v18 be available?

kfirufk commented 2 months ago

i tried to test it, because i work just fine with angular18 and ngx-sweeetalert

so yeah after creating a new project and trying to install the packages with npm i do get these errors. with yarn they are just warnings:

$ yarn add  sweetalert2 @sweetalert2/ngx-sweetalert2
yarn add v1.22.22
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > @sweetalert2/ngx-sweetalert2@12.3.0" has incorrect peer dependency "@angular/common@^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0".
warning " > @sweetalert2/ngx-sweetalert2@12.3.0" has incorrect peer dependency "@angular/core@^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
├─ @sweetalert2/ngx-sweetalert2@12.3.0
└─ sweetalert2@11.12.0
info All dependencies
├─ @sweetalert2/ngx-sweetalert2@12.3.0
└─ sweetalert2@11.12.0
Done in 1.64s.

i guess for now you can install with npm using --force so @fernando24j - build also works and @md-redwan-hossain - in my own project i use yarn, but it didn't break anything and the project works properly.

Hemszz commented 2 months ago

+1 support for angular 18

fathanyr commented 2 months ago

Just add heightAuto: false

Swal({
  title: `I will not change html's and body's height`,
  heightAuto: false
})
eavab commented 2 months ago

I've submitted a pull request that should update the dependencies similar to how the Angular 17 support was added. This should resolve the issue of needing to run npm install --force.

As a side note, I've been working for the past week on an enterprise application that used the --force and uses Angular 18 with no issues. It appears the dependency upgrade is all that is needed.

limonte commented 2 months ago

:tada: This issue has been resolved in version 12.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: