@devtron-labs/devtron-fe-common-lib 0.0.25 → 0.0.26-beta-2
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.
- package/dist/Common/CustomTagSelector/ResizableTagTextArea.d.ts +1 -1
- package/dist/Common/CustomTagSelector/Types.d.ts +1 -0
- package/dist/Common/Helper.d.ts +1 -0
- package/dist/index.js +19 -7
- package/package.json +1 -1
- package/src/Common/CustomTagSelector/ResizableTagTextArea.tsx +14 -6
- package/src/Common/CustomTagSelector/Types.ts +1 -0
- package/src/Common/Helper.tsx +5 -0
|
@@ -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;
|
package/dist/Common/Helper.d.ts
CHANGED
|
@@ -42,4 +42,5 @@ export declare function CustomInput({ name, value, error, onChange, onBlur, onFo
|
|
|
42
42
|
}): JSX.Element;
|
|
43
43
|
export declare function handleUTCTime(ts: string, isRelativeTime?: boolean): string;
|
|
44
44
|
export declare function useSearchString(): UseSearchString;
|
|
45
|
+
export declare const closeOnEscKeyPressed: (e: any, actionClose: () => void) => void;
|
|
45
46
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -10099,7 +10099,12 @@ function useSearchString() {
|
|
|
10099
10099
|
return agg;
|
|
10100
10100
|
}, {});
|
|
10101
10101
|
return { queryParams: queryParams, searchParams: searchParams };
|
|
10102
|
-
}
|
|
10102
|
+
}
|
|
10103
|
+
var closeOnEscKeyPressed = function (e, actionClose) {
|
|
10104
|
+
if (e.keyCode === 27 || e.key === 'Escape') {
|
|
10105
|
+
actionClose();
|
|
10106
|
+
}
|
|
10107
|
+
};
|
|
10103
10108
|
|
|
10104
10109
|
function Progressing(_a) {
|
|
10105
10110
|
var pageLoader = _a.pageLoader, size = _a.size, theme = _a.theme, styles = _a.styles, fillColor = _a.fillColor;
|
|
@@ -14662,7 +14667,7 @@ var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
|
|
|
14662
14667
|
};
|
|
14663
14668
|
|
|
14664
14669
|
function ResizableTagTextArea(_a) {
|
|
14665
|
-
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;
|
|
14670
|
+
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;
|
|
14666
14671
|
var _b = __read(React.useState(''), 2), text = _b[0], setText = _b[1];
|
|
14667
14672
|
React.useEffect(function () {
|
|
14668
14673
|
setText(value);
|
|
@@ -14675,9 +14680,11 @@ function ResizableTagTextArea(_a) {
|
|
|
14675
14680
|
if (document.activeElement !== refVar.current)
|
|
14676
14681
|
return;
|
|
14677
14682
|
refVar.current.style.height = minHeight + 'px';
|
|
14678
|
-
dependentRef
|
|
14683
|
+
if (dependentRef) {
|
|
14684
|
+
dependentRef.current.style.height = minHeight + 'px';
|
|
14685
|
+
}
|
|
14679
14686
|
var nextHeight = refVar.current.scrollHeight;
|
|
14680
|
-
if (nextHeight < dependentRef.current.scrollHeight) {
|
|
14687
|
+
if (dependentRef && nextHeight < dependentRef.current.scrollHeight) {
|
|
14681
14688
|
nextHeight = dependentRef.current.scrollHeight;
|
|
14682
14689
|
}
|
|
14683
14690
|
if (minHeight && nextHeight < minHeight) {
|
|
@@ -14687,19 +14694,23 @@ function ResizableTagTextArea(_a) {
|
|
|
14687
14694
|
nextHeight = maxHeight;
|
|
14688
14695
|
}
|
|
14689
14696
|
refVar.current.style.height = nextHeight + 'px';
|
|
14690
|
-
dependentRef
|
|
14697
|
+
if (dependentRef) {
|
|
14698
|
+
dependentRef.current.style.height = nextHeight + 'px';
|
|
14699
|
+
}
|
|
14691
14700
|
};
|
|
14692
14701
|
useThrottledEffect(reInitHeight, 500, [text]);
|
|
14693
14702
|
var handleOnBlur = function (event) {
|
|
14694
14703
|
refVar.current.style.height = minHeight + 'px';
|
|
14695
|
-
dependentRef
|
|
14704
|
+
if (dependentRef) {
|
|
14705
|
+
dependentRef.current.style.height = minHeight + 'px';
|
|
14706
|
+
}
|
|
14696
14707
|
onBlur && onBlur(event);
|
|
14697
14708
|
};
|
|
14698
14709
|
var handleOnFocus = function (event) {
|
|
14699
14710
|
reInitHeight();
|
|
14700
14711
|
onFocus && onFocus(event);
|
|
14701
14712
|
};
|
|
14702
|
-
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 }));
|
|
14713
|
+
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 }));
|
|
14703
14714
|
}
|
|
14704
14715
|
|
|
14705
14716
|
var validateTagValue = function (value) {
|
|
@@ -23416,6 +23427,7 @@ exports.TriggerTypeMap = TriggerTypeMap;
|
|
|
23416
23427
|
exports.URLS = URLS;
|
|
23417
23428
|
exports.VisibleModal = VisibleModal;
|
|
23418
23429
|
exports.VisibleModal2 = VisibleModal2;
|
|
23430
|
+
exports.closeOnEscKeyPressed = closeOnEscKeyPressed;
|
|
23419
23431
|
exports.createGitCommitUrl = createGitCommitUrl;
|
|
23420
23432
|
exports.extractImage = extractImage;
|
|
23421
23433
|
exports.get = get;
|
package/package.json
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
}
|
package/src/Common/Helper.tsx
CHANGED