@devtron-labs/devtron-fe-common-lib 0.0.45-beta-13 → 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, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, showLink, linkText, link, helperText, handleBlurChange, }: CustomInputProps): JSX.Element;
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;
@@ -20,5 +20,7 @@ export interface CustomInputProps {
20
20
  linkText?: string;
21
21
  error?: string[] | string;
22
22
  helperText?: string;
23
- handleBlurChange?: (e: any) => void;
23
+ handleOnBlur?: (e: any) => void;
24
+ readOnly?: boolean;
25
+ noTrim?: boolean;
24
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, _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, handleBlurChange = _a.handleBlurChange;
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,13 +26637,16 @@ function CustomInput(_a) {
26637
26637
  }
26638
26638
  return error;
26639
26639
  }
26640
- var handleOnBlur = function (event) {
26640
+ var onBlur = function (event) {
26641
26641
  var _a;
26642
- event.stopPropagation();
26643
- event.target.value = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
26644
- onChange(event);
26645
- if (typeof handleBlurChange === 'function') {
26646
- handleBlurChange(event);
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);
26647
+ }
26648
+ if (typeof handleOnBlur === 'function') {
26649
+ handleOnBlur(event);
26647
26650
  }
26648
26651
  };
26649
26652
  var renderFormError = function () {
@@ -26657,7 +26660,7 @@ function CustomInput(_a) {
26657
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) {
26658
26661
  e.persist();
26659
26662
  onChange(e);
26660
- }, onBlur: handleOnBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex, autoFocus: autoFocus }), 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 }))] })))] })));
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 }))] })))] })));
26661
26664
  }
26662
26665
 
26663
26666
  exports.AppStatus = AppStatus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.45-beta-13",
3
+ "version": "0.0.45-beta-14",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -24,7 +24,9 @@ export function CustomInput({
24
24
  linkText = '',
25
25
  link = '',
26
26
  helperText = '',
27
- handleBlurChange,
27
+ handleOnBlur,
28
+ readOnly = false,
29
+ noTrim = false,
28
30
  }: CustomInputProps) {
29
31
  const renderLabelHelperText = () => {
30
32
  return (
@@ -48,12 +50,15 @@ export function CustomInput({
48
50
  return error
49
51
  }
50
52
 
51
- const handleOnBlur = (event) => {
52
- event.stopPropagation()
53
- event.target.value = event.target.value?.trim()
54
- onChange(event)
55
- if (typeof handleBlurChange === 'function') {
56
- handleBlurChange(event)
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)
57
62
  }
58
63
  }
59
64
 
@@ -94,13 +99,14 @@ export function CustomInput({
94
99
  e.persist()
95
100
  onChange(e)
96
101
  }}
97
- onBlur={handleOnBlur}
102
+ onBlur={onBlur}
98
103
  onFocus={onFocus}
99
104
  placeholder={placeholder}
100
105
  value={value}
101
106
  disabled={disabled}
102
107
  tabIndex={tabIndex}
103
108
  autoFocus={autoFocus}
109
+ readOnly={readOnly}
104
110
  />
105
111
 
106
112
  {renderFormError()}
@@ -19,5 +19,7 @@ export interface CustomInputProps {
19
19
  linkText?: string
20
20
  error?: string[] | string
21
21
  helperText?: string;
22
- handleBlurChange?: (e) => void
22
+ handleOnBlur?: (e) => void
23
+ readOnly?: boolean
24
+ noTrim?: boolean
23
25
  }