@solidpepper/solidpepper-soliddesigner 0.3.1 → 0.3.3

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.
Files changed (18) hide show
  1. package/fesm2022/solidpepper-solidpepper-soliddesigner-confirm-save-before-pdf-modal.component-dmrHYZ_G.mjs +165 -0
  2. package/fesm2022/solidpepper-solidpepper-soliddesigner-confirm-save-before-pdf-modal.component-dmrHYZ_G.mjs.map +1 -0
  3. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-D-ajn-z9.mjs +871 -0
  4. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-D-ajn-z9.mjs.map +1 -0
  5. package/fesm2022/{solidpepper-solidpepper-soliddesigner-image-utils-BZ877qA2.mjs → solidpepper-solidpepper-soliddesigner-image-utils-S3Asxx7t.mjs} +2 -2
  6. package/fesm2022/{solidpepper-solidpepper-soliddesigner-image-utils-BZ877qA2.mjs.map → solidpepper-solidpepper-soliddesigner-image-utils-S3Asxx7t.mjs.map} +1 -1
  7. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-BFBuR2rJ.mjs +1306 -0
  8. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-BFBuR2rJ.mjs.map +1 -0
  9. package/fesm2022/{solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-DNuvMIlh.mjs → solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-Dg1wqw7b.mjs} +7254 -2408
  10. package/fesm2022/solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-Dg1wqw7b.mjs.map +1 -0
  11. package/fesm2022/solidpepper-solidpepper-soliddesigner.mjs +1 -1
  12. package/index.d.ts +101 -28
  13. package/package.json +8 -9
  14. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-CJ4Uve9q.mjs +0 -152
  15. package/fesm2022/solidpepper-solidpepper-soliddesigner-iframe-modal.component-CJ4Uve9q.mjs.map +0 -1
  16. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CSVxODUW.mjs +0 -771
  17. package/fesm2022/solidpepper-solidpepper-soliddesigner-page-grid-modal.component-CSVxODUW.mjs.map +0 -1
  18. package/fesm2022/solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-DNuvMIlh.mjs.map +0 -1
