@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/react.esm.js CHANGED
@@ -14,6 +14,8 @@ import { HubConnectionBuilder, LogLevel } from '@microsoft/signalr';
14
14
  import { changeProps, returnFound } from 'find-and';
15
15
  import MapboxDraw from '@mapbox/mapbox-gl-draw';
16
16
  import { geometryCollection, multiPolygon, polygon, multiLineString, multiPoint, point as point$1, bbox } from '@turf/turf';
17
+ import { jsPDF } from 'jspdf';
18
+ import html2canvas from 'html2canvas';
17
19
  import MapGL, { Source, Layer as Layer$1 } from 'react-map-gl/mapbox';
18
20
  import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css';
19
21
  import 'mapbox-gl/dist/mapbox-gl.css';
@@ -3375,6 +3377,7 @@ var ContainerTemplate;
3375
3377
  ContainerTemplate["Camera"] = "Camera";
3376
3378
  ContainerTemplate["AddFeature"] = "AddFeature";
3377
3379
  ContainerTemplate["Slideshow"] = "Slideshow";
3380
+ ContainerTemplate["ExportPdf"] = "ExportPdf";
3378
3381
  ContainerTemplate["Divider"] = "Divider";
3379
3382
  })(ContainerTemplate || (ContainerTemplate = {}));
3380
3383
  var HeaderTemplate;
@@ -6002,7 +6005,7 @@ const PagesContainer = memo(({ type = WidgetType.Dashboard, noBorders }) => {
6002
6005
  setSelectedTabId,
6003
6006
  type,
6004
6007
  ]);
