@devtron-labs/devtron-fe-common-lib 0.0.6-beta-15 → 0.0.6-beta-16
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/CustomTagSelector/TagLabelValueSelector.d.ts +2 -2
- package/dist/index.js +14 -14
- package/package.json +2 -1
- package/src/Common/BreadCrumb/BreadCrumb.tsx +77 -57
- package/src/Common/CustomTagSelector/TagDetails.tsx +1 -1
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { OptionType, TagType } from '../Types';
|
|
3
|
-
export
|
|
3
|
+
export declare const TagLabelValueSelector: ({ selectedTagIndex, tagData, setTagData, tagOptions, isRequired, type, }: {
|
|
4
4
|
selectedTagIndex: number;
|
|
5
5
|
tagData: TagType;
|
|
6
6
|
setTagData: (index: number, tagData: TagType) => void;
|
|
7
7
|
tagOptions?: OptionType[];
|
|
8
8
|
isRequired?: boolean;
|
|
9
9
|
type?: string;
|
|
10
|
-
})
|
|
10
|
+
}) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -4049,7 +4049,7 @@ function useBreadcrumbContext() {
|
|
|
4049
4049
|
|
|
4050
4050
|
React__default.createContext(null);
|
|
4051
4051
|
function useBreadcrumb(props, deps) {
|
|
4052
|
-
var sep = (props === null || props === void 0 ? void 0 : props.sep) ||
|
|
4052
|
+
var sep = (props === null || props === void 0 ? void 0 : props.sep) || '/';
|
|
4053
4053
|
deps = deps || [];
|
|
4054
4054
|
var _a = useRouteMatch(), url = _a.url, path = _a.path;
|
|
4055
4055
|
var params = useParams();
|
|
@@ -4071,12 +4071,12 @@ function useBreadcrumb(props, deps) {
|
|
|
4071
4071
|
setState(function (state) { return (__assign(__assign({}, state), { alias: tempAlias })); });
|
|
4072
4072
|
}
|
|
4073
4073
|
var levels = useMemo(function () {
|
|
4074
|
-
var paths = path.split(
|
|
4075
|
-
var urls = url.split(
|
|
4074
|
+
var paths = path.split('/').filter(Boolean);
|
|
4075
|
+
var urls = url.split('/').filter(Boolean);
|
|
4076
4076
|
return paths.map(function (path, idx) {
|
|
4077
4077
|
var crumb = { to: urls[idx], name: path };
|
|
4078
|
-
if (path.startsWith(
|
|
4079
|
-
crumb.className =
|
|
4078
|
+
if (path.startsWith(':') && params[path.replace(':', '')]) {
|
|
4079
|
+
crumb.className = 'param';
|
|
4080
4080
|
}
|
|
4081
4081
|
return crumb;
|
|
4082
4082
|
});
|
|
@@ -4091,22 +4091,22 @@ function useBreadcrumb(props, deps) {
|
|
|
4091
4091
|
? "".concat(prefix).concat(to)
|
|
4092
4092
|
: null,
|
|
4093
4093
|
name: typeof state.alias[name] === 'object'
|
|
4094
|
-
? !!((_d = state.alias[name]) === null || _d === void 0 ? void 0 : _d.component)
|
|
4094
|
+
? !!((_d = state.alias[name]) === null || _d === void 0 ? void 0 : _d.component)
|
|
4095
|
+
? state.alias[name].component
|
|
4096
|
+
: null
|
|
4095
4097
|
: state.alias[name] || name,
|
|
4096
4098
|
className: curr.className || '',
|
|
4097
4099
|
});
|
|
4098
4100
|
return { res: res, prefix: "".concat(prefix).concat(curr.to).concat(sep) };
|
|
4099
|
-
}, { res: [], prefix:
|
|
4101
|
+
}, { res: [], prefix: '/' });
|
|
4100
4102
|
}, [levels, state]).res;
|
|
4101
4103
|
return { breadcrumbs: breadcrumbs, setCrumb: setCrumb, resetCrumb: resetCrumb };
|
|
4102
4104
|
}
|
|
4103
4105
|
var BreadCrumb = function (_a) {
|
|
4104
|
-
var breadcrumbs = _a.breadcrumbs, _b = _a.sep, sep = _b === void 0 ?
|
|
4106
|
+
var breadcrumbs = _a.breadcrumbs, _b = _a.sep, sep = _b === void 0 ? '/' : _b, _c = _a.className, className = _c === void 0 ? 'dc__devtron-breadcrumb__item' : _c;
|
|
4105
4107
|
var url = useRouteMatch().url;
|
|
4106
4108
|
var filteredCrumbs = breadcrumbs.filter(function (crumb) { return !!crumb.name; });
|
|
4107
|
-
return jsx(React__default.Fragment, { children: filteredCrumbs.map(function (breadcrumb, idx) {
|
|
4108
|
-
return jsxs(React__default.Fragment, { children: [jsx(ConditionalWrap, __assign({ condition: !!breadcrumb.to, wrap: function (children) { return jsx(Link, __assign({ className: "".concat(url === breadcrumb.to ? 'active' : '', " ").concat(className, " ").concat(breadcrumb.className || ""), to: breadcrumb.to }, { children: children })); } }, { children: breadcrumb.name })), idx + 1 !== filteredCrumbs.length && breadcrumb.name && jsx("span", __assign({ className: "".concat(className, "__separator cn-5") }, { children: sep }))] }, idx);
|
|
4109
|
-
}) });
|
|
4109
|
+
return (jsx(React__default.Fragment, { children: filteredCrumbs.map(function (breadcrumb, idx) { return (jsxs(React__default.Fragment, { children: [jsx(ConditionalWrap, __assign({ condition: !!breadcrumb.to, wrap: function (children) { return (jsx(Link, __assign({ className: "".concat(url === breadcrumb.to ? 'active' : '', " ").concat(className, " ").concat(breadcrumb.className || ''), to: breadcrumb.to }, { children: children }))); } }, { children: breadcrumb.name })), idx + 1 !== filteredCrumbs.length && breadcrumb.name && (jsx("span", __assign({ className: "".concat(className, "__separator cn-5") }, { children: sep })))] }, idx)); }) }));
|
|
4110
4110
|
};
|
|
4111
4111
|
|
|
4112
4112
|
var RadioGroupContext = createContext({ name: '', value: '', disabled: false, onChange: function (event) { } });
|
|
@@ -8423,7 +8423,7 @@ var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
|
|
|
8423
8423
|
})));
|
|
8424
8424
|
};
|
|
8425
8425
|
|
|
8426
|
-
function
|
|
8426
|
+
var TagLabelValueSelector = function (_a) {
|
|
8427
8427
|
var selectedTagIndex = _a.selectedTagIndex, tagData = _a.tagData, setTagData = _a.setTagData, tagOptions = _a.tagOptions, isRequired = _a.isRequired, type = _a.type;
|
|
8428
8428
|
var _b = __read(useState(''), 2), selectedValue = _b[0], setSelectedValue = _b[1];
|
|
8429
8429
|
var _c = __read(useState(false), 2), isPopupOpen = _c[0], togglePopup = _c[1];
|
|
@@ -8493,7 +8493,7 @@ function TagLabelValueSelector(_a) {
|
|
|
8493
8493
|
return (jsxs(PopupMenu, __assign({ onToggleCallback: function (isOpen) { return togglePopup(isOpen); }, autoClose: true }, { children: [jsx(PopupMenu.Button, __assign({ rootClassName: "".concat(type === 'key'
|
|
8494
8494
|
? "dc__no-right-radius"
|
|
8495
8495
|
: "dc__no-border-radius dc__no-right-border dc__no-left-border", " ").concat(tagData[type === 'key' ? 'isInvalidKey' : 'isInvalidValue'] ? 'er-5 bw-1' : '') }, { children: jsx("input", { type: "text", className: "form__input pt-4-imp pb-4-imp dc__no-border", value: selectedValue, onChange: handleInputChange, onBlur: handleOnBlur }) })), jsx(PopupMenu.Body, __assign({ rootClassName: "tag-".concat(selectedTagIndex, "-class"), autoWidth: true }, { children: isPopupOpen && renderSuggestions() }))] })));
|
|
8496
|
-
}
|
|
8496
|
+
};
|
|
8497
8497
|
|
|
8498
8498
|
function TagDetails(_a) {
|
|
8499
8499
|
var index = _a.index, tagData = _a.tagData, setTagData = _a.setTagData, removeTag = _a.removeTag;
|
|
@@ -8615,4 +8615,4 @@ function ForceDeleteDialog(_a) {
|
|
|
8615
8615
|
return (jsx("div", { children: jsx(DeleteDialog, __assign({ title: forceDeleteDialogTitle, delete: onClickDelete, closeDelete: closeDeleteModal, deletePrefix: "Force " }, { children: jsxs(DeleteDialog.Description, { children: [jsxs("p", __assign({ className: "mt-12 mb-12 p-8 dc__break-word dc__window-bg" }, { children: ["Error: ", forceDeleteDialogMessage] })), jsx("p", { children: "Do you want to force delete?" })] }) })) }));
|
|
8616
8616
|
}
|
|
8617
8617
|
|
|
8618
|
-
export { BreadCrumb, Store as BreadcrumbStore, ConditionalWrap, ConfirmationDialog, DeleteDialog, DetailsProgressing, DialogForm, DialogFormSubmit, Drawer, ErrorScreenManager, ErrorScreenNotAuthorized, ForceDeleteDialog, Host, Modal, OpaqueModal, PATTERNS, PopupMenu, Progressing, RadioGroup, RadioGroupItem, RequestTimeout, ServerError, ServerErrors, TagLabelSelect, TippyCustomized, TippyTheme, ToastBody, ToastBody3, ToastBodyWithButton, VisibleModal, VisibleModal2, get, post, put, showError, toastAccessDenied, trash, useBreadcrumb };
|
|
8618
|
+
export { BreadCrumb, Store as BreadcrumbStore, ConditionalWrap, ConfirmationDialog, DeleteDialog, DetailsProgressing, DialogForm, DialogFormSubmit, Drawer, ErrorScreenManager, ErrorScreenNotAuthorized, ForceDeleteDialog, Host, Modal, OpaqueModal, PATTERNS, PopupMenu, Progressing, RadioGroup, RadioGroupItem, RequestTimeout, ServerError, ServerErrors, TagLabelSelect, TagLabelValueSelector, TippyCustomized, TippyTheme, ToastBody, ToastBody3, ToastBodyWithButton, VisibleModal, VisibleModal2, get, post, put, showError, toastAccessDenied, trash, useBreadcrumb };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devtron-labs/devtron-fe-common-lib",
|
|
3
|
-
"version": "0.0.6-beta-
|
|
3
|
+
"version": "0.0.6-beta-16",
|
|
4
4
|
"description": "Supporting common component library",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": "^17.0.2",
|
|
42
42
|
"react-dom": "^17.0.2",
|
|
43
|
+
"react-router": "^5.3.0",
|
|
43
44
|
"react-router-dom": "^5.3.0"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
@@ -1,36 +1,35 @@
|
|
|
1
1
|
import React, { useMemo, useEffect } from 'react'
|
|
2
|
-
import { Link, useRouteMatch, useParams } from 'react-router-dom'
|
|
2
|
+
import { Link, useRouteMatch, useParams } from 'react-router-dom'
|
|
3
3
|
import { useBreadcrumbContext } from './BreadcrumbStore'
|
|
4
|
-
import { ConditionalWrap } from '../Helper'
|
|
4
|
+
import { ConditionalWrap } from '../Helper'
|
|
5
5
|
export const BreadcrumbContext = React.createContext(null)
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
interface Breadcrumb {
|
|
9
|
-
to: string
|
|
10
|
-
name: string
|
|
11
|
-
className?: string
|
|
8
|
+
to: string
|
|
9
|
+
name: string
|
|
10
|
+
className?: string
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
interface UseBreadcrumbState {
|
|
15
|
-
breadcrumbs: Breadcrumb[]
|
|
16
|
-
setCrumb: (props: { [key: string]: any
|
|
17
|
-
resetCrumb: (props: string[]) => void
|
|
14
|
+
breadcrumbs: Breadcrumb[]
|
|
15
|
+
setCrumb: (props: { [key: string]: any }) => void
|
|
16
|
+
resetCrumb: (props: string[]) => void
|
|
18
17
|
}
|
|
19
18
|
|
|
20
19
|
interface AdvancedAlias {
|
|
21
|
-
component: any
|
|
22
|
-
linked: boolean
|
|
20
|
+
component: any
|
|
21
|
+
linked: boolean
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
interface UseBreadcrumbProps {
|
|
26
|
-
sep?: string
|
|
27
|
-
alias?: { [key: string]: AdvancedAlias | any
|
|
25
|
+
sep?: string
|
|
26
|
+
alias?: { [key: string]: AdvancedAlias | any }
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
type UseBreadcrumbOptionalProps = UseBreadcrumbProps | null
|
|
31
30
|
|
|
32
31
|
export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): UseBreadcrumbState {
|
|
33
|
-
let sep = props?.sep ||
|
|
32
|
+
let sep = props?.sep || '/'
|
|
34
33
|
deps = deps || []
|
|
35
34
|
const { url, path } = useRouteMatch()
|
|
36
35
|
const params = useParams()
|
|
@@ -38,12 +37,12 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
|
|
|
38
37
|
|
|
39
38
|
useEffect(() => {
|
|
40
39
|
if (!props || !props.alias) return
|
|
41
|
-
setState(state => ({ ...state, alias: { ...state.alias, ...props.alias } }))
|
|
40
|
+
setState((state) => ({ ...state, alias: { ...state.alias, ...props.alias } }))
|
|
42
41
|
return () => resetCrumb(Object.keys(props.alias))
|
|
43
42
|
}, deps)
|
|
44
43
|
|
|
45
44
|
function setCrumb(props) {
|
|
46
|
-
setState(state => ({ ...state, alias: { ...state.alias, ...props } }))
|
|
45
|
+
setState((state) => ({ ...state, alias: { ...state.alias, ...props } }))
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
function resetCrumb(props: string[]) {
|
|
@@ -51,36 +50,42 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
|
|
|
51
50
|
delete agg[curr]
|
|
52
51
|
return agg
|
|
53
52
|
}, state.alias)
|
|
54
|
-
setState(state => ({ ...state, alias: tempAlias }))
|
|
53
|
+
setState((state) => ({ ...state, alias: tempAlias }))
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
let levels: Breadcrumb[] = useMemo(() => {
|
|
58
|
-
const paths = path.split(
|
|
59
|
-
const urls = url.split(
|
|
57
|
+
const paths = path.split('/').filter(Boolean)
|
|
58
|
+
const urls = url.split('/').filter(Boolean)
|
|
60
59
|
return paths.map((path, idx) => {
|
|
61
60
|
const crumb: Breadcrumb = { to: urls[idx], name: path }
|
|
62
|
-
if (path.startsWith(
|
|
63
|
-
crumb.className =
|
|
61
|
+
if (path.startsWith(':') && params[path.replace(':', '')]) {
|
|
62
|
+
crumb.className = 'param'
|
|
64
63
|
}
|
|
65
64
|
return crumb
|
|
66
65
|
})
|
|
67
66
|
}, [path, url])
|
|
68
67
|
const { res: breadcrumbs } = useMemo(() => {
|
|
69
|
-
return levels.reduce(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
return levels.reduce(
|
|
69
|
+
(agg, curr, idx) => {
|
|
70
|
+
const { res, prefix } = agg
|
|
71
|
+
const { to, name } = curr
|
|
72
|
+
res.push({
|
|
73
|
+
to:
|
|
74
|
+
!state.alias[name]?.component || (state.alias[name]?.component && state.alias[name]?.linked)
|
|
75
|
+
? `${prefix}${to}`
|
|
76
|
+
: null,
|
|
77
|
+
name:
|
|
78
|
+
typeof state.alias[name] === 'object'
|
|
79
|
+
? !!state.alias[name]?.component
|
|
80
|
+
? state.alias[name].component
|
|
81
|
+
: null
|
|
82
|
+
: state.alias[name] || name,
|
|
83
|
+
className: curr.className || '',
|
|
84
|
+
})
|
|
85
|
+
return { res, prefix: `${prefix}${curr.to}${sep}` }
|
|
86
|
+
},
|
|
87
|
+
{ res: [], prefix: '/' },
|
|
88
|
+
)
|
|
84
89
|
}, [levels, state])
|
|
85
90
|
|
|
86
91
|
return { breadcrumbs, setCrumb, resetCrumb }
|
|
@@ -88,27 +93,42 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]):
|
|
|
88
93
|
|
|
89
94
|
interface Breadcrumbs {
|
|
90
95
|
breadcrumbs: Breadcrumb[]
|
|
91
|
-
sep?: string
|
|
92
|
-
className?: string
|
|
93
|
-
}
|
|
96
|
+
sep?: string
|
|
97
|
+
className?: string
|
|
98
|
+
}
|
|
94
99
|
|
|
95
|
-
export const BreadCrumb: React.FC<Breadcrumbs> = ({
|
|
100
|
+
export const BreadCrumb: React.FC<Breadcrumbs> = ({
|
|
101
|
+
breadcrumbs,
|
|
102
|
+
sep = '/',
|
|
103
|
+
className = 'dc__devtron-breadcrumb__item',
|
|
104
|
+
}) => {
|
|
96
105
|
const { url } = useRouteMatch()
|
|
97
|
-
const filteredCrumbs = breadcrumbs.filter(crumb => !!crumb.name)
|
|
98
|
-
return
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
{children
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const filteredCrumbs = breadcrumbs.filter((crumb) => !!crumb.name)
|
|
107
|
+
return (
|
|
108
|
+
<React.Fragment>
|
|
109
|
+
{filteredCrumbs.map((breadcrumb, idx) => (
|
|
110
|
+
<React.Fragment key={idx}>
|
|
111
|
+
<ConditionalWrap
|
|
112
|
+
condition={!!breadcrumb.to}
|
|
113
|
+
wrap={(children) => (
|
|
114
|
+
<Link
|
|
115
|
+
className={`${url === breadcrumb.to ? 'active' : ''} ${className} ${
|
|
116
|
+
breadcrumb.className || ''
|
|
117
|
+
}`}
|
|
118
|
+
to={breadcrumb.to}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</Link>
|
|
122
|
+
)}
|
|
123
|
+
>
|
|
124
|
+
{breadcrumb.name}
|
|
125
|
+
</ConditionalWrap>
|
|
109
126
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
127
|
+
{idx + 1 !== filteredCrumbs.length && breadcrumb.name && (
|
|
128
|
+
<span className={`${className}__separator cn-5`}>{sep}</span>
|
|
129
|
+
)}
|
|
130
|
+
</React.Fragment>
|
|
131
|
+
))}
|
|
132
|
+
</React.Fragment>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
@@ -2,7 +2,7 @@ import React from 'react'
|
|
|
2
2
|
import { ReactComponent as DeleteCross } from '../../Assets/Icon/ic-close.svg'
|
|
3
3
|
import { ReactComponent as InjectTag } from '../../Assets/Icon/inject-tag.svg'
|
|
4
4
|
import { TagType } from '../Types'
|
|
5
|
-
import TagLabelValueSelector from './TagLabelValueSelector'
|
|
5
|
+
import { TagLabelValueSelector } from './TagLabelValueSelector'
|
|
6
6
|
|
|
7
7
|
export default function TagDetails({
|
|
8
8
|
index,
|
|
@@ -5,7 +5,7 @@ import { ValidationRules } from './ValidationRules'
|
|
|
5
5
|
import { ReactComponent as ErrorCross } from '../../Assets/Icon/ic-close.svg'
|
|
6
6
|
import { ReactComponent as Info } from '../../Assets/Icon/ic-info-outlined.svg'
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export const TagLabelValueSelector = ({
|
|
9
9
|
selectedTagIndex,
|
|
10
10
|
tagData,
|
|
11
11
|
setTagData,
|
|
@@ -19,7 +19,7 @@ export default function TagLabelValueSelector({
|
|
|
19
19
|
tagOptions?: OptionType[]
|
|
20
20
|
isRequired?: boolean
|
|
21
21
|
type?: string
|
|
22
|
-
}) {
|
|
22
|
+
}) => {
|
|
23
23
|
const [selectedValue, setSelectedValue] = useState<string>('')
|
|
24
24
|
const [isPopupOpen, togglePopup] = useState<boolean>(false)
|
|
25
25
|
|