@adzen/doohbot 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.editorconfig +17 -0
  2. package/.vscode/extensions.json +4 -0
  3. package/.vscode/launch.json +26 -0
  4. package/.vscode/settings.json +13 -0
  5. package/.vscode/tasks.json +42 -0
  6. package/README.md +58 -0
  7. package/adzen-doohbot-0.0.1.tgz +0 -0
  8. package/adzen-doohbot-1.0.0.tgz +0 -0
  9. package/angular.json +119 -0
  10. package/package.json +57 -0
  11. package/projects/doohbot/README.md +63 -0
  12. package/projects/doohbot/ng-package.json +16 -0
  13. package/projects/doohbot/package.json +12 -0
  14. package/projects/doohbot/src/lib/directives/draggable/draggable-dialog.directive.ts +62 -0
  15. package/projects/doohbot/src/lib/directives/draggable/draggable-dialog.module.ts +9 -0
  16. package/projects/doohbot/src/lib/directives/resizable/resizable-dialog.directive.ts +163 -0
  17. package/projects/doohbot/src/lib/directives/resizable/resizable-dialog.module.ts +9 -0
  18. package/projects/doohbot/src/lib/doohbot.html +216 -0
  19. package/projects/doohbot/src/lib/doohbot.scss +568 -0
  20. package/projects/doohbot/src/lib/doohbot.spec.ts +21 -0
  21. package/projects/doohbot/src/lib/doohbot.ts +345 -0
  22. package/projects/doohbot/src/lib/elements/elements.ts +25 -0
  23. package/projects/doohbot/src/lib/helpers/predefined_messages.ts +2 -0
  24. package/projects/doohbot/src/lib/inputs/doohbot-input.ts +25 -0
  25. package/projects/doohbot/src/lib/model/doohbot.intents.ts +24 -0
  26. package/projects/doohbot/src/lib/model/message.ts +13 -0
  27. package/projects/doohbot/src/lib/model/token.ts +3 -0
  28. package/projects/doohbot/src/lib/services/messaging.service.ts +76 -0
  29. package/projects/doohbot/src/lib/shared/chips/chips.html +9 -0
  30. package/projects/doohbot/src/lib/shared/chips/chips.scss +27 -0
  31. package/projects/doohbot/src/lib/shared/chips/chips.spec.ts +23 -0
  32. package/projects/doohbot/src/lib/shared/chips/chips.ts +18 -0
  33. package/projects/doohbot/src/lib/shared/snackbar/snackbar.html +7 -0
  34. package/projects/doohbot/src/lib/shared/snackbar/snackbar.scss +73 -0
  35. package/projects/doohbot/src/lib/shared/snackbar/snackbar.spec.ts +21 -0
  36. package/projects/doohbot/src/lib/shared/snackbar/snackbar.ts +44 -0
  37. package/projects/doohbot/src/lib/utils/material-override.scss +312 -0
  38. package/projects/doohbot/src/lib/utils/utility.scss +536 -0
  39. package/projects/doohbot/src/public-api.ts +5 -0
  40. package/projects/doohbot/tsconfig.lib.json +19 -0
  41. package/projects/doohbot/tsconfig.lib.prod.json +11 -0
  42. package/projects/doohbot/tsconfig.spec.json +14 -0
  43. package/projects/doohbot-element/public/favicon.ico +0 -0
  44. package/projects/doohbot-element/src/app/app.config.ts +12 -0
  45. package/projects/doohbot-element/src/app/app.html +1 -0
  46. package/projects/doohbot-element/src/app/app.routes.ts +3 -0
  47. package/projects/doohbot-element/src/app/app.scss +0 -0
  48. package/projects/doohbot-element/src/app/app.spec.ts +23 -0
  49. package/projects/doohbot-element/src/app/app.ts +10 -0
  50. package/projects/doohbot-element/src/index.html +15 -0
  51. package/projects/doohbot-element/src/main.ts +6 -0
  52. package/projects/doohbot-element/src/styles.scss +15 -0
  53. package/projects/doohbot-element/tsconfig.app.json +15 -0
  54. package/projects/doohbot-element/tsconfig.spec.json +14 -0
  55. package/tsconfig.json +43 -0
