@evergis/react 3.1.71 → 3.1.73

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,7 @@
1
1
  import { RemoteTaskStatus } from '@evergis/api';
2
+ import { ThemeName } from '../../../../../../types';
2
3
  export declare const StyledButton: import('styled-components').StyledComponent<"button", any, import('@evergis/uilib-gl').IButtonProps & {
3
4
  status?: RemoteTaskStatus;
4
5
  statusColors?: Record<RemoteTaskStatus, string>;
6
+ themeName?: ThemeName;
5
7
  }, never>;
@@ -5,6 +5,6 @@ export declare const useDashboardHeader: () => {
5
5
  title: import('react').ReactNode;
6
6
  tooltip: import("react/jsx-runtime").JSX.Element;
7
7
  description: import('react').ReactNode;
8
- themeName: string;
8
+ themeName: import('../../..').ThemeName;
9
9
  renderElement: import('..').RenderElementFunction;
10
10
  };
@@ -2,7 +2,7 @@ import { i18n } from 'i18next';
2
2
  export declare const useGlobalContext: () => {
3
3
  t: i18n["t"];
4
4
  language: string;
5
- themeName: string;
5
+ themeName: import('../../..').ThemeName;
6
6
  api: import('@evergis/api').Api;
7
7
  ewktGeometry: string;
8
8
  };
@@ -1,10 +1,11 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { i18n } from 'i18next';
3
3
  import { Api } from '@evergis/api';
4
+ import { ThemeName } from '../../types';
4
5
  export type GlobalContextProps = PropsWithChildren<{
5
6
  t?: i18n["t"];
6
7
  language?: string;
7
8
  ewktGeometry?: string;
8
- themeName?: string;
9
+ themeName?: ThemeName;
9
10
  api?: Api;
10
11
  }>;
package/dist/index.js CHANGED
@@ -24,9 +24,9 @@ require('mapbox-gl/dist/mapbox-gl.css');
24
24
  var react = require('swiper/react');
25
25
  var ReactMarkdown = require('react-markdown');
26
26
  var remarkGfm = require('remark-gfm');
27
+ require('@xterm/xterm/css/xterm.css');
27
28
  var xterm = require('@xterm/xterm');
28
29
  var addonFit = require('@xterm/addon-fit');
29
- require('@xterm/xterm/css/xterm.css');
30
30
 
