@topconsultnpm/sdkui-react 6.19.0-dev2.45 → 6.19.0-dev2.47

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.
@@ -12,6 +12,7 @@ interface ITMTextArea extends ITMEditorBase {
12
12
  rows?: number;
13
13
  maxLength?: number;
14
14
  resize?: boolean;
15
+ autoCalculateRows?: boolean;
15
16
  }
16
17
  declare const TMTextArea: React.FunctionComponent<ITMTextArea>;
17
18
  export default TMTextArea;
@@ -28,7 +28,7 @@ const StyledTextAreaEditorButton = styled.div `
28
28
  // Define the TMTextArea component
29
29
  const TMTextArea = (props) => {
30
30
  // Extract properties from the props object
31
- const { label = '', value = '', width = '100%', height = 'auto', autoFocus = false, showClearButton, validationItems = [], disabled = false, isModifiedWhen = false, fontSize = FontSize.defaultFontSize, elementStyle = {}, icon = null, labelPosition = 'left', readOnly = false, onValueChanged, onBlur, placeHolder, formulaItems = [], buttons = [], maxHeight = 'auto', rows, maxLength, resize = true } = props;
31
+ const { label = '', value = '', width = '100%', height = 'auto', autoFocus = false, showClearButton, validationItems = [], disabled = false, isModifiedWhen = false, fontSize = FontSize.defaultFontSize, elementStyle = {}, icon = null, labelPosition = 'left', readOnly = false, onValueChanged, onBlur, placeHolder, formulaItems = [], buttons = [], maxHeight = 'auto', rows, maxLength, resize = true, autoCalculateRows = true } = props;
32
32
  // Reference to the textarea DOM element
33
33
  const inputRef = useRef(null);
34
34
  // Stores the textarea is focused
@@ -46,6 +46,8 @@ const TMTextArea = (props) => {
46
46
  const deviceType = useDeviceType();
47
47
  // Attach a `ResizeObserver` to the textarea to monitor changes in width: dynamically updates rows based on textarea content and width
48
48
  useEffect(() => {
49
+ if (!autoCalculateRows)
50
+ return;
49
51
  const observer = new ResizeObserver(() => { if (currentValue) {
50
52
  updateRows();
51
53
  } });
@@ -55,18 +57,18 @@ const TMTextArea = (props) => {
55
57
  return () => { if (inputRef.current) {
56
58
  observer.unobserve(inputRef.current);
57
59
  } };
58
- }, [currentValue]);
60
+ }, [currentValue, autoCalculateRows]);
59
61
  // Update current value whenever the `value` prop changes, synchronize the internal state with the `value` prop
60
62
  useEffect(() => {
61
63
  setCurrentValue(value);
62
64
  }, [value]);
63
65
  // Recalculate the number of rows whenever the `currentValue` changes
64
66
  useEffect(() => {
65
- if (currentValue) {
67
+ if (autoCalculateRows && currentValue) {
66
68
  const newRowCount = calculateRows(currentValue);
67
69
  setCalculatedRows(newRowCount);
68
70
  }
69
- }, [currentValue]);
71
+ }, [currentValue, autoCalculateRows]);
70
72
  // Populate the formula menu items whenever the `formulaItems` prop changes
71
73
  useEffect(() => {
72
74
  if (formulaItems && formulaItems.length > 0) {
@@ -171,7 +173,8 @@ const TMTextArea = (props) => {
171
173
  _jsx(StyledTextAreaEditorButton, { onClick: () => {
172
174
  onValueChanged?.({ target: { value: undefined } });
173
175
  setCurrentValue('');
174
- setCalculatedRows(1);
176
+ if (autoCalculateRows)
177
+ setCalculatedRows(1);
175
178
  onBlur?.(undefined);
176
179
  }, children: _jsx(IconClearButton, {}) }), buttons.map((buttonItem, index) => {
177
180
  return (_jsx(StyledTextAreaEditorButton, { onClick: buttonItem.onClick, children: _jsx(TMTooltip, { content: buttonItem.text, children: buttonItem.icon }) }, buttonItem.text));
@@ -40,19 +40,39 @@ const ToppyButton = styled.button.attrs((props) => ({
40
40
  background-color: transparent;
41
41
  border: none;
42
42
 
43
- /* Dimensioni dinamiche in base allo stato collassato
43
+ /* Dimensioni dinamiche in base allo stato collassato e al tipo di dispositivo
44
44
  Usa min() per adattarsi su schermi piccoli */
45
- width: ${(props) => (props.$isCollapsed ? 'min(60px, 100%)' : '120px')};
46
- height: ${(props) => (props.$isCollapsed ? 'min(70px, 100%)' : '140px')};
45
+ width: ${(props) => {
46
+ if (props.$isMobile) {
47
+ return props.$isCollapsed ? 'min(40px, 100%)' : '80px';
48
+ }
49
+ return props.$isCollapsed ? 'min(60px, 100%)' : '120px';
50
+ }};
51
+ height: ${(props) => {
52
+ if (props.$isMobile) {
53
+ return props.$isCollapsed ? 'min(45px, 100%)' : '95px';
54
+ }
55
+ return props.$isCollapsed ? 'min(70px, 100%)' : '140px';
56
+ }};
47
57
  max-width: 100%;
48
58
  max-height: 100%;
49
59
 
50
60
  user-select: none;
51
61
 
52
62
  img {
53
- /* Dimensioni dell'immagine in base allo stato collassato */
54
- width: ${(props) => (props.$isCollapsed ? '60px' : '120px')};
55
- height: ${(props) => (props.$isCollapsed ? '60px' : '140px')};
63
+ /* Dimensioni dell'immagine in base allo stato collassato e al tipo di dispositivo */
64
+ width: ${(props) => {
65
+ if (props.$isMobile) {
66
+ return props.$isCollapsed ? '40px' : '80px';
67
+ }
68
+ return props.$isCollapsed ? '60px' : '120px';
69
+ }};
70
+ height: ${(props) => {
71
+ if (props.$isMobile) {
72
+ return props.$isCollapsed ? '40px' : '95px';
73
+ }
74
+ return props.$isCollapsed ? '60px' : '140px';
75
+ }};
56
76
  pointer-events: none;
57
77
  border-radius: 50%; /* Rende l'immagine circolare */
58
78
  /* Rotazione leggera in base all'allineamento */
@@ -106,6 +126,7 @@ const ToppyDraggableHelpCenter = ({ content, deviceType, align = 'right', onTopp
106
126
  // Ref e stato per tracciare le dimensioni della speech bubble
107
127
  const bubbleRef = useRef(null);
108
128
  const [bubbleSize, setBubbleSize] = useState({ width: 0, height: 0 });
129
+ const isMobile = deviceType === DeviceType.MOBILE;
109
130
  /**
110
131
  * Effect per aggiornare le dimensioni della bubble quando cambia il contenuto
111
132
  * o lo stato di collassamento. Necessario per calcolare correttamente i limiti
@@ -278,6 +299,7 @@ const ToppyDraggableHelpCenter = ({ content, deviceType, align = 'right', onTopp
278
299
  }
279
300
  return undefined;
280
301
  }, [isDragging]);
281
- return (_jsxs(ToppyButton, { ref: buttonRef, "$align": align, "$isDragging": isDragging, "$x": position?.x, "$y": position?.y, "$isVisible": isVisible, "$isCollapsed": isCollapsed, onMouseDown: handleMouseDown, onContextMenu: (e) => e.preventDefault(), onDoubleClick: toggleCollapse, children: [(content && !isCollapsed) && (_jsx(ToppySpeechBubble, { ref: bubbleRef, align: align, children: content })), _jsx("img", { src: Toppy, alt: "Toppy Help", draggable: false })] }));
302
+ return (_jsxs(ToppyButton, { ref: buttonRef, "$align": align, "$isDragging": isDragging, "$x": position?.x, "$y": position?.y, "$isVisible": isVisible, "$isCollapsed": isCollapsed, "$isMobile": isMobile, onMouseDown: handleMouseDown, onContextMenu: (e) => e.preventDefault(), onClick: (e) => { if (isMobile)
303
+ toggleCollapse(e); }, onDoubleClick: toggleCollapse, children: [(content && !isCollapsed) && (_jsx(ToppySpeechBubble, { ref: bubbleRef, align: align, children: content })), _jsx("img", { src: Toppy, alt: "Toppy Help", draggable: false })] }));
282
304
  };
283
305
  export default ToppyDraggableHelpCenter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react",
3
- "version": "6.19.0-dev2.45",
3
+ "version": "6.19.0-dev2.47",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",