@devtron-labs/devtron-fe-common-lib 0.0.6-beta-14 → 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.
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { OptionType, TagType } from '../Types';
3
- export default function TagLabelValueSelector({ selectedTagIndex, tagData, setTagData, tagOptions, isRequired, type, }: {
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
- }): JSX.Element;
10
+ }) => JSX.Element;
@@ -1,10 +1,7 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  import { Placement } from 'tippy.js';
3
3
  import 'tippy.js/animations/shift-toward-subtle.css';
4
- export declare enum TippyTheme {
5
- black = "black",
6
- white = "white"
7
- }
4
+ import { TippyTheme } from './Types';
8
5
  interface TippyCustomizedProps {
9
6
  theme: TippyTheme;
10
7
  visible?: boolean;
@@ -31,5 +28,5 @@ interface TippyCustomizedProps {
31
28
  documentationLinkText?: string;
32
29
  children: React.ReactElement<any>;
33
30
  }
34
- export default function TippyCustomized(props: TippyCustomizedProps): JSX.Element;
31
+ export declare function TippyCustomized(props: TippyCustomizedProps): JSX.Element;
35
32
  export {};
@@ -21,3 +21,7 @@ export interface OptionType {
21
21
  label: string;
22
22
  value: string;
23
23
  }
24
+ export declare enum TippyTheme {
25
+ black = "black",
26
+ white = "white"
27
+ }
@@ -19,3 +19,4 @@ export * from './RadioGroup';
19
19
  export { default as PopupMenu } from './PopupMenu';
20
20
  export * from './TippyCustomized';
21
21
  export * from './CustomTagSelector';
22
+ export * from './Dialogs';
package/dist/index.js CHANGED
@@ -147,6 +147,12 @@ var ServerErrors = /** @class */ (function (_super) {
147
147
  return ServerErrors;
148
148
  }(Error));
149
149
 
150
+ var TippyTheme;
151
+ (function (TippyTheme) {
152
+ TippyTheme["black"] = "black";
153
+ TippyTheme["white"] = "white";
154
+ })(TippyTheme || (TippyTheme = {}));
155
+
150
156
  var responseMessages = {
151
157
  100: 'Continue',
152
158
  101: 'Switching Protocols',
@@ -3967,7 +3973,7 @@ var SvgIcClose = function SvgIcClose(props) {
3967
3973
  fillRule: "evenodd"
3968
3974
  })));
3969
3975
  };
3970
- var closeIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%20%20%20%20%3Cdefs%3E%20%20%20%20%20%20%20%20%3Cpath%20id%3D%22a%22%20class%3D%22stroke-color%22%20d%3D%22M18.295%205.705a.997.997%200%200%200-1.41%200L12%2010.59%207.115%205.705a.997.997%200%201%200-1.41%201.41L10.59%2012l-4.885%204.885a.997.997%200%201%200%201.41%201.41L12%2013.41l4.885%204.885a.997.997%200%200%200%201.41-1.41L13.41%2012l4.885-4.885a.997.997%200%200%200%200-1.41z%22%2F%3E%20%20%20%20%3C%2Fdefs%3E%20%20%20%20%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22%22%2F%3E%20%20%20%20%20%20%20%20%3Cuse%20fill%3D%22%23999%22%20xlink%3Ahref%3D%22%23a%22%2F%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
3976
+ var close = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%20%20%20%20%3Cdefs%3E%20%20%20%20%20%20%20%20%3Cpath%20id%3D%22a%22%20class%3D%22stroke-color%22%20d%3D%22M18.295%205.705a.997.997%200%200%200-1.41%200L12%2010.59%207.115%205.705a.997.997%200%201%200-1.41%201.41L10.59%2012l-4.885%204.885a.997.997%200%201%200%201.41%201.41L12%2013.41l4.885%204.885a.997.997%200%200%200%201.41-1.41L13.41%2012l4.885-4.885a.997.997%200%200%200%200-1.41z%22%2F%3E%20%20%20%20%3C%2Fdefs%3E%20%20%20%20%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22%22%2F%3E%20%20%20%20%20%20%20%20%3Cuse%20fill%3D%22%23999%22%20xlink%3Ahref%3D%22%23a%22%2F%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
3971
3977
 