31
31
  const AddFeatureButton = ({ title, icon = "feature_add" /* , layerName, geometryType*/ }) => {
32
32
  // const [, handleAddFeature] = useFeatureCreator(layerName, geometryType);
@@ -3523,6 +3523,85 @@ const getGradientColors = (colorsCount) => {
3523
3523
  .getColors()
3524
3524
  .slice(0, colorsCount === undefined || colorsCount < GRADIENT_COLORS.length ? GRADIENT_COLORS.length : colorsCount);
3525
3525
  };
3526
+ /**
3527
+ * Converts HSL hue value to RGB
3528
+ * @param p - lower bound
3529
+ * @param q - upper bound
3530
+ * @param t - hue value
3531
+ * @returns RGB component value (0-1)
3532
+ */
3533
+ const hue2rgb = (p, q, t) => {
3534
+ if (t < 0)
3535
+ t += 1;
3536
+ if (t > 1)
3537
+ t -= 1;
3538
+ if (t < 1 / 6)
3539
+ return p + (q - p) * 6 * t;
3540
+ if (t < 1 / 2)
3541
+ return q;
3542
+ if (t < 2 / 3)
3543
+ return p + (q - p) * (2 / 3 - t) * 6;
3544
+ return p;
3545
+ };
3546
+ /**
3547
+ * Converts RGB component (0-1) to hex string
3548
+ * @param value - RGB component value (0-1)
3549
+ * @returns hex string (00-ff)
3550
+ */
3551
+ const toHex = (value) => {
3552
+ const hex = Math.round(value * 255).toString(16);
3553
+ return hex.padStart(2, '0');
3554
+ };
3555
+ /**
3556
+ * Adjusts color brightness
3557
+ * @param color - hex color string (e.g., "#2196f3")
3558
+ * @param lightnessAdjustment - lightness adjustment in HSL units (e.g., 5 or -5)
3559
+ * @returns adjusted color in hex format
3560
+ */
3561
+ const adjustColor = (color, lightnessAdjustment = 5) => {
3562
+ // Convert hex to RGB
3563
+ const hex = color.replace('#', '');
3564
+ const r = parseInt(hex.substring(0, 2), 16) / 255;
3565
+ const g = parseInt(hex.substring(2, 4), 16) / 255;
3566
+ const b = parseInt(hex.substring(4, 6), 16) / 255;
3567
+ // Convert RGB to HSL
3568
+ const max = Math.max(r, g, b);
3569
+ const min = Math.min(r, g, b);
3570
+ let h = 0;
3571
+ let s = 0;
3572
+ const l = (max + min) / 2;
3573
+ if (max !== min) {
3574
+ const d = max - min;
3575
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
3576
+ switch (max) {
3577
+ case r:
3578
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
3579
+ break;
3580
+ case g:
3581
+ h = ((b - r) / d + 2) / 6;
3582
+ break;
3583
+ case b:
3584
+ h = ((r - g) / d + 4) / 6;
3585
+ break;
3586
+ }
3587
+ }
3588
+ const adjustedL = Math.max(0, Math.min(100, (l * 100) + lightnessAdjustment)) / 100;
3589
+ // Convert HSL back to RGB
3590
+ let rNew;
3591
+ let gNew;
3592
+ let bNew;
3593
+ if (s === 0) {
3594
+ rNew = gNew = bNew = adjustedL;
3595
+ }
3596
+ else {
3597
+ const q = adjustedL < 0.5 ? adjustedL * (1 + s) : adjustedL + s - adjustedL * s;
3598
+ const p = 2 * adjustedL - q;
3599
+ rNew = hue2rgb(p, q, h + 1 / 3);
3600
+ gNew = hue2rgb(p, q, h);
3601
+ bNew = hue2rgb(p, q, h - 1 / 3);
3602
+ }
3603
+ return `#${toHex(rNew)}${toHex(gNew)}${toHex(bNew)}`;
3604
+ };
3526
3605
 
3527
3606
  const NO_CONTENT_VALUE = "—";
3528
3607
  exports.DateFormat = void 0;
@@ -6842,12 +6921,12 @@ const LogTerminal = ({ log }) => {
6842
6921
  if (log.startsWith(previousLog)) {
6843
6922
  // Log is accumulated - write only the new part
6844
6923
  const newContent = log.substring(previousLog.length);
6845
- xtermRef.current.write(`${newContent.replace(/\n/g, "\r\n")}\r\n`);
6924
+ xtermRef.current.write(newContent);
6846
6925
  }
6847
6926
  else {
6848
6927
  // Log was replaced completely - clear and write all
6849
6928
  xtermRef.current.clear();
6850
- xtermRef.current.write(`${log.replace(/\n/g, "\r\n")}\r\n`);
6929
+ xtermRef.current.write(log);
6851
6930
  }
6852
6931
  previousLogRef.current = log;
6853
6932
  }
@@ -6856,7 +6935,7 @@ const LogTerminal = ({ log }) => {
6856
6935
  // JSON object (results) - always replace
6857
6936
  xtermRef.current.clear();
6858
6937
  const formatted = JSON.stringify(log, null, 2);
6859
- xtermRef.current.write(formatted.replace(/\n/g, "\r\n"));
6938
+ xtermRef.current.write(formatted);
6860
6939
  previousLogRef.current = "";
6861
6940
  }
6862
6941
  else if (!log) {
@@ -6918,36 +6997,57 @@ const LogDialog = ({ isOpen, onClose, logs, status, statusColors }) => {
6918
6997
  const getStatusColor = React.useCallback((status) => {
6919
6998
  return statusColors?.[status] || STATUS_COLORS[status] || STATUS_COLORS[api.RemoteTaskStatus.Unknown];
6920
6999
  }, [statusColors]);
6921
- return (jsxRuntime.jsxs(uilibGl.Dialog, { isOpen: isOpen, onCloseRequest: onClose, modal: true, maxWidth: "800px", minWidth: "600px", minHeight: "600px", children: [jsxRuntime.jsx(uilibGl.DialogTitle, { children: jsxRuntime.jsxs(uilibGl.Flex, { justifyContent: "space-between", alignItems: "center", children: [jsxRuntime.jsxs(uilibGl.Flex, { alignItems: "center", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { marginRight: "1rem", children: t("taskLogs", { ns: "dashboard", defaultValue: "Логи выполнения задачи" }) }), jsxRuntime.jsx(StatusBadge, { text: getStatusTitle(status), bgColor: getStatusColor(status) })] }), jsxRuntime.jsx(uilibGl.IconButton, { kind: "close", onClick: onClose })] }) }), jsxRuntime.jsx(uilibGl.DialogContent, { children: jsxRuntime.jsx(uilibGl.Flex, { flexDirection: "column", height: "100%", marginBottom: "2rem", children: jsxRuntime.jsx(LogTerminal, { log: logs || t("taskLogsEmpty", { ns: "dashboard", defaultValue: "Логи отсутствуют" }) }) }) })] }));
7000
+ return (jsxRuntime.jsxs(uilibGl.Dialog, { isOpen: isOpen, onCloseRequest: onClose, modal: true, maxWidth: "800px", minWidth: "600px", minHeight: "600px", children: [jsxRuntime.jsx(uilibGl.DialogTitle, { children: jsxRuntime.jsxs(uilibGl.Flex, { justifyContent: "space-between", alignItems: "center", children: [jsxRuntime.jsxs(uilibGl.Flex, { alignItems: "center", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { marginRight: "1rem", children: t("taskLogs", { ns: "dashboard", defaultValue: "Логи выполнения задачи" }) }), jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: uilibGl.darkTheme, children: jsxRuntime.jsx(StatusBadge, { text: getStatusTitle(status), bgColor: getStatusColor(status) }) })] }), jsxRuntime.jsx(uilibGl.IconButton, { kind: "close", onClick: onClose })] }) }), jsxRuntime.jsx(uilibGl.DialogContent, { children: jsxRuntime.jsx(uilibGl.Flex, { flexDirection: "column", height: "100%", marginBottom: "2rem", children: jsxRuntime.jsx(LogTerminal, { log: logs || t("taskLogsEmpty", { ns: "dashboard", defaultValue: "Логи отсутствуют" }) }) }) })] }));
6922
7001
  };
