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