3972
3978
  var OpaqueModal = /** @class */ (function (_super) {
3973
3979
  __extends(OpaqueModal, _super);
@@ -3988,7 +3994,7 @@ var OpaqueModal = /** @class */ (function (_super) {
3988
3994
  };
3989
3995
  OpaqueModal.prototype.render = function () {
3990
3996
  var _a = __assign({}, this.props), _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.onHide, onHide = _c === void 0 ? null : _c;
3991
- return ReactDOM.createPortal(jsxs("div", __assign({ className: "full-screen-modal__body-container ".concat(className) }, { children: [this.props.children, typeof onHide === 'function' && jsx("div", __assign({ className: "close-btn icon-dim-24", onClick: function (e) { return onHide(false); } }, { children: jsx("img", { className: "close-img", src: closeIcon, alt: "close" }) }))] })), document.getElementById('full-screen-modal'));
3997
+ return ReactDOM.createPortal(jsxs("div", __assign({ className: "full-screen-modal__body-container ".concat(className) }, { children: [this.props.children, typeof onHide === 'function' && jsx("div", __assign({ className: "close-btn icon-dim-24", onClick: function (e) { return onHide(false); } }, { children: jsx("img", { className: "close-img", src: close, alt: "close" }) }))] })), document.getElementById('full-screen-modal'));
3992
3998
  };
3993
3999
  return OpaqueModal;
3994
4000
  }(React__default.Component));
@@ -4043,7 +4049,7 @@ function useBreadcrumbContext() {
4043
4049
 
4044
4050
  React__default.createContext(null);
4045
4051
  function useBreadcrumb(props, deps) {
4046
- var sep = (props === null || props === void 0 ? void 0 : props.sep) || "/";
4052
+ var sep = (props === null || props === void 0 ? void 0 : props.sep) || '/';
4047
4053
  deps = deps || [];
4048
4054
  var _a = useRouteMatch(), url = _a.url, path = _a.path;
4049
4055
  var params = useParams();
@@ -4065,12 +4071,12 @@ function useBreadcrumb(props, deps) {
4065
4071
  setState(function (state) { return (__assign(__assign({}, state), { alias: tempAlias })); });
4066
4072
  }
4067
4073
  var levels = useMemo(function () {
4068
- var paths = path.split("/").filter(Boolean);
4069
- var urls = url.split("/").filter(Boolean);
4074
+ var paths = path.split('/').filter(Boolean);
4075
+ var urls = url.split('/').filter(Boolean);
4070
4076
  return paths.map(function (path, idx) {
4071
4077
  var crumb = { to: urls[idx], name: path };
4072
- if (path.startsWith(":") && params[path.replace(":", "")]) {
4073
- crumb.className = "param";
4078
+ if (path.startsWith(':') && params[path.replace(':', '')]) {
4079
+ crumb.className = 'param';
4074
4080
  }
4075
4081
  return crumb;
4076
4082
  });
@@ -4085,22 +4091,22 @@ function useBreadcrumb(props, deps) {
4085
4091
  ? "".concat(prefix).concat(to)
4086
4092
  : null,
4087
4093
  name: typeof state.alias[name] === 'object'
4088
- ? !!((_d = state.alias[name]) === null || _d === void 0 ? void 0 : _d.component) ? state.alias[name].component : null
4094
+ ? !!((_d = state.alias[name]) === null || _d === void 0 ? void 0 : _d.component)
4095
+ ? state.alias[name].component
4096
+ : null
4089
4097
  : state.alias[name] || name,
4090
4098
  className: curr.className || '',
4091
4099
  });
4092
4100
  return { res: res, prefix: "".concat(prefix).concat(curr.to).concat(sep) };
4093
- }, { res: [], prefix: "/" });
4101
+ }, { res: [], prefix: '/' });
4094
4102
  }, [levels, state]).res;
