@devtron-labs/devtron-fe-common-lib 0.0.19 → 0.0.20

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,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './Toggle.scss';
3
- declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dataTestId, ...props }: {
3
+ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dataTestId, Icon, iconClass, ...props }: {
4
4
  [x: string]: any;
5
5
  selected?: boolean;
6
6
  onSelect?: any;
@@ -8,5 +8,7 @@ declare const Toggle: ({ selected, onSelect, color, rootClassName, disabled, dat
8
8
  rootClassName?: string;
9
9
  disabled?: boolean;
10
10
  dataTestId?: string;
11
+ Icon?: any;
12
+ iconClass?: string;
11
13
  }) => JSX.Element;
12
14
  export default Toggle;
package/dist/index.js CHANGED
@@ -14925,7 +14925,7 @@ function Icon(_a) {
14925
14925
  }
14926
14926
  function Body(_a) {
14927
14927
  var title = _a.title, _b = _a.subtitle, subtitle = _b === void 0 ? null : _b, _c = _a.children, children = _c === void 0 ? null : _c;
14928
- return (jsxRuntime.jsxs("div", __assign({ className: "flex left column " }, { children: [jsxRuntime.jsx("h3", __assign({ className: "confirmation-dialog__title lh-1-25 dc__break-word w-100" }, { children: title })), subtitle && jsxRuntime.jsx("div", __assign({ className: "confirmation-dialog__subtitle" }, { children: subtitle })), children] })));
14928
+ return (jsxRuntime.jsxs("div", __assign({ className: "flex left column " }, { children: [jsxRuntime.jsx("h3", __assign({ className: "confirmation-dialog__title lh-1-5 dc__break-word w-100" }, { children: title })), subtitle && jsxRuntime.jsx("div", __assign({ className: "confirmation-dialog__subtitle" }, { children: subtitle })), children] })));
14929
14929
  }
14930
14930
  function ButtonGroup(_a) {
14931
14931
  var children = _a.children;
@@ -22675,13 +22675,13 @@ var Checkbox = /** @class */ (function (_super) {
22675
22675
  return Checkbox;
22676
22676
  }(React.Component));
22677
22677
 
22678
- var css_248z$2 = ".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\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\ninput:checked + .toggle__slider {\n background-color: var(--color);\n}\n\ninput:focus + .toggle__slider {\n box-shadow: 0 0 1px var(--color);\n}\n\ninput:checked + .toggle__slider:before {\n transform: translateX(100%);\n}\n\n/* Rounded sliders */\n.toggle__slider.round {\n border-radius: 34px;\n}\n\n.toggle__slider.round:before {\n border-radius: 50%;\n}";
22678
+ var css_248z$2 = ".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}";
22679
22679
  styleInject(css_248z$2);
22680
22680
 
22681
22681
  var Toggle = function (_a) {
22682
22682
  var _b;
22683
- var _c = _a.selected, selected = _c === void 0 ? false : _c, _d = _a.onSelect, onSelect = _d === void 0 ? null : _d, _e = _a.color, color = _e === void 0 ? "#36b37e" : _e, _f = _a.rootClassName, rootClassName = _f === void 0 ? "" : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.dataTestId, dataTestId = _h === void 0 ? "handle-toggle-button" : _h, props = __rest(_a, ["selected", "onSelect", "color", "rootClassName", "disabled", "dataTestId"]);
22684
- var _j = __read(React.useState(selected), 2), active = _j[0], setActive = _j[1];
22683
+ var _c = _a.selected, selected = _c === void 0 ? false : _c, _d = _a.onSelect, onSelect = _d === void 0 ? null : _d, _e = _a.color, color = _e === void 0 ? '#36b37e' : _e, _f = _a.rootClassName, rootClassName = _f === void 0 ? '' : _f, _g = _a.disabled, disabled = _g === void 0 ? false : _g, _h = _a.dataTestId, dataTestId = _h === void 0 ? 'handle-toggle-button' : _h, _j = _a.Icon, Icon = _j === void 0 ? null : _j, _k = _a.iconClass, iconClass = _k === void 0 ? '' : _k, props = __rest(_a, ["selected", "onSelect", "color", "rootClassName", "disabled", "dataTestId", "Icon", "iconClass"]);
22684
+ var _l = __read(React.useState(selected), 2), active = _l[0], setActive = _l[1];
22685
22685
  useEffectAfterMount(function () {
22686
22686
  if (typeof onSelect === 'function') {
22687
22687
  if (active !== selected) {
@@ -22697,7 +22697,7 @@ var Toggle = function (_a) {
22697
22697
  setActive(function (active) { return !active; });
22698
22698
  }
22699
22699
  }
22700
- return (jsxRuntime.jsxs("label", __assign({}, props, { className: "".concat(rootClassName, " toggle__switch ").concat(disabled ? 'disabled' : ''), style: (_b = {}, _b['--color'] = color, _b) }, { children: [jsxRuntime.jsx("input", { type: "checkbox", checked: !!active, onChange: handleClick, className: "toggle__input" }), jsxRuntime.jsx("span", { className: "toggle__slider round", "data-testid": dataTestId })] })));
22700
+ return (jsxRuntime.jsxs("label", __assign({}, props, { className: "".concat(rootClassName, " toggle__switch ").concat(disabled ? 'disabled' : ''), style: (_b = {}, _b['--color'] = color, _b) }, { children: [jsxRuntime.jsx("input", { type: "checkbox", checked: !!active, onChange: handleClick, className: "toggle__input" }), jsxRuntime.jsx("span", __assign({ className: "toggle__slider ".concat(Icon ? 'with-icon br-4 dc__border' : 'round'), "data-testid": dataTestId }, { children: Icon && jsxRuntime.jsx(Icon, { className: "icon-dim-20 br-4 p-2 ".concat(iconClass) }) }))] })));
22701
22701
  };
22702
22702
 
22703
22703
  var css_248z$1 = ".modal-body--scan-details {\n position: fixed;\n top: 0;\n right: 0;\n background: var(--N000);\n width: 800px;\n}\n\n.security-tab__table {\n width: 100%;\n}\n\n.security-tab__table-header {\n border-bottom: solid 1px var(--N200);\n}\n\n.security-cell-header {\n font-size: 12px;\n font-weight: 600;\n line-height: 1.5;\n letter-spacing: normal;\n text-transform: uppercase;\n color: var(--N500);\n}\n\n.dc__security-tab__table-row {\n font-size: 13px;\n font-weight: normal;\n line-height: 1.54;\n letter-spacing: normal;\n color: var(--N900);\n box-shadow: inset 0 -1px 0 0 #f5f5f5;\n}\n\n.security-tab__cell-cve,\n.security-tab__cell-severity,\n.security-tab__cell-package,\n.security-tab__cell-current-ver,\n.security-tab__cell-fixed-ver,\n.security-tab__cell-policy {\n padding: 10px;\n}\n\n.security-tab__cell-cve {\n padding-left: 0px;\n text-align: left;\n width: 20%;\n}\n\n.security-tab__cell-policy {\n padding-right: 0px;\n}\n\n.security-tab__cell-policy--whitelist,\n.security-tab__cell-policy--whitelisted {\n color: var(--G500);\n text-transform: capitalize;\n}\n\n.security-tab__cell-policy--block {\n color: var(--R500);\n text-transform: capitalize;\n}\n\n.scanned-object__results {\n margin: 0 20px;\n}";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -17,7 +17,7 @@ function Icon({ src, className = '' }: ConfirmationDialogIconType) {
17
17
  function Body({ title, subtitle = null, children = null }: ConfirmationDialogBodyType) {
18
18
  return (
19
19
  <div className="flex left column ">
20
- <h3 className="confirmation-dialog__title lh-1-25 dc__break-word w-100">{title}</h3>
20
+ <h3 className="confirmation-dialog__title lh-1-5 dc__break-word w-100">{title}</h3>
21
21
  {subtitle && <div className="confirmation-dialog__subtitle">{subtitle}</div>}
22
22
  {children}
23
23
  </div>
@@ -4,15 +4,14 @@
4
4
  width: 100%;
5
5
  height: 100%;
6
6
 
7
- &.disabled{
7
+ &.disabled {
8
8
  cursor: not-allowed;
9
- .toggle__slider{
9
+ .toggle__slider {
10
10
  cursor: not-allowed;
11
11
  }
12
12
  }
13
13
  }
14
14
 
15
-
16
15
  /* Hide default HTML checkbox */
17
16
 
18
17
  .toggle__switch input {
@@ -21,7 +20,6 @@
21
20
  height: 0;
22
21
  }
23
22
 
24
-
25
23
  /* The slider */
26
24
 
27
25
  .toggle__slider {
@@ -32,39 +30,49 @@
32
30
  right: 0;
33
31
  bottom: 0;
34
32
  background-color: #ccc;
35
- transition: all .4s ease;
36
- }
37
-
38
- .toggle__slider:before {
39
- position: absolute;
40
- content: "";
41
- height: calc( 100% - 8px);
42
- width: calc( 50% - 4px);
43
- left: 4px;
44
- bottom: 4px;
45
- background-color: white;
46
33
  transition: all 0.4s ease;
34
+ &.round {
35
+ border-radius: 34px;
36
+ &:before {
37
+ border-radius: 50%;
38
+ }
39
+ }
40
+ &:before {
41
+ position: absolute;
42
+ content: '';
43
+ height: calc(100% - 8px);
44
+ width: calc(50% - 4px);
45
+ left: 4px;
46
+ bottom: 4px;
47
+ background-color: white;
48
+ transition: all 0.4s ease;
49
+ }
50
+ &.with-icon {
51
+ background-color: var(--N000) !important;
52
+ svg {
53
+ position: absolute;
54
+ content: '';
55
+ top: -1px;
56
+ left: -1px;
57
+ background-color: var(--N300);
58
+ transition: all 0.4s ease;
59
+ }
60
+ }
47
61
  }
48
62
 
49
- input:checked+.toggle__slider {
63
+ input:checked + .toggle__slider {
50
64
  background-color: var(--color);
65
+ &:before {
66
+ transform: translateX(calc(100%));
67
+ }
68
+ &.with-icon {
69
+ svg {
70
+ transform: translateX(calc(100%));
71
+ background-color: var(--color);
72
+ }
73
+ }
51
74
  }
52
75
 
53
- input:focus+.toggle__slider {
76
+ input:focus + .toggle__slider {
54
77
  box-shadow: 0 0 1px var(--color);
55
78
  }
56
-
57
- input:checked+.toggle__slider:before {
58
- transform: translateX(calc( 100%));
59
- }
60
-
61
-
62
- /* Rounded sliders */
63
-
64
- .toggle__slider.round {
65
- border-radius: 34px;
66
- }
67
-
68
- .toggle__slider.round:before {
69
- border-radius: 50%;
70
- }
@@ -1,25 +1,35 @@
1
- import React from 'react';
2
- import { useEffectAfterMount } from '../Helper';
1
+ import React from 'react'
2
+ import { useEffectAfterMount } from '../Helper'
3
3
  import './Toggle.scss'
4
4
 
5
- const Toggle = ({selected=false, onSelect=null, color="#36b37e", rootClassName="", disabled=false, dataTestId="handle-toggle-button", ...props})=>{
6
- const [active, setActive] = React.useState(selected);
5
+ const Toggle = ({
6
+ selected = false,
7
+ onSelect = null,
8
+ color = '#36b37e',
9
+ rootClassName = '',
10
+ disabled = false,
11
+ dataTestId = 'handle-toggle-button',
12
+ Icon = null,
13
+ iconClass= '',
14
+ ...props
15
+ }) => {
16
+ const [active, setActive] = React.useState(selected)
7
17
 
8
- useEffectAfterMount(()=>{
9
- if(typeof onSelect === 'function'){
10
- if(active !== selected){
18
+ useEffectAfterMount(() => {
19
+ if (typeof onSelect === 'function') {
20
+ if (active !== selected) {
11
21
  onSelect(active)
12
22
  }
13
23
  }
14
- },[active])
24
+ }, [active])
15
25
 
16
26
  useEffectAfterMount(() => {
17
27
  setActive(selected)
18
28
  }, [selected])
19
29
 
20
- function handleClick(e){
21
- if(!disabled){
22
- setActive(active=>!active)
30
+ function handleClick(e) {
31
+ if (!disabled) {
32
+ setActive((active) => !active)
23
33
  }
24
34
  }
25
35
 
@@ -30,9 +40,11 @@ const Toggle = ({selected=false, onSelect=null, color="#36b37e", rootClassName="
30
40
  style={{ ['--color' as any]: color }}
31
41
  >
32
42
  <input type="checkbox" checked={!!active} onChange={handleClick} className="toggle__input" />
33
- <span className="toggle__slider round" data-testid={dataTestId}></span>
43
+ <span className={`toggle__slider ${Icon ? 'with-icon br-4 dc__border' : 'round'}`} data-testid={dataTestId}>
44
+ {Icon && <Icon className={`icon-dim-20 br-4 p-2 ${iconClass}`} />}
45
+ </span>
34
46
  </label>
35
47
  )
36
48
  }
37
49
 
38
- export default Toggle
50
+ export default Toggle