@solidpepper/solidpepper-soliddesigner 0.1.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.
@@ -0,0 +1,640 @@
1
+ import * as i0 from '@angular/core';
2
+ import { EventEmitter, inject, effect, Output, Input, Component, signal, computed } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+ import * as i2 from '@ngx-translate/core';
5
+ import { TranslateModule } from '@ngx-translate/core';
6
+ import { a as SaveService, A as AppParamsService, b as AssetsService, M as ModalService, P as PageContextMenuComponent, C as ConfirmDeleteModalComponent } from './solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-7V9C3Otl.mjs';
7
+
8
+ class PageGridItemComponent {
9
+ constructor() {
10
+ this.isCurrent = false;
11
+ this.selectPage = new EventEmitter();
12
+ this.dragStarted = new EventEmitter();
13
+ this.dropped = new EventEmitter();
14
+ this.contextMenuEvent = new EventEmitter();
15
+ this.dragOver = false;
16
+ this.dropSide = null;
17
+ this.saveService = inject(SaveService);
18
+ this.cacheBuster = '';
19
+ effect(() => {
20
+ const pulse = this.saveService.saveSuccessPulse();
21
+ const pulseCount = typeof pulse === 'object' ? pulse.count : pulse;
22
+ if (this.isCurrent && pulseCount > 0) {
23
+ this.cacheBuster = `t=${pulseCount}`;
24
+ }
25
+ });
26
+ }
27
+ get displayImageUrl() {
28
+ if (!this.cacheBuster || !this.imageUrl) {
29
+ return this.imageUrl;
30
+ }
31
+ const separator = this.imageUrl.includes('?') ? '&' : '?';
32
+ return `${this.imageUrl}${separator}${this.cacheBuster}`;
33
+ }
34
+ onDragStart(event) {
35
+ this.dragStarted.emit(this.index);
36
+ if (event.dataTransfer) {
37
+ event.dataTransfer.effectAllowed = 'move';
38
+ }
39
+ }
40
+ onDragOver(event) {
41
+ event.preventDefault();
42
+ this.dragOver = true;
43
+ const rect = event.currentTarget.getBoundingClientRect();
44
+ const midX = rect.left + rect.width / 2;
45
+ this.dropSide = event.clientX < midX ? 'before' : 'after';
46
+ }
47
+ onDrop(event) {
48
+ event.preventDefault();
49
+ if (this.dropSide) {
50
+ this.dropped.emit({ targetIndex: this.index, side: this.dropSide });
51
+ }
52
+ this.onDragEnd();
53
+ }
54
+ onDragLeave() {
55
+ this.dragOver = false;
56
+ this.dropSide = null;
57
+ }
58
+ onDragEnd() {
59
+ this.dragOver = false;
60
+ this.dropSide = null;
61
+ }
62
+ onContextMenu(event) {
63
+ event.preventDefault();
64
+ this.contextMenuEvent.emit({ event, index: this.index });
65
+ }
66
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
67
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.12", type: PageGridItemComponent, isStandalone: true, selector: "app-page-grid-item", inputs: { index: "index", imageUrl: "imageUrl", isCurrent: "isCurrent" }, outputs: { selectPage: "selectPage", dragStarted: "dragStarted", dropped: "dropped", contextMenuEvent: "contextMenuEvent" }, ngImport: i0, template: `
68
+ <div
69
+ class="page-grid-item"
70
+ [class.current]="isCurrent"
71
+ [class.drag-before]="dragOver && dropSide === 'before'"
72
+ [class.drag-after]="dragOver && dropSide === 'after'"
73
+ draggable="true"
74
+ (dragstart)="onDragStart($event)"
75
+ (dragover)="onDragOver($event)"
76
+ (dragleave)="onDragLeave()"
77
+ (drop)="onDrop($event)"
78
+ (dragend)="onDragEnd()"
79
+ (click)="selectPage.emit(index)"
80
+ (contextmenu)="onContextMenu($event)"
81
+ >
82
+ <img
83
+ [src]="displayImageUrl"
84
+ class="page-image"
85
+ alt="Page Thumbnail"
86
+ loading="lazy"
87
+ />
88
+ <span class="page-number">{{ index + 1 }}</span>
89
+ </div>
90
+ `, isInline: true, styles: [":host{display:block}.page-grid-item{background-color:var(--gray-4);border-radius:var(--radius-xs);padding:var(--spacing-xs) 0;display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:1px solid var(--gray-3);align-items:center;cursor:move;margin:0;position:relative;transition:transform .2s,background-color .2s;box-sizing:border-box}.page-grid-item:hover{transform:scale(1.05);background-color:var(--gray-3)}.page-grid-item.current{border-color:var(--active)}.page-image{background-color:#fff;border-radius:0;pointer-events:none;height:calc(100% - 2 * var(--spacing-xs) - 15px);width:auto;max-width:100%;object-fit:contain}.page-number{font-size:10px;color:var(--white)}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:var(--active);z-index:100;opacity:0;transition:opacity .2s;border-radius:2px}.page-grid-item.drag-before:before{left:-4px;opacity:1}.page-grid-item.drag-after:after{right:-4px;opacity:1}:host:nth-child(odd) .page-grid-item{margin:0!important;border-right:0!important;border-top-right-radius:0;border-bottom-right-radius:0;box-shadow:2px 0 5px #0003}:host:nth-child(odd) .page-image{margin-left:auto;background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3e %3cline x1='100%25' y1='0' x2='100%25' y2='20' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='26' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='34' x2='100%25' y2='54' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='60' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='68' x2='100%25' y2='88' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='64' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='102' x2='100%25' y2='122' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='128' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='136' x2='100%25' y2='156' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='162' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='170' x2='100%25' y2='190' stroke='%234f4f59' stroke-width='1.5'/%3e %3cline x1='0' y1='0' x2='100%25' y2='0' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='0' x2='0' y2='100%25' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='100%25' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3c/svg%3e\");border-right:0}:host:nth-child(2n) .page-grid-item{margin:0!important;border-left:0!important;border-top-left-radius:0;border-bottom-left-radius:0;box-shadow:-2px 0 5px #0003}:host:nth-child(2n) .page-image{margin-right:auto;background-image:url(\"data:image/svg+xml, %3csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3e %3cline x1='0' y1='0' x2='0' y2='20' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='26' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='34' x2='0' y2='54' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='60' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='68' x2='0' y2='88' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='94' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='102' x2='0' y2='122' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='128' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='136' x2='0' y2='156' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='162' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='170' x2='0' y2='190' stroke='%234f4f59' stroke-width='1.5'/%3e %3cline x1='0' y1='0' x2='100%25' y2='0' stroke='black' stroke-width='2'/%3e %3cline x1='100%25' y1='0' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='100%25' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3c/svg%3e\");border-left:0}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: TranslateModule }] }); }
91
+ }
92
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridItemComponent, decorators: [{
93
+ type: Component,
94
+ args: [{ selector: 'app-page-grid-item', standalone: true, imports: [CommonModule, TranslateModule], template: `
95
+ <div
96
+ class="page-grid-item"
97
+ [class.current]="isCurrent"
98
+ [class.drag-before]="dragOver && dropSide === 'before'"
99
+ [class.drag-after]="dragOver && dropSide === 'after'"
100
+ draggable="true"
101
+ (dragstart)="onDragStart($event)"
102
+ (dragover)="onDragOver($event)"
103
+ (dragleave)="onDragLeave()"
104
+ (drop)="onDrop($event)"
105
+ (dragend)="onDragEnd()"
106
+ (click)="selectPage.emit(index)"
107
+ (contextmenu)="onContextMenu($event)"
108
+ >
109
+ <img
110
+ [src]="displayImageUrl"
111
+ class="page-image"
112
+ alt="Page Thumbnail"
113
+ loading="lazy"
114
+ />
115
+ <span class="page-number">{{ index + 1 }}</span>
116
+ </div>
117
+ `, styles: [":host{display:block}.page-grid-item{background-color:var(--gray-4);border-radius:var(--radius-xs);padding:var(--spacing-xs) 0;display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:1px solid var(--gray-3);align-items:center;cursor:move;margin:0;position:relative;transition:transform .2s,background-color .2s;box-sizing:border-box}.page-grid-item:hover{transform:scale(1.05);background-color:var(--gray-3)}.page-grid-item.current{border-color:var(--active)}.page-image{background-color:#fff;border-radius:0;pointer-events:none;height:calc(100% - 2 * var(--spacing-xs) - 15px);width:auto;max-width:100%;object-fit:contain}.page-number{font-size:10px;color:var(--white)}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:var(--active);z-index:100;opacity:0;transition:opacity .2s;border-radius:2px}.page-grid-item.drag-before:before{left:-4px;opacity:1}.page-grid-item.drag-after:after{right:-4px;opacity:1}:host:nth-child(odd) .page-grid-item{margin:0!important;border-right:0!important;border-top-right-radius:0;border-bottom-right-radius:0;box-shadow:2px 0 5px #0003}:host:nth-child(odd) .page-image{margin-left:auto;background-image:url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3e %3cline x1='100%25' y1='0' x2='100%25' y2='20' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='26' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='34' x2='100%25' y2='54' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='60' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='68' x2='100%25' y2='88' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='64' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='102' x2='100%25' y2='122' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='128' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='136' x2='100%25' y2='156' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='100%25' cy='162' r='3' fill='%234f4f59'/%3e %3cline x1='100%25' y1='170' x2='100%25' y2='190' stroke='%234f4f59' stroke-width='1.5'/%3e %3cline x1='0' y1='0' x2='100%25' y2='0' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='0' x2='0' y2='100%25' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='100%25' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3c/svg%3e\");border-right:0}:host:nth-child(2n) .page-grid-item{margin:0!important;border-left:0!important;border-top-left-radius:0;border-bottom-left-radius:0;box-shadow:-2px 0 5px #0003}:host:nth-child(2n) .page-image{margin-right:auto;background-image:url(\"data:image/svg+xml, %3csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3e %3cline x1='0' y1='0' x2='0' y2='20' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='26' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='34' x2='0' y2='54' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='60' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='68' x2='0' y2='88' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='94' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='102' x2='0' y2='122' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='128' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='136' x2='0' y2='156' stroke='%234f4f59' stroke-width='1.5'/%3e %3ccircle cx='0' cy='162' r='3' fill='%234f4f59'/%3e %3cline x1='0' y1='170' x2='0' y2='190' stroke='%234f4f59' stroke-width='1.5'/%3e %3cline x1='0' y1='0' x2='100%25' y2='0' stroke='black' stroke-width='2'/%3e %3cline x1='100%25' y1='0' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3cline x1='0' y1='100%25' x2='100%25' y2='100%25' stroke='black' stroke-width='2'/%3e %3c/svg%3e\");border-left:0}\n"] }]
118
+ }], ctorParameters: () => [], propDecorators: { index: [{
119
+ type: Input,
120
+ args: [{ required: true }]
121
+ }], imageUrl: [{
122
+ type: Input,
123
+ args: [{ required: true }]
124
+ }], isCurrent: [{
125
+ type: Input
126
+ }], selectPage: [{
127
+ type: Output
128
+ }], dragStarted: [{
129
+ type: Output
130
+ }], dropped: [{
131
+ type: Output
132
+ }], contextMenuEvent: [{
133
+ type: Output
134
+ }] } });
135
+
136
+ class PageGridModalComponent {
137
+ constructor() {
138
+ this.appParams = inject(AppParamsService);
139
+ this.assetsService = inject(AssetsService);
140
+ this.modalService = inject(ModalService);
141
+ this.saveService = inject(SaveService);
142
+ this.isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
143
+ this.pages = signal([], ...(ngDevMode ? [{ debugName: "pages" }] : []));
144
+ this.currentPageIndex = computed(() => {
145
+ const guid = this.appParams.pageGuid();
146
+ const pages = this.pages();
147
+ return pages.findIndex((p) => p.documentPageGuid === guid);
148
+ }, ...(ngDevMode ? [{ debugName: "currentPageIndex" }] : []));
149
+ this.pageSpreads = computed(() => {
150
+ const pagesList = this.pages();
151
+ const items = [{ isFake: true }];
152
+ pagesList.forEach((p, i) => {
153
+ items.push({ ...p, index: i });
154
+ });
155
+ const chunks = [];
156
+ for (let i = 0; i < items.length; i += 2) {
157
+ chunks.push(items.slice(i, i + 2));
158
+ }
159
+ return chunks;
160
+ }, ...(ngDevMode ? [{ debugName: "pageSpreads" }] : []));
161
+ this.pageCacheBusters = signal({}, ...(ngDevMode ? [{ debugName: "pageCacheBusters" }] : []));
162
+ this.sessionBuster = `s=${Date.now()}`;
163
+ this.pageImageUrls = computed(() => {
164
+ const busters = this.pageCacheBusters();
165
+ return this.pages().map((p) => {
166
+ const baseUrl = p.publicationTemplateThumbnail || p.publicationTemplateUrl;
167
+ if (!baseUrl)
168
+ return '';
169
+ const guid = p.documentPageGuid;
170
+ const buster = busters[guid] || this.sessionBuster;
171
+ const separator = baseUrl.includes('?') ? '&' : '?';
172
+ return `${baseUrl}${separator}${buster}`;
173
+ });
174
+ }, ...(ngDevMode ? [{ debugName: "pageImageUrls" }] : []));
175
+ this.dragSourceIndex = null;
176
+ this.contextMenuVisible = false;
177
+ this.contextMenuPosition = { x: 0, y: 0 };
178
+ this.contextMenuPageIndex = null;
179
+ // Delete confirmation state
180
+ this.showDeleteConfirm = signal(false, ...(ngDevMode ? [{ debugName: "showDeleteConfirm" }] : []));
181
+ this.deleteIndex = null;
182
+ effect(() => {
183
+ const params = this.appParams.params();
184
+ const docData = params.documentData;
185
+ if (docData && Array.isArray(docData)) {
186
+ this.pages.set([...docData]);
187
+ }
188
+ });
189
+ effect(() => {
190
+ const pulse = this.saveService.saveSuccessPulse();
191
+ const pulseCount = typeof pulse === 'object' ? pulse.count : pulse;
192
+ const currentPage = this.pages()[this.currentPageIndex()];
193
+ if (currentPage && pulseCount > 0) {
194
+ const activeGuid = currentPage.documentPageGuid;
195
+ this.pageCacheBusters.update((map) => ({
196
+ ...map,
197
+ [activeGuid]: `t=${pulseCount}`,
198
+ }));
199
+ }
200
+ });
201
+ }
202
+ ngOnInit() { }
203
+ addPage() {
204
+ const guid = this.appParams.guid;
205
+ if (!guid)
206
+ return;
207
+ this.isLoading.set(true);
208
+ this.assetsService.addDocumentPage(guid).subscribe((newPage) => {
209
+ if (newPage) {
210
+ this.refreshPages();
211
+ }
212
+ else {
213
+ this.isLoading.set(false);
214
+ }
215
+ });
216
+ }
217
+ addPageBefore(index) {
218
+ const guid = this.appParams.guid;
219
+ if (!guid)
220
+ return;
221
+ this.isLoading.set(true);
222
+ this.assetsService
223
+ .addDocumentPage(guid, index + 1)
224
+ .subscribe((newPage) => {
225
+ if (newPage) {
226
+ this.refreshPages();
227
+ }
228
+ else {
229
+ this.isLoading.set(false);
230
+ }
231
+ });
232
+ }
233
+ addPageAfter(index) {
234
+ const guid = this.appParams.guid;
235
+ if (!guid)
236
+ return;
237
+ this.isLoading.set(true);
238
+ this.assetsService
239
+ .addDocumentPage(guid, index + 2)
240
+ .subscribe((newPage) => {
241
+ if (newPage) {
242
+ this.refreshPages();
243
+ }
244
+ else {
245
+ this.isLoading.set(false);
246
+ }
247
+ });
248
+ }
249
+ duplicatePage(index) {
250
+ const guid = this.appParams.guid;
251
+ const page = this.pages()[index];
252
+ if (!guid || !page)
253
+ return;
254
+ this.isLoading.set(true);
255
+ this.assetsService
256
+ .duplicateDocumentPage(guid, page.documentPageGuid)
257
+ .subscribe((newPage) => {
258
+ if (newPage) {
259
+ this.refreshPages();
260
+ }
261
+ else {
262
+ this.isLoading.set(false);
263
+ }
264
+ });
265
+ }
266
+ deletePage(index) {
267
+ this.deleteIndex = index;
268
+ this.showDeleteConfirm.set(true);
269
+ }
270
+ confirmDelete() {
271
+ if (this.deleteIndex === null)
272
+ return;
273
+ const index = this.deleteIndex;
274
+ const page = this.pages()[index];
275
+ const guid = this.appParams.guid;
276
+ if (!guid || !page) {
277
+ this.cancelDelete();
278
+ return;
279
+ }
280
+ this.isLoading.set(true);
281
+ this.assetsService
282
+ .deleteDocumentPage(guid, page.documentPageGuid)
283
+ .subscribe((result) => {
284
+ if (result) {
285
+ this.refreshPages();
286
+ }
287
+ else {
288
+ this.isLoading.set(false);
289
+ }
290
+ });
291
+ this.cancelDelete();
292
+ }
293
+ cancelDelete() {
294
+ this.showDeleteConfirm.set(false);
295
+ this.deleteIndex = null;
296
+ }
297
+ refreshPages() {
298
+ const guid = this.appParams.guid;
299
+ if (!guid)
300
+ return;
301
+ this.assetsService.getSVGDocumentPages(guid).subscribe((response) => {
302
+ if (response && response.template) {
303
+ this.appParams.setParams({ documentData: [...response.template] });
304
+ }
305
+ this.isLoading.set(false);
306
+ });
307
+ }
308
+ close() {
309
+ this.modalService.close();
310
+ }
311
+ goToPage(index) {
312
+ if (this.onPageSelect) {
313
+ this.onPageSelect(index);
314
+ }
315
+ this.close();
316
+ }
317
+ onDragStart(index) {
318
+ this.dragSourceIndex = index;
319
+ }
320
+ onDrop(data) {
321
+ if (this.dragSourceIndex === null)
322
+ return;
323
+ const source = this.dragSourceIndex;
324
+ let actualTargetIndex = data.targetIndex;
325
+ if (data.side === 'after') {
326
+ actualTargetIndex++;
327
+ }
328
+ if (actualTargetIndex === source || actualTargetIndex === source + 1) {
329
+ this.dragSourceIndex = null;
330
+ return;
331
+ }
332
+ const guid = this.appParams.guid;
333
+ if (!guid)
334
+ return;
335
+ const previousPages = this.pages();
336
+ const draggedPage = previousPages[source];
337
+ if (!draggedPage)
338
+ return;
339
+ const draggedPageGuid = draggedPage.documentPageGuid;
340
+ let insertionIndex = actualTargetIndex;
341
+ if (source < actualTargetIndex) {
342
+ insertionIndex--;
343
+ }
344
+ const newPageIdForApi = insertionIndex + 1;
345
+ // Optimistic reorder
346
+ this.pages.update((p) => {
347
+ const copy = [...p];
348
+ const [moved] = copy.splice(source, 1);
349
+ copy.splice(insertionIndex, 0, moved);
350
+ return copy;
351
+ });
352
+ this.isLoading.set(true);
353
+ this.assetsService
354
+ .moveDocumentPage(guid, draggedPageGuid, newPageIdForApi)
355
+ .subscribe({
356
+ next: (result) => {
357
+ if (result) {
358
+ this.refreshPages();
359
+ }
360
+ else {
361
+ this.pages.set(previousPages);
362
+ this.isLoading.set(false);
363
+ }
364
+ },
365
+ error: () => {
366
+ this.pages.set(previousPages);
367
+ this.isLoading.set(false);
368
+ },
369
+ });
370
+ this.dragSourceIndex = null;
371
+ }
372
+ onPageContextMenu(data) {
373
+ this.contextMenuPosition = { x: data.event.clientX, y: data.event.clientY };
374
+ this.contextMenuPageIndex = data.index;
375
+ this.contextMenuVisible = true;
376
+ }
377
+ onContextMenuAction(event) {
378
+ switch (event.action) {
379
+ case 'open':
380
+ this.goToPage(event.index);
381
+ break;
382
+ case 'insert-before':
383
+ this.addPageBefore(event.index);
384
+ break;
385
+ case 'insert-after':
386
+ this.addPageAfter(event.index);
387
+ break;
388
+ case 'duplicate':
389
+ this.duplicatePage(event.index);
390
+ break;
391
+ case 'delete':
392
+ this.deletePage(event.index);
393
+ break;
394
+ }
395
+ this.contextMenuVisible = false;
396
+ }
397
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
398
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.12", type: PageGridModalComponent, isStandalone: true, selector: "app-page-grid-modal", inputs: { onPageSelect: "onPageSelect" }, ngImport: i0, template: `
399
+ <div id="page-grid-backdrop" (click)="close()">
400
+ <div id="page-grid" (click)="$event.stopPropagation()">
401
+ <div id="page-grid-title">
402
+ <span id="icon-page-grid" class="icon">
403
+ <svg
404
+ width="24"
405
+ height="24"
406
+ viewBox="0 0 24 24"
407
+ fill="none"
408
+ xmlns="http://www.w3.org/2000/svg"
409
+ >
410
+ <rect x="3" y="3" width="5" height="5" fill="var(--white)" />
411
+ <rect x="9.5" y="3" width="5" height="5" fill="var(--white)" />
412
+ <rect x="16" y="3" width="5" height="5" fill="var(--white)" />
413
+ <rect x="3" y="9.5" width="5" height="5" fill="var(--white)" />
414
+ <rect x="9.5" y="9.5" width="5" height="5" fill="var(--white)" />
415
+ <rect x="16" y="9.5" width="5" height="5" fill="var(--white)" />
416
+ <rect x="3" y="16" width="5" height="5" fill="var(--white)" />
417
+ <rect x="9.5" y="16" width="5" height="5" fill="var(--white)" />
418
+ <rect x="16" y="16" width="5" height="5" fill="var(--white)" />
419
+ </svg>
420
+ </span>
421
+ <span id="title-page-grid">{{
422
+ 'GLOBAL.PAGES.GRID_VIEW' | translate
423
+ }}</span>
424
+ <button id="close-page-grid" class="close-btn" (click)="close()">
425
+ ×
426
+ </button>
427
+ </div>
428
+
429
+ <div class="page-grid-content">
430
+ @for (spread of pageSpreads(); track spread; let sIndex = $index) {
431
+ <div class="page-spread">
432
+ @for (item of spread; track item) {
433
+ @if (item.isFake) {
434
+ <div class="page-grid-fake-item"></div>
435
+ } @else {
436
+ <app-page-grid-item
437
+ [index]="item.index"
438
+ [imageUrl]="pageImageUrls()[item.index]"
439
+ [isCurrent]="item.index === currentPageIndex()"
440
+ (selectPage)="goToPage($event)"
441
+ (dragStarted)="onDragStart($event)"
442
+ (dropped)="onDrop($event)"
443
+ (contextMenuEvent)="onPageContextMenu($event)"
444
+ ></app-page-grid-item>
445
+ }
446
+ }
447
+ </div>
448
+ }
449
+
450
+ <!-- Add page card -->
451
+ <div class="page-grid-item-add" (click)="addPage()">
452
+ <div class="page-grid-item-add-page">
453
+ <svg
454
+ width="48"
455
+ height="48"
456
+ viewBox="0 0 24 24"
457
+ fill="none"
458
+ xmlns="http://www.w3.org/2000/svg"
459
+ >
460
+ <line
461
+ x1="12"
462
+ y1="5"
463
+ x2="12"
464
+ y2="19"
465
+ stroke="var(--gray-1)"
466
+ stroke-width="2"
467
+ stroke-linecap="round"
468
+ />
469
+ <line
470
+ x1="5"
471
+ y1="12"
472
+ x2="19"
473
+ y2="12"
474
+ stroke="var(--gray-1)"
475
+ stroke-width="2"
476
+ stroke-linecap="round"
477
+ />
478
+ </svg>
479
+ </div>
480
+ <span class="page-number">{{
481
+ 'GLOBAL.PAGES.ADD_PAGE' | translate
482
+ }}</span>
483
+ </div>
484
+ </div>
485
+ </div>
486
+
487
+ <!-- Full screen loader -->
488
+ @if (isLoading()) {
489
+ <div class="page-grid-loader">
490
+ <div class="spinner"></div>
491
+ </div>
492
+ }
493
+ </div>
494
+
495
+ <app-page-context-menu
496
+ [visible]="contextMenuVisible"
497
+ [position]="contextMenuPosition"
498
+ [pageIndex]="contextMenuPageIndex"
499
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
500
+ (action)="onContextMenuAction($event)"
501
+ (closeMenu)="contextMenuVisible = false"
502
+ ></app-page-context-menu>
503
+
504
+ <!-- Delete Confirmation Modal -->
505
+ @if (showDeleteConfirm()) {
506
+ <app-confirm-delete-modal
507
+ (confirm)="confirmDelete()"
508
+ (cancel)="cancelDelete()"
509
+ ></app-confirm-delete-modal>
510
+ }
511
+ `, isInline: true, styles: ["#page-grid-backdrop{position:fixed;top:0;left:0;width:100vw;height:100vh;background:#000000b3;z-index:2000;display:flex;justify-content:center;align-items:center}#page-grid{position:absolute;top:var(--spacing-s);left:var(--spacing-s);right:var(--spacing-s);bottom:var(--spacing-s);width:calc(100vw - 2 * var(--spacing-s));height:calc(100vh - 2 * var(--spacing-s));background-color:var(--gray-5);border-radius:var(--radius-s);padding:0 20px;display:flex;flex-direction:column;opacity:1;transition:opacity .5s ease;pointer-events:auto;overflow-y:auto;box-sizing:border-box}#page-grid-title{display:flex;align-items:center;width:100%;padding-top:var(--spacing-s);flex-shrink:0}#page-grid-title #icon-page-grid{background:var(--gray-3);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center}#page-grid-title #title-page-grid{font-size:var(--font-size-medium);font-weight:var(--font-weight-bold);color:var(--white);margin-top:var(--spacing-s);margin-bottom:var(--spacing-xs);margin-left:var(--spacing-xs)!important}#close-page-grid{margin-left:auto;background:none;border:none;font-size:32px;cursor:pointer;color:var(--white)}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;padding-bottom:40px;gap:var(--spacing-m)}.page-spread{display:flex;flex-direction:row;align-items:flex-end}.page-grid-content>*{margin-bottom:var(--spacing-s)}.page-grid-fake-item{background-color:var(--gray-4);border-radius:var(--radius-xs);border-top-right-radius:0;border-bottom-right-radius:0;padding:var(--spacing-xs);display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:1px solid var(--gray-3);border-right:0;align-items:center;margin:0;box-sizing:border-box;box-shadow:2px 0 5px #0003}.page-grid-item-add{background-color:var(--gray-3);border-radius:var(--radius-xs);padding:var(--spacing-xs);display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:none;align-items:center;cursor:pointer;margin:var(--spacing-s) 0;box-sizing:border-box;transition:transform .2s,background-color .2s}.page-grid-item-add:hover{transform:scale(1.05);background-color:var(--gray-2)}.page-grid-item-add-page{display:flex;align-content:center;flex-direction:column;justify-content:center;align-items:center;width:120px;height:180px;background:#fff;border:2px solid black;box-sizing:border-box;min-width:130px;min-height:186px}.page-number{font-size:10px;color:var(--white);text-align:center}.page-grid-loader{position:absolute;inset:0;background:#0006;display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:var(--radius-s)}.spinner{width:40px;height:40px;border:4px solid rgba(255,255,255,.3);border-top:4px solid var(--white);border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: TranslateModule }, { kind: "component", type: PageGridItemComponent, selector: "app-page-grid-item", inputs: ["index", "imageUrl", "isCurrent"], outputs: ["selectPage", "dragStarted", "dropped", "contextMenuEvent"] }, { kind: "component", type: PageContextMenuComponent, selector: "app-page-context-menu", inputs: ["visible", "position", "pageIndex", "isCurrentPage"], outputs: ["action", "closeMenu"] }, { kind: "component", type: ConfirmDeleteModalComponent, selector: "app-confirm-delete-modal", inputs: ["message"], outputs: ["confirm", "cancel"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }] }); }
512
+ }
513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, decorators: [{
514
+ type: Component,
515
+ args: [{ selector: 'app-page-grid-modal', standalone: true, imports: [
516
+ CommonModule,
517
+ TranslateModule,
518
+ PageGridItemComponent,
519
+ PageContextMenuComponent,
520
+ ConfirmDeleteModalComponent,
521
+ ], template: `
522
+ <div id="page-grid-backdrop" (click)="close()">
523
+ <div id="page-grid" (click)="$event.stopPropagation()">
524
+ <div id="page-grid-title">
525
+ <span id="icon-page-grid" class="icon">
526
+ <svg
527
+ width="24"
528
+ height="24"
529
+ viewBox="0 0 24 24"
530
+ fill="none"
531
+ xmlns="http://www.w3.org/2000/svg"
532
+ >
533
+ <rect x="3" y="3" width="5" height="5" fill="var(--white)" />
534
+ <rect x="9.5" y="3" width="5" height="5" fill="var(--white)" />
535
+ <rect x="16" y="3" width="5" height="5" fill="var(--white)" />
536
+ <rect x="3" y="9.5" width="5" height="5" fill="var(--white)" />
537
+ <rect x="9.5" y="9.5" width="5" height="5" fill="var(--white)" />
538
+ <rect x="16" y="9.5" width="5" height="5" fill="var(--white)" />
539
+ <rect x="3" y="16" width="5" height="5" fill="var(--white)" />
540
+ <rect x="9.5" y="16" width="5" height="5" fill="var(--white)" />
541
+ <rect x="16" y="16" width="5" height="5" fill="var(--white)" />
542
+ </svg>
543
+ </span>
544
+ <span id="title-page-grid">{{
545
+ 'GLOBAL.PAGES.GRID_VIEW' | translate
546
+ }}</span>
547
+ <button id="close-page-grid" class="close-btn" (click)="close()">
548
+ ×
549
+ </button>
550
+ </div>
551
+
552
+ <div class="page-grid-content">
553
+ @for (spread of pageSpreads(); track spread; let sIndex = $index) {
554
+ <div class="page-spread">
555
+ @for (item of spread; track item) {
556
+ @if (item.isFake) {
557
+ <div class="page-grid-fake-item"></div>
558
+ } @else {
559
+ <app-page-grid-item
560
+ [index]="item.index"
561
+ [imageUrl]="pageImageUrls()[item.index]"
562
+ [isCurrent]="item.index === currentPageIndex()"
563
+ (selectPage)="goToPage($event)"
564
+ (dragStarted)="onDragStart($event)"
565
+ (dropped)="onDrop($event)"
566
+ (contextMenuEvent)="onPageContextMenu($event)"
567
+ ></app-page-grid-item>
568
+ }
569
+ }
570
+ </div>
571
+ }
572
+
573
+ <!-- Add page card -->
574
+ <div class="page-grid-item-add" (click)="addPage()">
575
+ <div class="page-grid-item-add-page">
576
+ <svg
577
+ width="48"
578
+ height="48"
579
+ viewBox="0 0 24 24"
580
+ fill="none"
581
+ xmlns="http://www.w3.org/2000/svg"
582
+ >
583
+ <line
584
+ x1="12"
585
+ y1="5"
586
+ x2="12"
587
+ y2="19"
588
+ stroke="var(--gray-1)"
589
+ stroke-width="2"
590
+ stroke-linecap="round"
591
+ />
592
+ <line
593
+ x1="5"
594
+ y1="12"
595
+ x2="19"
596
+ y2="12"
597
+ stroke="var(--gray-1)"
598
+ stroke-width="2"
599
+ stroke-linecap="round"
600
+ />
601
+ </svg>
602
+ </div>
603
+ <span class="page-number">{{
604
+ 'GLOBAL.PAGES.ADD_PAGE' | translate
605
+ }}</span>
606
+ </div>
607
+ </div>
608
+ </div>
609
+
610
+ <!-- Full screen loader -->
611
+ @if (isLoading()) {
612
+ <div class="page-grid-loader">
613
+ <div class="spinner"></div>
614
+ </div>
615
+ }
616
+ </div>
617
+
618
+ <app-page-context-menu
619
+ [visible]="contextMenuVisible"
620
+ [position]="contextMenuPosition"
621
+ [pageIndex]="contextMenuPageIndex"
622
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
623
+ (action)="onContextMenuAction($event)"
624
+ (closeMenu)="contextMenuVisible = false"
625
+ ></app-page-context-menu>
626
+
627
+ <!-- Delete Confirmation Modal -->
628
+ @if (showDeleteConfirm()) {
629
+ <app-confirm-delete-modal
630
+ (confirm)="confirmDelete()"
631
+ (cancel)="cancelDelete()"
632
+ ></app-confirm-delete-modal>
633
+ }
634
+ `, styles: ["#page-grid-backdrop{position:fixed;top:0;left:0;width:100vw;height:100vh;background:#000000b3;z-index:2000;display:flex;justify-content:center;align-items:center}#page-grid{position:absolute;top:var(--spacing-s);left:var(--spacing-s);right:var(--spacing-s);bottom:var(--spacing-s);width:calc(100vw - 2 * var(--spacing-s));height:calc(100vh - 2 * var(--spacing-s));background-color:var(--gray-5);border-radius:var(--radius-s);padding:0 20px;display:flex;flex-direction:column;opacity:1;transition:opacity .5s ease;pointer-events:auto;overflow-y:auto;box-sizing:border-box}#page-grid-title{display:flex;align-items:center;width:100%;padding-top:var(--spacing-s);flex-shrink:0}#page-grid-title #icon-page-grid{background:var(--gray-3);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center}#page-grid-title #title-page-grid{font-size:var(--font-size-medium);font-weight:var(--font-weight-bold);color:var(--white);margin-top:var(--spacing-s);margin-bottom:var(--spacing-xs);margin-left:var(--spacing-xs)!important}#close-page-grid{margin-left:auto;background:none;border:none;font-size:32px;cursor:pointer;color:var(--white)}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;padding-bottom:40px;gap:var(--spacing-m)}.page-spread{display:flex;flex-direction:row;align-items:flex-end}.page-grid-content>*{margin-bottom:var(--spacing-s)}.page-grid-fake-item{background-color:var(--gray-4);border-radius:var(--radius-xs);border-top-right-radius:0;border-bottom-right-radius:0;padding:var(--spacing-xs);display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:1px solid var(--gray-3);border-right:0;align-items:center;margin:0;box-sizing:border-box;box-shadow:2px 0 5px #0003}.page-grid-item-add{background-color:var(--gray-3);border-radius:var(--radius-xs);padding:var(--spacing-xs);display:flex;flex-direction:column;gap:var(--spacing-xs);width:144px;height:220px;border:none;align-items:center;cursor:pointer;margin:var(--spacing-s) 0;box-sizing:border-box;transition:transform .2s,background-color .2s}.page-grid-item-add:hover{transform:scale(1.05);background-color:var(--gray-2)}.page-grid-item-add-page{display:flex;align-content:center;flex-direction:column;justify-content:center;align-items:center;width:120px;height:180px;background:#fff;border:2px solid black;box-sizing:border-box;min-width:130px;min-height:186px}.page-number{font-size:10px;color:var(--white);text-align:center}.page-grid-loader{position:absolute;inset:0;background:#0006;display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:var(--radius-s)}.spinner{width:40px;height:40px;border:4px solid rgba(255,255,255,.3);border-top:4px solid var(--white);border-radius:50%;animation:spin 1s linear infinite}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}\n"] }]
635
+ }], ctorParameters: () => [], propDecorators: { onPageSelect: [{
636
+ type: Input
637
+ }] } });
638
+
639
+ export { PageGridModalComponent };
640
+ //# sourceMappingURL=solidpepper-solidpepper-soliddesigner-page-grid-modal.component-BehgNJ3x.mjs.map