@topconsultnpm/sdkui-react-beta 6.6.87 → 6.6.89

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.
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { Colors, FontSize } from '../../utils/theme';
5
- import { IconDown, IconRight, SDKUI_Localizator, useWindowWidth } from '../../helper';
5
+ import { IconDown, IconRight, SDKUI_Localizator } from '../../helper';
6
+ import { DeviceType, useDeviceType } from './TMDeviceProvider';
6
7
  const StyledClosableContainer = styled.div `
7
8
  background-color: rgb(248,248,248);
8
9
  border-radius: 5px;
@@ -58,12 +59,13 @@ const StyledClosableItemsCount = styled.div `
58
59
  `;
59
60
  const TMClosableList = ({ dataSource, visibility = false, label, inline = false, hasPadding = true }) => {
60
61
  const [status, setStatus] = useState(visibility);
61
- let width = useWindowWidth();
62
+ // let width = useWindowWidth()
63
+ let devicrType = useDeviceType();
62
64
  const renderedItems = () => {
63
65
  return (dataSource.map((item, index) => (_jsx(StyledClosableItem, { children: item }, index))));
64
66
  };
65
- return (_jsxs(StyledClosableContainer, { "$isMobile": width < 1024, "$padding": hasPadding ? '5px' : '0', children: [_jsxs(StyledClosableContext, { children: [label && _jsxs(StyledClosableLabel, { "$isMobile": width < 640, "$inline": inline, children: [label, ":"] }), status ?
66
- _jsxs(StyledClosableItems, { "$isMobile": width < 640, "$inline": inline, children: [" ", renderedItems(), " "] }) :
67
- _jsxs(StyledClosableItems, { "$isMobile": width < 640, "$inline": inline, children: [" ", _jsxs(StyledClosableItem, { children: [" ", dataSource[0], " "] }), " "] })] }), dataSource.length > 1 && _jsxs(StyledClosabelIcon, { onClick: () => setStatus(!status), children: [!status && _jsxs(StyledClosableItemsCount, { children: [" (", _jsx("span", { children: "+" }), " ", dataSource.length - 1, " ", dataSource.length === 2 ? SDKUI_Localizator.OneMore : SDKUI_Localizator.More, ") "] }), !status ? _jsx(IconRight, { fontSize: 14 }) : _jsx(IconDown, { fontSize: 14 })] })] }));
67
+ return (_jsxs(StyledClosableContainer, { "$isMobile": devicrType === DeviceType.TABLET, "$padding": hasPadding ? '5px' : '0', children: [_jsxs(StyledClosableContext, { children: [label && _jsxs(StyledClosableLabel, { "$isMobile": devicrType === DeviceType.MOBILE, "$inline": inline, children: [label, ":"] }), status ?
68
+ _jsxs(StyledClosableItems, { "$isMobile": devicrType === DeviceType.MOBILE, "$inline": inline, children: [" ", renderedItems(), " "] }) :
69
+ _jsxs(StyledClosableItems, { "$isMobile": devicrType === DeviceType.MOBILE, "$inline": inline, children: [" ", _jsxs(StyledClosableItem, { children: [" ", dataSource[0], " "] }), " "] })] }), dataSource.length > 1 && _jsxs(StyledClosabelIcon, { onClick: () => setStatus(!status), children: [!status && _jsxs(StyledClosableItemsCount, { children: [" (", _jsx("span", { children: "+" }), " ", dataSource.length - 1, " ", dataSource.length === 2 ? SDKUI_Localizator.OneMore : SDKUI_Localizator.More, ") "] }), !status ? _jsx(IconRight, { fontSize: 14 }) : _jsx(IconDown, { fontSize: 14 })] })] }));
68
70
  };
69
71
  export default TMClosableList;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ declare enum DeviceType {
3
+ MOBILE = "mobile",
4
+ TABLET = "tablet",
5
+ DESKTOP = "desktop"
6
+ }
7
+ interface DeviceContextProps {
8
+ deviceType?: DeviceType;
9
+ }
10
+ declare const DeviceContext: React.Context<DeviceContextProps | undefined>;
11
+ declare const TMDeviceProvider: React.FC<{
12
+ children: React.ReactNode;
13
+ }>;
14
+ declare const useDeviceType: () => DeviceType | undefined;
15
+ export { DeviceContextProps, DeviceType, useDeviceType, TMDeviceProvider, DeviceContext };
@@ -0,0 +1,41 @@
1
+ import { jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState, createContext, useMemo, useContext } from 'react';
3
+ var DeviceType;
4
+ (function (DeviceType) {
5
+ DeviceType["MOBILE"] = "mobile";
6
+ DeviceType["TABLET"] = "tablet";
7
+ DeviceType["DESKTOP"] = "desktop";
8
+ })(DeviceType || (DeviceType = {}));
9
+ const DESKTOP_BREAKPOINT = 1024;
10
+ const TABLET_BREAKPOINT = 768;
11
+ const DeviceContext = createContext(undefined);
12
+ const TMDeviceProvider = ({ children }) => {
13
+ const [deviceType, setDeviceType] = useState(DeviceType.DESKTOP);
14
+ const updateDeviceType = () => {
15
+ const width = window.innerWidth;
16
+ if (width >= DESKTOP_BREAKPOINT) {
17
+ setDeviceType(DeviceType.DESKTOP);
18
+ }
19
+ else if (width >= TABLET_BREAKPOINT) {
20
+ setDeviceType(DeviceType.TABLET);
21
+ }
22
+ else {
23
+ setDeviceType(DeviceType.MOBILE);
24
+ }
25
+ };
26
+ useEffect(() => {
27
+ updateDeviceType();
28
+ window.addEventListener('resize', updateDeviceType);
29
+ return () => window.removeEventListener('resize', updateDeviceType);
30
+ }, []);
31
+ const contextValue = useMemo(() => ({ deviceType }), [deviceType]);
32
+ return (_jsxs(DeviceContext.Provider, { value: contextValue, children: [" ", children, " "] }));
33
+ };
34
+ const useDeviceType = () => {
35
+ const context = useContext(DeviceContext);
36
+ if (!context) {
37
+ throw new Error('DeviceProvider does not exsist');
38
+ }
39
+ return context.deviceType;
40
+ };
41
+ export { DeviceType, useDeviceType, TMDeviceProvider, DeviceContext };
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from 'react';
3
3
  import { Tooltip } from 'devextreme-react/cjs/tooltip';
4
- import { TABLET_WIDTH, genUniqueId, useWindowWidth } from '../../helper';
4
+ import { genUniqueId } from '../../helper';
5
+ import { DeviceType, useDeviceType } from './TMDeviceProvider';
5
6
  const TMTooltip = ({ children, position, content, hideAfterDelay }) => {
6
7
  const [showTooltip, setShowTooltip] = useState(false);
7
8
  const [id, setID] = useState('');
@@ -10,9 +11,10 @@ const TMTooltip = ({ children, position, content, hideAfterDelay }) => {
10
11
  window.addEventListener('click', () => setShowTooltip(false));
11
12
  return () => window.removeEventListener('click', () => setShowTooltip(false));
12
13
  }, []);
13
- const width = useWindowWidth();
14
- let isDesktop = width > TABLET_WIDTH;
15
- return (_jsxs("div", { children: [_jsx("div", { id: `idContainerTooltip${id}`, style: { display: 'flex', alignItems: 'center', height: 'max-content', width: 'max-content' }, onMouseEnter: () => { setShowTooltip(true); }, onMouseLeave: () => { setShowTooltip(false); }, onClick: () => { if (isDesktop || !hideAfterDelay)
14
+ // const width = useWindowWidth();
15
+ // let isDesktop = width > TABLET_WIDTH;
16
+ const deviceType = useDeviceType();
17
+ return (_jsxs("div", { children: [_jsx("div", { id: `idContainerTooltip${id}`, style: { display: 'flex', alignItems: 'center', height: 'max-content', width: 'max-content' }, onMouseEnter: () => { setShowTooltip(true); }, onMouseLeave: () => { setShowTooltip(false); }, onClick: () => { if (deviceType === DeviceType.DESKTOP || !hideAfterDelay)
16
18
  return; setTimeout(() => { setShowTooltip(false); }, 1500); }, children: children }), content &&
17
19
  _jsx(Tooltip, { target: `#idContainerTooltip${id}`, hideOnOutsideClick: true, visible: showTooltip, position: position ?? 'bottom', onHidden: () => setShowTooltip(false), children: content })] }));
