@evergis/react 3.1.80 → 3.1.82

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,7 +1,6 @@
1
1
  import { FC } from 'react';
2
- import { ConfigContainer, WidgetType } from '../../types';
2
+ import { WidgetType } from '../../types';
3
3
  export declare const Dashboard: FC<{
4
4
  type?: WidgetType;
5
- config?: ConfigContainer;
6
5
  noBorders?: boolean;
7
6
  }>;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ContainerProps } from '../../types';
3
+ export declare const EditContainer: FC<ContainerProps>;
@@ -29,5 +29,6 @@ export declare const containerComponents: {
29
29
  readonly ExportPdf: import('react').FC<import('../types').ContainerProps>;
30
30
  readonly Upload: import('react').FC<import('../types').ContainerProps>;
31
31
  readonly Task: import('react').FC<import('../types').ContainerProps>;
32
+ readonly Edit: import('react').FC<import('../types').ContainerProps>;
32
33
  readonly default: import('react').FC<import('../types').ContainerProps>;
33
34
  };
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ContainerProps } from '../../types';
3
+ export declare const ElementControl: FC<ContainerProps>;
@@ -3,6 +3,7 @@ export * from './ElementCamera';
3
3
  export * from './ElementCamera/styled';
4
4
  export * from './ElementChart';
5
5
  export * from './ElementChips';
6
+ export * from './ElementControl';
6
7
  export * from './ElementIcon';
7
8
  export * from './ElementImage';
8
9
  export * from './ElementLegend';