4095
4103
  return { breadcrumbs: breadcrumbs, setCrumb: setCrumb, resetCrumb: resetCrumb };
4096
4104
  }
4097
4105
  var BreadCrumb = function (_a) {
4098
- var breadcrumbs = _a.breadcrumbs, _b = _a.sep, sep = _b === void 0 ? "/" : _b, _c = _a.className, className = _c === void 0 ? "dc__devtron-breadcrumb__item" : _c;
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;
4099
4107
  var url = useRouteMatch().url;
4100
4108
  var filteredCrumbs = breadcrumbs.filter(function (crumb) { return !!crumb.name; });
4101
- return jsx(React__default.Fragment, { children: filteredCrumbs.map(function (breadcrumb, idx) {
4102
- 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);
4103
- }) });
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)); }) }));
4104
4110
  };
4105
4111
 
4106
4112
  var RadioGroupContext = createContext({ name: '', value: '', disabled: false, onChange: function (event) { } });
@@ -4232,13 +4238,13 @@ function Button(_a) {
4232
4238
  var _h = usePopupContext(), handleOpen = _h.handleOpen, popupPosition = _h.popupPosition; _h.buttonRef; var initialiseButtonWidth = _h.initialiseButtonWidth;
4233
4239
  return jsx("button", __assign({ ref: initialiseButtonWidth, type: "button", tabIndex: tabIndex, disabled: disabled, className: "".concat(rootClassName, " ").concat(popupPosition ? 'focused' : '', " ").concat(isKebab ? 'popup-button-kebab' : "popup-button"), onMouseEnter: onHover ? (disabled ? null : handleOpen) : function () { }, onClick: disabled ? null : handleOpen }, { children: children }));
4234
4240
  }
4235
- function Body(_a) {
4241
+ function Body$1(_a) {
4236
4242
  var _b = _a.children, children = _b === void 0 ? null : _b, _c = _a.rootClassName, rootClassName = _c === void 0 ? "" : _c, _d = _a.style, style = _d === void 0 ? {} : _d, _e = _a.autoWidth, autoWidth = _e === void 0 ? false : _e;
4237
4243
  var _f = usePopupContext(), handleClose = _f.handleClose, popupPosition = _f.popupPosition, opacity = _f.opacity, callbackRef = _f.callbackRef, buttonWidth = _f.buttonWidth;
4238
4244
  return popupPosition ? jsx(Modal, __assign({ callbackRef: callbackRef, onClick: handleClose, rootClassName: "".concat(rootClassName, " popup-body ").concat(!children ? 'popup-body--empty' : '', " ").concat(Object.keys(popupPosition).join(" ")), style: __assign(__assign(__assign(__assign({}, popupPosition), style), (autoWidth ? { width: buttonWidth.current } : {})), { opacity: opacity }) }, { children: children })) : null;
4239
4245
  }
4240
4246
  PopupMenu.Button = Button;
4241
- PopupMenu.Body = Body;
4247
+ PopupMenu.Body = Body$1;
4242
4248
 
4243
4249
  var top = 'top';
4244
4250
  var bottom = 'bottom';
@@ -8247,11 +8253,6 @@ var Tippy = index;
8247
8253
  var css_248z = ".tippy-box[data-animation=shift-toward-subtle][data-state=hidden]{opacity:0}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=top][data-state=hidden]{transform:translateY(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=bottom][data-state=hidden]{transform:translateY(5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=left][data-state=hidden]{transform:translateX(-5px)}.tippy-box[data-animation=shift-toward-subtle][data-state=hidden][data-placement^=right][data-state=hidden]{transform:translateX(5px)}";
8248
8254
  styleInject(css_248z);
8249
8255
 
8250
- var TippyTheme;
8251
- (function (TippyTheme) {
8252
- TippyTheme["black"] = "black";
8253
- TippyTheme["white"] = "white";
8254
- })(TippyTheme || (TippyTheme = {}));
8255
8256
  // This component will handle some of the new tippy designs and interactions
8256
8257
  // So this can be updated to support further for new features or interactions
8257
8258
  function TippyCustomized(props) {
@@ -8422,7 +8423,7 @@ var SvgIcInfoOutlined = function SvgIcInfoOutlined(props) {
8422
8423
  })));
