source: trip-planner-front/node_modules/primeng/fesm2020/primeng-splitter.mjs@ 6fe77af

Last change on this file since 6fe77af was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 17.2 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, Output, ContentChildren, ViewChild, NgModule } from '@angular/core';
3import * as i1 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import { DomHandler } from 'primeng/dom';
6import { PrimeTemplate, SharedModule } from 'primeng/api';
7
8class Splitter {
9 constructor(cd, el) {
10 this.cd = cd;
11 this.el = el;
12 this.stateStorage = "session";
13 this.stateKey = null;
14 this.layout = "horizontal";
15 this.gutterSize = 4;
16 this.panelSizes = [];
17 this.minSizes = [];
18 this.onResizeEnd = new EventEmitter();
19 this.onResizeStart = new EventEmitter();
20 this.nested = false;
21 this.panels = [];
22 this.dragging = false;
23 this.mouseMoveListener = null;
24 this.mouseUpListener = null;
25 this.touchMoveListener = null;
26 this.touchEndListener = null;
27 this.size = null;
28 this.gutterElement = null;
29 this.startPos = null;
30 this.prevPanelElement = null;
31 this.nextPanelElement = null;
32 this.nextPanelSize = null;
33 this.prevPanelSize = null;
34 this._panelSizes = null;
35 this.prevPanelIndex = null;
36 }
37 ngOnInit() {
38 this.nested = this.isNested();
39 }
40 ngAfterContentInit() {
41 this.templates.forEach((item) => {
42 switch (item.getType()) {
43 case 'panel':
44 this.panels.push(item.template);
45 break;
46 default:
47 this.panels.push(item.template);
48 break;
49 }
50 });
51 }
52 ngAfterViewInit() {
53 if (this.panels && this.panels.length) {
54 let initialized = false;
55 if (this.isStateful()) {
56 initialized = this.restoreState();
57 }
58 if (!initialized) {
59 let children = [...this.el.nativeElement.children[0].children].filter(child => DomHandler.hasClass(child, 'p-splitter-panel'));
60 let _panelSizes = [];
61 this.panels.map((panel, i) => {
62 let panelInitialSize = this.panelSizes.length - 1 >= i ? this.panelSizes[i] : null;
63 let panelSize = panelInitialSize || (100 / this.panels.length);
64 _panelSizes[i] = panelSize;
65 children[i].style.flexBasis = 'calc(' + panelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
66 });
67 this._panelSizes = _panelSizes;
68 }
69 }
70 }
71 resizeStart(event, index) {
72 this.gutterElement = event.currentTarget;
73 this.size = this.horizontal() ? DomHandler.getWidth(this.containerViewChild.nativeElement) : DomHandler.getHeight(this.containerViewChild.nativeElement);
74 this.dragging = true;
75 this.startPos = this.horizontal() ? (event.pageX || event.changedTouches[0].pageX) : (event.pageY || event.changedTouches[0].pageY);
76 this.prevPanelElement = this.gutterElement.previousElementSibling;
77 this.nextPanelElement = this.gutterElement.nextElementSibling;
78 this.prevPanelSize = 100 * (this.horizontal() ? DomHandler.getOuterWidth(this.prevPanelElement, true) : DomHandler.getOuterHeight(this.prevPanelElement, true)) / this.size;
79 this.nextPanelSize = 100 * (this.horizontal() ? DomHandler.getOuterWidth(this.nextPanelElement, true) : DomHandler.getOuterHeight(this.nextPanelElement, true)) / this.size;
80 this.prevPanelIndex = index;
81 DomHandler.addClass(this.gutterElement, 'p-splitter-gutter-resizing');
82 DomHandler.addClass(this.containerViewChild.nativeElement, 'p-splitter-resizing');
83 this.onResizeStart.emit({ originalEvent: event, sizes: this._panelSizes });
84 }
85 onResize(event) {
86 let newPos;
87 if (this.horizontal())
88 newPos = (event.pageX * 100 / this.size) - (this.startPos * 100 / this.size);
89 else
90 newPos = (event.pageY * 100 / this.size) - (this.startPos * 100 / this.size);
91 let newPrevPanelSize = this.prevPanelSize + newPos;
92 let newNextPanelSize = this.nextPanelSize - newPos;
93 if (this.validateResize(newPrevPanelSize, newNextPanelSize)) {
94 this.prevPanelElement.style.flexBasis = 'calc(' + newPrevPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
95 this.nextPanelElement.style.flexBasis = 'calc(' + newNextPanelSize + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
96 this._panelSizes[this.prevPanelIndex] = newPrevPanelSize;
97 this._panelSizes[this.prevPanelIndex + 1] = newNextPanelSize;
98 }
99 }
100 resizeEnd(event) {
101 if (this.isStateful()) {
102 this.saveState();
103 }
104 this.onResizeEnd.emit({ originalEvent: event, sizes: this._panelSizes });
105 DomHandler.removeClass(this.gutterElement, 'p-splitter-gutter-resizing');
106 DomHandler.removeClass(this.containerViewChild.nativeElement, 'p-splitter-resizing');
107 this.clear();
108 }
109 onGutterMouseDown(event, index) {
110 this.resizeStart(event, index);
111 this.bindMouseListeners();
112 }
113 onGutterTouchStart(event, index) {
114 if (event.cancelable) {
115 this.resizeStart(event, index);
116 this.bindTouchListeners();
117 event.preventDefault();
118 }
119 }
120 onGutterTouchEnd(event) {
121 this.resizeEnd(event);
122 this.unbindTouchListeners();
123 if (event.cancelable)
124 event.preventDefault();
125 }
126 validateResize(newPrevPanelSize, newNextPanelSize) {
127 if (this.minSizes.length >= 1 && this.minSizes[0] && this.minSizes[0] > newPrevPanelSize) {
128 return false;
129 }
130 if (this.minSizes.length > 1 && this.minSizes[1] && this.minSizes[1] > newNextPanelSize) {
131 return false;
132 }
133 return true;
134 }
135 bindMouseListeners() {
136 if (!this.mouseMoveListener) {
137 this.mouseMoveListener = event => this.onResize(event);
138 document.addEventListener('mousemove', this.mouseMoveListener);
139 }
140 if (!this.mouseUpListener) {
141 this.mouseUpListener = event => {
142 this.resizeEnd(event);
143 this.unbindMouseListeners();
144 };
145 document.addEventListener('mouseup', this.mouseUpListener);
146 }
147 }
148 bindTouchListeners() {
149 if (!this.touchMoveListener) {
150 this.touchMoveListener = event => this.onResize(event.changedTouches[0]);
151 document.addEventListener('touchmove', this.touchMoveListener);
152 }
153 if (!this.touchEndListener) {
154 this.touchEndListener = event => {
155 this.resizeEnd(event);
156 this.unbindTouchListeners();
157 };
158 document.addEventListener('touchend', this.touchEndListener);
159 }
160 }
161 unbindMouseListeners() {
162 if (this.mouseMoveListener) {
163 document.removeEventListener('mousemove', this.mouseMoveListener);
164 this.mouseMoveListener = null;
165 }
166 if (this.mouseUpListener) {
167 document.removeEventListener('mouseup', this.mouseUpListener);
168 this.mouseUpListener = null;
169 }
170 }
171 unbindTouchListeners() {
172 if (this.touchMoveListener) {
173 document.removeEventListener('touchmove', this.touchMoveListener);
174 this.touchMoveListener = null;
175 }
176 if (this.touchEndListener) {
177 document.removeEventListener('touchend', this.touchEndListener);
178 this.touchEndListener = null;
179 }
180 }
181 clear() {
182 this.dragging = false;
183 this.size = null;
184 this.startPos = null;
185 this.prevPanelElement = null;
186 this.nextPanelElement = null;
187 this.prevPanelSize = null;
188 this.nextPanelSize = null;
189 this.gutterElement = null;
190 this.prevPanelIndex = null;
191 }
192 isNested() {
193 if (this.el.nativeElement) {
194 let parent = this.el.nativeElement.parentElement;
195 while (parent && !DomHandler.hasClass(parent, 'p-splitter')) {
196 parent = parent.parentElement;
197 }
198 return parent !== null;
199 }
200 else {
201 return false;
202 }
203 }
204 isStateful() {
205 return this.stateKey != null;
206 }
207 getStorage() {
208 switch (this.stateStorage) {
209 case 'local':
210 return window.localStorage;
211 case 'session':
212 return window.sessionStorage;
213 default:
214 throw new Error(this.stateStorage + ' is not a valid value for the state storage, supported values are "local" and "session".');
215 }
216 }
217 saveState() {
218 this.getStorage().setItem(this.stateKey, JSON.stringify(this._panelSizes));
219 }
220 restoreState() {
221 const storage = this.getStorage();
222 const stateString = storage.getItem(this.stateKey);
223 if (stateString) {
224 this._panelSizes = JSON.parse(stateString);
225 let children = [...this.containerViewChild.nativeElement.children].filter(child => DomHandler.hasClass(child, 'p-splitter-panel'));
226 children.forEach((child, i) => {
227 child.style.flexBasis = 'calc(' + this._panelSizes[i] + '% - ' + ((this.panels.length - 1) * this.gutterSize) + 'px)';
228 });
229 return true;
230 }
231 return false;
232 }
233 containerClass() {
234 return {
235 'p-splitter p-component': true,
236 'p-splitter-horizontal': this.layout === "horizontal",
237 'p-splitter-vertical': this.layout === "vertical"
238 };
239 }
240 panelContainerClass() {
241 return {
242 'p-splitter-panel': true,
243 'p-splitter-panel-nested': true
244 };
245 }
246 gutterStyle() {
247 if (this.horizontal())
248 return { width: this.gutterSize + 'px' };
249 else
250 return { height: this.gutterSize + 'px' };
251 }
252 horizontal() {
253 return this.layout === 'horizontal';
254 }
255}
256Splitter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Splitter, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
257Splitter.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Splitter, selector: "p-splitter", inputs: { styleClass: "styleClass", panelStyleClass: "panelStyleClass", style: "style", panelStyle: "panelStyle", stateStorage: "stateStorage", stateKey: "stateKey", layout: "layout", gutterSize: "gutterSize", panelSizes: "panelSizes", minSizes: "minSizes" }, outputs: { onResizeEnd: "onResizeEnd", onResizeStart: "onResizeStart" }, host: { properties: { "class.p-splitter-panel-nested": "nested" }, classAttribute: "p-element" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], viewQueries: [{ propertyName: "containerViewChild", first: true, predicate: ["container"], descendants: true }], ngImport: i0, template: `
258 <div #container [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style">
259 <ng-template ngFor let-panel let-i="index" [ngForOf]="panels">
260 <div [ngClass]="panelContainerClass()" [class]="panelStyleClass" [ngStyle]="panelStyle">
261 <ng-container *ngTemplateOutlet="panel"></ng-container>
262 </div>
263 <div class="p-splitter-gutter" *ngIf="i !== (panels.length - 1)" [ngStyle]="gutterStyle()"
264 (mousedown)="onGutterMouseDown($event, i)" (touchstart)="onGutterTouchStart($event, i)">
265 <div class="p-splitter-gutter-handle"></div>
266 </div>
267 </ng-template>
268 </div>
269 `, isInline: true, styles: [".p-splitter{display:flex;flex-wrap:nowrap}.p-splitter-vertical{flex-direction:column}.p-splitter-panel{flex-grow:1}.p-splitter-panel-nested{display:flex}.p-splitter-panel p-splitter{flex-grow:1}.p-splitter-panel .p-splitter{flex-grow:1;border:0 none}.p-splitter-gutter{flex-grow:0;flex-shrink:0;display:flex;align-items:center;justify-content:center;cursor:col-resize}.p-splitter-horizontal.p-splitter-resizing{cursor:col-resize;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-splitter-horizontal>.p-splitter-gutter>.p-splitter-gutter-handle{height:24px;width:100%}.p-splitter-horizontal>.p-splitter-gutter{cursor:col-resize}.p-splitter-vertical.p-splitter-resizing{cursor:row-resize;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-splitter-vertical>.p-splitter-gutter{cursor:row-resize}.p-splitter-vertical>.p-splitter-gutter>.p-splitter-gutter-handle{width:24px;height:100%}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
270i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Splitter, decorators: [{
271 type: Component,
272 args: [{ selector: 'p-splitter', template: `
273 <div #container [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style">
274 <ng-template ngFor let-panel let-i="index" [ngForOf]="panels">
275 <div [ngClass]="panelContainerClass()" [class]="panelStyleClass" [ngStyle]="panelStyle">
276 <ng-container *ngTemplateOutlet="panel"></ng-container>
277 </div>
278 <div class="p-splitter-gutter" *ngIf="i !== (panels.length - 1)" [ngStyle]="gutterStyle()"
279 (mousedown)="onGutterMouseDown($event, i)" (touchstart)="onGutterTouchStart($event, i)">
280 <div class="p-splitter-gutter-handle"></div>
281 </div>
282 </ng-template>
283 </div>
284 `, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: {
285 'class': 'p-element',
286 '[class.p-splitter-panel-nested]': 'nested'
287 }, styles: [".p-splitter{display:flex;flex-wrap:nowrap}.p-splitter-vertical{flex-direction:column}.p-splitter-panel{flex-grow:1}.p-splitter-panel-nested{display:flex}.p-splitter-panel p-splitter{flex-grow:1}.p-splitter-panel .p-splitter{flex-grow:1;border:0 none}.p-splitter-gutter{flex-grow:0;flex-shrink:0;display:flex;align-items:center;justify-content:center;cursor:col-resize}.p-splitter-horizontal.p-splitter-resizing{cursor:col-resize;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-splitter-horizontal>.p-splitter-gutter>.p-splitter-gutter-handle{height:24px;width:100%}.p-splitter-horizontal>.p-splitter-gutter{cursor:col-resize}.p-splitter-vertical.p-splitter-resizing{cursor:row-resize;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-splitter-vertical>.p-splitter-gutter{cursor:row-resize}.p-splitter-vertical>.p-splitter-gutter>.p-splitter-gutter-handle{width:24px;height:100%}\n"] }]
288 }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }]; }, propDecorators: { styleClass: [{
289 type: Input
290 }], panelStyleClass: [{
291 type: Input
292 }], style: [{
293 type: Input
294 }], panelStyle: [{
295 type: Input
296 }], stateStorage: [{
297 type: Input
298 }], stateKey: [{
299 type: Input
300 }], layout: [{
301 type: Input
302 }], gutterSize: [{
303 type: Input
304 }], panelSizes: [{
305 type: Input
306 }], minSizes: [{
307 type: Input
308 }], onResizeEnd: [{
309 type: Output
310 }], onResizeStart: [{
311 type: Output
312 }], templates: [{
313 type: ContentChildren,
314 args: [PrimeTemplate]
315 }], containerViewChild: [{
316 type: ViewChild,
317 args: ['container', { static: false }]
318 }] } });
319class SplitterModule {
320}
321SplitterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SplitterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
322SplitterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SplitterModule, declarations: [Splitter], imports: [CommonModule], exports: [Splitter, SharedModule] });
323SplitterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SplitterModule, imports: [[CommonModule], SharedModule] });
324i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: SplitterModule, decorators: [{
325 type: NgModule,
326 args: [{
327 imports: [CommonModule],
328 exports: [Splitter, SharedModule],
329 declarations: [Splitter]
330 }]
331 }] });
332
333/**
334 * Generated bundle index. Do not edit.
335 */
336
337export { Splitter, SplitterModule };
Note: See TracBrowser for help on using the repository browser.