@@ -1,4 +1,5 @@
1
1
  export declare const elementComponents: {
2
+ readonly control: import('react').FC<import('..').ContainerProps>;
2
3
  readonly image: import('react').FC<import('..').ContainerProps>;
3
4
  readonly slideshow: import('react').FC<import('./ElementSlideshow/types').DashboardSlideshowProps>;
4
5
  readonly svg: import('react').FC<import('..').ContainerProps>;
@@ -20,6 +20,7 @@ export declare const useWidgetContext: (type?: WidgetType) => {
20
20
  ProjectPagesMenu?: import('react').FC;
21
21
  };
22
22
  config: import('../types').ConfigContainer;
23
+ isEditing: boolean;
23
24
  isLoading: boolean;
24
25
  pageIndex: number;
25
26
  filters: import('../types').SelectedFilters;
@@ -48,6 +48,7 @@ export interface ConfigOptions {
48
48
  relatedResources?: ConfigRelatedResource[];
49
49
  statusColors?: Record<RemoteTaskStatus, string>;
50
50
  chartType?: "bar" | "line" | "pie" | "stack";
51
+ controlType?: "dropdown" | "checkbox";
51
52
  layerNames?: string[];
52
53
  layerName?: string;
53
54
  geometryType?: GeometryType | EditGeometryType;
@@ -268,6 +269,7 @@ export declare enum ContainerTemplate {
268
269
  ExportPdf = "ExportPdf",
269
270
  Upload = "Upload",
270
271
  Task = "Task",
272
+ Edit = "Edit",
271
273
  Divider = "Divider"
272
274
  }
273
275
  export declare enum HeaderTemplate {
@@ -12,6 +12,7 @@ export type DashboardContextProps = PropsWithChildren<{
12
12
  dataSources?: WidgetDataSource[];
13
13
  geometryFilter?: boolean;
14
14
  loading?: boolean;
15
+ editMode?: boolean;
15
16
  filters?: SelectedFilters;
16
17
  dashboardLayers?: DashboardState["layers"];
17
18
  setDashboardLayer?: (props: DashboardLayerPayload) => void;
@@ -10,7 +10,7 @@ export type FeatureCardContextSettings = PropsWithChildren<{
10
10
  pageIndex?: number;
11
11
  handBookReference?: LayerReferenceConfigurationDc;
12
12
  isRaster?: boolean;
13
- isEditing?: boolean;
13
+ editMode?: boolean;
14
14
  isFeatureEditable?: boolean;
15
15
  hasCopyRights?: boolean;
16
16
  editOnly?: boolean;
package/dist/index.js CHANGED
@@ -3387,6 +3387,7 @@ exports.ContainerTemplate = void 0;
3387
3387
  ContainerTemplate["ExportPdf"] = "ExportPdf";
3388
3388
  ContainerTemplate["Upload"] = "Upload";
3389
3389
  ContainerTemplate["Task"] = "Task";
3390
+ ContainerTemplate["Edit"] = "Edit";
3390
3391
  ContainerTemplate["Divider"] = "Divider";
3391
3392
  })(exports.ContainerTemplate || (exports.ContainerTemplate = {}));
3392
3393
  exports.HeaderTemplate = void 0;
@@ -4002,8 +4003,8 @@ const ServerNotificationsProvider = ({ url, initialized, children }) => {
4002
4003
  };
4003
4004
 
4004
4005
  const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
4005
- const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
4006
- const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
4006
+ const { projectInfo, updateProject, layerInfos, geometryFilter, dashboardLayers, setDashboardLayer, components: dashboardComponents, config: dashboardConfig, containerIds, pageIndex: projectPageIndex, selectedTabId: projectSelectedTabId, setSelectedTabId: setProjectSelectedTabId, dataSources: projectDataSources, loading: projectLoading, editMode: projectEditMode, filters: projectFilters, changeFilters: projectChangeFilters, expandContainer: projectExpandContainer, expandedContainers: projectExpandedContainers, nextPage: projectNextPage, prevPage: projectPrevPage, changePage: projectChangePage, } = React.useContext(DashboardContext) || {};
4007
+ const { layerInfo, attributes, feature, closeFeatureCard, config: featureConfig, pageIndex: featurePageIndex, selectedTabId: featureSelectedTabId, setSelectedTabId: setFeatureSelectedTabId, dataSources: featureDataSources, loading: featureLoading, editMode: featureEditMode, filters: featureFilters, changeFilters: featureChangeFilters, expandContainer: featureExpandContainer, expandedContainers: featureExpandedContainers, nextPage: featureNextPage, prevPage: featurePrevPage, changePage: featureChangePage, } = React.useContext(FeatureCardContext) || {};
4007
4008
  return {
4008
4009
  projectInfo,
4009
4010
  layerInfos,
@@ -4018,6 +4019,7 @@ const useWidgetContext = (type = exports.WidgetType.Dashboard) => {
4018
4019
  containerIds,
4019
4020
  components: dashboardComponents,
4020
4021
  config: type === exports.WidgetType.Dashboard ? dashboardConfig : featureConfig,
4022
+ isEditing: type === exports.WidgetType.Dashboard ? projectEditMode : featureEditMode,
4021
4023
  isLoading: type === exports.WidgetType.Dashboard ? projectLoading : featureLoading,
4022
4024
  pageIndex: type === exports.WidgetType.Dashboard ? projectPageIndex || 1 : featurePageIndex || 1,
4023
4025
  filters: type === exports.WidgetType.Dashboard ? projectFilters : featureFilters,
@@ -5163,14 +5165,16 @@ const Container = styled(uilibGl.Flex) `
5163
5165
 
5164
5166
  ${({ isColumn }) => isColumn
5165
5167
  ? styled.css `
5166
- &&& > * {
5167
- justify-content: flex-start;
5168
- width: 100%;
5168
+ &&& > * {
5169
+ justify-content: flex-start;
5170
+ }
5171
+ > * {
5172
+ width: 100%;
5169
5173
 
5170
- :not(:last-child) {
5171
- margin-bottom: 1.5rem;
5172
- }
5174
+ :not(:last-child) {
5175
+ margin-bottom: 1.5rem;
5173
5176
  }
5177
+ }
5174
5178
  `
5175
5179
  : styled.css `
5176
5180
  flex-direction: row;
@@ -6501,16 +6505,6 @@ const TitleContainer = React.memo(({ containerId, templateName, layerNames, font
6501
6505
  return (jsxRuntime.jsx(Container, { id: id, style: style, isTitle: isVisible, children: jsxRuntime.jsxs(ContainerTitle, { simple: simple, children: [jsxRuntime.jsxs(ContainerIconTitle, { fontColor: fontColor, children: [renderElement({ id: "titleIcon", wrap: false }), renderElement({ id: "title" }), !!downloadById && (jsxRuntime.jsx(uilibGl.IconButton, { kind: "download", onClick: onExport })), isLayers && renderToggler] }), !isLayers && renderToggler, renderVisibility] }) }));
6502
6506
  });
6503
6507
 
6504
- const ContainerDivider = styled(uilibGl.Divider) `
6505
- width: 100%;
6506
- border-color: ${({ theme: { palette }, $bgColor }) => $bgColor || palette.elementDeep};
6507
- `;
6508
-
6509
- const DividerContainer = React.memo(({ elementConfig, config }) => {
6510
- const { id, style } = elementConfig || {};
6511
- return (jsxRuntime.jsx(Container, { id: id, style: style, children: jsxRuntime.jsx(ContainerDivider, { "$bgColor": config?.options?.bgColor }) }));
6512
- });
6513
-
6514
6508
  const SlideshowContainer = React.memo(({ config, elementConfig, type }) => {
6515
6509
  const { pageIndex, expandedContainers, selectedTabId, setSelectedTabId, dataSources } = useWidgetContext(type);
6516
6510
  const { attributes, layerInfo } = useRelatedDataSourceAttributes({
@@ -6963,6 +6957,21 @@ const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
6963
6957
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxRuntime.jsxs(uilibGl.Flex, { justifyContent: center ? "center" : "flex-start", children: [jsxRuntime.jsx(StatusWaitingButton, { title: title || t("run", { ns: "dashboard", defaultValue: "Запуск" }), icon: icon, status: status, statusColors: statusColors, isWaiting: loading || !!taskId, isDisabled: !relatedResources?.length, onClick: onClick }), !!(log || taskId) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(uilibGl.IconButton, { kind: "info", onClick: openLog }), jsxRuntime.jsx(LogDialog, { logs: log, status: status, statusColors: statusColors, isOpen: isLogDialogOpen, onClose: closeLog })] }))] })] }));
6964
6958
  });
6965
6959
 
6960
+ const EditContainer = ({ type, elementConfig, renderElement }) => {
6961
+ const { id, style } = elementConfig || {};
6962
+ return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ExpandableTitle, { elementConfig: elementConfig, type: type, renderElement: renderElement }), jsxRuntime.jsxs(Container, { id: id, isColumn: true, style: style, children: [jsxRuntime.jsx(ContainerAlias, { hasBottomMargin: true, children: renderElement({ id: "alias" }) }), jsxRuntime.jsx(ContainerValue, { children: renderElement({ id: "value" }) })] })] }));
6963
+ };
6964
+
6965
+ const ContainerDivider = styled(uilibGl.Divider) `
6966
+ width: 100%;
6967
+ border-color: ${({ theme: { palette }, $bgColor }) => $bgColor || palette.elementDeep};
6968
+ `;
6969
+
6970
+ const DividerContainer = React.memo(({ elementConfig, config }) => {
6971
+ const { id, style } = elementConfig || {};
6972
+ return (jsxRuntime.jsx(Container, { id: id, style: style, children: jsxRuntime.jsx(ContainerDivider, { "$bgColor": config?.options?.bgColor }) }));
6973
+ });
6974
+
6966
6975
  const containerComponents = {
6967
6976
  [exports.ContainerTemplate.DefaultAttributes]: DefaultAttributesContainer,
6968
6977
  [exports.ContainerTemplate.Pages]: PagesContainer,
@@ -6986,6 +6995,7 @@ const containerComponents = {
6986
6995
  [exports.ContainerTemplate.ExportPdf]: ExportPdfContainer,
6987
6996
  [exports.ContainerTemplate.Upload]: UploadContainer,
6988
6997
  [exports.ContainerTemplate.Task]: TaskContainer,
6998
+ [exports.ContainerTemplate.Edit]: EditContainer,
6989
6999
  default: ContainersGroupContainer,
6990
7000
  };
6991
7001
 
@@ -7759,6 +7769,35 @@ const ElementChips = React.memo(({ type, elementConfig }) => {
7759
7769
  return (jsxRuntime.jsx(DashboardChipsContainer, { style: style, children: tags?.map(tag => (jsxRuntime.jsx(DashboardChip$1, { text: tag, "$bgColor": colorAttr?.value || bgColor, "$fontColor": fontColor, "$fontSize": fontSize, "$isDefault": !colorAttr?.value }, tag))) }));
7760
7770
  });
7761
7771
 
7772
+ const ElementControl = ({ elementConfig }) => {
7773
+ const { t } = useGlobalContext();
7774
+ const { dataSources, filters, changeFilters } = useWidgetContext(exports.WidgetType.FeatureCard);
7775
+ const [value, setValue] = React.useState();
7776
+ const { options, attributeName } = elementConfig || {};
7777
+ const { filterName, relatedDataSource, label, placeholder = t("selectValue", { ns: "dashboard", defaultValue: "Выберите значение" }) } = options || {};
7778
+ const dataSource = React.useMemo(() => getDataSource(relatedDataSource, dataSources), [relatedDataSource, dataSources]);
7779
+ const items = React.useMemo(() => {
7780
+ if (!dataSource?.features?.length || !attributeName) {
7781
+ return [];
7782
+ }
7783
+ return dataSource.features.map(({ attributes }) => ({
7784
+ value: attributes?.[attributeName] || "",
7785
+ text: attributes?.[attributeName] || "",
7786
+ }));
7787
+ }, [dataSource?.features, attributeName]);
7788
+ const handleChange = React.useCallback(([option]) => {
7789
+ setValue(option?.value);
7790
+ if (filterName) {
7791
+ changeFilters?.({
7792
+ [filterName]: {
7793
+ value: option?.value,
7794
+ },
7795
+ });
7796
+ }
7797
+ }, [changeFilters, filterName]);
7798
+ return (jsxRuntime.jsx(uilibGl.Dropdown, { zIndex: 1000, width: "100%", label: label, options: items, value: filters?.[filterName]?.value ?? value, placeholder: placeholder, onChange: handleChange }));
7799
+ };
7800
+
7762
7801
  const StyledIconFontSizeMixin = styled.css `
7763
7802
  height: ${({ fontSize }) => `${fontSize}px`};
7764
7803
 
@@ -8398,6 +8437,7 @@ const ElementUploader = React.memo(({ elementConfig, type }) => {
8398
8437
  });
8399
8438
 
8400
8439
  const elementComponents = {
8440
+ control: ElementControl,
8401
8441
  image: ElementImage,
8402
8442
  slideshow: ElementSlideshow,
8403
8443
  svg: ElementSvg,
@@ -9578,11 +9618,16 @@ const tooltipValueFromRelatedFeatures = (t, value, relatedAttributes, layerInfo)
9578
9618
  };
9579
9619
 
9580
9620
  const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9581
- const { config: configProp, containerIds, projectInfo, layerInfo } = useWidgetContext(type);
9621
+ const { config: configProp, containerIds, projectInfo, layerInfo, isEditing } = useWidgetContext(type);
9582
9622
  const config = React.useMemo(() => {
9583
9623
  if (configProp) {
9584
9624
  return configProp;
9585
9625
  }
9626
+ if (isEditing) {
9627
+ return type === exports.WidgetType.Dashboard
9628
+ ? (projectInfo?.content?.editConfiguration || {})
9629
+ : (layerInfo?.configuration?.editConfiguration || {});
9630
+ }
9586
9631
  const currentConfig = type === exports.WidgetType.Dashboard
9587
9632
  ? (projectInfo?.content?.dashboardConfiguration || {})
9588
9633
  : (layerInfo?.configuration?.cardConfiguration || {});
@@ -9598,7 +9643,7 @@ const useWidgetConfig = (type = exports.WidgetType.Dashboard) => {
9598
9643
  return newConfig;
9599
9644
  }
9600
9645
  return currentConfig;
9601
- }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type]);
9646
+ }, [configProp, containerIds, layerInfo?.configuration?.cardConfiguration, projectInfo?.content?.dashboardConfiguration, type, isEditing]);
9602
9647
  const pages = React.useMemo(() => (getPagesFromConfig(config) || []), [config]);
9603
9648
  return {
9604
9649
  config,
@@ -10338,20 +10383,17 @@ const Chart = React.memo(({ config, element, elementConfig, type, renderElement
10338
10383
  return (jsxRuntime.jsxs(Tooltip, { children: [jsxRuntime.jsx(ChartTooltipLabel, { children: labels[indexX] }), items
10339
10384
  .filter(({ value }) => !isEmptyValue(value))
10340
10385
  ?.map(({ layerName, attributeName, attributeUnits, dataSourceName, value, stroke }, index) => {
10341
- const layerInfo = !attributeUnits
10342
- ? layerInfos?.find(({ name }) => name === layerName)
10343
- : null;
10344
- const attribute = !attributeUnits
10345
- ? layerInfo?.layerDefinition.attributes[attributeName]
10346
- : null;
10347
- const dataSource = dataSourceName ? getDataSource(dataSourceName, dataSources) : null;
10348
- const dataSourceUnits = !dataSource || !attributeUnits
10349
- ? null
10350
- : dataSource.features?.[0]?.attributes?.[attributeUnits];
10351
- const legendValue = attribute
10352
- ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat })
10353
- : [value, dataSourceUnits].filter(Boolean).join(" ");
10354
- return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: legendValue })] }, index));
10386
+ const layerInfo = layerInfos?.find(({ name }) => name === layerName);
10387
+ const attribute = layerInfo?.layerDefinition.attributes[attributeName];
10388
+ const dataSource = getDataSource(dataSourceName, dataSources);
10389
+ const units = attributeUnits
10390
+ ? dataSource?.features?.[0]?.attributes?.[attributeUnits]
10391
+ : attribute?.stringFormat?.unitsLabel;
10392
+ const formatValue = attribute
10393
+ ? formatAttributeValue({ t, type: attribute.type, value, stringFormat: attribute.stringFormat, noUnits: true })
10394
+ : value;
10395
+ const resultValue = [formatValue, units].filter(Boolean).join(" ");
10396
+ return (jsxRuntime.jsxs(ChartTooltipRow, { children: [jsxRuntime.jsx(ChartLegendColor$1, { "$color": stroke }), jsxRuntime.jsx(ChartLegendValue, { children: resultValue })] }, index));
10355
10397
  })] }));
10356
10398
  }, [labels, layerInfos, dataSources, dotSnapping]);
10357
10399
  const markers = React.useMemo(() => getChartMarkers(data[0]?.items, configMarkers, dataSources), [data, dataSources, configMarkers]);
@@ -10497,7 +10539,7 @@ const DashboardLoading = React.memo(() => {
10497
10539
  return (jsxRuntime.jsx(Container, { noBorders: true, children: jsxRuntime.jsx(ContainerWrapper, { "$noMargin": true, children: jsxRuntime.jsx(DashboardWrapper, { children: jsxRuntime.jsx(DashboardPlaceholderWrap, { children: jsxRuntime.jsxs(DashboardPlaceholder, { isLoading: true, children: [jsxRuntime.jsx(uilibGl.Icon, { kind: "dashboard_loading" }), jsxRuntime.jsx(uilibGl.Flex, { width: "8rem", children: jsxRuntime.jsx(uilibGl.LinearProgress, {}) })] }) }) }) }) }));
10498
10540
  });
10499
10541
 
10500
- const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, config, noBorders }) => {
10542
+ const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, noBorders }) => {
10501
10543
  const { dataSources, isLoading } = useWidgetContext(type);
10502
10544
  const { currentPage } = useWidgetPage(type);
10503
10545
  const isDiffPage = useDiffPage(type);
@@ -10505,7 +10547,7 @@ const Dashboard = React.memo(({ type = exports.WidgetType.Dashboard, config, noB
10505
10547
  if (dataSourceLoading || isDiffPage) {
10506
10548
  return (jsxRuntime.jsx(DashboardLoading, {}));
10507
10549
  }
10508
- return (jsxRuntime.jsx(PagesContainer, { type: type, config: config, noBorders: noBorders }));
10550
+ return (jsxRuntime.jsx(PagesContainer, { type: type, noBorders: noBorders }));
10509
10551
  });
10510
10552
 
10511
10553
  const CardCheckbox = styled(uilibGl.Checkbox) `
@@ -11153,6 +11195,7 @@ exports.ElementButton = ElementButton;
11153
11195
  exports.ElementCamera = ElementCamera;
11154
11196
  exports.ElementChart = ElementChart;
11155
11197
  exports.ElementChips = ElementChips;
11198
+ exports.ElementControl = ElementControl;
11156
11199
  exports.ElementIcon = ElementIcon;
11157
11200
  exports.ElementImage = ElementImage;
11158
11201
  exports.ElementLegend = ElementLegend;