@devtron-labs/devtron-fe-common-lib 0.0.18 → 0.0.20-beta-1
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/Constants.d.ts +5 -0
- package/dist/Common/ResizableTextarea.d.ts +3 -0
- package/dist/Common/Toggle/Toggle.d.ts +3 -1
- package/dist/Common/Types.d.ts +15 -0
- package/dist/Common/index.d.ts +1 -0
- package/dist/index.js +49 -7
- package/package.json +1 -1
- package/src/Common/Constants.ts +8 -2
- package/src/Common/Dialogs/ConfirmationDialog.tsx +1 -1
- package/src/Common/ResizableTextarea.tsx +73 -0
- package/src/Common/Toggle/Toggle.scss +40 -32
- package/src/Common/Toggle/Toggle.tsx +25 -13
- package/src/Common/Types.ts +16 -0
- package/src/Common/index.ts +1 -0
|
@@ -57,3 +57,8 @@ export declare const BuildStageVariable: {
|
|
|
57
57
|
PostBuild: string;
|
|
58
58
|
};
|
|
59
59
|
export declare const REGISTRY_TYPE_MAP: Record<string, RegistryTypeDetailType>;
|
|
60
|
+
export declare const RepositoryAction: {
|
|
61
|
+
CONTAINER: string;
|
|
62
|
+
CHART_PULL: string;
|
|
63
|
+
CHART_PUSH: string;
|
|
64
|
+
};
|
|
@@ -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/Common/Types.d.ts
CHANGED
|
@@ -338,4 +338,19 @@ export interface UseSearchString {
|
|
|
338
338
|
[key: string]: string;
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
+
export interface ResizableTextareaProps {
|
|
342
|
+
minHeight?: number;
|
|
343
|
+
maxHeight?: number;
|
|
344
|
+
value?: string;
|
|
345
|
+
onChange?: (e: any) => void;
|
|
346
|
+
onBlur?: (e: any) => void;
|
|
347
|
+
onFocus?: (e: any) => void;
|
|
348
|
+
className?: string;
|
|
349
|
+
placeholder?: string;
|
|
350
|
+
lineHeight?: number;
|
|
351
|
+
padding?: number;
|
|
352
|
+
disabled?: boolean;
|
|
353
|
+
name?: string;
|
|
354
|
+
dataTestId?: string;
|
|
355
|
+
}
|
|
341
356
|
export {};
|
package/dist/Common/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ var REGISTRY_TYPE_MAP = {
|
|
|
116
116
|
defaultRegistryURL: 'docker.io',
|
|
117
117
|
registryURL: {
|
|
118
118
|
label: 'Registry URL',
|
|
119
|
-
defaultValue: '
|
|
119
|
+
defaultValue: '',
|
|
120
120
|
placeholder: '',
|
|
121
121
|
},
|
|
122
122
|
id: {
|
|
@@ -208,7 +208,7 @@ var REGISTRY_TYPE_MAP = {
|
|
|
208
208
|
defaultRegistryURL: 'quay.io',
|
|
209
209
|
registryURL: {
|
|
210
210
|
label: 'Registry URL',
|
|
211
|
-
defaultValue: '
|
|
211
|
+
defaultValue: '',
|
|
212
212
|
placeholder: '',
|
|
213
213
|
},
|
|
214
214
|
id: {
|
|
@@ -245,6 +245,11 @@ var REGISTRY_TYPE_MAP = {
|
|
|
245
245
|
placeholder: '',
|
|
246
246
|
},
|
|
247
247
|
},
|
|
248
|
+
};
|
|
249
|
+
var RepositoryAction = {
|
|
250
|
+
CONTAINER: "CONTAINER",
|
|
251
|
+
CHART_PULL: "CHART_PULL",
|
|
252
|
+
CHART_PUSH: "CHART_PUSH"
|
|
248
253
|
};
|
|
249
254
|
|
|
250
255
|
/******************************************************************************
|
|
@@ -14925,7 +14930,7 @@ function Icon(_a) {
|
|
|
14925
14930
|
}
|
|
14926
14931
|
function Body(_a) {
|
|
14927
14932
|
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-
|
|
14933
|
+
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
14934
|
}
|
|
14930
14935
|
function ButtonGroup(_a) {
|
|
14931
14936
|
var children = _a.children;
|
|
@@ -22675,13 +22680,13 @@ var Checkbox = /** @class */ (function (_super) {
|
|
|
22675
22680
|
return Checkbox;
|
|
22676
22681
|
}(React.Component));
|
|
22677
22682
|
|
|
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\
|
|
22683
|
+
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
22684
|
styleInject(css_248z$2);
|
|
22680
22685
|
|
|
22681
22686
|
var Toggle = function (_a) {
|
|
22682
22687
|
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 ?
|
|
22684
|
-
var
|
|
22688
|
+
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"]);
|
|
22689
|
+
var _l = __read(React.useState(selected), 2), active = _l[0], setActive = _l[1];
|
|
22685
22690
|
useEffectAfterMount(function () {
|
|
22686
22691
|
if (typeof onSelect === 'function') {
|
|
22687
22692
|
if (active !== selected) {
|
|
@@ -22697,7 +22702,7 @@ var Toggle = function (_a) {
|
|
|
22697
22702
|
setActive(function (active) { return !active; });
|
|
22698
22703
|
}
|
|
22699
22704
|
}
|
|
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
|
|
22705
|
+
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
22706
|
};
|
|
22702
22707
|
|
|
22703
22708
|
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}";
|
|
@@ -23307,6 +23312,41 @@ var AddImageButton = function (_a) {
|
|
|
23307
23312
|
return (jsxRuntime.jsx("div", __assign({ className: "add-tag-button flex pt-12 pr-12", "data-testid": "add-tags-button", onClick: handleClick }, { children: jsxRuntime.jsxs("div", __assign({ className: "lh-16 flex" }, { children: [jsxRuntime.jsx(SvgIcAdd, { className: "icon-dim-16 cn-6" }), jsxRuntime.jsx("span", __assign({ className: "cn-7" }, { children: "Add tags/comment" }))] })) })));
|
|
23308
23313
|
};
|
|
23309
23314
|
|
|
23315
|
+
var ResizableTextarea = function (_a) {
|
|
23316
|
+
var minHeight = _a.minHeight, maxHeight = _a.maxHeight, value = _a.value, _b = _a.onChange, onChange = _b === void 0 ? null : _b, _c = _a.onBlur, onBlur = _c === void 0 ? null : _c, _d = _a.onFocus, onFocus = _d === void 0 ? null : _d, _e = _a.className, className = _e === void 0 ? '' : _e, _f = _a.placeholder, placeholder = _f === void 0 ? 'Enter your text here..' : _f, _g = _a.lineHeight, lineHeight = _g === void 0 ? 14 : _g, _h = _a.padding, padding = _h === void 0 ? 12 : _h, _j = _a.disabled, disabled = _j === void 0 ? false : _j, dataTestId = _a.dataTestId, props = __rest(_a, ["minHeight", "maxHeight", "value", "onChange", "onBlur", "onFocus", "className", "placeholder", "lineHeight", "padding", "disabled", "dataTestId"]);
|
|
23317
|
+
var _k = __read(React.useState(''), 2), text = _k[0], setText = _k[1];
|
|
23318
|
+
var _textRef = React.useRef(null);
|
|
23319
|
+
React.useEffect(function () {
|
|
23320
|
+
setText(value);
|
|
23321
|
+
}, [value]);
|
|
23322
|
+
function handleChange(e) {
|
|
23323
|
+
e.persist();
|
|
23324
|
+
setText(e.target.value);
|
|
23325
|
+
if (typeof onChange === 'function')
|
|
23326
|
+
onChange(e);
|
|
23327
|
+
}
|
|
23328
|
+
function handleBlur(e) {
|
|
23329
|
+
if (typeof onBlur === 'function')
|
|
23330
|
+
onBlur(e);
|
|
23331
|
+
}
|
|
23332
|
+
function handleFocus(e) {
|
|
23333
|
+
if (typeof onFocus === 'function')
|
|
23334
|
+
onFocus(e);
|
|
23335
|
+
}
|
|
23336
|
+
useThrottledEffect(function () {
|
|
23337
|
+
_textRef.current.style.height = 'auto';
|
|
23338
|
+
var nextHeight = _textRef.current.scrollHeight;
|
|
23339
|
+
if (minHeight && nextHeight < minHeight) {
|
|
23340
|
+
nextHeight = minHeight;
|
|
23341
|
+
}
|
|
23342
|
+
if (maxHeight && nextHeight > maxHeight) {
|
|
23343
|
+
nextHeight = maxHeight;
|
|
23344
|
+
}
|
|
23345
|
+
_textRef.current.style.height = nextHeight + 2 + 'px';
|
|
23346
|
+
}, 500, [text]);
|
|
23347
|
+
return (jsxRuntime.jsx("textarea", __assign({ "data-testid": dataTestId, ref: function (el) { return (_textRef.current = el); }, value: text, placeholder: placeholder, className: "dc__resizable-textarea ".concat(className), onChange: handleChange, onBlur: handleBlur, onFocus: handleFocus, style: { lineHeight: "".concat(lineHeight, "px"), padding: "".concat(padding, "px") }, spellCheck: false, disabled: disabled }, props)));
|
|
23348
|
+
};
|
|
23349
|
+
|
|
23310
23350
|
exports.BreadCrumb = BreadCrumb;
|
|
23311
23351
|
exports.BreadcrumbStore = Store;
|
|
23312
23352
|
exports.BuildStageVariable = BuildStageVariable;
|
|
@@ -23351,8 +23391,10 @@ exports.ROUTES = ROUTES;
|
|
|
23351
23391
|
exports.RadioGroup = RadioGroup$1;
|
|
23352
23392
|
exports.RadioGroupItem = RadioGroupItem;
|
|
23353
23393
|
exports.Reload = Reload;
|
|
23394
|
+
exports.RepositoryAction = RepositoryAction;
|
|
23354
23395
|
exports.RequestTimeout = RequestTimeout;
|
|
23355
23396
|
exports.ResizableTagTextArea = ResizableTagTextArea;
|
|
23397
|
+
exports.ResizableTextarea = ResizableTextarea;
|
|
23356
23398
|
exports.ScanVulnerabilitiesTable = ScanVulnerabilitiesTable;
|
|
23357
23399
|
exports.ServerError = ServerError;
|
|
23358
23400
|
exports.ServerErrors = ServerErrors;
|
package/package.json
CHANGED
package/src/Common/Constants.ts
CHANGED
|
@@ -102,7 +102,7 @@ export const REGISTRY_TYPE_MAP: Record<string, RegistryTypeDetailType> = {
|
|
|
102
102
|
defaultRegistryURL: 'docker.io',
|
|
103
103
|
registryURL: {
|
|
104
104
|
label: 'Registry URL',
|
|
105
|
-
defaultValue: '
|
|
105
|
+
defaultValue: '',
|
|
106
106
|
placeholder: '',
|
|
107
107
|
},
|
|
108
108
|
id: {
|
|
@@ -195,7 +195,7 @@ export const REGISTRY_TYPE_MAP: Record<string, RegistryTypeDetailType> = {
|
|
|
195
195
|
defaultRegistryURL: 'quay.io',
|
|
196
196
|
registryURL: {
|
|
197
197
|
label: 'Registry URL',
|
|
198
|
-
defaultValue: '
|
|
198
|
+
defaultValue: '',
|
|
199
199
|
placeholder: '',
|
|
200
200
|
},
|
|
201
201
|
id: {
|
|
@@ -232,4 +232,10 @@ export const REGISTRY_TYPE_MAP: Record<string, RegistryTypeDetailType> = {
|
|
|
232
232
|
placeholder: '',
|
|
233
233
|
},
|
|
234
234
|
},
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export const RepositoryAction = {
|
|
238
|
+
CONTAINER: "CONTAINER",
|
|
239
|
+
CHART_PULL: "CHART_PULL",
|
|
240
|
+
CHART_PUSH: "CHART_PUSH"
|
|
235
241
|
}
|
|
@@ -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-
|
|
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>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { useThrottledEffect } from './Helper'
|
|
3
|
+
import { ResizableTextareaProps } from './Types'
|
|
4
|
+
|
|
5
|
+
export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
6
|
+
minHeight,
|
|
7
|
+
maxHeight,
|
|
8
|
+
value,
|
|
9
|
+
onChange = null,
|
|
10
|
+
onBlur = null,
|
|
11
|
+
onFocus = null,
|
|
12
|
+
className = '',
|
|
13
|
+
placeholder = 'Enter your text here..',
|
|
14
|
+
lineHeight = 14,
|
|
15
|
+
padding = 12,
|
|
16
|
+
disabled = false,
|
|
17
|
+
dataTestId,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
const [text, setText] = useState('')
|
|
21
|
+
const _textRef = useRef(null)
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setText(value)
|
|
25
|
+
}, [value])
|
|
26
|
+
|
|
27
|
+
function handleChange(e) {
|
|
28
|
+
e.persist()
|
|
29
|
+
setText(e.target.value)
|
|
30
|
+
if (typeof onChange === 'function') onChange(e)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function handleBlur(e) {
|
|
34
|
+
if (typeof onBlur === 'function') onBlur(e)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function handleFocus(e) {
|
|
38
|
+
if (typeof onFocus === 'function') onFocus(e)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
useThrottledEffect(
|
|
42
|
+
() => {
|
|
43
|
+
_textRef.current.style.height = 'auto'
|
|
44
|
+
let nextHeight = _textRef.current.scrollHeight
|
|
45
|
+
if (minHeight && nextHeight < minHeight) {
|
|
46
|
+
nextHeight = minHeight
|
|
47
|
+
}
|
|
48
|
+
if (maxHeight && nextHeight > maxHeight) {
|
|
49
|
+
nextHeight = maxHeight
|
|
50
|
+
}
|
|
51
|
+
_textRef.current.style.height = nextHeight + 2 + 'px'
|
|
52
|
+
},
|
|
53
|
+
500,
|
|
54
|
+
[text],
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<textarea
|
|
59
|
+
data-testid={dataTestId}
|
|
60
|
+
ref={(el) => (_textRef.current = el)}
|
|
61
|
+
value={text}
|
|
62
|
+
placeholder={placeholder}
|
|
63
|
+
className={`dc__resizable-textarea ${className}`}
|
|
64
|
+
onChange={handleChange}
|
|
65
|
+
onBlur={handleBlur}
|
|
66
|
+
onFocus={handleFocus}
|
|
67
|
+
style={{ lineHeight: `${lineHeight}px`, padding: `${padding}px` }}
|
|
68
|
+
spellCheck={false}
|
|
69
|
+
disabled={disabled}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
@@ -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
|
|
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
|
|
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 = ({
|
|
6
|
-
|
|
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
|
|
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=
|
|
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
|
package/src/Common/Types.ts
CHANGED
|
@@ -371,4 +371,20 @@ export interface UseSearchString {
|
|
|
371
371
|
searchParams: {
|
|
372
372
|
[key: string]: string
|
|
373
373
|
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export interface ResizableTextareaProps {
|
|
377
|
+
minHeight?: number
|
|
378
|
+
maxHeight?: number
|
|
379
|
+
value?: string
|
|
380
|
+
onChange?: (e) => void
|
|
381
|
+
onBlur?: (e) => void
|
|
382
|
+
onFocus?: (e) => void
|
|
383
|
+
className?: string
|
|
384
|
+
placeholder?: string
|
|
385
|
+
lineHeight?: number
|
|
386
|
+
padding?: number
|
|
387
|
+
disabled?: boolean
|
|
388
|
+
name?: string
|
|
389
|
+
dataTestId?: string
|
|
374
390
|
}
|
package/src/Common/index.ts
CHANGED