diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f605a9..17acfe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## v0.13.0 +- Embrace standalone components and get rig of `NgModule`. + ## v0.12.0 - `angular 18` migration. diff --git a/README.md b/README.md index 745e4be..9500df3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Use the fork, Luke. PR without tests will likely not be merged. ## What is it ? -It's an angular component to easily integrate [intl-tel-input](https://github.com/jackocnr/intl-tel-input). +It's an angular standalone component to easily integrate [intl-tel-input](https://github.com/jackocnr/intl-tel-input). ## Installation diff --git a/src/lib/components/intl-tel-input.component.html b/src/lib/components/intl-tel-input.component.html index 1571ad3..27859bf 100644 --- a/src/lib/components/intl-tel-input.component.html +++ b/src/lib/components/intl-tel-input.component.html @@ -1,4 +1,6 @@ - +@if (label && name) { + +} { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - IntlTelInputComponent, - ], imports: [ + IntlTelInputComponent, FormsModule, ], providers: [ diff --git a/src/lib/components/intl-tel-input.component.ts b/src/lib/components/intl-tel-input.component.ts index 29969d9..8aaa843 100644 --- a/src/lib/components/intl-tel-input.component.ts +++ b/src/lib/components/intl-tel-input.component.ts @@ -8,15 +8,18 @@ */ import { AfterViewInit, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; -import { ControlContainer, NgForm } from '@angular/forms'; +import { ControlContainer, FormsModule, NgForm } from '@angular/forms'; import intlTelInput from 'intl-tel-input'; import { IntlTelInputOptions } from '../model/intl-tel-input-options'; import { IntlTelInput } from "../model/intl-tel-input"; +import { NgClass } from "@angular/common"; @Component({ selector: 'intl-tel-input', + standalone: true, templateUrl: './intl-tel-input.component.html', styleUrls: ['./intl-tel-input.component.scss'], + imports: [NgClass, FormsModule], viewProviders: [{ provide: ControlContainer, useExisting: NgForm }] }) export class IntlTelInputComponent implements AfterViewInit { diff --git a/src/lib/intl-tel-input-ng.module.spec.ts b/src/lib/intl-tel-input-ng.module.spec.ts deleted file mode 100644 index a43c200..0000000 --- a/src/lib/intl-tel-input-ng.module.spec.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { IntlTelInputNgModule } from './intl-tel-input-ng.module'; - -describe('IntlTelInputNgModule', () => { - let intlTelInputNgModule: IntlTelInputNgModule; - - beforeEach(() => { - intlTelInputNgModule = new IntlTelInputNgModule(); - }); - - it('should create an instance', () => { - expect(intlTelInputNgModule).toBeTruthy(); - }); - - it('should create an instance with providers via forRoot()', () => { - const intlTelInputNgModuleWithProviders = IntlTelInputNgModule.forRoot(); - expect(intlTelInputNgModuleWithProviders.providers).toBeTruthy(); - }); -}); diff --git a/src/lib/intl-tel-input-ng.module.ts b/src/lib/intl-tel-input-ng.module.ts deleted file mode 100644 index 154b386..0000000 --- a/src/lib/intl-tel-input-ng.module.ts +++ /dev/null @@ -1,34 +0,0 @@ -/* - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS - * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR - * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -import { CommonModule } from '@angular/common'; -import { ModuleWithProviders, NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; -import { IntlTelInputComponent } from './components/intl-tel-input.component'; - -@NgModule({ - declarations: [ - IntlTelInputComponent, - ], - imports: [ - CommonModule, - FormsModule, - ], - exports: [ - IntlTelInputComponent, - ] -}) -export class IntlTelInputNgModule { - static forRoot(): ModuleWithProviders { - return { - ngModule: IntlTelInputNgModule, - providers: [] - }; - } -} diff --git a/src/public_api.ts b/src/public_api.ts index 8782f66..07cc259 100644 --- a/src/public_api.ts +++ b/src/public_api.ts @@ -5,4 +5,3 @@ export * from './lib/components/intl-tel-input.component'; export * from './lib/model/intl-tel-input-options'; export * from './lib/model/intl-tel-input'; -export * from './lib/intl-tel-input-ng.module';