6005
- return (jsxs("div", { style: { width }, children: [jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsx(Container, { isColumn: isColumn, isMain: true, noBorders: noBorders, children: jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
6008
+ return (jsxs("div", { id: "dashboard-root", style: { width }, children: [jsx(ExpandableTitle, { elementConfig: config, type: type, renderElement: renderElement }), jsx(Container, { isColumn: isColumn, isMain: true, noBorders: noBorders, children: jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) })] }));
6006
6009
  });
6007
6010
 
6008
6011
  const TwoColumnsInnerContainer = memo(({ renderElement }) => {
@@ -6570,6 +6573,12 @@ const LayersContainer = memo(({ type, elementConfig, renderElement }) => {
6570
6573
  return (jsxs(Fragment$1, { children: [jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsx(LayersContainerWrapper, { style: style, children: jsx(LayerTree, { layers: layers, onlyMainTools: true }) }))] }));
6571
6574
  });
6572
6575
 
6576
+ const ExportPdfContainer = memo(({ elementConfig }) => {
6577
+ const { loading, onExport } = useExportPdf(["dashboard-root"]);
6578
+ const { style } = elementConfig || {};
6579
+ return (jsx(Container, { style: style, children: jsx(IconButton, { kind: "tools_print", primary: true, disabled: loading, onClick: onExport, children: "\u042D\u043A\u0441\u043F\u043E\u0440\u0442 \u0432 PDF" }) }));
6580
+ });
6581
+
6573
6582
  const containerComponents = {
6574
6583
  [ContainerTemplate.DefaultAttributes]: DefaultAttributesContainer,
6575
6584
  [ContainerTemplate.Pages]: PagesContainer,
@@ -6591,6 +6600,7 @@ const containerComponents = {
6591
6600
  [ContainerTemplate.Camera]: CameraContainer,
6592
6601
  [ContainerTemplate.AddFeature]: AddFeatureContainer,
6593
6602
  [ContainerTemplate.Divider]: DividerContainer,
6603
+ [ContainerTemplate.ExportPdf]: ExportPdfContainer,
6594
6604
  default: ContainersGroupContainer,
6595
6605
  };
6596
6606
 
@@ -9084,6 +9094,128 @@ const useExpandableContainers = () => {
9084
9094
  return [expandedContainers, expandContainer];
9085
9095
  };
9086
9096
 
9097
+ const useExportPdf = (ids) => {
9098
+ const [loading, setLoading] = useState(false);
9099
+ const onExport = useCallback(async () => {
9100
+ if (ids.length === 0) {
9101
+ return;
9102
+ }
9103
+ setLoading(true);
9104
+ const pdf = new jsPDF("landscape", "pt", "a4", false);
9105
+ for (let i = 0; i < ids.length; i++) {
9106
+ const pageItemContents = document.querySelector(`#${ids[i]}`);
9107
+ const data = await html2canvas(pageItemContents, {
9108
+ scale: 2,
9109
+ windowWidth: 800,
9110
+ onclone: (clonedDocument, clonedElement) => {
9111
+ clonedDocument.body.style.width = "1920px";
9112
+ clonedDocument.body.style.height = "1080px";
9113
+ /* if (!isCoverPage) {
9114
+ clonedDocument.body.style.background = "#f4f7f9";
9115
+ }
9116
+
9117
+ const pageContainers = clonedElement.querySelectorAll(".export-page-container");
9118
+ const inputWrappers = clonedElement.querySelectorAll(".page-title-input");
9119
+ const textareas = clonedElement.querySelectorAll(".report-page-item-textarea");
9120
+ const datePickerWrappers = clonedElement.querySelectorAll(".report-page-item-datepicker");
9121
+ const pageBlockContainers = clonedElement.querySelectorAll(".report-page-block-container");
9122
+ const pageItemTitles = clonedDocument.querySelectorAll(".report-page-item-title");
9123
+
9124
+ pageContainers.forEach((element) => {
9125
+ (element as HTMLDivElement).style.background = isCoverPage ? "transparent" : "#f4f7f9";
9126
+ (element as HTMLDivElement).style.border = "none";
9127
+ (element as HTMLDivElement).style.padding = isCoverPage ? "0px" : "3rem 3rem 30rem";
9128
+ (element as HTMLDivElement).style.margin = isCoverPage ? "0px" : "initial";
9129
+ });
9130
+
9131
+ inputWrappers.forEach((inputWrapper) => {
9132
+ const input = inputWrapper.querySelector("input");
9133
+ const div = document.createElement("div");
9134
+
9135
+ div.innerText = (input as HTMLInputElement).value;
9136
+
9137
+ inputWrapper.replaceWith(div);
9138
+ });
9139
+
9140
+ textareas.forEach((textarea) => {
9141
+ const div = document.createElement("div");
9142
+
9143
+ if ((textarea as HTMLTextAreaElement).classList.contains("report-page-item-comment")) {
9144
+ if (isCoverPage) {
9145
+ (div as HTMLDivElement).style.display = "none";
9146
+ } else {
9147
+ (div as HTMLDivElement).style.fontSize = "24px";
9148
+ (div as HTMLDivElement).style.fontWeight = "400";
9149
+ (div as HTMLDivElement).style.opacity = "0.54";
9150
+ (div as HTMLDivElement).style.marginTop = "2rem";
9151
+ }
9152
+ }
9153
+
9154
+ if (isCoverPage) {
9155
+ if ((textarea as HTMLTextAreaElement).classList.contains("report-page-front-cover-title")) {
9156
+ (div as HTMLDivElement).style.fontSize = "32px";
9157
+ (div as HTMLDivElement).style.fontWeight = "300";
9158
+ (div as HTMLDivElement).style.lineHeight = "normal";
9159
+ }
9160
+
9161
+ if ((textarea as HTMLTextAreaElement).classList.contains("report-page-front-cover-comment")) {
9162
+ (div as HTMLDivElement).style.fontSize = "16px";
9163
+ (div as HTMLDivElement).style.fontWeight = "400";
9164
+ (div as HTMLDivElement).style.opacity = "0.54";
9165
+ (div as HTMLDivElement).style.lineHeight = "normal";
9166
+ }
9167
+ }
9168
+
9169
+ div.innerText = (textarea as HTMLTextAreaElement).value;
9170
+
9171
+ textarea.replaceWith(div);
9172
+ });
9173
+
9174
+ datePickerWrappers.forEach((inputWrapper) => {
9175
+ const input = inputWrapper.querySelector("input");
9176
+ const div = document.createElement("div");
9177
+
9178
+ if (isCoverPage) {
9179
+ (div as HTMLDivElement).style.fontSize = "12px";
9180
+ (div as HTMLDivElement).style.fontWeight = "400";
9181
+ (div as HTMLDivElement).style.opacity = "0.54";
9182
+ }
9183
+
9184
+ div.innerText = (input as HTMLInputElement).value;
9185
+
9186
+ inputWrapper.replaceWith(div);
9187
+ });
9188
+
9189
+ pageBlockContainers.forEach((element) => {
9190
+ (element as HTMLDivElement).style.background = "#ffffff";
9191
+ });
9192
+
9193
+ pageItemTitles.forEach((item) => {
9194
+ if (isCoverPage) {
9195
+ (item as HTMLDivElement).style.display = "none";
9196
+ } else {
9197
+ (item as HTMLDivElement).style.fontSize = "40px";
9198
+ (item as HTMLDivElement).style.fontWeight = "300";
9199
+ (item as HTMLDivElement).style.marginBottom = "2rem";
9200
+ }
9201
+ });*/
9202
+ },
9203
+ });
9204
+ const img = data.toDataURL("image/png");
9205
+ const imgProperties = pdf.getImageProperties(img);
9206
+ const pdfWidth = pdf.internal.pageSize.getWidth();
9207
+ const pdfHeight = (imgProperties.height * pdfWidth) / imgProperties.width;
9208
+ if (i > 0) {
9209
+ pdf.addPage("a4", "landscape");
9210
+ }
9211
+ pdf.addImage(img, "PNG", 0, 0, pdfWidth, pdfHeight);
9212
+ }
9213
+ pdf.save(`report_${format(new Date(), "yyyy-MM-dd_HH:mm:ss")}.pdf`);
9214
+ setLoading(false);
9215
+ }, [ids]);
9216
+ return { loading, onExport };
9217
+ };
9218
+
9087
9219
  const getMinMaxFromStringValue = (items, value, current, type) => {
9088
9220
  const valueIndex = items.findIndex(item => item.value === (type === "min" ? value.min : value.max));
9089
9221
  const currentIndex = items.findIndex(item => item.value === (type === "min" ? value.min : value.max));
@@ -9965,5 +10097,5 @@ const Map$1 = ({ zIndex, lowerSiblings, upperSiblings, onError, children, ...res
9965
10097
  }, children: children }), upperSiblings] }));
9966
10098
  };
