@evergis/react 3.1.57 → 3.1.59

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.
@@ -1,5 +1,6 @@
1
- import { ConfigContainerChild, ContainerProps } from '../../types';
1
+ import { ConfigContainerChild, ContainerProps, WidgetType } from '../../types';
2
2
  export type ContainerChildrenProps = {
3
+ type: WidgetType;
3
4
  items: ConfigContainerChild[];
4
5
  elementConfig?: ConfigContainerChild;
5
6
  isColumn?: boolean;
@@ -9,6 +9,7 @@ export * from './useWidgetFilters';
9
9
  export * from './useGetConfigLayer';
10
10
  export * from './useGlobalContext';
11
11
  export * from './useHeaderRender';
12
+ export * from './useHideIfEmptyDataSource';
12
13
  export * from './useProjectDashboardInit';
13
14
  export * from './useRelatedDataSourceAttributes';
14
15
  export * from './useRenderElement';
@@ -0,0 +1,2 @@
1
+ import { WidgetType } from '../types';
2
+ export declare const useHideIfEmptyDataSource: (type?: WidgetType) => (dataSourceName: string) => boolean;
@@ -31,6 +31,8 @@ export interface ConfigRelatedResource {
31
31
  resourceId: string;
32
32
  parameters: Record<string, unknown>;
33
33
  script?: string;
34
+ fileName?: string;
35
+ methodName?: string;
34
36
  }
35
37
  export interface BaseMapSettings {
36
38
  opacity?: number;
@@ -118,6 +120,7 @@ export interface ConfigOptions {
118
120
  bigIcon?: boolean;
119
121
  onlyIcon?: boolean;
120
122
  hideEmpty?: boolean;
123
+ hideIfEmptyDataSource?: string;
121
124
  innerValue?: boolean;
122
125
  groupTooltip?: boolean;
123
126
  tabId?: string;
@@ -1,8 +1,10 @@
1
1
  export declare const usePythonTask: () => {
2
- runTask: ({ resourceId, parameters, script, }: {
2
+ runTask: ({ resourceId, parameters, script, fileName, methodName, }: {
3
3
  resourceId: string;
4
4
  parameters: Record<string, unknown>;
5
- script: string;
5
+ script?: string;
6
+ fileName?: string;
7
+ methodName?: string;
6
8
  }) => Promise<void>;
7
9
  stopTask: () => Promise<void>;
8
10
  result: string;
package/dist/index.js CHANGED
@@ -4840,7 +4840,7 @@ const usePythonTask = () => {
4840
4840
  setTaskId(null);
4841
4841
  setSubscriptionId(null);
4842
4842
  }, []);
4843
- const runTask = React.useCallback(async ({ resourceId, parameters, script, }) => {
4843
+ const runTask = React.useCallback(async ({ resourceId, parameters, script, fileName, methodName, }) => {
4844
4844
  reset();
4845
4845
  const start = Date.now();
4846
4846
  let prototypeId = await api$1.remoteTaskManager.createTaskPrototype({
@@ -4854,6 +4854,8 @@ const usePythonTask = () => {
4854
4854
  resourceId,
4855
4855
  parameters,
4856
4856
  script,
4857
+ fileName,
4858
+ methodName,
4857
4859
  method: "pythonrunner/run",
4858
4860
  },
4859
4861
  },
@@ -5417,7 +5419,7 @@ const ContainersGroupContainer = React.memo(({ elementConfig, type, renderElemen
5417
5419
  const { column, expandable, expanded } = options || {};
5418
5420
  const isColumn = column === undefined || column;
5419
5421
  const isVisible = isVisibleContainer(id, expandable, expanded, expandedContainers);
5420
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsx(Container, { id: id, isColumn: isColumn, children: jsxRuntime.jsx(ContainerChildren, { items: children, elementConfig: elementConfig, isColumn: isColumn, isMain: id?.startsWith(CONFIG_PAGE_ID), renderElement: renderElement }) }))] }));
5422
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), isVisible && (jsxRuntime.jsx(Container, { id: id, isColumn: isColumn, children: jsxRuntime.jsx(ContainerChildren, { type: type, items: children, elementConfig: elementConfig, isColumn: isColumn, isMain: id?.startsWith(CONFIG_PAGE_ID), renderElement: renderElement }) }))] }));
5421
5423
  });
5422
5424
 
5423
5425
  const ChartLegendContainer = styled(uilibGl.Flex) `
@@ -6122,7 +6124,7 @@ const PagesContainer = React.memo(({ type = exports.WidgetType.Dashboard, noBord
6122
6124
  setSelectedTabId,
6123
6125
  type,
6124
6126
  ]);
6125
- return (jsxRuntime.jsx(Container, { id: getRootElementId(type), style: { width }, isMain: true, isColumn: isColumn, noBorders: noBorders, children: jsxRuntime.jsx(ContainerChildren, { items: filteredChildren, isMain: true, renderElement: renderElement }) }));
6127
+ return (jsxRuntime.jsx(Container, { id: getRootElementId(type), style: { width }, isMain: true, isColumn: isColumn, noBorders: noBorders, children: jsxRuntime.jsx(ContainerChildren, { type: type, items: filteredChildren, isMain: true, renderElement: renderElement }) }));
6126
6128
  });
6127
6129
 
6128
6130
  const ImageContainerBg$1 = styled.div `
@@ -6737,7 +6739,7 @@ const TaskContainer = React.memo(({ type, elementConfig }) => {
6737
6739
  const { options } = elementConfig || {};
6738
6740
  const { title, relatedResources, center, icon } = options || {};
6739
6741
  const onClick = React.useCallback(async () => {
6740
- await Promise.all(relatedResources.map(({ resourceId, parameters, script }) => {
6742
+ await Promise.all(relatedResources.map(({ resourceId, parameters, script, fileName, methodName }) => {
6741
6743
  const newParams = applyQueryFilters({
6742
6744
  parameters,
6743
6745
  dataSources,
@@ -6745,7 +6747,7 @@ const TaskContainer = React.memo(({ type, elementConfig }) => {
6745
6747
  filters: currentPage.filters,
6746
6748
  geometry: ewktGeometry,
6747
6749
  });
6748
- return runTask({ resourceId, parameters: newParams, script });
6750
+ return runTask({ resourceId, parameters: newParams, script, fileName, methodName });
6749
6751
  }));
6750
6752
  }, [currentPage.filters, dataSources, ewktGeometry, relatedResources, runTask, selectedFilters]);
6751
6753
  return (jsxRuntime.jsx(uilibGl.Flex, { justifyContent: center ? "center" : "flex-start", children: jsxRuntime.jsxs(uilibGl.WaitingButton, { primary: true, isWaiting: loading, disabled: !relatedResources?.length, onClick: onClick, children: [icon && jsxRuntime.jsx(uilibGl.FlexSpan, { marginRight: "0.5rem", children: jsxRuntime.jsx(uilibGl.Icon, { kind: icon }) }), title || t("run", { ns: "dashboard", defaultValue: "Запуск" })] }) }));
@@ -8257,7 +8259,7 @@ const getElementValue = ({ getDefaultContainer, ...props }) => {
8257
8259
  return attribute?.name ? layerInfo.layerDefinition.attributes[attribute.name]?.description || null : null;
8258
8260
  }
8259
8261
  const ElementComponent = type ? elementComponents[type] : null;
8260
- return ElementComponent ? jsxRuntime.jsx(ElementComponent, { ...props }) : getDefaultContainer();
8262
+ return ElementComponent ? jsxRuntime.jsx(ElementComponent, { ...props }) : getDefaultContainer?.();
8261
8263
  };
8262
8264
 
8263
8265
  const getLayerAttributes = (layerDefinition) => {
@@ -9965,6 +9967,15 @@ const useGetConfigLayer = () => {
9965
9967
  return React.useCallback((layerName) => currentPage?.layers?.find(({ name }) => name === layerName), [currentPage?.layers]);
9966
9968
  };
9967
9969
 
9970
+ const useHideIfEmptyDataSource = (type = exports.WidgetType.Dashboard) => {
9971
+ const { dataSources } = useWidgetContext(type);
9972
+ return React.useCallback((dataSourceName) => {
9973
+ if (!dataSourceName)
9974
+ return false;
9975
+ return !getDataSource(dataSourceName, dataSources)?.features?.length;
9976
+ }, [dataSources]);
9977
+ };
9978
+
9968
9979
  const useProjectDashboardInit = () => {
9969
9980
  const { projectInfo, updateProject } = useWidgetContext();
9970
9981
  return React.useCallback(() => {
@@ -10272,7 +10283,8 @@ const ChartLegend = ({ data, chartElement, fontSize, type, twoColumns, loading }
10272
10283
  return (jsxRuntime.jsxs(uilibGl.Flex, { flexDirection: "column", opacity: loading ? FILTERED_VALUE_OPACITY / 100 : 1, children: [jsxRuntime.jsx(ChartLegendContainer, { twoColumns: twoColumns, children: sliceItems(data)?.map(({ name, color }, index) => (jsxRuntime.jsxs(ChartLegendItem, { hasAnyFilter: hasAnyFilter, isFiltered: isFiltered(name), onClick: axes?.[0]?.filterName ? () => onFilter(name) : undefined, children: [jsxRuntime.jsx(ChartLegendColor, { color: color }), jsxRuntime.jsx(ChartLegendName, { "$fontSize": fontSize, "$fontColor": fontColor, children: name })] }, index))) }), showMoreBtn && (jsxRuntime.jsx(uilibGl.LegendToggler, { onClick: onShowMore, toggled: showMore, children: t("other", { ns: "dashboard", defaultValue: "Другое" }) }))] }));
10273
10284
  };
10274
10285
 
10275
- const ContainerChildren = React.memo(({ items, isColumn, isMain, renderElement }) => {
10286
+ const ContainerChildren = React.memo(({ type, items, isColumn, isMain, renderElement }) => {
10287
+ const checkIfEmptyDataSource = useHideIfEmptyDataSource(type);
10276
10288
  return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: items
10277
10289
  ?.filter(item => !["title", "icon", "titleIcon"].includes(item.id))
10278
10290
  ?.map((item, index) => {
@@ -10281,6 +10293,8 @@ const ContainerChildren = React.memo(({ items, isColumn, isMain, renderElement }
10281
10293
  index,
10282
10294
  wrap: isColumn || isMain,
10283
10295
  });
10296
+ if (checkIfEmptyDataSource(item.options?.hideIfEmptyDataSource))
10297
+ return null;
10284
10298
  return isMain ? (jsxRuntime.jsx(ContainerWrapper, { "data-id": item.id, "data-templatename": item.templateName, "$noMargin": item.options?.noMargin, children: jsxRuntime.jsx(DashboardWrapper, { children: render }) }, index)) : (jsxRuntime.jsx(React.Fragment, { children: render }, index));
10285
10299
  }) }));
10286
10300
  });
@@ -11021,6 +11035,7 @@ exports.useExportPdf = useExportPdf;
11021
11035
  exports.useGetConfigLayer = useGetConfigLayer;
11022
11036
  exports.useGlobalContext = useGlobalContext;
11023
11037
  exports.useHeaderRender = useHeaderRender;
11038
+ exports.useHideIfEmptyDataSource = useHideIfEmptyDataSource;
11024
11039
  exports.useLayerParams = useLayerParams;
11025
11040
  exports.useMapContext = useMapContext;
11026
11041
  exports.useMapDraw = useMapDraw;