@ngutil/layout 0.0.3-dev.6 → 0.0.3-dev.8
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/docking/docking-content.component.d.ts +5 -0
- package/docking/docking-layout.component.d.ts +24 -0
- package/docking/docking-panel.component.d.ts +39 -0
- package/docking/index.d.ts +13 -0
- package/esm2022/docking/docking-content.component.mjs +11 -0
- package/esm2022/docking/docking-layout.component.mjs +264 -0
- package/esm2022/docking/docking-panel.component.mjs +148 -0
- package/esm2022/docking/index.mjs +20 -0
- package/esm2022/index.mjs +4 -2
- package/esm2022/l9/index.mjs +3 -0
- package/esm2022/l9/range.mjs +109 -0
- package/esm2022/l9/state.mjs +29 -0
- package/esm2022/util/dimension-watcher.mjs +84 -0
- package/esm2022/util/dimension.mjs +2 -0
- package/esm2022/util/index.mjs +3 -0
- package/esm2022/util/media-watcher.mjs +29 -0
- package/esm2022/util/rect.mjs +2 -0
- package/fesm2022/ngutil-layout.mjs +667 -8
- package/fesm2022/ngutil-layout.mjs.map +1 -1
- package/index.d.ts +3 -1
- package/l9/index.d.ts +2 -0
- package/l9/range.d.ts +28 -0
- package/l9/state.d.ts +14 -0
- package/package.json +2 -2
- package/util/dimension-watcher.d.ts +4 -0
- package/util/dimension.d.ts +5 -0
- package/util/index.d.ts +4 -0
- package/util/media-watcher.d.ts +5 -0
- package/util/rect.d.ts +5 -0
- package/esm2022/lib/layout/layout.component.mjs +0 -12
- package/lib/layout/layout.component.d.ts +0 -5
|
@@ -1,19 +1,678 @@
|
|
|
1
|
-
import { CommonModule } from '@angular/common';
|
|
2
1
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { Component } from '@angular/core';
|
|
2
|
+
import { inject, NgZone, Component, ElementRef, Input, Output, ChangeDetectionStrategy, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
|
3
|
+
import { Observable, distinctUntilChanged, shareReplay, BehaviorSubject, map, combineLatest, switchMap, of, Subject, startWith } from 'rxjs';
|
|
4
|
+
import { NumberWithUnit, Destructible, coerceBoolAttr, FastDOM } from '@ngutil/common';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const WATCHES = {};
|
|
7
|
+
/**
|
|
8
|
+
* watchMedia("(display-mode: standalone)")
|
|
9
|
+
*/
|
|
10
|
+
function watchMedia(expr) {
|
|
11
|
+
const existing = WATCHES[expr];
|
|
12
|
+
if (existing == null) {
|
|
13
|
+
return (WATCHES[expr] = _createWatcher(expr));
|
|
14
|
+
}
|
|
15
|
+
return existing;
|
|
16
|
+
}
|
|
17
|
+
function _createWatcher(expr) {
|
|
18
|
+
const zone = inject(NgZone);
|
|
19
|
+
return zone.runOutsideAngular(() => new Observable((sub) => {
|
|
20
|
+
const query = window.matchMedia(expr);
|
|
21
|
+
const listener = (event) => {
|
|
22
|
+
sub.next(event.matches);
|
|
23
|
+
};
|
|
24
|
+
query.addEventListener("change", listener);
|
|
25
|
+
sub.next(query.matches);
|
|
26
|
+
return () => {
|
|
27
|
+
query.removeEventListener("change", listener);
|
|
28
|
+
delete WATCHES[expr];
|
|
29
|
+
};
|
|
30
|
+
}).pipe(distinctUntilChanged(), shareReplay(1)));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const RESIZE_WATCHES = new Map();
|
|
34
|
+
const SCROLL_WATCHES = new Map();
|
|
35
|
+
function watchDimension(el, box = "border-box") {
|
|
36
|
+
const zone = inject(NgZone);
|
|
37
|
+
return box === "scroll-box" ? _watchScroll(zone, el) : _watchResize(zone, el, box);
|
|
38
|
+
}
|
|
39
|
+
function _watchResize(zone, el, box) {
|
|
40
|
+
return _watch(zone, el, RESIZE_WATCHES, () => _createResizeWatcher(zone, el, box));
|
|
41
|
+
}
|
|
42
|
+
function _watchScroll(zone, el) {
|
|
43
|
+
return _watch(zone, el, SCROLL_WATCHES, () => _createScollWatcher(zone, el));
|
|
44
|
+
}
|
|
45
|
+
function _watch(zone, el, watches, factory) {
|
|
46
|
+
const existing = watches.get(el);
|
|
47
|
+
if (existing == null) {
|
|
48
|
+
const watcher = factory();
|
|
49
|
+
watches.set(el, watcher);
|
|
50
|
+
return watcher;
|
|
51
|
+
}
|
|
52
|
+
return existing;
|
|
53
|
+
}
|
|
54
|
+
function _createResizeWatcher(zone, el, box) {
|
|
55
|
+
if (box !== "border-box") {
|
|
56
|
+
throw new Error(`Currently not implemented box mode: ${box}`);
|
|
57
|
+
}
|
|
58
|
+
return zone.runOutsideAngular(() => new Observable((sub) => {
|
|
59
|
+
const observer = new ResizeObserver(entries => {
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
if (entry.borderBoxSize) {
|
|
62
|
+
sub.next({
|
|
63
|
+
width: _number(entry.borderBoxSize[0].inlineSize),
|
|
64
|
+
height: _number(entry.borderBoxSize[0].blockSize)
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
sub.next({
|
|
69
|
+
width: _number(el.offsetWidth),
|
|
70
|
+
height: _number(el.offsetHeight)
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
observer.observe(el, { box: box });
|
|
76
|
+
return () => {
|
|
77
|
+
observer.disconnect();
|
|
78
|
+
RESIZE_WATCHES.delete(el);
|
|
79
|
+
};
|
|
80
|
+
}).pipe(distinctUntilChanged((p, c) => p && c && p.width === c.width && p.height === c.height), shareReplay(1)));
|
|
81
|
+
}
|
|
82
|
+
function _createScollWatcher(zone, el) {
|
|
83
|
+
return zone.runOutsideAngular(() => new Observable((sub) => {
|
|
84
|
+
let lastSw = 0;
|
|
85
|
+
let lastSh = 0;
|
|
86
|
+
const emit = () => {
|
|
87
|
+
const sw = el.scrollWidth;
|
|
88
|
+
const sh = el.scrollHeight;
|
|
89
|
+
if (lastSw !== sw || lastSh !== sh) {
|
|
90
|
+
lastSw = sw;
|
|
91
|
+
lastSh = sh;
|
|
92
|
+
sub.next({ width: _number(lastSw), height: _number(lastSh) });
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const dimSum = _watchResize(zone, el, "border-box").subscribe(emit);
|
|
96
|
+
const mutation = new MutationObserver(emit);
|
|
97
|
+
mutation.observe(el, {
|
|
98
|
+
subtree: true,
|
|
99
|
+
childList: true,
|
|
100
|
+
attributes: true,
|
|
101
|
+
characterData: true
|
|
102
|
+
});
|
|
103
|
+
return () => {
|
|
104
|
+
dimSum.unsubscribe();
|
|
105
|
+
mutation.disconnect();
|
|
106
|
+
SCROLL_WATCHES.delete(el);
|
|
107
|
+
};
|
|
108
|
+
}).pipe(shareReplay(1)));
|
|
109
|
+
}
|
|
110
|
+
function _number(val) {
|
|
111
|
+
return new NumberWithUnit(val, "pk");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* -----------------------------------------------
|
|
116
|
+
* | TOP:LEFT | TOP:CENTER | TOP:RIGHT |
|
|
117
|
+
* -----------------------------------------------
|
|
118
|
+
* | MIDDLE:LEFT | MIDDLE:CENTER | MIDDLE:RIGH |
|
|
119
|
+
* -----------------------------------------------
|
|
120
|
+
* | BOTTOMN:LEFT | BOTTOM:CENTER | BOTTOM:RIGHT |
|
|
121
|
+
* -----------------------------------------------
|
|
122
|
+
*/
|
|
123
|
+
const vertical = ["top", "middle", "bottom"];
|
|
124
|
+
const horizontal = ["left", "center", "right"];
|
|
125
|
+
class L9Cell {
|
|
126
|
+
static coerce(value) {
|
|
127
|
+
const [v, h] = value.split(":");
|
|
128
|
+
if (vertical.includes(v) && horizontal.includes(h)) {
|
|
129
|
+
return new L9Cell(v, h);
|
|
130
|
+
}
|
|
131
|
+
throw new Error(`Invalid cell value: ${value}`);
|
|
132
|
+
}
|
|
133
|
+
constructor(v, h) {
|
|
134
|
+
this.v = v;
|
|
135
|
+
this.h = h;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
class L9Range {
|
|
139
|
+
static coerce(value) {
|
|
140
|
+
if (value instanceof L9Range) {
|
|
141
|
+
return value;
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
return new L9Range(value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
constructor(range) {
|
|
148
|
+
this.cells = parse(range);
|
|
149
|
+
this.orient = this.#determineOrient();
|
|
150
|
+
}
|
|
151
|
+
isEq(other) {
|
|
152
|
+
if (other instanceof L9Range) {
|
|
153
|
+
const selfFirst = this.cells[0];
|
|
154
|
+
const otherFirst = other.cells[0];
|
|
155
|
+
if (selfFirst.h !== otherFirst.h || selfFirst.v !== otherFirst.v) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
const selfLast = this.cells[this.cells.length - 1];
|
|
159
|
+
const otherLast = other.cells[other.cells.length - 1];
|
|
160
|
+
if (selfLast.h === otherLast.h && selfLast.v === otherLast.v) {
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
#determineOrient() {
|
|
167
|
+
const { v: sv, h: sh } = this.cells[0];
|
|
168
|
+
const { v: ev, h: eh } = this.cells[this.cells.length - 1];
|
|
169
|
+
if (sv === ev) {
|
|
170
|
+
return "horizontal";
|
|
171
|
+
}
|
|
172
|
+
else if (sh === eh) {
|
|
173
|
+
return "vertical";
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
return "rect";
|
|
177
|
+
}
|
|
178
|
+
}
|
|
8
179
|
}
|
|
9
|
-
|
|
180
|
+
function parse(value) {
|
|
181
|
+
const cells = [];
|
|
182
|
+
if (vertical.includes(value)) {
|
|
183
|
+
for (const h of horizontal) {
|
|
184
|
+
cells.push(new L9Cell(value, h));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else if (horizontal.includes(value)) {
|
|
188
|
+
for (const v of vertical) {
|
|
189
|
+
cells.push(new L9Cell(v, value));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (value.includes("-")) {
|
|
193
|
+
const [begin, end] = value.split("-");
|
|
194
|
+
const beginCells = parse(begin);
|
|
195
|
+
const endCells = parse(end);
|
|
196
|
+
if (beginCells.length > 1) {
|
|
197
|
+
throw new Error(`Currently not supported begin range value: ${begin}`);
|
|
198
|
+
}
|
|
199
|
+
if (endCells.length > 1) {
|
|
200
|
+
throw new Error(`Currently not supported end range value: ${end}`);
|
|
201
|
+
}
|
|
202
|
+
const { v: bv, h: bh } = beginCells[0];
|
|
203
|
+
const { v: ev, h: eh } = endCells[0];
|
|
204
|
+
const vstart = Math.min(vertical.indexOf(bv), vertical.indexOf(ev));
|
|
205
|
+
const vend = Math.max(vertical.indexOf(bv), vertical.indexOf(ev));
|
|
206
|
+
const hstart = Math.min(horizontal.indexOf(bh), horizontal.indexOf(eh));
|
|
207
|
+
const hend = Math.max(horizontal.indexOf(bh), horizontal.indexOf(eh));
|
|
208
|
+
for (let vi = vstart; vi <= vend; vi++) {
|
|
209
|
+
for (let hi = hstart; hi <= hend; hi++) {
|
|
210
|
+
cells.push(new L9Cell(vertical[vi], horizontal[hi]));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (value.includes(":")) {
|
|
215
|
+
cells.push(L9Cell.coerce(value));
|
|
216
|
+
}
|
|
217
|
+
if (cells.length === 0) {
|
|
218
|
+
throw Error(`Undefined l9cell: "${value}"`);
|
|
219
|
+
}
|
|
220
|
+
return cells;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
class L9State {
|
|
224
|
+
#dims;
|
|
225
|
+
constructor(prefix) {
|
|
226
|
+
this.prefix = prefix;
|
|
227
|
+
this.#dims = new BehaviorSubject({});
|
|
228
|
+
this.style = this.#dims.pipe(map(dims => {
|
|
229
|
+
const res = {};
|
|
230
|
+
for (const [k, v] of Object.entries(dims)) {
|
|
231
|
+
if (v == null) {
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
const [vertical, horizontal] = k.split(":");
|
|
235
|
+
res[`--${this.prefix}-${vertical}-${horizontal}-w`] = v.width.toString();
|
|
236
|
+
res[`--${this.prefix}-${vertical}-${horizontal}-h`] = v.height.toString();
|
|
237
|
+
}
|
|
238
|
+
return res;
|
|
239
|
+
}), shareReplay(1));
|
|
240
|
+
}
|
|
241
|
+
update(range, dim) {
|
|
242
|
+
range = L9Range.coerce(range);
|
|
243
|
+
const dims = { ...this.#dims.value };
|
|
244
|
+
// for (const cell of range.horizontals) {
|
|
245
|
+
// dims[cell] = dim.width
|
|
246
|
+
// }
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
class DockingContentComponent {
|
|
251
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
252
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.3", type: DockingContentComponent, isStandalone: true, selector: "nu-docking-content", ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{display:flex;flex-flow:column nowrap;align-items:stretch;box-sizing:border-box;flex:1;overflow:auto}\n"] }); }
|
|
253
|
+
}
|
|
254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingContentComponent, decorators: [{
|
|
255
|
+
type: Component,
|
|
256
|
+
args: [{ standalone: true, selector: "nu-docking-content", template: `<ng-content></ng-content>`, styles: [":host{display:flex;flex-flow:column nowrap;align-items:stretch;box-sizing:border-box;flex:1;overflow:auto}\n"] }]
|
|
257
|
+
}] });
|
|
258
|
+
|
|
259
|
+
const DEFAULT_POSITION = L9Range.coerce("left");
|
|
260
|
+
class DockingPanelComponent extends Destructible {
|
|
261
|
+
set positionInput(val) {
|
|
262
|
+
const coerced = L9Range.coerce(val);
|
|
263
|
+
console.log("SET POSITION", coerced, this.position.value.isEq(coerced));
|
|
264
|
+
if (coerced.orient === "rect") {
|
|
265
|
+
throw new Error(`Invalid position value: ${val}`);
|
|
266
|
+
}
|
|
267
|
+
if (!this.position.value.isEq(coerced)) {
|
|
268
|
+
this.position.next(coerced);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
set stateInput(val) {
|
|
272
|
+
if (this.state.value !== val) {
|
|
273
|
+
this.state.next(val);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
set modeInput(val) {
|
|
277
|
+
if (this.mode.value !== val) {
|
|
278
|
+
this.mode.next(val);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
set fullSizeInput(val) {
|
|
282
|
+
const coerced = NumberWithUnit.coerce(val, "px");
|
|
283
|
+
if (this.#fullSize.value !== coerced) {
|
|
284
|
+
this.#fullSize.next(coerced);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
#fullSize;
|
|
288
|
+
set miniSizeInput(val) {
|
|
289
|
+
const coerced = NumberWithUnit.coerce(val, "px");
|
|
290
|
+
if (this.#miniSize.value !== coerced) {
|
|
291
|
+
this.#miniSize.next(coerced);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
#miniSize;
|
|
295
|
+
set minimizable(val) {
|
|
296
|
+
this.#minimizable = coerceBoolAttr(val);
|
|
297
|
+
this.#minimizableAuto = false;
|
|
298
|
+
}
|
|
299
|
+
get minimizable() {
|
|
300
|
+
return this.#minimizable;
|
|
301
|
+
}
|
|
302
|
+
#minimizable;
|
|
303
|
+
#minimizableAuto;
|
|
304
|
+
#autoSize;
|
|
305
|
+
constructor() {
|
|
306
|
+
super();
|
|
307
|
+
this.el = inject((ElementRef));
|
|
308
|
+
this.position = new BehaviorSubject(DEFAULT_POSITION);
|
|
309
|
+
this.state = new BehaviorSubject("invisible");
|
|
310
|
+
this.mode = new BehaviorSubject("overlay");
|
|
311
|
+
this.#fullSize = new BehaviorSubject(NumberWithUnit.coerce(0));
|
|
312
|
+
this.#miniSize = new BehaviorSubject(NumberWithUnit.coerce(0));
|
|
313
|
+
this.#minimizable = false;
|
|
314
|
+
this.#minimizableAuto = true;
|
|
315
|
+
this.#autoSize = combineLatest({
|
|
316
|
+
dim: watchDimension(this.el.nativeElement, "scroll-box"),
|
|
317
|
+
pos: this.position
|
|
318
|
+
}).pipe(map(({ dim, pos }) => {
|
|
319
|
+
if (pos.orient === "horizontal") {
|
|
320
|
+
return dim.height;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
return dim.width;
|
|
324
|
+
}
|
|
325
|
+
}), shareReplay(1));
|
|
326
|
+
this.fullSize = this.#fullSize.pipe(switchMap(size => {
|
|
327
|
+
if (size.unit === "auto") {
|
|
328
|
+
return this.#autoSize;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
return of(size);
|
|
332
|
+
}
|
|
333
|
+
}), shareReplay(1));
|
|
334
|
+
this.miniSize = this.#miniSize.pipe(switchMap(size => {
|
|
335
|
+
if (size.unit === "auto") {
|
|
336
|
+
return this.#autoSize;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return of(size);
|
|
340
|
+
}
|
|
341
|
+
}), shareReplay(1));
|
|
342
|
+
this.changes = combineLatest({
|
|
343
|
+
position: this.position,
|
|
344
|
+
state: this.state,
|
|
345
|
+
mode: this.mode,
|
|
346
|
+
fullSize: this.fullSize,
|
|
347
|
+
miniSize: this.miniSize
|
|
348
|
+
});
|
|
349
|
+
this.d.sub(this.changes).subscribe(changes => {
|
|
350
|
+
if (this.#minimizableAuto) {
|
|
351
|
+
this.#minimizable = this.#miniSize.value.value !== 0;
|
|
352
|
+
}
|
|
353
|
+
FastDOM.setAttributes(this.el.nativeElement, {
|
|
354
|
+
state: changes.state,
|
|
355
|
+
orient: changes.position.orient,
|
|
356
|
+
mode: changes.mode,
|
|
357
|
+
side: changes.position.orient === "horizontal" ? changes.position.cells[0].v : changes.position.cells[0].h
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
open() {
|
|
362
|
+
this.state.next("full");
|
|
363
|
+
}
|
|
364
|
+
close() {
|
|
365
|
+
this.state.next("invisible");
|
|
366
|
+
}
|
|
367
|
+
minimize() {
|
|
368
|
+
if (this.minimizable) {
|
|
369
|
+
this.state.next("mini");
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingPanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
373
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.1.3", type: DockingPanelComponent, isStandalone: true, selector: "nu-docking-panel", inputs: { positionInput: ["position", "positionInput"], stateInput: ["state", "stateInput"], modeInput: ["mode", "modeInput"], fullSizeInput: ["fullSize", "fullSizeInput"], miniSizeInput: ["miniSize", "miniSizeInput"], minimizable: "minimizable" }, outputs: { state: "stateChanges" }, exportAs: ["nuDockingPanel"], usesInheritance: true, ngImport: i0, template: `<ng-content></ng-content>`, isInline: true, styles: [":host{---docking-panel-t: var(--docking-panel-t, auto);---docking-panel-r: var(--docking-panel-r, auto);---docking-panel-b: var(--docking-panel-b, auto);---docking-panel-l: var(--docking-panel-l, auto);---docking-panel-w: var(--docking-panel-w, auto);---docking-panel-h: var(--docking-panel-h, auto);---docking-panel-real-w: var(--docking-panel-real-w, var(---docking-panel-w));---docking-panel-real-h: var(--docking-panel-real-h, var(---docking-panel-h));display:flex;flex-flow:column nowrap;align-items:stretch;position:absolute;box-sizing:border-box;top:var(---docking-panel-t);right:var(---docking-panel-r);bottom:var(---docking-panel-b);left:var(---docking-panel-l);width:var(---docking-panel-w);height:var(---docking-panel-h);transition:transform var(---docking-layout-anim-duration) var(---docking-layout-anim-ease),width var(---docking-layout-anim-duration) var(---docking-layout-anim-ease),height var(---docking-layout-anim-duration) var(---docking-layout-anim-ease)}:host[side=top],:host[side=left]{---docking-panel-t-hide: -100%;---docking-panel-t-visible: 0%}:host[side=bottom],:host[side=right]{---docking-panel-t-hide: 100%;---docking-panel-t-visible: 0%}:host[state=invisible][orient=horizontal]{transform:translateY(var(---docking-panel-t-hide))}:host[state=invisible][orient=vertical]{transform:translate(var(---docking-panel-t-hide))}:host:not([state=invisible])[orient=horizontal]{transform:translateY(var(---docking-panel-t-visible))}:host:not([state=invisible])[orient=vertical]{transform:translate(var(---docking-panel-t-visible))}\n"] }); }
|
|
374
|
+
}
|
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingPanelComponent, decorators: [{
|
|
376
|
+
type: Component,
|
|
377
|
+
args: [{ standalone: true, selector: "nu-docking-panel", exportAs: "nuDockingPanel", template: `<ng-content></ng-content>`, styles: [":host{---docking-panel-t: var(--docking-panel-t, auto);---docking-panel-r: var(--docking-panel-r, auto);---docking-panel-b: var(--docking-panel-b, auto);---docking-panel-l: var(--docking-panel-l, auto);---docking-panel-w: var(--docking-panel-w, auto);---docking-panel-h: var(--docking-panel-h, auto);---docking-panel-real-w: var(--docking-panel-real-w, var(---docking-panel-w));---docking-panel-real-h: var(--docking-panel-real-h, var(---docking-panel-h));display:flex;flex-flow:column nowrap;align-items:stretch;position:absolute;box-sizing:border-box;top:var(---docking-panel-t);right:var(---docking-panel-r);bottom:var(---docking-panel-b);left:var(---docking-panel-l);width:var(---docking-panel-w);height:var(---docking-panel-h);transition:transform var(---docking-layout-anim-duration) var(---docking-layout-anim-ease),width var(---docking-layout-anim-duration) var(---docking-layout-anim-ease),height var(---docking-layout-anim-duration) var(---docking-layout-anim-ease)}:host[side=top],:host[side=left]{---docking-panel-t-hide: -100%;---docking-panel-t-visible: 0%}:host[side=bottom],:host[side=right]{---docking-panel-t-hide: 100%;---docking-panel-t-visible: 0%}:host[state=invisible][orient=horizontal]{transform:translateY(var(---docking-panel-t-hide))}:host[state=invisible][orient=vertical]{transform:translate(var(---docking-panel-t-hide))}:host:not([state=invisible])[orient=horizontal]{transform:translateY(var(---docking-panel-t-visible))}:host:not([state=invisible])[orient=vertical]{transform:translate(var(---docking-panel-t-visible))}\n"] }]
|
|
378
|
+
}], ctorParameters: () => [], propDecorators: { positionInput: [{
|
|
379
|
+
type: Input,
|
|
380
|
+
args: ["position"]
|
|
381
|
+
}], stateInput: [{
|
|
382
|
+
type: Input,
|
|
383
|
+
args: ["state"]
|
|
384
|
+
}], state: [{
|
|
385
|
+
type: Output,
|
|
386
|
+
args: ["stateChanges"]
|
|
387
|
+
}], modeInput: [{
|
|
388
|
+
type: Input,
|
|
389
|
+
args: ["mode"]
|
|
390
|
+
}], fullSizeInput: [{
|
|
391
|
+
type: Input,
|
|
392
|
+
args: ["fullSize"]
|
|
393
|
+
}], miniSizeInput: [{
|
|
394
|
+
type: Input,
|
|
395
|
+
args: ["miniSize"]
|
|
396
|
+
}], minimizable: [{
|
|
397
|
+
type: Input,
|
|
398
|
+
args: ["minimizable"]
|
|
399
|
+
}] } });
|
|
400
|
+
|
|
401
|
+
const EMBEDDED_ZINDEX = 20;
|
|
402
|
+
const OVERLAY_ZINDEX = EMBEDDED_ZINDEX * 2;
|
|
403
|
+
// interface PanelRefChanges {
|
|
404
|
+
// ref: PanelRef
|
|
405
|
+
// changes: DockingPanelChanges
|
|
406
|
+
// }
|
|
407
|
+
// class PanelRef {
|
|
408
|
+
// style: Partial<CSSStyleDeclaration> = {}
|
|
409
|
+
// readonly changes: Observable<PanelRefChanges>
|
|
410
|
+
// constructor(public readonly panel: DockingPanelDirective) {
|
|
411
|
+
// this.changes = panel.changes.pipe(
|
|
412
|
+
// map(changes => {
|
|
413
|
+
// return { ref: this, changes }
|
|
414
|
+
// })
|
|
415
|
+
// )
|
|
416
|
+
// }
|
|
417
|
+
// }
|
|
418
|
+
class DockingLayoutComponent extends Destructible {
|
|
419
|
+
constructor() {
|
|
420
|
+
super(...arguments);
|
|
421
|
+
this.#el = inject((ElementRef));
|
|
422
|
+
this.contentOnly = false;
|
|
423
|
+
this.positionMode = "absolute";
|
|
424
|
+
this.#reflow = new Subject();
|
|
425
|
+
}
|
|
426
|
+
#el;
|
|
427
|
+
#reflow;
|
|
428
|
+
ngAfterViewInit() {
|
|
429
|
+
// eslint-disable-next-line prettier/prettier
|
|
430
|
+
this.panels = this.dockingPanels.changes.pipe(startWith(null), map(() => this.dockingPanels.toArray()), shareReplay(1));
|
|
431
|
+
// this.panels.subscribe(panels => console.log({ panels }))
|
|
432
|
+
this.d
|
|
433
|
+
.sub(combineLatest({ panels: this.panels, reflow: this.#reflow.pipe(startWith(null)) }))
|
|
434
|
+
.pipe(switchMap(({ panels }) => combineLatest(panels.map(panel => panel.changes.pipe(map(changes => {
|
|
435
|
+
return { panel, changes };
|
|
436
|
+
}))))))
|
|
437
|
+
.subscribe(this.#layout.bind(this));
|
|
438
|
+
// this.d
|
|
439
|
+
// .sub(merge(this.dockingPanels.changes, this.#reflow))
|
|
440
|
+
// .pipe(
|
|
441
|
+
// startWith(null),
|
|
442
|
+
// map(() => this.dockingPanels.map(panel => new PanelRef(panel))),
|
|
443
|
+
// switchMap(refs => combineLatest(refs.map(ref => ref.changes))),
|
|
444
|
+
// map(changes => {
|
|
445
|
+
// this.#layout(changes)
|
|
446
|
+
// return changes.map(c => c.ref)
|
|
447
|
+
// })
|
|
448
|
+
// )
|
|
449
|
+
// .subscribe(this.panels)
|
|
450
|
+
}
|
|
451
|
+
ngOnChanges(changes) {
|
|
452
|
+
if ("contentOnly" in changes || "positionMode" in changes) {
|
|
453
|
+
this.#reflow.next();
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
#layout(entries) {
|
|
457
|
+
console.log("layout", entries);
|
|
458
|
+
let paddingTop = 0;
|
|
459
|
+
let paddingRight = 0;
|
|
460
|
+
let paddingBottom = 0;
|
|
461
|
+
let paddingLeft = 0;
|
|
462
|
+
let embeddedZIndex = EMBEDDED_ZINDEX;
|
|
463
|
+
let overlayZIndex = OVERLAY_ZINDEX;
|
|
464
|
+
if (this.contentOnly) {
|
|
465
|
+
// TODO:...
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
for (const entry of entries) {
|
|
469
|
+
const panelState = entry.changes;
|
|
470
|
+
const panelSize = panelState.state === "full"
|
|
471
|
+
? panelState.fullSize.value
|
|
472
|
+
: panelState.state === "mini"
|
|
473
|
+
? panelState.miniSize.value
|
|
474
|
+
: 0;
|
|
475
|
+
const isHorizontal = panelState.position.orient === "horizontal";
|
|
476
|
+
const isEmbedded = panelState.mode === "embedded";
|
|
477
|
+
let panelTop = null;
|
|
478
|
+
let panelRight = null;
|
|
479
|
+
let panelBottom = null;
|
|
480
|
+
let panelLeft = null;
|
|
481
|
+
if (isHorizontal) {
|
|
482
|
+
panelLeft = 0;
|
|
483
|
+
panelRight = 0;
|
|
484
|
+
if (panelState.position.cells[0].v === "top") {
|
|
485
|
+
if (isEmbedded) {
|
|
486
|
+
paddingTop = Math.max(paddingTop, panelSize);
|
|
487
|
+
}
|
|
488
|
+
panelTop = 0;
|
|
489
|
+
}
|
|
490
|
+
else if (panelState.position.cells[0].v === "bottom") {
|
|
491
|
+
if (isEmbedded) {
|
|
492
|
+
paddingBottom = Math.max(paddingBottom, panelSize);
|
|
493
|
+
}
|
|
494
|
+
panelBottom = 0;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
panelTop = 0;
|
|
499
|
+
panelBottom = 0;
|
|
500
|
+
if (panelState.position.cells[0].h === "left") {
|
|
501
|
+
if (isEmbedded) {
|
|
502
|
+
paddingLeft = Math.max(paddingLeft, panelSize);
|
|
503
|
+
}
|
|
504
|
+
panelLeft = 0;
|
|
505
|
+
}
|
|
506
|
+
else if (panelState.position.cells[0].h === "right") {
|
|
507
|
+
if (isEmbedded) {
|
|
508
|
+
paddingRight = Math.max(paddingRight, panelSize);
|
|
509
|
+
}
|
|
510
|
+
panelRight = 0;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const panelGivenSize = panelState.state === "full"
|
|
514
|
+
? panelState.fullSize
|
|
515
|
+
: panelState.state === "mini"
|
|
516
|
+
? panelState.miniSize
|
|
517
|
+
: new NumberWithUnit(0, "px");
|
|
518
|
+
FastDOM.setStyle(entry.panel.el.nativeElement, {
|
|
519
|
+
"z-index": `${isEmbedded ? embeddedZIndex++ : overlayZIndex++}`,
|
|
520
|
+
"--docking-panel-t": panelTop != null ? `${panelTop}px` : null,
|
|
521
|
+
"--docking-panel-r": panelRight != null ? `${panelRight}px` : null,
|
|
522
|
+
"--docking-panel-b": panelBottom != null ? `${panelBottom}px` : null,
|
|
523
|
+
"--docking-panel-l": panelLeft != null ? `${panelLeft}px` : null,
|
|
524
|
+
"--docking-panel-w": !isHorizontal
|
|
525
|
+
? `${panelGivenSize.unit === "auto" ? "auto" : panelGivenSize}`
|
|
526
|
+
: null,
|
|
527
|
+
"--docking-panel-h": isHorizontal
|
|
528
|
+
? `${panelGivenSize.unit === "auto" ? "auto" : panelGivenSize}`
|
|
529
|
+
: null,
|
|
530
|
+
"--docking-panel-real-w": !isHorizontal ? `${panelSize}px` : null,
|
|
531
|
+
"--docking-panel-real-h": isHorizontal ? `${panelSize}px` : null
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
console.log({ paddingTop, paddingRight, paddingBottom, paddingLeft });
|
|
535
|
+
FastDOM.setStyle(this.#el.nativeElement, {
|
|
536
|
+
"--docking-layout-top": `${paddingTop}px`,
|
|
537
|
+
"--docking-layout-right": `${paddingRight}px`,
|
|
538
|
+
"--docking-layout-bottom": `${paddingBottom}px`,
|
|
539
|
+
"--docking-layout-left": `${paddingLeft}px`
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
#layoutOld(entries) {
|
|
544
|
+
// let paddingTop = 0
|
|
545
|
+
// let paddingRight = 0
|
|
546
|
+
// let paddingBottom = 0
|
|
547
|
+
// let paddingLeft = 0
|
|
548
|
+
// if (!this.contentOnly) {
|
|
549
|
+
// let embeddedZIndex = EMBEDDED_ZINDEX
|
|
550
|
+
// let overlayZIndex = OVERLAY_ZINDEX
|
|
551
|
+
// const leftRight: PanelRefChanges[] = entries.filter(v =>
|
|
552
|
+
// ["left", "right"].includes(v.changes.position.side)
|
|
553
|
+
// )
|
|
554
|
+
// const topBottom: PanelRefChanges[] = entries.filter(v =>
|
|
555
|
+
// ["top", "bottom"].includes(v.changes.position.side)
|
|
556
|
+
// )
|
|
557
|
+
// for (const entry of entries) {
|
|
558
|
+
// const changes = entry.changes
|
|
559
|
+
// const ref = entry.ref
|
|
560
|
+
// if (changes.mode === "embedded") {
|
|
561
|
+
// ref.style.zIndex = `${embeddedZIndex++}`
|
|
562
|
+
// } else if (changes.mode === "overlay") {
|
|
563
|
+
// ref.style.zIndex = `${overlayZIndex++}`
|
|
564
|
+
// }
|
|
565
|
+
// }
|
|
566
|
+
// for (const entry of leftRight) {
|
|
567
|
+
// const changes = entry.changes
|
|
568
|
+
// const ref = entry.ref
|
|
569
|
+
// const padding =
|
|
570
|
+
// changes.mode === "embedded"
|
|
571
|
+
// ? changes.state === "full"
|
|
572
|
+
// ? changes.fullSize
|
|
573
|
+
// : changes.state === "mini"
|
|
574
|
+
// ? changes.miniSize
|
|
575
|
+
// : 0
|
|
576
|
+
// : 0
|
|
577
|
+
// ref.style.top = "0"
|
|
578
|
+
// ref.style.bottom = "0"
|
|
579
|
+
// if (changes.position.side === "left") {
|
|
580
|
+
// paddingLeft = Math.max(paddingLeft, padding)
|
|
581
|
+
// ref.style.left = "0"
|
|
582
|
+
// ref.style.right = ""
|
|
583
|
+
// } else {
|
|
584
|
+
// paddingRight = Math.max(paddingRight, padding)
|
|
585
|
+
// ref.style.right = "0"
|
|
586
|
+
// ref.style.left = ""
|
|
587
|
+
// }
|
|
588
|
+
// }
|
|
589
|
+
// for (const entry of topBottom) {
|
|
590
|
+
// const changes = entry.changes
|
|
591
|
+
// const ref = entry.ref
|
|
592
|
+
// const padding =
|
|
593
|
+
// changes.mode === "embedded"
|
|
594
|
+
// ? changes.state === "full"
|
|
595
|
+
// ? changes.fullSize
|
|
596
|
+
// : changes.state === "mini"
|
|
597
|
+
// ? changes.miniSize
|
|
598
|
+
// : 0
|
|
599
|
+
// : 0
|
|
600
|
+
// if (changes.mode === "embedded") {
|
|
601
|
+
// ref.style.left = `${paddingLeft}px`
|
|
602
|
+
// ref.style.right = `${paddingRight}px`
|
|
603
|
+
// } else {
|
|
604
|
+
// ref.style.left = "0"
|
|
605
|
+
// ref.style.right = "0"
|
|
606
|
+
// }
|
|
607
|
+
// if (changes.position?.cells[0].v === "top") {
|
|
608
|
+
// paddingTop = Math.max(paddingTop, padding)
|
|
609
|
+
// ref.style.top = "0"
|
|
610
|
+
// ref.style.bottom = ""
|
|
611
|
+
// } else {
|
|
612
|
+
// paddingBottom = Math.max(paddingBottom, padding)
|
|
613
|
+
// ref.style.bottom = `0`
|
|
614
|
+
// ref.style.top = ""
|
|
615
|
+
// }
|
|
616
|
+
// }
|
|
617
|
+
// }
|
|
618
|
+
// const cel = this.contentEl.nativeElement
|
|
619
|
+
// cel.style.padding = `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`
|
|
620
|
+
}
|
|
621
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingLayoutComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
|
|
622
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.1.3", type: DockingLayoutComponent, isStandalone: true, selector: "nu-docking", inputs: { contentOnly: "contentOnly", positionMode: "positionMode" }, queries: [{ propertyName: "contentComponent", first: true, predicate: DockingContentComponent, descendants: true }, { propertyName: "dockingPanels", predicate: DockingPanelComponent }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
|
|
623
|
+
<ng-content select="nu-docking-panel"></ng-content>
|
|
624
|
+
|
|
625
|
+
@if (!contentComponent) {
|
|
626
|
+
<nu-docking-content>
|
|
627
|
+
<ng-content></ng-content>
|
|
628
|
+
</nu-docking-content>
|
|
629
|
+
} @else {
|
|
630
|
+
<ng-content select="nu-docking-content"></ng-content>
|
|
631
|
+
}
|
|
632
|
+
`, isInline: true, styles: [":host{---docking-layout-top: var(--docking-layout-top, 0px);---docking-layout-right: var(--docking-layout-right, 0px);---docking-layout-bottom: var(--docking-layout-bottom, 0px);---docking-layout-left: var(--docking-layout-left, 0px);---docking-layout-anim-duration: var(--docking-layout-anim-duration, .2s);---docking-layout-anim-ease: var(--docking-layout-anim-ease, ease-out);display:flex;flex-flow:column nowrap;align-items:stretch;position:relative;overflow:hidden;box-sizing:border-box;z-index:0;padding:var(---docking-layout-top) var(---docking-layout-right) var(---docking-layout-bottom) var(---docking-layout-left);transition:padding var(---docking-layout-anim-duration) var(---docking-layout-anim-ease)}\n"], dependencies: [{ kind: "component", type: DockingContentComponent, selector: "nu-docking-content" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
633
|
+
}
|
|
634
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: DockingLayoutComponent, decorators: [{
|
|
10
635
|
type: Component,
|
|
11
|
-
args: [{ selector: "nu-
|
|
636
|
+
args: [{ selector: "nu-docking", standalone: true, imports: [DockingContentComponent], template: `
|
|
637
|
+
<ng-content select="nu-docking-panel"></ng-content>
|
|
638
|
+
|
|
639
|
+
@if (!contentComponent) {
|
|
640
|
+
<nu-docking-content>
|
|
641
|
+
<ng-content></ng-content>
|
|
642
|
+
</nu-docking-content>
|
|
643
|
+
} @else {
|
|
644
|
+
<ng-content select="nu-docking-content"></ng-content>
|
|
645
|
+
}
|
|
646
|
+
`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{---docking-layout-top: var(--docking-layout-top, 0px);---docking-layout-right: var(--docking-layout-right, 0px);---docking-layout-bottom: var(--docking-layout-bottom, 0px);---docking-layout-left: var(--docking-layout-left, 0px);---docking-layout-anim-duration: var(--docking-layout-anim-duration, .2s);---docking-layout-anim-ease: var(--docking-layout-anim-ease, ease-out);display:flex;flex-flow:column nowrap;align-items:stretch;position:relative;overflow:hidden;box-sizing:border-box;z-index:0;padding:var(---docking-layout-top) var(---docking-layout-right) var(---docking-layout-bottom) var(---docking-layout-left);transition:padding var(---docking-layout-anim-duration) var(---docking-layout-anim-ease)}\n"] }]
|
|
647
|
+
}], propDecorators: { contentOnly: [{
|
|
648
|
+
type: Input
|
|
649
|
+
}], positionMode: [{
|
|
650
|
+
type: Input
|
|
651
|
+
}], contentComponent: [{
|
|
652
|
+
type: ContentChild,
|
|
653
|
+
args: [DockingContentComponent]
|
|
654
|
+
}], dockingPanels: [{
|
|
655
|
+
type: ContentChildren,
|
|
656
|
+
args: [DockingPanelComponent]
|
|
657
|
+
}] } });
|
|
658
|
+
|
|
659
|
+
const members = [DockingLayoutComponent, DockingPanelComponent, DockingContentComponent];
|
|
660
|
+
class NuDockingLayout {
|
|
661
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: NuDockingLayout, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
662
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.1.3", ngImport: i0, type: NuDockingLayout, imports: [DockingLayoutComponent, DockingPanelComponent, DockingContentComponent], exports: [DockingLayoutComponent, DockingPanelComponent, DockingContentComponent] }); }
|
|
663
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: NuDockingLayout }); }
|
|
664
|
+
}
|
|
665
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.3", ngImport: i0, type: NuDockingLayout, decorators: [{
|
|
666
|
+
type: NgModule,
|
|
667
|
+
args: [{
|
|
668
|
+
imports: members,
|
|
669
|
+
exports: members
|
|
670
|
+
}]
|
|
12
671
|
}] });
|
|
13
672
|
|
|
14
673
|
/**
|
|
15
674
|
* Generated bundle index. Do not edit.
|
|
16
675
|
*/
|
|
17
676
|
|
|
18
|
-
export {
|
|
677
|
+
export { DockingContentComponent, DockingLayoutComponent, DockingPanelComponent, L9Cell, L9Range, L9State, NuDockingLayout, watchDimension, watchMedia };
|
|
19
678
|
//# sourceMappingURL=ngutil-layout.mjs.map
|