9967
10099
 
9968
- export { AddFeatureButton, AddFeatureContainer, AttributeGalleryContainer, AttributeLabel, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementSlideshow, ElementSvg, ElementTooltip, ElementValueWrapper, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, TwoColumnsInnerContainer, WidgetType, addDataSource, addDataSources, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useGetConfigLayer, useGlobalContext, useHeaderRender, useLayerParams, useMapContext, useMapDraw, useProjectDashboardInit, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
10100
+ export { AddFeatureButton, AddFeatureContainer, AttributeGalleryContainer, AttributeLabel, BaseMapTheme, CONFIG_PAGES_ID, CONFIG_PAGE_ID, CameraContainer, Chart, ChartContainer, ChartLegend, ChartLoading, ContainerChildren, ContainerLoading, ContainerTemplate, ContainerWrapper, ContainersGroupContainer, DEFAULT_ATTRIBUTE_NAME, DEFAULT_BARCHART_RADIUS, DEFAULT_BASE_MAP, DEFAULT_CHART_ANGLE, DEFAULT_CHART_HEIGHT, DEFAULT_CHART_WIDTH, DEFAULT_CIRCLE_PAINT, DEFAULT_DASHBOARD_CONFIG, DEFAULT_DATA_SOURCE_LIMIT, DEFAULT_FILL_EXTRUSION_PAINT, DEFAULT_FILL_PAINT, DEFAULT_ID_ATTRIBUTE_NAME, DEFAULT_LAT, DEFAULT_LINE_PAINT, DEFAULT_LNG, DEFAULT_PAGES_CONFIG, DEFAULT_PIECHART_RADIUS, DEFAULT_ZOOM, Dashboard, DashboardCheckbox, DashboardChip, DashboardContent, DashboardContext, DashboardDefaultHeader, DashboardHeader, DashboardLoading, DashboardPlaceholder, DashboardPlaceholderWrap, DashboardProvider, DashboardWrapper, DataSourceContainer, DataSourceError, DataSourceErrorContainer, DataSourceInnerContainer, DataSourceProgressContainer, DateFormat, DefaultAttributesContainer, DefaultHeaderContainer, DefaultHeaderWrapper, DividerContainer, EditGeometryType, ElementButton, ElementCamera, ElementChart, ElementChips, ElementIcon, ElementImage, ElementLegend, ElementLink, ElementSlideshow, ElementSvg, ElementTooltip, ElementValueWrapper, ExpandableTitle, FEATURE_CARD_DEFAULT_COLORS, FEATURE_CARD_OTHER_COLOR, FILTERED_VALUE_OPACITY, FILTER_PREFIX, FeatureCardButtons, FeatureCardContext, FeatureCardDefaultHeader, FeatureCardGradientHeader, FeatureCardHeader, FeatureCardIconHeader, FeatureCardProvider, FeatureCardSlideshowHeader, FeatureCardTitle, FeatureControls, FeatureTitleContainer, FiltersContainer, GEOMETRY_ATTRIBUTE, GlobalContext, GlobalProvider, Header, HeaderContainer, HeaderFrontView, HeaderTemplate, HeaderTitleContainer, HiddenTitleItems, IconContainer, ImageContainer, LEFT_PANEL_HEADER_HEIGHT, Layer, LayerDescription, LayerGroup, LayerGroupList, LayerIcon, LayerListContainer, LayerTree, LayersContainer, LayersListWrapper, LinearProgressContainer, LogoContainer, MAX_CHART_WIDTH, Map$1 as Map, MapContext, MapProvider, NO_CONTENT_VALUE, NUMERIC_ATTRIBUTE_TYPES, NoLiveSnapshotContainer, OneColumnContainer, PageNavigator, PageTitle, PagesContainer, Pagination, PresentationHeader, PresentationHeaderButtons, PresentationHeaderTools, PresentationPanelContainer, PresentationPanelWrapper, PresentationWrapper, ProgressContainer, RoundedBackgroundContainer, ScalingFactor, ServerNotificationsContext, ServerNotificationsProvider, SlideshowContainer, SmallPreviewContainer$1 as SmallPreviewContainer, SmallPreviewControl, SmallPreviewCounter, SmallPreviewImages, SmallPreviewLeft, SmallPreviewRight, StackBar, SvgImage, TIME_ZONE_FORMAT, TabsContainer, TextTrim, ThemeName, TitleContainer, TmsType, TopContainer, TopContainerButtons, TwoColumnContainer, TwoColumnsInnerContainer, WidgetType, addDataSource, addDataSources, applyFiltersToCondition, applyQueryFilters, applyVarsToCondition, checkEqualOrIncludes, checkIsLoading, convertSpToTurfFeature, createConfigLayer, createConfigPage, createNewPageId, createTreeNode, dateOptions, debounce, decimalOpacityToHex, eqlParametersToPayload, findAttributeInExpression, formatArea, formatAttributeValue, formatChartRelatedValue, formatConditionValue, formatDataSourceCondition, formatDate$1 as formatDate, formatElementValue, formatLength, formatNumber, formatPolygonMeasure, getActualExtrusionHeight, getAttributeByName, getAttributeValue, getAttributesConfiguration, getChartFilterName, getChartMarkers, getConfigFilter, getContainerComponent, getDashboardHeader, getDataFromAttributes, getDataFromRelatedFeatures, getDataSource, getDataSourceFilterValue, getDate, getDefaultConfig, getElementValue, getFeatureAttributes, getFeatureCardHeader, getFilterComponent, getFilterSelectedItems, getFilterValue, getFormattedAttributes, getGradientColors, getLayerDefinition, getLayerInfo, getLayerInfoFromDataSources, getPagesFromConfig, getPagesFromProjectInfo, getProxyService, getRelatedAttribute, getRenderElement, getResourceUrl, getSelectedFilterValue, getSlideshowImages, getSvgUrl, getTotalFromAttributes, getTotalFromRelatedFeatures, hexToRgba, isCompositeLayerConfiguration, isEmptyElementValue, isEmptyValue, isHiddenEmptyValue, isLayerService, isNotValidSelectedTab, isNumeric, isObject, isProxyService, isVisibleContainer, numberOptions, parseClientStyle, pieChartTooltipFromAttributes, pieChartTooltipFromRelatedFeatures, pointOptions, removeDataSource, rgbToHex, roundTotalSum, sliceShownOtherItems, timeOptions, tooltipNameFromAttributes, tooltipValueFromAttributes, tooltipValueFromRelatedFeatures, transparentizeColor, treeNodesToProjectItems, useAppHeight, useChartChange, useChartData, useDashboardHeader, useDataSources, useDebouncedCallback, useDiffPage, useExpandableContainers, useExportPdf, useGetConfigLayer, useGlobalContext, useHeaderRender, useLayerParams, useMapContext, useMapDraw, useProjectDashboardInit, useRedrawLayer, useRelatedDataSourceAttributes, useRenderElement, useServerNotificationsContext, useShownOtherItems, useToggle, useUpdateDataSource, useWidgetConfig, useWidgetContext, useWidgetFilters, useWidgetPage, useWindowResize, useZoomToFeatures, useZoomToPoint };
9969
10101
  //# sourceMappingURL=react.esm.js.map