Skip to content

Commit 387847b

Browse files
committed
feat: convert to standalone
ResizableModule is now deprecated, please migrate to the standalone `ResizableDirective` / `ResizeHandleDirective` directives instead
1 parent 4cf73c6 commit 387847b

11 files changed

Lines changed: 41 additions & 59 deletions

File tree

.eslintrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
"prefix": "mwl",
2929
"style": "kebab-case"
3030
}
31-
],
32-
"@angular-eslint/prefer-standalone": "off"
31+
]
3332
}
3433
},
3534
{

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ Then use it in your app like so:
3434

3535
```typescript
3636
import { Component } from '@angular/core';
37-
import { ResizeEvent } from 'angular-resizable-element';
37+
import { ResizeEvent, ResizableDirective, ResizeHandleDirective } from 'angular-resizable-element';
3838

3939
@Component({
4040
selector: 'demo-app',
41+
imports: [ResizableDirective, ResizeHandleDirective],
4142
styles: [
4243
`
4344
.rectangle {
@@ -105,17 +106,6 @@ export class MyComponent {
105106
console.log('Element was resized', event);
106107
}
107108
}
108-
109-
// now use within your apps module
110-
import { NgModule } from '@angular/core';
111-
import { ResizableModule } from 'angular-resizable-element';
112-
113-
@NgModule({
114-
declarations: [MyComponent],
115-
imports: [ResizableModule],
116-
bootstrap: [MyComponent],
117-
})
118-
class MyModule {}
119109
```
120110

121111
You may also find it useful to view the [demo source](https://github.com/mattlewis92/angular-resizable-element/blob/main/projects/demo/app/demo.component.ts).
@@ -129,7 +119,7 @@ https://mattlewis92.github.io/angular-resizable-element/docs/
129119

130120
### Prepare your environment
131121

132-
- Install [Node.js (>=14.19.0 or >=16.9.0)](http://nodejs.org/)
122+
- Install [Node.js (>=24.5.0)](http://nodejs.org/)
133123
- Install pnpm: `corepack enable`
134124
- Install local dev dependencies: `pnpm install` while current directory is this repo
135125

projects/angular-resizable-element/src/lib/resizable.directive.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ export const MOUSE_MOVE_THROTTLE_MS: number = 50;
205205
@Directive({
206206
selector: '[mwlResizable]',
207207
exportAs: 'mwlResizable',
208-
standalone: false,
209208
})
210209
export class ResizableDirective implements OnInit, OnDestroy {
211210
/**

projects/angular-resizable-element/src/lib/resizable.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import { NgModule } from '@angular/core';
22
import { ResizableDirective } from './resizable.directive';
33
import { ResizeHandleDirective } from './resize-handle.directive';
44

5+
/**
6+
* @deprecated import standalone `ResizableDirective` / `ResizeHandleDirective` directives instead
7+
*/
58
@NgModule({
6-
declarations: [ResizableDirective, ResizeHandleDirective],
9+
imports: [ResizableDirective, ResizeHandleDirective],
710
exports: [ResizableDirective, ResizeHandleDirective],
811
})
912
export class ResizableModule {}

projects/angular-resizable-element/src/lib/resize-handle.directive.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,7 @@ import { IS_TOUCH_DEVICE } from './util/is-touch-device';
3030
* <div mwlResizeHandle [resizableContainer]="resizableElement" [resizeEdges]="{bottom: true, right: true}"></div>
3131
* ```
3232
*/
33-
@Directive({
34-
selector: '[mwlResizeHandle]',
35-
standalone: false,
36-
})
33+
@Directive({ selector: '[mwlResizeHandle]' })
3734
export class ResizeHandleDirective implements OnInit, OnDestroy {
3835
private renderer = inject(Renderer2);
3936
private element = inject(ElementRef);

projects/angular-resizable-element/src/test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import 'zone.js';
44
import 'zone.js/testing';
55
import 'zone.js/plugins/mocha-patch';
66
import { getTestBed } from '@angular/core/testing';
7-
import {
8-
BrowserDynamicTestingModule,
9-
platformBrowserDynamicTesting,
10-
} from '@angular/platform-browser-dynamic/testing';
117

128
import { use } from 'chai';
139
import sinonChai from 'sinon-chai';
10+
import {
11+
BrowserTestingModule,
12+
platformBrowserTesting,
13+
} from '@angular/platform-browser/testing';
1414

1515
use(sinonChai);
1616

1717
// First, initialize the Angular testing environment.
1818
getTestBed().initTestEnvironment(
19-
BrowserDynamicTestingModule,
20-
platformBrowserDynamicTesting(),
19+
BrowserTestingModule,
20+
platformBrowserTesting(),
2121
{ teardown: { destroyAfterEach: true } },
2222
);

projects/angular-resizable-element/src/test/resizable.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { Component, ElementRef, ViewChild } from '@angular/core';
2-
import { ResizableDirective } from '../lib/resizable.directive';
3-
import { Edges } from '../lib/interfaces/edges.interface';
4-
import { ResizableModule, ResizeEvent } from '../public-api';
2+
import {
3+
ResizableDirective,
4+
Edges,
5+
ResizeEvent,
6+
ResizeHandleDirective,
7+
} from 'angular-resizable-element';
58
import { ComponentFixture, TestBed } from '@angular/core/testing';
69
import { expect } from 'chai';
710
import * as sinon from 'sinon';
11+
import { NgStyle } from '@angular/common';
812

913
@Component({
1014
styles: [
@@ -95,7 +99,7 @@ import * as sinon from 'sinon';
9599
}
96100
</div>
97101
`,
98-
standalone: false,
102+
imports: [NgStyle, ResizableDirective, ResizeHandleDirective],
99103
})
100104
class TestComponent {
101105
@ViewChild(ResizableDirective) resizable: ResizableDirective;
@@ -112,7 +116,7 @@ class TestComponent {
112116
right: true,
113117
};
114118
enableGhostResize: boolean = true;
115-
resizeSnapGrid: object = {};
119+
resizeSnapGrid: Edges = {};
116120
resizeCursors: object = {};
117121
ghostElementPositioning: 'fixed' | 'absolute' = 'fixed';
118122
showResizeHandle = false;
@@ -133,8 +137,7 @@ describe('resizable directive', () => {
133137

134138
beforeEach(() => {
135139
TestBed.configureTestingModule({
136-
imports: [ResizableModule],
137-
declarations: [TestComponent],
140+
imports: [TestComponent],
138141
});
139142
});
140143

@@ -1431,8 +1434,6 @@ describe('resizable directive', () => {
14311434

14321435
it('should set the resize cursor on the body when resizing', () => {
14331436
const fixture: ComponentFixture<TestComponent> = createComponent();
1434-
const elm: HTMLElement =
1435-
fixture.componentInstance.resizable['elm'].nativeElement;
14361437
const handle = fixture.nativeElement.querySelector('.resize-handle-left');
14371438
triggerDomEvent('mousedown', handle, {
14381439
clientX: 100,

projects/demo/app/demo.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { Component } from '@angular/core';
2-
import { ResizeEvent } from 'angular-resizable-element';
2+
import {
3+
ResizeEvent,
4+
ResizableDirective,
5+
ResizeHandleDirective,
6+
} from 'angular-resizable-element';
7+
import { NgStyle } from '@angular/common';
38

49
@Component({
510
selector: 'mwl-demo',
11+
imports: [NgStyle, ResizableDirective, ResizeHandleDirective],
612
styles: [
713
`
814
.rectangle {
@@ -88,7 +94,6 @@ import { ResizeEvent } from 'angular-resizable-element';
8894
</div>
8995
</div>
9096
`,
91-
standalone: false,
9297
})
9398
export class DemoComponent {
9499
public style: object = {};

projects/demo/app/demo.module.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

projects/demo/main.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import { enableProdMode } from '@angular/core';
2-
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
32

4-
import { DemoModule } from './app/demo.module';
53
import { environment } from './environments/environment';
4+
import { bootstrapApplication } from '@angular/platform-browser';
5+
6+
import { DemoComponent } from './app/demo.component';
67

78
if (environment.production) {
89
enableProdMode();
910
}
1011

11-
platformBrowserDynamic()
12-
.bootstrapModule(DemoModule)
13-
.catch((err) => console.error(err));
12+
bootstrapApplication(DemoComponent).catch((err) => console.error(err));

0 commit comments

Comments
 (0)