18
20
  };
@@ -2,12 +2,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useState, useEffect, useRef } from 'react';
3
3
  import { StyledEditorButtonIcon, StyledEditorContainer, StyledEditorIcon, StyledEditorLabel, StyledTextareaEditor } from './TMEditorStyled';
4
4
  import { FontSize } from '../../utils/theme';
5
- import { useWindowWidth } from '../../helper';
6
5
  import TMContextMenu, { useContextMenu } from '../base/TMContextMenuOLD';
7
6
  import { TMExceptionBoxManager } from '../base/TMPopUp';
8
7
  import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
9
8
  import TMVilViewer from '../base/TMVilViewer';
10
9
  import TMTooltip from '../base/TMTooltip';
10
+ import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
11
11
  const TMTextArea = (props) => {
12
12
  const { label = '', value = '', width = '100%', height = 'auto', autoFocus = false, validationItems = [], disabled = false, isModifiedWhen = false, fontSize = FontSize.defaultFontSize, elementStyle = {}, icon = null, labelPosition = 'left', readOnly = false, onValueChanged, onBlur, placeHolder, formulaItems = [], buttons = [], maxHeight = 'auto' } = props;
13
13
  const inputRef = useRef(null);
@@ -15,7 +15,8 @@ const TMTextArea = (props) => {
15
15
  const [currentValue, setCurrentValue] = useState(value);
16
16
  const [formulaMenuItems, setFormulaMenuItems] = useState([]);
17
17
  const { clicked, setClicked, points, setPoints } = useContextMenu();
18
- let screenWidth = useWindowWidth();
18
+ // let screenWidth = useWindowWidth();
19
+ const deviceType = useDeviceType();
19
20
  useEffect(() => {
20
21
  setCurrentValue(value);
21
22
  }, [value]);
@@ -59,7 +60,7 @@ const TMTextArea = (props) => {
59
60
  const y = e.clientY - bounds.top;
60
61
  // set the x and y coordinates of our users right click
61
62
  setPoints({ x, y });
62
- }, "$isMobile": screenWidth < 640, "$maxHeight": maxHeight, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$width": width }), buttons.map((buttonItem, index) => {
63
+ }, "$isMobile": deviceType === DeviceType.MOBILE, "$maxHeight": maxHeight, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$width": width }), buttons.map((buttonItem, index) => {
63
64
  return (_jsx(StyledEditorButtonIcon, { onClick: buttonItem.onClick, "$index": index, "$transform": '-26px', children: _jsx(TMTooltip, { content: buttonItem.text, children: buttonItem.icon }) }, index));
64
65
  }), formulaItems.length > 0 && clicked && (_jsx(TMContextMenu, { menuData: formulaMenuItems, top: points.y, left: points.x, onMenuItemClick: (formula) => insertText(formula) })), _jsx(TMVilViewer, { vil: validationItems })] });
