@evergis/react 4.0.33 → 4.0.35

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.
@@ -13,6 +13,7 @@ export declare const DEFAULT_CHART_WIDTH = 154;
13
13
  export declare const MAX_CHART_WIDTH = 300;
14
14
  export declare const DEFAULT_CHART_ANGLE = 4;
15
15
  export declare const DEFAULT_CHART_HEIGHT = 90;
16
+ export declare const STACK_BAR_TOTAL_HEIGHT = 20;
16
17
  export declare const FILTER_PREFIX = "%";
17
18
  export declare const PROVIDER_PREFIX = "$";
18
19
  export declare enum ProviderPrefix {
@@ -167,6 +167,7 @@ export interface ConfigOptions {
167
167
  expandedLayers?: boolean;
168
168
  modalId?: string;
169
169
  url?: string;
170
+ maxZoomTo?: number;
170
171
  customFeatureSelect?: CustomFeatureSelect;
171
172
  }
172
173
  export interface ConfigDataSource {
@@ -233,6 +234,7 @@ export interface ConfigLayer {
233
234
  searchFields?: string[];
234
235
  minScale?: number;
235
236
  maxScale?: number;
237
+ maxZoomTo?: number;
236
238
  hiddenAttributes?: string[];
237
239
  customFeatureSelect?: CustomFeatureSelect;
238
240
  }
@@ -1,2 +1,3 @@
1
1
  import { FeatureDc } from '@evergis/api';
2
- export declare const useZoomToFeatures: () => (features?: FeatureDc[], padding?: number) => void;
2
+ import { FitBoundsOptions } from 'maplibre-gl';
3
+ export declare const useZoomToFeatures: () => (features?: FeatureDc[], options?: FitBoundsOptions) => void;
package/dist/index.js CHANGED
@@ -3436,6 +3436,7 @@ const DEFAULT_CHART_WIDTH = 154;
3436
3436
  const MAX_CHART_WIDTH = 300;
3437
3437
  const DEFAULT_CHART_ANGLE = 4;
3438
3438
  const DEFAULT_CHART_HEIGHT = 90;
3439
+ const STACK_BAR_TOTAL_HEIGHT = 20;
3439
3440
  const FILTER_PREFIX = "%";
3440
3441
  const PROVIDER_PREFIX = "$";
3441
3442
  exports.ProviderPrefix = void 0;
@@ -5341,7 +5342,7 @@ const useRedrawLayer = () => {
5341
5342
 
5342
5343
  const useZoomToFeatures = () => {
5343
5344
  const { map } = useMapContext();
5344
- return React.useCallback((features, padding) => {
5345
+ return React.useCallback((features, options) => {
5345
5346
  if (!features) {
5346
5347
  return;
5347
5348
  }
@@ -5349,7 +5350,7 @@ const useZoomToFeatures = () => {
5349
5350
  type: "FeatureCollection",
5350
5351
  features: features,
5351
5352
  });
5352
- map.current.fitBounds(currentFeatureCenter, { padding: padding ?? 150 });
5353
+ map.current.fitBounds(currentFeatureCenter, { ...options, padding: options?.padding ?? 150 });
5353
5354
  }, [map]);
5354
5355
  };
5355
5356
 
@@ -11396,16 +11397,22 @@ const StackBar = ({ data, filterName, type, alias, options, renderElement, rende
11396
11397
  const { t } = useGlobalContext();
11397
11398
  const { hasAnyFilter, isFiltered, onFilter } = useWidgetFilters(type, filterName, data?.[0]?.items);
11398
11399
  const { items, layerInfo, attributeName } = data?.[0] || {};
11399
- const attribute = layerInfo?.configuration?.attributesConfiguration?.attributes[attributeName];
11400
+ const attribute = layerInfo?.configuration?.attributesConfiguration?.attributes[attributeName]
11401
+ ?? layerInfo?.configuration
11402
+ ?.attributesConfiguration
11403
+ ?.attributes
11404
+ ?.find(({ attributeName: name }) => name === attributeName);
11400
11405
  const units = attribute?.stringFormat?.unitsLabel;
11401
11406
  const total = React.useMemo(() => items?.reduce((result, { value }) => result + Number(value), 0) || 0, [items]);
11402
11407
  const getWidth = React.useCallback(value => ((Number(value) / total) * 100).toFixed(2), [total]);
11403
11408
  const renderGroupTooltip = React.useMemo(() => (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsx(ChartTooltipTable, { cellPadding: 0, cellSpacing: 0, children: items?.map(({ name, value, color }, index) => (jsxRuntime.jsxs("tr", { children: [jsxRuntime.jsx("td", { children: jsxRuntime.jsxs(ChartTooltip, { alignItems: "center", children: [jsxRuntime.jsx(ChartTooltipColor, { "$color": color }), jsxRuntime.jsx(ChartTooltipName, { children: name })] }) }), jsxRuntime.jsx("td", { children: value })] }, index))) }) })), [items]);
11404
11409
  const renderItem = React.useCallback(({ name, value, color }, ref) => (jsxRuntime.jsx(StackBarSection, { ref: ref, "$width": getWidth(value), "$height": height, "$color": color, cornerRadius: cornerRadius, hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: filterName ? () => onFilter(name) : undefined })), [cornerRadius, filterName, getWidth, hasAnyFilter, height, isFiltered, onFilter]);
11405
11410
  const renderItems = React.useMemo(() => (jsxRuntime.jsx(jsxRuntime.Fragment, { children: items?.map((item, index) => (jsxRuntime.jsx(React.Fragment, { children: groupTooltip ? (renderItem(item)) : (jsxRuntime.jsx(uilibGl.ThemeProvider, { children: jsxRuntime.jsx(uilibGl.Tooltip, { placement: "top", arrow: true, content: renderTooltip([item]), children: ref => renderItem(item, ref) }) })) }, index))) })), [groupTooltip, items, renderItem, renderTooltip]);
11406
- if (!total || !attribute)
11411
+ if (!total)
11407
11412
  return null;
11408
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(alias || showTotal) && (jsxRuntime.jsxs(StackBarHeader, { children: [jsxRuntime.jsx(StackBarAlias, { children: renderElement({ id: "alias" }) }), showTotal && (jsxRuntime.jsxs(StackBarTotal, { children: [jsxRuntime.jsx(StackBarValue, { children: formatAttributeValue({ t, type: attribute.type, value: total, stringFormat: attribute.stringFormat, noUnits: true }) }), !!units && jsxRuntime.jsx(StackBarUnits, { children: units })] }))] })), groupTooltip ? (jsxRuntime.jsx(uilibGl.Tooltip, { placement: "top", arrow: true, content: renderGroupTooltip, children: ref => jsxRuntime.jsx(StackBarContainer, { ref: ref, children: renderItems }) })) : (jsxRuntime.jsx(StackBarContainer, { children: renderItems }))] }));
11413
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [(alias || showTotal) && (jsxRuntime.jsxs(StackBarHeader, { children: [jsxRuntime.jsx(StackBarAlias, { children: renderElement({ id: "alias" }) }), showTotal && (jsxRuntime.jsxs(StackBarTotal, { children: [jsxRuntime.jsx(StackBarValue, { children: attribute
11414
+ ? formatAttributeValue({ t, type: attribute.type, value: total, stringFormat: attribute.stringFormat, noUnits: true })
11415
+ : total }), !!units && jsxRuntime.jsx(StackBarUnits, { children: units })] }))] })), groupTooltip ? (jsxRuntime.jsx(uilibGl.Tooltip, { placement: "top", arrow: true, content: renderGroupTooltip, children: ref => jsxRuntime.jsx(StackBarContainer, { ref: ref, children: renderItems }) })) : (jsxRuntime.jsx(StackBarContainer, { children: renderItems }))] }));
11409
11416
  };