@@ -0,0 +1,1306 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, signal, computed, effect, Input, Component } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import * as i2 from '@ngx-translate/core';
6
+ import { TranslateService, TranslateModule } from '@ngx-translate/core';
7
+ import { from, concatMap, toArray } from 'rxjs';
8
+ import { spIconFolder, spIconGrid, spIconPlus, spIconTrash, spIconClose, spIconChevronDown, spIconChevronRight, SpIconComponent } from '@solidpepper/solidpepper-icons';
9
+ import { SpButtonComponent, SpBadgeComponent, SpCheckboxComponent, SpFloatingWindowComponent, SpContextMenuComponent } from '@solidpepper/solidpepper-component';
10
+ import { A as AppParamsService, a as AssetsService, M as ModalService, S as SaveService, D as DocumentService, P as PageContextMenuComponent, C as ConfirmDeleteModalComponent } from './solidpepper-solidpepper-soliddesigner-solidpepper-solidpepper-soliddesigner-Dg1wqw7b.mjs';
11
+
12
+ class PageGridModalComponent {
13
+ filterBySection(sectionGuid) {
14
+ this.activeSectionFilter.set(sectionGuid);
15
+ }
16
+ trackByGlobalIndex(index, item) {
17
+ return item.page?.documentPageGuid || item.globalIndex;
18
+ }
19
+ getSectionIndex(page) {
20
+ const sections = this.sections();
21
+ if (!sections || sections.length === 0)
22
+ return 0;
23
+ const secGuid = page?.documentSectionGuid || page?.sectionGuid;
24
+ if (!secGuid)
25
+ return 0;
26
+ const idx = sections.findIndex((s) => s.guid === secGuid);
27
+ return idx !== -1 ? idx : 0;
28
+ }
29
+ getSectionColorClass(page) {
30
+ const sections = this.sections();
31
+ if (!sections || sections.length <= 1) {
32
+ return 'section-border-gray';
33
+ }
34
+ const sIdx = this.getSectionIndex(page);
35
+ if (sIdx === 0) {
36
+ return 'section-border-gray';
37
+ }
38
+ const colorIdx = ((sIdx - 1) % 7) + 1;
39
+ return `section-border-${colorIdx}`;
40
+ }
41
+ getSectionColor(sectionIndex) {
42
+ const sections = this.sections();
43
+ if (!sections || sections.length <= 1 || sectionIndex === 0) {
44
+ return 'oklch(var(--bc) / 0.22)';
45
+ }
46
+ const colors = [
47
+ 'oklch(var(--bc) / 0.22)',
48
+ '#3b82f6', // 1: Blue
49
+ '#10b981', // 2: Emerald Green
50
+ '#8b5cf6', // 3: Violet / Purple
51
+ '#f59e0b', // 4: Amber / Orange
52
+ '#f43f5e', // 5: Rose / Red
53
+ '#06b6d4', // 6: Cyan
54
+ '#6366f1', // 7: Indigo
55
+ ];
56
+ const colorIdx = ((sectionIndex - 1) % 7) + 1;
57
+ return colors[colorIdx];
58
+ }
59
+ getSectionName(page) {
60
+ const sections = this.sections();
61
+ if (!sections || sections.length === 0)
62
+ return '';
63
+ const secGuid = page?.documentSectionGuid || page?.sectionGuid;
64
+ if (!secGuid)
65
+ return '';
66
+ const sec = sections.find((s) => s.guid === secGuid);
67
+ return sec ? sec.name : '';
68
+ }
69
+ getSectionPageCount(sectionGuid) {
70
+ return this.pages().filter((p) => p.documentSectionGuid === sectionGuid || p.sectionGuid === sectionGuid).length;
71
+ }
72
+ scrollToSection(sectionGuid) {
73
+ this.filterBySection(sectionGuid);
74
+ const pages = this.pages();
75
+ const firstIdx = pages.findIndex((p) => p.documentSectionGuid === sectionGuid || p.sectionGuid === sectionGuid);
76
+ if (firstIdx !== -1) {
77
+ const el = document.getElementById(`page-card-${firstIdx}`);
78
+ if (el) {
79
+ el.scrollIntoView({ behavior: 'smooth', block: 'center' });
80
+ }
81
+ }
82
+ }
83
+ openSectionPickerForSelected(event) {
84
+ const items = (this.sections() || []).map((sec) => ({
85
+ id: sec.guid,
86
+ label: sec.name,
87
+ icon: spIconFolder,
88
+ action: () => {
89
+ this.sectionPickerVisible = false;
90
+ this.moveSelectedPagesToSection(sec.guid);
91
+ },
92
+ }));
93
+ this.sectionPickerItems = items;
94
+ this.sectionPickerPosition = { x: event.clientX, y: event.clientY };
95
+ this.sectionPickerVisible = true;
96
+ }
97
+ moveSelectedPagesToSection(targetSectionGuid) {
98
+ const pages = this.pages();
99
+ const selectedIndices = Array.from(this.selectedPageIndices()).sort((a, b) => a - b);
100
+ const pagesToMove = selectedIndices
101
+ .map((i) => pages[i])
102
+ .filter((p) => {
103
+ const sec = p?.documentSectionGuid || p?.sectionGuid;
104
+ return sec !== targetSectionGuid;
105
+ });
106
+ if (pagesToMove.length === 0)
107
+ return;
108
+ this.isLoading.set(true);
109
+ from(pagesToMove)
110
+ .pipe(concatMap((p) => this.assetsService.moveDocumentPageToSection(p.documentPageGuid, targetSectionGuid)), toArray())
111
+ .subscribe({
112
+ next: () => {
113
+ this.selectedPageIndices.set(new Set());
114
+ this.refreshPages();
115
+ },
116
+ error: (err) => {
117
+ console.error('Error moving selected pages to section', err);
118
+ this.isLoading.set(false);
119
+ },
120
+ });
121
+ }
122
+ constructor() {
123
+ this.appParams = inject(AppParamsService);
124
+ this.assetsService = inject(AssetsService);
125
+ this.modalService = inject(ModalService);
126
+ this.saveService = inject(SaveService);
127
+ this.translate = inject(TranslateService);
128
+ this.documentService = inject(DocumentService);
129
+ this.spIconGrid = spIconGrid;
130
+ this.spIconPlus = spIconPlus;
131
+ this.spIconTrash = spIconTrash;
132
+ this.spIconClose = spIconClose;
133
+ this.spIconChevronDown = spIconChevronDown;
134
+ this.spIconChevronRight = spIconChevronRight;
135
+ this.spIconFolder = spIconFolder;
136
+ this.isLoading = signal(false, ...(ngDevMode ? [{ debugName: "isLoading" }] : []));
137
+ this.pages = signal([], ...(ngDevMode ? [{ debugName: "pages" }] : []));
138
+ this.sections = computed(() => this.appParams.documentSections(), ...(ngDevMode ? [{ debugName: "sections" }] : []));
139
+ this.hasSections = computed(() => {
140
+ const s = this.sections();
141
+ return s && s.length > 0;
142
+ }, ...(ngDevMode ? [{ debugName: "hasSections" }] : []));
143
+ this.hasMultipleSections = computed(() => {
144
+ const s = this.sections();
145
+ return s && s.length > 1;
146
+ }, ...(ngDevMode ? [{ debugName: "hasMultipleSections" }] : []));
147
+ this.activeSectionFilter = signal(null, ...(ngDevMode ? [{ debugName: "activeSectionFilter" }] : []));
148
+ this.displayedPages = computed(() => {
149
+ const all = this.pages();
150
+ const filter = this.activeSectionFilter();
151
+ if (!filter) {
152
+ return all.map((page, index) => ({ page, globalIndex: index }));
153
+ }
154
+ return all
155
+ .map((page, index) => ({ page, globalIndex: index }))
156
+ .filter((item) => item.page.documentSectionGuid === filter ||
157
+ item.page.sectionGuid === filter);
158
+ }, ...(ngDevMode ? [{ debugName: "displayedPages" }] : []));
159
+ this.needsLeadingSpacer = computed(() => {
160
+ const list = this.displayedPages();
161
+ if (list.length === 0)
162
+ return true;
163
+ const first = list[0];
164
+ if (first.globalIndex === 0)
165
+ return true;
166
+ return (first.globalIndex + 1) % 2 !== 0;
167
+ }, ...(ngDevMode ? [{ debugName: "needsLeadingSpacer" }] : []));
168
+ this.sectionPickerVisible = false;
169
+ this.sectionPickerPosition = { x: 0, y: 0 };
170
+ this.sectionPickerItems = [];
171
+ this.pageAspectRatio = computed(() => {
172
+ const props = this.documentService.properties();
173
+ if (!props.width || !props.height)
174
+ return '210 / 297';
175
+ return `${props.width} / ${props.height}`;
176
+ }, ...(ngDevMode ? [{ debugName: "pageAspectRatio" }] : []));
177
+ this.currentPageIndex = computed(() => {
178
+ const guid = this.appParams.pageGuid();
179
+ const pages = this.pages();
180
+ return pages.findIndex((p) => p.documentPageGuid === guid);
181
+ }, ...(ngDevMode ? [{ debugName: "currentPageIndex" }] : []));
182
+ this.selectedPageIndices = signal(new Set(), ...(ngDevMode ? [{ debugName: "selectedPageIndices" }] : []));
183
+ this.selectedCount = computed(() => this.selectedPageIndices().size, ...(ngDevMode ? [{ debugName: "selectedCount" }] : []));
184
+ this.canSelectAll = computed(() => {
185
+ const displayed = this.displayedPages();
186
+ if (displayed.length === 0)
187
+ return false;
188
+ const selected = this.selectedPageIndices();
189
+ return displayed.some((item) => !selected.has(item.globalIndex));
190
+ }, ...(ngDevMode ? [{ debugName: "canSelectAll" }] : []));
191
+ this.canDeleteSelected = computed(() => {
192
+ const count = this.selectedCount();
193
+ return count > 0 && count < this.pages().length;
194
+ }, ...(ngDevMode ? [{ debugName: "canDeleteSelected" }] : []));
195
+ this.pageCacheBusters = signal({}, ...(ngDevMode ? [{ debugName: "pageCacheBusters" }] : []));
196
+ this.sessionBuster = `s=${Date.now()}`;
197
+ this.pageImageUrls = computed(() => {
198
+ const busters = this.pageCacheBusters();
199
+ return this.pages().map((p) => {
200
+ const baseUrl = p.publicationTemplateThumbnail || p.publicationTemplateUrl;
201
+ if (!baseUrl)
202
+ return '';
203
+ const guid = p.documentPageGuid;
204
+ const buster = busters[guid] || this.sessionBuster;
205
+ const separator = baseUrl.includes('?') ? '&' : '?';
206
+ return `${baseUrl}${separator}${buster}`;
207
+ });
208
+ }, ...(ngDevMode ? [{ debugName: "pageImageUrls" }] : []));
209
+ this.dragSourceIndex = null;
210
+ this.dragOverIndex = signal(null, ...(ngDevMode ? [{ debugName: "dragOverIndex" }] : []));
211
+ this.dropSide = signal(null, ...(ngDevMode ? [{ debugName: "dropSide" }] : []));
212
+ this.dragOverSectionGuid = signal(null, ...(ngDevMode ? [{ debugName: "dragOverSectionGuid" }] : []));
213
+ this.contextMenuVisible = false;
214
+ this.contextMenuPosition = { x: 0, y: 0 };
215
+ this.contextMenuPageIndex = null;
216
+ this.currentPageSectionGuid = computed(() => {
217
+ const pageIdx = this.contextMenuPageIndex;
218
+ if (pageIdx === null)
219
+ return null;
220
+ const page = this.pages()[pageIdx];
221
+ if (!page)
222
+ return null;
223
+ return page.documentSectionGuid || page.sectionGuid || null;
224
+ }, ...(ngDevMode ? [{ debugName: "currentPageSectionGuid" }] : []));
225
+ // Delete confirmation state
226
+ this.showDeleteConfirm = signal(false, ...(ngDevMode ? [{ debugName: "showDeleteConfirm" }] : []));
227
+ this.isBatchDelete = signal(false, ...(ngDevMode ? [{ debugName: "isBatchDelete" }] : []));
228
+ this.deleteIndex = null;
229
+ this.deleteModalTitle = computed(() => {
230
+ return this.isBatchDelete()
231
+ ? this.translate.instant('GLOBAL.PAGES.DELETE_MULTIPLE_CONFIRM_TITLE')
232
+ : this.translate.instant('GLOBAL.PAGES.DELETE_CONFIRM_TITLE');
233
+ }, ...(ngDevMode ? [{ debugName: "deleteModalTitle" }] : []));
234
+ this.deleteModalMessage = computed(() => {
235
+ return this.isBatchDelete()
236
+ ? this.translate.instant('GLOBAL.PAGES.DELETE_MULTIPLE_CONFIRM_MSG', {
237
+ count: this.selectedCount(),
238
+ })
239
+ : this.translate.instant('GLOBAL.PAGES.DELETE_CONFIRM_MSG');
240
+ }, ...(ngDevMode ? [{ debugName: "deleteModalMessage" }] : []));
241
+ effect(() => {
242
+ const params = this.appParams.params();
243
+ const docData = params.documentData;
244
+ if (docData && Array.isArray(docData)) {
245
+ this.pages.set([...docData]);
246
+ }
247
+ });
248
+ effect(() => {
249
+ const pulse = this.saveService.saveSuccessPulse();
250
+ const pulseCount = typeof pulse === 'object' ? pulse.count : pulse;
251
+ const currentPage = this.pages()[this.currentPageIndex()];
252
+ if (currentPage && pulseCount > 0) {
253
+ const activeGuid = currentPage.documentPageGuid;
254
+ this.pageCacheBusters.update((map) => ({
255
+ ...map,
256
+ [activeGuid]: `t=${pulseCount}`,
257
+ }));
258
+ }
259
+ });
260
+ }
261
+ ngOnInit() { }
262
+ togglePageSelection(index) {
263
+ this.selectedPageIndices.update((set) => {
264
+ const next = new Set(set);
265
+ if (next.has(index)) {
266
+ next.delete(index);
267
+ }
268
+ else {
269
+ next.add(index);
270
+ }
271
+ return next;
272
+ });
273
+ }
274
+ selectAll() {
275
+ const displayed = this.displayedPages();
276
+ this.selectedPageIndices.update((set) => {
277
+ const next = new Set(set);
278
+ for (const item of displayed) {
279
+ next.add(item.globalIndex);
280
+ }
281
+ return next;
282
+ });
283
+ }
284
+ deselectAll() {
285
+ this.selectedPageIndices.set(new Set());
286
+ }
287
+ deleteSelectedPages() {
288
+ if (!this.canDeleteSelected())
289
+ return;
290
+ this.isBatchDelete.set(true);
291
+ this.showDeleteConfirm.set(true);
292
+ }
293
+ addPage() {
294
+ const guid = this.appParams.guid;
295
+ if (!guid)
296
+ return;
297
+ this.isLoading.set(true);
298
+ const filter = this.activeSectionFilter();
299
+ let targetSection = filter || undefined;
300
+ if (!targetSection) {
301
+ const pages = this.pages();
302
+ const lastPage = pages.length > 0 ? pages[pages.length - 1] : null;
303
+ targetSection = lastPage
304
+ ? lastPage.documentSectionGuid || lastPage.sectionGuid
305
+ : undefined;
306
+ }
307
+ const sizeParams = this.getPageSizeParams();
308
+ this.assetsService
309
+ .addDocumentPage(guid, undefined, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
310
+ .subscribe((newPage) => {
311
+ if (newPage) {
312
+ this.refreshPages();
313
+ }
314
+ else {
315
+ this.isLoading.set(false);
316
+ }
317
+ });
318
+ }
319
+ addPageToSection(sectionGuid, sectionPages) {
320
+ const guid = this.appParams.guid;
321
+ if (!guid)
322
+ return;
323
+ this.isLoading.set(true);
324
+ const lastPage = sectionPages && sectionPages.length > 0
325
+ ? sectionPages[sectionPages.length - 1]
326
+ : null;
327
+ const targetPosition = lastPage ? lastPage.globalIndex + 2 : undefined;
328
+ const sizeParams = this.getPageSizeParams();
329
+ this.assetsService
330
+ .addDocumentPage(guid, targetPosition, sectionGuid, sizeParams.width, sizeParams.height, sizeParams.viewBox)
331
+ .subscribe((newPage) => {
332
+ if (newPage) {
333
+ this.refreshPages();
334
+ }
335
+ else {
336
+ this.isLoading.set(false);
337
+ }
338
+ });
339
+ }
340
+ addPageBefore(index) {
341
+ const guid = this.appParams.guid;
342
+ if (!guid)
343
+ return;
344
+ const page = this.pages()[index];
345
+ const targetSection = page
346
+ ? page.documentSectionGuid || page.sectionGuid
347
+ : undefined;
348
+ const sizeParams = this.getPageSizeParams();
349
+ this.isLoading.set(true);
350
+ this.assetsService
351
+ .addDocumentPage(guid, index + 1, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
352
+ .subscribe((newPage) => {
353
+ if (newPage) {
354
+ this.refreshPages();
355
+ }
356
+ else {
357
+ this.isLoading.set(false);
358
+ }
359
+ });
360
+ }
361
+ addPageAfter(index) {
362
+ const guid = this.appParams.guid;
363
+ if (!guid)
364
+ return;
365
+ const page = this.pages()[index];
366
+ const targetSection = page
367
+ ? page.documentSectionGuid || page.sectionGuid
368
+ : undefined;
369
+ const sizeParams = this.getPageSizeParams();
370
+ this.isLoading.set(true);
371
+ this.assetsService
372
+ .addDocumentPage(guid, index + 2, targetSection, sizeParams.width, sizeParams.height, sizeParams.viewBox)
373
+ .subscribe((newPage) => {
374
+ if (newPage) {
375
+ this.refreshPages();
376
+ }
377
+ else {
378
+ this.isLoading.set(false);
379
+ }
380
+ });
381
+ }
382
+ getPageSizeParams() {
383
+ const props = this.documentService?.properties?.();
384
+ if (props && props.width && props.height) {
385
+ return {
386
+ width: props.width,
387
+ height: props.height,
388
+ viewBox: props.viewBox || `0 0 ${props.width} ${props.height}`,
389
+ };
390
+ }
391
+ return {};
392
+ }
393
+ duplicatePage(index) {
394
+ const guid = this.appParams.guid;
395
+ const page = this.pages()[index];
396
+ if (!guid || !page)
397
+ return;
398
+ this.isLoading.set(true);
399
+ this.assetsService
400
+ .duplicateDocumentPage(guid, page.documentPageGuid)
401
+ .subscribe((newPage) => {
402
+ if (newPage) {
403
+ this.refreshPages();
404
+ }
405
+ else {
406
+ this.isLoading.set(false);
407
+ }
408
+ });
409
+ }
410
+ deletePage(index) {
411
+ this.isBatchDelete.set(false);
412
+ this.deleteIndex = index;
413
+ this.showDeleteConfirm.set(true);
414
+ }
415
+ confirmDelete() {
416
+ const guid = this.appParams.guid;
417
+ if (!guid) {
418
+ this.cancelDelete();
419
+ return;
420
+ }
421
+ if (this.isBatchDelete()) {
422
+ if (!this.canDeleteSelected()) {
423
+ this.cancelDelete();
424
+ return;
425
+ }
426
+ const pagesList = this.pages();
427
+ const guidsToDelete = Array.from(this.selectedPageIndices())
428
+ .map((i) => pagesList[i]?.documentPageGuid)
429
+ .filter((g) => !!g);
430
+ if (guidsToDelete.length === 0) {
431
+ this.cancelDelete();
432
+ return;
433
+ }
434
+ this.isLoading.set(true);
435
+ from(guidsToDelete)
436
+ .pipe(concatMap((pageGuid) => this.assetsService.deleteDocumentPage(guid, pageGuid)), toArray())
437
+ .subscribe({
438
+ next: () => {
439
+ this.selectedPageIndices.set(new Set());
440
+ this.refreshPages();
441
+ },
442
+ error: () => {
443
+ this.isLoading.set(false);
444
+ },
445
+ });
446
+ this.cancelDelete();
447
+ return;
448
+ }
449
+ if (this.deleteIndex === null)
450
+ return;
451
+ const index = this.deleteIndex;
452
+ const page = this.pages()[index];
453
+ if (!page) {
454
+ this.cancelDelete();
455
+ return;
456
+ }
457
+ this.isLoading.set(true);
458
+ this.assetsService
459
+ .deleteDocumentPage(guid, page.documentPageGuid)
460
+ .subscribe((result) => {
461
+ if (result) {
462
+ this.selectedPageIndices.update((set) => {
463
+ const next = new Set(set);
464
+ next.delete(index);
465
+ return next;
466
+ });
467
+ this.refreshPages();
468
+ }
469
+ else {
470
+ this.isLoading.set(false);
471
+ }
472
+ });
473
+ this.cancelDelete();
474
+ }
475
+ cancelDelete() {
476
+ this.showDeleteConfirm.set(false);
477
+ this.deleteIndex = null;
478
+ this.isBatchDelete.set(false);
479
+ }
480
+ refreshPages() {
481
+ const guid = this.appParams.guid;
482
+ if (!guid)
483
+ return;
484
+ this.assetsService.getSVGDocumentPages(guid).subscribe((response) => {
485
+ if (response && response.template) {
486
+ this.appParams.setParams({
487
+ documentData: [...response.template],
488
+ documentSections: response.sections || response.Sections || [],
489
+ });
490
+ }
491
+ this.selectedPageIndices.set(new Set());
492
+ this.isLoading.set(false);
493
+ });
494
+ }
495
+ close() {
496
+ this.modalService.close();
497
+ }
498
+ goToPage(index) {
499
+ if (this.onPageSelect) {
500
+ this.onPageSelect(index);
501
+ }
502
+ this.close();
503
+ }
504
+ movePageToSection(pageIndex, targetSectionGuid) {
505
+ const page = this.pages()[pageIndex];
506
+ if (!page)
507
+ return;
508
+ const currentSecGuid = page.documentSectionGuid || page.sectionGuid;
509
+ if (currentSecGuid === targetSectionGuid)
510
+ return;
511
+ const guid = this.appParams.guid;
512
+ if (!guid)
513
+ return;
514
+ const pages = this.pages();
515
+ const sections = this.sections();
516
+ const targetSecIdx = sections.findIndex((s) => s.guid === targetSectionGuid);
517
+ const pagesInTarget = pages.filter((p) => (p.documentSectionGuid === targetSectionGuid ||
518
+ p.sectionGuid === targetSectionGuid) &&
519
+ p.documentPageGuid !== page.documentPageGuid);
520
+ let insertionIndex = 0;
521
+ if (pagesInTarget.length > 0) {
522
+ const lastTargetPage = pagesInTarget[pagesInTarget.length - 1];
523
+ insertionIndex = pages.indexOf(lastTargetPage) + 1;
524
+ }
525
+ else {
526
+ if (targetSecIdx > 0) {
527
+ for (let i = targetSecIdx - 1; i >= 0; i--) {
528
+ const prevSec = sections[i];
529
+ const lastPageOfPrev = [...pages]
530
+ .reverse()
531
+ .find((p) => (p.documentSectionGuid === prevSec.guid ||
532
+ p.sectionGuid === prevSec.guid) &&
533
+ p.documentPageGuid !== page.documentPageGuid);
534
+ if (lastPageOfPrev) {
535
+ insertionIndex = pages.indexOf(lastPageOfPrev) + 1;
536
+ break;
537
+ }
538
+ }
539
+ }
540
+ }
541
+ if (pageIndex < insertionIndex) {
542
+ insertionIndex--;
543
+ }
544
+ const newPageIdForApi = Math.max(1, insertionIndex + 1);
545
+ this.isLoading.set(true);
546
+ this.assetsService
547
+ .moveDocumentPage(guid, page.documentPageGuid, newPageIdForApi, targetSectionGuid)
548
+ .subscribe({
549
+ next: (result) => {
550
+ if (result) {
551
+ this.refreshPages();
552
+ }
553
+ else {
554
+ this.assetsService
555
+ .moveDocumentPageToSection(page.documentPageGuid, targetSectionGuid)
556
+ .subscribe(() => this.refreshPages());
557
+ }
558
+ },
559
+ error: () => {
560
+ this.assetsService
561
+ .moveDocumentPageToSection(page.documentPageGuid, targetSectionGuid)
562
+ .subscribe(() => this.refreshPages());
563
+ },
564
+ });
565
+ }
566
+ // ---- Drag & Drop ----
567
+ onDragStart(event, index) {
568
+ this.dragSourceIndex = index;
569
+ if (event.dataTransfer) {
570
+ event.dataTransfer.effectAllowed = 'move';
571
+ }
572
+ }
573
+ onDragOver(event, index) {
574
+ event.preventDefault();
575
+ this.dragOverIndex.set(index);
576
+ const rect = event.currentTarget.getBoundingClientRect();
577
+ const midX = rect.left + rect.width / 2;
578
+ this.dropSide.set(event.clientX < midX ? 'before' : 'after');
579
+ if (event.dataTransfer) {
580
+ event.dataTransfer.dropEffect = 'move';
581
+ }
582
+ }
583
+ onDragLeave() {
584
+ this.dragOverIndex.set(null);
585
+ this.dropSide.set(null);
586
+ }
587
+ onDragEnd() {
588
+ this.dragSourceIndex = null;
589
+ this.dragOverIndex.set(null);
590
+ this.dropSide.set(null);
591
+ this.dragOverSectionGuid.set(null);
592
+ }
593
+ onDrop(event, targetIndex, targetSectionGuid) {
594
+ event.preventDefault();
595
+ event.stopPropagation();
596
+ const side = this.dropSide();
597
+ this.dragOverIndex.set(null);
598
+ this.dropSide.set(null);
599
+ this.dragOverSectionGuid.set(null);
600
+ if (this.dragSourceIndex === null)
601
+ return;
602
+ const source = this.dragSourceIndex;
603
+ let actualTargetIndex = targetIndex;
604
+ if (side === 'after') {
605
+ actualTargetIndex++;
606
+ }
607
+ const previousPages = this.pages();
608
+ const draggedPage = previousPages[source];
609
+ if (!draggedPage) {
610
+ this.dragSourceIndex = null;
611
+ return;
612
+ }
613
+ const sourceSectionGuid = draggedPage.documentSectionGuid || draggedPage.sectionGuid;
614
+ const targetPage = previousPages[targetIndex];
615
+ const resolvedTargetSectionGuid = targetSectionGuid ||
616
+ (targetPage
617
+ ? targetPage.documentSectionGuid || targetPage.sectionGuid
618
+ : undefined);
619
+ const isSectionChange = !!resolvedTargetSectionGuid &&
620
+ resolvedTargetSectionGuid !== sourceSectionGuid;
621
+ if (!isSectionChange &&
622
+ (actualTargetIndex === source || actualTargetIndex === source + 1)) {
623
+ this.dragSourceIndex = null;
624
+ return;
625
+ }
626
+ const guid = this.appParams.guid;
627
+ if (!guid)
628
+ return;
629
+ const draggedPageGuid = draggedPage.documentPageGuid;
630
+ let insertionIndex = actualTargetIndex;
631
+ if (source < actualTargetIndex) {
632
+ insertionIndex--;
633
+ }
634
+ const newPageIdForApi = insertionIndex + 1;
635
+ // Optimistic local update
636
+ this.pages.update((p) => {
637
+ const copy = [...p];
638
+ const [moved] = copy.splice(source, 1);
639
+ if (resolvedTargetSectionGuid) {
640
+ moved.documentSectionGuid = resolvedTargetSectionGuid;
641
+ moved.sectionGuid = resolvedTargetSectionGuid;
642
+ }
643
+ copy.splice(insertionIndex, 0, moved);
644
+ return copy;
645
+ });
646
+ this.isLoading.set(true);
647
+ this.assetsService
648
+ .moveDocumentPage(guid, draggedPageGuid, newPageIdForApi, resolvedTargetSectionGuid)
649
+ .subscribe({
650
+ next: (result) => {
651
+ if (result) {
652
+ this.refreshPages();
653
+ }
654
+ else {
655
+ this.pages.set(previousPages);
656
+ this.isLoading.set(false);
657
+ }
658
+ },
659
+ error: () => {
660
+ this.pages.set(previousPages);
661
+ this.isLoading.set(false);
662
+ },
663
+ });
664
+ this.dragSourceIndex = null;
665
+ }
666
+ onEmptySectionDragOver(event, sectionGuid) {
667
+ event.preventDefault();
668
+ if (event.dataTransfer) {
669
+ event.dataTransfer.dropEffect = 'move';
670
+ }
671
+ this.dragOverSectionGuid.set(sectionGuid);
672
+ }
673
+ onEmptySectionDrop(event, targetSectionGuid) {
674
+ event.preventDefault();
675
+ event.stopPropagation();
676
+ this.dragOverIndex.set(null);
677
+ this.dropSide.set(null);
678
+ this.dragOverSectionGuid.set(null);
679
+ if (this.dragSourceIndex === null)
680
+ return;
681
+ const source = this.dragSourceIndex;
682
+ this.movePageToSection(source, targetSectionGuid);
683
+ this.dragSourceIndex = null;
684
+ }
685
+ // ---- Context Menu ----
686
+ onPageContextMenu(event, index) {
687
+ event.preventDefault();
688
+ event.stopPropagation();
689
+ this.contextMenuPosition = { x: event.clientX, y: event.clientY };
690
+ this.contextMenuPageIndex = index;
691
+ this.contextMenuVisible = true;
692
+ }
693
+ onContextMenuAction(event) {
694
+ switch (event.action) {
695
+ case 'open':
696
+ this.goToPage(event.index);
697
+ break;
698
+ case 'insert-before':
699
+ this.addPageBefore(event.index);
700
+ break;
701
+ case 'insert-after':
702
+ this.addPageAfter(event.index);
703
+ break;
704
+ case 'duplicate':
705
+ this.duplicatePage(event.index);
706
+ break;
707
+ case 'delete':
708
+ this.deletePage(event.index);
709
+ break;
710
+ case 'move-to-section':
711
+ if (event.sectionGuid) {
712
+ this.movePageToSection(event.index, event.sectionGuid);
713
+ }
714
+ break;
715
+ }
716
+ this.contextMenuVisible = false;
717
+ }
718
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
719
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.12", type: PageGridModalComponent, isStandalone: true, selector: "app-page-grid-modal", inputs: { onPageSelect: "onPageSelect" }, ngImport: i0, template: `
720
+ <sp-floating-window
721
+ [title]="'GLOBAL.PAGES.GRID_VIEW' | translate"
722
+ [icon]="spIconGrid"
723
+ [isOpen]="true"
724
+ [initialWidth]="840"
725
+ [initialHeight]="580"
726
+ [minWidth]="420"
727
+ [minHeight]="300"
728
+ [centerOnOpen]="true"
729
+ [maximizable]="true"
730
+ [zIndex]="2000"
731
+ (closed)="close()"
732
+ >
733
+ <!-- Section Switcher & Quick Drop Bar (if multiple sections exist) -->
734
+ <div
735
+ *ngIf="hasMultipleSections()"
736
+ class="page-grid-section-nav px-4 py-2 bg-base-200/50 border-b border-base-300 flex items-center gap-2 overflow-x-auto select-none shrink-0"
737
+ >
738
+ <span
739
+ class="text-xs font-semibold text-base-content/60 flex items-center gap-1 shrink-0 mr-1"
740
+ >
741
+ <sp-icon [icon]="spIconFolder" [size]="13"></sp-icon>
742
+ <span>{{ 'GLOBAL.SECTIONS.TITLE' | translate }}:</span>
743
+ </span>
744
+
745
+ <!-- Chip "Tout" en premier -->
746
+ <button
747
+ type="button"
748
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
749
+ [class.bg-primary]="activeSectionFilter() === null"
750
+ [class.text-primary-content]="activeSectionFilter() === null"
751
+ [class.border-primary]="activeSectionFilter() === null"
752
+ [class.shadow-xs]="activeSectionFilter() === null"
753
+ [class.bg-base-100]="activeSectionFilter() !== null"
754
+ [class.border-base-300]="activeSectionFilter() !== null"
755
+ [class.text-base-content]="activeSectionFilter() !== null"
756
+ (click)="filterBySection(null)"
757
+ >
758
+ <span>{{ 'GLOBAL.SECTIONS.ALL' | translate }}</span>
759
+ <span
760
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
761
+ [class.bg-primary-content/20]="activeSectionFilter() === null"
762
+ [class.bg-base-200]="activeSectionFilter() !== null"
763
+ >
764
+ {{ pages().length }}
765
+ </span>
766
+ </button>
767
+
768
+ <!-- Les autres sections ensuite -->
769
+ <button
770
+ *ngFor="let sec of sections(); let sIdx = index"
771
+ type="button"
772
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
773
+ [class.bg-primary]="activeSectionFilter() === sec.guid"
774
+ [class.text-primary-content]="activeSectionFilter() === sec.guid"
775
+ [class.border-primary]="activeSectionFilter() === sec.guid"
776
+ [class.shadow-xs]="activeSectionFilter() === sec.guid"
777
+ [class.bg-base-100]="activeSectionFilter() !== sec.guid"
778
+ [class.text-base-content]="activeSectionFilter() !== sec.guid"
779
+ [style.border-color]="
780
+ activeSectionFilter() !== sec.guid ? getSectionColor(sIdx) : null
781
+ "
782
+ [class.!border-primary]="dragOverSectionGuid() === sec.guid"
783
+ [class.!bg-primary/20]="dragOverSectionGuid() === sec.guid"
784
+ (click)="filterBySection(sec.guid)"
785
+ (dragover)="onEmptySectionDragOver($event, sec.guid)"
786
+ (dragleave)="dragOverSectionGuid.set(null)"
787
+ (drop)="onEmptySectionDrop($event, sec.guid)"
788
+ [title]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
789
+ >
790
+ <span
791
+ class="w-2 h-2 rounded-full shrink-0"
792
+ [style.background-color]="getSectionColor(sIdx)"
793
+ ></span>
794
+ <span class="truncate max-w-[130px]">{{ sec.name }}</span>
795
+ <span
796
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
797
+ [class.bg-primary-content/20]="activeSectionFilter() === sec.guid"
798
+ [class.bg-base-200]="activeSectionFilter() !== sec.guid"
799
+ >
800
+ {{ getSectionPageCount(sec.guid) }}
801
+ </span>
802
+ </button>
803
+ </div>
804
+
805
+ <!-- Scrollable content area inside floating window body -->
806
+ <div class="page-grid-scroll-container">
807
+ <div class="page-grid-content">
808
+ <!-- Emplacement Page 0 non affichée pour décaler la couverture (page 1) à droite -->
809
+ <div
810
+ *ngIf="needsLeadingSpacer()"
811
+ class="page-grid-item page-placeholder"
812
+ ></div>
813
+
814
+ <div
815
+ *ngFor="let item of displayedPages(); trackBy: trackByGlobalIndex"
816
+ [id]="'page-card-' + item.globalIndex"
817
+ class="page-grid-item"
818
+ [class.page-cover]="item.globalIndex === 0"
819
+ [class.page-left]="
820
+ item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 0
821
+ "
822
+ [class.page-right]="
823
+ item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 1
824
+ "
825
+ [ngClass]="getSectionColorClass(item.page)"
826
+ [class.active]="item.globalIndex === currentPageIndex()"
827
+ [class.selected]="selectedPageIndices().has(item.globalIndex)"
828
+ [class.drag-before]="
829
+ dragOverIndex() === item.globalIndex && dropSide() === 'before'
830
+ "
831
+ [class.drag-after]="
832
+ dragOverIndex() === item.globalIndex && dropSide() === 'after'
833
+ "
834
+ draggable="true"
835
+ (dragstart)="onDragStart($event, item.globalIndex)"
836
+ (dragover)="onDragOver($event, item.globalIndex)"
837
+ (dragleave)="onDragLeave()"
838
+ (drop)="
839
+ onDrop(
840
+ $event,
841
+ item.globalIndex,
842
+ item.page.documentSectionGuid || item.page.sectionGuid
843
+ )
844
+ "
845
+ (dragend)="onDragEnd()"
846
+ (click)="goToPage(item.globalIndex)"
847
+ (contextmenu)="onPageContextMenu($event, item.globalIndex)"
848
+ >
849
+ <!-- Selection Checkbox -->
850
+ <div
851
+ class="page-select-checkbox-container"
852
+ (click)="$event.stopPropagation()"
853
+ >
854
+ <sp-checkbox
855
+ [checked]="selectedPageIndices().has(item.globalIndex)"
856
+ size="sm"
857
+ (checkedChange)="togglePageSelection(item.globalIndex)"
858
+ ></sp-checkbox>
859
+ </div>
860
+
861
+ <!-- Page Thumbnail -->
862
+ <div
863
+ class="page-thumb-wrapper"
864
+ [style.aspect-ratio]="pageAspectRatio()"
865
+ >
866
+ <img
867
+ [src]="pageImageUrls()[item.globalIndex]"
868
+ class="page-image"
869
+ [alt]="
870
+ 'GLOBAL.PAGES.PAGE_NAME'
871
+ | translate: { number: item.globalIndex + 1 }
872
+ "
873
+ loading="lazy"
874
+ />
875
+ </div>
876
+
877
+ <!-- Page Number -->
878
+ <div class="page-number">{{ item.globalIndex + 1 }}</div>
879
+ </div>
880
+
881
+ <!-- Empty state when section has 0 pages -->
882
+ <div
883
+ *ngIf="displayedPages().length === 0"
884
+ class="w-full py-12 flex flex-col items-center justify-center text-base-content/40 border-2 border-dashed border-base-300 rounded-xl my-4 gap-2"
885
+ >
886
+ <sp-icon
887
+ [icon]="spIconFolder"
888
+ [size]="32"
889
+ class="opacity-40"
890
+ ></sp-icon>
891
+ <span class="text-xs font-medium">{{
892
+ 'GLOBAL.SECTIONS.NO_PAGES' | translate
893
+ }}</span>
894
+ </div>
895
+
896
+ <!-- Add Page Card -->
897
+ <div class="page-grid-item page-grid-item-add" (click)="addPage()">
898
+ <div
899
+ class="page-thumb-wrapper page-add-wrapper"
900
+ [style.aspect-ratio]="pageAspectRatio()"
901
+ >
902
+ <sp-icon
903
+ [icon]="spIconPlus"
904
+ [size]="28"
905
+ class="text-base-content/40"
906
+ ></sp-icon>
907
+ </div>
908
+ <div class="page-number">
909
+ {{ 'GLOBAL.PAGES.ADD_PAGE' | translate }}
910
+ </div>
911
+ </div>
912
+ </div>
913
+ </div>
914
+
915
+ <!-- Selection action bar docked at the bottom of the window -->
916
+ <div *ngIf="selectedCount() > 0" class="page-grid-selection-bar">
917
+ <div class="selection-bar-left flex items-center gap-2">
918
+ <sp-badge variant="primary" size="xs">
919
+ {{
920
+ 'GLOBAL.PAGES.SELECTED_COUNT'
921
+ | translate: { count: selectedCount() }
922
+ }}
923
+ </sp-badge>
924
+ <sp-button
925
+ *ngIf="canSelectAll()"
926
+ variant="ghost"
927
+ size="xs"
928
+ [tooltip]="'GLOBAL.PAGES.SELECT_ALL' | translate"
929
+ (clicked)="selectAll()"
930
+ >
931
+ {{ 'GLOBAL.PAGES.SELECT_ALL' | translate }}
932
+ </sp-button>
933
+ <sp-button
934
+ variant="secondary"
935
+ size="xs"
936
+ [tooltip]="'GLOBAL.PAGES.DESELECT_ALL' | translate"
937
+ (clicked)="deselectAll()"
938
+ >
939
+ {{ 'GLOBAL.PAGES.DESELECT_ALL' | translate }}
940
+ </sp-button>
941
+ </div>
942
+
943
+ <div class="selection-bar-right flex items-center gap-2">
944
+ <!-- Move to Section button -->
945
+ <sp-button
946
+ *ngIf="hasMultipleSections()"
947
+ variant="secondary"
948
+ size="xs"
949
+ [tooltip]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
950
+ (clicked)="openSectionPickerForSelected($event)"
951
+ >
952
+ <sp-icon prefix [icon]="spIconFolder" [size]="13"></sp-icon>
953
+ {{ 'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate }}
954
+ </sp-button>
955
+
956
+ <sp-button
957
+ *ngIf="canDeleteSelected()"
958
+ variant="danger"
959
+ size="xs"
960
+ [tooltip]="'GLOBAL.PAGES.DELETE_SELECTED' | translate"
961
+ (clicked)="deleteSelectedPages()"
962
+ >
963
+ <sp-icon prefix [icon]="spIconTrash" [size]="13"></sp-icon>
964
+ {{ 'GLOBAL.PAGES.DELETE_SELECTED' | translate }}
965
+ </sp-button>
966
+ </div>
967
+ </div>
968
+
969
+ <!-- Loading overlay inside floating window -->
970
+ <div *ngIf="isLoading()" class="page-grid-loader">
971
+ <span class="loading loading-spinner loading-lg text-primary"></span>
972
+ </div>
973
+ </sp-floating-window>
974
+
975
+ <app-page-context-menu
976
+ [visible]="contextMenuVisible"
977
+ [position]="contextMenuPosition"
978
+ [pageIndex]="contextMenuPageIndex"
979
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
980
+ [sections]="sections()"
981
+ [currentPageSectionGuid]="currentPageSectionGuid()"
982
+ (action)="onContextMenuAction($event)"
983
+ (closeMenu)="contextMenuVisible = false"
984
+ ></app-page-context-menu>
985
+
986
+ <!-- Standalone Section Picker Context Menu -->
987
+ <sp-context-menu
988
+ [items]="sectionPickerItems"
989
+ [visible]="sectionPickerVisible"
990
+ [position]="sectionPickerPosition"
991
+ (closeMenu)="sectionPickerVisible = false"
992
+ ></sp-context-menu>
993
+
994
+ <!-- Delete Confirmation Modal -->
995
+ <app-confirm-delete-modal
996
+ *ngIf="showDeleteConfirm()"
997
+ [title]="deleteModalTitle()"
998
+ [message]="deleteModalMessage()"
999
+ (confirm)="confirmDelete()"
1000
+ (cancel)="cancelDelete()"
1001
+ ></app-confirm-delete-modal>
1002
+ `, isInline: true, styles: [":host{display:contents}.page-grid-section-nav{scrollbar-width:thin}.page-grid-section-nav::-webkit-scrollbar{height:4px}.section-nav-chip:hover{border-color:oklch(var(--p));transform:translateY(-1px)}.page-grid-scroll-container{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px 20px 32px}.page-grid-selection-bar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;background-color:oklch(var(--b2));border-top:1px solid oklch(var(--b3));flex-shrink:0;-webkit-user-select:none;user-select:none;box-sizing:border-box}.selection-bar-left,.selection-bar-right{display:flex;align-items:center;gap:8px}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;column-gap:16px;row-gap:20px}.page-grid-item{background-color:oklch(var(--b1));border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:8px;width:140px;border:2px solid oklch(var(--bc) / .22);align-items:center;cursor:pointer;box-sizing:border-box;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease;position:relative;-webkit-user-select:none;user-select:none}.page-grid-item.section-border-gray{border-color:oklch(var(--bc) / .22)}.page-grid-item.section-border-1{border-color:#3b82f6}.page-grid-item.section-border-2{border-color:#10b981}.page-grid-item.section-border-3{border-color:#8b5cf6}.page-grid-item.section-border-4{border-color:#f59e0b}.page-grid-item.section-border-5{border-color:#f43f5e}.page-grid-item.section-border-6{border-color:#06b6d4}.page-grid-item.section-border-7{border-color:#6366f1}.page-grid-item:hover{transform:translateY(-2px);box-shadow:0 4px 12px #00000026;z-index:5}.page-grid-item.active{box-shadow:0 0 0 2px oklch(var(--p));background-color:oklch(var(--p) / .05);z-index:6}.page-grid-item.active .page-number{color:oklch(var(--p));font-weight:700}.page-grid-item.selected{border-color:oklch(var(--p))!important;box-shadow:0 0 0 2px oklch(var(--p))}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:oklch(var(--p));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}.page-grid-item.page-placeholder{visibility:hidden!important;pointer-events:none!important;border:none!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:0!important;min-height:0!important}.page-grid-item.page-cover{border-radius:8px;border:1px solid oklch(var(--b3));padding:8px}.page-grid-item.page-cover .page-thumb-wrapper{border-radius:4px}.page-grid-item.page-left{border-top-right-radius:0!important;border-bottom-right-radius:0!important;border-right:none!important;padding-right:0!important}.page-grid-item.page-left .page-thumb-wrapper{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.page-grid-item.page-right{margin-left:-16px;border-top-left-radius:0!important;border-bottom-left-radius:0!important;border-left:none!important;padding-left:0!important}.page-grid-item.page-right .page-thumb-wrapper{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.page-grid-item.page-right:hover,.page-grid-item.page-right.active{border-left:1px solid oklch(var(--p))!important;margin-left:-17px}.page-thumb-wrapper{width:100%;display:flex;align-items:center;justify-content:center;background-color:oklch(var(--b2));border-radius:4px;overflow:hidden}.page-image{width:100%;height:100%;object-fit:contain}.page-number{font-size:11px;font-weight:600;color:oklch(var(--bc));text-align:center}.page-select-checkbox-container{position:absolute;top:6px;left:6px;z-index:10;opacity:0;transition:opacity .15s ease}.page-grid-item:hover .page-select-checkbox-container,.page-grid-item.selected .page-select-checkbox-container{opacity:1}.page-grid-item-add{border-style:dashed}.page-grid-item-add:hover{background-color:oklch(var(--b2) / .5);border-color:oklch(var(--p))}.page-grid-item-add .page-add-wrapper{border:1px dashed oklch(var(--b3));background:oklch(var(--b1))}.page-grid-loader{position:absolute;inset:0;background:#0006;-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:inherit}.page-grid-scroll-container::-webkit-scrollbar{width:6px;height:6px;background:transparent}.page-grid-scroll-container::-webkit-scrollbar-thumb{border-radius:10px;background:oklch(var(--bc) / .25)}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "component", type: SpIconComponent, selector: "sp-icon", inputs: ["icon", "name", "size", "color", "fill", "strokeWidth", "class", "ariaLabel"] }, { kind: "component", type: SpButtonComponent, selector: "sp-button", inputs: ["variant", "size", "type", "disabled", "loading", "active", "tooltip", "customClass", "fullWidth", "showTextWhileLoading"], outputs: ["clicked", "buttonClick"] }, { kind: "component", type: SpBadgeComponent, selector: "sp-badge", inputs: ["variant", "size", "dot", "roundedFull", "customClass"] }, { kind: "component", type: SpCheckboxComponent, selector: "sp-checkbox", inputs: ["checked", "disabled", "label", "size"], outputs: ["checkedChange", "changed"] }, { kind: "component", type: SpFloatingWindowComponent, selector: "sp-floating-window", inputs: ["title", "icon", "maximizable", "startMaximized", "initialX", "initialY", "initialWidth", "initialHeight", "minWidth", "minHeight", "zIndex", "centerOnOpen", "isOpen"], outputs: ["closed", "positionChange", "sizeChange", "maximizedChange"] }, { kind: "component", type: SpContextMenuComponent, selector: "sp-context-menu", inputs: ["items", "visible", "position", "customClass", "minWidth"], outputs: ["closeMenu", "itemSelected"] }, { kind: "component", type: PageContextMenuComponent, selector: "app-page-context-menu", inputs: ["visible", "position", "pageIndex", "isCurrentPage", "sections", "currentPageSectionGuid"], outputs: ["action", "closeMenu"] }, { kind: "component", type: ConfirmDeleteModalComponent, selector: "app-confirm-delete-modal", inputs: ["title", "message"], outputs: ["confirm", "cancel"] }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }] }); }
1003
+ }
1004
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: PageGridModalComponent, decorators: [{
1005
+ type: Component,
1006
+ args: [{ selector: 'app-page-grid-modal', standalone: true, imports: [
1007
+ CommonModule,
1008
+ TranslateModule,
1009
+ SpIconComponent,
1010
+ SpButtonComponent,
1011
+ SpBadgeComponent,
1012
+ SpCheckboxComponent,
1013
+ SpFloatingWindowComponent,
1014
+ SpContextMenuComponent,
1015
+ PageContextMenuComponent,
1016
+ ConfirmDeleteModalComponent,
1017
+ ], template: `
1018
+ <sp-floating-window
1019
+ [title]="'GLOBAL.PAGES.GRID_VIEW' | translate"
1020
+ [icon]="spIconGrid"
1021
+ [isOpen]="true"
1022
+ [initialWidth]="840"
1023
+ [initialHeight]="580"
1024
+ [minWidth]="420"
1025
+ [minHeight]="300"
1026
+ [centerOnOpen]="true"
1027
+ [maximizable]="true"
1028
+ [zIndex]="2000"
1029
+ (closed)="close()"
1030
+ >
1031
+ <!-- Section Switcher & Quick Drop Bar (if multiple sections exist) -->
1032
+ <div
1033
+ *ngIf="hasMultipleSections()"
1034
+ class="page-grid-section-nav px-4 py-2 bg-base-200/50 border-b border-base-300 flex items-center gap-2 overflow-x-auto select-none shrink-0"
1035
+ >
1036
+ <span
1037
+ class="text-xs font-semibold text-base-content/60 flex items-center gap-1 shrink-0 mr-1"
1038
+ >
1039
+ <sp-icon [icon]="spIconFolder" [size]="13"></sp-icon>
1040
+ <span>{{ 'GLOBAL.SECTIONS.TITLE' | translate }}:</span>
1041
+ </span>
1042
+
1043
+ <!-- Chip "Tout" en premier -->
1044
+ <button
1045
+ type="button"
1046
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
1047
+ [class.bg-primary]="activeSectionFilter() === null"
1048
+ [class.text-primary-content]="activeSectionFilter() === null"
1049
+ [class.border-primary]="activeSectionFilter() === null"
1050
+ [class.shadow-xs]="activeSectionFilter() === null"
1051
+ [class.bg-base-100]="activeSectionFilter() !== null"
1052
+ [class.border-base-300]="activeSectionFilter() !== null"
1053
+ [class.text-base-content]="activeSectionFilter() !== null"
1054
+ (click)="filterBySection(null)"
1055
+ >
1056
+ <span>{{ 'GLOBAL.SECTIONS.ALL' | translate }}</span>
1057
+ <span
1058
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
1059
+ [class.bg-primary-content/20]="activeSectionFilter() === null"
1060
+ [class.bg-base-200]="activeSectionFilter() !== null"
1061
+ >
1062
+ {{ pages().length }}
1063
+ </span>
1064
+ </button>
1065
+
1066
+ <!-- Les autres sections ensuite -->
1067
+ <button
1068
+ *ngFor="let sec of sections(); let sIdx = index"
1069
+ type="button"
1070
+ class="section-nav-chip flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-all cursor-pointer"
1071
+ [class.bg-primary]="activeSectionFilter() === sec.guid"
1072
+ [class.text-primary-content]="activeSectionFilter() === sec.guid"
1073
+ [class.border-primary]="activeSectionFilter() === sec.guid"
1074
+ [class.shadow-xs]="activeSectionFilter() === sec.guid"
1075
+ [class.bg-base-100]="activeSectionFilter() !== sec.guid"
1076
+ [class.text-base-content]="activeSectionFilter() !== sec.guid"
1077
+ [style.border-color]="
1078
+ activeSectionFilter() !== sec.guid ? getSectionColor(sIdx) : null
1079
+ "
1080
+ [class.!border-primary]="dragOverSectionGuid() === sec.guid"
1081
+ [class.!bg-primary/20]="dragOverSectionGuid() === sec.guid"
1082
+ (click)="filterBySection(sec.guid)"
1083
+ (dragover)="onEmptySectionDragOver($event, sec.guid)"
1084
+ (dragleave)="dragOverSectionGuid.set(null)"
1085
+ (drop)="onEmptySectionDrop($event, sec.guid)"
1086
+ [title]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
1087
+ >
1088
+ <span
1089
+ class="w-2 h-2 rounded-full shrink-0"
1090
+ [style.background-color]="getSectionColor(sIdx)"
1091
+ ></span>
1092
+ <span class="truncate max-w-[130px]">{{ sec.name }}</span>
1093
+ <span
1094
+ class="text-[10px] px-1.5 py-0.2 rounded-full"
1095
+ [class.bg-primary-content/20]="activeSectionFilter() === sec.guid"
1096
+ [class.bg-base-200]="activeSectionFilter() !== sec.guid"
1097
+ >
1098
+ {{ getSectionPageCount(sec.guid) }}
1099
+ </span>
1100
+ </button>
1101
+ </div>
1102
+
1103
+ <!-- Scrollable content area inside floating window body -->
1104
+ <div class="page-grid-scroll-container">
1105
+ <div class="page-grid-content">
1106
+ <!-- Emplacement Page 0 non affichée pour décaler la couverture (page 1) à droite -->
1107
+ <div
1108
+ *ngIf="needsLeadingSpacer()"
1109
+ class="page-grid-item page-placeholder"
1110
+ ></div>
1111
+
1112
+ <div
1113
+ *ngFor="let item of displayedPages(); trackBy: trackByGlobalIndex"
1114
+ [id]="'page-card-' + item.globalIndex"
1115
+ class="page-grid-item"
1116
+ [class.page-cover]="item.globalIndex === 0"
1117
+ [class.page-left]="
1118
+ item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 0
1119
+ "
1120
+ [class.page-right]="
1121
+ item.globalIndex > 0 && (item.globalIndex + 1) % 2 === 1
1122
+ "
1123
+ [ngClass]="getSectionColorClass(item.page)"
1124
+ [class.active]="item.globalIndex === currentPageIndex()"
1125
+ [class.selected]="selectedPageIndices().has(item.globalIndex)"
1126
+ [class.drag-before]="
1127
+ dragOverIndex() === item.globalIndex && dropSide() === 'before'
1128
+ "
1129
+ [class.drag-after]="
1130
+ dragOverIndex() === item.globalIndex && dropSide() === 'after'
1131
+ "
1132
+ draggable="true"
1133
+ (dragstart)="onDragStart($event, item.globalIndex)"
1134
+ (dragover)="onDragOver($event, item.globalIndex)"
1135
+ (dragleave)="onDragLeave()"
1136
+ (drop)="
1137
+ onDrop(
1138
+ $event,
1139
+ item.globalIndex,
1140
+ item.page.documentSectionGuid || item.page.sectionGuid
1141
+ )
1142
+ "
1143
+ (dragend)="onDragEnd()"
1144
+ (click)="goToPage(item.globalIndex)"
1145
+ (contextmenu)="onPageContextMenu($event, item.globalIndex)"
1146
+ >
1147
+ <!-- Selection Checkbox -->
1148
+ <div
1149
+ class="page-select-checkbox-container"
1150
+ (click)="$event.stopPropagation()"
1151
+ >
1152
+ <sp-checkbox
1153
+ [checked]="selectedPageIndices().has(item.globalIndex)"
1154
+ size="sm"
1155
+ (checkedChange)="togglePageSelection(item.globalIndex)"
1156
+ ></sp-checkbox>
1157
+ </div>
1158
+
1159
+ <!-- Page Thumbnail -->
1160
+ <div
1161
+ class="page-thumb-wrapper"
1162
+ [style.aspect-ratio]="pageAspectRatio()"
1163
+ >
1164
+ <img
1165
+ [src]="pageImageUrls()[item.globalIndex]"
1166
+ class="page-image"
1167
+ [alt]="
1168
+ 'GLOBAL.PAGES.PAGE_NAME'
1169
+ | translate: { number: item.globalIndex + 1 }
1170
+ "
1171
+ loading="lazy"
1172
+ />
1173
+ </div>
1174
+
1175
+ <!-- Page Number -->
1176
+ <div class="page-number">{{ item.globalIndex + 1 }}</div>
1177
+ </div>
1178
+
1179
+ <!-- Empty state when section has 0 pages -->
1180
+ <div
1181
+ *ngIf="displayedPages().length === 0"
1182
+ class="w-full py-12 flex flex-col items-center justify-center text-base-content/40 border-2 border-dashed border-base-300 rounded-xl my-4 gap-2"
1183
+ >
1184
+ <sp-icon
1185
+ [icon]="spIconFolder"
1186
+ [size]="32"
1187
+ class="opacity-40"
1188
+ ></sp-icon>
1189
+ <span class="text-xs font-medium">{{
1190
+ 'GLOBAL.SECTIONS.NO_PAGES' | translate
1191
+ }}</span>
1192
+ </div>
1193
+
1194
+ <!-- Add Page Card -->
1195
+ <div class="page-grid-item page-grid-item-add" (click)="addPage()">
1196
+ <div
1197
+ class="page-thumb-wrapper page-add-wrapper"
1198
+ [style.aspect-ratio]="pageAspectRatio()"
1199
+ >
1200
+ <sp-icon
1201
+ [icon]="spIconPlus"
1202
+ [size]="28"
1203
+ class="text-base-content/40"
1204
+ ></sp-icon>
1205
+ </div>
1206
+ <div class="page-number">
1207
+ {{ 'GLOBAL.PAGES.ADD_PAGE' | translate }}
1208
+ </div>
1209
+ </div>
1210
+ </div>
1211
+ </div>
1212
+
1213
+ <!-- Selection action bar docked at the bottom of the window -->
1214
+ <div *ngIf="selectedCount() > 0" class="page-grid-selection-bar">
1215
+ <div class="selection-bar-left flex items-center gap-2">
1216
+ <sp-badge variant="primary" size="xs">
1217
+ {{
1218
+ 'GLOBAL.PAGES.SELECTED_COUNT'
1219
+ | translate: { count: selectedCount() }
1220
+ }}
1221
+ </sp-badge>
1222
+ <sp-button
1223
+ *ngIf="canSelectAll()"
1224
+ variant="ghost"
1225
+ size="xs"
1226
+ [tooltip]="'GLOBAL.PAGES.SELECT_ALL' | translate"
1227
+ (clicked)="selectAll()"
1228
+ >
1229
+ {{ 'GLOBAL.PAGES.SELECT_ALL' | translate }}
1230
+ </sp-button>
1231
+ <sp-button
1232
+ variant="secondary"
1233
+ size="xs"
1234
+ [tooltip]="'GLOBAL.PAGES.DESELECT_ALL' | translate"
1235
+ (clicked)="deselectAll()"
1236
+ >
1237
+ {{ 'GLOBAL.PAGES.DESELECT_ALL' | translate }}
1238
+ </sp-button>
1239
+ </div>
1240
+
1241
+ <div class="selection-bar-right flex items-center gap-2">
1242
+ <!-- Move to Section button -->
1243
+ <sp-button
1244
+ *ngIf="hasMultipleSections()"
1245
+ variant="secondary"
1246
+ size="xs"
1247
+ [tooltip]="'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate"
1248
+ (clicked)="openSectionPickerForSelected($event)"
1249
+ >
1250
+ <sp-icon prefix [icon]="spIconFolder" [size]="13"></sp-icon>
1251
+ {{ 'GLOBAL.SECTIONS.MOVE_PAGE_TO_SECTION' | translate }}
1252
+ </sp-button>
1253
+
1254
+ <sp-button
1255
+ *ngIf="canDeleteSelected()"
1256
+ variant="danger"
1257
+ size="xs"
1258
+ [tooltip]="'GLOBAL.PAGES.DELETE_SELECTED' | translate"
1259
+ (clicked)="deleteSelectedPages()"
1260
+ >
1261
+ <sp-icon prefix [icon]="spIconTrash" [size]="13"></sp-icon>
1262
+ {{ 'GLOBAL.PAGES.DELETE_SELECTED' | translate }}
1263
+ </sp-button>
1264
+ </div>
1265
+ </div>
1266
+
1267
+ <!-- Loading overlay inside floating window -->
1268
+ <div *ngIf="isLoading()" class="page-grid-loader">
1269
+ <span class="loading loading-spinner loading-lg text-primary"></span>
1270
+ </div>
1271
+ </sp-floating-window>
1272
+
1273
+ <app-page-context-menu
1274
+ [visible]="contextMenuVisible"
1275
+ [position]="contextMenuPosition"
1276
+ [pageIndex]="contextMenuPageIndex"
1277
+ [isCurrentPage]="contextMenuPageIndex === currentPageIndex()"
1278
+ [sections]="sections()"
1279
+ [currentPageSectionGuid]="currentPageSectionGuid()"
1280
+ (action)="onContextMenuAction($event)"
1281
+ (closeMenu)="contextMenuVisible = false"
1282
+ ></app-page-context-menu>
1283
+
1284
+ <!-- Standalone Section Picker Context Menu -->
1285
+ <sp-context-menu
1286
+ [items]="sectionPickerItems"
1287
+ [visible]="sectionPickerVisible"
1288
+ [position]="sectionPickerPosition"
1289
+ (closeMenu)="sectionPickerVisible = false"
1290
+ ></sp-context-menu>
1291
+
1292
+ <!-- Delete Confirmation Modal -->
1293
+ <app-confirm-delete-modal
1294
+ *ngIf="showDeleteConfirm()"
1295
+ [title]="deleteModalTitle()"
1296
+ [message]="deleteModalMessage()"
1297
+ (confirm)="confirmDelete()"
1298
+ (cancel)="cancelDelete()"
1299
+ ></app-confirm-delete-modal>
1300
+ `, styles: [":host{display:contents}.page-grid-section-nav{scrollbar-width:thin}.page-grid-section-nav::-webkit-scrollbar{height:4px}.section-nav-chip:hover{border-color:oklch(var(--p));transform:translateY(-1px)}.page-grid-scroll-container{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;padding:16px 20px 32px}.page-grid-selection-bar{display:flex;align-items:center;justify-content:space-between;padding:8px 16px;background-color:oklch(var(--b2));border-top:1px solid oklch(var(--b3));flex-shrink:0;-webkit-user-select:none;user-select:none;box-sizing:border-box}.selection-bar-left,.selection-bar-right{display:flex;align-items:center;gap:8px}.page-grid-content{display:flex;flex-wrap:wrap;justify-content:center;align-items:flex-start;column-gap:16px;row-gap:20px}.page-grid-item{background-color:oklch(var(--b1));border-radius:8px;padding:8px;display:flex;flex-direction:column;gap:8px;width:140px;border:2px solid oklch(var(--bc) / .22);align-items:center;cursor:pointer;box-sizing:border-box;transition:transform .2s ease,border-color .2s ease,box-shadow .2s ease;position:relative;-webkit-user-select:none;user-select:none}.page-grid-item.section-border-gray{border-color:oklch(var(--bc) / .22)}.page-grid-item.section-border-1{border-color:#3b82f6}.page-grid-item.section-border-2{border-color:#10b981}.page-grid-item.section-border-3{border-color:#8b5cf6}.page-grid-item.section-border-4{border-color:#f59e0b}.page-grid-item.section-border-5{border-color:#f43f5e}.page-grid-item.section-border-6{border-color:#06b6d4}.page-grid-item.section-border-7{border-color:#6366f1}.page-grid-item:hover{transform:translateY(-2px);box-shadow:0 4px 12px #00000026;z-index:5}.page-grid-item.active{box-shadow:0 0 0 2px oklch(var(--p));background-color:oklch(var(--p) / .05);z-index:6}.page-grid-item.active .page-number{color:oklch(var(--p));font-weight:700}.page-grid-item.selected{border-color:oklch(var(--p))!important;box-shadow:0 0 0 2px oklch(var(--p))}.page-grid-item:before,.page-grid-item:after{content:\"\";position:absolute;top:0;bottom:0;width:4px;background:oklch(var(--p));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}.page-grid-item.page-placeholder{visibility:hidden!important;pointer-events:none!important;border:none!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:0!important;min-height:0!important}.page-grid-item.page-cover{border-radius:8px;border:1px solid oklch(var(--b3));padding:8px}.page-grid-item.page-cover .page-thumb-wrapper{border-radius:4px}.page-grid-item.page-left{border-top-right-radius:0!important;border-bottom-right-radius:0!important;border-right:none!important;padding-right:0!important}.page-grid-item.page-left .page-thumb-wrapper{border-top-right-radius:0!important;border-bottom-right-radius:0!important}.page-grid-item.page-right{margin-left:-16px;border-top-left-radius:0!important;border-bottom-left-radius:0!important;border-left:none!important;padding-left:0!important}.page-grid-item.page-right .page-thumb-wrapper{border-top-left-radius:0!important;border-bottom-left-radius:0!important}.page-grid-item.page-right:hover,.page-grid-item.page-right.active{border-left:1px solid oklch(var(--p))!important;margin-left:-17px}.page-thumb-wrapper{width:100%;display:flex;align-items:center;justify-content:center;background-color:oklch(var(--b2));border-radius:4px;overflow:hidden}.page-image{width:100%;height:100%;object-fit:contain}.page-number{font-size:11px;font-weight:600;color:oklch(var(--bc));text-align:center}.page-select-checkbox-container{position:absolute;top:6px;left:6px;z-index:10;opacity:0;transition:opacity .15s ease}.page-grid-item:hover .page-select-checkbox-container,.page-grid-item.selected .page-select-checkbox-container{opacity:1}.page-grid-item-add{border-style:dashed}.page-grid-item-add:hover{background-color:oklch(var(--b2) / .5);border-color:oklch(var(--p))}.page-grid-item-add .page-add-wrapper{border:1px dashed oklch(var(--b3));background:oklch(var(--b1))}.page-grid-loader{position:absolute;inset:0;background:#0006;-webkit-backdrop-filter:blur(1px);backdrop-filter:blur(1px);display:flex;justify-content:center;align-items:center;z-index:3000;border-radius:inherit}.page-grid-scroll-container::-webkit-scrollbar{width:6px;height:6px;background:transparent}.page-grid-scroll-container::-webkit-scrollbar-thumb{border-radius:10px;background:oklch(var(--bc) / .25)}\n"] }]
1301
+ }], ctorParameters: () => [], propDecorators: { onPageSelect: [{
1302
+ type: Input
1303
+ }] } });
1304
+
1305
+ export { PageGridModalComponent };
1306
+ //# sourceMappingURL=solidpepper-solidpepper-soliddesigner-page-grid-modal.component-BFBuR2rJ.mjs.map