@devtron-labs/devtron-fe-common-lib 0.0.45-beta-9 → 0.0.45-beta-11

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, onBlur, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, showLink, linkText, link, helperText, state, setState, handleBlurChange }: CustomInputProps): JSX.Element;
3
+ export declare function CustomInput({ name, value, error, onChange, onBlur, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, showLink, linkText, link, helperText, state, handleBlurChange }: CustomInputProps): JSX.Element;
@@ -23,5 +23,5 @@ export interface CustomInputProps {
23
23
  helperText?: string;
24
24
  state?: any;
25
25
  setState?: any;
26
- handleBlurChange?: () => void;
26
+ handleBlurChange?: (e: any) => void;
27
27
  }
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; _a.onBlur; var _c = _a.onFocus, onFocus = _c === void 0 ? function (e) { } : _c, _d = _a.label, label = _d === void 0 ? '' : _d, _e = _a.type, type = _e === void 0 ? 'text' : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.labelClassName, labelClassName = _g === void 0 ? '' : _g, _h = _a.placeholder, placeholder = _h === void 0 ? '' : _h, _j = _a.tabIndex, tabIndex = _j === void 0 ? 1 : _j, _k = _a.dataTestid, dataTestid = _k === void 0 ? '' : _k, _l = _a.isRequiredField, isRequiredField = _l === void 0 ? false : _l, _m = _a.autoFocus, autoFocus = _m === void 0 ? true : _m, _o = _a.rootClassName, rootClassName = _o === void 0 ? '' : _o, _p = _a.autoComplete, autoComplete = _p === void 0 ? 'off' : _p, _q = _a.showLink, showLink = _q === void 0 ? false : _q, _r = _a.linkText, linkText = _r === void 0 ? '' : _r, _s = _a.link, link = _s === void 0 ? '' : _s, _t = _a.helperText, helperText = _t === void 0 ? '' : _t, state = _a.state, setState = _a.setState, handleBlurChange = _a.handleBlurChange;
26627
+ var name = _a.name, value = _a.value, error = _a.error, onChange = _a.onChange; _a.onBlur; var _c = _a.onFocus, onFocus = _c === void 0 ? function (e) { } : _c, _d = _a.label, label = _d === void 0 ? '' : _d, _e = _a.type, type = _e === void 0 ? 'text' : _e, _f = _a.disabled, disabled = _f === void 0 ? false : _f, _g = _a.labelClassName, labelClassName = _g === void 0 ? '' : _g, _h = _a.placeholder, placeholder = _h === void 0 ? '' : _h, _j = _a.tabIndex, tabIndex = _j === void 0 ? 1 : _j, _k = _a.dataTestid, dataTestid = _k === void 0 ? '' : _k, _l = _a.isRequiredField, isRequiredField = _l === void 0 ? false : _l, _m = _a.autoFocus, autoFocus = _m === void 0 ? true : _m, _o = _a.rootClassName, rootClassName = _o === void 0 ? '' : _o, _p = _a.autoComplete, autoComplete = _p === void 0 ? 'off' : _p, _q = _a.showLink, showLink = _q === void 0 ? false : _q, _r = _a.linkText, linkText = _r === void 0 ? '' : _r, _s = _a.link, link = _s === void 0 ? '' : _s, _t = _a.helperText, helperText = _t === void 0 ? '' : _t; _a.state; var handleBlurChange = _a.handleBlurChange;
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
  };
@@ -26638,14 +26638,9 @@ function CustomInput(_a) {
26638
26638
  return error;
26639
26639
  }
26640
26640
  var handleOnBlur = function (event) {
26641
+ onChange(__assign(__assign({}, event), { target: __assign(__assign({}, event.target), { value: event.target.value.trim() }) }));
26641
26642
  if (typeof handleBlurChange === 'function') {
26642
- handleBlurChange();
26643
- }
26644
- if (state) {
26645
- setState(function (prevState) {
26646
- var _a;
26647
- return (__assign(__assign({}, prevState), (_a = {}, _a[event.target.name] = __assign(__assign({}, prevState[event.target.name]), { value: event.target.value.trim() }), _a)));
26648
- });
26643
+ handleBlurChange(__assign(__assign({}, event), { target: __assign(__assign({}, event.target), { value: event.target.value.trim() }) }));
26649
26644
  }
26650
26645
  };
26651
26646
  var renderFormError = function () {
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-9",
3
+ "version": "0.0.45-beta-11",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -1,6 +1,7 @@
1
1
  import { CustomInputProps } from './Types'
2
2
  import { ReactComponent as Info } from '../../Assets/Icon/ic-info-filled.svg'
3
3
  import { ReactComponent as FormError } from '../../Assets/Icon/ic-warning.svg'
4
+ import { useState } from 'react'
4
5
 
5
6
  export function CustomInput({
6
7
  name,
@@ -25,9 +26,9 @@ export function CustomInput({
25
26
  link = '',
26
27
  helperText = '',
27
28
  state,
28
- setState,
29
29
  handleBlurChange
30
30
  }: CustomInputProps) {
31
+
31
32
  const renderLabelHelperText = () => {
32
33
  return (
33
34
  <span>
@@ -51,18 +52,22 @@ export function CustomInput({
51
52
  }
52
53
 
53
54
  const handleOnBlur = (event) => {
54
- if(typeof handleBlurChange === 'function') {
55
- handleBlurChange()
56
- }
57
-
58
- if (state) {
59
- setState((prevState) => ({
60
- ...prevState,
61
- [event.target.name]: {
62
- ...prevState[event.target.name],
63
- value: event.target.value.trim(),
64
- },
65
- }))
55
+
56
+ onChange({
57
+ ...event,
58
+ target: {
59
+ ...event.target,
60
+ value: event.target.value.trim(),
61
+ },
62
+ })
63
+ if (typeof handleBlurChange === 'function') {
64
+ handleBlurChange({
65
+ ...event,
66
+ target: {
67
+ ...event.target,
68
+ value: event.target.value.trim(),
69
+ },
70
+ })
66
71
  }
67
72
 
68
73
  }
@@ -22,5 +22,5 @@ export interface CustomInputProps {
22
22
  helperText?: string;
23
23
  state?;
24
24
  setState?;
25
- handleBlurChange?: () => void
25
+ handleBlurChange?: (e) => void
26
26
  }