@devtron-labs/devtron-fe-common-lib 0.0.58-beta-21 → 0.0.58-beta-24

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, helperText, handleOnBlur, readOnly, noTrim, ref, onKeyPress, defaultValue, onKeyDown, required, additionalErrorInfo, inputWrapClassName, dataIndex, }: CustomInputProps): JSX.Element;
3
+ export declare function CustomInput({ name, value, error, onChange, onFocus, label, type, disabled, labelClassName, placeholder, tabIndex, dataTestid, isRequiredField, autoFocus, rootClassName, autoComplete, helperText, handleOnBlur, readOnly, noTrim, ref, onKeyPress, defaultValue, onKeyDown, required, additionalErrorInfo, inputWrapClassName, inputProps, }: CustomInputProps): JSX.Element;
@@ -1,4 +1,4 @@
1
- import React, { HTMLInputTypeAttribute } from 'react';
1
+ import React, { HTMLInputTypeAttribute, InputHTMLAttributes } from 'react';
2
2
  export interface CustomInputProps {
3
3
  name: string;
4
4
  value: string | number;
@@ -27,5 +27,5 @@ export interface CustomInputProps {
27
27
  required?: boolean;
28
28
  additionalErrorInfo?: React.ReactNode;
29
29
  inputWrapClassName?: string;
30
- dataIndex?: string;
30
+ inputProps?: InputHTMLAttributes<HTMLInputElement>;
31
31
  }
@@ -35,5 +35,5 @@ import './searchBar.scss';
35
35
  * <SearchBar inputProps={{ placeholder: 'Enter search text' }} />
36
36
  * ```
37
37
  */
38
- declare const SearchBar: ({ initialSearchText, handleSearchChange, handleEnter, inputProps, containerClassName, shouldDebounce, debounceTimeout, searchIconClassName, }: SearchBarProps) => JSX.Element;
38
+ declare const SearchBar: ({ initialSearchText, handleSearchChange, handleEnter, inputProps, containerClassName, shouldDebounce, debounceTimeout, }: SearchBarProps) => JSX.Element;
39
39
  export default SearchBar;
@@ -32,9 +32,4 @@ export interface SearchBarProps {
32
32
  * Timeout for the debounce handler to be triggered
33
33
  */
34
34
  debounceTimeout?: number;
35
- /**
36
- * Placeholder for the search input
37
- * @default 'Search'
38
- */
39
- searchIconClassName?: string;
40
35
  }
package/dist/index.js CHANGED
@@ -24668,8 +24668,8 @@ styleInject(css_248z$5);
24668
24668
  * ```
24669
24669
  */
24670
24670
  var SearchBar = function (_a) {
24671
- var _b = _a.initialSearchText, initialSearchText = _b === void 0 ? '' : _b, _c = _a.handleSearchChange, handleSearchChange = _c === void 0 ? function () { } : _c, _d = _a.handleEnter, handleEnter = _d === void 0 ? function () { } : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, containerClassName = _a.containerClassName, _f = _a.shouldDebounce, shouldDebounce = _f === void 0 ? false : _f, _g = _a.debounceTimeout, debounceTimeout = _g === void 0 ? 300 : _g, _h = _a.searchIconClassName, searchIconClassName = _h === void 0 ? '' : _h;
24672
- var _j = __read(React.useState(!!initialSearchText), 2), showClearButton = _j[0], setShowClearButton = _j[1];
24671
+ var _b = _a.initialSearchText, initialSearchText = _b === void 0 ? '' : _b, _c = _a.handleSearchChange, handleSearchChange = _c === void 0 ? function () { } : _c, _d = _a.handleEnter, handleEnter = _d === void 0 ? function () { } : _d, _e = _a.inputProps, inputProps = _e === void 0 ? {} : _e, containerClassName = _a.containerClassName, _f = _a.shouldDebounce, shouldDebounce = _f === void 0 ? false : _f, _g = _a.debounceTimeout, debounceTimeout = _g === void 0 ? 300 : _g;
24672
+ var _h = __read(React.useState(!!initialSearchText), 2), showClearButton = _h[0], setShowClearButton = _h[1];
24673
24673
  var inputRef = React.useRef();
24674
24674
  var debouncedSearchChange = React.useCallback(debounce$2(handleSearchChange, debounceTimeout), [
24675
24675
  handleSearchChange,
@@ -24701,7 +24701,7 @@ var SearchBar = function (_a) {
24701
24701
  inputRef.current.value = '';
24702
24702
  _applySearch('');
24703
24703
  };
24704
- return (jsxRuntime.jsx("div", __assign({ className: containerClassName }, { children: jsxRuntime.jsxs("div", __assign({ className: "search-bar bc-n50 focus-within-border-b5 dc__hover-border-n300 dc__block w-100 min-w-200 dc__position-rel en-2 bw-1 br-4 h-32" }, { children: [jsxRuntime.jsx(SvgIcSearch, { className: "search-bar__icon dc__position-abs icon-color-n6 icon-dim-16 ".concat(searchIconClassName) }), jsxRuntime.jsx("input", __assign({ placeholder: inputProps.placeholder || 'Search', "data-testid": "search-bar", type: "text" }, inputProps, { defaultValue: initialSearchText, className: "search-bar__input dc__position-abs w-100 h-100 br-4 dc__no-border pt-6 pr-10 pb-6 pl-30 fs-13 lh-20 fw-4 cn-9 placeholder-cn5 ".concat(showClearButton ? 'pr-30' : 'pr-10'), onChange: handleChange, onKeyDown: handleKeyDown, ref: inputRef })), showClearButton && (jsxRuntime.jsx("button", __assign({ className: "flex search-bar__clear-button dc__position-abs dc__transparent mt-0 mb-0 mr-5 ml-5", type: "button", onClick: clearSearch, "aria-label": "Clear search" }, { children: jsxRuntime.jsx(SvgIcErrorCross, { className: "icon-dim-18 icon-n4 dc__vertical-align-middle" }) })))] })) })));
24704
+ return (jsxRuntime.jsx("div", __assign({ className: containerClassName }, { children: jsxRuntime.jsxs("div", __assign({ className: "search-bar bc-n50 focus-within-border-b5 dc__hover-border-n300 dc__block w-100 min-w-200 dc__position-rel en-2 bw-1 br-4 h-32" }, { children: [jsxRuntime.jsx(SvgIcSearch, { className: "search-bar__icon dc__position-abs icon-color-n6 icon-dim-16" }), jsxRuntime.jsx("input", __assign({ placeholder: inputProps.placeholder || 'Search', "data-testid": "search-bar", type: "text" }, inputProps, { defaultValue: initialSearchText, className: "search-bar__input dc__position-abs w-100 h-100 br-4 dc__no-border pt-6 pr-10 pb-6 pl-30 fs-13 lh-20 fw-4 cn-9 placeholder-cn5 ".concat(showClearButton ? 'pr-30' : 'pr-10'), onChange: handleChange, onKeyDown: handleKeyDown, ref: inputRef })), showClearButton && (jsxRuntime.jsx("button", __assign({ className: "flex search-bar__clear-button dc__position-abs dc__transparent mt-0 mb-0 mr-5 ml-5", type: "button", onClick: clearSearch, "aria-label": "Clear search" }, { children: jsxRuntime.jsx(SvgIcErrorCross, { className: "icon-dim-16 icon-n4 dc__vertical-align-middle" }) })))] })) })));
24705
24705
  };
24706
24706
 
24707
24707
  var css_248z$4 = ".toggle__switch {\n position: relative;\n display: inline-block;\n width: 100%;\n height: 100%;\n}\n.toggle__switch.disabled {\n cursor: not-allowed;\n}\n.toggle__switch.disabled .toggle__slider {\n cursor: not-allowed;\n}\n\n/* Hide default HTML checkbox */\n.toggle__switch input {\n opacity: 0;\n width: 0;\n height: 0;\n}\n\n/* The slider */\n.toggle__slider {\n position: absolute;\n cursor: pointer;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: #ccc;\n transition: all 0.4s ease;\n}\n.toggle__slider.round {\n border-radius: 34px;\n}\n.toggle__slider.round:before {\n border-radius: 50%;\n}\n.toggle__slider:before {\n position: absolute;\n content: \"\";\n height: calc(100% - 8px);\n width: calc(50% - 4px);\n left: 4px;\n bottom: 4px;\n background-color: white;\n transition: all 0.4s ease;\n}\n.toggle__slider.with-icon {\n background-color: var(--N000) !important;\n}\n.toggle__slider.with-icon svg {\n position: absolute;\n content: \"\";\n top: -1px;\n left: -1px;\n background-color: var(--N300);\n transition: all 0.4s ease;\n}\n\ninput:checked + .toggle__slider {\n background-color: var(--color);\n}\ninput:checked + .toggle__slider:before {\n transform: translateX(100%);\n}\ninput:checked + .toggle__slider.with-icon svg {\n transform: translateX(100%);\n background-color: var(--color);\n}\n\ninput:focus + .toggle__slider {\n box-shadow: 0 0 1px var(--color);\n}";
@@ -28485,7 +28485,7 @@ var handleAddCD = function (_a) {
28485
28485
  };
28486
28486
 
28487
28487
  function CustomInput(_a) {
28488
- var name = _a.name, value = _a.value, error = _a.error, onChange = _a.onChange, _b = _a.onFocus, onFocus = _b === void 0 ? function (e) { } : _b, label = _a.label, _c = _a.type, type = _c === void 0 ? 'text' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.labelClassName, labelClassName = _e === void 0 ? '' : _e, _f = _a.placeholder, placeholder = _f === void 0 ? '' : _f, _g = _a.tabIndex, tabIndex = _g === void 0 ? 1 : _g, _h = _a.dataTestid, dataTestid = _h === void 0 ? '' : _h, _j = _a.isRequiredField, isRequiredField = _j === void 0 ? false : _j, _k = _a.autoFocus, autoFocus = _k === void 0 ? false : _k, _l = _a.rootClassName, rootClassName = _l === void 0 ? '' : _l, _m = _a.autoComplete, autoComplete = _m === void 0 ? 'off' : _m, _o = _a.helperText, helperText = _o === void 0 ? '' : _o, handleOnBlur = _a.handleOnBlur, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.noTrim, noTrim = _q === void 0 ? false : _q, ref = _a.ref, onKeyPress = _a.onKeyPress, defaultValue = _a.defaultValue, onKeyDown = _a.onKeyDown, required = _a.required, additionalErrorInfo = _a.additionalErrorInfo, _r = _a.inputWrapClassName, inputWrapClassName = _r === void 0 ? '' : _r, _s = _a.dataIndex, dataIndex = _s === void 0 ? '' : _s;
28488
+ var name = _a.name, value = _a.value, error = _a.error, onChange = _a.onChange, _b = _a.onFocus, onFocus = _b === void 0 ? function (e) { } : _b, label = _a.label, _c = _a.type, type = _c === void 0 ? 'text' : _c, _d = _a.disabled, disabled = _d === void 0 ? false : _d, _e = _a.labelClassName, labelClassName = _e === void 0 ? '' : _e, _f = _a.placeholder, placeholder = _f === void 0 ? '' : _f, _g = _a.tabIndex, tabIndex = _g === void 0 ? 1 : _g, _h = _a.dataTestid, dataTestid = _h === void 0 ? '' : _h, _j = _a.isRequiredField, isRequiredField = _j === void 0 ? false : _j, _k = _a.autoFocus, autoFocus = _k === void 0 ? false : _k, _l = _a.rootClassName, rootClassName = _l === void 0 ? '' : _l, _m = _a.autoComplete, autoComplete = _m === void 0 ? 'off' : _m, _o = _a.helperText, helperText = _o === void 0 ? '' : _o, handleOnBlur = _a.handleOnBlur, _p = _a.readOnly, readOnly = _p === void 0 ? false : _p, _q = _a.noTrim, noTrim = _q === void 0 ? false : _q, ref = _a.ref, onKeyPress = _a.onKeyPress, defaultValue = _a.defaultValue, onKeyDown = _a.onKeyDown, required = _a.required, additionalErrorInfo = _a.additionalErrorInfo, _r = _a.inputWrapClassName, inputWrapClassName = _r === void 0 ? '' : _r, _s = _a.inputProps, inputProps = _s === void 0 ? {} : _s;
28489
28489
  function handleError(error) {
28490
28490
  if (!Array.isArray(error)) {
28491
28491
  return [error];
@@ -28534,10 +28534,10 @@ function CustomInput(_a) {
28534
28534
  return (jsxRuntime.jsx("label", __assign({ className: "form__label ".concat(labelClassName), "data-testid": "label-".concat(dataTestid) }, { children: renderInputLabelConditionally() })));
28535
28535
  }
28536
28536
  };
28537
- return (jsxRuntime.jsxs("div", __assign({ className: "flex column left top ".concat(inputWrapClassName) }, { children: [renderInputLabel(), jsxRuntime.jsx("input", { "data-testid": dataTestid, "data-index": dataIndex, type: type, name: name, autoComplete: autoComplete, className: "form__input ".concat(rootClassName), onChange: function (e) {
28537
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex column left top ".concat(inputWrapClassName) }, { children: [renderInputLabel(), jsxRuntime.jsx("input", __assign({ "data-testid": dataTestid, type: type, name: name, autoComplete: autoComplete, className: "form__input ".concat(rootClassName), onChange: function (e) {
28538
28538
  e.persist();
28539
28539
  onChange(e);
28540
- }, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex, autoFocus: autoFocus, readOnly: readOnly, ref: ref, onKeyPress: onKeyPress, defaultValue: defaultValue, onKeyDown: onKeyDown, required: required }), getInputError(), 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 }))] })))] })));
28540
+ }, onBlur: onBlur, onFocus: onFocus, placeholder: placeholder, value: value, disabled: disabled, tabIndex: tabIndex, autoFocus: autoFocus, readOnly: readOnly, ref: ref, onKeyPress: onKeyPress, defaultValue: defaultValue, onKeyDown: onKeyDown, required: required }, inputProps)), getInputError(), 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 }))] })))] })));
28541
28541
  }