6923
7002
 
7003
+ exports.ThemeName = void 0;
7004
+ (function (ThemeName) {
7005
+ ThemeName["Light"] = "light";
7006
+ ThemeName["Dark"] = "dark";
7007
+ })(exports.ThemeName || (exports.ThemeName = {}));
7008
+
7009
+ exports.TmsType = void 0;
7010
+ (function (TmsType) {
7011
+ TmsType["WMS"] = "WMS";
7012
+ TmsType["TMS"] = "TMS";
7013
+ TmsType["ArcGIS"] = "ArcGIS";
7014
+ })(exports.TmsType || (exports.TmsType = {}));
7015
+ exports.EditGeometryType = void 0;
7016
+ (function (EditGeometryType) {
7017
+ EditGeometryType["Raster"] = "raster";
7018
+ })(exports.EditGeometryType || (exports.EditGeometryType = {}));
7019
+
6924
7020
  const StyledButton = styled(uilibGl.FlatButton) `
6925
7021
  display: flex;
6926
7022
  align-items: center;
6927
-
6928
- ${({ status = api.RemoteTaskStatus.Unknown, statusColors }) => !!statusColors?.[status] && styled.css `
7023
+
7024
+ ${({ status = api.RemoteTaskStatus.Unknown, statusColors, themeName }) => !!statusColors?.[status] && styled.css `
6929
7025
  transition: background-color ${uilibGl.transition.toggle};
6930
7026
  background-color: ${statusColors[status]};
6931
-
7027
+
6932
7028
  :hover {
6933
- background-color: ${statusColors[status]};
7029
+ background-color: ${adjustColor(statusColors[status], themeName === exports.ThemeName.Dark ? -5 : 5)};
7030
+ }
7031
+
7032
+ :active {
7033
+ background-color: ${adjustColor(statusColors[status], themeName === exports.ThemeName.Dark ? -10 : 10)};
6934
7034
  }
6935
7035
  `}
6936
7036
  `;
6937
7037
 
6938
7038
  const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWaiting, isDisabled, onClick }) => {
6939
- const { t } = useGlobalContext();
7039
+ const { t, themeName } = useGlobalContext();
6940
7040
  const renderTitle = React.useMemo(() => status === api.RemoteTaskStatus.Process
6941
7041
  ? t("", { ns: "dashboard", defaultValue: "Остановить" })
6942
7042
  : status === api.RemoteTaskStatus.Unknown ? title : STATUS_TITLES[status], [status, t, title]);
6943
7043
  const renderIcon = React.useMemo(() => {
6944
- const iconComponent = isWaiting ? (jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1, theme: uilibGl.darkTheme }))
7044
+ const iconComponent = isWaiting ? (jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1, mono: true }))
6945
7045
  : status !== api.RemoteTaskStatus.Unknown
6946
7046
  ? jsxRuntime.jsx(uilibGl.Icon, { kind: STATUS_ICONS[status] })
6947
7047
  : jsxRuntime.jsx(uilibGl.Icon, { kind: icon });
6948
- return (jsxRuntime.jsx(uilibGl.FlexSpan, { marginRight: renderTitle ? "0.5rem" : 0, children: iconComponent }));
7048
+ return (jsxRuntime.jsx(uilibGl.Flex, { alignItems: "center", marginRight: renderTitle ? "0.5rem" : 0, children: iconComponent }));
6949
7049
  }, [icon, isWaiting, renderTitle, status]);
6950
- return (jsxRuntime.jsxs(StyledButton, { status: status, statusColors: statusColors, disabled: isDisabled, onClick: onClick, children: [renderIcon, renderTitle] }));
7050
+ return (jsxRuntime.jsx(uilibGl.ThemeProvider, { theme: uilibGl.darkTheme, children: jsxRuntime.jsxs(StyledButton, { status: status, statusColors: statusColors, disabled: isDisabled, themeName: themeName, onClick: onClick, children: [renderIcon, renderTitle] }) }));
6951
7051
  };
6952
7052
 
6953
7053
  const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
@@ -7102,27 +7202,10 @@ const PageTitle = styled(uilibGl.H2) `
7102
7202
  font-family: "Nunito Sans", serif;
