@nanahoshi/mona-ui 0.1.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.
- package/README.md +25 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +590 -0
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +168 -0
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +220 -0
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +225 -0
- package/fesm2022/nanahoshi-mona-ui-button.mjs +497 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +1569 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +453 -0
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +200 -0
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +853 -0
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +923 -0
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +495 -0
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +686 -0
- package/fesm2022/nanahoshi-mona-ui-common.mjs +642 -0
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +485 -0
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +132 -0
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +460 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +659 -0
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +828 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +523 -0
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +615 -0
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +701 -0
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +1400 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +245 -0
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +170 -0
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +680 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-cell.component-B9SQH5N-.mjs +105 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-table-cell.directive-DlLwcCFT.mjs +42 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-Dgea-O0X.mjs +130 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-toggle.component-DIUutx9s.mjs +773 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DRHycGIh.mjs +240 -0
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-C3eZIaJK.mjs +5374 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +2 -0
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +154 -0
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +1356 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2263 -0
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +379 -0
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +630 -0
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +527 -0
- package/fesm2022/nanahoshi-mona-ui-list.mjs +4 -0
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +966 -0
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +641 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +536 -0
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +597 -0
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +790 -0
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +83 -0
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +325 -0
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +1559 -0
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1321 -0
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +294 -0
- package/fesm2022/nanahoshi-mona-ui-query.mjs +175 -0
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +339 -0
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +565 -0
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1049 -0
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +636 -0
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +843 -0
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +537 -0
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +308 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +664 -0
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +111 -0
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +369 -0
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +314 -0
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +450 -0
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +723 -0
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +716 -0
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1329 -0
- package/fesm2022/nanahoshi-mona-ui.mjs +9 -0
- package/package.json +289 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +223 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +642 -0
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +70 -0
- package/types/nanahoshi-mona-ui-button-group.d.ts +77 -0
- package/types/nanahoshi-mona-ui-button.d.ts +111 -0
- package/types/nanahoshi-mona-ui-calendar.d.ts +262 -0
- package/types/nanahoshi-mona-ui-check-box.d.ts +133 -0
- package/types/nanahoshi-mona-ui-chip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +113 -0
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +201 -0
- package/types/nanahoshi-mona-ui-color-palette.d.ts +102 -0
- package/types/nanahoshi-mona-ui-color-picker.d.ts +156 -0
- package/types/nanahoshi-mona-ui-combo-box.d.ts +232 -0
- package/types/nanahoshi-mona-ui-common.d.ts +386 -0
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +129 -0
- package/types/nanahoshi-mona-ui-date-input.d.ts +60 -0
- package/types/nanahoshi-mona-ui-date-picker.d.ts +177 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +199 -0
- package/types/nanahoshi-mona-ui-dialog.d.ts +261 -0
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +159 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +219 -0
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +176 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +113 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +87 -0
- package/types/nanahoshi-mona-ui-fieldset.d.ts +68 -0
- package/types/nanahoshi-mona-ui-filter.d.ts +115 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +1114 -0
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +25 -0
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +28 -0
- package/types/nanahoshi-mona-ui-internal-list.d.ts +269 -0
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +391 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +136 -0
- package/types/nanahoshi-mona-ui-list-box.d.ts +225 -0
- package/types/nanahoshi-mona-ui-list-view.d.ts +188 -0
- package/types/nanahoshi-mona-ui-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-menubar.d.ts +198 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +247 -0
- package/types/nanahoshi-mona-ui-notification.d.ts +106 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +161 -0
- package/types/nanahoshi-mona-ui-pager.d.ts +238 -0
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -0
- package/types/nanahoshi-mona-ui-popover.d.ts +130 -0
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +412 -0
- package/types/nanahoshi-mona-ui-popup.d.ts +485 -0
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +139 -0
- package/types/nanahoshi-mona-ui-query.d.ts +89 -0
- package/types/nanahoshi-mona-ui-radio-button.d.ts +128 -0
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +166 -0
- package/types/nanahoshi-mona-ui-slider.d.ts +305 -0
- package/types/nanahoshi-mona-ui-split-button.d.ts +182 -0
- package/types/nanahoshi-mona-ui-splitter.d.ts +70 -0
- package/types/nanahoshi-mona-ui-stepper.d.ts +173 -0
- package/types/nanahoshi-mona-ui-switch.d.ts +125 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +158 -0
- package/types/nanahoshi-mona-ui-text-area.d.ts +42 -0
- package/types/nanahoshi-mona-ui-text-box.d.ts +164 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +23 -0
- package/types/nanahoshi-mona-ui-time-picker.d.ts +184 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +143 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +130 -0
- package/types/nanahoshi-mona-ui-tree-view.d.ts +274 -0
- package/types/nanahoshi-mona-ui-window.d.ts +295 -0
- package/types/nanahoshi-mona-ui.d.ts +2 -0
|
@@ -0,0 +1,1329 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Directive, inject, DestroyRef, DOCUMENT, ElementRef, NgZone, input, afterNextRender, Pipe, ApplicationRef, Injector, signal, ViewContainerRef, computed, viewChild, TemplateRef, createComponent, Component, forwardRef, Injectable, contentChild, output, model, effect, untracked } from '@angular/core';
|
|
3
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { fromEvent, Subject, asapScheduler, map, take } from 'rxjs';
|
|
5
|
+
import { createElementControlId, focusElement, setWindowStyles } from '@nanahoshi/mona-ui/internal';
|
|
6
|
+
import { PopupDataInjectionToken, PopupCloseEvent, PopupCloseSource, PopupService } from '@nanahoshi/mona-ui/popup';
|
|
7
|
+
import * as i1 from '@angular/cdk/a11y';
|
|
8
|
+
import { CdkTrapFocus } from '@angular/cdk/a11y';
|
|
9
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
10
|
+
import { LucideMinimize, LucideMaximize, LucideMinus, LucideDynamicIcon, LucideX } from '@lucide/angular';
|
|
11
|
+
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
12
|
+
import { ThemeService } from '@nanahoshi/mona-ui/theme';
|
|
13
|
+
import { cva } from 'class-variance-authority';
|
|
14
|
+
|
|
15
|
+
class WindowActionTemplateDirective {
|
|
16
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowActionTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
17
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: WindowActionTemplateDirective, isStandalone: true, selector: "ng-template[monaWindowActionTemplate]", ngImport: i0 }); }
|
|
18
|
+
}
|
|
19
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowActionTemplateDirective, decorators: [{
|
|
20
|
+
type: Directive,
|
|
21
|
+
args: [{
|
|
22
|
+
selector: "ng-template[monaWindowActionTemplate]"
|
|
23
|
+
}]
|
|
24
|
+
}] });
|
|
25
|
+
|
|
26
|
+
class WindowContentTemplateDirective {
|
|
27
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
28
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: WindowContentTemplateDirective, isStandalone: true, selector: "ng-template[monaWindowContentTemplate]", ngImport: i0 }); }
|
|
29
|
+
}
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowContentTemplateDirective, decorators: [{
|
|
31
|
+
type: Directive,
|
|
32
|
+
args: [{
|
|
33
|
+
selector: "ng-template[monaWindowContentTemplate]"
|
|
34
|
+
}]
|
|
35
|
+
}] });
|
|
36
|
+
|
|
37
|
+
class WindowFooterTemplateDirective {
|
|
38
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
39
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: WindowFooterTemplateDirective, isStandalone: true, selector: "ng-template[monaWindowFooterTemplate]", ngImport: i0 }); }
|
|
40
|
+
}
|
|
41
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowFooterTemplateDirective, decorators: [{
|
|
42
|
+
type: Directive,
|
|
43
|
+
args: [{
|
|
44
|
+
selector: "ng-template[monaWindowFooterTemplate]"
|
|
45
|
+
}]
|
|
46
|
+
}] });
|
|
47
|
+
|
|
48
|
+
class WindowTitleTemplateDirective {
|
|
49
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowTitleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
50
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: WindowTitleTemplateDirective, isStandalone: true, selector: "ng-template[monaWindowTitleTemplate]", ngImport: i0 }); }
|
|
51
|
+
}
|
|
52
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowTitleTemplateDirective, decorators: [{
|
|
53
|
+
type: Directive,
|
|
54
|
+
args: [{
|
|
55
|
+
selector: "ng-template[monaWindowTitleTemplate]"
|
|
56
|
+
}]
|
|
57
|
+
}] });
|
|
58
|
+
|
|
59
|
+
const DefaultMaxWindowHeight = 800;
|
|
60
|
+
const DefaultMaxWindowWidth = 1200;
|
|
61
|
+
const DefaultMinWindowHeight = 50;
|
|
62
|
+
const DefaultMinWindowWidth = 50;
|
|
63
|
+
|
|
64
|
+
const KeyboardMoveStep = 10;
|
|
65
|
+
const KeyboardMoveStepFine = 1;
|
|
66
|
+
class WindowDragHandlerDirective {
|
|
67
|
+
#destroyRef;
|
|
68
|
+
#document;
|
|
69
|
+
#hostElementRef;
|
|
70
|
+
#zone;
|
|
71
|
+
#activeCleanup;
|
|
72
|
+
constructor() {
|
|
73
|
+
this.#destroyRef = inject(DestroyRef);
|
|
74
|
+
this.#document = inject(DOCUMENT);
|
|
75
|
+
this.#hostElementRef = inject(ElementRef);
|
|
76
|
+
this.#zone = inject(NgZone);
|
|
77
|
+
this.draggable = input(true, /* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [{ debugName: "draggable" }] : /* istanbul ignore next */ []));
|
|
79
|
+
this.windowRef = input.required(/* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "windowRef" }] : /* istanbul ignore next */ []));
|
|
81
|
+
afterNextRender({
|
|
82
|
+
read: () => this.#setEvents()
|
|
83
|
+
});
|
|
84
|
+
this.#destroyRef.onDestroy(() => this.#activeCleanup?.());
|
|
85
|
+
}
|
|
86
|
+
onKeydown(event) {
|
|
87
|
+
if (!this.draggable()) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const step = event.shiftKey ? KeyboardMoveStepFine : KeyboardMoveStep;
|
|
91
|
+
const element = this.windowRef().element;
|
|
92
|
+
const innerWidth = this.#document.defaultView?.innerWidth || DefaultMaxWindowWidth;
|
|
93
|
+
const innerHeight = this.#document.defaultView?.innerHeight || DefaultMaxWindowHeight;
|
|
94
|
+
const initialTop = element.getBoundingClientRect().top;
|
|
95
|
+
const initialLeft = element.getBoundingClientRect().left;
|
|
96
|
+
let top = initialTop;
|
|
97
|
+
let left = initialLeft;
|
|
98
|
+
switch (event.key) {
|
|
99
|
+
case "ArrowUp":
|
|
100
|
+
top = Math.max(0, initialTop - step);
|
|
101
|
+
break;
|
|
102
|
+
case "ArrowDown":
|
|
103
|
+
top = Math.min(innerHeight, initialTop + step);
|
|
104
|
+
break;
|
|
105
|
+
case "ArrowLeft":
|
|
106
|
+
left = Math.max(0, initialLeft - step);
|
|
107
|
+
break;
|
|
108
|
+
case "ArrowRight":
|
|
109
|
+
left = Math.min(innerWidth, initialLeft + step);
|
|
110
|
+
break;
|
|
111
|
+
default:
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
element.style.top = `${top}px`;
|
|
116
|
+
element.style.left = `${left}px`;
|
|
117
|
+
this.windowRef().moveStart$$.next();
|
|
118
|
+
this.windowRef().move$$.next({ top, left });
|
|
119
|
+
this.windowRef().moveEnd$$.next();
|
|
120
|
+
}
|
|
121
|
+
#onPointerDown(event) {
|
|
122
|
+
if (!this.draggable()) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const element = this.windowRef().element;
|
|
126
|
+
const initialX = event.clientX;
|
|
127
|
+
const initialY = event.clientY;
|
|
128
|
+
const initialTop = element.getBoundingClientRect().top;
|
|
129
|
+
const initialLeft = element.getBoundingClientRect().left;
|
|
130
|
+
const innerWidth = this.#document.defaultView?.innerWidth || DefaultMaxWindowWidth;
|
|
131
|
+
const innerHeight = this.#document.defaultView?.innerHeight || DefaultMaxWindowHeight;
|
|
132
|
+
let dragInitiated = false;
|
|
133
|
+
const onPointerMove = (event) => {
|
|
134
|
+
if (!dragInitiated) {
|
|
135
|
+
dragInitiated = true;
|
|
136
|
+
this.windowRef().moveStart$$.next();
|
|
137
|
+
}
|
|
138
|
+
if (event.clientX < 0 || event.clientX > innerWidth || event.clientY < 0 || event.clientY > innerHeight) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const deltaX = event.clientX - initialX;
|
|
142
|
+
const deltaY = event.clientY - initialY;
|
|
143
|
+
const top = initialTop + deltaY;
|
|
144
|
+
const left = initialLeft + deltaX;
|
|
145
|
+
element.style.top = `${top}px`;
|
|
146
|
+
element.style.left = `${left}px`;
|
|
147
|
+
this.windowRef().move$$.next({ top, left });
|
|
148
|
+
};
|
|
149
|
+
const cleanup = () => {
|
|
150
|
+
this.#document.removeEventListener("pointermove", onPointerMove);
|
|
151
|
+
this.#document.removeEventListener("pointerup", onPointerUp);
|
|
152
|
+
this.#activeCleanup = undefined;
|
|
153
|
+
};
|
|
154
|
+
const onPointerUp = () => {
|
|
155
|
+
cleanup();
|
|
156
|
+
if (dragInitiated) {
|
|
157
|
+
this.windowRef().moveEnd$$.next();
|
|
158
|
+
dragInitiated = false;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
this.#activeCleanup = cleanup;
|
|
162
|
+
this.#document.addEventListener("pointermove", onPointerMove);
|
|
163
|
+
this.#document.addEventListener("pointerup", onPointerUp);
|
|
164
|
+
}
|
|
165
|
+
#setEvents() {
|
|
166
|
+
this.#zone.runOutsideAngular(() => {
|
|
167
|
+
fromEvent(this.#hostElementRef.nativeElement, "pointerdown")
|
|
168
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
169
|
+
.subscribe(event => this.#onPointerDown(event));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowDragHandlerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
173
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: WindowDragHandlerDirective, isStandalone: true, selector: "div[monaWindowDragHandler]", inputs: { draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, windowRef: { classPropertyName: "windowRef", publicName: "windowRef", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "keydown": "onKeydown($event)" } }, ngImport: i0 }); }
|
|
174
|
+
}
|
|
175
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowDragHandlerDirective, decorators: [{
|
|
176
|
+
type: Directive,
|
|
177
|
+
args: [{
|
|
178
|
+
selector: "div[monaWindowDragHandler]",
|
|
179
|
+
host: {
|
|
180
|
+
"(keydown)": "onKeydown($event)"
|
|
181
|
+
}
|
|
182
|
+
}]
|
|
183
|
+
}], ctorParameters: () => [], propDecorators: { draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], windowRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowRef", required: true }] }] } });
|
|
184
|
+
|
|
185
|
+
const KeyboardResizeStep = 10;
|
|
186
|
+
const KeyboardResizeStepFine = 1;
|
|
187
|
+
class WindowResizeHandlerDirective {
|
|
188
|
+
#destroyRef;
|
|
189
|
+
#document;
|
|
190
|
+
#hostElementRef;
|
|
191
|
+
#zone;
|
|
192
|
+
#activeCleanup;
|
|
193
|
+
constructor() {
|
|
194
|
+
this.#destroyRef = inject(DestroyRef);
|
|
195
|
+
this.#document = inject(DOCUMENT);
|
|
196
|
+
this.#hostElementRef = inject(ElementRef);
|
|
197
|
+
this.#zone = inject(NgZone);
|
|
198
|
+
this.direction = input.required(/* @ts-ignore */
|
|
199
|
+
...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
200
|
+
this.maxHeight = input(/* @ts-ignore */
|
|
201
|
+
...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : /* istanbul ignore next */ []));
|
|
202
|
+
this.maxWidth = input(/* @ts-ignore */
|
|
203
|
+
...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : /* istanbul ignore next */ []));
|
|
204
|
+
this.minHeight = input(/* @ts-ignore */
|
|
205
|
+
...(ngDevMode ? [undefined, { debugName: "minHeight" }] : /* istanbul ignore next */ []));
|
|
206
|
+
this.minWidth = input(/* @ts-ignore */
|
|
207
|
+
...(ngDevMode ? [undefined, { debugName: "minWidth" }] : /* istanbul ignore next */ []));
|
|
208
|
+
this.windowRef = input.required(/* @ts-ignore */
|
|
209
|
+
...(ngDevMode ? [{ debugName: "windowRef" }] : /* istanbul ignore next */ []));
|
|
210
|
+
afterNextRender({
|
|
211
|
+
read: () => this.#setEvents()
|
|
212
|
+
});
|
|
213
|
+
this.#destroyRef.onDestroy(() => this.#activeCleanup?.());
|
|
214
|
+
}
|
|
215
|
+
onKeydown(event) {
|
|
216
|
+
const step = event.shiftKey ? KeyboardResizeStepFine : KeyboardResizeStep;
|
|
217
|
+
let deltaX = 0;
|
|
218
|
+
let deltaY = 0;
|
|
219
|
+
switch (event.key) {
|
|
220
|
+
case "ArrowUp":
|
|
221
|
+
deltaY = -step;
|
|
222
|
+
break;
|
|
223
|
+
case "ArrowDown":
|
|
224
|
+
deltaY = step;
|
|
225
|
+
break;
|
|
226
|
+
case "ArrowLeft":
|
|
227
|
+
deltaX = -step;
|
|
228
|
+
break;
|
|
229
|
+
case "ArrowRight":
|
|
230
|
+
deltaX = step;
|
|
231
|
+
break;
|
|
232
|
+
default:
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const element = this.windowRef().element;
|
|
236
|
+
const rect = element.getBoundingClientRect();
|
|
237
|
+
const initial = { width: rect.width, height: rect.height, top: rect.top, left: rect.left };
|
|
238
|
+
const result = this.#computeResize(this.direction(), deltaX, deltaY, initial, this.#bounds());
|
|
239
|
+
if (!result) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
this.#applyResize(element, result, initial);
|
|
244
|
+
}
|
|
245
|
+
#applyResize(element, result, initial) {
|
|
246
|
+
if (result.height != null) {
|
|
247
|
+
element.style.height = `${result.height}px`;
|
|
248
|
+
}
|
|
249
|
+
if (result.top != null) {
|
|
250
|
+
element.style.top = `${result.top}px`;
|
|
251
|
+
}
|
|
252
|
+
if (result.width != null) {
|
|
253
|
+
element.style.width = `${result.width}px`;
|
|
254
|
+
}
|
|
255
|
+
if (result.left != null) {
|
|
256
|
+
element.style.left = `${result.left}px`;
|
|
257
|
+
}
|
|
258
|
+
this.windowRef().resize$$.next({
|
|
259
|
+
width: result.width ?? initial.width,
|
|
260
|
+
height: result.height ?? initial.height,
|
|
261
|
+
left: result.left ?? initial.left,
|
|
262
|
+
top: result.top ?? initial.top
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
#bounds() {
|
|
266
|
+
const innerWidth = this.#document.defaultView?.innerWidth || DefaultMaxWindowWidth;
|
|
267
|
+
const innerHeight = this.#document.defaultView?.innerHeight || DefaultMaxWindowHeight;
|
|
268
|
+
return {
|
|
269
|
+
innerWidth,
|
|
270
|
+
innerHeight,
|
|
271
|
+
minWidth: this.minWidth() || DefaultMinWindowWidth,
|
|
272
|
+
minHeight: this.minHeight() || DefaultMinWindowHeight,
|
|
273
|
+
maxWidth: this.maxWidth() ?? innerWidth,
|
|
274
|
+
maxHeight: this.maxHeight() ?? innerHeight
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
#computeResize(direction, deltaX, deltaY, initial, bounds) {
|
|
278
|
+
const { minWidth, minHeight, maxWidth, maxHeight, innerWidth, innerHeight } = bounds;
|
|
279
|
+
let height;
|
|
280
|
+
let left;
|
|
281
|
+
let width;
|
|
282
|
+
let top;
|
|
283
|
+
switch (direction) {
|
|
284
|
+
case "northwest":
|
|
285
|
+
if (initial.top + deltaY <= 0 || initial.height - deltaY < minHeight) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (initial.height - deltaY > maxHeight || initial.width - deltaX > maxWidth) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
height = initial.height - deltaY;
|
|
292
|
+
top = initial.top + deltaY;
|
|
293
|
+
if (initial.left + deltaX < 0 || initial.width - deltaX < minWidth) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
width = initial.width - deltaX;
|
|
297
|
+
left = initial.left + deltaX;
|
|
298
|
+
break;
|
|
299
|
+
case "north":
|
|
300
|
+
if (initial.top + deltaY <= 0 || initial.height - deltaY < minHeight) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
if (initial.height - deltaY > maxHeight) {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
height = initial.height - deltaY;
|
|
307
|
+
top = initial.top + deltaY;
|
|
308
|
+
break;
|
|
309
|
+
case "northeast":
|
|
310
|
+
if (initial.top + deltaY <= 0 || initial.height - deltaY < minHeight) {
|
|
311
|
+
return null;
|
|
312
|
+
}
|
|
313
|
+
if (initial.height - deltaY > maxHeight || initial.width + deltaX > maxWidth) {
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
height = initial.height - deltaY;
|
|
317
|
+
top = initial.top + deltaY;
|
|
318
|
+
if (initial.width + deltaX < 100 || initial.left + initial.width + deltaX > innerWidth) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
width = initial.width + deltaX;
|
|
322
|
+
break;
|
|
323
|
+
case "east":
|
|
324
|
+
if (initial.width + deltaX < minWidth || initial.left + initial.width + deltaX > innerWidth) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
if (initial.width + deltaX > maxWidth) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
width = initial.width + deltaX;
|
|
331
|
+
break;
|
|
332
|
+
case "southeast":
|
|
333
|
+
if (initial.height + deltaY < minHeight || initial.top + initial.height + deltaY > innerHeight) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
if (initial.height + deltaY > maxHeight || initial.width + deltaX > maxWidth) {
|
|
337
|
+
return null;
|
|
338
|
+
}
|
|
339
|
+
height = initial.height + deltaY;
|
|
340
|
+
if (initial.width + deltaX < minWidth || initial.left + initial.width + deltaX > innerWidth) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
width = initial.width + deltaX;
|
|
344
|
+
break;
|
|
345
|
+
case "south":
|
|
346
|
+
if (initial.height + deltaY < minHeight || initial.top + initial.height + deltaY > innerHeight) {
|
|
347
|
+
return null;
|
|
348
|
+
}
|
|
349
|
+
if (initial.height + deltaY > maxHeight) {
|
|
350
|
+
return null;
|
|
351
|
+
}
|
|
352
|
+
height = initial.height + deltaY;
|
|
353
|
+
break;
|
|
354
|
+
case "southwest":
|
|
355
|
+
if (initial.height + deltaY < minHeight || initial.top + initial.height + deltaY > innerHeight) {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
if (initial.height + deltaY > maxHeight || initial.width - deltaX > maxWidth) {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
height = initial.height + deltaY;
|
|
362
|
+
if (initial.left + deltaX < 0 || initial.width - deltaX < minWidth) {
|
|
363
|
+
return null;
|
|
364
|
+
}
|
|
365
|
+
width = initial.width - deltaX;
|
|
366
|
+
left = initial.left + deltaX;
|
|
367
|
+
break;
|
|
368
|
+
case "west":
|
|
369
|
+
if (initial.left + deltaX < 0 || initial.width - deltaX < minWidth) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
if (initial.width - deltaX > maxWidth) {
|
|
373
|
+
return null;
|
|
374
|
+
}
|
|
375
|
+
width = initial.width - deltaX;
|
|
376
|
+
left = initial.left + deltaX;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
return { width, height, left, top };
|
|
380
|
+
}
|
|
381
|
+
#onPointerDown(event) {
|
|
382
|
+
const element = this.windowRef().element;
|
|
383
|
+
const rect = element.getBoundingClientRect();
|
|
384
|
+
const initial = { width: rect.width, height: rect.height, top: rect.top, left: rect.left };
|
|
385
|
+
const initialX = event.clientX;
|
|
386
|
+
const initialY = event.clientY;
|
|
387
|
+
const oldSelectStart = this.#document.onselectstart;
|
|
388
|
+
const oldDragStart = this.#document.ondragstart;
|
|
389
|
+
this.#document.onselectstart = () => false;
|
|
390
|
+
this.#document.ondragstart = () => false;
|
|
391
|
+
const bounds = this.#bounds();
|
|
392
|
+
const onPointerMove = (event) => {
|
|
393
|
+
const deltaX = event.clientX - initialX;
|
|
394
|
+
const deltaY = event.clientY - initialY;
|
|
395
|
+
const result = this.#computeResize(this.direction(), deltaX, deltaY, initial, bounds);
|
|
396
|
+
if (!result) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.#applyResize(element, result, initial);
|
|
400
|
+
};
|
|
401
|
+
const cleanup = () => {
|
|
402
|
+
this.#document.removeEventListener("pointermove", onPointerMove);
|
|
403
|
+
this.#document.removeEventListener("pointerup", onPointerUp);
|
|
404
|
+
this.#document.onselectstart = oldSelectStart;
|
|
405
|
+
this.#document.ondragstart = oldDragStart;
|
|
406
|
+
this.#activeCleanup = undefined;
|
|
407
|
+
};
|
|
408
|
+
const onPointerUp = () => {
|
|
409
|
+
cleanup();
|
|
410
|
+
};
|
|
411
|
+
this.#activeCleanup = cleanup;
|
|
412
|
+
this.#document.addEventListener("pointermove", onPointerMove);
|
|
413
|
+
this.#document.addEventListener("pointerup", onPointerUp);
|
|
414
|
+
}
|
|
415
|
+
#setEvents() {
|
|
416
|
+
this.#zone.runOutsideAngular(() => {
|
|
417
|
+
fromEvent(this.#hostElementRef.nativeElement, "pointerdown")
|
|
418
|
+
.pipe(takeUntilDestroyed(this.#destroyRef))
|
|
419
|
+
.subscribe(event => this.#onPointerDown(event));
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowResizeHandlerDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
423
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: WindowResizeHandlerDirective, isStandalone: true, selector: "div[monaWindowResizeHandler]", inputs: { direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: true, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, windowRef: { classPropertyName: "windowRef", publicName: "windowRef", isSignal: true, isRequired: true, transformFunction: null } }, host: { listeners: { "keydown": "onKeydown($event)" } }, ngImport: i0 }); }
|
|
424
|
+
}
|
|
425
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowResizeHandlerDirective, decorators: [{
|
|
426
|
+
type: Directive,
|
|
427
|
+
args: [{
|
|
428
|
+
selector: "div[monaWindowResizeHandler]",
|
|
429
|
+
host: {
|
|
430
|
+
"(keydown)": "onKeydown($event)"
|
|
431
|
+
}
|
|
432
|
+
}]
|
|
433
|
+
}], ctorParameters: () => [], propDecorators: { direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: true }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], windowRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "windowRef", required: true }] }] } });
|
|
434
|
+
|
|
435
|
+
const windowBaseVariants = cva(`
|
|
436
|
+
flex flex-col
|
|
437
|
+
bg-background
|
|
438
|
+
w-full h-full
|
|
439
|
+
`, {
|
|
440
|
+
variants: {
|
|
441
|
+
rounded: {
|
|
442
|
+
none: "rounded-none",
|
|
443
|
+
small: "rounded-sm",
|
|
444
|
+
medium: "rounded-md",
|
|
445
|
+
large: "rounded-lg"
|
|
446
|
+
}
|
|
447
|
+
},
|
|
448
|
+
defaultVariants: {
|
|
449
|
+
rounded: "medium"
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
const windowContentContainerVariants = cva(`
|
|
453
|
+
flex flex-col
|
|
454
|
+
relative w-full h-full
|
|
455
|
+
border border-border
|
|
456
|
+
shadow-sm
|
|
457
|
+
`, {
|
|
458
|
+
variants: {
|
|
459
|
+
rounded: {
|
|
460
|
+
none: "rounded-none",
|
|
461
|
+
small: "rounded-sm",
|
|
462
|
+
medium: "rounded-md",
|
|
463
|
+
large: "rounded-lg"
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
const windowContentVariants = cva(`
|
|
468
|
+
flex-1 overflow-auto
|
|
469
|
+
`);
|
|
470
|
+
const windowResizerVariants = cva(`
|
|
471
|
+
absolute flex
|
|
472
|
+
`, {
|
|
473
|
+
variants: {
|
|
474
|
+
position: {
|
|
475
|
+
east: "top-0 bottom-0 -right-0.5 w-2 cursor-ew-resize",
|
|
476
|
+
north: "left-0 right-0 -top-0.5 h-2 cursor-ns-resize",
|
|
477
|
+
south: "left-0 right-0 -bottom-0.5 h-2 cursor-ns-resize",
|
|
478
|
+
west: "top-0 bottom-0 -left-0.5 w-2 cursor-ew-resize",
|
|
479
|
+
northeast: "-top-0.5 -right-0.5 w-2 h-2 cursor-nesw-resize",
|
|
480
|
+
northwest: "-top-0.5 -left-0.5 w-2 h-2 cursor-nwse-resize",
|
|
481
|
+
southeast: "-bottom-0.5 -right-0.5 w-2 h-2 cursor-nwse-resize",
|
|
482
|
+
southwest: "-bottom-0.5 -left-0.5 w-2 h-2 cursor-nesw-resize"
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
const windowTitleBarActionVariants = cva(`
|
|
487
|
+
flex items-center space-evenly
|
|
488
|
+
`);
|
|
489
|
+
const windowTitleBarVariants = cva(`
|
|
490
|
+
flex items-center justify-start
|
|
491
|
+
px-2 py-1 text-sm overflow-hidden
|
|
492
|
+
border-b border-border
|
|
493
|
+
`, {
|
|
494
|
+
variants: {
|
|
495
|
+
look: {
|
|
496
|
+
default: "bg-secondary text-foreground",
|
|
497
|
+
primary: "bg-primary text-primary-foreground"
|
|
498
|
+
},
|
|
499
|
+
rounded: {
|
|
500
|
+
none: "rounded-ss-none rounded-se-none",
|
|
501
|
+
small: "rounded-ss-sm rounded-se-sm",
|
|
502
|
+
medium: "rounded-ss-md rounded-se-md",
|
|
503
|
+
large: "rounded-ss-lg rounded-se-lg"
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
const windowTitleContainerVariants = cva(`
|
|
508
|
+
flex items-center flex-1
|
|
509
|
+
h-full cursor-default select-none
|
|
510
|
+
overflow-hidden text-ellipsis
|
|
511
|
+
`);
|
|
512
|
+
const windowTitleVariants = cva(`
|
|
513
|
+
font-semibold
|
|
514
|
+
overflow-hidden text-ellipsis whitespace-nowrap
|
|
515
|
+
`, {
|
|
516
|
+
variants: {
|
|
517
|
+
look: {
|
|
518
|
+
default: "text-foreground",
|
|
519
|
+
primary: "text-primary-foreground"
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
const windowBaseThemeVariants = (theme) => {
|
|
525
|
+
switch (theme) {
|
|
526
|
+
case "mona":
|
|
527
|
+
return windowBaseVariants;
|
|
528
|
+
default:
|
|
529
|
+
return windowBaseVariants;
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
const windowContentContainerThemeVariants = (theme) => {
|
|
533
|
+
switch (theme) {
|
|
534
|
+
case "mona":
|
|
535
|
+
return windowContentContainerVariants;
|
|
536
|
+
default:
|
|
537
|
+
return windowContentContainerVariants;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
const windowContentThemeVariants = (theme) => {
|
|
541
|
+
switch (theme) {
|
|
542
|
+
case "mona":
|
|
543
|
+
return windowContentVariants;
|
|
544
|
+
default:
|
|
545
|
+
return windowContentVariants;
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
const windowResizerThemeVariants = (theme) => {
|
|
549
|
+
switch (theme) {
|
|
550
|
+
case "mona":
|
|
551
|
+
return windowResizerVariants;
|
|
552
|
+
default:
|
|
553
|
+
return windowResizerVariants;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
const windowTitleBarActionThemeVariants = (theme) => {
|
|
557
|
+
switch (theme) {
|
|
558
|
+
case "mona":
|
|
559
|
+
return windowTitleBarActionVariants;
|
|
560
|
+
default:
|
|
561
|
+
return windowTitleBarActionVariants;
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
const windowTitleBarThemeVariants = (theme) => {
|
|
565
|
+
switch (theme) {
|
|
566
|
+
case "mona":
|
|
567
|
+
return windowTitleBarVariants;
|
|
568
|
+
default:
|
|
569
|
+
return windowTitleBarVariants;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
const windowTitleContainerThemeVariants = (theme) => {
|
|
573
|
+
switch (theme) {
|
|
574
|
+
case "mona":
|
|
575
|
+
return windowTitleContainerVariants;
|
|
576
|
+
default:
|
|
577
|
+
return windowTitleContainerVariants;
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const windowTitleThemeVariants = (theme) => {
|
|
581
|
+
switch (theme) {
|
|
582
|
+
case "mona":
|
|
583
|
+
return windowTitleVariants;
|
|
584
|
+
default:
|
|
585
|
+
return windowTitleVariants;
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
class ResizePositionPipe {
|
|
590
|
+
#themeService = inject(ThemeService);
|
|
591
|
+
transform(position) {
|
|
592
|
+
if (!position) {
|
|
593
|
+
return null;
|
|
594
|
+
}
|
|
595
|
+
const theme = this.#themeService.theme();
|
|
596
|
+
return windowResizerThemeVariants(theme)({ position });
|
|
597
|
+
}
|
|
598
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ResizePositionPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
599
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: ResizePositionPipe, isStandalone: true, name: "monaResizePosition" }); }
|
|
600
|
+
}
|
|
601
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ResizePositionPipe, decorators: [{
|
|
602
|
+
type: Pipe,
|
|
603
|
+
args: [{
|
|
604
|
+
name: "monaResizePosition"
|
|
605
|
+
}]
|
|
606
|
+
}] });
|
|
607
|
+
|
|
608
|
+
class WindowContentComponent {
|
|
609
|
+
#appRef;
|
|
610
|
+
#document;
|
|
611
|
+
#hostElementRef;
|
|
612
|
+
#injector;
|
|
613
|
+
#sizeBeforeMaximize;
|
|
614
|
+
#sizeBeforeMinimize;
|
|
615
|
+
#themeService;
|
|
616
|
+
#trapFocus;
|
|
617
|
+
#viewContainerRef;
|
|
618
|
+
constructor() {
|
|
619
|
+
this.#appRef = inject(ApplicationRef);
|
|
620
|
+
this.#document = inject(DOCUMENT);
|
|
621
|
+
this.#hostElementRef = inject(ElementRef);
|
|
622
|
+
this.#injector = inject(Injector);
|
|
623
|
+
this.#sizeBeforeMaximize = signal({ width: 0, height: 0, top: 0, left: 0 }, /* @ts-ignore */
|
|
624
|
+
...(ngDevMode ? [{ debugName: "#sizeBeforeMaximize" }] : /* istanbul ignore next */ []));
|
|
625
|
+
this.#sizeBeforeMinimize = signal(0, /* @ts-ignore */
|
|
626
|
+
...(ngDevMode ? [{ debugName: "#sizeBeforeMinimize" }] : /* istanbul ignore next */ []));
|
|
627
|
+
this.#themeService = inject(ThemeService);
|
|
628
|
+
this.#trapFocus = inject(CdkTrapFocus);
|
|
629
|
+
this.#viewContainerRef = inject(ViewContainerRef);
|
|
630
|
+
this.baseClass = computed(() => {
|
|
631
|
+
const theme = this.#themeService.theme();
|
|
632
|
+
const rounded = this.windowData.rounded;
|
|
633
|
+
return windowBaseThemeVariants(theme)({ rounded });
|
|
634
|
+
}, /* @ts-ignore */
|
|
635
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
636
|
+
this.componentAnchor = viewChild.required("componentAnchor", { ...(ngDevMode ? { debugName: "componentAnchor" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
|
|
637
|
+
this.contentClass = computed(() => {
|
|
638
|
+
const theme = this.#themeService.theme();
|
|
639
|
+
return windowContentThemeVariants(theme)();
|
|
640
|
+
}, /* @ts-ignore */
|
|
641
|
+
...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
|
|
642
|
+
this.contentContainerClass = computed(() => {
|
|
643
|
+
const theme = this.#themeService.theme();
|
|
644
|
+
const rounded = this.windowData.rounded;
|
|
645
|
+
return windowContentContainerThemeVariants(theme)({ rounded });
|
|
646
|
+
}, /* @ts-ignore */
|
|
647
|
+
...(ngDevMode ? [{ debugName: "contentContainerClass" }] : /* istanbul ignore next */ []));
|
|
648
|
+
this.contentTemplate = computed(() => {
|
|
649
|
+
const content = this.windowData.content;
|
|
650
|
+
return content instanceof TemplateRef ? content : null;
|
|
651
|
+
}, /* @ts-ignore */
|
|
652
|
+
...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
653
|
+
this.contentType = signal("template", /* @ts-ignore */
|
|
654
|
+
...(ngDevMode ? [{ debugName: "contentType" }] : /* istanbul ignore next */ []));
|
|
655
|
+
this.headerId = createElementControlId();
|
|
656
|
+
this.maximizeIcon = computed(() => {
|
|
657
|
+
return this.maximized() && !this.minimized() ? LucideMinimize : LucideMaximize;
|
|
658
|
+
}, /* @ts-ignore */
|
|
659
|
+
...(ngDevMode ? [{ debugName: "maximizeIcon" }] : /* istanbul ignore next */ []));
|
|
660
|
+
this.maximized = signal(false, /* @ts-ignore */
|
|
661
|
+
...(ngDevMode ? [{ debugName: "maximized" }] : /* istanbul ignore next */ []));
|
|
662
|
+
this.minimized = signal(false, /* @ts-ignore */
|
|
663
|
+
...(ngDevMode ? [{ debugName: "minimized" }] : /* istanbul ignore next */ []));
|
|
664
|
+
this.titleBarActionClass = computed(() => {
|
|
665
|
+
const theme = this.#themeService.theme();
|
|
666
|
+
return windowTitleBarActionThemeVariants(theme)();
|
|
667
|
+
}, /* @ts-ignore */
|
|
668
|
+
...(ngDevMode ? [{ debugName: "titleBarActionClass" }] : /* istanbul ignore next */ []));
|
|
669
|
+
this.titleBarClass = computed(() => {
|
|
670
|
+
const theme = this.#themeService.theme();
|
|
671
|
+
const look = this.windowData.look;
|
|
672
|
+
const rounded = this.windowData.rounded;
|
|
673
|
+
return windowTitleBarThemeVariants(theme)({ look, rounded });
|
|
674
|
+
}, /* @ts-ignore */
|
|
675
|
+
...(ngDevMode ? [{ debugName: "titleBarClass" }] : /* istanbul ignore next */ []));
|
|
676
|
+
this.titleClass = computed(() => {
|
|
677
|
+
const theme = this.#themeService.theme();
|
|
678
|
+
const look = this.windowData.look;
|
|
679
|
+
return windowTitleThemeVariants(theme)({ look });
|
|
680
|
+
}, /* @ts-ignore */
|
|
681
|
+
...(ngDevMode ? [{ debugName: "titleClass" }] : /* istanbul ignore next */ []));
|
|
682
|
+
this.titleContainerClass = computed(() => {
|
|
683
|
+
const theme = this.#themeService.theme();
|
|
684
|
+
return windowTitleContainerThemeVariants(theme)();
|
|
685
|
+
}, /* @ts-ignore */
|
|
686
|
+
...(ngDevMode ? [{ debugName: "titleContainerClass" }] : /* istanbul ignore next */ []));
|
|
687
|
+
this.windowData = inject(PopupDataInjectionToken);
|
|
688
|
+
this.#trapFocus.autoCapture = true;
|
|
689
|
+
this.#trapFocus.enabled = this.windowData.modal ?? false;
|
|
690
|
+
if (this.windowData.content instanceof TemplateRef) {
|
|
691
|
+
this.contentType.set("template");
|
|
692
|
+
}
|
|
693
|
+
else if (this.windowData.content) {
|
|
694
|
+
this.contentType.set("component");
|
|
695
|
+
this.componentRef = createComponent(this.windowData.content, {
|
|
696
|
+
environmentInjector: this.#appRef.injector,
|
|
697
|
+
elementInjector: this.#injector
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
afterNextRender({
|
|
701
|
+
read: () => {
|
|
702
|
+
this.#createView();
|
|
703
|
+
this.focusElement();
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
onCloseClick(event) {
|
|
708
|
+
this.closeWindow(event);
|
|
709
|
+
}
|
|
710
|
+
onMaximizeClick() {
|
|
711
|
+
const innerWidth = this.#document.defaultView?.innerWidth;
|
|
712
|
+
const innerHeight = this.#document.defaultView?.innerHeight;
|
|
713
|
+
if (this.minimized()) {
|
|
714
|
+
this.minimized.set(false);
|
|
715
|
+
this.windowData.windowReference.resize({
|
|
716
|
+
width: this.maximized() ? innerWidth : this.#sizeBeforeMaximize().width,
|
|
717
|
+
height: this.maximized() ? innerHeight : this.#sizeBeforeMaximize().height,
|
|
718
|
+
center: false
|
|
719
|
+
});
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (this.maximized()) {
|
|
723
|
+
this.maximized.set(false);
|
|
724
|
+
this.windowData.windowReference.resize({
|
|
725
|
+
width: this.#sizeBeforeMaximize().width,
|
|
726
|
+
height: this.#sizeBeforeMaximize().height
|
|
727
|
+
});
|
|
728
|
+
this.windowData.windowReference.move({
|
|
729
|
+
top: this.#sizeBeforeMaximize().top,
|
|
730
|
+
left: this.#sizeBeforeMaximize().left
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
else {
|
|
734
|
+
const element = this.windowData.windowReference.element;
|
|
735
|
+
this.#sizeBeforeMaximize.set({
|
|
736
|
+
width: this.windowData.windowReference.width,
|
|
737
|
+
height: this.windowData.windowReference.height,
|
|
738
|
+
top: element.offsetTop,
|
|
739
|
+
left: element.offsetLeft
|
|
740
|
+
});
|
|
741
|
+
this.maximized.set(true);
|
|
742
|
+
this.windowData.windowReference.resize({
|
|
743
|
+
width: innerWidth,
|
|
744
|
+
height: innerHeight
|
|
745
|
+
});
|
|
746
|
+
this.windowData.windowReference.move({ top: 0, left: 0 });
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
onMinimizeClick() {
|
|
750
|
+
if (this.minimized()) {
|
|
751
|
+
this.minimized.set(false);
|
|
752
|
+
this.windowData.windowReference.resize({
|
|
753
|
+
width: this.windowData.windowReference.width,
|
|
754
|
+
height: this.#sizeBeforeMinimize()
|
|
755
|
+
});
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
this.#sizeBeforeMinimize.set(this.windowData.windowReference.height);
|
|
759
|
+
this.minimized.set(true);
|
|
760
|
+
this.windowData.windowReference.resize({
|
|
761
|
+
width: this.windowData.windowReference.width,
|
|
762
|
+
height: undefined
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
closeWindow(event) {
|
|
767
|
+
const closeEvent = new PopupCloseEvent({ event, via: PopupCloseSource.CloseButton, originalEvent: event });
|
|
768
|
+
if (this.windowData.preventClose && this.windowData.preventClose(closeEvent)) {
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this.windowData.windowReference.close(closeEvent);
|
|
772
|
+
}
|
|
773
|
+
focusElement() {
|
|
774
|
+
const element = this.windowData.focusedElement;
|
|
775
|
+
if (!element) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const windowElement = this.#hostElementRef.nativeElement;
|
|
779
|
+
focusElement(windowElement, element);
|
|
780
|
+
}
|
|
781
|
+
#createView() {
|
|
782
|
+
if (this.contentType() === "component" && this.componentAnchor() && this.componentRef) {
|
|
783
|
+
const index = this.#viewContainerRef.indexOf(this.componentRef.hostView);
|
|
784
|
+
if (index !== -1) {
|
|
785
|
+
this.#viewContainerRef.detach(index);
|
|
786
|
+
}
|
|
787
|
+
this.componentAnchor().insert(this.componentRef.hostView, 0);
|
|
788
|
+
this.componentRef.changeDetectorRef.detectChanges();
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
792
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: WindowContentComponent, isStandalone: true, selector: "mona-window-content", host: { attributes: { "role": "dialog" }, properties: { "class": "baseClass()", "attr.aria-labelledby": "headerId", "attr.aria-modal": "windowData.modal ?? false" } }, viewQueries: [{ propertyName: "componentAnchor", first: true, predicate: ["componentAnchor"], descendants: true, read: ViewContainerRef, isSignal: true }], hostDirectives: [{ directive: i1.CdkTrapFocus }], ngImport: i0, template: "<div [class]=\"contentContainerClass()\">\r\n <div\r\n [class]=\"titleBarClass()\"\r\n monaWindowDragHandler\r\n (dblclick)=\"onMaximizeClick()\"\r\n [draggable]=\"windowData.draggable\"\r\n [windowRef]=\"windowData.windowReference\"\r\n [attr.tabindex]=\"windowData.draggable ? 0 : null\"\r\n [attr.aria-label]=\"windowData.draggable ? 'Move window. Use arrow keys to move.' : null\">\r\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\r\n @if (windowData.titleTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"windowData.titleTemplate\"></ng-container>\r\n } @else {\r\n <span [class]=\"titleClass()\">{{ windowData.title ?? \"\" }}</span>\r\n }\r\n </div>\r\n <div [class]=\"titleBarActionClass()\">\r\n @if (windowData.actionTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"windowData.actionTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: windowData.windowReference.windowRef }\">\r\n </ng-container>\r\n }\r\n @let maximizeTitle = maximized() || minimized() ? \"Restore\" : \"Maximize\";\r\n @if (windowData.minimizable && !minimized()) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n [title]=\"'Minimize'\"\r\n aria-label=\"Minimize\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onMinimizeClick()\">\r\n <svg lucideMinus [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n @if (windowData.maximizable) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n [title]=\"maximizeTitle\"\r\n [attr.aria-label]=\"maximizeTitle\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onMaximizeClick()\">\r\n <svg [lucideIcon]=\"maximizeIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n @if (windowData.closable) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n title=\"Close\"\r\n aria-label=\"Close window\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onCloseClick($event)\">\r\n <svg lucideX [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n @if (!minimized()) {\r\n <div [class]=\"contentClass()\">\r\n @switch (contentType()) {\r\n @case (\"template\") {\r\n <ng-container [ngTemplateOutlet]=\"contentTemplate()!\"></ng-container>\r\n }\r\n @case (\"component\") {\r\n <ng-container #componentAnchor></ng-container>\r\n }\r\n }\r\n </div>\r\n @if (windowData.footerTemplate) {\r\n <div>\r\n <ng-container [ngTemplateOutlet]=\"windowData.footerTemplate\"></ng-container>\r\n </div>\r\n }\r\n }\r\n @if (windowData.resizable && !maximized()) {\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"north\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top. Use arrow keys to resize.\"\r\n [class]=\"'north' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"south\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom. Use arrow keys to resize.\"\r\n [class]=\"'south' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"east\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the right. Use arrow keys to resize.\"\r\n [class]=\"'east' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"west\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the left. Use arrow keys to resize.\"\r\n [class]=\"'west' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"northeast\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top-right corner. Use arrow keys to resize.\"\r\n [class]=\"'northeast' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"northwest\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top-left corner. Use arrow keys to resize.\"\r\n [class]=\"'northwest' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"southeast\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom-right corner. Use arrow keys to resize.\"\r\n [class]=\"'southeast' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"southwest\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom-left corner. Use arrow keys to resize.\"\r\n [class]=\"'southwest' | monaResizePosition\"></div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "directive", type: WindowDragHandlerDirective, selector: "div[monaWindowDragHandler]", inputs: ["draggable", "windowRef"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "class"], outputs: ["disabledChange", "loadingChange", "lookChange", "selectedChange"] }, { kind: "directive", type: WindowResizeHandlerDirective, selector: "div[monaWindowResizeHandler]", inputs: ["direction", "maxHeight", "maxWidth", "minHeight", "minWidth", "windowRef"] }, { kind: "component", type: LucideMinus, selector: "svg[lucideMinus]" }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }, { kind: "pipe", type: ResizePositionPipe, name: "monaResizePosition" }] }); }
|
|
793
|
+
}
|
|
794
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowContentComponent, decorators: [{
|
|
795
|
+
type: Component,
|
|
796
|
+
args: [{ selector: "mona-window-content", imports: [
|
|
797
|
+
WindowDragHandlerDirective,
|
|
798
|
+
NgTemplateOutlet,
|
|
799
|
+
ButtonDirective,
|
|
800
|
+
WindowResizeHandlerDirective,
|
|
801
|
+
ResizePositionPipe,
|
|
802
|
+
LucideMinus,
|
|
803
|
+
LucideDynamicIcon,
|
|
804
|
+
LucideX
|
|
805
|
+
], host: {
|
|
806
|
+
"[class]": "baseClass()",
|
|
807
|
+
"[attr.aria-labelledby]": "headerId",
|
|
808
|
+
"[attr.aria-modal]": "windowData.modal ?? false",
|
|
809
|
+
role: "dialog"
|
|
810
|
+
}, hostDirectives: [CdkTrapFocus], template: "<div [class]=\"contentContainerClass()\">\r\n <div\r\n [class]=\"titleBarClass()\"\r\n monaWindowDragHandler\r\n (dblclick)=\"onMaximizeClick()\"\r\n [draggable]=\"windowData.draggable\"\r\n [windowRef]=\"windowData.windowReference\"\r\n [attr.tabindex]=\"windowData.draggable ? 0 : null\"\r\n [attr.aria-label]=\"windowData.draggable ? 'Move window. Use arrow keys to move.' : null\">\r\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\r\n @if (windowData.titleTemplate) {\r\n <ng-container [ngTemplateOutlet]=\"windowData.titleTemplate\"></ng-container>\r\n } @else {\r\n <span [class]=\"titleClass()\">{{ windowData.title ?? \"\" }}</span>\r\n }\r\n </div>\r\n <div [class]=\"titleBarActionClass()\">\r\n @if (windowData.actionTemplate) {\r\n <ng-container\r\n [ngTemplateOutlet]=\"windowData.actionTemplate\"\r\n [ngTemplateOutletContext]=\"{ $implicit: windowData.windowReference.windowRef }\">\r\n </ng-container>\r\n }\r\n @let maximizeTitle = maximized() || minimized() ? \"Restore\" : \"Maximize\";\r\n @if (windowData.minimizable && !minimized()) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n [title]=\"'Minimize'\"\r\n aria-label=\"Minimize\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onMinimizeClick()\">\r\n <svg lucideMinus [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n @if (windowData.maximizable) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n [title]=\"maximizeTitle\"\r\n [attr.aria-label]=\"maximizeTitle\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onMaximizeClick()\">\r\n <svg [lucideIcon]=\"maximizeIcon()\" [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n @if (windowData.closable) {\r\n <button\r\n monaButton\r\n look=\"ghost\"\r\n size=\"small\"\r\n type=\"button\"\r\n [iconOnly]=\"true\"\r\n [rounded]=\"windowData.rounded\"\r\n title=\"Close\"\r\n aria-label=\"Close window\"\r\n (dblclick)=\"$event.stopPropagation()\"\r\n (click)=\"onCloseClick($event)\">\r\n <svg lucideX [size]=\"16\" aria-hidden=\"true\"></svg>\r\n </button>\r\n }\r\n </div>\r\n </div>\r\n @if (!minimized()) {\r\n <div [class]=\"contentClass()\">\r\n @switch (contentType()) {\r\n @case (\"template\") {\r\n <ng-container [ngTemplateOutlet]=\"contentTemplate()!\"></ng-container>\r\n }\r\n @case (\"component\") {\r\n <ng-container #componentAnchor></ng-container>\r\n }\r\n }\r\n </div>\r\n @if (windowData.footerTemplate) {\r\n <div>\r\n <ng-container [ngTemplateOutlet]=\"windowData.footerTemplate\"></ng-container>\r\n </div>\r\n }\r\n }\r\n @if (windowData.resizable && !maximized()) {\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"north\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top. Use arrow keys to resize.\"\r\n [class]=\"'north' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"south\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom. Use arrow keys to resize.\"\r\n [class]=\"'south' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"east\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the right. Use arrow keys to resize.\"\r\n [class]=\"'east' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"west\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the left. Use arrow keys to resize.\"\r\n [class]=\"'west' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"northeast\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top-right corner. Use arrow keys to resize.\"\r\n [class]=\"'northeast' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"northwest\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the top-left corner. Use arrow keys to resize.\"\r\n [class]=\"'northwest' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"southeast\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom-right corner. Use arrow keys to resize.\"\r\n [class]=\"'southeast' | monaResizePosition\"></div>\r\n <div\r\n monaWindowResizeHandler\r\n [minWidth]=\"windowData.minWidth\"\r\n [minHeight]=\"windowData.minHeight\"\r\n [maxWidth]=\"windowData.maxWidth\"\r\n [maxHeight]=\"windowData.maxHeight\"\r\n [windowRef]=\"windowData.windowReference\"\r\n direction=\"southwest\"\r\n tabindex=\"0\"\r\n aria-label=\"Resize window from the bottom-left corner. Use arrow keys to resize.\"\r\n [class]=\"'southwest' | monaResizePosition\"></div>\r\n }\r\n</div>\r\n" }]
|
|
811
|
+
}], ctorParameters: () => [], propDecorators: { componentAnchor: [{ type: i0.ViewChild, args: ["componentAnchor", { ...{
|
|
812
|
+
read: ViewContainerRef
|
|
813
|
+
}, isSignal: true }] }] } });
|
|
814
|
+
|
|
815
|
+
class WindowRef {
|
|
816
|
+
#options;
|
|
817
|
+
constructor(options) {
|
|
818
|
+
this.#options = options;
|
|
819
|
+
}
|
|
820
|
+
center() {
|
|
821
|
+
this.#options.center();
|
|
822
|
+
}
|
|
823
|
+
close(result) {
|
|
824
|
+
this.#options.close(result);
|
|
825
|
+
}
|
|
826
|
+
closeWithDelay(delay, result) {
|
|
827
|
+
this.#options.closeWithDelay(delay, result);
|
|
828
|
+
}
|
|
829
|
+
move(params) {
|
|
830
|
+
this.#options.move(params);
|
|
831
|
+
}
|
|
832
|
+
resize(params) {
|
|
833
|
+
this.#options.resize(params);
|
|
834
|
+
}
|
|
835
|
+
get close$() {
|
|
836
|
+
return this.#options.close$;
|
|
837
|
+
}
|
|
838
|
+
get closed$() {
|
|
839
|
+
return this.#options.closed$;
|
|
840
|
+
}
|
|
841
|
+
get component() {
|
|
842
|
+
return this.#options.component;
|
|
843
|
+
}
|
|
844
|
+
get drag$() {
|
|
845
|
+
return this.#options.drag$;
|
|
846
|
+
}
|
|
847
|
+
get dragEnd$() {
|
|
848
|
+
return this.#options.dragEnd$;
|
|
849
|
+
}
|
|
850
|
+
get dragStart$() {
|
|
851
|
+
return this.#options.dragStart$;
|
|
852
|
+
}
|
|
853
|
+
get element() {
|
|
854
|
+
return this.#options.element;
|
|
855
|
+
}
|
|
856
|
+
get height() {
|
|
857
|
+
return this.#options.height;
|
|
858
|
+
}
|
|
859
|
+
get popupRef() {
|
|
860
|
+
return this.#options.popupRef;
|
|
861
|
+
}
|
|
862
|
+
get resize$() {
|
|
863
|
+
return this.#options.resize$;
|
|
864
|
+
}
|
|
865
|
+
get width() {
|
|
866
|
+
return this.#options.width;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* @internal - used by WindowService. Do not export.
|
|
872
|
+
*/
|
|
873
|
+
class WindowReference {
|
|
874
|
+
#windowRef;
|
|
875
|
+
constructor(options, document) {
|
|
876
|
+
this.options = options;
|
|
877
|
+
this.document = document;
|
|
878
|
+
this.move$$ = new Subject();
|
|
879
|
+
this.moveEnd$$ = new Subject();
|
|
880
|
+
this.moveStart$$ = new Subject();
|
|
881
|
+
this.resize$$ = new Subject();
|
|
882
|
+
this.#windowRef = new WindowRef(this);
|
|
883
|
+
}
|
|
884
|
+
center() {
|
|
885
|
+
const element = this.#popupRefOrThrow.overlayRef.overlayElement;
|
|
886
|
+
const width = element.getBoundingClientRect().width;
|
|
887
|
+
const height = element.getBoundingClientRect().height;
|
|
888
|
+
const left = (this.document.defaultView?.innerWidth || DefaultMaxWindowWidth - width) / 2;
|
|
889
|
+
const top = (this.document.defaultView?.innerHeight || DefaultMaxWindowHeight - height) / 2;
|
|
890
|
+
element.style.left = `${left}px`;
|
|
891
|
+
element.style.top = `${top}px`;
|
|
892
|
+
}
|
|
893
|
+
close(result) {
|
|
894
|
+
const event = result instanceof PopupCloseEvent
|
|
895
|
+
? result
|
|
896
|
+
: new PopupCloseEvent({ result, via: PopupCloseSource.Programmatic });
|
|
897
|
+
this.#popupRefOrThrow.close(event);
|
|
898
|
+
}
|
|
899
|
+
closeWithDelay(delay, result) {
|
|
900
|
+
asapScheduler.schedule(() => this.close(result), delay);
|
|
901
|
+
}
|
|
902
|
+
initializePopupRef(popupRef) {
|
|
903
|
+
this.options.popupRef = popupRef;
|
|
904
|
+
}
|
|
905
|
+
move(params) {
|
|
906
|
+
const element = this.#popupRefOrThrow.overlayRef.overlayElement;
|
|
907
|
+
const top = params.top != null ? `${params.top}px` : ``;
|
|
908
|
+
const left = params.left != null ? `${params.left}px` : ``;
|
|
909
|
+
element.style.top = top;
|
|
910
|
+
element.style.left = left;
|
|
911
|
+
}
|
|
912
|
+
resize(params) {
|
|
913
|
+
const element = this.#popupRefOrThrow.overlayRef.overlayElement;
|
|
914
|
+
const width = params.width ? `${params.width}px` : ``;
|
|
915
|
+
const height = params.height ? `${params.height}px` : ``;
|
|
916
|
+
element.style.width = width;
|
|
917
|
+
element.style.height = height;
|
|
918
|
+
if (params.center) {
|
|
919
|
+
asapScheduler.schedule(() => this.center());
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
get close$() {
|
|
923
|
+
return this.#popupRefOrThrow.beforeClose.pipe(map(event => event));
|
|
924
|
+
}
|
|
925
|
+
get closed$() {
|
|
926
|
+
return this.#popupRefOrThrow.closed.pipe(map(() => undefined));
|
|
927
|
+
}
|
|
928
|
+
get component() {
|
|
929
|
+
// The type of component is ComponentRef<WindowContentComponent>. It is set as unknown to avoid circular dependency.
|
|
930
|
+
const popupComponent = this.popupRef.component;
|
|
931
|
+
if (!popupComponent) {
|
|
932
|
+
return null;
|
|
933
|
+
}
|
|
934
|
+
return popupComponent.instance.componentRef ?? null;
|
|
935
|
+
}
|
|
936
|
+
get drag$() {
|
|
937
|
+
return this.move$$;
|
|
938
|
+
}
|
|
939
|
+
get dragEnd$() {
|
|
940
|
+
return this.moveEnd$$;
|
|
941
|
+
}
|
|
942
|
+
get dragStart$() {
|
|
943
|
+
return this.moveStart$$;
|
|
944
|
+
}
|
|
945
|
+
get element() {
|
|
946
|
+
return this.#popupRefOrThrow.overlayRef.overlayElement;
|
|
947
|
+
}
|
|
948
|
+
get height() {
|
|
949
|
+
return this.element.offsetHeight;
|
|
950
|
+
}
|
|
951
|
+
get popupRef() {
|
|
952
|
+
return this.#popupRefOrThrow;
|
|
953
|
+
}
|
|
954
|
+
get resize$() {
|
|
955
|
+
return this.resize$$;
|
|
956
|
+
}
|
|
957
|
+
get width() {
|
|
958
|
+
return this.element.offsetWidth;
|
|
959
|
+
}
|
|
960
|
+
get windowRef() {
|
|
961
|
+
return this.#windowRef;
|
|
962
|
+
}
|
|
963
|
+
get #popupRefOrThrow() {
|
|
964
|
+
if (!this.options.popupRef) {
|
|
965
|
+
throw new Error("WindowReference: popupRef has not been initialized.");
|
|
966
|
+
}
|
|
967
|
+
return this.options.popupRef;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
const createWindowInjectorData = (settings) => {
|
|
972
|
+
return {
|
|
973
|
+
actionTemplate: settings.actionTemplate,
|
|
974
|
+
closable: settings.closable ?? true,
|
|
975
|
+
closeOnEscape: settings.closeOnEscape ?? true,
|
|
976
|
+
content: settings.content,
|
|
977
|
+
draggable: settings.draggable ?? false,
|
|
978
|
+
focusedElement: settings.focusedElement,
|
|
979
|
+
footerTemplate: settings.footerTemplate,
|
|
980
|
+
height: settings.height,
|
|
981
|
+
left: settings.left,
|
|
982
|
+
look: settings.look ?? "default",
|
|
983
|
+
maxHeight: settings.maxHeight,
|
|
984
|
+
maxWidth: settings.maxWidth,
|
|
985
|
+
maximizable: settings.maximizable ?? true,
|
|
986
|
+
minHeight: settings.minHeight ?? 50,
|
|
987
|
+
minWidth: settings.minWidth ?? 50,
|
|
988
|
+
minimizable: settings.minimizable ?? true,
|
|
989
|
+
modal: settings.modal,
|
|
990
|
+
rounded: settings.rounded ?? "medium",
|
|
991
|
+
preventClose: settings.preventClose,
|
|
992
|
+
resizable: settings.resizable ?? false,
|
|
993
|
+
title: typeof settings.title === "string" ? settings.title : undefined,
|
|
994
|
+
titleTemplate: typeof settings.title === "string" ? undefined : settings.title,
|
|
995
|
+
top: settings.top,
|
|
996
|
+
width: settings.width
|
|
997
|
+
};
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
class WindowService {
|
|
1001
|
+
#document = inject(DOCUMENT);
|
|
1002
|
+
#injector = inject(Injector);
|
|
1003
|
+
#popupService = inject(PopupService);
|
|
1004
|
+
open(settings) {
|
|
1005
|
+
const windowReference = new WindowReference({}, this.#document);
|
|
1006
|
+
const injectorData = { ...createWindowInjectorData(settings), windowReference };
|
|
1007
|
+
const popupRef = this.#popupService.create({
|
|
1008
|
+
anchor: this.#document.body,
|
|
1009
|
+
backdropClass: settings.modal
|
|
1010
|
+
? ["fixed", "inset-0", "bg-background/50", "transition-opacity", "z-40", "backdrop-blur-xs"]
|
|
1011
|
+
: "transparent",
|
|
1012
|
+
closeOnBackdropClick: false,
|
|
1013
|
+
closeOnEscape: settings.closeOnEscape ?? true,
|
|
1014
|
+
closeOnOutsideClick: false,
|
|
1015
|
+
content: WindowContentComponent,
|
|
1016
|
+
data: injectorData,
|
|
1017
|
+
hasBackdrop: settings.modal,
|
|
1018
|
+
height: settings.height || "fit-content",
|
|
1019
|
+
maxHeight: settings.maxHeight,
|
|
1020
|
+
maxWidth: settings.maxWidth,
|
|
1021
|
+
minHeight: settings.minHeight,
|
|
1022
|
+
minWidth: settings.minWidth,
|
|
1023
|
+
positionStrategy: "global",
|
|
1024
|
+
preventClose: (event) => {
|
|
1025
|
+
if (settings.preventClose) {
|
|
1026
|
+
return settings.preventClose(event);
|
|
1027
|
+
}
|
|
1028
|
+
return false;
|
|
1029
|
+
},
|
|
1030
|
+
providers: [
|
|
1031
|
+
{
|
|
1032
|
+
provide: WindowRef,
|
|
1033
|
+
useFactory: forwardRef(() => windowReference.windowRef)
|
|
1034
|
+
}
|
|
1035
|
+
],
|
|
1036
|
+
width: settings.width
|
|
1037
|
+
});
|
|
1038
|
+
windowReference.initializePopupRef(popupRef);
|
|
1039
|
+
afterNextRender({
|
|
1040
|
+
read: () => {
|
|
1041
|
+
const element = popupRef.overlayRef.overlayElement;
|
|
1042
|
+
setWindowStyles(element, settings);
|
|
1043
|
+
}
|
|
1044
|
+
}, { injector: this.#injector });
|
|
1045
|
+
return windowReference.windowRef;
|
|
1046
|
+
}
|
|
1047
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1048
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowService, providedIn: "root" }); }
|
|
1049
|
+
}
|
|
1050
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowService, decorators: [{
|
|
1051
|
+
type: Injectable,
|
|
1052
|
+
args: [{
|
|
1053
|
+
providedIn: "root"
|
|
1054
|
+
}]
|
|
1055
|
+
}] });
|
|
1056
|
+
|
|
1057
|
+
class WindowComponent {
|
|
1058
|
+
#destroyRef;
|
|
1059
|
+
#windowService;
|
|
1060
|
+
#windowRef;
|
|
1061
|
+
constructor() {
|
|
1062
|
+
this.#destroyRef = inject(DestroyRef);
|
|
1063
|
+
this.#windowService = inject(WindowService);
|
|
1064
|
+
this.actionTemplate = contentChild(WindowActionTemplateDirective, { ...(ngDevMode ? { debugName: "actionTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
1065
|
+
this.contentTemplate = contentChild(WindowContentTemplateDirective, { ...(ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
1066
|
+
this.footerTemplate = contentChild(WindowFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
1067
|
+
this.titleTemplate = contentChild(WindowTitleTemplateDirective, { ...(ngDevMode ? { debugName: "titleTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
|
|
1068
|
+
/**
|
|
1069
|
+
* @description Sets the visibility of the close button in the window header.
|
|
1070
|
+
* @default true
|
|
1071
|
+
*/
|
|
1072
|
+
this.closable = input(true, /* @ts-ignore */
|
|
1073
|
+
...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
|
|
1074
|
+
/**
|
|
1075
|
+
* @description Emits when the window is about to be closed.
|
|
1076
|
+
*/
|
|
1077
|
+
this.close = output();
|
|
1078
|
+
/**
|
|
1079
|
+
* @description Emitted after the window has fully closed (post-animation). Preventing this event has no effect.
|
|
1080
|
+
*/
|
|
1081
|
+
this.closed = output();
|
|
1082
|
+
/**
|
|
1083
|
+
* @description Sets whether the window should close when the escape key is pressed.
|
|
1084
|
+
* @default true
|
|
1085
|
+
*/
|
|
1086
|
+
this.closeOnEscape = input(true, /* @ts-ignore */
|
|
1087
|
+
...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
|
|
1088
|
+
/**
|
|
1089
|
+
* @description Emits when the window dragging ends.
|
|
1090
|
+
*/
|
|
1091
|
+
this.dragEnd = output();
|
|
1092
|
+
/**
|
|
1093
|
+
* @description Emits when the window dragging starts.
|
|
1094
|
+
*/
|
|
1095
|
+
this.dragStart = output();
|
|
1096
|
+
/**
|
|
1097
|
+
* @description Sets whether the window can be dragged by the user.
|
|
1098
|
+
* @default true
|
|
1099
|
+
*/
|
|
1100
|
+
this.draggable = input(true, /* @ts-ignore */
|
|
1101
|
+
...(ngDevMode ? [{ debugName: "draggable" }] : /* istanbul ignore next */ []));
|
|
1102
|
+
/**
|
|
1103
|
+
* @description Sets the element that should receive focus when the window is opened.
|
|
1104
|
+
* Accepts an element reference or a query selector string.
|
|
1105
|
+
*/
|
|
1106
|
+
this.focusedElement = input(/* @ts-ignore */
|
|
1107
|
+
...(ngDevMode ? [undefined, { debugName: "focusedElement" }] : /* istanbul ignore next */ []));
|
|
1108
|
+
/**
|
|
1109
|
+
* @description Sets the height of the window.
|
|
1110
|
+
*/
|
|
1111
|
+
this.height = model(/* @ts-ignore */
|
|
1112
|
+
...(ngDevMode ? [undefined, { debugName: "height" }] : /* istanbul ignore next */ []));
|
|
1113
|
+
/**
|
|
1114
|
+
* @description Sets the left position of the window.
|
|
1115
|
+
*/
|
|
1116
|
+
this.left = model(/* @ts-ignore */
|
|
1117
|
+
...(ngDevMode ? [undefined, { debugName: "left" }] : /* istanbul ignore next */ []));
|
|
1118
|
+
/**
|
|
1119
|
+
* @description Sets the look of the window.
|
|
1120
|
+
* @default "default"
|
|
1121
|
+
*/
|
|
1122
|
+
this.look = input("default", /* @ts-ignore */
|
|
1123
|
+
...(ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []));
|
|
1124
|
+
/**
|
|
1125
|
+
* @description Sets the maximum height of the window.
|
|
1126
|
+
*/
|
|
1127
|
+
this.maxHeight = input(/* @ts-ignore */
|
|
1128
|
+
...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : /* istanbul ignore next */ []));
|
|
1129
|
+
/**
|
|
1130
|
+
* @description Sets the maximum width of the window.
|
|
1131
|
+
*/
|
|
1132
|
+
this.maxWidth = input(/* @ts-ignore */
|
|
1133
|
+
...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : /* istanbul ignore next */ []));
|
|
1134
|
+
/**
|
|
1135
|
+
* @description Sets whether the user can maximize the window.
|
|
1136
|
+
* @default true
|
|
1137
|
+
*/
|
|
1138
|
+
this.maximizable = input(/* @ts-ignore */
|
|
1139
|
+
...(ngDevMode ? [undefined, { debugName: "maximizable" }] : /* istanbul ignore next */ []));
|
|
1140
|
+
/**
|
|
1141
|
+
* @description Sets the minimum height of the window.
|
|
1142
|
+
*/
|
|
1143
|
+
this.minHeight = input(/* @ts-ignore */
|
|
1144
|
+
...(ngDevMode ? [undefined, { debugName: "minHeight" }] : /* istanbul ignore next */ []));
|
|
1145
|
+
/**
|
|
1146
|
+
* @description Sets the minimum width of the window.
|
|
1147
|
+
*/
|
|
1148
|
+
this.minWidth = input(/* @ts-ignore */
|
|
1149
|
+
...(ngDevMode ? [undefined, { debugName: "minWidth" }] : /* istanbul ignore next */ []));
|
|
1150
|
+
/**
|
|
1151
|
+
* @description Sets whether the user can minimize the window.
|
|
1152
|
+
* @default true
|
|
1153
|
+
*/
|
|
1154
|
+
this.minimizable = input(/* @ts-ignore */
|
|
1155
|
+
...(ngDevMode ? [undefined, { debugName: "minimizable" }] : /* istanbul ignore next */ []));
|
|
1156
|
+
/**
|
|
1157
|
+
* @description Sets whether the window should have an overlay behind it.
|
|
1158
|
+
* @default false
|
|
1159
|
+
*/
|
|
1160
|
+
this.modal = input(/* @ts-ignore */
|
|
1161
|
+
...(ngDevMode ? [undefined, { debugName: "modal" }] : /* istanbul ignore next */ []));
|
|
1162
|
+
/**
|
|
1163
|
+
* @description Sets whether the user can resize the window.
|
|
1164
|
+
* @default false
|
|
1165
|
+
*/
|
|
1166
|
+
this.resizable = input(/* @ts-ignore */
|
|
1167
|
+
...(ngDevMode ? [undefined, { debugName: "resizable" }] : /* istanbul ignore next */ []));
|
|
1168
|
+
/**
|
|
1169
|
+
* @description Sets the border radius of the window.
|
|
1170
|
+
* @default "medium"
|
|
1171
|
+
*/
|
|
1172
|
+
this.rounded = input("medium", /* @ts-ignore */
|
|
1173
|
+
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
1174
|
+
/**
|
|
1175
|
+
* @description Sets the title of the window.
|
|
1176
|
+
*/
|
|
1177
|
+
this.title = input(/* @ts-ignore */
|
|
1178
|
+
...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
|
|
1179
|
+
/**
|
|
1180
|
+
* @description Sets the top position of the window.
|
|
1181
|
+
*/
|
|
1182
|
+
this.top = model(/* @ts-ignore */
|
|
1183
|
+
...(ngDevMode ? [undefined, { debugName: "top" }] : /* istanbul ignore next */ []));
|
|
1184
|
+
/**
|
|
1185
|
+
* @description Sets the width of the window.
|
|
1186
|
+
*/
|
|
1187
|
+
this.width = model(/* @ts-ignore */
|
|
1188
|
+
...(ngDevMode ? [undefined, { debugName: "width" }] : /* istanbul ignore next */ []));
|
|
1189
|
+
effect(() => {
|
|
1190
|
+
const top = this.top();
|
|
1191
|
+
const left = this.left();
|
|
1192
|
+
this.#windowRef?.move({ top, left });
|
|
1193
|
+
});
|
|
1194
|
+
effect(() => {
|
|
1195
|
+
const height = this.height();
|
|
1196
|
+
const width = this.width();
|
|
1197
|
+
const center = untracked(() => this.top() == null && this.left() == null);
|
|
1198
|
+
this.#windowRef?.resize({ height, width, center });
|
|
1199
|
+
});
|
|
1200
|
+
afterNextRender({ read: () => this.#openWindow() });
|
|
1201
|
+
this.#destroyRef.onDestroy(() => this.#windowRef?.close());
|
|
1202
|
+
}
|
|
1203
|
+
closeWindow() {
|
|
1204
|
+
this.#windowRef?.close();
|
|
1205
|
+
}
|
|
1206
|
+
move(position) {
|
|
1207
|
+
if (position.top !== undefined) {
|
|
1208
|
+
this.#windowRef?.move({ top: position.top });
|
|
1209
|
+
}
|
|
1210
|
+
if (position.left !== undefined) {
|
|
1211
|
+
this.#windowRef?.move({ left: position.left });
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
openWindow() {
|
|
1215
|
+
this.#openWindow();
|
|
1216
|
+
}
|
|
1217
|
+
resize(dimensions) {
|
|
1218
|
+
if (dimensions.width !== undefined) {
|
|
1219
|
+
this.#windowRef?.resize({ width: dimensions.width });
|
|
1220
|
+
}
|
|
1221
|
+
if (dimensions.height !== undefined) {
|
|
1222
|
+
this.#windowRef?.resize({ height: dimensions.height });
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
#openWindow() {
|
|
1226
|
+
this.#windowRef = this.#windowService.open({
|
|
1227
|
+
actionTemplate: this.actionTemplate(),
|
|
1228
|
+
closable: this.closable(),
|
|
1229
|
+
closeOnEscape: this.closeOnEscape(),
|
|
1230
|
+
content: this.contentTemplate(),
|
|
1231
|
+
draggable: this.draggable(),
|
|
1232
|
+
focusedElement: this.focusedElement(),
|
|
1233
|
+
footerTemplate: this.footerTemplate(),
|
|
1234
|
+
height: this.height(),
|
|
1235
|
+
left: this.left(),
|
|
1236
|
+
look: this.look(),
|
|
1237
|
+
maxHeight: this.maxHeight(),
|
|
1238
|
+
maxWidth: this.maxWidth(),
|
|
1239
|
+
maximizable: this.maximizable(),
|
|
1240
|
+
minHeight: this.minHeight(),
|
|
1241
|
+
minWidth: this.minWidth(),
|
|
1242
|
+
minimizable: this.minimizable(),
|
|
1243
|
+
modal: this.modal(),
|
|
1244
|
+
resizable: this.resizable(),
|
|
1245
|
+
rounded: this.rounded(),
|
|
1246
|
+
title: this.titleTemplate() ?? this.title(),
|
|
1247
|
+
top: this.top(),
|
|
1248
|
+
width: this.width()
|
|
1249
|
+
});
|
|
1250
|
+
this.#setSubscriptions();
|
|
1251
|
+
}
|
|
1252
|
+
#setCloseSubscription() {
|
|
1253
|
+
if (!this.#windowRef) {
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
this.#windowRef.popupRef.beforeClose.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
|
|
1257
|
+
this.close.emit(event);
|
|
1258
|
+
});
|
|
1259
|
+
this.#windowRef.closed$.pipe(take(1), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1260
|
+
this.closed.emit();
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
#setDragSubscription() {
|
|
1264
|
+
if (!this.#windowRef) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
this.#windowRef.drag$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
|
|
1268
|
+
if (event.left != null) {
|
|
1269
|
+
this.left.set(event.left);
|
|
1270
|
+
}
|
|
1271
|
+
if (event.top != null) {
|
|
1272
|
+
this.top.set(event.top);
|
|
1273
|
+
}
|
|
1274
|
+
});
|
|
1275
|
+
this.#windowRef.dragEnd$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1276
|
+
this.dragEnd.emit();
|
|
1277
|
+
});
|
|
1278
|
+
this.#windowRef.dragStart$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
1279
|
+
this.dragStart.emit();
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
#setResizeSubscription() {
|
|
1283
|
+
if (!this.#windowRef) {
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
this.#windowRef.resize$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
|
|
1287
|
+
if (event.width != null) {
|
|
1288
|
+
this.width.set(event.width);
|
|
1289
|
+
}
|
|
1290
|
+
if (event.height != null) {
|
|
1291
|
+
this.height.set(event.height);
|
|
1292
|
+
}
|
|
1293
|
+
if (event.left != null) {
|
|
1294
|
+
this.left.set(event.left);
|
|
1295
|
+
}
|
|
1296
|
+
if (event.top != null) {
|
|
1297
|
+
this.top.set(event.top);
|
|
1298
|
+
}
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
#setSubscriptions() {
|
|
1302
|
+
this.#setCloseSubscription();
|
|
1303
|
+
this.#setDragSubscription();
|
|
1304
|
+
this.#setResizeSubscription();
|
|
1305
|
+
}
|
|
1306
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1307
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: WindowComponent, isStandalone: true, selector: "mona-window", inputs: { closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, draggable: { classPropertyName: "draggable", publicName: "draggable", isSignal: true, isRequired: false, transformFunction: null }, focusedElement: { classPropertyName: "focusedElement", publicName: "focusedElement", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, left: { classPropertyName: "left", publicName: "left", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, maximizable: { classPropertyName: "maximizable", publicName: "maximizable", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, minimizable: { classPropertyName: "minimizable", publicName: "minimizable", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, resizable: { classPropertyName: "resizable", publicName: "resizable", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, top: { classPropertyName: "top", publicName: "top", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { close: "close", closed: "closed", dragEnd: "dragEnd", dragStart: "dragStart", height: "heightChange", left: "leftChange", top: "topChange", width: "widthChange" }, host: { classAttribute: "hidden" }, queries: [{ propertyName: "actionTemplate", first: true, predicate: WindowActionTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "contentTemplate", first: true, predicate: WindowContentTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "footerTemplate", first: true, predicate: WindowFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "titleTemplate", first: true, predicate: WindowTitleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: ``, isInline: true }); }
|
|
1308
|
+
}
|
|
1309
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: WindowComponent, decorators: [{
|
|
1310
|
+
type: Component,
|
|
1311
|
+
args: [{
|
|
1312
|
+
selector: "mona-window",
|
|
1313
|
+
template: ``,
|
|
1314
|
+
host: {
|
|
1315
|
+
class: "hidden"
|
|
1316
|
+
}
|
|
1317
|
+
}]
|
|
1318
|
+
}], ctorParameters: () => [], propDecorators: { actionTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => WindowActionTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => WindowContentTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], footerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => WindowFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], titleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => WindowTitleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], close: [{ type: i0.Output, args: ["close"] }], closed: [{ type: i0.Output, args: ["closed"] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], dragEnd: [{ type: i0.Output, args: ["dragEnd"] }], dragStart: [{ type: i0.Output, args: ["dragStart"] }], draggable: [{ type: i0.Input, args: [{ isSignal: true, alias: "draggable", required: false }] }], focusedElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusedElement", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }, { type: i0.Output, args: ["heightChange"] }], left: [{ type: i0.Input, args: [{ isSignal: true, alias: "left", required: false }] }, { type: i0.Output, args: ["leftChange"] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], maximizable: [{ type: i0.Input, args: [{ isSignal: true, alias: "maximizable", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], minimizable: [{ type: i0.Input, args: [{ isSignal: true, alias: "minimizable", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], resizable: [{ type: i0.Input, args: [{ isSignal: true, alias: "resizable", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], top: [{ type: i0.Input, args: [{ isSignal: true, alias: "top", required: false }] }, { type: i0.Output, args: ["topChange"] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }, { type: i0.Output, args: ["widthChange"] }] } });
|
|
1319
|
+
|
|
1320
|
+
/*
|
|
1321
|
+
* Public API Surface of @nanahoshi/mona-ui/window
|
|
1322
|
+
*/
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Generated bundle index. Do not edit.
|
|
1326
|
+
*/
|
|
1327
|
+
|
|
1328
|
+
export { WindowActionTemplateDirective, WindowComponent, WindowContentTemplateDirective, WindowFooterTemplateDirective, WindowRef, WindowService, WindowTitleTemplateDirective };
|
|
1329
|
+
//# sourceMappingURL=nanahoshi-mona-ui-window.mjs.map
|