28542
28542
 
28543
28543
  exports.DraggablePositionVariant = void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.58-beta-21",
3
+ "version": "0.0.58-beta-24",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -30,7 +30,7 @@ export function CustomInput({
30
30
  required,
31
31
  additionalErrorInfo,
32
32
  inputWrapClassName = '',
33
- dataIndex = '',
33
+ inputProps = {},
34
34
  }: CustomInputProps) {
35
35
  function handleError(error: any): any[] {
36
36
  if (!Array.isArray(error)) {
@@ -97,7 +97,6 @@ export function CustomInput({
97
97
  {renderInputLabel()}
98
98
  <input
99
99
  data-testid={dataTestid}
100
- data-index={dataIndex}
101
100
  type={type}
102
101
  name={name}
103
102
  autoComplete={autoComplete}
@@ -119,6 +118,7 @@ export function CustomInput({
119
118
  defaultValue={defaultValue}
120
119
  onKeyDown={onKeyDown}
121
120
  required={required}
121
+ {...inputProps}
122
122
  />
123
123
 
124
124
  {getInputError()}
@@ -1,4 +1,4 @@
1
- import React, { HTMLInputTypeAttribute } from 'react'
1
+ import React, { HTMLInputTypeAttribute, InputHTMLAttributes } from 'react'
2
2
 
3
3
  export interface CustomInputProps {
4
4
  name: string
@@ -6,7 +6,7 @@ export interface CustomInputProps {
6
6
  onChange: (e: any) => void
7
7
  onFocus?: (e: any) => void
8
8
  autoComplete?: string
9
- label?: string | React.ReactNode
9
+ label?: string | React.ReactNode
10
10
  labelClassName?: string
11
11
  type?: HTMLInputTypeAttribute
12
12
  disabled?: boolean
@@ -28,5 +28,5 @@ export interface CustomInputProps {
28
28
  required?: boolean
29
29
  additionalErrorInfo?: React.ReactNode
30
30
  inputWrapClassName?: string
31
- dataIndex?: string
32
- }
31
+ inputProps?: InputHTMLAttributes<HTMLInputElement>
32
+ }
@@ -47,7 +47,6 @@ const SearchBar = ({
47
47
  containerClassName,
48
48
  shouldDebounce = false,
49
49
  debounceTimeout = 300,
50
- searchIconClassName = '',
51
50
  }: SearchBarProps) => {
52
51
  const [showClearButton, setShowClearButton] = useState(!!initialSearchText)
53
52
  const inputRef = useRef<HTMLInputElement>()
@@ -88,9 +87,7 @@ const SearchBar = ({
88
87
  return (
89
88
  <div className={containerClassName}>
90
89
  <div className="search-bar bc-n50 focus-within-border-b5 dc__hover-border-n300 dc__block w-100 min-w-200 dc__position-rel en-2 bw-1 br-4 h-32">
91
- <Search
92
- className={`search-bar__icon dc__position-abs icon-color-n6 icon-dim-16 ${searchIconClassName}`}
93
- />
90
+ <Search className="search-bar__icon dc__position-abs icon-color-n6 icon-dim-16" />
94
91
  <input
95
92
  placeholder={inputProps.placeholder || 'Search'}
96
93
  data-testid="search-bar"
@@ -111,7 +108,7 @@ const SearchBar = ({
111
108
  onClick={clearSearch}
112
109
  aria-label="Clear search"
113
110
  >
114
- <Clear className="icon-dim-18 icon-n4 dc__vertical-align-middle" />
111
+ <Clear className="icon-dim-16 icon-n4 dc__vertical-align-middle" />
115
112
  </button>
116
113
  )}
117
114
  </div>
@@ -33,9 +33,4 @@ export interface SearchBarProps {
33
33
  * Timeout for the debounce handler to be triggered
34
34
  */
35
35
  debounceTimeout?: number
36
- /**
37
- * Placeholder for the search input
38
- * @default 'Search'
39
- */
40
- searchIconClassName?: string
41
36
  }