@evergis/react 3.1.70 → 3.1.72

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;
@@ -6791,7 +6870,6 @@ const LogTerminal = ({ log }) => {
6791
6870
  const fitAddonRef = React.useRef(null);
6792
6871
  const previousLogRef = React.useRef("");
6793
6872
  const theme = styled.useTheme();
6794
- // Initialize terminal
6795
6873
  React.useEffect(() => {
6796
6874
  if (!terminalRef.current)
6797
6875
  return;
@@ -6799,11 +6877,10 @@ const LogTerminal = ({ log }) => {
6799
6877
  const terminal = new xterm.Terminal({
6800
6878
  cursorBlink: false,
6801
6879
  fontSize: 12,
6802
- fontFamily: '"Nunito Sans", sans-serif',
6880
+ fontFamily: '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace',
6803
6881
  scrollback: 10000,
6804
6882
  convertEol: true,
6805
6883
  lineHeight: 1.5,
6806
- letterSpacing: 0,
6807
6884
  theme: {
6808
6885
  background: theme.palette.background,
6809
6886
  foreground: theme.palette.textPrimary,
@@ -6844,12 +6921,12 @@ const LogTerminal = ({ log }) => {
6844
6921
  if (log.startsWith(previousLog)) {
6845
6922
  // Log is accumulated - write only the new part
6846
6923
  const newContent = log.substring(previousLog.length);
6847
- xtermRef.current.write(`${newContent.replace(/\n/g, "\r\n")}\r\n`);
6924
+ xtermRef.current.write(newContent);
6848
6925
  }
6849
6926
  else {
6850
6927
  // Log was replaced completely - clear and write all
6851
6928
  xtermRef.current.clear();
6852
- xtermRef.current.write(`${log.replace(/\n/g, "\r\n")}\r\n`);
6929
+ xtermRef.current.write(log);
6853
6930
  }
6854
6931
  previousLogRef.current = log;
6855
6932
  }
@@ -6858,7 +6935,7 @@ const LogTerminal = ({ log }) => {
6858
6935
  // JSON object (results) - always replace
6859
6936
  xtermRef.current.clear();
6860
6937
  const formatted = JSON.stringify(log, null, 2);
6861
- xtermRef.current.write(formatted.replace(/\n/g, "\r\n"));
6938
+ xtermRef.current.write(formatted);
6862
6939
  previousLogRef.current = "";
6863
6940
  }
6864
6941
  else if (!log) {
@@ -6869,7 +6946,6 @@ const LogTerminal = ({ log }) => {
6869
6946
  // Scroll to bottom
6870
6947
  xtermRef.current.scrollToBottom();
6871
6948
  }, [log]);
6872
- // Fit terminal on container resize
6873
6949
  React.useEffect(() => {
6874
6950
  if (!fitAddonRef.current)
6875
6951
  return;
@@ -6921,36 +6997,57 @@ const LogDialog = ({ isOpen, onClose, logs, status, statusColors }) => {
6921
6997
  const getStatusColor = React.useCallback((status) => {
6922
6998
  return statusColors?.[status] || STATUS_COLORS[status] || STATUS_COLORS[api.RemoteTaskStatus.Unknown];
6923
6999
  }, [statusColors]);
6924
- 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: "Логи отсутствуют" }) }) }) })] }));
6925
7001
  };
6926
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
+
6927
7020
  const StyledButton = styled(uilibGl.FlatButton) `
6928
7021
  display: flex;
6929
7022
  align-items: center;
6930
-
6931
- ${({ status = api.RemoteTaskStatus.Unknown, statusColors }) => !!statusColors?.[status] && styled.css `
7023
+
7024
+ ${({ status = api.RemoteTaskStatus.Unknown, statusColors, themeName }) => !!statusColors?.[status] && styled.css `
6932
7025
  transition: background-color ${uilibGl.transition.toggle};
6933
7026
  background-color: ${statusColors[status]};
6934
-
7027
+
6935
7028
  :hover {
6936
- 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)};
6937
7034
  }
6938
7035
  `}
6939
7036
  `;
6940
7037
 
6941
7038
  const StatusWaitingButton = ({ title, icon = "play", status, statusColors, isWaiting, isDisabled, onClick }) => {
6942
- const { t } = useGlobalContext();
7039
+ const { t, themeName } = useGlobalContext();
6943
7040
  const renderTitle = React.useMemo(() => status === api.RemoteTaskStatus.Process
6944
7041
  ? t("", { ns: "dashboard", defaultValue: "Остановить" })
6945
7042
  : status === api.RemoteTaskStatus.Unknown ? title : STATUS_TITLES[status], [status, t, title]);
6946
7043
  const renderIcon = React.useMemo(() => {
6947
- const iconComponent = isWaiting ? (jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1, theme: uilibGl.darkTheme }))
7044
+ const iconComponent = isWaiting ? (jsxRuntime.jsx(uilibGl.CircularProgress, { diameter: 1, mono: true }))
6948
7045
  : status !== api.RemoteTaskStatus.Unknown
6949
7046
  ? jsxRuntime.jsx(uilibGl.Icon, { kind: STATUS_ICONS[status] })
6950
7047
  : jsxRuntime.jsx(uilibGl.Icon, { kind: icon });
6951
- 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 }));
6952
7049
  }, [icon, isWaiting, renderTitle, status]);
6953
- 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] }) }));
6954
7051
  };
6955
7052
 
6956
7053
  const TaskContainer = React.memo(({ type, elementConfig, renderElement }) => {
@@ -7105,23 +7202,6 @@ const PageTitle = styled(uilibGl.H2) `
7105
7202
  font-family: "Nunito Sans", serif;
7106
7203
  `;
7107
7204
 
7108
- exports.ThemeName = void 0;
7109
- (function (ThemeName) {
7110
- ThemeName["Light"] = "light";
7111
- ThemeName["Dark"] = "dark";
7112
- })(exports.ThemeName || (exports.ThemeName = {}));
7113
-
7114
- exports.TmsType = void 0;
7115
- (function (TmsType) {
7116
- TmsType["WMS"] = "WMS";
7117
- TmsType["TMS"] = "TMS";
7118
- TmsType["ArcGIS"] = "ArcGIS";
7119
- })(exports.TmsType || (exports.TmsType = {}));
7120
- exports.EditGeometryType = void 0;
7121
- (function (EditGeometryType) {
7122
- EditGeometryType["Raster"] = "raster";
7123
- })(exports.EditGeometryType || (exports.EditGeometryType = {}));
7124
-
7125
7205
  const DashboardDefaultHeader = React.memo(() => {
7126
7206
  const { components: { ProjectCatalogMenu, ProjectPanelMenu, ProjectPagesMenu }, } = useWidgetContext();
7127
7207
  const { pageId, image, icon, tooltip, themeName } = useDashboardHeader();
@@ -11173,6 +11253,7 @@ exports.TwoColumnContainer = TwoColumnContainer;
11173
11253
  exports.UploadContainer = UploadContainer;
11174
11254
  exports.addDataSource = addDataSource;
11175
11255
  exports.addDataSources = addDataSources;
11256
+ exports.adjustColor = adjustColor;
11176
11257
  exports.applyFiltersToCondition = applyFiltersToCondition;
11177
11258
  exports.applyQueryFilters = applyQueryFilters;
11178
11259
  exports.applyVarsToCondition = applyVarsToCondition;