8423
8424
  };
8424
8425
 
8425
- function TagLabelValueSelector(_a) {
8426
+ var TagLabelValueSelector = function (_a) {
8426
8427
  var selectedTagIndex = _a.selectedTagIndex, tagData = _a.tagData, setTagData = _a.setTagData, tagOptions = _a.tagOptions, isRequired = _a.isRequired, type = _a.type;
8427
8428
  var _b = __read(useState(''), 2), selectedValue = _b[0], setSelectedValue = _b[1];
8428
8429
  var _c = __read(useState(false), 2), isPopupOpen = _c[0], togglePopup = _c[1];
@@ -8492,7 +8493,7 @@ function TagLabelValueSelector(_a) {
8492
8493
  return (jsxs(PopupMenu, __assign({ onToggleCallback: function (isOpen) { return togglePopup(isOpen); }, autoClose: true }, { children: [jsx(PopupMenu.Button, __assign({ rootClassName: "".concat(type === 'key'
8493
8494
  ? "dc__no-right-radius"
8494
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() }))] })));
8495
- }
8496
+ };
8496
8497
 
8497
8498
  function TagDetails(_a) {
8498
8499
  var index = _a.index, tagData = _a.tagData, setTagData = _a.setTagData, removeTag = _a.removeTag;
@@ -8527,4 +8528,91 @@ var TagLabelSelect = function (_a) {
8527
8528
  return (jsxs("div", { children: [jsxs("div", __assign({ className: "flexbox dc__content-space mb-8" }, { children: [jsx("span", { children: "Tags" }), jsx(PropagateTagInfo, {})] })), jsxs("div", { children: [jsxs("div", __assign({ className: "dc_width-max-content cb-5 fw-6 fs-13 flexbox mr-20 mb-8 cursor", onClick: addNewTag }, { children: [jsx(SvgIcAdd, { className: "icon-dim-20 fcb-5" }), " Add tag"] })), jsx("div", __assign({ className: "mb-8" }, { children: labelTags === null || labelTags === void 0 ? void 0 : labelTags.map(function (tagData, index) { return (jsx(TagDetails, { index: index, tagData: tagData, setTagData: setTagData, removeTag: removeTag }, "tag-".concat(index))); }) }))] })] }));
8528
8529
  };
8529
8530
 
8530
- export { BreadCrumb, Store as BreadcrumbStore, ConditionalWrap, DetailsProgressing, Drawer, ErrorScreenManager, ErrorScreenNotAuthorized, Host, Modal, OpaqueModal, PATTERNS, PopupMenu, Progressing, RadioGroup, RadioGroupItem, RequestTimeout, ServerError, ServerErrors, TagLabelSelect, TippyTheme, ToastBody, ToastBody3, ToastBodyWithButton, VisibleModal, VisibleModal2, get, post, put, showError, toastAccessDenied, trash, useBreadcrumb };
8531
+ function ConfirmationDialog(_a) {
8532
+ var _b = _a.className, className = _b === void 0 ? '' : _b, children = _a.children;
8533
+ return (jsx(VisibleModal2, __assign({ className: "confirmation-dialog" }, { children: jsx("div", __assign({ className: "confirmation-dialog__body ".concat(className) }, { children: children })) })));
8534
+ }
8535
+ function Icon(_a) {
8536
+ var src = _a.src, _b = _a.className, className = _b === void 0 ? '' : _b;
8537
+ return jsx("img", { src: src, className: "confirmation-dialog__icon ".concat(className), alt: "" });
8538
+ }
8539
+ function Body(_a) {
8540
+ var title = _a.title, _b = _a.subtitle, subtitle = _b === void 0 ? null : _b, _c = _a.children, children = _c === void 0 ? null : _c;
8541
+ return (jsxs("div", __assign({ className: "flex left column " }, { children: [jsx("h3", __assign({ className: "confirmation-dialog__title lh-1-25 dc__break-word w-100" }, { children: title })), subtitle && jsx("div", __assign({ className: "confirmation-dialog__subtitle" }, { children: subtitle })), children] })));
8542
+ }
8543
+ function ButtonGroup(_a) {
8544
+ var children = _a.children;
8545
+ return jsx("div", __assign({ className: "flex right confirmation-dialog__button-group" }, { children: children }));
8546
+ }
8547
+ ConfirmationDialog.Icon = Icon;
8548
+ ConfirmationDialog.Body = Body;
8549
+ ConfirmationDialog.ButtonGroup = ButtonGroup;
8550
+
8551
+ var warn = "data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2248%22%20height%3D%2248%22%20viewBox%3D%220%200%2048%2048%22%3E%20%20%20%20%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M0%200h48v48H0z%22%2F%3E%20%20%20%20%20%20%20%20%3Cg%20fill%3D%22%23FFEBEB%22%20stroke%3D%22%23F33E3E%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M7%2024h24v17a4%204%200%200%201-4%204H11a4%204%200%200%201-4-4V24z%22%2F%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20stroke-linecap%3D%22round%22%20d%3D%22M19%2029.5v10M24%2029.5v10M14%2029.5v10%22%2F%3E%20%20%20%20%20%20%20%20%3C%2Fg%3E%20%20%20%20%20%20%20%20%3Cpath%20stroke%3D%22%23F33E3E%22%20stroke-dasharray%3D%2217%2C3%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20d%3D%22M42%2010a3%203%200%200%201%200%206H31M38%2023a3%203%200%200%200-3-3h-8%22%2F%3E%20%20%20%20%20%20%20%20%3Cg%20stroke%3D%22%23F33E3E%22%20stroke-linejoin%3D%22round%22%20stroke-width%3D%222%22%20transform%3D%22rotate%28-10%2036.29%20-8.86%29%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Crect%20width%3D%2230%22%20height%3D%225%22%20y%3D%226%22%20fill%3D%22%23FFEBEB%22%20rx%3D%221%22%2F%3E%20%20%20%20%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M11%200h8a2%202%200%200%201%202%202v4H9V2a2%202%200%200%201%202-2z%22%2F%3E%20%20%20%20%20%20%20%20%3C%2Fg%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
8552
+
8553
+ var DeleteDialog = function (props) {
8554
+ return jsxs(ConfirmationDialog, __assign({ className: "confirmation-dialog__body--w-400" }, { children: [jsx(ConfirmationDialog.Icon, { src: warn }), jsx(ConfirmationDialog.Body, __assign({ title: props.title }, { children: jsxs("div", __assign({ className: "fs-13 cn-7 lh-1-54 w-100" }, { children: [props.description ? props.description : null, props.children] })) })), jsx(ConfirmationDialog.ButtonGroup, { children: jsxs("div", __assign({ className: "flex right" }, { children: [jsx("button", __assign({ type: "button", className: "cta cancel cta-cd-delete-modal ml-16", onClick: props.closeDelete, disabled: props.apiCallInProgress }, { children: "Cancel" })), jsx("button", __assign({ type: "button", className: "cta delete cta-cd-delete-modal ml-16", onClick: function () { return props.delete(); }, disabled: props.apiCallInProgress }, { children: props.apiCallInProgress ? jsx(Progressing, {}) : "".concat(props.deletePrefix || '', "Delete").concat(props.deletePostfix || '') }))] })) })] }));
8555
+ };
8556
+ function DeleteDialogDescription(props) {
8557
+ return jsx(Fragment, { children: props.children });
8558
+ }
8559
+ DeleteDialog.Description = DeleteDialogDescription;
8560
+
8561
+ //TODO: may not need context
8562
+ var DialogFormContext = createContext({ title: '', isLoading: false, close: function (event) { }, onSave: function (event) { } });
8563
+ var DialogForm = /** @class */ (function (_super) {
8564
+ __extends(DialogForm, _super);
8565
+ function DialogForm(props) {
8566
+ var _this = _super.call(this, props) || this;
8567
+ _this.escFunction = _this.escFunction.bind(_this);
8568
+ return _this;
8569
+ }
8570
+ DialogForm.prototype.componentDidMount = function () {
8571
+ document.addEventListener('keydown', this.escFunction);
8572
+ };
8573
+ DialogForm.prototype.componentWillUnmount = function () {
8574
+ document.removeEventListener('keydown', this.escFunction);
8575
+ };
8576
+ DialogForm.prototype.escFunction = function (event) {
8577
+ if (event.keyCode === 27 && this.props.closeOnESC) {
8578
+ this.props.close(event);
8579
+ }
8580
+ };
8581
+ DialogForm.prototype.render = function () {
8582
+ var _this = this;
8583
+ return (jsx(DialogFormContext.Provider, __assign({ value: {
8584
+ title: this.props.title,
8585
+ isLoading: this.props.isLoading,
8586
+ close: this.props.close,
8587
+ onSave: this.props.onSave,
8588
+ } }, { children: jsx(VisibleModal, __assign({ className: "" }, { children: jsxs("div", __assign({ className: "modal__body ".concat(this.props.className || '') }, { children: [jsxs("div", __assign({ className: "modal__header ".concat(this.props.headerClassName || '') }, { children: [jsx("h1", __assign({ className: "modal__title" }, { children: this.props.title })), jsxs("button", __assign({ type: "button", className: "dc__transparent", onClick: this.props.close }, { children: [' ', jsx("img", { src: close, alt: "close" })] }))] })), jsx(DialogFormContext.Consumer, { children: function (context) {
8589
+ return (jsx("form", __assign({ noValidate: true, onSubmit: function (e) {
8590
+ e.preventDefault();
8591
+ if (!context.isLoading) {
8592
+ context.onSave(e);
8593
+ }
8594
+ } }, { children: _this.props.children })));
8595
+ } })] })) })) })));
8596
+ };
8597
+ return DialogForm;
8598
+ }(Component));
8599
+ var DialogFormSubmit = /** @class */ (function (_super) {
8600
+ __extends(DialogFormSubmit, _super);
8601
+ function DialogFormSubmit() {
8602
+ return _super !== null && _super.apply(this, arguments) || this;
8603
+ }
8604
+ DialogFormSubmit.prototype.render = function () {
8605
+ var _this = this;
8606
+ return (jsx(DialogFormContext.Consumer, { children: function (context) {
8607
+ return (jsx("button", __assign({ type: "submit", className: "cta dc__align-right", tabIndex: _this.props.tabIndex }, { children: context.isLoading ? jsx(Progressing, {}) : _this.props.children })));
8608
+ } }));
8609
+ };
8610
+ return DialogFormSubmit;
8611
+ }(Component));
8612
+
8613
+ function ForceDeleteDialog(_a) {
8614
+ var onClickDelete = _a.onClickDelete, closeDeleteModal = _a.closeDeleteModal, forceDeleteDialogTitle = _a.forceDeleteDialogTitle, forceDeleteDialogMessage = _a.forceDeleteDialogMessage;
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
+ }
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, 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-14",
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; }) => void;
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("/").filter(Boolean)
59
- const urls = url.split("/").filter(Boolean)
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(":") && params[path.replace(":", "")]) {
63
- crumb.className = "param"
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((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: typeof state.alias[name] === 'object'
78
- ? !!state.alias[name]?.component ? state.alias[name].component : null
79
- : state.alias[name] || name,
80
- className: curr.className || '',
81
- });
82
- return { res, prefix: `${prefix}${curr.to}${sep}` }
83
- }, { res: [], prefix: "/" })
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> = ({ breadcrumbs, sep = "/", className = "dc__devtron-breadcrumb__item" }) => {
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 <React.Fragment>
99
- {filteredCrumbs.map((breadcrumb, idx) =>
100
- <React.Fragment key={idx}>
101
- <ConditionalWrap
102
- condition={!!breadcrumb.to}
103
- wrap={children => <Link className={`${url === breadcrumb.to ? 'active' : ''} ${className} ${breadcrumb.className || ""}`} to={breadcrumb.to}>
104
- {children}
105
- </Link>}
106
- >
107
- {breadcrumb.name}
108
- </ConditionalWrap>
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
- {idx + 1 !== filteredCrumbs.length && breadcrumb.name && <span className={`${className}__separator cn-5`}>{sep}</span>}
111
- </React.Fragment>
112
- )}
113
- </React.Fragment>
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
+ }
@@ -1,7 +1,8 @@
1
1
  import React from 'react'
