UNPKG

59.3 kBJavaScriptView Raw
1import { Component, ChangeDetectionStrategy, NgZone, ElementRef, ChangeDetectorRef, Renderer2, Input, Output, ViewChildren, EventEmitter, Directive, NgModule } from '@angular/core';
2import { CommonModule } from '@angular/common';
3import { __spread } from 'tslib';
4import { Observable, Subject } from 'rxjs';
5import { debounceTime } from 'rxjs/operators';
6
7/**
8 * @fileoverview added by tsickle
9 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
10 */
11/**
12 * @param {?} event
13 * @return {?}
14 */
15function getPointFromEvent(event) {
16 // TouchEvent
17 if (((/** @type {?} */ (event))).changedTouches !== undefined && ((/** @type {?} */ (event))).changedTouches.length > 0) {
18 return {
19 x: ((/** @type {?} */ (event))).changedTouches[0].clientX,
20 y: ((/** @type {?} */ (event))).changedTouches[0].clientY,
21 };
22 }
23 // MouseEvent
24 else if (((/** @type {?} */ (event))).clientX !== undefined && ((/** @type {?} */ (event))).clientY !== undefined) {
25 return {
26 x: ((/** @type {?} */ (event))).clientX,
27 y: ((/** @type {?} */ (event))).clientY,
28 };
29 }
30 return null;
31}
32/**
33 * @param {?} elRef
34 * @param {?} direction
35 * @return {?}
36 */
37function getElementPixelSize(elRef, direction) {
38 /** @type {?} */
39 var rect = ((/** @type {?} */ (elRef.nativeElement))).getBoundingClientRect();
40 return (direction === 'horizontal') ? rect.width : rect.height;
41}
42/**
43 * @param {?} v
44 * @return {?}
45 */
46function getInputBoolean(v) {
47 return (typeof (v) === 'boolean') ? v : (v === 'false' ? false : true);
48}
49/**
50 * @template T
51 * @param {?} v
52 * @param {?} defaultValue
53 * @return {?}
54 */
55function getInputPositiveNumber(v, defaultValue) {
56 if (v === null || v === undefined)
57 return defaultValue;
58 v = Number(v);
59 return !isNaN(v) && v >= 0 ? v : defaultValue;
60}
61/**
62 * @param {?} unit
63 * @param {?} sizes
64 * @return {?}
65 */
66function isUserSizesValid(unit, sizes) {
67 // All sizes have to be not null and total should be 100
68 if (unit === 'percent') {
69 /** @type {?} */
70 var total = sizes.reduce((/**
71 * @param {?} total
72 * @param {?} s
73 * @return {?}
74 */
75 function (total, s) { return s !== null ? total + s : total; }), 0);
76 return sizes.every((/**
77 * @param {?} s
78 * @return {?}
79 */
80 function (s) { return s !== null; })) && total > 99.9 && total < 100.1;
81 }
82 // A size at null is mandatory but only one.
83 if (unit === 'pixel') {
84 return sizes.filter((/**
85 * @param {?} s
86 * @return {?}
87 */
88 function (s) { return s === null; })).length === 1;
89 }
90}
91/**
92 * @param {?} a
93 * @return {?}
94 */
95function getAreaMinSize(a) {
96 if (a.size === null) {
97 return null;
98 }
99 if (a.component.lockSize === true) {
100 return a.size;
101 }
102 if (a.component.minSize === null) {
103 return null;
104 }
105 if (a.component.minSize > a.size) {
106 return a.size;
107 }
108 return a.component.minSize;
109}
110/**
111 * @param {?} a
112 * @return {?}
113 */
114function getAreaMaxSize(a) {
115 if (a.size === null) {
116 return null;
117 }
118 if (a.component.lockSize === true) {
119 return a.size;
120 }
121 if (a.component.maxSize === null) {
122 return null;
123 }
124 if (a.component.maxSize < a.size) {
125 return a.size;
126 }
127 return a.component.maxSize;
128}
129/**
130 * @param {?} unit
131 * @param {?} sideAreas
132 * @param {?} pixels
133 * @param {?} allAreasSizePixel
134 * @return {?}
135 */
136function getGutterSideAbsorptionCapacity(unit, sideAreas, pixels, allAreasSizePixel) {
137 return sideAreas.reduce((/**
138 * @param {?} acc
139 * @param {?} area
140 * @return {?}
141 */
142 function (acc, area) {
143 /** @type {?} */
144 var res = getAreaAbsorptionCapacity(unit, area, acc.remain, allAreasSizePixel);
145 acc.list.push(res);
146 acc.remain = res.pixelRemain;
147 return acc;
148 }), { remain: pixels, list: [] });
149}
150/**
151 * @param {?} unit
152 * @param {?} areaSnapshot
153 * @param {?} pixels
154 * @param {?} allAreasSizePixel
155 * @return {?}
156 */
157function getAreaAbsorptionCapacity(unit, areaSnapshot, pixels, allAreasSizePixel) {
158 // No pain no gain
159 if (pixels === 0) {
160 return {
161 areaSnapshot: areaSnapshot,
162 pixelAbsorb: 0,
163 percentAfterAbsorption: areaSnapshot.sizePercentAtStart,
164 pixelRemain: 0,
165 };
166 }
167 // Area start at zero and need to be reduced, not possible
168 if (areaSnapshot.sizePixelAtStart === 0 && pixels < 0) {
169 return {
170 areaSnapshot: areaSnapshot,
171 pixelAbsorb: 0,
172 percentAfterAbsorption: 0,
173 pixelRemain: pixels,
174 };
175 }
176 if (unit === 'percent') {
177 return getAreaAbsorptionCapacityPercent(areaSnapshot, pixels, allAreasSizePixel);
178 }
179 if (unit === 'pixel') {
180 return getAreaAbsorptionCapacityPixel(areaSnapshot, pixels);
181 }
182}
183/**
184 * @param {?} areaSnapshot
185 * @param {?} pixels
186 * @param {?} allAreasSizePixel
187 * @return {?}
188 */
189function getAreaAbsorptionCapacityPercent(areaSnapshot, pixels, allAreasSizePixel) {
190 /** @type {?} */
191 var tempPixelSize = areaSnapshot.sizePixelAtStart + pixels;
192 /** @type {?} */
193 var tempPercentSize = tempPixelSize / allAreasSizePixel * 100;
194 // ENLARGE AREA
195 if (pixels > 0) {
196 // If maxSize & newSize bigger than it > absorb to max and return remaining pixels
197 if (areaSnapshot.area.maxSize !== null && tempPercentSize > areaSnapshot.area.maxSize) {
198 // Use area.area.maxSize as newPercentSize and return calculate pixels remaining
199 /** @type {?} */
200 var maxSizePixel = areaSnapshot.area.maxSize / 100 * allAreasSizePixel;
201 return {
202 areaSnapshot: areaSnapshot,
203 pixelAbsorb: maxSizePixel,
204 percentAfterAbsorption: areaSnapshot.area.maxSize,
205 pixelRemain: areaSnapshot.sizePixelAtStart + pixels - maxSizePixel
206 };
207 }
208 return {
209 areaSnapshot: areaSnapshot,
210 pixelAbsorb: pixels,
211 percentAfterAbsorption: tempPercentSize > 100 ? 100 : tempPercentSize,
212 pixelRemain: 0
213 };
214 }
215 // REDUCE AREA
216 else if (pixels < 0) {
217 // If minSize & newSize smaller than it > absorb to min and return remaining pixels
218 if (areaSnapshot.area.minSize !== null && tempPercentSize < areaSnapshot.area.minSize) {
219 // Use area.area.minSize as newPercentSize and return calculate pixels remaining
220 /** @type {?} */
221 var minSizePixel = areaSnapshot.area.minSize / 100 * allAreasSizePixel;
222 return {
223 areaSnapshot: areaSnapshot,
224 pixelAbsorb: minSizePixel,
225 percentAfterAbsorption: areaSnapshot.area.minSize,
226 pixelRemain: areaSnapshot.sizePixelAtStart + pixels - minSizePixel
227 };
228 }
229 // If reduced under zero > return remaining pixels
230 else if (tempPercentSize < 0) {
231 // Use 0 as newPercentSize and return calculate pixels remaining
232 return {
233 areaSnapshot: areaSnapshot,
234 pixelAbsorb: -areaSnapshot.sizePixelAtStart,
235 percentAfterAbsorption: 0,
236 pixelRemain: pixels + areaSnapshot.sizePixelAtStart
237 };
238 }
239 return {
240 areaSnapshot: areaSnapshot,
241 pixelAbsorb: pixels,
242 percentAfterAbsorption: tempPercentSize,
243 pixelRemain: 0
244 };
245 }
246}
247/**
248 * @param {?} areaSnapshot
249 * @param {?} pixels
250 * @param {?} containerSizePixel
251 * @return {?}
252 */
253function getAreaAbsorptionCapacityPixel(areaSnapshot, pixels, containerSizePixel) {
254 /** @type {?} */
255 var tempPixelSize = areaSnapshot.sizePixelAtStart + pixels;
256 // ENLARGE AREA
257 if (pixels > 0) {
258 // If maxSize & newSize bigger than it > absorb to max and return remaining pixels
259 if (areaSnapshot.area.maxSize !== null && tempPixelSize > areaSnapshot.area.maxSize) {
260 return {
261 areaSnapshot: areaSnapshot,
262 pixelAbsorb: areaSnapshot.area.maxSize - areaSnapshot.sizePixelAtStart,
263 percentAfterAbsorption: -1,
264 pixelRemain: tempPixelSize - areaSnapshot.area.maxSize
265 };
266 }
267 return {
268 areaSnapshot: areaSnapshot,
269 pixelAbsorb: pixels,
270 percentAfterAbsorption: -1,
271 pixelRemain: 0
272 };
273 }
274 // REDUCE AREA
275 else if (pixels < 0) {
276 // If minSize & newSize smaller than it > absorb to min and return remaining pixels
277 if (areaSnapshot.area.minSize !== null && tempPixelSize < areaSnapshot.area.minSize) {
278 return {
279 areaSnapshot: areaSnapshot,
280 pixelAbsorb: areaSnapshot.area.minSize + pixels - tempPixelSize,
281 percentAfterAbsorption: -1,
282 pixelRemain: tempPixelSize - areaSnapshot.area.minSize
283 };
284 }
285 // If reduced under zero > return remaining pixels
286 else if (tempPixelSize < 0) {
287 return {
288 areaSnapshot: areaSnapshot,
289 pixelAbsorb: -areaSnapshot.sizePixelAtStart,
290 percentAfterAbsorption: -1,
291 pixelRemain: pixels + areaSnapshot.sizePixelAtStart
292 };
293 }
294 return {
295 areaSnapshot: areaSnapshot,
296 pixelAbsorb: pixels,
297 percentAfterAbsorption: -1,
298 pixelRemain: 0
299 };
300 }
301}
302/**
303 * @param {?} unit
304 * @param {?} item
305 * @return {?}
306 */
307function updateAreaSize(unit, item) {
308 if (unit === 'percent') {
309 item.areaSnapshot.area.size = item.percentAfterAbsorption;
310 }
311 else if (unit === 'pixel') {
312 // Update size except for the wildcard size area
313 if (item.areaSnapshot.area.size !== null) {
314 item.areaSnapshot.area.size = item.areaSnapshot.sizePixelAtStart + item.pixelAbsorb;
315 }
316 }
317}
318
319/**
320 * @fileoverview added by tsickle
321 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
322 */
323/**
324 * angular-split
325 *
326 *
327 * PERCENT MODE ([unit]="'percent'")
328 * ___________________________________________________________________________________________
329 * | A [g1] B [g2] C [g3] D [g4] E |
330 * |-------------------------------------------------------------------------------------------|
331 * | 20 30 20 15 15 | <-- [size]="x"
332 * | 10px 10px 10px 10px | <-- [gutterSize]="10"
333 * |calc(20% - 8px) calc(30% - 12px) calc(20% - 8px) calc(15% - 6px) calc(15% - 6px)| <-- CSS flex-basis property (with flex-grow&shrink at 0)
334 * | 152px 228px 152px 114px 114px | <-- el.getBoundingClientRect().width
335 * |___________________________________________________________________________________________|
336 * 800px <-- el.getBoundingClientRect().width
337 * flex-basis = calc( { area.size }% - { area.size/100 * nbGutter*gutterSize }px );
338 *
339 *
340 * PIXEL MODE ([unit]="'pixel'")
341 * ___________________________________________________________________________________________
342 * | A [g1] B [g2] C [g3] D [g4] E |
343 * |-------------------------------------------------------------------------------------------|
344 * | 100 250 * 150 100 | <-- [size]="y"
345 * | 10px 10px 10px 10px | <-- [gutterSize]="10"
346 * | 0 0 100px 0 0 250px 1 1 auto 0 0 150px 0 0 100px | <-- CSS flex property (flex-grow/flex-shrink/flex-basis)
347 * | 100px 250px 200px 150px 100px | <-- el.getBoundingClientRect().width
348 * |___________________________________________________________________________________________|
349 * 800px <-- el.getBoundingClientRect().width
350 *
351 */
352var SplitComponent = /** @class */ (function () {
353 function SplitComponent(ngZone, elRef, cdRef, renderer) {
354 this.ngZone = ngZone;
355 this.elRef = elRef;
356 this.cdRef = cdRef;
357 this.renderer = renderer;
358 this._direction = 'horizontal';
359 ////
360 this._unit = 'percent';
361 ////
362 this._gutterSize = 11;
363 ////
364 this._gutterStep = 1;
365 ////
366 this._restrictMove = false;
367 ////
368 this._useTransition = false;
369 ////
370 this._disabled = false;
371 ////
372 this._dir = 'ltr';
373 ////
374 this._gutterDblClickDuration = 0;
375 ////
376 this.dragStart = new EventEmitter(false);
377 this.dragEnd = new EventEmitter(false);
378 this.gutterClick = new EventEmitter(false);
379 this.gutterDblClick = new EventEmitter(false);
380 this.dragProgressSubject = new Subject();
381 this.dragProgress$ = this.dragProgressSubject.asObservable();
382 ////
383 this.isDragging = false;
384 this.dragListeners = [];
385 this.snapshot = null;
386 this.startPoint = null;
387 this.endPoint = null;
388 this.displayedAreas = [];
389 this.hidedAreas = [];
390 this._clickTimeout = null;
391 // To force adding default class, could be override by user @Input() or not
392 this.direction = this._direction;
393 }
394 Object.defineProperty(SplitComponent.prototype, "direction", {
395 get: /**
396 * @return {?}
397 */
398 function () {
399 return this._direction;
400 },
401 set: /**
402 * @param {?} v
403 * @return {?}
404 */
405 function (v) {
406 this._direction = (v === 'vertical') ? 'vertical' : 'horizontal';
407 this.renderer.addClass(this.elRef.nativeElement, "as-" + this._direction);
408 this.renderer.removeClass(this.elRef.nativeElement, "as-" + ((this._direction === 'vertical') ? 'horizontal' : 'vertical'));
409 this.build(false, false);
410 },
411 enumerable: true,
412 configurable: true
413 });
414 Object.defineProperty(SplitComponent.prototype, "unit", {
415 get: /**
416 * @return {?}
417 */
418 function () {
419 return this._unit;
420 },
421 set: /**
422 * @param {?} v
423 * @return {?}
424 */
425 function (v) {
426 this._unit = (v === 'pixel') ? 'pixel' : 'percent';
427 this.renderer.addClass(this.elRef.nativeElement, "as-" + this._unit);
428 this.renderer.removeClass(this.elRef.nativeElement, "as-" + ((this._unit === 'pixel') ? 'percent' : 'pixel'));
429 this.build(false, true);
430 },
431 enumerable: true,
432 configurable: true
433 });
434 Object.defineProperty(SplitComponent.prototype, "gutterSize", {
435 get: /**
436 * @return {?}
437 */
438 function () {
439 return this._gutterSize;
440 },
441 set: /**
442 * @param {?} v
443 * @return {?}
444 */
445 function (v) {
446 this._gutterSize = getInputPositiveNumber(v, 11);
447 this.build(false, false);
448 },
449 enumerable: true,
450 configurable: true
451 });
452 Object.defineProperty(SplitComponent.prototype, "gutterStep", {
453 get: /**
454 * @return {?}
455 */
456 function () {
457 return this._gutterStep;
458 },
459 set: /**
460 * @param {?} v
461 * @return {?}
462 */
463 function (v) {
464 this._gutterStep = getInputPositiveNumber(v, 1);
465 },
466 enumerable: true,
467 configurable: true
468 });
469 Object.defineProperty(SplitComponent.prototype, "restrictMove", {
470 get: /**
471 * @return {?}
472 */
473 function () {
474 return this._restrictMove;
475 },
476 set: /**
477 * @param {?} v
478 * @return {?}
479 */
480 function (v) {
481 this._restrictMove = getInputBoolean(v);
482 },
483 enumerable: true,
484 configurable: true
485 });
486 Object.defineProperty(SplitComponent.prototype, "useTransition", {
487 get: /**
488 * @return {?}
489 */
490 function () {
491 return this._useTransition;
492 },
493 set: /**
494 * @param {?} v
495 * @return {?}
496 */
497 function (v) {
498 this._useTransition = getInputBoolean(v);
499 if (this._useTransition)
500 this.renderer.addClass(this.elRef.nativeElement, 'as-transition');
501 else
502 this.renderer.removeClass(this.elRef.nativeElement, 'as-transition');
503 },
504 enumerable: true,
505 configurable: true
506 });
507 Object.defineProperty(SplitComponent.prototype, "disabled", {
508 get: /**
509 * @return {?}
510 */
511 function () {
512 return this._disabled;
513 },
514 set: /**
515 * @param {?} v
516 * @return {?}
517 */
518 function (v) {
519 this._disabled = getInputBoolean(v);
520 if (this._disabled)
521 this.renderer.addClass(this.elRef.nativeElement, 'as-disabled');
522 else
523 this.renderer.removeClass(this.elRef.nativeElement, 'as-disabled');
524 },
525 enumerable: true,
526 configurable: true
527 });
528 Object.defineProperty(SplitComponent.prototype, "dir", {
529 get: /**
530 * @return {?}
531 */
532 function () {
533 return this._dir;
534 },
535 set: /**
536 * @param {?} v
537 * @return {?}
538 */
539 function (v) {
540 this._dir = (v === 'rtl') ? 'rtl' : 'ltr';
541 this.renderer.setAttribute(this.elRef.nativeElement, 'dir', this._dir);
542 },
543 enumerable: true,
544 configurable: true
545 });
546 Object.defineProperty(SplitComponent.prototype, "gutterDblClickDuration", {
547 get: /**
548 * @return {?}
549 */
550 function () {
551 return this._gutterDblClickDuration;
552 },
553 set: /**
554 * @param {?} v
555 * @return {?}
556 */
557 function (v) {
558 this._gutterDblClickDuration = getInputPositiveNumber(v, 0);
559 },
560 enumerable: true,
561 configurable: true
562 });
563 Object.defineProperty(SplitComponent.prototype, "transitionEnd", {
564 get: /**
565 * @return {?}
566 */
567 function () {
568 var _this = this;
569 return new Observable((/**
570 * @param {?} subscriber
571 * @return {?}
572 */
573 function (subscriber) { return _this.transitionEndSubscriber = subscriber; })).pipe(debounceTime(20));
574 },
575 enumerable: true,
576 configurable: true
577 });
578 /**
579 * @return {?}
580 */
581 SplitComponent.prototype.ngAfterViewInit = /**
582 * @return {?}
583 */
584 function () {
585 var _this = this;
586 this.ngZone.runOutsideAngular((/**
587 * @return {?}
588 */
589 function () {
590 // To avoid transition at first rendering
591 setTimeout((/**
592 * @return {?}
593 */
594 function () { return _this.renderer.addClass(_this.elRef.nativeElement, 'as-init'); }));
595 }));
596 };
597 /**
598 * @private
599 * @return {?}
600 */
601 SplitComponent.prototype.getNbGutters = /**
602 * @private
603 * @return {?}
604 */
605 function () {
606 return (this.displayedAreas.length === 0) ? 0 : this.displayedAreas.length - 1;
607 };
608 /**
609 * @param {?} component
610 * @return {?}
611 */
612 SplitComponent.prototype.addArea = /**
613 * @param {?} component
614 * @return {?}
615 */
616 function (component) {
617 /** @type {?} */
618 var newArea = {
619 component: component,
620 order: 0,
621 size: 0,
622 minSize: null,
623 maxSize: null,
624 };
625 if (component.visible === true) {
626 this.displayedAreas.push(newArea);
627 this.build(true, true);
628 }
629 else {
630 this.hidedAreas.push(newArea);
631 }
632 };
633 /**
634 * @param {?} component
635 * @return {?}
636 */
637 SplitComponent.prototype.removeArea = /**
638 * @param {?} component
639 * @return {?}
640 */
641 function (component) {
642 if (this.displayedAreas.some((/**
643 * @param {?} a
644 * @return {?}
645 */
646 function (a) { return a.component === component; }))) {
647 /** @type {?} */
648 var area = this.displayedAreas.find((/**
649 * @param {?} a
650 * @return {?}
651 */
652 function (a) { return a.component === component; }));
653 this.displayedAreas.splice(this.displayedAreas.indexOf(area), 1);
654 this.build(true, true);
655 }
656 else if (this.hidedAreas.some((/**
657 * @param {?} a
658 * @return {?}
659 */
660 function (a) { return a.component === component; }))) {
661 /** @type {?} */
662 var area = this.hidedAreas.find((/**
663 * @param {?} a
664 * @return {?}
665 */
666 function (a) { return a.component === component; }));
667 this.hidedAreas.splice(this.hidedAreas.indexOf(area), 1);
668 }
669 };
670 /**
671 * @param {?} component
672 * @param {?} resetOrders
673 * @param {?} resetSizes
674 * @return {?}
675 */
676 SplitComponent.prototype.updateArea = /**
677 * @param {?} component
678 * @param {?} resetOrders
679 * @param {?} resetSizes
680 * @return {?}
681 */
682 function (component, resetOrders, resetSizes) {
683 if (component.visible === true) {
684 this.build(resetOrders, resetSizes);
685 }
686 };
687 /**
688 * @param {?} component
689 * @return {?}
690 */
691 SplitComponent.prototype.showArea = /**
692 * @param {?} component
693 * @return {?}
694 */
695 function (component) {
696 var _a;
697 /** @type {?} */
698 var area = this.hidedAreas.find((/**
699 * @param {?} a
700 * @return {?}
701 */
702 function (a) { return a.component === component; }));
703 if (area === undefined) {
704 return;
705 }
706 /** @type {?} */
707 var areas = this.hidedAreas.splice(this.hidedAreas.indexOf(area), 1);
708 (_a = this.displayedAreas).push.apply(_a, __spread(areas));
709 this.build(true, true);
710 };
711 /**
712 * @param {?} comp
713 * @return {?}
714 */
715 SplitComponent.prototype.hideArea = /**
716 * @param {?} comp
717 * @return {?}
718 */
719 function (comp) {
720 var _a;
721 /** @type {?} */
722 var area = this.displayedAreas.find((/**
723 * @param {?} a
724 * @return {?}
725 */
726 function (a) { return a.component === comp; }));
727 if (area === undefined) {
728 return;
729 }
730 /** @type {?} */
731 var areas = this.displayedAreas.splice(this.displayedAreas.indexOf(area), 1);
732 areas.forEach((/**
733 * @param {?} area
734 * @return {?}
735 */
736 function (area) {
737 area.order = 0;
738 area.size = 0;
739 }));
740 (_a = this.hidedAreas).push.apply(_a, __spread(areas));
741 this.build(true, true);
742 };
743 /**
744 * @return {?}
745 */
746 SplitComponent.prototype.getVisibleAreaSizes = /**
747 * @return {?}
748 */
749 function () {
750 return this.displayedAreas.map((/**
751 * @param {?} a
752 * @return {?}
753 */
754 function (a) { return a.size === null ? '*' : a.size; }));
755 };
756 /**
757 * @param {?} sizes
758 * @return {?}
759 */
760 SplitComponent.prototype.setVisibleAreaSizes = /**
761 * @param {?} sizes
762 * @return {?}
763 */
764 function (sizes) {
765 if (sizes.length !== this.displayedAreas.length) {
766 return false;
767 }
768 /** @type {?} */
769 var formatedSizes = sizes.map((/**
770 * @param {?} s
771 * @return {?}
772 */
773 function (s) { return getInputPositiveNumber(s, null); }));
774 /** @type {?} */
775 var isValid = isUserSizesValid(this.unit, formatedSizes);
776 if (isValid === false) {
777 return false;
778 }
779 // @ts-ignore
780 this.displayedAreas.forEach((/**
781 * @param {?} area
782 * @param {?} i
783 * @return {?}
784 */
785 function (area, i) { return area.component._size = formatedSizes[i]; }));
786 this.build(false, true);
787 return true;
788 };
789 /**
790 * @private
791 * @param {?} resetOrders
792 * @param {?} resetSizes
793 * @return {?}
794 */
795 SplitComponent.prototype.build = /**
796 * @private
797 * @param {?} resetOrders
798 * @param {?} resetSizes
799 * @return {?}
800 */
801 function (resetOrders, resetSizes) {
802 this.stopDragging();
803 // ¤ AREAS ORDER
804 if (resetOrders === true) {
805 // If user provided 'order' for each area, use it to sort them.
806 if (this.displayedAreas.every((/**
807 * @param {?} a
808 * @return {?}
809 */
810 function (a) { return a.component.order !== null; }))) {
811 this.displayedAreas.sort((/**
812 * @param {?} a
813 * @param {?} b
814 * @return {?}
815 */
816 function (a, b) { return ((/** @type {?} */ (a.component.order))) - ((/** @type {?} */ (b.component.order))); }));
817 }
818 // Then set real order with multiples of 2, numbers between will be used by gutters.
819 this.displayedAreas.forEach((/**
820 * @param {?} area
821 * @param {?} i
822 * @return {?}
823 */
824 function (area, i) {
825 area.order = i * 2;
826 area.component.setStyleOrder(area.order);
827 }));
828 }
829 // ¤ AREAS SIZE
830 if (resetSizes === true) {
831 /** @type {?} */
832 var useUserSizes_1 = isUserSizesValid(this.unit, this.displayedAreas.map((/**
833 * @param {?} a
834 * @return {?}
835 */
836 function (a) { return a.component.size; })));
837 switch (this.unit) {
838 case 'percent': {
839 /** @type {?} */
840 var defaultSize_1 = 100 / this.displayedAreas.length;
841 this.displayedAreas.forEach((/**
842 * @param {?} area
843 * @return {?}
844 */
845 function (area) {
846 area.size = useUserSizes_1 ? (/** @type {?} */ (area.component.size)) : defaultSize_1;
847 area.minSize = getAreaMinSize(area);
848 area.maxSize = getAreaMaxSize(area);
849 }));
850 break;
851 }
852 case 'pixel': {
853 if (useUserSizes_1) {
854 this.displayedAreas.forEach((/**
855 * @param {?} area
856 * @return {?}
857 */
858 function (area) {
859 area.size = area.component.size;
860 area.minSize = getAreaMinSize(area);
861 area.maxSize = getAreaMaxSize(area);
862 }));
863 }
864 else {
865 /** @type {?} */
866 var wildcardSizeAreas = this.displayedAreas.filter((/**
867 * @param {?} a
868 * @return {?}
869 */
870 function (a) { return a.component.size === null; }));
871 // No wildcard area > Need to select one arbitrarily > first
872 if (wildcardSizeAreas.length === 0 && this.displayedAreas.length > 0) {
873 this.displayedAreas.forEach((/**
874 * @param {?} area
875 * @param {?} i
876 * @return {?}
877 */
878 function (area, i) {
879 area.size = (i === 0) ? null : area.component.size;
880 area.minSize = (i === 0) ? null : getAreaMinSize(area);
881 area.maxSize = (i === 0) ? null : getAreaMaxSize(area);
882 }));
883 }
884 // More than one wildcard area > Need to keep only one arbitrarly > first
885 else if (wildcardSizeAreas.length > 1) {
886 /** @type {?} */
887 var alreadyGotOne_1 = false;
888 this.displayedAreas.forEach((/**
889 * @param {?} area
890 * @return {?}
891 */
892 function (area) {
893 if (area.component.size === null) {
894 if (alreadyGotOne_1 === false) {
895 area.size = null;
896 area.minSize = null;
897 area.maxSize = null;
898 alreadyGotOne_1 = true;
899 }
900 else {
901 area.size = 100;
902 area.minSize = null;
903 area.maxSize = null;
904 }
905 }
906 else {
907 area.size = area.component.size;
908 area.minSize = getAreaMinSize(area);
909 area.maxSize = getAreaMaxSize(area);
910 }
911 }));
912 }
913 }
914 break;
915 }
916 }
917 }
918 this.refreshStyleSizes();
919 this.cdRef.markForCheck();
920 };
921 /**
922 * @private
923 * @return {?}
924 */
925 SplitComponent.prototype.refreshStyleSizes = /**
926 * @private
927 * @return {?}
928 */
929 function () {
930 var _this = this;
931 ///////////////////////////////////////////
932 // PERCENT MODE
933 if (this.unit === 'percent') {
934 // Only one area > flex-basis 100%
935 if (this.displayedAreas.length === 1) {
936 this.displayedAreas[0].component.setStyleFlex(0, 0, "100%", false, false);
937 }
938 // Multiple areas > use each percent basis
939 else {
940 /** @type {?} */
941 var sumGutterSize_1 = this.getNbGutters() * this.gutterSize;
942 this.displayedAreas.forEach((/**
943 * @param {?} area
944 * @return {?}
945 */
946 function (area) {
947 area.component.setStyleFlex(0, 0, "calc( " + area.size + "% - " + (/** @type {?} */ (area.size)) / 100 * sumGutterSize_1 + "px )", (area.minSize !== null && area.minSize === area.size) ? true : false, (area.maxSize !== null && area.maxSize === area.size) ? true : false);
948 }));
949 }
950 }
951 ///////////////////////////////////////////
952 // PIXEL MODE
953 else if (this.unit === 'pixel') {
954 this.displayedAreas.forEach((/**
955 * @param {?} area
956 * @return {?}
957 */
958 function (area) {
959 // Area with wildcard size
960 if (area.size === null) {
961 if (_this.displayedAreas.length === 1) {
962 area.component.setStyleFlex(1, 1, "100%", false, false);
963 }
964 else {
965 area.component.setStyleFlex(1, 1, "auto", false, false);
966 }
967 }
968 // Area with pixel size
969 else {
970 // Only one area > flex-basis 100%
971 if (_this.displayedAreas.length === 1) {
972 area.component.setStyleFlex(0, 0, "100%", false, false);
973 }
974 // Multiple areas > use each pixel basis
975 else {
976 area.component.setStyleFlex(0, 0, area.size + "px", (area.minSize !== null && area.minSize === area.size) ? true : false, (area.maxSize !== null && area.maxSize === area.size) ? true : false);
977 }
978 }
979 }));
980 }
981 };
982 /**
983 * @param {?} event
984 * @param {?} gutterNum
985 * @return {?}
986 */
987 SplitComponent.prototype.clickGutter = /**
988 * @param {?} event
989 * @param {?} gutterNum
990 * @return {?}
991 */
992 function (event, gutterNum) {
993 var _this = this;
994 /** @type {?} */
995 var tempPoint = getPointFromEvent(event);
996 // Be sure mouseup/touchend happened at same point as mousedown/touchstart to trigger click/dblclick
997 if (this.startPoint && this.startPoint.x === tempPoint.x && this.startPoint.y === tempPoint.y) {
998 // If timeout in progress and new click > clearTimeout & dblClickEvent
999 if (this._clickTimeout !== null) {
1000 window.clearTimeout(this._clickTimeout);
1001 this._clickTimeout = null;
1002 this.notify('dblclick', gutterNum);
1003 this.stopDragging();
1004 }
1005 // Else start timeout to call clickEvent at end
1006 else {
1007 this._clickTimeout = window.setTimeout((/**
1008 * @return {?}
1009 */
1010 function () {
1011 _this._clickTimeout = null;
1012 _this.notify('click', gutterNum);
1013 _this.stopDragging();
1014 }), this.gutterDblClickDuration);
1015 }
1016 }
1017 };
1018 /**
1019 * @param {?} event
1020 * @param {?} gutterOrder
1021 * @param {?} gutterNum
1022 * @return {?}
1023 */
1024 SplitComponent.prototype.startDragging = /**
1025 * @param {?} event
1026 * @param {?} gutterOrder
1027 * @param {?} gutterNum
1028 * @return {?}
1029 */
1030 function (event, gutterOrder, gutterNum) {
1031 var _this = this;
1032 event.preventDefault();
1033 event.stopPropagation();
1034 this.startPoint = getPointFromEvent(event);
1035 if (this.startPoint === null || this.disabled === true) {
1036 return;
1037 }
1038 this.snapshot = {
1039 gutterNum: gutterNum,
1040 lastSteppedOffset: 0,
1041 allAreasSizePixel: getElementPixelSize(this.elRef, this.direction) - this.getNbGutters() * this.gutterSize,
1042 allInvolvedAreasSizePercent: 100,
1043 areasBeforeGutter: [],
1044 areasAfterGutter: [],
1045 };
1046 this.displayedAreas.forEach((/**
1047 * @param {?} area
1048 * @return {?}
1049 */
1050 function (area) {
1051 /** @type {?} */
1052 var areaSnapshot = {
1053 area: area,
1054 sizePixelAtStart: getElementPixelSize(area.component.elRef, _this.direction),
1055 sizePercentAtStart: (_this.unit === 'percent') ? area.size : -1 // If pixel mode, anyway, will not be used.
1056 };
1057 if (area.order < gutterOrder) {
1058 if (_this.restrictMove === true) {
1059 _this.snapshot.areasBeforeGutter = [areaSnapshot];
1060 }
1061 else {
1062 _this.snapshot.areasBeforeGutter.unshift(areaSnapshot);
1063 }
1064 }
1065 else if (area.order > gutterOrder) {
1066 if (_this.restrictMove === true) {
1067 if (_this.snapshot.areasAfterGutter.length === 0)
1068 _this.snapshot.areasAfterGutter = [areaSnapshot];
1069 }
1070 else {
1071 _this.snapshot.areasAfterGutter.push(areaSnapshot);
1072 }
1073 }
1074 }));
1075 this.snapshot.allInvolvedAreasSizePercent = __spread(this.snapshot.areasBeforeGutter, this.snapshot.areasAfterGutter).reduce((/**
1076 * @param {?} t
1077 * @param {?} a
1078 * @return {?}
1079 */
1080 function (t, a) { return t + a.sizePercentAtStart; }), 0);
1081 if (this.snapshot.areasBeforeGutter.length === 0 || this.snapshot.areasAfterGutter.length === 0) {
1082 return;
1083 }
1084 this.dragListeners.push(this.renderer.listen('document', 'mouseup', this.stopDragging.bind(this)));
1085 this.dragListeners.push(this.renderer.listen('document', 'touchend', this.stopDragging.bind(this)));
1086 this.dragListeners.push(this.renderer.listen('document', 'touchcancel', this.stopDragging.bind(this)));
1087 this.ngZone.runOutsideAngular((/**
1088 * @return {?}
1089 */
1090 function () {
1091 _this.dragListeners.push(_this.renderer.listen('document', 'mousemove', _this.dragEvent.bind(_this)));
1092 _this.dragListeners.push(_this.renderer.listen('document', 'touchmove', _this.dragEvent.bind(_this)));
1093 }));
1094 this.displayedAreas.forEach((/**
1095 * @param {?} area
1096 * @return {?}
1097 */
1098 function (area) { return area.component.lockEvents(); }));
1099 this.isDragging = true;
1100 this.renderer.addClass(this.elRef.nativeElement, 'as-dragging');
1101 this.renderer.addClass(this.gutterEls.toArray()[this.snapshot.gutterNum - 1].nativeElement, 'as-dragged');
1102 this.notify('start', this.snapshot.gutterNum);
1103 };
1104 /**
1105 * @private
1106 * @param {?} event
1107 * @return {?}
1108 */
1109 SplitComponent.prototype.dragEvent = /**
1110 * @private
1111 * @param {?} event
1112 * @return {?}
1113 */
1114 function (event) {
1115 var _this = this;
1116 event.preventDefault();
1117 event.stopPropagation();
1118 if (this._clickTimeout !== null) {
1119 window.clearTimeout(this._clickTimeout);
1120 this._clickTimeout = null;
1121 }
1122 if (this.isDragging === false) {
1123 return;
1124 }
1125 this.endPoint = getPointFromEvent(event);
1126 if (this.endPoint === null) {
1127 return;
1128 }
1129 // Calculate steppedOffset
1130 /** @type {?} */
1131 var offset = (this.direction === 'horizontal') ? (this.startPoint.x - this.endPoint.x) : (this.startPoint.y - this.endPoint.y);
1132 if (this.dir === 'rtl') {
1133 offset = -offset;
1134 }
1135 /** @type {?} */
1136 var steppedOffset = Math.round(offset / this.gutterStep) * this.gutterStep;
1137 if (steppedOffset === this.snapshot.lastSteppedOffset) {
1138 return;
1139 }
1140 this.snapshot.lastSteppedOffset = steppedOffset;
1141 // Need to know if each gutter side areas could reacts to steppedOffset
1142 /** @type {?} */
1143 var areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -steppedOffset, this.snapshot.allAreasSizePixel);
1144 /** @type {?} */
1145 var areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset, this.snapshot.allAreasSizePixel);
1146 // Each gutter side areas can't absorb all offset
1147 if (areasBefore.remain !== 0 && areasAfter.remain !== 0) {
1148 if (Math.abs(areasBefore.remain) === Math.abs(areasAfter.remain)) ;
1149 else if (Math.abs(areasBefore.remain) > Math.abs(areasAfter.remain)) {
1150 areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset + areasBefore.remain, this.snapshot.allAreasSizePixel);
1151 }
1152 else {
1153 areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -(steppedOffset - areasAfter.remain), this.snapshot.allAreasSizePixel);
1154 }
1155 }
1156 // Areas before gutter can't absorbs all offset > need to recalculate sizes for areas after gutter.
1157 else if (areasBefore.remain !== 0) {
1158 areasAfter = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasAfterGutter, steppedOffset + areasBefore.remain, this.snapshot.allAreasSizePixel);
1159 }
1160 // Areas after gutter can't absorbs all offset > need to recalculate sizes for areas before gutter.
1161 else if (areasAfter.remain !== 0) {
1162 areasBefore = getGutterSideAbsorptionCapacity(this.unit, this.snapshot.areasBeforeGutter, -(steppedOffset - areasAfter.remain), this.snapshot.allAreasSizePixel);
1163 }
1164 if (this.unit === 'percent') {
1165 // Hack because of browser messing up with sizes using calc(X% - Ypx) -> el.getBoundingClientRect()
1166 // If not there, playing with gutters makes total going down to 99.99875% then 99.99286%, 99.98986%,..
1167 /** @type {?} */
1168 var all = __spread(areasBefore.list, areasAfter.list);
1169 /** @type {?} */
1170 var areaToReset_1 = all.find((/**
1171 * @param {?} a
1172 * @return {?}
1173 */
1174 function (a) { return a.percentAfterAbsorption !== 0 && a.percentAfterAbsorption !== a.areaSnapshot.area.minSize && a.percentAfterAbsorption !== a.areaSnapshot.area.maxSize; }));
1175 if (areaToReset_1) {
1176 areaToReset_1.percentAfterAbsorption = this.snapshot.allInvolvedAreasSizePercent - all.filter((/**
1177 * @param {?} a
1178 * @return {?}
1179 */
1180 function (a) { return a !== areaToReset_1; })).reduce((/**
1181 * @param {?} total
1182 * @param {?} a
1183 * @return {?}
1184 */
1185 function (total, a) { return total + a.percentAfterAbsorption; }), 0);
1186 }
1187 }
1188 // Now we know areas could absorb steppedOffset, time to really update sizes
1189 areasBefore.list.forEach((/**
1190 * @param {?} item
1191 * @return {?}
1192 */
1193 function (item) { return updateAreaSize(_this.unit, item); }));
1194 areasAfter.list.forEach((/**
1195 * @param {?} item
1196 * @return {?}
1197 */
1198 function (item) { return updateAreaSize(_this.unit, item); }));
1199 this.refreshStyleSizes();
1200 this.notify('progress', this.snapshot.gutterNum);
1201 };
1202 /**
1203 * @private
1204 * @param {?=} event
1205 * @return {?}
1206 */
1207 SplitComponent.prototype.stopDragging = /**
1208 * @private
1209 * @param {?=} event
1210 * @return {?}
1211 */
1212 function (event) {
1213 var _this = this;
1214 if (event) {
1215 event.preventDefault();
1216 event.stopPropagation();
1217 }
1218 if (this.isDragging === false) {
1219 return;
1220 }
1221 this.displayedAreas.forEach((/**
1222 * @param {?} area
1223 * @return {?}
1224 */
1225 function (area) { return area.component.unlockEvents(); }));
1226 while (this.dragListeners.length > 0) {
1227 /** @type {?} */
1228 var fct = this.dragListeners.pop();
1229 if (fct)
1230 fct();
1231 }
1232 // Warning: Have to be before "notify('end')"
1233 // because "notify('end')"" can be linked to "[size]='x'" > "build()" > "stopDragging()"
1234 this.isDragging = false;
1235 // If moved from starting point, notify end
1236 if (this.endPoint && (this.startPoint.x !== this.endPoint.x || this.startPoint.y !== this.endPoint.y)) {
1237 this.notify('end', this.snapshot.gutterNum);
1238 }
1239 this.renderer.removeClass(this.elRef.nativeElement, 'as-dragging');
1240 this.renderer.removeClass(this.gutterEls.toArray()[this.snapshot.gutterNum - 1].nativeElement, 'as-dragged');
1241 this.snapshot = null;
1242 // Needed to let (click)="clickGutter(...)" event run and verify if mouse moved or not
1243 this.ngZone.runOutsideAngular((/**
1244 * @return {?}
1245 */
1246 function () {
1247 setTimeout((/**
1248 * @return {?}
1249 */
1250 function () {
1251 _this.startPoint = null;
1252 _this.endPoint = null;
1253 }));
1254 }));
1255 };
1256 /**
1257 * @param {?} type
1258 * @param {?} gutterNum
1259 * @return {?}
1260 */
1261 SplitComponent.prototype.notify = /**
1262 * @param {?} type
1263 * @param {?} gutterNum
1264 * @return {?}
1265 */
1266 function (type, gutterNum) {
1267 var _this = this;
1268 /** @type {?} */
1269 var sizes = this.getVisibleAreaSizes();
1270 if (type === 'start') {
1271 this.dragStart.emit({ gutterNum: gutterNum, sizes: sizes });
1272 }
1273 else if (type === 'end') {
1274 this.dragEnd.emit({ gutterNum: gutterNum, sizes: sizes });
1275 }
1276 else if (type === 'click') {
1277 this.gutterClick.emit({ gutterNum: gutterNum, sizes: sizes });
1278 }
1279 else if (type === 'dblclick') {
1280 this.gutterDblClick.emit({ gutterNum: gutterNum, sizes: sizes });
1281 }
1282 else if (type === 'transitionEnd') {
1283 if (this.transitionEndSubscriber) {
1284 this.ngZone.run((/**
1285 * @return {?}
1286 */
1287 function () { return _this.transitionEndSubscriber.next(sizes); }));
1288 }
1289 }
1290 else if (type === 'progress') {
1291 // Stay outside zone to allow users do what they want about change detection mechanism.
1292 this.dragProgressSubject.next({ gutterNum: gutterNum, sizes: sizes });
1293 }
1294 };
1295 /**
1296 * @return {?}
1297 */
1298 SplitComponent.prototype.ngOnDestroy = /**
1299 * @return {?}
1300 */
1301 function () {
1302 this.stopDragging();
1303 };
1304 SplitComponent.decorators = [
1305 { type: Component, args: [{
1306 selector: 'as-split',
1307 exportAs: 'asSplit',
1308 changeDetection: ChangeDetectionStrategy.OnPush,
1309 template: "\n <ng-content></ng-content>\n <ng-template ngFor [ngForOf]=\"displayedAreas\" let-index=\"index\" let-last=\"last\">\n <div *ngIf=\"last === false\" \n #gutterEls\n class=\"as-split-gutter\"\n [style.flex-basis.px]=\"gutterSize\"\n [style.order]=\"index*2+1\"\n (mousedown)=\"startDragging($event, index*2+1, index+1)\"\n (touchstart)=\"startDragging($event, index*2+1, index+1)\"\n (mouseup)=\"clickGutter($event, index+1)\"\n (touchend)=\"clickGutter($event, index+1)\">\n <div class=\"as-split-gutter-icon\"></div>\n </div>\n </ng-template>",
1310 styles: [":host{display:flex;flex-wrap:nowrap;justify-content:flex-start;align-items:stretch;overflow:hidden;width:100%;height:100%}:host>.as-split-gutter{flex-grow:0;flex-shrink:0;background-color:#eee;display:flex;align-items:center;justify-content:center}:host>.as-split-gutter>.as-split-gutter-icon{width:100%;height:100%;background-position:center center;background-repeat:no-repeat}:host ::ng-deep>.as-split-area{flex-grow:0;flex-shrink:0;overflow-x:hidden;overflow-y:auto}:host ::ng-deep>.as-split-area.as-hidden{flex:0 1 0!important;overflow-x:hidden;overflow-y:hidden}:host.as-horizontal{flex-direction:row}:host.as-horizontal>.as-split-gutter{flex-direction:row;cursor:col-resize;height:100%}:host.as-horizontal>.as-split-gutter>.as-split-gutter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg==)}:host.as-horizontal ::ng-deep>.as-split-area{height:100%}:host.as-vertical{flex-direction:column}:host.as-vertical>.as-split-gutter{flex-direction:column;cursor:row-resize;width:100%}:host.as-vertical>.as-split-gutter .as-split-gutter-icon{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAFCAMAAABl/6zIAAAABlBMVEUAAADMzMzIT8AyAAAAAXRSTlMAQObYZgAAABRJREFUeAFjYGRkwIMJSeMHlBkOABP7AEGzSuPKAAAAAElFTkSuQmCC)}:host.as-vertical ::ng-deep>.as-split-area{width:100%}:host.as-vertical ::ng-deep>.as-split-area.as-hidden{max-width:0}:host.as-disabled>.as-split-gutter{cursor:default}:host.as-disabled>.as-split-gutter .as-split-gutter-icon{background-image:url(\"\")}:host.as-transition.as-init:not(.as-dragging) ::ng-deep>.as-split-area,:host.as-transition.as-init:not(.as-dragging)>.as-split-gutter{transition:flex-basis .3s}"]
1311 }] }
1312 ];
1313 /** @nocollapse */
1314 SplitComponent.ctorParameters = function () { return [
1315 { type: NgZone },
1316 { type: ElementRef },
1317 { type: ChangeDetectorRef },
1318 { type: Renderer2 }
1319 ]; };
1320 SplitComponent.propDecorators = {
1321 direction: [{ type: Input }],
1322 unit: [{ type: Input }],
1323 gutterSize: [{ type: Input }],
1324 gutterStep: [{ type: Input }],
1325 restrictMove: [{ type: Input }],
1326 useTransition: [{ type: Input }],
1327 disabled: [{ type: Input }],
1328 dir: [{ type: Input }],
1329 gutterDblClickDuration: [{ type: Input }],
1330 dragStart: [{ type: Output }],
1331 dragEnd: [{ type: Output }],
1332 gutterClick: [{ type: Output }],
1333 gutterDblClick: [{ type: Output }],
1334 transitionEnd: [{ type: Output }],
1335 gutterEls: [{ type: ViewChildren, args: ['gutterEls',] }]
1336 };
1337 return SplitComponent;
1338}());
1339
1340/**
1341 * @fileoverview added by tsickle
1342 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1343 */
1344var SplitAreaDirective = /** @class */ (function () {
1345 function SplitAreaDirective(ngZone, elRef, renderer, split) {
1346 this.ngZone = ngZone;
1347 this.elRef = elRef;
1348 this.renderer = renderer;
1349 this.split = split;
1350 this._order = null;
1351 ////
1352 this._size = null;
1353 ////
1354 this._minSize = null;
1355 ////
1356 this._maxSize = null;
1357 ////
1358 this._lockSize = false;
1359 ////
1360 this._visible = true;
1361 this.lockListeners = [];
1362 this.renderer.addClass(this.elRef.nativeElement, 'as-split-area');
1363 }
1364 Object.defineProperty(SplitAreaDirective.prototype, "order", {
1365 get: /**
1366 * @return {?}
1367 */
1368 function () {
1369 return this._order;
1370 },
1371 set: /**
1372 * @param {?} v
1373 * @return {?}
1374 */
1375 function (v) {
1376 this._order = getInputPositiveNumber(v, null);
1377 this.split.updateArea(this, true, false);
1378 },
1379 enumerable: true,
1380 configurable: true
1381 });
1382 Object.defineProperty(SplitAreaDirective.prototype, "size", {
1383 get: /**
1384 * @return {?}
1385 */
1386 function () {
1387 return this._size;
1388 },
1389 set: /**
1390 * @param {?} v
1391 * @return {?}
1392 */
1393 function (v) {
1394 this._size = getInputPositiveNumber(v, null);
1395 this.split.updateArea(this, false, true);
1396 },
1397 enumerable: true,
1398 configurable: true
1399 });
1400 Object.defineProperty(SplitAreaDirective.prototype, "minSize", {
1401 get: /**
1402 * @return {?}
1403 */
1404 function () {
1405 return this._minSize;
1406 },
1407 set: /**
1408 * @param {?} v
1409 * @return {?}
1410 */
1411 function (v) {
1412 this._minSize = getInputPositiveNumber(v, null);
1413 this.split.updateArea(this, false, true);
1414 },
1415 enumerable: true,
1416 configurable: true
1417 });
1418 Object.defineProperty(SplitAreaDirective.prototype, "maxSize", {
1419 get: /**
1420 * @return {?}
1421 */
1422 function () {
1423 return this._maxSize;
1424 },
1425 set: /**
1426 * @param {?} v
1427 * @return {?}
1428 */
1429 function (v) {
1430 this._maxSize = getInputPositiveNumber(v, null);
1431 this.split.updateArea(this, false, true);
1432 },
1433 enumerable: true,
1434 configurable: true
1435 });
1436 Object.defineProperty(SplitAreaDirective.prototype, "lockSize", {
1437 get: /**
1438 * @return {?}
1439 */
1440 function () {
1441 return this._lockSize;
1442 },
1443 set: /**
1444 * @param {?} v
1445 * @return {?}
1446 */
1447 function (v) {
1448 this._lockSize = getInputBoolean(v);
1449 this.split.updateArea(this, false, true);
1450 },
1451 enumerable: true,
1452 configurable: true
1453 });
1454 Object.defineProperty(SplitAreaDirective.prototype, "visible", {
1455 get: /**
1456 * @return {?}
1457 */
1458 function () {
1459 return this._visible;
1460 },
1461 set: /**
1462 * @param {?} v
1463 * @return {?}
1464 */
1465 function (v) {
1466 this._visible = getInputBoolean(v);
1467 if (this._visible) {
1468 this.split.showArea(this);
1469 this.renderer.removeClass(this.elRef.nativeElement, 'as-hidden');
1470 }
1471 else {
1472 this.split.hideArea(this);
1473 this.renderer.addClass(this.elRef.nativeElement, 'as-hidden');
1474 }
1475 },
1476 enumerable: true,
1477 configurable: true
1478 });
1479 /**
1480 * @return {?}
1481 */
1482 SplitAreaDirective.prototype.ngOnInit = /**
1483 * @return {?}
1484 */
1485 function () {
1486 var _this = this;
1487 this.split.addArea(this);
1488 this.ngZone.runOutsideAngular((/**
1489 * @return {?}
1490 */
1491 function () {
1492 _this.transitionListener = _this.renderer.listen(_this.elRef.nativeElement, 'transitionend', (/**
1493 * @param {?} event
1494 * @return {?}
1495 */
1496 function (event) {
1497 // Limit only flex-basis transition to trigger the event
1498 if (event.propertyName === 'flex-basis') {
1499 _this.split.notify('transitionEnd', -1);
1500 }
1501 }));
1502 }));
1503 };
1504 /**
1505 * @param {?} value
1506 * @return {?}
1507 */
1508 SplitAreaDirective.prototype.setStyleOrder = /**
1509 * @param {?} value
1510 * @return {?}
1511 */
1512 function (value) {
1513 this.renderer.setStyle(this.elRef.nativeElement, 'order', value);
1514 };
1515 /**
1516 * @param {?} grow
1517 * @param {?} shrink
1518 * @param {?} basis
1519 * @param {?} isMin
1520 * @param {?} isMax
1521 * @return {?}
1522 */
1523 SplitAreaDirective.prototype.setStyleFlex = /**
1524 * @param {?} grow
1525 * @param {?} shrink
1526 * @param {?} basis
1527 * @param {?} isMin
1528 * @param {?} isMax
1529 * @return {?}
1530 */
1531 function (grow, shrink, basis, isMin, isMax) {
1532 // Need 3 separated properties to work on IE11 (https://github.com/angular/flex-layout/issues/323)
1533 this.renderer.setStyle(this.elRef.nativeElement, 'flex-grow', grow);
1534 this.renderer.setStyle(this.elRef.nativeElement, 'flex-shrink', shrink);
1535 this.renderer.setStyle(this.elRef.nativeElement, 'flex-basis', basis);
1536 if (isMin === true)
1537 this.renderer.addClass(this.elRef.nativeElement, 'as-min');
1538 else
1539 this.renderer.removeClass(this.elRef.nativeElement, 'as-min');
1540 if (isMax === true)
1541 this.renderer.addClass(this.elRef.nativeElement, 'as-max');
1542 else
1543 this.renderer.removeClass(this.elRef.nativeElement, 'as-max');
1544 };
1545 /**
1546 * @return {?}
1547 */
1548 SplitAreaDirective.prototype.lockEvents = /**
1549 * @return {?}
1550 */
1551 function () {
1552 var _this = this;
1553 this.ngZone.runOutsideAngular((/**
1554 * @return {?}
1555 */
1556 function () {
1557 _this.lockListeners.push(_this.renderer.listen(_this.elRef.nativeElement, 'selectstart', (/**
1558 * @param {?} e
1559 * @return {?}
1560 */
1561 function (e) { return false; })));
1562 _this.lockListeners.push(_this.renderer.listen(_this.elRef.nativeElement, 'dragstart', (/**
1563 * @param {?} e
1564 * @return {?}
1565 */
1566 function (e) { return false; })));
1567 }));
1568 };
1569 /**
1570 * @return {?}
1571 */
1572 SplitAreaDirective.prototype.unlockEvents = /**
1573 * @return {?}
1574 */
1575 function () {
1576 while (this.lockListeners.length > 0) {
1577 /** @type {?} */
1578 var fct = this.lockListeners.pop();
1579 if (fct)
1580 fct();
1581 }
1582 };
1583 /**
1584 * @return {?}
1585 */
1586 SplitAreaDirective.prototype.ngOnDestroy = /**
1587 * @return {?}
1588 */
1589 function () {
1590 this.unlockEvents();
1591 if (this.transitionListener) {
1592 this.transitionListener();
1593 }
1594 this.split.removeArea(this);
1595 };
1596 SplitAreaDirective.decorators = [
1597 { type: Directive, args: [{
1598 selector: 'as-split-area, [as-split-area]',
1599 exportAs: 'asSplitArea'
1600 },] }
1601 ];
1602 /** @nocollapse */
1603 SplitAreaDirective.ctorParameters = function () { return [
1604 { type: NgZone },
1605 { type: ElementRef },
1606 { type: Renderer2 },
1607 { type: SplitComponent }
1608 ]; };
1609 SplitAreaDirective.propDecorators = {
1610 order: [{ type: Input }],
1611 size: [{ type: Input }],
1612 minSize: [{ type: Input }],
1613 maxSize: [{ type: Input }],
1614 lockSize: [{ type: Input }],
1615 visible: [{ type: Input }]
1616 };
1617 return SplitAreaDirective;
1618}());
1619
1620/**
1621 * @fileoverview added by tsickle
1622 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1623 */
1624var AngularSplitModule = /** @class */ (function () {
1625 function AngularSplitModule() {
1626 }
1627 /**
1628 * @return {?}
1629 */
1630 AngularSplitModule.forRoot = /**
1631 * @return {?}
1632 */
1633 function () {
1634 return {
1635 ngModule: AngularSplitModule,
1636 providers: []
1637 };
1638 };
1639 /**
1640 * @return {?}
1641 */
1642 AngularSplitModule.forChild = /**
1643 * @return {?}
1644 */
1645 function () {
1646 return {
1647 ngModule: AngularSplitModule,
1648 providers: []
1649 };
1650 };
1651 AngularSplitModule.decorators = [
1652 { type: NgModule, args: [{
1653 imports: [
1654 CommonModule
1655 ],
1656 declarations: [
1657 SplitComponent,
1658 SplitAreaDirective,
1659 ],
1660 exports: [
1661 SplitComponent,
1662 SplitAreaDirective,
1663 ]
1664 },] }
1665 ];
1666 return AngularSplitModule;
1667}());
1668
1669export { AngularSplitModule, SplitAreaDirective, SplitComponent };
1670//# sourceMappingURL=angular-split.js.map