@evergis/react 3.1.38 → 3.1.39
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/dist/components/Dashboard/containers/ExportPdfContainer/index.d.ts +3 -0
- package/dist/components/Dashboard/containers/registry.d.ts +1 -0
- package/dist/components/Dashboard/hooks/index.d.ts +1 -0
- package/dist/components/Dashboard/hooks/useExportPdf.d.ts +4 -0
- package/dist/components/Dashboard/types.d.ts +1 -0
- package/dist/index.js +134 -1
- package/dist/index.js.map +1 -1
- package/dist/react.esm.js +134 -2
- package/dist/react.esm.js.map +1 -1
- package/package.json +6 -2
|
@@ -27,5 +27,6 @@ export declare const containerComponents: {
|
|
|
27
27
|
readonly Camera: import('react').FC<import('../types').ContainerProps>;
|
|
28
28
|
readonly AddFeature: import('react').FC<import('../types').ContainerProps>;
|
|
29
29
|
readonly Divider: import('react').FC<import('../types').ContainerProps>;
|
|
30
|
+
readonly ExportPdf: import('react').FC<import('../types').ContainerProps>;
|
|
30
31
|
readonly default: import('react').FC<import('../types').ContainerProps>;
|
|
31
32
|
};
|
|
@@ -4,6 +4,7 @@ export * from './useDashboardHeader';
|
|
|
4
4
|
export * from './useDataSources';
|
|
5
5
|
export * from './useDiffPage';
|
|
6
6
|
export * from './useExpandableContainers';
|
|
7
|
+
export * from './useExportPdf';
|
|
7
8
|
export * from './useWidgetFilters';
|
|
8
9
|
export * from './useGetConfigLayer';
|
|
9
10
|
export * from './useGlobalContext';
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var signalr = require('@microsoft/signalr');
|
|
|
16
16
|
var findAnd = require('find-and');
|
|
17
17
|
var MapboxDraw = require('@mapbox/mapbox-gl-draw');
|
|
18
18
|
var turf = require('@turf/turf');
|
|
19
|
+
var jspdf = require('jspdf');
|
|
20
|
+
var html2canvas = require('html2canvas');
|
|
19
21
|
var MapGL = require('react-map-gl/mapbox');
|
|
20
22
|
require('@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css');
|
|
21
23
|
require('mapbox-gl/dist/mapbox-gl.css');
|
|
@@ -3377,6 +3379,7 @@ exports.ContainerTemplate = void 0;
|
|
|
3377
3379
|
ContainerTemplate["Camera"] = "Camera";
|
|
3378
3380
|
ContainerTemplate["AddFeature"] = "AddFeature";
|
|
3379
3381
|
ContainerTemplate["Slideshow"] = "Slideshow";
|
|
3382
|
+
ContainerTemplate["ExportPdf"] = "ExportPdf";
|
|
3380
3383
|
ContainerTemplate["Divider"] = "Divider";
|
|
3381
3384
|
})(exports.ContainerTemplate || (exports.ContainerTemplate = {}));
|
|
3382
3385
|
exports.HeaderTemplate = void 0;
|
|
@@ -6004,7 +6007,7 @@ const PagesContainer = React.memo(({ type = exports.WidgetType.Dashboard, noBord
|
|
|
6004
6007
|
setSelectedTabId,
|
|
6005
6008
|
type,
|
|
6006
6009
|
]);
|
|
6007
|
-
return (jsxRuntime.jsxs("div", { style: { width }, children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsxRuntime.jsx(Container, { isColumn: isColumn, isMain: true, noBorders: noBorders, children: jsxRuntime.jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
|
|
6010
|
+
return (jsxRuntime.jsxs("div", { id: "dashboard-root", style: { width }, children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsxRuntime.jsx(Container, { isColumn: isColumn, isMain: true, noBorders: noBorders, children: jsxRuntime.jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
|
|
6008
6011
|
});
|
|
6009
6012
|
|
|
6010
6013
|
const TwoColumnsInnerContainer = React.memo(({ renderElement }) => {
|
|
@@ -6572,6 +6575,12 @@ const LayersContainer = React.memo(({ type, elementConfig, renderElement }) => {
|
|
|
6572
6575
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsx(LayersContainerWrapper, { style: style, children: jsxRuntime.jsx(LayerTree, { layers: layers, onlyMainTools: true }) }))] }));
|
|
6573
6576
|
});
|
|
6574
6577
|
|
|
6578
|
+
const ExportPdfContainer = React.memo(({ elementConfig }) => {
|
|
6579
|
+
const { loading, onExport } = useExportPdf(["dashboard-root"]);
|
|
6580
|
+
const { style } = elementConfig || {};
|
|
6581
|
+
return (jsxRuntime.jsx(Container, { style: style, children: jsxRuntime.jsx(uilibGl.IconButton, { kind: "tools_print", primary: true, disabled: loading, onClick: onExport, children: "\u042D\u043A\u0441\u043F\u043E\u0440\u0442 \u0432 PDF" }) }));
|
|
6582
|
+
});
|
|
6583
|
+
|
|
6575
6584
|
const containerComponents = {
|
|
6576
6585
|
[exports.ContainerTemplate.DefaultAttributes]: DefaultAttributesContainer,
|
|
6577
6586
|
[exports.ContainerTemplate.Pages]: PagesContainer,
|
|
@@ -6593,6 +6602,7 @@ const containerComponents = {
|
|
|
6593
6602
|
[exports.ContainerTemplate.Camera]: CameraContainer,
|
|
6594
6603
|
[exports.ContainerTemplate.AddFeature]: AddFeatureContainer,
|
|
6595
6604
|
[exports.ContainerTemplate.Divider]: DividerContainer,
|
|
6605
|
+
[exports.ContainerTemplate.ExportPdf]: ExportPdfContainer,
|
|
6596
6606
|
default: ContainersGroupContainer,
|
|
6597
6607
|
};
|
|
6598
6608
|
|
|
@@ -9086,6 +9096,128 @@ const useExpandableContainers = () => {
|
|
|
9086
9096
|
return [expandedContainers, expandContainer];
|
|
9087
9097
|
};
|
|
9088
9098
|
|
|
9099
|
+
const useExportPdf = (ids) => {
|
|
9100
|
+
const [loading, setLoading] = React.useState(false);
|
|
9101
|
+
const onExport = React.useCallback(async () => {
|
|
9102
|
+
if (ids.length === 0) {
|
|
9103
|
+
return;
|
|
9104
|
+
}
|
|
9105
|
+
setLoading(true);
|
|
9106
|
+
const pdf = new jspdf.jsPDF("landscape", "pt", "a4", false);
|
|
9107
|
+
for (let i = 0; i < ids.length; i++) {
|
|
9108
|
+
const pageItemContents = document.querySelector(`#${ids[i]}`);
|
|
9109
|
+
const data = await html2canvas(pageItemContents, {
|
|
9110
|
+
scale: 2,
|
|
9111
|
+
windowWidth: 800,
|
|
9112
|
+
onclone: (clonedDocument, clonedElement) => {
|
|
9113
|
+
clonedDocument.body.style.width = "1920px";
|
|
9114
|
+
clonedDocument.body.style.height = "1080px";
|
|
9115
|
+
/* if (!isCoverPage) {
|
|
9116
|
+
clonedDocument.body.style.background = "#f4f7f9";
|
|
9117
|
+
}
|
|
9118
|
+
|
|
9119
|
+
const pageContainers = clonedElement.querySelectorAll(".export-page-container");
|
|
9120
|
+
const inputWrappers = clonedElement.querySelectorAll(".page-title-input");
|
|
9121
|
+
const textareas = clonedElement.querySelectorAll(".report-page-item-textarea");
|
|
9122
|
+
const datePickerWrappers = clonedElement.querySelectorAll(".report-page-item-datepicker");
|
|
9123
|
+
const pageBlockContainers = clonedElement.querySelectorAll(".report-page-block-container");
|
|
9124
|
+
const pageItemTitles = clonedDocument.querySelectorAll(".report-page-item-title");
|
|
9125
|
+
|
|
9126
|
+
pageContainers.forEach((element) => {
|
|
9127
|
+
(element as HTMLDivElement).style.background = isCoverPage ? "transparent" : "#f4f7f9";
|
|
9128
|
+
(element as HTMLDivElement).style.border = "none";
|
|
9129
|
+
(element as HTMLDivElement).style.padding = isCoverPage ? "0px" : "3rem 3rem 30rem";
|
|
9130
|
+
(element as HTMLDivElement).style.margin = isCoverPage ? "0px" : "initial";
|
|
9131
|
+
});
|
|
9132
|
+
|
|
9133
|
+
inputWrappers.forEach((inputWrapper) => {
|
|
9134
|
+
const input = inputWrapper.querySelector("input");
|
|
9135
|
+
const div = document.createElement("div");
|
|
9136
|
+
|
|
9137
|
+
div.innerText = (input as HTMLInputElement).value;
|
|
9138
|
+
|
|
9139
|
+
inputWrapper.replaceWith(div);
|
|
9140
|
+
});
|
|
9141
|
+
|
|
9142
|
+
textareas.forEach((textarea) => {
|
|
9143
|
+
const div = document.createElement("div");
|
|
9144
|
+
|
|
9145
|
+
if ((textarea as HTMLTextAreaElement).classList.contains("report-page-item-comment")) {
|
|
9146
|
+
if (isCoverPage) {
|
|
9147
|
+
(div as HTMLDivElement).style.display = "none";
|
|
9148
|
+
} else {
|
|
9149
|
+
(div as HTMLDivElement).style.fontSize = "24px";
|
|
9150
|
+
(div as HTMLDivElement).style.fontWeight = "400";
|
|
9151
|
+
(div as HTMLDivElement).style.opacity = "0.54";
|
|
9152
|
+
(div as HTMLDivElement).style.marginTop = "2rem";
|
|
9153
|
+
}
|
|
9154
|
+
}
|
|
9155
|
+
|
|
9156
|
+
if (isCoverPage) {
|
|
9157
|
+
if ((textarea as HTMLTextAreaElement).classList.contains("report-page-front-cover-title")) {
|
|
9158
|
+
(div as HTMLDivElement).style.fontSize = "32px";
|
|
9159
|
+
(div as HTMLDivElement).style.fontWeight = "300";
|
|
9160
|
+
(div as HTMLDivElement).style.lineHeight = "normal";
|
|
9161
|
+
}
|
|
9162
|
+
|
|
9163
|
+
if ((textarea as HTMLTextAreaElement).classList.contains("report-page-front-cover-comment")) {
|
|
9164
|
+
(div as HTMLDivElement).style.fontSize = "16px";
|
|
9165
|
+
(div as HTMLDivElement).style.fontWeight = "400";
|
|
9166
|
+
(div as HTMLDivElement).style.opacity = "0.54";
|
|
9167
|
+
(div as HTMLDivElement).style.lineHeight = "normal";
|
|
9168
|
+
}
|
|
9169
|
+
}
|
|
9170
|
+
|
|
9171
|
+
div.innerText = (textarea as HTMLTextAreaElement).value;
|
|
9172
|
+
|
|
9173
|
+
textarea.replaceWith(div);
|
|
9174
|
+
});
|
|
9175
|
+
|
|
9176
|
+
datePickerWrappers.forEach((inputWrapper) => {
|
|
9177
|
+
const input = inputWrapper.querySelector("input");
|
|
9178
|
+
const div = document.createElement("div");
|
|
9179
|
+
|
|
9180
|
+
if (isCoverPage) {
|
|
9181
|
+
(div as HTMLDivElement).style.fontSize = "12px";
|
|
9182
|
+
(div as HTMLDivElement).style.fontWeight = "400";
|
|
9183
|
+
(div as HTMLDivElement).style.opacity = "0.54";
|
|
9184
|
+
}
|
|
9185
|
+
|
|
9186
|
+
div.innerText = (input as HTMLInputElement).value;
|
|
9187
|
+
|
|
9188
|
+
inputWrapper.replaceWith(div);
|
|
9189
|
+
});
|
|
9190
|
+
|
|
9191
|
+
pageBlockContainers.forEach((element) => {
|
|
9192
|
+
(element as HTMLDivElement).style.background = "#ffffff";
|
|
9193
|
+
});
|
|
9194
|
+
|
|
9195
|
+
pageItemTitles.forEach((item) => {
|
|
9196
|
+
if (isCoverPage) {
|
|
9197
|
+
(item as HTMLDivElement).style.display = "none";
|
|
9198
|
+
} else {
|
|
9199
|
+
(item as HTMLDivElement).style.fontSize = "40px";
|
|
9200
|
+
(item as HTMLDivElement).style.fontWeight = "300";
|
|
9201
|
+
(item as HTMLDivElement).style.marginBottom = "2rem";
|
|
9202
|
+
}
|
|
9203
|
+
});*/
|
|
9204
|
+
},
|
|
9205
|
+
});
|
|
9206
|
+
const img = data.toDataURL("image/png");
|
|
9207
|
+
const imgProperties = pdf.getImageProperties(img);
|
|
9208
|
+
const pdfWidth = pdf.internal.pageSize.getWidth();
|
|
9209
|
+
const pdfHeight = (imgProperties.height * pdfWidth) / imgProperties.width;
|
|
9210
|
+
if (i > 0) {
|
|
9211
|
+
pdf.addPage("a4", "landscape");
|
|
9212
|
+
}
|
|
9213
|
+
pdf.addImage(img, "PNG", 0, 0, pdfWidth, pdfHeight);
|
|
9214
|
+
}
|
|
9215
|
+
pdf.save(`report_${dateFns.format(new Date(), "yyyy-MM-dd_HH:mm:ss")}.pdf`);
|
|
9216
|
+
setLoading(false);
|
|
9217
|
+
}, [ids]);
|
|
9218
|
+
return { loading, onExport };
|
|
9219
|
+
};
|
|
9220
|
+
|
|
9089
9221
|
const getMinMaxFromStringValue = (items, value, current, type) => {
|
|
9090
9222
|
const valueIndex = items.findIndex(item => item.value === (type === "min" ? value.min : value.max));
|
|
9091
9223
|
const currentIndex = items.findIndex(item => item.value === (type === "min" ? value.min : value.max));
|
|
@@ -10209,6 +10341,7 @@ exports.useDataSources = useDataSources;
|
|
|
10209
10341
|
exports.useDebouncedCallback = useDebouncedCallback;
|
|
10210
10342
|
exports.useDiffPage = useDiffPage;
|
|
10211
10343
|
exports.useExpandableContainers = useExpandableContainers;
|
|
10344
|
+
exports.useExportPdf = useExportPdf;
|
|
10212
10345
|
exports.useGetConfigLayer = useGetConfigLayer;
|
|
10213
10346
|
exports.useGlobalContext = useGlobalContext;
|
|
10214
10347
|
exports.useHeaderRender = useHeaderRender;
|