@devtron-labs/devtron-fe-common-lib 0.0.48-beta-9 → 0.0.48-beta-11
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/.eslintignore +75 -0
- package/.eslintrc.js +84 -16
- package/.github/pull_request_template.md +25 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/release-package.yml +2 -3
- package/.husky/pre-commit +5 -0
- package/.lintstagedrc +3 -0
- package/.nvmrc +1 -0
- package/dist/Common/BreadCrumb/BreadCrumb.d.ts +1 -1
- package/dist/Common/BreadCrumb/BreadcrumbStore.d.ts +2 -2
- package/dist/Common/Constants.d.ts +1 -5
- package/dist/Common/CustomInput/CustomInput.d.ts +1 -1
- package/dist/Common/CustomInput/Types.d.ts +2 -2
- package/dist/Common/CustomTagSelector/ResizableTagTextArea.d.ts +1 -1
- package/dist/Common/DeleteComponentModal/DeleteComponent.d.ts +1 -1
- package/dist/Common/DevtronProgressing/DevtronProgressing.d.ts +1 -1
- package/dist/Common/Dialogs/ConfirmationDialog.d.ts +6 -6
- package/dist/Common/Dialogs/DeleteDialog.d.ts +1 -1
- package/dist/Common/Dialogs/ForceDeleteDialog.d.ts +1 -1
- package/dist/Common/Dialogs/Types.d.ts +1 -1
- package/dist/Common/EmptyState/EmptyState.d.ts +20 -17
- package/dist/Common/EmptyState/GenericEmptyState.d.ts +1 -1
- package/dist/Common/Error.d.ts +2 -1
- package/dist/Common/ErrorScreenNotFound.d.ts +1 -1
- package/dist/Common/Helper.d.ts +1 -1
- package/dist/Common/ImageTags.d.ts +1 -1
- package/dist/Common/InfoColorBar/InfoColourbar.d.ts +1 -1
- package/dist/Common/Modals/Modal.d.ts +2 -2
- package/dist/Common/Modals/OpaqueModal.d.ts +3 -3
- package/dist/Common/Modals/VisibleModal.d.ts +3 -3
- package/dist/Common/Modals/VisibleModal2.d.ts +3 -3
- package/dist/Common/MultiSelectCustomization.d.ts +1 -1
- package/dist/Common/Policy.Types.d.ts +2 -2
- package/dist/Common/PopupMenu.d.ts +5 -5
- package/dist/Common/Progressing.d.ts +2 -2
- package/dist/Common/RadioGroup/RadioGroup.d.ts +1 -1
- package/dist/Common/ResizableTextarea.d.ts +1 -1
- package/dist/Common/TippyCustomized.d.ts +1 -1
- package/dist/Common/ToastBody.d.ts +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +266 -351
- package/package.json +19 -2
- package/src/Common/AddCDButton/AddCDButton.tsx +1 -2
- package/src/Common/Api.ts +21 -26
- package/src/Common/AppStatus/AppStatus.tsx +12 -12
- package/src/Common/AppStatus/utils.ts +6 -5
- package/src/Common/BreadCrumb/BreadCrumb.tsx +32 -28
- package/src/Common/BreadCrumb/BreadcrumbStore.tsx +2 -2
- package/src/Common/BreadCrumb/Types.ts +11 -12
- package/src/Common/Checkbox.tsx +17 -19
- package/src/Common/ClipboardButton/ClipboardButton.tsx +1 -1
- package/src/Common/ClipboardButton/__tests__/ClipboardButton.test.tsx +0 -1
- package/src/Common/Common.service.ts +59 -64
- package/src/Common/Constants.ts +9 -14
- package/src/Common/CustomInput/CustomInput.tsx +22 -29
- package/src/Common/CustomInput/Types.ts +4 -4
- package/src/Common/CustomInput/index.ts +1 -1
- package/src/Common/CustomTagSelector/PropagateTagInfo.tsx +15 -18
- package/src/Common/CustomTagSelector/ResizableTagTextArea.tsx +9 -9
- package/src/Common/CustomTagSelector/TagDetails.tsx +9 -3
- package/src/Common/CustomTagSelector/TagLabelSelect.tsx +7 -9
- package/src/Common/CustomTagSelector/TagLabelValueSelector.tsx +31 -35
- package/src/Common/CustomTagSelector/TagSelector.utils.ts +2 -3
- package/src/Common/CustomTagSelector/Types.ts +1 -1
- package/src/Common/CustomTagSelector/ValidationRules.ts +18 -22
- package/src/Common/CustomTagSelector/index.ts +2 -2
- package/src/Common/DebouncedSearch/DebouncedSearch.tsx +2 -1
- package/src/Common/DebouncedSearch/__tests__/DebouncedSearch.test.tsx +0 -1
- package/src/Common/DeleteComponentModal/DeleteComponent.tsx +27 -32
- package/src/Common/DeleteComponentModal/types.ts +1 -1
- package/src/Common/DevtronProgressing/DevtronProgressing.tsx +5 -8
- package/src/Common/Dialogs/ConfirmationDialog.tsx +24 -24
- package/src/Common/Dialogs/DeleteDialog.tsx +3 -5
- package/src/Common/Dialogs/DialogForm.tsx +31 -35
- package/src/Common/Dialogs/ForceDeleteDialog.tsx +13 -7
- package/src/Common/Dialogs/Types.ts +12 -12
- package/src/Common/Dialogs/index.ts +1 -1
- package/src/Common/Drawer/Drawer.tsx +1 -1
- package/src/Common/EmptyState/EmptyState.tsx +13 -17
- package/src/Common/EmptyState/GenericEmptyState.tsx +7 -21
- package/src/Common/Error.tsx +5 -5
- package/src/Common/ErrorScreenNotFound.tsx +9 -12
- package/src/Common/Grid/Grid.tsx +1 -2
- package/src/Common/Helper.tsx +23 -24
- package/src/Common/Hooks/UseClickOutside/UseClickOutside.tsx +1 -1
- package/src/Common/Hooks/UseSuperAdmin/UseSuperAdmin.tsx +1 -1
- package/src/Common/ImageTags.Types.ts +2 -3
- package/src/Common/ImageTags.tsx +61 -66
- package/src/Common/InfoColorBar/InfoColourbar.tsx +10 -5
- package/src/Common/Modals/Modal.tsx +3 -3
- package/src/Common/Modals/OpaqueModal.tsx +25 -18
- package/src/Common/Modals/VisibleModal.tsx +7 -3
- package/src/Common/Modals/VisibleModal2.tsx +20 -15
- package/src/Common/MultiSelectCustomization.tsx +9 -13
- package/src/Common/Policy.Types.ts +38 -38
- package/src/Common/PopupMenu.tsx +10 -9
- package/src/Common/Progressing.tsx +15 -18
- package/src/Common/RJSF/Form.tsx +0 -1
- package/src/Common/RJSF/common/FieldRow.tsx +0 -1
- package/src/Common/RJSF/config.ts +0 -1
- package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +1 -1
- package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +0 -1
- package/src/Common/RJSF/templates/BaseInput.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +0 -1
- package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +1 -6
- package/src/Common/RJSF/templates/Description.tsx +0 -1
- package/src/Common/RJSF/templates/Field.tsx +14 -3
- package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +6 -9
- package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +5 -7
- package/src/Common/RJSF/templates/TitleField.tsx +0 -1
- package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +0 -1
- package/src/Common/RJSF/utils.ts +53 -57
- package/src/Common/RJSF/widgets/Checkbox.tsx +2 -2
- package/src/Common/RJSF/widgets/Select.tsx +0 -1
- package/src/Common/RadioGroup/RadioGroup.tsx +18 -23
- package/src/Common/RadioGroup.tsx +24 -23
- package/src/Common/Reload.tsx +0 -1
- package/src/Common/ResizableTextarea.tsx +18 -17
- package/src/Common/Security/ScanVulnerabilitiesTable.tsx +29 -34
- package/src/Common/ServerError.ts +5 -1
- package/src/Common/TippyCustomized.tsx +41 -38
- package/src/Common/ToastBody.tsx +6 -7
- package/src/Common/Toggle/Toggle.tsx +3 -3
- package/src/Common/Types.ts +12 -12
- package/src/custom.d.ts +7 -7
- package/src/index.ts +1 -1
package/src/Common/PopupMenu.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import * as React from 'react'
|
|
2
3
|
import { Modal } from './Modals/Modal'
|
|
3
4
|
import { PopupMenuBodyType, PopupMenuButtonType, PopupMenuType } from './Types'
|
|
4
5
|
|
|
@@ -12,12 +13,12 @@ function usePopupContext() {
|
|
|
12
13
|
return context
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
const PopupMenu = ({
|
|
16
17
|
children = null,
|
|
17
18
|
onToggleCallback = null,
|
|
18
19
|
autoClose = false,
|
|
19
20
|
autoPosition = false,
|
|
20
|
-
}: PopupMenuType) {
|
|
21
|
+
}: PopupMenuType) => {
|
|
21
22
|
const [popupPosition, setPopupPosition] = React.useState(null)
|
|
22
23
|
const [opacity, setOpacity] = React.useState(0)
|
|
23
24
|
const observer = React.useRef<IntersectionObserver | null>(null)
|
|
@@ -135,15 +136,15 @@ function PopupMenu({
|
|
|
135
136
|
)
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
const Button = ({
|
|
139
140
|
children = null,
|
|
140
141
|
disabled = false,
|
|
141
142
|
rootClassName = '',
|
|
142
143
|
tabIndex = 0,
|
|
143
144
|
onHover = false,
|
|
144
145
|
isKebab = false,
|
|
145
|
-
dataTestId =
|
|
146
|
-
}: PopupMenuButtonType) {
|
|
146
|
+
dataTestId = '',
|
|
147
|
+
}: PopupMenuButtonType) => {
|
|
147
148
|
const { handleOpen, popupPosition, buttonRef, initialiseButtonWidth } = usePopupContext()
|
|
148
149
|
return (
|
|
149
150
|
<button
|
|
@@ -163,14 +164,14 @@ function Button({
|
|
|
163
164
|
)
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
|
|
167
|
+
const Body = ({
|
|
167
168
|
children = null,
|
|
168
169
|
rootClassName = '',
|
|
169
170
|
style = {},
|
|
170
171
|
autoWidth = false,
|
|
171
172
|
preventWheelDisable = false,
|
|
172
173
|
noBackDrop,
|
|
173
|
-
}: PopupMenuBodyType) {
|
|
174
|
+
}: PopupMenuBodyType) => {
|
|
174
175
|
const { handleClose, popupPosition, opacity, callbackRef, buttonWidth } = usePopupContext()
|
|
175
176
|
return popupPosition ? (
|
|
176
177
|
<Modal
|
|
@@ -183,7 +184,7 @@ function Body({
|
|
|
183
184
|
...popupPosition,
|
|
184
185
|
...style,
|
|
185
186
|
...(autoWidth ? { width: buttonWidth.current } : {}),
|
|
186
|
-
opacity
|
|
187
|
+
opacity,
|
|
187
188
|
}}
|
|
188
189
|
preventWheelDisable={preventWheelDisable}
|
|
189
190
|
noBackDrop={noBackDrop}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { ProgressingProps } from './Types'
|
|
3
2
|
|
|
4
|
-
export
|
|
3
|
+
export const Progressing = ({ pageLoader, size, theme, styles, fillColor }: ProgressingProps): JSX.Element => {
|
|
5
4
|
const loaderSize = size ? `${size}px` : pageLoader ? '48px' : '20px'
|
|
6
5
|
return (
|
|
7
6
|
<div className={`loader ${theme || 'default'}-background`} style={styles} data-testid="progressing">
|
|
@@ -29,25 +28,23 @@ export function Progressing({ pageLoader, size, theme, styles, fillColor }: Prog
|
|
|
29
28
|
)
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
export
|
|
31
|
+
export const DetailsProgressing = ({
|
|
33
32
|
loadingText,
|
|
34
33
|
size = 24,
|
|
35
34
|
fullHeight = false,
|
|
36
35
|
styles,
|
|
37
36
|
fillColor,
|
|
38
37
|
children,
|
|
39
|
-
}: ProgressingProps): JSX.Element
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
>
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
}
|
|
38
|
+
}: ProgressingProps): JSX.Element => (
|
|
39
|
+
<div
|
|
40
|
+
className={`details-loader bcn-0 flex column fs-14 fw-6 ${fullHeight ? 'h-100' : 'details-loader-height'}`}
|
|
41
|
+
style={styles}
|
|
42
|
+
data-testid="details-progressing"
|
|
43
|
+
>
|
|
44
|
+
<span style={{ width: `${size}px`, height: `${size}px` }}>
|
|
45
|
+
<Progressing size={size} fillColor={fillColor} />
|
|
46
|
+
</span>
|
|
47
|
+
{loadingText && <span className="mt-10">{loadingText}</span>}
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
)
|
package/src/Common/RJSF/Form.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { getSubmitButtonOptions, SubmitButtonProps } from '@rjsf/utils'
|
|
3
2
|
|
|
4
3
|
export const SubmitButton = ({ uiSchema }: SubmitButtonProps) => {
|
|
@@ -6,11 +5,7 @@ export const SubmitButton = ({ uiSchema }: SubmitButtonProps) => {
|
|
|
6
5
|
|
|
7
6
|
return norender ? null : (
|
|
8
7
|
<div className="flexbox flex-justify-end">
|
|
9
|
-
<button
|
|
10
|
-
type="submit"
|
|
11
|
-
{...submitButtonProps}
|
|
12
|
-
className={`cta ${submitButtonProps.className || ''}`}
|
|
13
|
-
>
|
|
8
|
+
<button type="submit" {...submitButtonProps} className={`cta ${submitButtonProps.className || ''}`}>
|
|
14
9
|
{submitText}
|
|
15
10
|
</button>
|
|
16
11
|
</div>
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { FieldTemplateProps, getUiOptions, getTemplate, ADDITIONAL_PROPERTY_FLAG } from '@rjsf/utils'
|
|
3
2
|
import { FieldRowWithLabel } from '../common/FieldRow'
|
|
4
3
|
|
|
5
4
|
export const Field = (props: FieldTemplateProps) => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
5
|
+
const {
|
|
6
|
+
id,
|
|
7
|
+
label,
|
|
8
|
+
children,
|
|
9
|
+
errors,
|
|
10
|
+
hidden,
|
|
11
|
+
required,
|
|
12
|
+
displayLabel,
|
|
13
|
+
registry,
|
|
14
|
+
uiSchema,
|
|
15
|
+
classNames,
|
|
16
|
+
schema,
|
|
17
|
+
description,
|
|
18
|
+
} = props
|
|
8
19
|
const uiOptions = getUiOptions(uiSchema)
|
|
9
20
|
const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate'>(
|
|
10
21
|
'WrapIfAdditionalTemplate',
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import { errorId, FieldErrorProps } from '@rjsf/utils'
|
|
3
2
|
|
|
4
3
|
import { ReactComponent as Error } from '../../../Assets/Icon/ic-warning.svg'
|
|
@@ -11,14 +10,12 @@ export const FieldErrorTemplate = ({ errors = [], idSchema }: FieldErrorProps) =
|
|
|
11
10
|
<span id={id}>
|
|
12
11
|
{errors
|
|
13
12
|
.filter((elem) => !!elem)
|
|
14
|
-
.map((error, index: number) =>
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
)
|
|
21
|
-
})}
|
|
13
|
+
.map((error, index: number) => (
|
|
14
|
+
<span className="form__error" key={index}>
|
|
15
|
+
<Error className="form__icon form__icon--error" />
|
|
16
|
+
{error}
|
|
17
|
+
</span>
|
|
18
|
+
))}
|
|
22
19
|
</span>
|
|
23
20
|
)
|
|
24
21
|
)
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
import {
|
|
3
2
|
ObjectFieldTemplatePropertyType,
|
|
4
3
|
ObjectFieldTemplateProps,
|
|
@@ -55,13 +54,12 @@ const Field = ({
|
|
|
55
54
|
{ActionButton}
|
|
56
55
|
</>
|
|
57
56
|
)
|
|
58
|
-
} else {
|
|
59
|
-
return (
|
|
60
|
-
<FieldRowWithLabel label={title} required={required} showLabel id={idSchema.$id}>
|
|
61
|
-
{ActionButton}
|
|
62
|
-
</FieldRowWithLabel>
|
|
63
|
-
)
|
|
64
57
|
}
|
|
58
|
+
return (
|
|
59
|
+
<FieldRowWithLabel label={title} required={required} showLabel id={idSchema.$id}>
|
|
60
|
+
{ActionButton}
|
|
61
|
+
</FieldRowWithLabel>
|
|
62
|
+
)
|
|
65
63
|
}
|
|
66
64
|
return (
|
|
67
65
|
<>
|
package/src/Common/RJSF/utils.ts
CHANGED
|
@@ -13,63 +13,59 @@ export const translateString = (stringToTranslate: TranslatableString, params?:
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export const getCommonSelectStyle = (styleOverrides = {}) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
...styleOverrides,
|
|
71
|
-
}
|
|
72
|
-
}
|
|
16
|
+
export const getCommonSelectStyle = (styleOverrides = {}) => ({
|
|
17
|
+
menuList: (base) => ({
|
|
18
|
+
...base,
|
|
19
|
+
paddingTop: 0,
|
|
20
|
+
paddingBottom: 0,
|
|
21
|
+
}),
|
|
22
|
+
control: (base, state) => ({
|
|
23
|
+
...base,
|
|
24
|
+
minHeight: '32px',
|
|
25
|
+
boxShadow: 'none',
|
|
26
|
+
backgroundColor: 'var(--N50)',
|
|
27
|
+
border: state.isFocused ? '1px solid var(--B500)' : '1px solid var(--N200)',
|
|
28
|
+
cursor: 'pointer',
|
|
29
|
+
}),
|
|
30
|
+
option: (base, state) => ({
|
|
31
|
+
...base,
|
|
32
|
+
color: 'var(--N900)',
|
|
33
|
+
backgroundColor: state.isFocused ? 'var(--N100)' : 'white',
|
|
34
|
+
padding: '10px 12px',
|
|
35
|
+
}),
|
|
36
|
+
dropdownIndicator: (base, state) => ({
|
|
37
|
+
...base,
|
|
38
|
+
color: 'var(--N400)',
|
|
39
|
+
padding: '0 8px',
|
|
40
|
+
transition: 'all .2s ease',
|
|
41
|
+
transform: state.selectProps.menuIsOpen ? 'rotate(180deg)' : 'rotate(0deg)',
|
|
42
|
+
}),
|
|
43
|
+
valueContainer: (base, state) => ({
|
|
44
|
+
...base,
|
|
45
|
+
padding: '0 8px',
|
|
46
|
+
fontWeight: '400',
|
|
47
|
+
color: state.selectProps.menuIsOpen ? 'var(--N500)' : base.color,
|
|
48
|
+
}),
|
|
49
|
+
loadingMessage: (base) => ({
|
|
50
|
+
...base,
|
|
51
|
+
color: 'var(--N600)',
|
|
52
|
+
}),
|
|
53
|
+
noOptionsMessage: (base) => ({
|
|
54
|
+
...base,
|
|
55
|
+
color: 'var(--N600)',
|
|
56
|
+
}),
|
|
57
|
+
multiValue: (base, state) => ({
|
|
58
|
+
...base,
|
|
59
|
+
border: `1px solid var(--N200)`,
|
|
60
|
+
borderRadius: `4px`,
|
|
61
|
+
background: 'white',
|
|
62
|
+
height: '28px',
|
|
63
|
+
marginRight: '8px',
|
|
64
|
+
padding: '2px',
|
|
65
|
+
fontSize: '12px',
|
|
66
|
+
}),
|
|
67
|
+
...styleOverrides,
|
|
68
|
+
})
|
|
73
69
|
|
|
74
70
|
/**
|
|
75
71
|
* Returns the redirection props for a url
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Tippy from '@tippyjs/react'
|
|
2
|
-
import
|
|
2
|
+
import { useState, useEffect } from 'react'
|
|
3
|
+
import * as React from 'react'
|
|
3
4
|
import { ConditionalWrap } from '../Helper'
|
|
4
5
|
import './radioGroup.scss'
|
|
5
6
|
|
|
@@ -28,30 +29,24 @@ interface RadioGroupComposition {
|
|
|
28
29
|
Radio?: React.FC<any>
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
const RadioGroup: React.FC<RadioGroupInterface> & RadioGroupComposition = React.memo(
|
|
32
|
-
name,
|
|
33
|
-
|
|
34
|
-
children,
|
|
35
|
-
className = '',
|
|
36
|
-
initialTab,
|
|
37
|
-
disabled = false,
|
|
38
|
-
dataTestId,
|
|
39
|
-
}) {
|
|
40
|
-
const [selected, select] = useState(null)
|
|
32
|
+
const RadioGroup: React.FC<RadioGroupInterface> & RadioGroupComposition = React.memo(
|
|
33
|
+
({ name, onChange, children, className = '', initialTab, disabled = false, dataTestId }) => {
|
|
34
|
+
const [selected, select] = useState(null)
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (initialTab === selected) return
|
|
38
|
+
select(initialTab)
|
|
39
|
+
}, [initialTab])
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
41
|
+
return (
|
|
42
|
+
<RadioContext.Provider value={{ name, selected, select, disabled, onChange }}>
|
|
43
|
+
<div className={`${className} radio-group`}>{children}</div>
|
|
44
|
+
</RadioContext.Provider>
|
|
45
|
+
)
|
|
46
|
+
},
|
|
47
|
+
)
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
const Radio = ({
|
|
55
50
|
value,
|
|
56
51
|
children,
|
|
57
52
|
className = '',
|
|
@@ -62,7 +57,7 @@ function Radio({
|
|
|
62
57
|
isDisabled = false,
|
|
63
58
|
tippyClass = '',
|
|
64
59
|
dataTestId,
|
|
65
|
-
}) {
|
|
60
|
+
}) => {
|
|
66
61
|
const { name, selected, select, disabled, onChange } = useRadioContext()
|
|
67
62
|
return (
|
|
68
63
|
<ConditionalWrap
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Component, createContext } from 'react'
|
|
2
2
|
import { RadioGroupItemProps, RadioGroupProps } from './Types'
|
|
3
|
+
|
|
3
4
|
const RadioGroupContext = createContext({ name: '', value: '', disabled: false, onChange: (event) => {} })
|
|
4
5
|
|
|
5
6
|
export class RadioGroupItem extends Component<RadioGroupItemProps> {
|
|
6
7
|
render() {
|
|
7
8
|
return (
|
|
8
9
|
<RadioGroupContext.Consumer>
|
|
9
|
-
{(context) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
</
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
10
|
+
{(context) => (
|
|
11
|
+
<label
|
|
12
|
+
className={
|
|
13
|
+
this.props.disabled || context.disabled ? 'form__radio-item disabled' : 'form__radio-item'
|
|
14
|
+
}
|
|
15
|
+
>
|
|
16
|
+
<input
|
|
17
|
+
type="radio"
|
|
18
|
+
className="form__checkbox"
|
|
19
|
+
name={context.name}
|
|
20
|
+
disabled={context.disabled || this.props.disabled}
|
|
21
|
+
onChange={context.onChange}
|
|
22
|
+
value={this.props.value}
|
|
23
|
+
checked={context.value === this.props.value}
|
|
24
|
+
data-testid={this.props.dataTestId}
|
|
25
|
+
/>
|
|
26
|
+
<span className="form__radio-item-content" data-testid={`${this.props.dataTestId}-span`}>
|
|
27
|
+
<span className="radio__button" />
|
|
28
|
+
<span className="radio__title">{this.props.children}</span>
|
|
29
|
+
</span>
|
|
30
|
+
</label>
|
|
31
|
+
)}
|
|
31
32
|
</RadioGroupContext.Consumer>
|
|
32
33
|
)
|
|
33
34
|
}
|
package/src/Common/Reload.tsx
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import * as React from 'react'
|
|
2
3
|
import { useThrottledEffect } from './Helper'
|
|
3
4
|
import { ResizableTextareaProps } from './Types'
|
|
4
5
|
|
|
5
6
|
export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
minHeight,
|
|
8
|
+
maxHeight,
|
|
9
|
+
value,
|
|
10
|
+
onChange = null,
|
|
11
|
+
onBlur = null,
|
|
12
|
+
onFocus = null,
|
|
13
|
+
className = '',
|
|
14
|
+
placeholder = 'Enter your text here..',
|
|
15
|
+
lineHeight = 14,
|
|
16
|
+
padding = 12,
|
|
17
|
+
disabled = false,
|
|
18
|
+
dataTestId,
|
|
19
|
+
...props
|
|
20
|
+
}) => {
|
|
20
21
|
const [text, setText] = useState('')
|
|
21
22
|
const _textRef = useRef(null)
|
|
22
23
|
|
|
@@ -48,7 +49,7 @@ export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
|
48
49
|
if (maxHeight && nextHeight > maxHeight) {
|
|
49
50
|
nextHeight = maxHeight
|
|
50
51
|
}
|
|
51
|
-
_textRef.current.style.height = nextHeight + 2
|
|
52
|
+
_textRef.current.style.height = `${nextHeight + 2}px`
|
|
52
53
|
},
|
|
53
54
|
500,
|
|
54
55
|
[text],
|
|
@@ -70,4 +71,4 @@ export const ResizableTextarea: React.FC<ResizableTextareaProps> = ({
|
|
|
70
71
|
{...props}
|
|
71
72
|
/>
|
|
72
73
|
)
|
|
73
|
-
}
|
|
74
|
+
}
|