2
2
  import { ReactComponent as InjectTag } from '../../Assets/Icon/inject-tag.svg'
3
3
  import { ReactComponent as Help } from '../../Assets/Icon/ic-help-outline.svg'
4
- import TippyCustomized, { TippyTheme } from '../TippyCustomized'
4
+ import { TippyCustomized } from '../TippyCustomized'
5
+ import { TippyTheme } from '../Types'
5
6
 
6
7
  export default function PropagateTagInfo() {
7
8
  const additionalInfo = () => {
@@ -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 default function TagLabelValueSelector({
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
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import warn from '../../../Assets/Img/warning-medium.svg';
2
+ import warn from '../../Assets/Img/warning-medium.svg';
3
3
  import { Progressing } from '../Progressing'
4
4
  import ConfirmationDialog from './ConfirmationDialog';
5
5
  import { DeleteDialogProps } from './Types';
@@ -1,6 +1,6 @@
1
1
  import React, { Component, createContext } from 'react';
2
2
  import { VisibleModal } from '../Modals/VisibleModal';
3
- import close from '../../../Assets/Icons/ic-close.svg';
3
+ import close from '../../Assets/Icon/ic-close.svg';
4
4
  import { Progressing } from '../Progressing'
5
5
  //TODO: may not need context
6
6
  const DialogFormContext = createContext({ title: '', isLoading: false, close: (event) => {}, onSave: (event) => {} });
@@ -1,13 +1,9 @@
1
- import React, { ReactNode, useEffect, useRef } from 'react'
1
+ import React, { ReactNode, useRef } from 'react'
2
2
  import Tippy from '@tippyjs/react'
3
3
  import { Placement } from 'tippy.js'
4
4
  import { ReactComponent as CloseIcon } from '../Assets/Icon/ic-close.svg'
5
5
  import 'tippy.js/animations/shift-toward-subtle.css'
6
-
7
- export enum TippyTheme {
8
- black = 'black',
9
- white = 'white',
10
- }
6
+ import { TippyTheme } from './Types'
11
7
 
12
8
  interface TippyCustomizedProps {
13
9
  theme: TippyTheme
@@ -38,7 +34,7 @@ interface TippyCustomizedProps {
38
34
 
39
35
  // This component will handle some of the new tippy designs and interactions
40
36
  // So this can be updated to support further for new features or interactions
41
- export default function TippyCustomized(props: TippyCustomizedProps) {
37
+ export function TippyCustomized(props: TippyCustomizedProps) {
42
38
  const tippyRef = useRef(null)
43
39
  const isWhiteTheme = props.theme === TippyTheme.white
44
40
 
@@ -23,4 +23,9 @@ export interface TagType {
23
23
  export interface OptionType {
24
24
  label: string;
25
25
  value: string;
26
+ }
27
+
28
+ export enum TippyTheme {
29
+ black = 'black',
30
+ white = 'white',
26
31
  }
@@ -18,4 +18,5 @@ export { default as BreadcrumbStore } from './BreadCrumb/BreadcrumbStore'
18
18
  export * from './RadioGroup'
19
19
  export { default as PopupMenu } from './PopupMenu'
20
20
  export * from './TippyCustomized'
21
- export * from './CustomTagSelector'
21
+ export * from './CustomTagSelector'
22
+ export * from './Dialogs'