65
66
  };
@@ -3,13 +3,14 @@ import { useState, useEffect, useRef } from 'react';
3
3
  import styled from 'styled-components';
4
4
  import { StyledEditor, StyledEditorContainer, StyledEditorIcon, StyledEditorLabel, editorColorManager } from './TMEditorStyled';
5
5
  import { FontSize, TMColors } from '../../utils/theme';
6
- import { genUniqueId, IconClearButton, IconHide, IconShow, useWindowWidth } from '../../helper';
6
+ import { genUniqueId, IconClearButton, IconHide, IconShow } from '../../helper';
7
7
  import ShowAlert from '../base/TMAlert';
8
8
  import { TMExceptionBoxManager } from '../base/TMPopUp';
9
9
  import TMLayoutContainer, { TMLayoutItem } from '../base/TMLayout';
10
10
  import TMVilViewer from '../base/TMVilViewer';
11
11
  import TMTooltip from '../base/TMTooltip';
12
12
  import { ContextMenu } from 'devextreme-react';
13
+ import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
13
14
  const StyledShowPasswordIcon = styled.div `
14
15
  color: ${props => !props.$disabled ? (props.$vil.length === 0) ? !props.$isModified ? TMColors.text_normal : TMColors.isModified : editorColorManager(props.$vil) : TMColors.disabled};
15
16
  position: absolute;
@@ -38,7 +39,8 @@ const TMTextBox = ({ autoFocus, maxLength, labelColor, precision, scale, showCle
38
39
  const [formulaMenuItems, setFormulaMenuItems] = useState([]);
39
40
  const [isFocused, setIsFocused] = useState(false);
40
41
  const inputRef = useRef(null);
41
- let screenWidth = useWindowWidth();
42
+ // let screenWidth = useWindowWidth();
43
+ const deviceType = useDeviceType();
42
44
  const [id, setID] = useState('');
43
45
  useEffect(() => { setID(genUniqueId()); }, []);
44
46
  useEffect(() => { setCurrentType(type); setInitialType(type); }, [type]);
@@ -140,7 +142,7 @@ const TMTextBox = ({ autoFocus, maxLength, labelColor, precision, scale, showCle
140
142
  if (!scale && (e.key == "." || e.key == ","))
141
143
  e.preventDefault();
142
144
  }
143
- }, "$isMobile": screenWidth < 640, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$maxValue": maxValue, "$width": width, "$type": currentType, "$borderRadius": borderRadius }), initialType === 'password' && currentValue && _jsx(StyledShowPasswordIcon, { onClick: toggleShowPassword, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, children: showPasswordIcon() }), initialType !== 'password' &&
145
+ }, "$isMobile": deviceType === DeviceType.MOBILE, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, "$fontSize": fontSize, "$maxValue": maxValue, "$width": width, "$type": currentType, "$borderRadius": borderRadius }), initialType === 'password' && currentValue && _jsx(StyledShowPasswordIcon, { onClick: toggleShowPassword, "$disabled": disabled, "$vil": validationItems, "$isModified": isModifiedWhen, children: showPasswordIcon() }), initialType !== 'password' &&
144
146
  _jsxs("div", { style: { display: 'flex', flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', position: 'absolute', right: '6px', top: label.length > 0 ? '20px' : '7px', pointerEvents: disabled ? 'none' : 'auto', opacity: disabled ? 0.4 : 1 }, children: [showClearButton && currentValue &&
145
147
  _jsx(StyledTextBoxEditorButton, { onClick: () => {
146
148
  onValueChanged?.({ target: { value: undefined } });
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useState } from 'react';
3
3
  import { ResultTypes } from '@topconsultnpm/sdk-ts-beta';
4
4
  import { FormModes } from '../../ts/types';
5
- import { IconArrowDown, IconArrowLeft, IconArrowUp, IconCloseCircle, IconHide, IconSave, IconShow, IconUndo, IconWarning, MOBILE_WIDTH, SDKUI_Localizator, getColor, useWindowWidth } from '../../helper';
5
+ import { IconArrowDown, IconArrowLeft, IconArrowUp, IconCloseCircle, IconHide, IconSave, IconShow, IconUndo, IconWarning, SDKUI_Localizator, getColor } from '../../helper';
6
6
  import { ButtonNames, TMExceptionBoxManager, TMMessageBoxManager } from '../base/TMPopUp';
7
7
  import TMLayoutContainer, { TMCard, TMLayoutItem, TMSplitterLayout } from '../base/TMLayout';
8
8
  import { StyledResultTypeContainer, StyledToolbarForm } from '../base/Styled';
@@ -10,11 +10,13 @@ import TMButton from '../base/TMButton';
10
10
  import { TMColors } from '../../utils/theme';
11
11
  import TMValidationItemsList from '../grids/TMValidationItemsList';
12
12
  import TMModal from '../base/TMModal';
13
+ import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
13
14
  const TMSaveForm = ({ id, formMode = FormModes.Update, title, children, isModal, exception, customToolbarElements, hasNavigation, showBackButton, onClose, onSaveAsync, onNext, onPrev, canNext, canPrev, isModified, onShowList, validationItems = [], onUndo, onCancel, width, height }) => {
14
15
  const [showList, setShowList] = useState(true);
15
16
  const [showErrorGrid, setShowErrorGrid] = useState(false);
16
- let windowWidth = useWindowWidth();
17
- let isMobile = windowWidth <= MOBILE_WIDTH;
17
+ // let windowWidth = useWindowWidth()
18
+ // let isMobile: boolean = windowWidth <= MOBILE_WIDTH;
19
+ const deviceType = useDeviceType();
18
20
  const doSaveAsync = async () => { try {
19
21
  await onSaveAsync?.();
20
22
  }
@@ -66,7 +68,7 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, title, children, isModal,
66
68
  const doClose = () => {
67
69
  if (!isModified) {
68
70
  onClose?.();
69
- isMobile && setShowList(true), onShowList?.(true);
71
+ deviceType === DeviceType.MOBILE && setShowList(true), onShowList?.(true);
70
72
  return;
71
73
  }
72
74
  TMMessageBoxManager.show({
@@ -76,9 +78,9 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, title, children, isModal,
76
78
  if (e == ButtonNames.CANCEL)
77
79
  return;
78
80
  if (e == ButtonNames.NO)
79
- isMobile && (onUndo(), setShowList(true), onShowList?.(true));
81
+ deviceType === DeviceType.MOBILE && (onUndo(), setShowList(true), onShowList?.(true));
80
82
  if (e == ButtonNames.YES)
81
- isMobile ? (await onSaveAsync?.(), setShowList(true), onShowList?.(true)) : await onSaveAsync?.();
83
+ deviceType === DeviceType.MOBILE ? (await onSaveAsync?.(), setShowList(true), onShowList?.(true)) : await onSaveAsync?.();
82
84
  onClose?.();
83
85
  }
84
86
  catch (ex) {
@@ -93,8 +95,8 @@ const TMSaveForm = ({ id, formMode = FormModes.Update, title, children, isModal,
93
95
  return (_jsxs(TMLayoutContainer, { direction: 'vertical', children: [_jsx(TMLayoutItem, { height: 'max-content', children: _jsxs(StyledToolbarForm, { children: [showBackButton && _jsx(TMButton, { btnStyle: 'toolbar', color: 'tertiary', caption: SDKUI_Localizator.Back, icon: _jsx(IconArrowLeft, {}), elementStyle: { marginRight: '10px' }, onClick: () => { doClose(); } }), _jsx(TMButton, { caption: SDKUI_Localizator.Save, icon: _jsx(IconSave, {}), keyGesture: "alt+s", backgroundColor: errorsCount > 0 ? TMColors.error : isModified ? TMColors.success : TMColors.disabled, onClick: doSaveAsync, color: "success", btnStyle: "toolbar", disabled: !(isModified && errorsCount <= 0) }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Previous, icon: _jsx(IconArrowUp, {}), btnStyle: "toolbar", disabled: !canPrev || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doPrev }), hasNavigation && _jsx(TMButton, { caption: SDKUI_Localizator.Next, icon: _jsx(IconArrowDown, {}), btnStyle: "toolbar", disabled: !canNext || isModified || formMode == FormModes.Create || formMode == FormModes.Duplicate, onClick: doNext }), _jsx(TMButton, { caption: SDKUI_Localizator.Undo, icon: _jsx(IconUndo, {}), keyGesture: "alt+z", color: "tertiary", btnStyle: "toolbar", disabled: isModified ? false : true, onClick: onUndo }), customToolbarElements, warningsCount > 0 &&
94
96
  _jsx(TMLayoutItem, { width: 'fit-content', height: '90%', children: _jsxs(StyledResultTypeContainer, { style: { marginLeft: '10px' }, onClick: () => setShowErrorGrid(!showErrorGrid), "$resultType": ResultTypes.WARNING, children: [" ", _jsx(IconWarning, { fontSize: 16 }), " ", _jsx("span", { children: warningsCount })] }) }), errorsCount > 0 &&
95
97
  _jsx(TMLayoutItem, { width: 'fit-content', height: '90%', children: _jsxs(StyledResultTypeContainer, { style: { marginLeft: warningsCount <= 0 ? '10px' : '0' }, onClick: () => setShowErrorGrid(!showErrorGrid), "$resultType": ResultTypes.ERROR, children: [" ", _jsx(IconCloseCircle, { fontSize: 16 }), " ", _jsx("span", { children: errorsCount })] }) }), onShowList &&
96
- _jsx("div", { style: { right: '10px', position: 'absolute' }, children: !isMobile && _jsx(TMButton, { caption: showList ? SDKUI_Localizator.List_Hide : SDKUI_Localizator.List_Show, icon: showList ? _jsx(IconHide, {}) : _jsx(IconShow, {}), keyGesture: "alt+h", onClick: () => { setShowList(!showList); onShowList?.(!showList); }, btnStyle: 'toolbar' }) }), (formMode == FormModes.Create || formMode == FormModes.Duplicate) &&
97
- _jsx("div", { style: { right: '50px', position: 'absolute' }, children: !isMobile && onCancel && _jsx(TMButton, { icon: _jsx(IconCloseCircle, {}), onClick: onCancel, btnStyle: 'toolbar', caption: SDKUI_Localizator.Cancel, color: 'tertiary' }) })] }) }), _jsx(TMLayoutItem, { children: _jsxs(TMSplitterLayout, { separatorSize: 4, direction: 'vertical', start: showErrorGrid && validationItems.length > 0 ? ['80%', '20%'] : ['100%', '0'], min: ['0', '0'], children: [_jsx(TMCard, { showBorder: false, children: exception
98
+ _jsx("div", { style: { right: '10px', position: 'absolute' }, children: deviceType !== DeviceType.MOBILE && _jsx(TMButton, { caption: showList ? SDKUI_Localizator.List_Hide : SDKUI_Localizator.List_Show, icon: showList ? _jsx(IconHide, {}) : _jsx(IconShow, {}), keyGesture: "alt+h", onClick: () => { setShowList(!showList); onShowList?.(!showList); }, btnStyle: 'toolbar' }) }), (formMode == FormModes.Create || formMode == FormModes.Duplicate) &&
99
+ _jsx("div", { style: { right: '50px', position: 'absolute' }, children: deviceType !== DeviceType.MOBILE && onCancel && _jsx(TMButton, { icon: _jsx(IconCloseCircle, {}), onClick: onCancel, btnStyle: 'toolbar', caption: SDKUI_Localizator.Cancel, color: 'tertiary' }) })] }) }), _jsx(TMLayoutItem, { children: _jsxs(TMSplitterLayout, { separatorSize: 4, direction: 'vertical', start: showErrorGrid && validationItems.length > 0 ? ['80%', '20%'] : ['100%', '0'], min: ['0', '0'], children: [_jsx(TMCard, { showBorder: false, children: exception
98
100
  ?
99
101
  _jsx("div", { style: { width: '100%', height: '100%', marginTop: '50px', display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column', color: getColor('error') }, children: 'Si è verificato un errore' })
100
102
  : _jsx(_Fragment, { children: children }) }), showErrorGrid && validationItems.length > 0 ? _jsx(TMCard, { scrollY: true, padding: false, showBorder: false, children: _jsx(TMValidationItemsList, { validationItems: validationItems }) }) : _jsx(_Fragment, {})] }) })] }));
@@ -46,3 +46,4 @@ export { default as SettingsAppearance } from "./settings/SettingsAppearance";
46
46
  export * from "./viewers/TMTidViewer";
47
47
  export * from "./viewers/TMMidViewer";
48
48
  export * from "./viewers/TMDataListItemViewer";
49
+ export * from "./base/TMDeviceProvider";
@@ -61,3 +61,5 @@ export { default as SettingsAppearance } from "./settings/SettingsAppearance";
61
61
  export * from "./viewers/TMTidViewer";
62
62
  export * from "./viewers/TMMidViewer";
63
63
  export * from "./viewers/TMDataListItemViewer";
64
+ //TMDeviceProvider
65
+ export * from "./base/TMDeviceProvider";
@@ -4,7 +4,7 @@ import { SDK_Globals, ObjectClasses } from "@topconsultnpm/sdk-ts-beta";
4
4
  import DataGrid, { Column, GroupPanel, Grouping, HeaderFilter, LoadPanel, Pager, Paging, Scrolling, SearchPanel, Selection } from "devextreme-react/cjs/data-grid";
5
5
  import { PlatformObjectService } from "../../services/platform_services";
6
6
  import { FormModes, TMProgressOptions } from "../../ts";
7
- import { Globalization, IconAdd, IconColumns, IconCopy, IconDelete, IconDuplicate, IconHide, IconMail, IconMenuVertical, IconOpenInNew, IconRefresh, IconShow, MOBILE_WIDTH, SDKUI_Globals, SDKUI_Localizator, calcSaveFormTitle, canNext, canPrev, getNext, getPrev, useWindowWidth } from "../../helper";
7
+ import { Globalization, IconAdd, IconColumns, IconCopy, IconDelete, IconDuplicate, IconHide, IconMail, IconMenuVertical, IconOpenInNew, IconRefresh, IconShow, SDKUI_Globals, SDKUI_Localizator, calcSaveFormTitle, canNext, canPrev, getNext, getPrev } from "../../helper";
8
8
  import TMSpinner from "../base/TMSpinner";
9
9
  import { ButtonNames, TMExceptionBoxManager, TMMessageBoxManager } from "../base/TMPopUp";
10
10
  import TMLayoutContainer, { TMCard, TMLayoutItem, TMSplitterLayout } from "../base/TMLayout";
@@ -12,12 +12,14 @@ import TMButton from "../base/TMButton";
12
12
  import TMDropDownMenu from "../base/TMDropDownMenu";
13
13
  import { FontSize, TMColors } from "../../utils/theme";
14
14
  import selectionManagerImage from '../../assets/multipleSelectionManager.jpg';
15
+ import { DeviceType, useDeviceType } from "../base/TMDeviceProvider";
15
16
  const TMToolbarButton = ({ showTooltip = true, color = 'primary', icon, caption = '', onClick, disabled, keyGesture }) => {
16
17
  return (_jsx(TMButton, { keyGesture: keyGesture, color: color, disabled: disabled, caption: caption, onClick: () => { onClick && onClick(); }, icon: icon, showTooltip: showTooltip, btnStyle: 'toolbar' }));
17
18
  };
18
19
  const TMPage = ({ id, objClass = ObjectClasses.None, objType, listInsteadOfContent, detailInsteadOfContent, routePage, customButtons, customColumns, searchText, detailForm, detailTitlePathKeys, deps, abortSignal, onProgressChanged, onSelectionChanged, onCountersChanged }) => {
19
- let width = useWindowWidth();
20
- let isMobile = width <= MOBILE_WIDTH;
20
+ // let width = useWindowWidth();
21
+ // let isMobile: boolean = width <= MOBILE_WIDTH;
22
+ const deviceType = useDeviceType();
21
23
  let gridInstance;
22
24
  const [showId, setShowId] = useState(false);
23
25
  const [showAllColumns, setShowAllColumns] = useState(false);
@@ -61,8 +63,8 @@ const TMPage = ({ id, objClass = ObjectClasses.None, objType, listInsteadOfConte
61
63
  TMSpinner.hide();
62
64
  }
63
65
  };
64
- const duplicate = () => { isMobile && setShowList(false); setFormMode(FormModes.Duplicate); };
65
- const create = () => { isMobile && setShowList(false); setFormMode(FormModes.Create); };
66
+ const duplicate = () => { deviceType === DeviceType.MOBILE && setShowList(false); setFormMode(FormModes.Duplicate); };
67
+ const create = () => { deviceType === DeviceType.MOBILE && setShowList(false); setFormMode(FormModes.Create); };
66
68
  const deleteItems = async () => {
67
69
  let msg = "";
68
70
  switch (selectedItems.length) {
@@ -137,7 +139,7 @@ const TMPage = ({ id, objClass = ObjectClasses.None, objType, listInsteadOfConte
137
139
  return null;
138
140
  return React.cloneElement(detailForm, {
139
141
  id: selectedItems.length == 0 ? -1 : selectedItems[0].id,
140
- showBackButton: isMobile,
142
+ showBackButton: deviceType === DeviceType.MOBILE,
141
143
  formMode: formMode,
142
144
  canNext: canNext(visibleItems, selectedItems),
143
145
  onNext: () => { setSelectedItems([getNext(visibleItems, selectedItems)]); },
@@ -176,16 +178,16 @@ const TMPage = ({ id, objClass = ObjectClasses.None, objType, listInsteadOfConte
176
178
  });
177
179
  };
178
180
  const cellRenderObjectIcon = (data) => { return PlatformObjectService.getIcon(objClass, data.row.data); };
179
- return (_jsxs(TMSplitterLayout, { direction: "horizontal", showSeparator: showList && !isMobile, start: showList ? !isMobile ? ['30%', '70%'] : ['100%', '0%'] : ['0', '100%'], min: ['0px', '0px'], children: [listInsteadOfContent ??
181
+ return (_jsxs(TMSplitterLayout, { direction: "horizontal", showSeparator: showList && deviceType !== DeviceType.MOBILE, start: showList ? deviceType !== DeviceType.MOBILE ? ['30%', '70%'] : ['100%', '0%'] : ['0', '100%'], min: ['0px', '0px'], children: [listInsteadOfContent ??
180
182
  _jsxs(TMCard, { borderRadius: false, fontWeight: "bold", showBorder: false, title: objNames, children: [_jsx(ToolbarPage, {}), _jsxs(DataGrid, { disabled: selectionListDisabled, ref: (grid) => (gridInstance = grid), height: "calc(100% - 35px)", width: 'calc(100% - 5px)', dataSource: items, keyExpr: "id", allowColumnResizing: true, columnResizingMode: "widget", allowColumnReordering: true, showBorders: false, onContentReady: (e) => {
181
183
  setVisibleItems(e.component.getVisibleRows().map((row) => { return row.data; }));
182
184
  e.component.selectRows(selectedItems?.map((item) => item.id), false);
183
185
  }, onRowClick: (row) => {
184
- if (!isMobile)
186
+ if (deviceType !== DeviceType.MOBILE)
185
187
  return;
186
188
  setSelectedItems([row.data]);
187
189
  setShowList(false);
188
- }, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, showRowLines: SDKUI_Globals.dataGridShowRowLines, onSelectionChanged: (e) => { setSelectedItems(e.selectedRowsData); onSelectionChanged?.(e.selectedRowsData); }, children: [_jsx(GroupPanel, { visible: !!(!isMobile && showAllColumns) }), _jsx(SearchPanel, { visible: false }), _jsx(Grouping, { autoExpandAll: false }), _jsx(HeaderFilter, { visible: true }), _jsx(Selection, { mode: "multiple", showCheckBoxesMode: "onClick", selectAllMode: 'allPages' }), _jsx(Scrolling, { mode: "standard", useNative: SDKUI_Globals.dataGridUseNativeScrollbar }), _jsx(Paging, { pageSize: 25 }), _jsx(Pager, { visible: true, showInfo: true, showNavigationButtons: true }), _jsx(LoadPanel, { enabled: true }), _jsx(Column, { width: 20, cellRender: cellRenderObjectIcon }), _jsx(Column, { width: 'auto', visible: showId, dataField: "id", caption: "ID" }), _jsx(Column, { width: 250, dataField: "name", caption: SDKUI_Localizator.Name, sortOrder: "asc" }), _jsx(Column, { width: 250, visible: showAllColumns, dataField: "description", caption: SDKUI_Localizator.Description }), customColumns?.map((item, index) => { return React.cloneElement(item, { key: index, visible: showAllColumns }); }), _jsx(Column, { width: 'auto', visible: showAllColumns, dataField: "ownerID", caption: SDKUI_Localizator.OwnerID }), _jsx(Column, { width: 'auto', visible: showAllColumns, dataField: "ownerName", caption: SDKUI_Localizator.OwnerName }), _jsx(Column, { width: 'auto', dataType: "date", format: Globalization.getDateDisplayFormat(), visible: showAllColumns, dataField: "creationTime", caption: SDKUI_Localizator.CreationTime }), _jsx(Column, { width: 'auto', dataType: "date", format: Globalization.getDateDisplayFormat(), visible: showAllColumns, dataField: "lastUpdateTime", caption: SDKUI_Localizator.LastUpdateTime })] })] }), detailInsteadOfContent ??
190
+ }, showColumnLines: SDKUI_Globals.dataGridShowColumnLines, showRowLines: SDKUI_Globals.dataGridShowRowLines, onSelectionChanged: (e) => { setSelectedItems(e.selectedRowsData); onSelectionChanged?.(e.selectedRowsData); }, children: [_jsx(GroupPanel, { visible: !!(deviceType !== DeviceType.MOBILE && showAllColumns) }), _jsx(SearchPanel, { visible: false }), _jsx(Grouping, { autoExpandAll: false }), _jsx(HeaderFilter, { visible: true }), _jsx(Selection, { mode: "multiple", showCheckBoxesMode: "onClick", selectAllMode: 'allPages' }), _jsx(Scrolling, { mode: "standard", useNative: SDKUI_Globals.dataGridUseNativeScrollbar }), _jsx(Paging, { pageSize: 25 }), _jsx(Pager, { visible: true, showInfo: true, showNavigationButtons: true }), _jsx(LoadPanel, { enabled: true }), _jsx(Column, { width: 20, cellRender: cellRenderObjectIcon }), _jsx(Column, { width: 'auto', visible: showId, dataField: "id", caption: "ID" }), _jsx(Column, { width: 250, dataField: "name", caption: SDKUI_Localizator.Name, sortOrder: "asc" }), _jsx(Column, { width: 250, visible: showAllColumns, dataField: "description", caption: SDKUI_Localizator.Description }), customColumns?.map((item, index) => { return React.cloneElement(item, { key: index, visible: showAllColumns }); }), _jsx(Column, { width: 'auto', visible: showAllColumns, dataField: "ownerID", caption: SDKUI_Localizator.OwnerID }), _jsx(Column, { width: 'auto', visible: showAllColumns, dataField: "ownerName", caption: SDKUI_Localizator.OwnerName }), _jsx(Column, { width: 'auto', dataType: "date", format: Globalization.getDateDisplayFormat(), visible: showAllColumns, dataField: "creationTime", caption: SDKUI_Localizator.CreationTime }), _jsx(Column, { width: 'auto', dataType: "date", format: Globalization.getDateDisplayFormat(), visible: showAllColumns, dataField: "lastUpdateTime", caption: SDKUI_Localizator.LastUpdateTime })] })] }), detailInsteadOfContent ??
189
191
  _jsx(TMLayoutItem, { children: selectedItems.length == 1 || formMode == FormModes.Create || formMode == FormModes.Duplicate ?
190
192
  _jsx(TMCard, { borderRadius: false, fontWeight: "bold", showBorder: false, title: calcSaveFormTitle(objName, formMode, selectedItems.length == 0 ? -1 : selectedItems[0].id, detailTitlePathKeys), children: getDetailFormWithProps() })
191
193
  :
@@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
3
3
  import { SDK_Globals, AppModules } from '@topconsultnpm/sdk-ts-beta';
4
4
  import TMQueryResult from './TMQueryResult';
5
5
  import styled from 'styled-components';
6
- import { IconApply, IconCloseOutline, IconUser, IconInfo, IconRefresh, IconSync, IconDownload, IconPreview, IconPrinter, IconCheckIn, IconEdit, IconStar, IconRecursiveOps, IconMail, IconDcmtTypeOnlyMetadata, IconCopy, IconRelation, IconSignature, IconDelete, IconUndo, IconCloseCircle, IconMenuVertical, IconArchiveDoc, IconDuplicate, IconSubstFile, IconConvertFilePdf, IconCheckFile, IconBatchUpdate, IconShare, IconSharedDcmt, IconSearch, IconExportTo, IconShow, IconSettings, IconActivityLog, SDKUI_Localizator, useWindowWidth, MOBILE_WIDTH, IconArrowLeft } from '../../helper';
6
+ import { IconApply, IconCloseOutline, IconUser, IconInfo, IconRefresh, IconSync, IconDownload, IconPreview, IconPrinter, IconCheckIn, IconEdit, IconStar, IconRecursiveOps, IconMail, IconDcmtTypeOnlyMetadata, IconCopy, IconRelation, IconSignature, IconDelete, IconUndo, IconCloseCircle, IconMenuVertical, IconArchiveDoc, IconDuplicate, IconSubstFile, IconConvertFilePdf, IconCheckFile, IconBatchUpdate, IconShare, IconSharedDcmt, IconSearch, IconExportTo, IconShow, IconSettings, IconActivityLog, SDKUI_Localizator, IconArrowLeft } from '../../helper';
7
7
  import { FormModes } from '../../ts';
8
8
  import { TMColors } from '../../utils/theme';
9
9
  import { StyledBadge } from '../base/Styled';
@@ -19,6 +19,7 @@ import TMUserChooser from '../choosers/TMUserChooser';
19
19
  import TMApplyForm from '../forms/TMApplyForm';
20
20
  import TMTidViewer from '../viewers/TMTidViewer';
21
21
  import TMListView from '../base/TMListView';
22
+ import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
22
23
  export var SearchResultContext;
23
24
  (function (SearchResultContext) {
24
25
  SearchResultContext["METADATA_SEARCH"] = "metadataSearch";
@@ -221,8 +222,9 @@ const TMQueryResultForm = ({ onUpdate, isModal, onClose, context = SearchResultC
221
222
  _jsxs(StyledTitleContainer, { children: [context === SearchResultContext.WORKFLOW_APPROVE ? _jsx(IconActivityLog, { fontSize: 14 }) : context === SearchResultContext.FAVORITES ? _jsx(IconStar, {}) : context === SearchResultContext.RECENT ? _jsx(IconRefresh, {}) : '', context === SearchResultContext.WORKFLOW_APPROVE ? SDKUI_Localizator.WorkflowApproval : context === SearchResultContext.FAVORITES ? SDKUI_Localizator.Favorites : context === SearchResultContext.RECENT ? SDKUI_Localizator.Recent : ''] }, context === SearchResultContext.WORKFLOW_APPROVE ? 'title2' : context === SearchResultContext.FAVORITES ? 'title0' : context === SearchResultContext.RECENT ? 'title1' : '')
222
223
  ];
223
224
  const [toolbar, setToolbar] = useState(toolbarElements);
224
- let width = useWindowWidth();
225
- let isMobile = width <= MOBILE_WIDTH;
225
+ // let width = useWindowWidth()
226
+ const deviceType = useDeviceType();
227
+ let isMobile = deviceType === DeviceType.MOBILE;
226
228
  useEffect(() => { if (isMobile) {
227
229
  setCurrentSearchResult1(undefined);
228
230
  setCurrentSearchResult2(undefined);
@@ -8,6 +8,7 @@ import { FontSize, TMColors } from '../../utils/theme';
8
8
  import { ButtonNames, TMMessageBoxManager } from '../base/TMPopUp';
9
9
  import Logo from '../../assets/Toppy-generico.png';
10
10
  import { ApplicationThemeColor } from './TMSidebarItem';
11
+ import { DeviceType, useDeviceType } from '../base/TMDeviceProvider';
11
12
  export var TMSearchContext;
12
13
  (function (TMSearchContext) {
13
14
  TMSearchContext["JOBS"] = "jobs";
@@ -34,8 +35,9 @@ const StyledChaBotBtnWrapper = styled.div ` position: relative; cursor: pointer;
34
35
  const StyledChatBotToppyContainer = styled.div ` background-color: orange; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50px; position: absolute; left: -10px; `;
