@devtron-labs/devtron-fe-common-lib 0.0.60-beta-3 → 0.0.60-beta-6
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/SearchBar/SearchBar.component.d.ts +1 -1
- package/dist/Common/SearchBar/types.d.ts +4 -0
- package/dist/Common/Types.d.ts +0 -1
- package/dist/index.js +18 -10
- package/package.json +1 -1
- package/src/Common/SearchBar/SearchBar.component.tsx +25 -11
- package/src/Common/SearchBar/types.ts +4 -0
- package/src/Common/Types.ts +0 -1
|
@@ -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, }: SearchBarProps) => JSX.Element;
|
|
38
|
+
declare const SearchBar: ({ initialSearchText, handleSearchChange, handleEnter, inputProps, containerClassName, shouldDebounce, debounceTimeout, handleOnBlur, }: SearchBarProps) => JSX.Element;
|
|
39
39
|
export default SearchBar;
|
package/dist/Common/Types.d.ts
CHANGED
|
@@ -340,7 +340,6 @@ export interface CommonNodeAttr {
|
|
|
340
340
|
};
|
|
341
341
|
appReleaseTagNames?: string[];
|
|
342
342
|
tagsEditable?: boolean;
|
|
343
|
-
isGitOpsRepoNotConfigured?: boolean;
|
|
344
343
|
deploymentAppCreated?: boolean;
|
|
345
344
|
isLast?: boolean;
|
|
346
345
|
downstreamEnvironments?: DownstreamNodesEnvironmentsType[];
|
package/dist/index.js
CHANGED
|
@@ -24685,13 +24685,28 @@ styleInject(css_248z$5);
|
|
|
24685
24685
|
* ```
|
|
24686
24686
|
*/
|
|
24687
24687
|
var SearchBar = function (_a) {
|
|
24688
|
-
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;
|
|
24688
|
+
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, handleOnBlur = _a.handleOnBlur;
|
|
24689
24689
|
var _h = __read(React.useState(!!initialSearchText), 2), showClearButton = _h[0], setShowClearButton = _h[1];
|
|
24690
24690
|
var inputRef = React.useRef();
|
|
24691
24691
|
var debouncedSearchChange = React.useCallback(debounce$2(handleSearchChange, debounceTimeout), [
|
|
24692
24692
|
handleSearchChange,
|
|
24693
24693
|
debounceTimeout,
|
|
24694
24694
|
]);
|
|
24695
|
+
// assuming initialSearchText will change if we are changing history otherwise will be constant and will not change
|
|
24696
|
+
// since on changing history we expect to make api call using useAsync so not applying handleEnter
|
|
24697
|
+
React.useEffect(function () {
|
|
24698
|
+
inputRef.current.value = initialSearchText;
|
|
24699
|
+
setShowClearButton(!!initialSearchText);
|
|
24700
|
+
}, [initialSearchText]);
|
|
24701
|
+
var _applySearch = function (value) {
|
|
24702
|
+
handleSearchChange(value);
|
|
24703
|
+
handleEnter(value);
|
|
24704
|
+
};
|
|
24705
|
+
var clearSearch = function () {
|
|
24706
|
+
inputRef.current.value = '';
|
|
24707
|
+
_applySearch('');
|
|
24708
|
+
setShowClearButton(false);
|
|
24709
|
+
};
|
|
24695
24710
|
var handleChange = function (e) {
|
|
24696
24711
|
var value = e.target.value;
|
|
24697
24712
|
setShowClearButton(!!value);
|
|
@@ -24702,23 +24717,16 @@ var SearchBar = function (_a) {
|
|
|
24702
24717
|
handleSearchChange(value);
|
|
24703
24718
|
}
|
|
24704
24719
|
};
|
|
24705
|
-
var _applySearch = function (value) {
|
|
24706
|
-
handleSearchChange(value);
|
|
24707
|
-
handleEnter(value);
|
|
24708
|
-
};
|
|
24709
24720
|
var handleKeyDown = function (e) {
|
|
24710
24721
|
var key = e.key;
|
|
24711
24722
|
if (key === 'Enter') {
|
|
24723
|
+
e.preventDefault();
|
|
24712
24724
|
var inputTarget = e.target;
|
|
24713
24725
|
var value = inputTarget.value.trim();
|
|
24714
24726
|
_applySearch(value);
|
|
24715
24727
|
}
|
|
24716
24728
|
};
|
|
24717
|
-
|
|
24718
|
-
inputRef.current.value = '';
|
|
24719
|
-
_applySearch('');
|
|
24720
|
-
};
|
|
24721
|
-
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: "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" }) })))] })) })));
|
|
24729
|
+
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: "Search", "data-testid": "search-bar", type: "text" }, inputProps, { defaultValue: initialSearchText, className: "search-bar__input bc-n50 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, onBlur: handleOnBlur })), 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" }) })))] })) })));
|
|
24722
24730
|
};
|
|
24723
24731
|
|
|
24724
24732
|
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}";
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeEvent, useCallback, useRef, useState, KeyboardEvent } from 'react'
|
|
1
|
+
import { ChangeEvent, useCallback, useRef, useState, KeyboardEvent, useEffect } from 'react'
|
|
2
2
|
import { ReactComponent as Search } from '../../Assets/Icon/ic-search.svg'
|
|
3
3
|
import { ReactComponent as Clear } from '../../Assets/Icon/ic-error-cross.svg'
|
|
4
4
|
import { SearchBarProps } from './types'
|
|
@@ -47,6 +47,7 @@ const SearchBar = ({
|
|
|
47
47
|
containerClassName,
|
|
48
48
|
shouldDebounce = false,
|
|
49
49
|
debounceTimeout = 300,
|
|
50
|
+
handleOnBlur,
|
|
50
51
|
}: SearchBarProps) => {
|
|
51
52
|
const [showClearButton, setShowClearButton] = useState(!!initialSearchText)
|
|
52
53
|
const inputRef = useRef<HTMLInputElement>()
|
|
@@ -55,9 +56,28 @@ const SearchBar = ({
|
|
|
55
56
|
debounceTimeout,
|
|
56
57
|
])
|
|
57
58
|
|
|
59
|
+
// assuming initialSearchText will change if we are changing history otherwise will be constant and will not change
|
|
60
|
+
// since on changing history we expect to make api call using useAsync so not applying handleEnter
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
inputRef.current.value = initialSearchText
|
|
63
|
+
setShowClearButton(!!initialSearchText)
|
|
64
|
+
}, [initialSearchText])
|
|
65
|
+
|
|
66
|
+
const _applySearch = (value: string) => {
|
|
67
|
+
handleSearchChange(value)
|
|
68
|
+
handleEnter(value)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const clearSearch = () => {
|
|
72
|
+
inputRef.current.value = ''
|
|
73
|
+
_applySearch('')
|
|
74
|
+
setShowClearButton(false)
|
|
75
|
+
}
|
|
76
|
+
|
|
58
77
|
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
|
|
59
78
|
const { value } = e.target
|
|
60
79
|
setShowClearButton(!!value)
|
|
80
|
+
|
|
61
81
|
if (shouldDebounce) {
|
|
62
82
|
debouncedSearchChange(value)
|
|
63
83
|
} else {
|
|
@@ -65,25 +85,17 @@ const SearchBar = ({
|
|
|
65
85
|
}
|
|
66
86
|
}
|
|
67
87
|
|
|
68
|
-
const _applySearch = (value: string) => {
|
|
69
|
-
handleSearchChange(value)
|
|
70
|
-
handleEnter(value)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
88
|
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
|
74
89
|
const { key } = e
|
|
75
90
|
|
|
76
91
|
if (key === 'Enter') {
|
|
92
|
+
e.preventDefault()
|
|
77
93
|
const inputTarget = e.target as HTMLInputElement
|
|
78
94
|
const value = inputTarget.value.trim()
|
|
79
95
|
_applySearch(value)
|
|
80
96
|
}
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
const clearSearch = () => {
|
|
84
|
-
inputRef.current.value = ''
|
|
85
|
-
_applySearch('')
|
|
86
|
-
}
|
|
87
99
|
return (
|
|
88
100
|
<div className={containerClassName}>
|
|
89
101
|
<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">
|
|
@@ -94,13 +106,15 @@ const SearchBar = ({
|
|
|
94
106
|
type="text"
|
|
95
107
|
{...inputProps}
|
|
96
108
|
defaultValue={initialSearchText}
|
|
97
|
-
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 ${
|
|
109
|
+
className={`search-bar__input bc-n50 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 ${
|
|
98
110
|
showClearButton ? 'pr-30' : 'pr-10'
|
|
99
111
|
}`}
|
|
100
112
|
onChange={handleChange}
|
|
101
113
|
onKeyDown={handleKeyDown}
|
|
102
114
|
ref={inputRef}
|
|
115
|
+
onBlur={handleOnBlur}
|
|
103
116
|
/>
|
|
117
|
+
{/* TODO: Sync with product since it should have ic-enter in case of not applied */}
|
|
104
118
|
{showClearButton && (
|
|
105
119
|
<button
|
|
106
120
|
className="flex search-bar__clear-button dc__position-abs dc__transparent mt-0 mb-0 mr-5 ml-5"
|
package/src/Common/Types.ts
CHANGED
|
@@ -373,7 +373,6 @@ export interface CommonNodeAttr {
|
|
|
373
373
|
}
|
|
374
374
|
appReleaseTagNames?: string[]
|
|
375
375
|
tagsEditable?: boolean
|
|
376
|
-
isGitOpsRepoNotConfigured?: boolean
|
|
377
376
|
deploymentAppCreated?: boolean
|
|
378
377
|
isLast?: boolean
|
|
379
378
|
downstreamEnvironments?: DownstreamNodesEnvironmentsType[]
|