11410
11417
 
11411
11418
  const Chart = React.memo(({ config, element, elementConfig, type, renderElement }) => {
@@ -11548,7 +11555,8 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11548
11555
  }, customYAxis: yAxis => yAxis.ticks(4), renderTooltip: renderLineChartTooltip, customize: customize, dotSnapping: dotSnapping, dynamicTooltipEnable: true, stackedTooltip: true, tooltipClassName: "dashboardLineChartTooltip", drawGridX: !isHidedY, margin: margin })] }));
11549
11556
  }
11550
11557
  if (isStackBar) {
11551
- return (jsxRuntime.jsx(AnyChartWrapper, { height: height, children: jsxRuntime.jsx(StackBar, { data: data, filterName: filterName, type: type, alias: elementConfig?.children?.find(child => child.id === "alias"), options: options, renderTooltip: renderPieChartTooltip, renderElement: renderElement }) }));
11558
+ const stackBarHeight = showTotal ? height + STACK_BAR_TOTAL_HEIGHT : height;
11559
+ return (jsxRuntime.jsx(AnyChartWrapper, { height: stackBarHeight, children: jsxRuntime.jsx(StackBar, { data: data, filterName: filterName, type: type, alias: elementConfig?.children?.find(child => child.id === "alias"), options: options, renderTooltip: renderPieChartTooltip, renderElement: renderElement }) }));
11552
11560
  }
11553
11561
  if (isPieChart) {
11554
11562
  return (jsxRuntime.jsx(AnyChartWrapper, { height: height, children: jsxRuntime.jsx(charts.PieChart, { data: (data[0]?.items
@@ -11566,6 +11574,7 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11566
11574
  }, [
11567
11575
  customXAxisBottom,
11568
11576
  customYAxisLeft,
11577
+ dotSnapping,
11569
11578
  element,
11570
11579
  isLineChart,
11571
11580
  isStackBar,
@@ -11578,7 +11587,6 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
11578
11587
  width,
11579
11588
  barWidth,
11580
11589
  showLabels,
11581
- showMarkers,
11582
11590
  padding,
11583
11591
  formatTooltipValue,
11584
11592
  formatTooltipName,
@@ -12460,6 +12468,7 @@ exports.PresentationWrapper = PresentationWrapper;
12460
12468
  exports.ProgressContainer = ProgressContainer;
12461
12469
  exports.RoundedBackgroundContainer = RoundedBackgroundContainer;
12462
12470
  exports.SERVER_NOTIFICATION_EVENT = SERVER_NOTIFICATION_EVENT;
12471
+ exports.STACK_BAR_TOTAL_HEIGHT = STACK_BAR_TOTAL_HEIGHT;
12463
12472
  exports.ServerNotificationsContext = ServerNotificationsContext;
12464
12473
  exports.ServerNotificationsProvider = ServerNotificationsProvider;
12465
12474
  exports.SlideshowContainer = SlideshowContainer;