@evergis/react 3.1.74 → 3.1.75

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.
@@ -0,0 +1,9 @@
1
+ import { FC, CSSProperties } from 'react';
2
+ import { ITerminalInitOnlyOptions, ITerminalOptions } from '@xterm/xterm';
3
+ export interface TaskLogTerminalProps {
4
+ log?: string | Record<string, any>;
5
+ className?: string;
6
+ styles?: CSSProperties;
7
+ terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;
8
+ }
9
+ export declare const LogTerminal: FC<TaskLogTerminalProps>;
@@ -0,0 +1 @@
1
+ export declare const TerminalWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -13,6 +13,7 @@ export * from './FeatureCardHeader';
13
13
  export * from './FeatureCardTitle';
14
14
  export * from './HiddenTitleItems';
15
15
  export * from './Loading';
16
+ export * from './LogTerminal';
16
17
  export * from './Pagination';
17
18
  export * from './Pagination/styled';
18
19
  export * from './StackBar';
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');
28
27
  var xterm = require('@xterm/xterm');
29
28
  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);
@@ -5695,8 +5695,8 @@ const TwoColumnContainer = React.memo(({ config, elementConfig, type, renderElem
5695
5695
  const icon = children?.[iconIndex];
5696
5696
  const hasIcon = !!icon;
5697
5697
  const elementChildren = elementConfig?.children?.map(child => ({
5698
- ...child,
5699
5698
  type: "attributeValue",
5699
+ ...child,
5700
5700
  attributeName: attribute,
5701
5701
  options: { noUnits: hasUnits, ...child.options },
5702
5702
  }));
@@ -6848,121 +6848,6 @@ const StatusBadge = styled(uilibGl.Chip) `
6848
6848
  color: ${({ theme }) => theme.palette.iconContrast};
6849
6849
  `;
6850
6850
 
6851
- const TerminalWrapper = styled.div `
6852
- flex: 1;
6853
- overflow: hidden;
6854
- padding: 0;
6855
- margin: 0;
6856
- box-sizing: border-box;
6857
- min-height: 0;
6858
-
6859
- .xterm-viewport {
6860
- overflow-y: auto;
6861
- }
6862
-
6863
- .xterm-screen .xterm-rows span {
6864
- letter-spacing: 0 !important;
6865
- }
6866
- `;
6867
-
6868
- const LogTerminal = ({ log }) => {
6869
- const terminalRef = React.useRef(null);
6870
- const xtermRef = React.useRef(null);
6871
- const fitAddonRef = React.useRef(null);
6872
- const previousLogRef = React.useRef("");
6873
- const theme = styled.useTheme();
6874
- React.useEffect(() => {
6875
- if (!terminalRef.current)
6876
- return;
6877
- // Create terminal instance
6878
- const terminal = new xterm.Terminal({
6879
- cursorBlink: false,
6880
- fontSize: 12,
6881
- fontFamily: '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace',
6882
- scrollback: 10000,
6883
- convertEol: true,
6884
- lineHeight: 1.5,
6885
- theme: {
6886
- background: theme.palette.background,
6887
- foreground: theme.palette.textPrimary,
6888
- cursor: theme.palette.primary,
6889
- },
6890
- });
6891
- // Create fit addon
6892
- const fitAddon = new addonFit.FitAddon();
6893
- terminal.loadAddon(fitAddon);
6894
- // Open terminal
6895
- terminal.open(terminalRef.current);
6896
- fitAddon.fit();
6897
- // Store refs
6898
- xtermRef.current = terminal;
6899
- fitAddonRef.current = fitAddon;
6900
- // Handle window resize
6901
- const handleResize = () => {
6902
- fitAddon.fit();
6903
- };
6904
- window.addEventListener("resize", handleResize);
6905
- // Cleanup
6906
- return () => {
6907
- window.removeEventListener("resize", handleResize);
6908
- terminal.dispose();
6909
- xtermRef.current = null;
6910
- fitAddonRef.current = null;
6911
- };
6912
- }, [theme]);
6913
- // Update log content
6914
- React.useEffect(() => {
6915
- if (!xtermRef.current)
6916
- return;
6917
- // Handle different log types
6918
- if (typeof log === "string") {
6919
- // For string logs, only write the new content (append mode)
6920
- const previousLog = previousLogRef.current;
6921
- if (log !== previousLog) {
6922
- if (log.startsWith(previousLog)) {
6923
- // Log is accumulated - write only the new part
6924
- const newContent = log.substring(previousLog.length);
6925
- xtermRef.current.write(newContent);
6926
- }
6927
- else {
6928
- // Log was replaced completely - clear and write all
6929
- xtermRef.current.clear();
6930
- xtermRef.current.write(log);
6931
- }
6932
- previousLogRef.current = log;
6933
- }
6934
- }
6935
- else if (typeof log === "object") {
6936
- // JSON object (results) - always replace
6937
- xtermRef.current.clear();
6938
- const formatted = JSON.stringify(log, null, 2);
6939
- xtermRef.current.write(formatted);
6940
- previousLogRef.current = "";
6941
- }
6942
- else if (!log) {
6943
- // No log - clear terminal
6944
- xtermRef.current.clear();
6945
- previousLogRef.current = "";
6946
- }
6947
- // Scroll to bottom
6948
- xtermRef.current.scrollToBottom();
6949
- }, [log]);
6950
- React.useEffect(() => {
6951
- if (!fitAddonRef.current)
6952
- return;
6953
- const resizeObserver = new ResizeObserver(() => {
6954
- fitAddonRef.current?.fit();
6955
- });
6956
- if (terminalRef.current) {
6957
- resizeObserver.observe(terminalRef.current);
6958
- }
6959
- return () => {
6960
- resizeObserver.disconnect();
6961
- };
6962
- }, []);
6963
- return jsxRuntime.jsx(TerminalWrapper, { ref: terminalRef });
6964
- };
6965
-
6966
6851
  const STATUS_TRANSLATION_KEYS = {
6967
6852
  [api.RemoteTaskStatus.Process]: "taskProcess",
6968
6853
  [api.RemoteTaskStatus.Completed]: "taskCompleted",
@@ -7432,7 +7317,7 @@ const FeatureCardGradientHeader = ({ isRow }) => {
7432
7317
  };
7433
7318
 
7434
7319
  const HeaderFontColorMixin = styled.css `
7435
- ${HeaderTitleContainer}, ${LayerDescription} {
7320
+ ${HeaderTitleContainer}, ${HeaderTitleContainer} *, ${LayerDescription} {
7436
7321
  color: ${({ $fontColor }) => $fontColor};
7437
7322
  }
7438
7323
  `;
@@ -7981,8 +7866,13 @@ const LocalLinkButton = styled(uilibGl.IconButton).attrs(() => ({
7981
7866
  width: 1rem;
7982
7867
  height: 1rem;
7983
7868
  background-color: ${({ theme: { palette } }) => palette.primary};
7869
+ padding: 0;
7984
7870
  border-radius: 50%;
7985
7871
 
7872
+ :hover {
7873
+ background-color: ${({ theme: { palette } }) => palette.primary};
7874
+ }
7875
+
7986
7876
  span[kind] {
7987
7877
  display: flex;
7988
7878
  justify-content: center;
@@ -8012,8 +7902,8 @@ const LocalLink = React.memo(({ link }) => {
8012
7902
  const ElementLink = React.memo(({ type, elementConfig }) => {
8013
7903
  const { attributes } = useWidgetContext(type);
8014
7904
  const attribute = getAttributeByName(elementConfig?.attributeName, attributes);
8015
- const link = attribute?.value;
8016
- if (!link || typeof link !== "string")
7905
+ const link = getResourceUrl(attribute?.value?.toString());
7906
+ if (!link)
8017
7907
  return null;
8018
7908
  return link.startsWith("http") ? jsxRuntime.jsx(ExternalLink, { onClick: () => window.open(link) }) : jsxRuntime.jsx(LocalLink, { link: link });
8019
7909
  });
@@ -10794,6 +10684,122 @@ const HiddenTitleItems = React.memo(({ elementConfig, config, type, filter }) =>
10794
10684
  getConfigFilter(filterName, configFilters)?.defaultValue, index)) }));
10795
10685
  });
10796
10686
 
10687
+ const TerminalWrapper = styled.div `
10688
+ flex: 1;
10689
+ overflow: hidden;
10690
+ padding: 0;
10691
+ margin: 0;
10692
+ box-sizing: border-box;
10693
+ min-height: 0;
10694
+
10695
+ .xterm-viewport {
10696
+ overflow-y: auto;
10697
+ }
10698
+
10699
+ .xterm-screen .xterm-rows span {
10700
+ letter-spacing: 0 !important;
10701
+ }
10702
+ `;
10703
+
10704
+ const LogTerminal = ({ log, terminalOptions, className, styles }) => {
10705
+ const terminalRef = React.useRef(null);
10706
+ const xtermRef = React.useRef(null);
10707
+ const fitAddonRef = React.useRef(null);
10708
+ const previousLogRef = React.useRef("");
10709
+ const theme = styled.useTheme();
10710
+ React.useEffect(() => {
10711
+ if (!terminalRef.current)
10712
+ return;
10713
+ // Create terminal instance
10714
+ const terminal = new xterm.Terminal({
10715
+ cursorBlink: false,
10716
+ fontSize: 12,
10717
+ fontFamily: '"Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace',
10718
+ scrollback: 10000,
10719
+ convertEol: true,
10720
+ lineHeight: 1.5,
10721
+ theme: {
10722
+ background: theme.palette.background,
10723
+ foreground: theme.palette.textPrimary,
10724
+ cursor: theme.palette.primary,
10725
+ },
10726
+ ...terminalOptions,
10727
+ });
10728
+ // Create fit addon
10729
+ const fitAddon = new addonFit.FitAddon();
10730
+ terminal.loadAddon(fitAddon);
10731
+ // Open terminal
10732
+ terminal.open(terminalRef.current);
10733
+ fitAddon.fit();
10734
+ // Store refs
10735
+ xtermRef.current = terminal;
10736
+ fitAddonRef.current = fitAddon;
10737
+ // Handle window resize
10738
+ const handleResize = () => {
10739
+ fitAddon.fit();
10740
+ };
10741
+ window.addEventListener("resize", handleResize);
10742
+ // Cleanup
10743
+ return () => {
10744
+ window.removeEventListener("resize", handleResize);
10745
+ terminal.dispose();
10746
+ xtermRef.current = null;
10747
+ fitAddonRef.current = null;
10748
+ };
10749
+ }, [theme, terminalOptions]);
10750
+ // Update log content
10751
+ React.useEffect(() => {
10752
+ if (!xtermRef.current)
10753
+ return;
10754
+ // Handle different log types
10755
+ if (typeof log === "string") {
10756
+ // For string logs, only write the new content (append mode)
10757
+ const previousLog = previousLogRef.current;
10758
+ if (log !== previousLog) {
10759
+ if (log.startsWith(previousLog)) {
10760
+ // Log is accumulated - write only the new part
10761
+ const newContent = log.substring(previousLog.length);
10762
+ xtermRef.current.write(newContent);
10763
+ }
10764
+ else {
10765
+ // Log was replaced completely - clear and write all
10766
+ xtermRef.current.clear();
10767
+ xtermRef.current.write(log);
10768
+ }
10769
+ previousLogRef.current = log;
10770
+ }
10771
+ }
10772
+ else if (typeof log === "object") {
10773
+ // JSON object (results) - always replace
10774
+ xtermRef.current.clear();
10775
+ const formatted = JSON.stringify(log, null, 2);
10776
+ xtermRef.current.write(formatted);
10777
+ previousLogRef.current = "";
10778
+ }
10779
+ else if (!log) {
10780
+ // No log - clear terminal
10781
+ xtermRef.current.clear();
10782
+ previousLogRef.current = "";
10783
+ }
10784
+ // Scroll to bottom
10785
+ xtermRef.current.scrollToBottom();
10786
+ }, [log]);
10787
+ React.useEffect(() => {
10788
+ if (!fitAddonRef.current)
10789
+ return;
10790
+ const resizeObserver = new ResizeObserver(() => {
10791
+ fitAddonRef.current?.fit();
10792
+ });
10793
+ if (terminalRef.current) {
10794
+ resizeObserver.observe(terminalRef.current);
10795
+ }
10796
+ return () => {
10797
+ resizeObserver.disconnect();
10798
+ };
10799
+ }, []);
10800
+ return jsxRuntime.jsx(TerminalWrapper, { ref: terminalRef, className: className, style: styles });
10801
+ };
10802
+
10797
10803
  const PageNavigator = styled(uilibGl.Flex) `
10798
10804
  margin-right: -0.5rem;
10799
10805
  align-items: center;
@@ -11217,6 +11223,7 @@ exports.LayerTree = LayerTree;
11217
11223
  exports.LayersContainer = LayersContainer;
11218
11224
  exports.LayersListWrapper = LayersListWrapper;
11219
11225
  exports.LinearProgressContainer = LinearProgressContainer;
11226
+ exports.LogTerminal = LogTerminal;
11220
11227
  exports.LogoContainer = LogoContainer;
11221
11228
  exports.MAX_CHART_WIDTH = MAX_CHART_WIDTH;
11222
11229
  exports.Map = Map$1;