package/.editorconfig ADDED
@@ -0,0 +1,17 @@
1
+ # Editor configuration, see https://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.ts]
12
+ quote_type = single
13
+ ij_typescript_use_double_quotes = false
14
+
15
+ [*.md]
16
+ max_line_length = off
17
+ trim_trailing_whitespace = false
@@ -0,0 +1,4 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
3
+ "recommendations": ["angular.ng-template"]
4
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
3
+ "version": "0.2.0",
4
+ "configurations": [
5
+ {
6
+ "name": "ng serve",
7
+ "type": "chrome",
8
+ "request": "launch",
9
+ "preLaunchTask": "npm: start",
10
+ "url": "http://localhost:4200/",
11
+ "webRoot": "${workspaceFolder}",
12
+ "sourceMaps": true,
13
+ "sourceMapPathOverrides": {
14
+ "webpack:///src/*": "${webRoot}/src/*"
15
+ }
16
+ },
17
+ {
18
+ "name": "ng test",
19
+ "type": "chrome",
20
+ "request": "launch",
21
+ "preLaunchTask": "npm: test",
22
+ "url": "http://localhost:9876/debug.html",
23
+ "webRoot": "${workspaceFolder}"
24
+ }
25
+ ]
26
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "cSpell.words": [
3
+ "adzen",
4
+ "Bottomsheet",
5
+ "conditons",
6
+ "contenteditable",
7
+ "Doohbot",
8
+ "packagr",
9
+ "Pannel",
10
+ "spinbutton",
11
+ "thum"
12
+ ]
13
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ // For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
3
+ "version": "2.0.0",
4
+ "tasks": [
5
+ {
6
+ "type": "npm",
7
+ "script": "start",
8
+ "isBackground": true,
9
+ "problemMatcher": {
10
+ "owner": "typescript",
11
+ "pattern": "$tsc",
12
+ "background": {
13
+ "activeOnStart": true,
14
+ "beginsPattern": {
15
+ "regexp": "(.*?)"
16
+ },
17
+ "endsPattern": {
18
+ "regexp": "bundle generation complete"
19
+ }
20
+ }
21
+ }
22
+ },
23
+ {
24
+ "type": "npm",
25
+ "script": "test",
26
+ "isBackground": true,
27
+ "problemMatcher": {
28
+ "owner": "typescript",
29
+ "pattern": "$tsc",
30
+ "background": {
31
+ "activeOnStart": true,
32
+ "beginsPattern": {
33
+ "regexp": "(.*?)"
34
+ },
35
+ "endsPattern": {
36
+ "regexp": "bundle generation complete"
37
+ }
38
+ }
39
+ }
40
+ }
41
+ ]
42
+ }
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # DoohBot
2
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.7.
3
+
4
+ ## Development server
5
+
6
+ To start a local development server, run:
7
+
8
+ ```bash
9
+ ng serve
10
+ ```
11
+
12
+ Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.
13
+
14
+ ## Code scaffolding
15
+
16
+ Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
17
+
18
+ ```bash
19
+ ng generate component component-name
20
+ ```
21
+
22
+ For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
23
+
24
+ ```bash
25
+ ng generate --help
26
+ ```
27
+
28
+ ## Building
29
+
30
+ To build the project run:
31
+
32
+ ```bash
33
+ ng build
34
+ ```
35
+
36
+ This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.
37
+
38
+ ## Running unit tests
39
+
40
+ To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
41
+
42
+ ```bash
43
+ ng test
44
+ ```
45
+
46
+ ## Running end-to-end tests
47
+
48
+ For end-to-end (e2e) testing, run:
49
+
50
+ ```bash
51
+ ng e2e
52
+ ```
53
+
54
+ Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
55
+
56
+ ## Additional Resources
57
+
58
+ 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.
Binary file
Binary file
package/angular.json ADDED
@@ -0,0 +1,119 @@
1
+ {
2
+ "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3
+ "version": 1,
4
+ "newProjectRoot": "projects",
5
+ "projects": {
6
+ "doohbot": {
7
+ "projectType": "library",
8
+ "root": "projects/doohbot",
9
+ "sourceRoot": "projects/doohbot/src",
10
+ "prefix": "lib",
11
+ "architect": {
12
+ "build": {
13
+ "builder": "@angular/build:ng-packagr",
14
+ "configurations": {
15
+ "production": {
16
+ "tsConfig": "projects/doohbot/tsconfig.lib.prod.json"
17
+ },
18
+ "development": {
19
+ "tsConfig": "projects/doohbot/tsconfig.lib.json"
20
+ }
21
+ },
22
+ "defaultConfiguration": "production"
23
+ },
24
+ "test": {
25
+ "builder": "@angular/build:karma",
26
+ "options": {
27
+ "tsConfig": "projects/doohbot/tsconfig.spec.json"
28
+ }
29
+ }
30
+ }
31
+ },
32
+
33
+ "doohbot-element": {
34
+ "projectType": "application",
35
+ "schematics": {
36
+ "@schematics/angular:component": {
37
+ "style": "scss"
38
+ }
39
+ },
40
+ "root": "projects/doohbot-element",
41
+ "sourceRoot": "projects/doohbot-element/src",
42
+ "prefix": "app",
43
+ "architect": {
44
+ "build": {
45
+ "builder": "@angular/build:application",
46
+ "options": {
47
+ "browser": "projects/doohbot-element/src/main.ts",
48
+ "polyfills": ["zone.js"],
49
+ "tsConfig": "projects/doohbot-element/tsconfig.app.json",
50
+ "inlineStyleLanguage": "scss",
51
+ "assets": [
52
+ {
53
+ "glob": "**/*",
54
+ "input": "projects/doohbot-element/public"
55
+ }
56
+ ],
57
+ "styles": ["projects/doohbot-element/src/styles.scss"]
58
+ },
59
+ "configurations": {
60
+ "production": {
61
+ "budgets": [
62
+ {
63
+ "type": "initial",
64
+ "maximumWarning": "500kB",
65
+ "maximumError": "1MB"
66
+ },
67
+ {
68
+ "type": "anyComponentStyle",
69
+ "maximumWarning": "4kB",
70
+ "maximumError": "8kB"
71
+ }
72
+ ],
73
+ "outputHashing": "all"
74
+ },
75
+ "development": {
76
+ "optimization": false,
77
+ "extractLicenses": false,
78
+ "sourceMap": true
79
+ }
80
+ },
81
+ "defaultConfiguration": "production"
82
+ },
83
+ "serve": {
84
+ "builder": "@angular/build:dev-server",
85
+ "configurations": {
86
+ "production": {
87
+ "buildTarget": "doohbot-element:build:production"
88
+ },
89
+ "development": {
90
+ "buildTarget": "doohbot-element:build:development"
91
+ }
92
+ },
93
+ "defaultConfiguration": "development"
94
+ },
95
+ "extract-i18n": {
96
+ "builder": "@angular/build:extract-i18n"
97
+ },
98
+ "test": {
99
+ "builder": "@angular/build:karma",
100
+ "options": {
101
+ "polyfills": ["zone.js", "zone.js/testing"],
102
+ "tsConfig": "projects/doohbot-element/tsconfig.spec.json",
103
+ "inlineStyleLanguage": "scss",
104
+ "assets": [
105
+ {
106
+ "glob": "**/*",
107
+ "input": "projects/doohbot-element/public"
108
+ }
109
+ ],
110
+ "styles": ["projects/doohbot-element/src/styles.scss"]
111
+ }
112
+ }
113
+ }
114
+ }
115
+ },
116
+ "cli": {
117
+ "analytics": false
118
+ }
119
+ }
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@adzen/doohbot",
3
+ "version": "1.0.0",
4
+ "scripts": {
5
+ "ng": "ng",
6
+ "start": "ng serve",
7
+ "build": "ng build",
8
+ "watch": "ng build --watch --configuration development",
9
+ "test": "ng test"
10
+ },
11
+ "prettier": {
12
+ "printWidth": 100,
13
+ "singleQuote": true,
14
+ "overrides": [
15
+ {
16
+ "files": "*.html",
17
+ "options": {
18
+ "parser": "angular"
19
+ }
20
+ }
21
+ ]
22
+ },
23
+ "private": false,
24
+ "dependencies": {
25
+ "@angular/cdk": "^20.2.10",
26
+ "@angular/common": "^20.3.0",
27
+ "@angular/compiler": "^20.3.0",
28
+ "@angular/core": "^20.3.0",
29
+ "@angular/elements": "^20.3.9",
30
+ "@angular/forms": "^20.3.0",
31
+ "@angular/material": "^20.2.10",
32
+ "@angular/platform-browser": "^20.3.0",
33
+ "@angular/router": "^20.3.0",
34
+ "@ctrl/ngx-emoji-mart": "^9.3.0",
35
+ "@webcomponents/custom-elements": "^1.6.0",
36
+ "rxjs": "~7.8.0",
37
+ "tslib": "^2.3.0",
38
+ "zone.js": "~0.15.0"
39
+ },
40
+ "devDependencies": {
41
+ "@angular/build": "^20.3.8",
42
+ "@angular/cli": "^20.3.7",
43
+ "@angular/compiler-cli": "^20.3.0",
44
+ "@types/jasmine": "~5.1.0",
45
+ "@types/node": "^24.10.0",
46
+ "jasmine-core": "~5.9.0",
47
+ "karma": "~6.4.0",
48
+ "karma-chrome-launcher": "~3.2.0",
49
+ "karma-coverage": "~2.2.0",
50
+ "karma-jasmine": "~5.1.0",
51
+ "karma-jasmine-html-reporter": "~2.1.0",
52
+ "ng-packagr": "^20.3.0",
53
+ "prettier": "^3.6.2",
54
+ "ts-node": "^10.9.2",
55
+ "typescript": "~5.9.2"
56
+ }
57
+ }
@@ -0,0 +1,63 @@
1
+ # Chatbot
2
+
3
+ This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.3.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 chatbot
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/chatbot
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.
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/doohbot",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts",
6
+ "styleIncludePaths": ["src/lib"]
7
+ },
8
+ "assets": [
9
+ "src/assets",
10
+ {
11
+ "glob": "**/*",
12
+ "input": "node_modules/doohbot/assets/",
13
+ "output": "/assets/"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "doohbot",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^20.3.0",
6
+ "@angular/core": "^20.3.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false
12
+ }
@@ -0,0 +1,62 @@
1
+ import { Directive, ElementRef, HostListener, Input, OnInit, Renderer2 } from '@angular/core';
2
+
3
+ @Directive({
4
+ selector: '[draggableDialog]',
5
+ })
6
+ export class DraggableDialogDirective implements OnInit {
7
+ private isDragging = false;
8
+ private startX = 0;
9
+ private startY = 0;
10
+ private offsetX = 0;
11
+ private offsetY = 0;
12
+
13
+ @Input('dragHandle') dragHandleSelector: string | undefined;
14
+
15
+ private dragHandle: HTMLElement | undefined;
16
+
17
+ constructor(
18
+ private el: ElementRef,
19
+ private renderer: Renderer2,
20
+ ) {}
21
+
22
+ ngOnInit() {
23
+ if (this.dragHandleSelector) {
24
+ this.dragHandle = this.el.nativeElement.querySelector(this.dragHandleSelector);
25
+ } else {
26
+ this.dragHandle = this.el.nativeElement; // fallback
27
+ }
28
+ if (this.dragHandle) {
29
+ this.renderer.setStyle(this.dragHandle, 'cursor', 'move');
30
+ }
31
+ }
32
+
33
+ @HostListener('mousedown', ['$event'])
34
+ onMouseDown(event: MouseEvent) {
35
+ if (!this.dragHandle || event.target !== this.dragHandle) return;
36
+
37
+ this.isDragging = true;
38
+ this.startX = event.clientX - this.offsetX;
39
+ this.startY = event.clientY - this.offsetY;
40
+
41
+ event.preventDefault();
42
+ }
43
+
44
+ @HostListener('document:mousemove', ['$event'])
45
+ onMouseMove(event: MouseEvent) {
46
+ if (!this.isDragging) return;
47
+
48
+ this.offsetX = event.clientX - this.startX;
49
+ this.offsetY = event.clientY - this.startY;
50
+
51
+ this.renderer.setStyle(
52
+ this.el.nativeElement,
53
+ 'transform',
54
+ `translate(${this.offsetX}px, ${this.offsetY}px)`,
55
+ );
56
+ }
57
+
58
+ @HostListener('document:mouseup', [])
59
+ onMouseUp() {
60
+ this.isDragging = false;
61
+ }
62
+ }
@@ -0,0 +1,9 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { DraggableDialogDirective } from './draggable-dialog.directive';
3
+
4
+ @NgModule({
5
+ declarations: [],
6
+ imports: [DraggableDialogDirective],
7
+ exports: [DraggableDialogDirective],
8
+ })
9
+ export default class DraggableDialogModule {}
@@ -0,0 +1,163 @@
1
+ // resizable-dialog.directive.ts
2
+ import { Directive, ElementRef, Renderer2, OnInit, OnDestroy, HostListener } from '@angular/core';
3
+
4
+ @Directive({
5
+ selector: '[resizableDialog]',
6
+ })
7
+ export class ResizableDialogDirective implements OnInit, OnDestroy {
8
+ private resizeHandles: HTMLElement[] = [];
9
+ private activeHandle: string | null = null;
10
+ private startX = 0;
11
+ private startY = 0;
12
+ private startWidth = 0;
13
+ private startHeight = 0;
14
+ private startLeft = 0;
15
+ private startTop = 0;
16
+
17
+ // Define resize directions
18
+ private directions = ['n', 's', 'e', 'w', 'ne', 'nw', 'se', 'sw'];
19
+
20
+ constructor(
21
+ private el: ElementRef<HTMLElement>,
22
+ private renderer: Renderer2,
23
+ ) {}
24
+
25
+ ngOnInit() {
26
+ this.setStyle();
27
+ this.createResizeHandles();
28
+ }
29
+
30
+ ngOnDestroy() {
31
+ this.removeResizeHandles();
32
+ }
33
+
34
+ private setStyle() {
35
+ const element = this.el.nativeElement;
36
+ this.renderer.setStyle(element, 'position', 'absolute');
37
+ this.renderer.setStyle(element, 'overflow', 'hidden');
38
+ this.renderer.setStyle(element, 'boxSizing', 'border-box');
39
+ }
40
+
41
+ private createResizeHandles() {
42
+ this.directions.forEach((dir) => {
43
+ const handle = this.renderer.createElement('div');
44
+ this.renderer.setAttribute(handle, 'data-dir', dir);
45
+ this.renderer.setStyle(handle, 'position', 'absolute');
46
+ this.renderer.setStyle(handle, 'background', 'transparent');
47
+ this.renderer.setStyle(handle, 'zIndex', '10');
48
+ this.renderer.setStyle(handle, 'userSelect', 'none');
49
+
50
+ // Set size and position based on direction
51
+ if (dir.includes('e') || dir.includes('w')) {
52
+ this.renderer.setStyle(handle, 'width', '10px');
53
+ this.renderer.setStyle(handle, 'cursor', dir.includes('e') ? 'e-resize' : 'w-resize');
54
+ this.renderer.setStyle(handle, 'top', '0');
55
+ this.renderer.setStyle(handle, 'bottom', '0');
56
+ this.renderer.setStyle(handle, 'right', dir.includes('e') ? '0' : null);
57
+ this.renderer.setStyle(handle, 'left', dir.includes('w') ? '0' : null);
58
+ }
59
+ if (dir.includes('n') || dir.includes('s')) {
60
+ this.renderer.setStyle(handle, 'height', '10px');
61
+ this.renderer.setStyle(handle, 'cursor', dir.includes('s') ? 's-resize' : 'n-resize');
62
+ this.renderer.setStyle(handle, 'left', '0');
63
+ this.renderer.setStyle(handle, 'right', '0');
64
+ this.renderer.setStyle(handle, 'bottom', dir.includes('s') ? '0' : null);
65
+ this.renderer.setStyle(handle, 'top', dir.includes('n') ? '0' : null);
66
+ }
67
+ if (dir === 'ne' || dir === 'nw' || dir === 'se' || dir === 'sw') {
68
+ this.renderer.setStyle(handle, 'width', '12px');
69
+ this.renderer.setStyle(handle, 'height', '12px');
70
+ this.renderer.setStyle(handle, 'borderRadius', '50%');
71
+ this.renderer.setStyle(handle, 'cursor', `${dir}-resize`);
72
+ this.renderer.setStyle(handle, 'top', dir.includes('n') ? '0' : null);
73
+ this.renderer.setStyle(handle, 'bottom', dir.includes('s') ? '0' : null);
74
+ this.renderer.setStyle(handle, 'left', dir.includes('w') ? '0' : null);
75
+ this.renderer.setStyle(handle, 'right', dir.includes('e') ? '0' : null);
76
+ }
77
+
78
+ this.renderer.appendChild(this.el.nativeElement, handle);
79
+ this.resizeHandles.push(handle);
80
+ });
81
+ }
82
+
83
+ private removeResizeHandles() {
84
+ this.resizeHandles.forEach((handle) => {
85
+ this.renderer.removeChild(this.el.nativeElement, handle);
86
+ });
87
+ this.resizeHandles = [];
88
+ }
89
+
90
+ @HostListener('mousedown', ['$event'])
91
+ onMouseDown(event: MouseEvent) {
92
+ const target = event.target as HTMLElement;
93
+ const dir = target.getAttribute('data-dir');
94
+ if (!dir) return;
95
+
96
+ event.preventDefault();
97
+
98
+ this.activeHandle = dir;
99
+ const rect = this.el.nativeElement.getBoundingClientRect();
100
+
101
+ this.startX = event.clientX;
102
+ this.startY = event.clientY;
103
+ this.startWidth = parseFloat(this.getComputedStyleValue('width'));
104
+ this.startHeight = parseFloat(this.getComputedStyleValue('height'));
105
+ this.startLeft = parseFloat(this.getComputedStyleValue('left'));
106
+ this.startTop = parseFloat(this.getComputedStyleValue('top'));
107
+
108
+ // Prevent text selection during resize
109
+ document.body.classList.add('no-select');
110
+ }
111
+
112
+ @HostListener('document:mousemove', ['$event'])
113
+ onMouseMove(event: MouseEvent) {
114
+ if (!this.activeHandle) return;
115
+
116
+ const dx = event.clientX - this.startX;
117
+ const dy = event.clientY - this.startY;
118
+
119
+ let newWidth = this.startWidth;
120
+ let newHeight = this.startHeight;
121
+ let newLeft = this.startLeft;
122
+ let newTop = this.startTop;
123
+
124
+ const minWidth = 150;
125
+ const minHeight = 100;
126
+
127
+ // Horizontal resize
128
+ if (this.activeHandle.includes('e')) {
129
+ newWidth = Math.max(this.startWidth + dx, minWidth);
130
+ }
131
+ if (this.activeHandle.includes('w')) {
132
+ newWidth = Math.max(this.startWidth - dx, minWidth);
133
+ newLeft = this.startLeft + (this.startWidth - newWidth);
134
+ }
135
+
136
+ // Vertical resize
137
+ if (this.activeHandle.includes('s')) {
138
+ newHeight = Math.max(this.startHeight + dy, minHeight);
139
+ }
140
+ if (this.activeHandle.includes('n')) {
141
+ newHeight = Math.max(this.startHeight - dy, minHeight);
142
+ newTop = this.startTop + (this.startHeight - newHeight);
143
+ }
144
+
145
+ // Apply changes
146
+ this.renderer.setStyle(this.el.nativeElement, 'width', `${newWidth}px`);
147
+ this.renderer.setStyle(this.el.nativeElement, 'height', `${newHeight}px`);
148
+ this.renderer.setStyle(this.el.nativeElement, 'left', `${newLeft}px`);
149
+ this.renderer.setStyle(this.el.nativeElement, 'top', `${newTop}px`);
150
+ }
151
+
152
+ @HostListener('document:mouseup')
153
+ onMouseUp() {
154
+ if (this.activeHandle) {
155
+ this.activeHandle = null;
156
+ document.body.classList.remove('no-select');
157
+ }
158
+ }
159
+
160
+ private getComputedStyleValue(property: string): string {
161
+ return getComputedStyle(this.el.nativeElement).getPropertyValue(property) || '0';
162
+ }
163
+ }