@shival99/z-ui 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/features/media.css +14 -0
- package/assets/css/features/office.css +11 -0
- package/assets/css/global.css +5 -9
- package/assets/css/overlay.css +28 -3
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs +16 -2
- package/fesm2022/shival99-z-ui-components-z-autocomplete.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-command.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-command.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-drawer.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs +4 -3
- package/fesm2022/shival99-z-ui-components-z-gallery.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-loading.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-loading.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-menu.mjs +4 -4
- package/fesm2022/shival99-z-ui-components-z-menu.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-modal.mjs +2 -2
- package/fesm2022/shival99-z-ui-components-z-modal.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-overlay.mjs +32 -29
- package/fesm2022/shival99-z-ui-components-z-overlay.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-select.mjs +20 -2
- package/fesm2022/shival99-z-ui-components-z-select.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-components-z-table.mjs +7 -7
- package/fesm2022/shival99-z-ui-components-z-table.mjs.map +1 -1
- package/fesm2022/shival99-z-ui-services-excel.mjs +672 -0
- package/fesm2022/shival99-z-ui-services-excel.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-services-office.mjs +123 -0
- package/fesm2022/shival99-z-ui-services-office.mjs.map +1 -0
- package/fesm2022/shival99-z-ui-services.mjs +2 -778
- package/fesm2022/shival99-z-ui-services.mjs.map +1 -1
- package/package.json +22 -6
- package/types/shival99-z-ui-components-z-autocomplete.d.ts +2 -1
- package/types/shival99-z-ui-components-z-calendar.d.ts +4 -4
- package/types/shival99-z-ui-components-z-overlay.d.ts +11 -12
- package/types/shival99-z-ui-components-z-select.d.ts +4 -2
- package/types/shival99-z-ui-components-z-table.d.ts +2 -2
- package/types/shival99-z-ui-services-excel.d.ts +36 -0
- package/types/shival99-z-ui-services-office.d.ts +15 -0
- package/types/shival99-z-ui-services.d.ts +151 -194
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, EventEmitter, Inject, PLATFORM_ID, Injectable, inject, Injector, TemplateRef, DestroyRef, signal, computed, effect } from '@angular/core';
|
|
3
|
-
import { zNormalize
|
|
3
|
+
import { zNormalize } from '@shival99/z-ui/utils';
|
|
4
4
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
5
5
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
6
6
|
import { Subject, takeUntil, fromEvent, filter, firstValueFrom, from, switchMap, of, catchError, throwError, tap, map, defer, BehaviorSubject } from 'rxjs';
|
|
7
7
|
import { ZOverlayService } from '@shival99/z-ui/components/z-overlay';
|
|
8
|
-
import * as ExcelJS from 'exceljs';
|
|
9
|
-
import { saveAs } from 'file-saver';
|
|
10
|
-
import * as XLSX from 'xlsx';
|
|
11
8
|
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
|
|
12
9
|
import { Router } from '@angular/router';
|
|
13
10
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -695,779 +692,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
695
692
|
args: [{ providedIn: 'root' }]
|
|
696
693
|
}] });
|
|
697
694
|
|
|
698
|
-
class ZExcelService {
|
|
699
|
-
static _isHeaderConfig(config) {
|
|
700
|
-
if (!config || typeof config !== 'object') {
|
|
701
|
-
return false;
|
|
702
|
-
}
|
|
703
|
-
return config.constructor === Object;
|
|
704
|
-
}
|
|
705
|
-
static _getHeaderConfig(col) {
|
|
706
|
-
const empty = {
|
|
707
|
-
content: undefined,
|
|
708
|
-
class: undefined,
|
|
709
|
-
style: undefined,
|
|
710
|
-
align: undefined,
|
|
711
|
-
tooltip: undefined,
|
|
712
|
-
rowSpan: undefined,
|
|
713
|
-
colSpan: undefined,
|
|
714
|
-
};
|
|
715
|
-
if (!col) {
|
|
716
|
-
return empty;
|
|
717
|
-
}
|
|
718
|
-
if (!ZExcelService._isHeaderConfig(col.header)) {
|
|
719
|
-
return { ...empty, content: col.header };
|
|
720
|
-
}
|
|
721
|
-
return {
|
|
722
|
-
content: col.header.content,
|
|
723
|
-
class: undefined,
|
|
724
|
-
style: undefined,
|
|
725
|
-
align: col.header.align,
|
|
726
|
-
tooltip: undefined,
|
|
727
|
-
rowSpan: undefined,
|
|
728
|
-
colSpan: undefined,
|
|
729
|
-
};
|
|
730
|
-
}
|
|
731
|
-
async exportExcel(config, options = {}) {
|
|
732
|
-
try {
|
|
733
|
-
const result = await ZExcelService.exportExcelStatic(config);
|
|
734
|
-
await this._saveFile(result, options);
|
|
735
|
-
}
|
|
736
|
-
catch (error) {
|
|
737
|
-
console.error('Error exporting Excel:', error);
|
|
738
|
-
options.toast?.error?.('Failed to export Excel file');
|
|
739
|
-
throw error;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
async exportFromTable(config, options = {}) {
|
|
743
|
-
try {
|
|
744
|
-
const excelColumns = this._convertTableColumnsToExcel(config);
|
|
745
|
-
const excelConfig = {
|
|
746
|
-
fileName: config.fileName,
|
|
747
|
-
columns: excelColumns,
|
|
748
|
-
source: config.source,
|
|
749
|
-
};
|
|
750
|
-
await this.exportExcel(excelConfig, options);
|
|
751
|
-
}
|
|
752
|
-
catch (error) {
|
|
753
|
-
console.error('Error exporting from table:', error);
|
|
754
|
-
options.toast?.error?.('Failed to export Excel file');
|
|
755
|
-
throw error;
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
async exportFromElement(elementId, fileName = 'export', options = {}) {
|
|
759
|
-
try {
|
|
760
|
-
const result = await ZExcelService.exportFromElementStatic(elementId, fileName);
|
|
761
|
-
await this._saveFile(result, options);
|
|
762
|
-
}
|
|
763
|
-
catch (error) {
|
|
764
|
-
console.error('Error exporting from element:', error);
|
|
765
|
-
options.toast?.error?.('Failed to export Excel file');
|
|
766
|
-
throw error;
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
async exportFromElementXlsx(elementId, fileName = 'export', options = {}) {
|
|
770
|
-
try {
|
|
771
|
-
const element = document.getElementById(elementId);
|
|
772
|
-
if (!element) {
|
|
773
|
-
throw new Error(`Element with id "${elementId}" not found`);
|
|
774
|
-
}
|
|
775
|
-
const table = element.querySelector('table') || element;
|
|
776
|
-
if (table.tagName !== 'TABLE') {
|
|
777
|
-
throw new Error('Element must be a table or contain a table');
|
|
778
|
-
}
|
|
779
|
-
const workbook = XLSX.utils.table_to_book(table, { sheet: 'Sheet1' });
|
|
780
|
-
const { addTimestamp = true } = options;
|
|
781
|
-
let finalFileName = `${fileName}.xlsx`;
|
|
782
|
-
if (addTimestamp) {
|
|
783
|
-
finalFileName = `${fileName}_${ZExcelService._formatTimestamp()}.xlsx`;
|
|
784
|
-
}
|
|
785
|
-
XLSX.writeFile(workbook, finalFileName);
|
|
786
|
-
if (options.showNotification !== false) {
|
|
787
|
-
options.toast?.success?.(`File "${finalFileName}" has been downloaded`);
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
catch (error) {
|
|
791
|
-
console.error('Error exporting from element with XLSX:', error);
|
|
792
|
-
options.toast?.error?.('Failed to export Excel file');
|
|
793
|
-
throw error;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
static async exportExcelStatic(config) {
|
|
797
|
-
const workbook = new ExcelJS.Workbook();
|
|
798
|
-
const { fileName = 'export', columns, source } = config;
|
|
799
|
-
for (const sheetSource of source) {
|
|
800
|
-
const sheet = workbook.addWorksheet(sheetSource.sheetName || 'Sheet1');
|
|
801
|
-
const flatColumns = ZExcelService._flattenColumns(columns);
|
|
802
|
-
const headerLevels = ZExcelService._calculateHeaderLevels(columns);
|
|
803
|
-
sheet.columns = flatColumns.map(col => ({
|
|
804
|
-
key: col.id,
|
|
805
|
-
header: col.header || col.id,
|
|
806
|
-
width: col.width || Z_EXCEL_WIDTH_LIMITS.default,
|
|
807
|
-
style: { font: Z_EXCEL_DEFAULT_CONFIG.font },
|
|
808
|
-
}));
|
|
809
|
-
ZExcelService._createHeaderRows(sheet, columns, headerLevels);
|
|
810
|
-
const dataStartRow = headerLevels + 1;
|
|
811
|
-
const mergedCells = new Set();
|
|
812
|
-
const mergeRegions = ZExcelService._processMergeRegions(flatColumns, sheetSource.data, dataStartRow);
|
|
813
|
-
sheetSource.data.forEach((dataItem, rowIndex) => {
|
|
814
|
-
const row = sheet.addRow([]);
|
|
815
|
-
flatColumns.forEach((col, colIndex) => {
|
|
816
|
-
const cell = row.getCell(colIndex + 1);
|
|
817
|
-
const cellValue = ZExcelService._getCellValue(col, dataItem, rowIndex, sheetSource.data);
|
|
818
|
-
cell.value = cellValue;
|
|
819
|
-
});
|
|
820
|
-
row.eachCell((cell, colNumber) => {
|
|
821
|
-
const colConfig = flatColumns[colNumber - 1];
|
|
822
|
-
const currentRow = dataStartRow + rowIndex + 1;
|
|
823
|
-
const cellKey = `${currentRow}:${colNumber}`;
|
|
824
|
-
if (mergedCells.has(cellKey)) {
|
|
825
|
-
return;
|
|
826
|
-
}
|
|
827
|
-
cell.font = {
|
|
828
|
-
name: Z_EXCEL_DEFAULT_CONFIG.font.name,
|
|
829
|
-
size: Z_EXCEL_DEFAULT_CONFIG.font.size,
|
|
830
|
-
...(cell.font || {}),
|
|
831
|
-
};
|
|
832
|
-
if (colConfig.formatNum) {
|
|
833
|
-
const rawValue = ZExcelService._getCellValue(colConfig, dataItem, rowIndex, sheetSource.data);
|
|
834
|
-
zFormatNumExcel(cell, rawValue, colConfig.formatNum);
|
|
835
|
-
}
|
|
836
|
-
if (!colConfig.formatNum && colConfig.format) {
|
|
837
|
-
const context = {
|
|
838
|
-
row: dataItem,
|
|
839
|
-
rowIndex,
|
|
840
|
-
data: sheetSource.data,
|
|
841
|
-
cell: cell,
|
|
842
|
-
};
|
|
843
|
-
colConfig.format(context);
|
|
844
|
-
}
|
|
845
|
-
if (colConfig.align) {
|
|
846
|
-
cell.alignment = {
|
|
847
|
-
horizontal: colConfig.align,
|
|
848
|
-
vertical: 'middle',
|
|
849
|
-
...(cell.alignment || {}),
|
|
850
|
-
};
|
|
851
|
-
}
|
|
852
|
-
if (colConfig.note) {
|
|
853
|
-
const noteText = colConfig.note(dataItem, rowIndex, sheetSource.data);
|
|
854
|
-
if (noteText) {
|
|
855
|
-
cell.note = noteText;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
cell.border = Z_EXCEL_BORDER_THIN;
|
|
859
|
-
});
|
|
860
|
-
});
|
|
861
|
-
mergeRegions.forEach(region => {
|
|
862
|
-
try {
|
|
863
|
-
sheet.mergeCells(region.startRow, region.startCol, region.endRow, region.endCol);
|
|
864
|
-
const mergedCell = sheet.getCell(region.startRow, region.startCol);
|
|
865
|
-
if (!mergedCell.alignment) {
|
|
866
|
-
mergedCell.alignment = { vertical: 'middle' };
|
|
867
|
-
}
|
|
868
|
-
for (let r = region.startRow; r <= region.endRow; r++) {
|
|
869
|
-
for (let c = region.startCol; c <= region.endCol; c++) {
|
|
870
|
-
mergedCells.add(`${r}:${c}`);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
catch (error) {
|
|
875
|
-
console.warn(`Failed to merge cells:`, error);
|
|
876
|
-
}
|
|
877
|
-
});
|
|
878
|
-
ZExcelService._applyAutoFitWidth(sheet, flatColumns);
|
|
879
|
-
}
|
|
880
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
881
|
-
return { buffer: buffer, fileName: `${fileName}.xlsx` };
|
|
882
|
-
}
|
|
883
|
-
static async exportFromElementStatic(elementId, fileName = 'export') {
|
|
884
|
-
const workbook = new ExcelJS.Workbook();
|
|
885
|
-
const element = document.getElementById(elementId);
|
|
886
|
-
if (!element) {
|
|
887
|
-
throw new Error(`Element with id "${elementId}" not found`);
|
|
888
|
-
}
|
|
889
|
-
const sheet = workbook.addWorksheet('Sheet1');
|
|
890
|
-
const table = element.querySelector('table') || element;
|
|
891
|
-
if (table.tagName !== 'TABLE') {
|
|
892
|
-
throw new Error('Element must be a table or contain a table');
|
|
893
|
-
}
|
|
894
|
-
ZExcelService._processTableElement(sheet, table);
|
|
895
|
-
ZExcelService._applyAutoFitWidthForTable(sheet);
|
|
896
|
-
const buffer = await workbook.xlsx.writeBuffer();
|
|
897
|
-
return { buffer: buffer, fileName: `${fileName}.xlsx` };
|
|
898
|
-
}
|
|
899
|
-
async _saveFile(result, options) {
|
|
900
|
-
const { addTimestamp = true, showNotification = true } = options;
|
|
901
|
-
let finalFileName = result.fileName;
|
|
902
|
-
if (addTimestamp) {
|
|
903
|
-
const timestamp = ZExcelService._formatTimestamp();
|
|
904
|
-
if (!finalFileName.includes(timestamp.slice(0, 8))) {
|
|
905
|
-
finalFileName = finalFileName.replace('.xlsx', `_${timestamp}.xlsx`);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
const blob = new Blob([result.buffer], {
|
|
909
|
-
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
910
|
-
});
|
|
911
|
-
saveAs(blob, finalFileName);
|
|
912
|
-
if (showNotification) {
|
|
913
|
-
options.toast?.success?.(`File "${finalFileName}" has been downloaded`);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
_convertTableColumnsToExcel(config) {
|
|
917
|
-
const { tableColumns, excelOverrides = {}, excludeColumns = [], headerResolver } = config;
|
|
918
|
-
const convertColumn = (col) => {
|
|
919
|
-
if (excludeColumns.includes(col.id)) {
|
|
920
|
-
return null;
|
|
921
|
-
}
|
|
922
|
-
if (['select', 'expand', 'actions'].includes(col.id)) {
|
|
923
|
-
return null;
|
|
924
|
-
}
|
|
925
|
-
const headerConfig = ZExcelService._getHeaderConfig(col);
|
|
926
|
-
let headerText = '';
|
|
927
|
-
headerText = col.id;
|
|
928
|
-
if (headerResolver) {
|
|
929
|
-
headerText = headerResolver(col);
|
|
930
|
-
}
|
|
931
|
-
if (!headerResolver && typeof headerConfig.content === 'string') {
|
|
932
|
-
headerText = headerConfig.content;
|
|
933
|
-
}
|
|
934
|
-
if (!headerResolver && typeof headerConfig.content === 'function') {
|
|
935
|
-
const result = headerConfig.content();
|
|
936
|
-
headerText = typeof result === 'string' ? result : col.id;
|
|
937
|
-
}
|
|
938
|
-
const excelCol = {
|
|
939
|
-
id: col.id,
|
|
940
|
-
header: headerText,
|
|
941
|
-
accessorKey: col.accessorKey,
|
|
942
|
-
accessorFn: col.accessorFn ? (row) => col.accessorFn(row) : undefined,
|
|
943
|
-
autoFit: true,
|
|
944
|
-
align: headerConfig.align,
|
|
945
|
-
visible: typeof col.visible === 'boolean' ? col.visible : true,
|
|
946
|
-
};
|
|
947
|
-
const override = excelOverrides[col.id];
|
|
948
|
-
if (override) {
|
|
949
|
-
Object.assign(excelCol, override);
|
|
950
|
-
}
|
|
951
|
-
if (col.columns && col.columns.length > 0) {
|
|
952
|
-
excelCol.columns = col.columns
|
|
953
|
-
.map((childCol) => convertColumn(childCol))
|
|
954
|
-
.filter((c) => c !== null);
|
|
955
|
-
if (excelCol.columns && excelCol.columns.length > 0) {
|
|
956
|
-
excelCol.headerColSpan = ZExcelService._getLeafCount(excelCol.columns);
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
return excelCol;
|
|
960
|
-
};
|
|
961
|
-
return tableColumns
|
|
962
|
-
.map((col) => convertColumn(col))
|
|
963
|
-
.filter((c) => c !== null);
|
|
964
|
-
}
|
|
965
|
-
static _flattenColumns(columns) {
|
|
966
|
-
const result = [];
|
|
967
|
-
const flatten = (cols) => {
|
|
968
|
-
for (const col of cols) {
|
|
969
|
-
if (col.visible === false) {
|
|
970
|
-
continue;
|
|
971
|
-
}
|
|
972
|
-
if (col.columns && col.columns.length > 0) {
|
|
973
|
-
flatten(col.columns);
|
|
974
|
-
continue;
|
|
975
|
-
}
|
|
976
|
-
result.push(col);
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
flatten(columns);
|
|
980
|
-
return result;
|
|
981
|
-
}
|
|
982
|
-
static _calculateHeaderLevels(columns) {
|
|
983
|
-
const getLevel = (cols, currentLevel = 1) => {
|
|
984
|
-
let maxLevel = currentLevel;
|
|
985
|
-
for (const col of cols) {
|
|
986
|
-
let currentColLevel = currentLevel;
|
|
987
|
-
if (col.headerRowSpan && col.headerRowSpan > 1) {
|
|
988
|
-
currentColLevel = currentLevel + col.headerRowSpan - 1;
|
|
989
|
-
}
|
|
990
|
-
if (col.columns && col.columns.length > 0) {
|
|
991
|
-
if (!col.headerRowSpan || col.headerRowSpan <= 1) {
|
|
992
|
-
const childLevel = getLevel(col.columns, currentLevel + 1);
|
|
993
|
-
currentColLevel = Math.max(currentColLevel, childLevel);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
maxLevel = Math.max(maxLevel, currentColLevel);
|
|
997
|
-
}
|
|
998
|
-
return maxLevel;
|
|
999
|
-
};
|
|
1000
|
-
return getLevel(columns);
|
|
1001
|
-
}
|
|
1002
|
-
static _createHeaderRows(sheet, columns, maxLevels) {
|
|
1003
|
-
const headerStructure = [];
|
|
1004
|
-
for (let i = 0; i < maxLevels; i++) {
|
|
1005
|
-
headerStructure[i] = [];
|
|
1006
|
-
}
|
|
1007
|
-
ZExcelService._buildHeaderStructure(columns, headerStructure, 0, maxLevels);
|
|
1008
|
-
const processedMergeRegions = new Set();
|
|
1009
|
-
headerStructure.forEach((row, rowIndex) => {
|
|
1010
|
-
const headerRow = sheet.getRow(rowIndex + 1);
|
|
1011
|
-
const sortedRow = row.sort((a, b) => (a.startCol || 0) - (b.startCol || 0));
|
|
1012
|
-
sortedRow.forEach((headerCell) => {
|
|
1013
|
-
if (headerCell.isProcessed || headerCell.isEmpty) {
|
|
1014
|
-
return;
|
|
1015
|
-
}
|
|
1016
|
-
const colIndex = (headerCell.startCol || 0) + 1;
|
|
1017
|
-
const cell = headerRow.getCell(colIndex);
|
|
1018
|
-
cell.value = headerCell.header;
|
|
1019
|
-
if (headerCell.colSpan > 1 || headerCell.rowSpan > 1) {
|
|
1020
|
-
const startRow = rowIndex + 1;
|
|
1021
|
-
const endRow = startRow + headerCell.rowSpan - 1;
|
|
1022
|
-
const startCol = colIndex;
|
|
1023
|
-
const endCol = colIndex + headerCell.colSpan - 1;
|
|
1024
|
-
const mergeKey = `${startRow}:${startCol}-${endRow}:${endCol}`;
|
|
1025
|
-
if (!processedMergeRegions.has(mergeKey)) {
|
|
1026
|
-
try {
|
|
1027
|
-
sheet.mergeCells(startRow, startCol, endRow, endCol);
|
|
1028
|
-
processedMergeRegions.add(mergeKey);
|
|
1029
|
-
headerCell.isProcessed = true;
|
|
1030
|
-
}
|
|
1031
|
-
catch (error) {
|
|
1032
|
-
console.warn(`Failed to merge header cells:`, error);
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
const defaultColor = rowIndex === 0 ? Z_EXCEL_DEFAULT_CONFIG.headerColors.level0 : Z_EXCEL_DEFAULT_CONFIG.headerColors.level1;
|
|
1037
|
-
cell.fill = {
|
|
1038
|
-
type: 'pattern',
|
|
1039
|
-
pattern: 'solid',
|
|
1040
|
-
fgColor: { argb: defaultColor },
|
|
1041
|
-
};
|
|
1042
|
-
cell.font = Z_EXCEL_DEFAULT_CONFIG.headerFont;
|
|
1043
|
-
cell.alignment = { horizontal: 'center', vertical: 'middle' };
|
|
1044
|
-
cell.border = Z_EXCEL_BORDER_THIN;
|
|
1045
|
-
if (headerCell.formatHeader) {
|
|
1046
|
-
headerCell.formatHeader(cell);
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
});
|
|
1050
|
-
}
|
|
1051
|
-
static _buildHeaderStructure(columns, headerStructure, level, maxLevels, startCol = 0) {
|
|
1052
|
-
let currentCol = startCol;
|
|
1053
|
-
for (const col of columns) {
|
|
1054
|
-
if (col.visible === false) {
|
|
1055
|
-
continue;
|
|
1056
|
-
}
|
|
1057
|
-
if (col.columns && col.columns.length > 0) {
|
|
1058
|
-
const childrenLeafCount = ZExcelService._getLeafCount(col.columns);
|
|
1059
|
-
const colSpan = col.headerColSpan || childrenLeafCount;
|
|
1060
|
-
const rowSpan = col.headerRowSpan || 1;
|
|
1061
|
-
headerStructure[level].push({
|
|
1062
|
-
header: col.header || col.id,
|
|
1063
|
-
colSpan,
|
|
1064
|
-
rowSpan,
|
|
1065
|
-
formatHeader: col.formatHeader,
|
|
1066
|
-
startCol: currentCol,
|
|
1067
|
-
endCol: currentCol + colSpan - 1,
|
|
1068
|
-
});
|
|
1069
|
-
if (col.headerRowSpan && col.headerRowSpan > 1) {
|
|
1070
|
-
currentCol += colSpan;
|
|
1071
|
-
continue;
|
|
1072
|
-
}
|
|
1073
|
-
ZExcelService._buildHeaderStructure(col.columns, headerStructure, level + 1, maxLevels, currentCol);
|
|
1074
|
-
currentCol += colSpan;
|
|
1075
|
-
continue;
|
|
1076
|
-
}
|
|
1077
|
-
const colSpan = col.headerColSpan || 1;
|
|
1078
|
-
const rowSpan = col.headerRowSpan || maxLevels - level;
|
|
1079
|
-
headerStructure[level].push({
|
|
1080
|
-
header: col.header || col.id,
|
|
1081
|
-
colSpan,
|
|
1082
|
-
rowSpan,
|
|
1083
|
-
formatHeader: col.formatHeader,
|
|
1084
|
-
startCol: currentCol,
|
|
1085
|
-
endCol: currentCol + colSpan - 1,
|
|
1086
|
-
});
|
|
1087
|
-
currentCol += colSpan;
|
|
1088
|
-
}
|
|
1089
|
-
return currentCol;
|
|
1090
|
-
}
|
|
1091
|
-
static _getLeafCount(columns) {
|
|
1092
|
-
let count = 0;
|
|
1093
|
-
for (const col of columns) {
|
|
1094
|
-
if (col.visible === false) {
|
|
1095
|
-
continue;
|
|
1096
|
-
}
|
|
1097
|
-
if (col.columns && col.columns.length > 0) {
|
|
1098
|
-
count += ZExcelService._getLeafCount(col.columns);
|
|
1099
|
-
continue;
|
|
1100
|
-
}
|
|
1101
|
-
count++;
|
|
1102
|
-
}
|
|
1103
|
-
return count;
|
|
1104
|
-
}
|
|
1105
|
-
static _getCellValue(col, row, rowIndex, data) {
|
|
1106
|
-
if (col.accessorFn) {
|
|
1107
|
-
return col.accessorFn(row, rowIndex, data);
|
|
1108
|
-
}
|
|
1109
|
-
if (col.accessorKey) {
|
|
1110
|
-
return row[col.accessorKey];
|
|
1111
|
-
}
|
|
1112
|
-
return '';
|
|
1113
|
-
}
|
|
1114
|
-
static _processMergeRegions(flatColumns, data, dataStartRow) {
|
|
1115
|
-
const mergeRegions = [];
|
|
1116
|
-
const dataLength = data.length;
|
|
1117
|
-
flatColumns.forEach((colConfig, colIndex) => {
|
|
1118
|
-
const colNumber = colIndex + 1;
|
|
1119
|
-
if (colConfig.rowSpan || colConfig.colSpan) {
|
|
1120
|
-
let currentGroupStart = 0;
|
|
1121
|
-
while (currentGroupStart < dataLength) {
|
|
1122
|
-
const currentItem = data[currentGroupStart];
|
|
1123
|
-
const rowSpan = typeof colConfig.rowSpan === 'function'
|
|
1124
|
-
? colConfig.rowSpan(currentItem, currentGroupStart, data)
|
|
1125
|
-
: colConfig.rowSpan || 1;
|
|
1126
|
-
const colSpan = typeof colConfig.colSpan === 'function'
|
|
1127
|
-
? colConfig.colSpan(currentItem, currentGroupStart, data)
|
|
1128
|
-
: colConfig.colSpan || 1;
|
|
1129
|
-
const hasRowSpan = rowSpan > 1;
|
|
1130
|
-
const hasColSpan = colSpan > 1;
|
|
1131
|
-
if (hasRowSpan || hasColSpan) {
|
|
1132
|
-
const startRow = dataStartRow + currentGroupStart;
|
|
1133
|
-
const endRow = hasRowSpan ? Math.min(startRow + rowSpan - 1, dataStartRow + dataLength - 1) : startRow;
|
|
1134
|
-
const startCol = colNumber;
|
|
1135
|
-
const endCol = hasColSpan ? colNumber + colSpan - 1 : colNumber;
|
|
1136
|
-
if ((endRow > startRow || endCol > startCol) && endRow < dataStartRow + dataLength) {
|
|
1137
|
-
mergeRegions.push({
|
|
1138
|
-
startRow,
|
|
1139
|
-
startCol,
|
|
1140
|
-
endRow,
|
|
1141
|
-
endCol,
|
|
1142
|
-
firstItemIndex: currentGroupStart,
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
currentGroupStart += Math.max(1, rowSpan);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
});
|
|
1150
|
-
return mergeRegions;
|
|
1151
|
-
}
|
|
1152
|
-
static _applyAutoFitWidth(sheet, flatColumns) {
|
|
1153
|
-
flatColumns.forEach((col, index) => {
|
|
1154
|
-
const colNumber = index + 1;
|
|
1155
|
-
const column = sheet.getColumn(colNumber);
|
|
1156
|
-
if (col.autoFit && !col.width) {
|
|
1157
|
-
let maxWidth = 0;
|
|
1158
|
-
sheet.eachRow((row) => {
|
|
1159
|
-
const cell = row.getCell(colNumber);
|
|
1160
|
-
if (cell.value) {
|
|
1161
|
-
const cellWidth = ZExcelService._calculateCellWidth(cell, String(cell.value)) /
|
|
1162
|
-
ZExcelService._getMergedColumnSpan(sheet, row, cell);
|
|
1163
|
-
maxWidth = Math.max(maxWidth, cellWidth);
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
const calculatedWidth = Math.max(Z_EXCEL_WIDTH_LIMITS.min, Math.min(Z_EXCEL_WIDTH_LIMITS.max, maxWidth + 1));
|
|
1167
|
-
column.width = calculatedWidth;
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
static _applyAutoFitWidthForTable(sheet) {
|
|
1172
|
-
const { columnCount } = sheet;
|
|
1173
|
-
for (let colNumber = 1; colNumber <= columnCount; colNumber++) {
|
|
1174
|
-
const column = sheet.getColumn(colNumber);
|
|
1175
|
-
let maxWidth = 0;
|
|
1176
|
-
sheet.eachRow((row) => {
|
|
1177
|
-
const cell = row.getCell(colNumber);
|
|
1178
|
-
if (cell.value) {
|
|
1179
|
-
const cellWidth = ZExcelService._calculateCellWidth(cell, String(cell.value)) /
|
|
1180
|
-
ZExcelService._getMergedColumnSpan(sheet, row, cell);
|
|
1181
|
-
maxWidth = Math.max(maxWidth, cellWidth);
|
|
1182
|
-
}
|
|
1183
|
-
});
|
|
1184
|
-
const calculatedWidth = Math.max(Z_EXCEL_WIDTH_LIMITS.tableMin, Math.min(Z_EXCEL_WIDTH_LIMITS.tableMax, maxWidth * 0.8 + 2));
|
|
1185
|
-
column.width = calculatedWidth;
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
static _getMergedColumnSpan(sheet, row, cell) {
|
|
1189
|
-
if (!cell.isMerged) {
|
|
1190
|
-
return 1;
|
|
1191
|
-
}
|
|
1192
|
-
let colSpan = 0;
|
|
1193
|
-
for (let colNumber = 1; colNumber <= sheet.columnCount; colNumber++) {
|
|
1194
|
-
const mergedCell = row.getCell(colNumber);
|
|
1195
|
-
if (mergedCell.address === cell.master.address || mergedCell.isMergedTo(cell.master)) {
|
|
1196
|
-
colSpan++;
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
return Math.max(1, colSpan);
|
|
1200
|
-
}
|
|
1201
|
-
static _calculateCellWidth(cell, text) {
|
|
1202
|
-
const font = cell.font || {};
|
|
1203
|
-
const fontSize = font.size || Z_EXCEL_DEFAULT_CONFIG.font.size;
|
|
1204
|
-
const fontFamily = font.name || Z_EXCEL_DEFAULT_CONFIG.font.name;
|
|
1205
|
-
const isBold = font.bold || false;
|
|
1206
|
-
const isItalic = font.italic || false;
|
|
1207
|
-
const fontSizeMultiplier = fontSize / 11;
|
|
1208
|
-
const fontMultiplier = Z_EXCEL_FONT_MULTIPLIERS[fontFamily] || 1.0;
|
|
1209
|
-
let adjustedWidth = 0;
|
|
1210
|
-
for (const char of text) {
|
|
1211
|
-
const charWidth = Z_EXCEL_CHAR_WIDTH_MAP[char] || 1.0;
|
|
1212
|
-
adjustedWidth += charWidth;
|
|
1213
|
-
}
|
|
1214
|
-
adjustedWidth *= fontSizeMultiplier * fontMultiplier;
|
|
1215
|
-
if (isBold) {
|
|
1216
|
-
adjustedWidth *= 1.1;
|
|
1217
|
-
}
|
|
1218
|
-
if (isItalic) {
|
|
1219
|
-
adjustedWidth *= 1.05;
|
|
1220
|
-
}
|
|
1221
|
-
return Math.ceil(adjustedWidth * 1.2);
|
|
1222
|
-
}
|
|
1223
|
-
static _processTableElement(sheet, table) {
|
|
1224
|
-
const rows = Array.from(table.rows);
|
|
1225
|
-
const mergedCells = new Set();
|
|
1226
|
-
rows.forEach((row, rowIndex) => {
|
|
1227
|
-
const cells = Array.from(row.cells);
|
|
1228
|
-
let colOffset = 0;
|
|
1229
|
-
cells.forEach((cell, cellIndex) => {
|
|
1230
|
-
const computedStyle = window.getComputedStyle(cell);
|
|
1231
|
-
if (computedStyle.display === 'none' || computedStyle.visibility === 'hidden') {
|
|
1232
|
-
return;
|
|
1233
|
-
}
|
|
1234
|
-
const rect = cell.getBoundingClientRect();
|
|
1235
|
-
if (rect.width === 0 && rect.height === 0) {
|
|
1236
|
-
return;
|
|
1237
|
-
}
|
|
1238
|
-
while (mergedCells.has(`${rowIndex + 1}:${cellIndex + colOffset + 1}`)) {
|
|
1239
|
-
colOffset++;
|
|
1240
|
-
}
|
|
1241
|
-
const excelRow = sheet.getRow(rowIndex + 1);
|
|
1242
|
-
const colIndex = cellIndex + colOffset;
|
|
1243
|
-
const excelCell = excelRow.getCell(colIndex + 1);
|
|
1244
|
-
const cellContent = cell.textContent?.trim() || '';
|
|
1245
|
-
excelCell.value = ZExcelService._parseContentValue(cellContent);
|
|
1246
|
-
if (!excelCell.font) {
|
|
1247
|
-
excelCell.font = Z_EXCEL_DEFAULT_CONFIG.font;
|
|
1248
|
-
}
|
|
1249
|
-
ZExcelService._applyCellFormatFromHTML(excelCell, cell);
|
|
1250
|
-
const rowSpan = parseInt(cell.getAttribute('rowspan') || '1');
|
|
1251
|
-
const colSpan = parseInt(cell.getAttribute('colspan') || '1');
|
|
1252
|
-
if (rowSpan > 1 || colSpan > 1) {
|
|
1253
|
-
const startRow = rowIndex + 1;
|
|
1254
|
-
const startCol = colIndex + 1;
|
|
1255
|
-
const endRow = startRow + rowSpan - 1;
|
|
1256
|
-
const endCol = startCol + colSpan - 1;
|
|
1257
|
-
const mergeKey = `${startRow}:${startCol}-${endRow}:${endCol}`;
|
|
1258
|
-
if (!mergedCells.has(mergeKey)) {
|
|
1259
|
-
sheet.mergeCells(startRow, startCol, endRow, endCol);
|
|
1260
|
-
mergedCells.add(mergeKey);
|
|
1261
|
-
for (let r = startRow; r <= endRow; r++) {
|
|
1262
|
-
for (let c = startCol; c <= endCol; c++) {
|
|
1263
|
-
mergedCells.add(`${r}:${c}`);
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
});
|
|
1269
|
-
});
|
|
1270
|
-
}
|
|
1271
|
-
static _parseContentValue(content) {
|
|
1272
|
-
if (!content || content.trim() === '') {
|
|
1273
|
-
return '';
|
|
1274
|
-
}
|
|
1275
|
-
const trimmedContent = content.trim();
|
|
1276
|
-
if (/^-?\d+(\.\d+)?$/.test(trimmedContent)) {
|
|
1277
|
-
const parsed = parseFloat(trimmedContent);
|
|
1278
|
-
if (!isNaN(parsed) && isFinite(parsed)) {
|
|
1279
|
-
return parsed;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
if (/^-?\d+(\.\d+)?%$/.test(trimmedContent)) {
|
|
1283
|
-
const numberPart = trimmedContent.replace('%', '');
|
|
1284
|
-
const parsed = parseFloat(numberPart);
|
|
1285
|
-
if (!isNaN(parsed) && isFinite(parsed)) {
|
|
1286
|
-
return parsed / 100;
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
return trimmedContent;
|
|
1290
|
-
}
|
|
1291
|
-
static _applyCellFormatFromHTML(excelCell, htmlCell) {
|
|
1292
|
-
const computedStyle = window.getComputedStyle(htmlCell);
|
|
1293
|
-
excelCell.font = {
|
|
1294
|
-
name: Z_EXCEL_DEFAULT_CONFIG.font.name,
|
|
1295
|
-
bold: computedStyle.fontWeight === 'bold' || parseInt(computedStyle.fontWeight) >= 600,
|
|
1296
|
-
italic: computedStyle.fontStyle === 'italic',
|
|
1297
|
-
size: parseInt(computedStyle.fontSize) || Z_EXCEL_DEFAULT_CONFIG.font.size,
|
|
1298
|
-
color: { argb: zConvertColorToArgb(computedStyle.color) },
|
|
1299
|
-
};
|
|
1300
|
-
if (computedStyle.backgroundColor && computedStyle.backgroundColor !== 'rgba(0, 0, 0, 0)') {
|
|
1301
|
-
excelCell.fill = {
|
|
1302
|
-
type: 'pattern',
|
|
1303
|
-
pattern: 'solid',
|
|
1304
|
-
fgColor: { argb: zConvertColorToArgb(computedStyle.backgroundColor) },
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1307
|
-
excelCell.alignment = {
|
|
1308
|
-
horizontal: ZExcelService._getExcelAlignment(computedStyle.textAlign),
|
|
1309
|
-
vertical: ZExcelService._getExcelVerticalAlignment(computedStyle.verticalAlign),
|
|
1310
|
-
};
|
|
1311
|
-
excelCell.border = Z_EXCEL_BORDER_THIN;
|
|
1312
|
-
}
|
|
1313
|
-
static _getExcelAlignment(textAlign) {
|
|
1314
|
-
switch (textAlign) {
|
|
1315
|
-
case 'center':
|
|
1316
|
-
return 'center';
|
|
1317
|
-
case 'right':
|
|
1318
|
-
return 'right';
|
|
1319
|
-
case 'left':
|
|
1320
|
-
return 'left';
|
|
1321
|
-
default:
|
|
1322
|
-
return undefined;
|
|
1323
|
-
}
|
|
1324
|
-
}
|
|
1325
|
-
static _getExcelVerticalAlignment(verticalAlign) {
|
|
1326
|
-
switch (verticalAlign) {
|
|
1327
|
-
case 'middle':
|
|
1328
|
-
return 'middle';
|
|
1329
|
-
case 'top':
|
|
1330
|
-
return 'top';
|
|
1331
|
-
case 'bottom':
|
|
1332
|
-
return 'bottom';
|
|
1333
|
-
default:
|
|
1334
|
-
return 'middle';
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
static _formatTimestamp() {
|
|
1338
|
-
const now = new Date();
|
|
1339
|
-
const year = now.getFullYear();
|
|
1340
|
-
const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
1341
|
-
const day = String(now.getDate()).padStart(2, '0');
|
|
1342
|
-
const hours = String(now.getHours()).padStart(2, '0');
|
|
1343
|
-
const minutes = String(now.getMinutes()).padStart(2, '0');
|
|
1344
|
-
const seconds = String(now.getSeconds()).padStart(2, '0');
|
|
1345
|
-
return `${year}${month}${day}_${hours}${minutes}${seconds}`;
|
|
1346
|
-
}
|
|
1347
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZExcelService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1348
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZExcelService, providedIn: 'root' });
|
|
1349
|
-
}
|
|
1350
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZExcelService, decorators: [{
|
|
1351
|
-
type: Injectable,
|
|
1352
|
-
args: [{
|
|
1353
|
-
providedIn: 'root',
|
|
1354
|
-
}]
|
|
1355
|
-
}] });
|
|
1356
|
-
|
|
1357
|
-
class ZGalleryOfficeRenderService {
|
|
1358
|
-
async renderDoc(container, blob) {
|
|
1359
|
-
const { renderAsync } = await import('docx-preview');
|
|
1360
|
-
await renderAsync(blob, container, undefined, {
|
|
1361
|
-
className: 'z-gallery-docx',
|
|
1362
|
-
inWrapper: true,
|
|
1363
|
-
breakPages: true,
|
|
1364
|
-
});
|
|
1365
|
-
const observer = this._observeDocxZoom(container);
|
|
1366
|
-
return { dispose: () => observer?.disconnect() };
|
|
1367
|
-
}
|
|
1368
|
-
async renderSheet(container, blob) {
|
|
1369
|
-
const [{ read, utils }, { createUniver, LocaleType, mergeLocales }, sheetsCore, viVN] = await Promise.all([
|
|
1370
|
-
import('xlsx'),
|
|
1371
|
-
import('@univerjs/presets'),
|
|
1372
|
-
import('@univerjs/preset-sheets-core'),
|
|
1373
|
-
import('@univerjs/preset-sheets-core/locales/vi-VN'),
|
|
1374
|
-
]);
|
|
1375
|
-
const workbook = read(await blob.arrayBuffer(), { type: 'array' });
|
|
1376
|
-
const { univerAPI } = createUniver({
|
|
1377
|
-
locale: LocaleType.VI_VN,
|
|
1378
|
-
locales: { [LocaleType.VI_VN]: mergeLocales(viVN.default ?? viVN) },
|
|
1379
|
-
presets: [
|
|
1380
|
-
sheetsCore.UniverSheetsCorePreset({
|
|
1381
|
-
container,
|
|
1382
|
-
header: true,
|
|
1383
|
-
toolbar: false,
|
|
1384
|
-
contextMenu: false,
|
|
1385
|
-
formulaBar: true,
|
|
1386
|
-
}),
|
|
1387
|
-
],
|
|
1388
|
-
});
|
|
1389
|
-
univerAPI.createWorkbook(this._toUniverWorkbook(workbook, utils)).setEditable(false);
|
|
1390
|
-
return { dispose: () => univerAPI.dispose() };
|
|
1391
|
-
}
|
|
1392
|
-
async renderSlide(container, blob) {
|
|
1393
|
-
const { PptxViewer, RECOMMENDED_ZIP_LIMITS } = await import('@aiden0z/pptx-renderer');
|
|
1394
|
-
const viewer = new PptxViewer(container, {
|
|
1395
|
-
fitMode: 'contain',
|
|
1396
|
-
zipLimits: RECOMMENDED_ZIP_LIMITS,
|
|
1397
|
-
pdfjs: {
|
|
1398
|
-
moduleUrl: '/assets/pdfjs/build/pdf.mjs',
|
|
1399
|
-
workerUrl: '/assets/pdfjs/build/pdf.worker.mjs',
|
|
1400
|
-
},
|
|
1401
|
-
});
|
|
1402
|
-
await viewer.open(blob, { renderMode: 'slide' });
|
|
1403
|
-
return { dispose: () => viewer.destroy() };
|
|
1404
|
-
}
|
|
1405
|
-
_toUniverWorkbook(workbook, utils) {
|
|
1406
|
-
const sheets = {};
|
|
1407
|
-
const sheetOrder = [];
|
|
1408
|
-
workbook.SheetNames.forEach((sheetName, index) => {
|
|
1409
|
-
const sheet = workbook.Sheets[sheetName];
|
|
1410
|
-
if (!sheet) {
|
|
1411
|
-
return;
|
|
1412
|
-
}
|
|
1413
|
-
const rows = utils.sheet_to_json(sheet, { header: 1, raw: true, defval: null });
|
|
1414
|
-
const sheetId = `sheet-${index}`;
|
|
1415
|
-
sheetOrder.push(sheetId);
|
|
1416
|
-
sheets[sheetId] = {
|
|
1417
|
-
id: sheetId,
|
|
1418
|
-
name: sheetName,
|
|
1419
|
-
rowCount: Math.max(rows.length + 10, 50),
|
|
1420
|
-
columnCount: Math.max(...rows.map(row => row.length), 10) + 5,
|
|
1421
|
-
cellData: this._toUniverCellData(rows),
|
|
1422
|
-
};
|
|
1423
|
-
});
|
|
1424
|
-
return {
|
|
1425
|
-
id: 'z-gallery-preview',
|
|
1426
|
-
appVersion: '0.25.1',
|
|
1427
|
-
name: workbook.Props?.Title ?? '',
|
|
1428
|
-
sheetOrder,
|
|
1429
|
-
sheets,
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
|
-
_toUniverCellData(rows) {
|
|
1433
|
-
const cellData = {};
|
|
1434
|
-
rows.forEach((row, rowIndex) => {
|
|
1435
|
-
row.forEach((value, columnIndex) => {
|
|
1436
|
-
if (value === null || value === undefined || value === '') {
|
|
1437
|
-
return;
|
|
1438
|
-
}
|
|
1439
|
-
cellData[rowIndex] ??= {};
|
|
1440
|
-
cellData[rowIndex][columnIndex] = typeof value === 'number' ? { v: value } : { v: String(value) };
|
|
1441
|
-
});
|
|
1442
|
-
});
|
|
1443
|
-
return cellData;
|
|
1444
|
-
}
|
|
1445
|
-
_observeDocxZoom(container) {
|
|
1446
|
-
if (typeof ResizeObserver === 'undefined') {
|
|
1447
|
-
return null;
|
|
1448
|
-
}
|
|
1449
|
-
const observer = new ResizeObserver(() => {
|
|
1450
|
-
const wrapper = container.querySelector('.docx-wrapper');
|
|
1451
|
-
const page = wrapper?.querySelector('.docx');
|
|
1452
|
-
if (!wrapper || !page) {
|
|
1453
|
-
return;
|
|
1454
|
-
}
|
|
1455
|
-
const availableWidth = container.clientWidth;
|
|
1456
|
-
const pageWidth = page.offsetWidth;
|
|
1457
|
-
const scale = pageWidth > 0 && availableWidth < pageWidth ? availableWidth / pageWidth : 1;
|
|
1458
|
-
wrapper.style.zoom = `${scale}`;
|
|
1459
|
-
});
|
|
1460
|
-
observer.observe(container);
|
|
1461
|
-
return observer;
|
|
1462
|
-
}
|
|
1463
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZGalleryOfficeRenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1464
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZGalleryOfficeRenderService, providedIn: 'root' });
|
|
1465
|
-
}
|
|
1466
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImport: i0, type: ZGalleryOfficeRenderService, decorators: [{
|
|
1467
|
-
type: Injectable,
|
|
1468
|
-
args: [{ providedIn: 'root' }]
|
|
1469
|
-
}] });
|
|
1470
|
-
|
|
1471
695
|
class ZIndexDbService {
|
|
1472
696
|
_db = null;
|
|
1473
697
|
_dbName;
|
|
@@ -2826,5 +2050,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.6", ngImpor
|
|
|
2826
2050
|
* Generated bundle index. Do not edit.
|
|
2827
2051
|
*/
|
|
2828
2052
|
|
|
2829
|
-
export { ZCacheService, ZDynamicRef, ZDynamicService,
|
|
2053
|
+
export { ZCacheService, ZDynamicRef, ZDynamicService, ZHttpAbstractService, ZIndexDbService, ZOverlayContainerService, ZOverlayZIndexService, ZSubjectService, ZThemeService, ZTranslateService, Z_CACHE_DEFAULT_PREFIX, Z_CACHE_SCOPE_SEPARATOR, Z_DB_SCOPE_SEPARATOR, Z_DEFAULT_THEME, Z_DYNAMIC_ANIMATION_DURATION, Z_DYNAMIC_DATA, Z_EXCEL_BORDER_THIN, Z_EXCEL_CHAR_WIDTH_MAP, Z_EXCEL_COLORS, Z_EXCEL_DEFAULT_CONFIG, Z_EXCEL_FONT_MULTIPLIERS, Z_EXCEL_WIDTH_LIMITS, Z_HTTP_DEFAULT_CONFIG, Z_INDEXDB_BATCH_SIZE, Z_INDEXDB_DEFAULT_CONFIG, Z_INDEXDB_MAX_VERSION, Z_LANG_CACHE_KEY, Z_LANG_TO_LOCALE, Z_STORAGE_SCOPE_FALLBACK, Z_THEME_CONFIG, Z_THEME_CSS_MAP, Z_THEME_PREFERENCES_CACHE_KEY, zBuildLegacyScopedCacheKey, zBuildLegacyScopedDbName, zBuildScopedCacheKey, zBuildScopedDbName, zConfigureStorageAppName, zGetStorageAppName, zNormalizeStorageAppName, zStripLegacyScopedCacheKey, zStripScopedCacheKey };
|
|
2830
2054
|
//# sourceMappingURL=shival99-z-ui-services.mjs.map
|