@devtron-labs/devtron-fe-common-lib 0.0.31 → 0.0.32

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,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import { ResizableTagTextAreaProps } from './Types';
3
- export declare function ResizableTagTextArea({ className, minHeight, maxHeight, value, onChange, onBlur, onFocus, placeholder, tabIndex, refVar, dependentRef, dataTestId, }: ResizableTagTextAreaProps): JSX.Element;
3
+ export declare function ResizableTagTextArea({ className, minHeight, maxHeight, value, onChange, onBlur, onFocus, placeholder, tabIndex, refVar, dependentRef, dataTestId, handleKeyDown, }: ResizableTagTextAreaProps): JSX.Element;
@@ -64,4 +64,5 @@ export interface ResizableTagTextAreaProps {
64
64
  refVar?: React.MutableRefObject<HTMLTextAreaElement>;
65
65
  dependentRef?: React.MutableRefObject<HTMLTextAreaElement>;
66
66
  dataTestId?: string;
67
+ handleKeyDown?: any;
67
68
  }
package/dist/index.js CHANGED
@@ -14777,7 +14777,7 @@ var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
14777
14777
  };
14778
14778
 
14779
14779
  function ResizableTagTextArea(_a) {
14780
- var className = _a.className, minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, placeholder = _a.placeholder, tabIndex = _a.tabIndex, refVar = _a.refVar, dependentRef = _a.dependentRef, dataTestId = _a.dataTestId;
14780
+ var className = _a.className, minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, onChange = _a.onChange, onBlur = _a.onBlur, onFocus = _a.onFocus, placeholder = _a.placeholder, tabIndex = _a.tabIndex, refVar = _a.refVar, dependentRef = _a.dependentRef, dataTestId = _a.dataTestId, handleKeyDown = _a.handleKeyDown;
14781
14781
  var _b = __read(React.useState(''), 2), text = _b[0], setText = _b[1];
14782
14782
  React.useEffect(function () {
14783
14783
  setText(value);
@@ -14790,9 +14790,11 @@ function ResizableTagTextArea(_a) {
14790
14790
  if (document.activeElement !== refVar.current)
14791
14791
  return;
14792
14792
  refVar.current.style.height = minHeight + 'px';
14793
- dependentRef.current.style.height = minHeight + 'px';
14793
+ if (dependentRef) {
14794
+ dependentRef.current.style.height = minHeight + 'px';
14795
+ }
14794
14796
  var nextHeight = refVar.current.scrollHeight;
14795
- if (nextHeight < dependentRef.current.scrollHeight) {
14797
+ if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
14796
14798
  nextHeight = dependentRef.current.scrollHeight;
14797
14799
  }
14798
14800
  if (minHeight && nextHeight < minHeight) {
@@ -14802,19 +14804,23 @@ function ResizableTagTextArea(_a) {
14802
14804
  nextHeight = maxHeight;
14803
14805
  }
14804
14806
  refVar.current.style.height = nextHeight + 'px';
14805
- dependentRef.current.style.height = nextHeight + 'px';
14807
+ if (dependentRef) {
14808
+ dependentRef.current.style.height = nextHeight + 'px';
14809
+ }
14806
14810
  };
14807
14811
  useThrottledEffect(reInitHeight, 500, [text]);
14808
14812
  var handleOnBlur = function (event) {
14809
14813
  refVar.current.style.height = minHeight + 'px';
14810
- dependentRef.current.style.height = minHeight + 'px';
14814
+ if (dependentRef) {
14815
+ dependentRef.current.style.height = minHeight + 'px';
14816
+ }
14811
14817
  onBlur && onBlur(event);
14812
14818
  };
14813
14819
  var handleOnFocus = function (event) {
14814
14820
  reInitHeight();
14815
14821
  onFocus && onFocus(event);
14816
14822
  };
14817
- return (jsxRuntime.jsx("textarea", { rows: 1, ref: refVar, value: text, placeholder: placeholder, className: "".concat(className || '', " lh-20"), style: { resize: 'none' }, onChange: handleChange, onBlur: handleOnBlur, onFocus: handleOnFocus, tabIndex: tabIndex, "data-testid": dataTestId }));
14823
+ return (jsxRuntime.jsx("textarea", { rows: 1, ref: refVar, value: text, placeholder: placeholder, className: "".concat(className || '', " lh-20"), style: { resize: 'none' }, onChange: handleChange, onBlur: handleOnBlur, onFocus: handleOnFocus, tabIndex: tabIndex, "data-testid": dataTestId, onKeyDown: handleKeyDown }));
14818
14824
  }
14819
14825
 
14820
14826
  var validateTagValue = function (value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.31",
3
+ "version": "v0.0.32",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -15,6 +15,7 @@ export function ResizableTagTextArea({
15
15
  refVar,
16
16
  dependentRef,
17
17
  dataTestId,
18
+ handleKeyDown,
18
19
  }: ResizableTagTextAreaProps) {
19
20
  const [text, setText] = useState('')
20
21
 
@@ -29,10 +30,12 @@ export function ResizableTagTextArea({
29
30
 
30
31
  const reInitHeight = () => {
31
32
  if (document.activeElement !== refVar.current) return
32
- refVar.current.style.height = minHeight+ 'px'
33
- dependentRef.current.style.height = minHeight+ 'px'
33
+ refVar.current.style.height = minHeight + 'px'
34
+ if (dependentRef) {
35
+ dependentRef.current.style.height = minHeight + 'px'
36
+ }
34
37
  let nextHeight = refVar.current.scrollHeight
35
- if (nextHeight < dependentRef.current.scrollHeight) {
38
+ if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
36
39
  nextHeight = dependentRef.current.scrollHeight
37
40
  }
38
41
  if (minHeight && nextHeight < minHeight) {
@@ -42,14 +45,18 @@ export function ResizableTagTextArea({
42
45
  nextHeight = maxHeight
43
46
  }
44
47
  refVar.current.style.height = nextHeight + 'px'
45
- dependentRef.current.style.height = nextHeight + 'px'
48
+ if (dependentRef) {
49
+ dependentRef.current.style.height = nextHeight + 'px'
50
+ }
46
51
  }
47
52
 
48
53
  useThrottledEffect(reInitHeight, 500, [text])
49
54
 
50
55
  const handleOnBlur = (event) => {
51
- refVar.current.style.height = minHeight+ 'px'
52
- dependentRef.current.style.height = minHeight+ 'px'
56
+ refVar.current.style.height = minHeight + 'px'
57
+ if (dependentRef) {
58
+ dependentRef.current.style.height = minHeight + 'px'
59
+ }
53
60
  onBlur && onBlur(event)
54
61
  }
55
62
 
@@ -71,6 +78,7 @@ export function ResizableTagTextArea({
71
78
  onFocus={handleOnFocus}
72
79
  tabIndex={tabIndex}
73
80
  data-testid={dataTestId}
81
+ onKeyDown={handleKeyDown}
74
82
  />
75
83
  )
76
84
  }
@@ -68,4 +68,5 @@ export interface ResizableTagTextAreaProps {
68
68
  refVar?: React.MutableRefObject<HTMLTextAreaElement>
69
69
  dependentRef?: React.MutableRefObject<HTMLTextAreaElement>
70
70
  dataTestId?: string
71
+ handleKeyDown?: any
71
72
  }