35
36
  const StyledToppyImage = styled.div ` display: flex; align-items: center; justify-content: center; width: 25px; height: 25px; border-radius: 50px; overflow: hidden; background-color: white; `;
36
37
  export const TMSearchBar = ({ searchValue, onSearchValueChanged, maxWidth, marginLeft }) => {
37
- const size = useWindowWidth();
38
- return (_jsxs(StyledSearchBarContainer, { style: { maxWidth: maxWidth ? maxWidth : size <= 640 ? '65%' : '650px', marginLeft: marginLeft ? marginLeft : size <= 640 ? '10px' : '50px' }, "$isMobile": size <= 640, children: [_jsx(IconSearch, { fontSize: 12, color: '#00000060', style: { position: 'absolute', width: '20px', height: '20px', left: '5px', top: '5px', zIndex: 1 } }), _jsx(StyledSearchBar, { placeholder: SDKUI_Localizator.Search + '...', type: "text", value: searchValue, onChange: (e) => onSearchValueChanged(e.target.value) }), searchValue.length > 0 && _jsx(IconCloseOutline, { onClick: () => onSearchValueChanged(''), color: '#00000060', style: { cursor: 'pointer', position: 'absolute', width: '20px', height: '20px', right: '5px', top: '5px', zIndex: 1 } })] }));
38
+ // const size = useWindowWidth()
39
+ const deviceType = useDeviceType();
40
+ return (_jsxs(StyledSearchBarContainer, { style: { maxWidth: maxWidth ? maxWidth : deviceType === DeviceType.MOBILE ? '65%' : '650px', marginLeft: marginLeft ? marginLeft : deviceType === DeviceType.MOBILE ? '10px' : '50px' }, "$isMobile": deviceType === DeviceType.MOBILE, children: [_jsx(IconSearch, { fontSize: 12, color: '#00000060', style: { position: 'absolute', width: '20px', height: '20px', left: '5px', top: '5px', zIndex: 1 } }), _jsx(StyledSearchBar, { placeholder: SDKUI_Localizator.Search + '...', type: "text", value: searchValue, onChange: (e) => onSearchValueChanged(e.target.value) }), searchValue.length > 0 && _jsx(IconCloseOutline, { onClick: () => onSearchValueChanged(''), color: '#00000060', style: { cursor: 'pointer', position: 'absolute', width: '20px', height: '20px', right: '5px', top: '5px', zIndex: 1 } })] }));
39
41
  };
40
42
  const TMHeader = ({ showSearchBar = true, clearSearchJobValue, clearSearchQEValue, searchContext = TMSearchContext.JOBS, onChangePassword, onLogout, settingsMenuContext, onSeacrhJobsValueChange, onSeacrhJobslistValueChange, onSeacrhProcessMonitorValueChange, onSeacrhProcessValueChange, onSeacrhPlatformValueChange, onSeacrhQEValueChange, onSettingsClick }) => {
41
43
  const [menuStatus, setMenuStatus] = useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.6.87",
3
+ "version": "6.6.89",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",