7103
7203
  `;
7104
7204
 
7105
- exports.ThemeName = void 0;
7106
- (function (ThemeName) {
7107
- ThemeName["Light"] = "light";
7108
- ThemeName["Dark"] = "dark";
7109
- })(exports.ThemeName || (exports.ThemeName = {}));
7110
-
7111
- exports.TmsType = void 0;
7112
- (function (TmsType) {
7113
- TmsType["WMS"] = "WMS";
7114
- TmsType["TMS"] = "TMS";
7115
- TmsType["ArcGIS"] = "ArcGIS";
7116
- })(exports.TmsType || (exports.TmsType = {}));
7117
- exports.EditGeometryType = void 0;
7118
- (function (EditGeometryType) {
7119
- EditGeometryType["Raster"] = "raster";
7120
- })(exports.EditGeometryType || (exports.EditGeometryType = {}));
7121
-
7122
7205
  const DashboardDefaultHeader = React.memo(() => {
7123
7206
  const { components: { ProjectCatalogMenu, ProjectPanelMenu, ProjectPagesMenu }, } = useWidgetContext();
7124
7207
  const { pageId, image, icon, tooltip, themeName } = useDashboardHeader();
7125
- return (jsxRuntime.jsxs(DefaultHeaderContainer, { image: image, isDark: themeName === exports.ThemeName.Dark, children: [!pageId && jsxRuntime.jsx(uilibGl.LinearProgress, {}), jsxRuntime.jsxs(uilibGl.Flex, { column: true, gap: "1rem", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsxs(TopContainer, { children: [jsxRuntime.jsx(LogoContainer, { children: icon }), jsxRuntime.jsxs(TopContainerButtons, { children: [jsxRuntime.jsx(ProjectCatalogMenu, {}), jsxRuntime.jsx(ProjectPanelMenu, {})] })] }) }), jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsx(uilibGl.Flex, { column: true, gap: "0.25rem", children: jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsxs(uilibGl.Flex, { alignItems: "center", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { flexGrow: 1, children: jsxRuntime.jsx(uilibGl.Tooltip, { arrow: true, content: tooltip, children: ref => (jsxRuntime.jsx(PageTitle, { ref: ref, children: jsxRuntime.jsx(ProjectPagesMenu, {}) })) }) }), jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsx(Pagination, {}) })] }) }) }) })] })] }));
7208
+ return (jsxRuntime.jsxs(DefaultHeaderContainer, { image: getResourceUrl(image), isDark: themeName === exports.ThemeName.Dark, children: [!pageId && jsxRuntime.jsx(uilibGl.LinearProgress, {}), jsxRuntime.jsxs(uilibGl.Flex, { column: true, gap: "1rem", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsxs(TopContainer, { children: [jsxRuntime.jsx(LogoContainer, { children: icon }), jsxRuntime.jsxs(TopContainerButtons, { children: [jsxRuntime.jsx(ProjectCatalogMenu, {}), jsxRuntime.jsx(ProjectPanelMenu, {})] })] }) }), jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsx(uilibGl.Flex, { column: true, gap: "0.25rem", children: jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsxs(uilibGl.Flex, { alignItems: "center", children: [jsxRuntime.jsx(uilibGl.FlexSpan, { flexGrow: 1, children: jsxRuntime.jsx(uilibGl.Tooltip, { arrow: true, content: tooltip, children: ref => (jsxRuntime.jsx(PageTitle, { ref: ref, children: jsxRuntime.jsx(ProjectPagesMenu, {}) })) }) }), jsxRuntime.jsx(uilibGl.FlexSpan, { children: jsxRuntime.jsx(Pagination, {}) })] }) }) }) })] })] }));
7126
7209
  });
7127
7210
 
7128
7211
  const HeaderFrontView = styled(uilibGl.Flex) `
@@ -11170,6 +11253,7 @@ exports.TwoColumnContainer = TwoColumnContainer;
11170
11253
  exports.UploadContainer = UploadContainer;
11171
11254
  exports.addDataSource = addDataSource;
11172
11255
  exports.addDataSources = addDataSources;
11256
+ exports.adjustColor = adjustColor;
11173
11257
  exports.applyFiltersToCondition = applyFiltersToCondition;
11174
11258
  exports.applyQueryFilters = applyQueryFilters;
11175
11259
  exports.applyVarsToCondition = applyVarsToCondition;