@devtron-labs/devtron-fe-common-lib 0.0.45-beta-12 → 0.0.45-beta-14
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 { CustomInputProps } from './Types';
|
|
3
|
-
export declare function CustomInput({ name, value, error, onChange,
|
|
3
|
+
export declare function CustomInput({ name, value, error, onChange, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, showLink, linkText, link, helperText, handleOnBlur, readOnly, noTrim, }: CustomInputProps): JSX.Element;
|
|
@@ -3,7 +3,6 @@ export interface CustomInputProps {
|
|
|
3
3
|
name: string;
|
|
4
4
|
value: string | number;
|
|
5
5
|
onChange: (e: any) => void;
|
|
6
|
-
onBlur?: (e: any) => void;
|
|
7
6
|
onFocus?: (e: any) => void;
|
|
8
7
|
autoComplete?: string;
|
|
9
8
|
label?: React.ReactNode;
|
|
@@ -21,7 +20,7 @@ export interface CustomInputProps {
|
|
|
21
20
|
linkText?: string;
|
|
22
21
|
error?: string[] | string;
|
|
23
22
|
helperText?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
handleOnBlur?: (e: any) => void;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
noTrim?: boolean;
|
|
27
26
|
}
|
package/dist/index.js
CHANGED
|
@@ -26624,7 +26624,7 @@ function DevtronProgressing(_a) {
|
|
|
26624
26624
|
}
|
|
26625
26625
|
|
|
26626
26626
|
function CustomInput(_a) {
|
|
26627
|
-
var name = _a.name, value = _a.value, error = _a.error, onChange = _a.onChange
|
|
26627
|
+
var name = _a.name, value = _a.value, error = _a.error, onChange = _a.onChange, _b = _a.onFocus, onFocus = _b === void 0 ? function (e) { } : _b, _c = _a.label, label = _c === void 0 ? '' : _c, _d = _a.type, type = _d === void 0 ? 'text' : _d, _e = _a.disabled, disabled = _e === void 0 ? false : _e, _f = _a.labelClassName, labelClassName = _f === void 0 ? '' : _f, _g = _a.placeholder, placeholder = _g === void 0 ? '' : _g, _h = _a.tabIndex, tabIndex = _h === void 0 ? 1 : _h, _j = _a.dataTestid, dataTestid = _j === void 0 ? '' : _j, _k = _a.isRequiredField, isRequiredField = _k === void 0 ? false : _k, _l = _a.autoFocus, autoFocus = _l === void 0 ? true : _l, _m = _a.rootClassName, rootClassName = _m === void 0 ? '' : _m, _o = _a.autoComplete, autoComplete = _o === void 0 ? 'off' : _o, _p = _a.showLink, showLink = _p === void 0 ? false : _p, _q = _a.linkText, linkText = _q === void 0 ? '' : _q, _r = _a.link, link = _r === void 0 ? '' : _r, _s = _a.helperText, helperText = _s === void 0 ? '' : _s, handleOnBlur = _a.handleOnBlur, _t = _a.readOnly, readOnly = _t === void 0 ? false : _t, _u = _a.noTrim, noTrim = _u === void 0 ? false : _u;
|
|
26628
26628
|
var renderLabelHelperText = function () {
|
|
26629
26629
|
return (jsxRuntime.jsx("span", { children: jsxRuntime.jsx("a", __assign({ target: "_blank", href: link, className: "cursor fs-13 onlink ml-4" }, { children: linkText })) }));
|
|
26630
26630
|
};
|
|
@@ -26637,12 +26637,18 @@ function CustomInput(_a) {
|
|
|
26637
26637
|
}
|
|
26638
26638
|
return error;
|
|
26639
26639
|
}
|
|
26640
|
-
var
|
|
26641
|
-
|
|
26642
|
-
|
|
26643
|
-
|
|
26640
|
+
var onBlur = function (event) {
|
|
26641
|
+
var _a;
|
|
26642
|
+
//NOTE: This is to prevent the input from being trimmed when the user do not want to trim the input
|
|
26643
|
+
if (!noTrim) {
|
|
26644
|
+
event.stopPropagation();
|
|
26645
|
+
event.target.value = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
|
|
26646
|
+
onChange(event);
|
|
26644
26647
|
}
|
|
26645
|
-
|
|
26648
|
+
if (typeof handleOnBlur === 'function') {
|
|
26649
|
+
handleOnBlur(event);
|
|
26650
|
+
}
|
|
26651
|
+
};
|
|
26646
26652
|
var renderFormError = function () {
|
|
26647
26653
|
if ((error === null || error === void 0 ? void 0 : error.length) > 0) {
|
|
26648
26654
|
if (typeof error === 'object') {
|
|
@@ -26654,7 +26660,7 @@ function CustomInput(_a) {
|
|
|
26654
26660
|
return (jsxRuntime.jsxs("div", __assign({ className: "flex column left top" }, { children: [label && (jsxRuntime.jsxs("label", __assign({ className: "form__label ".concat(labelClassName), "data-testid": "label-".concat(dataTestid) }, { children: [jsxRuntime.jsx("span", __assign({ className: "".concat(isRequiredField ? 'dc__required-field' : '') }, { children: label })), showLink && renderLabelHelperText()] }))), jsxRuntime.jsx("input", { "data-testid": dataTestid, type: type, name: name, autoComplete: autoComplete, className: "form__input ".concat(rootClassName), onChange: function (e) {
|
|
26655
26661
|
e.persist();
|
|
26656
26662
|
onChange(e);
|
|
26657
|
-
}, onBlur:
|
|
26663
|
+
}, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex, autoFocus: autoFocus, readOnly: readOnly }), renderFormError(), helperText && (jsxRuntime.jsxs("div", __assign({ className: "form__text-field-info" }, { children: [jsxRuntime.jsx(SvgIcInfoFilled, { className: "form__icon form__icon--info" }), jsxRuntime.jsx("p", __assign({ className: "sentence-case" }, { children: helperText }))] })))] })));
|
|
26658
26664
|
}
|
|
26659
26665
|
|
|
26660
26666
|
exports.AppStatus = AppStatus;
|
package/package.json
CHANGED
|
@@ -8,7 +8,6 @@ export function CustomInput({
|
|
|
8
8
|
value,
|
|
9
9
|
error,
|
|
10
10
|
onChange,
|
|
11
|
-
onBlur = (e) => {},
|
|
12
11
|
onFocus = (e) => {},
|
|
13
12
|
label = '',
|
|
14
13
|
type = 'text',
|
|
@@ -25,10 +24,10 @@ export function CustomInput({
|
|
|
25
24
|
linkText = '',
|
|
26
25
|
link = '',
|
|
27
26
|
helperText = '',
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
handleOnBlur,
|
|
28
|
+
readOnly = false,
|
|
29
|
+
noTrim = false,
|
|
30
30
|
}: CustomInputProps) {
|
|
31
|
-
|
|
32
31
|
const renderLabelHelperText = () => {
|
|
33
32
|
return (
|
|
34
33
|
<span>
|
|
@@ -51,19 +50,17 @@ export function CustomInput({
|
|
|
51
50
|
return error
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
},[])
|
|
53
|
+
const onBlur = (event) => {
|
|
54
|
+
//NOTE: This is to prevent the input from being trimmed when the user do not want to trim the input
|
|
55
|
+
if (!noTrim) {
|
|
56
|
+
event.stopPropagation()
|
|
57
|
+
event.target.value = event.target.value?.trim()
|
|
58
|
+
onChange(event)
|
|
59
|
+
}
|
|
60
|
+
if (typeof handleOnBlur === 'function') {
|
|
61
|
+
handleOnBlur(event)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
67
64
|
|
|
68
65
|
const renderFormError = () => {
|
|
69
66
|
if (error?.length > 0) {
|
|
@@ -102,13 +99,14 @@ export function CustomInput({
|
|
|
102
99
|
e.persist()
|
|
103
100
|
onChange(e)
|
|
104
101
|
}}
|
|
105
|
-
onBlur={
|
|
102
|
+
onBlur={onBlur}
|
|
106
103
|
onFocus={onFocus}
|
|
107
104
|
placeholder={placeholder}
|
|
108
105
|
value={value}
|
|
109
106
|
disabled={disabled}
|
|
110
107
|
tabIndex={tabIndex}
|
|
111
108
|
autoFocus={autoFocus}
|
|
109
|
+
readOnly={readOnly}
|
|
112
110
|
/>
|
|
113
111
|
|
|
114
112
|
{renderFormError()}
|
|
@@ -2,7 +2,6 @@ export interface CustomInputProps {
|
|
|
2
2
|
name: string
|
|
3
3
|
value: string | number
|
|
4
4
|
onChange: (e: any) => void
|
|
5
|
-
onBlur?: (e: any) => void
|
|
6
5
|
onFocus?: (e: any) => void
|
|
7
6
|
autoComplete?: string
|
|
8
7
|
label?: React.ReactNode
|
|
@@ -20,7 +19,7 @@ export interface CustomInputProps {
|
|
|
20
19
|
linkText?: string
|
|
21
20
|
error?: string[] | string
|
|
22
21
|
helperText?: string;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
handleOnBlur?: (e) => void
|
|
23
|
+
readOnly?: boolean
|
|
24
|
+
noTrim?: boolean
|
|
26
25
|
}
|