@devtron-labs/devtron-fe-common-lib 0.0.37 → 0.0.39-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.
Files changed (73) hide show
  1. package/dist/Common/AppStatus/AppStatus.d.ts +3 -0
  2. package/dist/Common/AppStatus/constants.d.ts +51 -0
  3. package/dist/Common/AppStatus/index.d.ts +1 -0
  4. package/dist/Common/AppStatus/types.d.ts +12 -0
  5. package/dist/Common/AppStatus/utils.d.ts +1 -0
  6. package/dist/Common/Helper.d.ts +1 -0
  7. package/dist/Common/Hooks/UseClickOutside/UseClickOutside.d.ts +1 -0
  8. package/dist/Common/Hooks/index.d.ts +1 -0
  9. package/dist/Common/RJSF/Form.d.ts +4 -0
  10. package/dist/Common/RJSF/common/FieldRow.d.ts +3 -0
  11. package/dist/Common/RJSF/common/types.d.ts +8 -0
  12. package/dist/Common/RJSF/config.d.ts +4 -0
  13. package/dist/Common/RJSF/constants.d.ts +5 -0
  14. package/dist/Common/RJSF/index.d.ts +2 -0
  15. package/dist/Common/RJSF/templates/ArrayFieldItemTemplate.d.ts +3 -0
  16. package/dist/Common/RJSF/templates/ArrayFieldTemplate.d.ts +3 -0
  17. package/dist/Common/RJSF/templates/BaseInput.d.ts +3 -0
  18. package/dist/Common/RJSF/templates/ButtonTemplates/AddButton.d.ts +3 -0
  19. package/dist/Common/RJSF/templates/ButtonTemplates/RemoveButton.d.ts +3 -0
  20. package/dist/Common/RJSF/templates/ButtonTemplates/SubmitButton.d.ts +3 -0
  21. package/dist/Common/RJSF/templates/ButtonTemplates/index.d.ts +3 -0
  22. package/dist/Common/RJSF/templates/Description.d.ts +3 -0
  23. package/dist/Common/RJSF/templates/Field.d.ts +3 -0
  24. package/dist/Common/RJSF/templates/FieldErrorTemplate.d.ts +3 -0
  25. package/dist/Common/RJSF/templates/ObjectFieldTemplate.d.ts +3 -0
  26. package/dist/Common/RJSF/templates/TitleField.d.ts +3 -0
  27. package/dist/Common/RJSF/templates/WrapIfAdditionalTemplate.d.ts +3 -0
  28. package/dist/Common/RJSF/templates/index.d.ts +10 -0
  29. package/dist/Common/RJSF/types.d.ts +3 -0
  30. package/dist/Common/RJSF/utils.d.ts +14 -0
  31. package/dist/Common/RJSF/widgets/Checkbox.d.ts +3 -0
  32. package/dist/Common/RJSF/widgets/Select.d.ts +3 -0
  33. package/dist/Common/RJSF/widgets/index.d.ts +2 -0
  34. package/dist/Common/index.d.ts +2 -0
  35. package/dist/index.js +487 -147
  36. package/package.json +4 -1
  37. package/src/Assets/Icon/ic-chevron-down.svg +5 -0
  38. package/src/Common/AppStatus/AppStatus.tsx +64 -0
  39. package/src/Common/AppStatus/constants.ts +53 -0
  40. package/src/Common/AppStatus/index.ts +1 -0
  41. package/src/Common/AppStatus/types.ts +12 -0
  42. package/src/Common/AppStatus/utils.ts +14 -0
  43. package/src/Common/Helper.tsx +8 -0
  44. package/src/Common/Hooks/UseClickOutside/UseClickOutside.tsx +15 -0
  45. package/src/Common/Hooks/index.ts +1 -0
  46. package/src/Common/RJSF/Form.tsx +28 -0
  47. package/src/Common/RJSF/common/FieldRow.tsx +31 -0
  48. package/src/Common/RJSF/common/types.ts +9 -0
  49. package/src/Common/RJSF/config.ts +37 -0
  50. package/src/Common/RJSF/constants.ts +5 -0
  51. package/src/Common/RJSF/index.ts +2 -0
  52. package/src/Common/RJSF/rjsfForm.scss +17 -0
  53. package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +33 -0
  54. package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +77 -0
  55. package/src/Common/RJSF/templates/BaseInput.tsx +16 -0
  56. package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +18 -0
  57. package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +10 -0
  58. package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +18 -0
  59. package/src/Common/RJSF/templates/ButtonTemplates/index.ts +3 -0
  60. package/src/Common/RJSF/templates/Description.tsx +12 -0
  61. package/src/Common/RJSF/templates/Field.tsx +30 -0
  62. package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +25 -0
  63. package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +96 -0
  64. package/src/Common/RJSF/templates/TitleField.tsx +9 -0
  65. package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +51 -0
  66. package/src/Common/RJSF/templates/index.ts +10 -0
  67. package/src/Common/RJSF/types.ts +4 -0
  68. package/src/Common/RJSF/utils.ts +59 -0
  69. package/src/Common/RJSF/widgets/Checkbox.tsx +44 -0
  70. package/src/Common/RJSF/widgets/Select.tsx +72 -0
  71. package/src/Common/RJSF/widgets/index.ts +2 -0
  72. package/src/Common/Security/scanVulnerabilities.css +2 -0
  73. package/src/Common/index.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtron-labs/devtron-fe-common-lib",
3
- "version": "0.0.37",
3
+ "version": "0.0.39-beta-1",
4
4
  "description": "Supporting common component library",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -41,6 +41,9 @@
41
41
  "@sentry/browser": "^7.31.1"
42
42
  },
43
43
  "peerDependencies": {
44
+ "@rjsf/core": "^5.13.3",
45
+ "@rjsf/utils": "^5.13.3",
46
+ "@rjsf/validator-ajv8": "^5.13.3",
44
47
  "react": "^17.0.2",
45
48
  "react-dom": "^17.0.2",
46
49
  "react-router": "^5.3.0",
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
2
+ <g fill="none" fill-rule="evenodd">
3
+ <path fill="#999" class="fill-color" fill-rule="nonzero" d="M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6z"/>
4
+ </g>
5
+ </svg>
@@ -0,0 +1,64 @@
1
+ import Tippy from '@tippyjs/react'
2
+ import { ReactComponent as InfoIcon } from '../../Assets/Icon/ic-info-outlined.svg'
3
+ import { StatusConstants, YET_TO_RUN } from './constants'
4
+ import { AppStatusType } from './types'
5
+ import { triggerStatus } from './utils'
6
+
7
+ export default function AppStatus({
8
+ appStatus,
9
+ isDeploymentStatus = false,
10
+ isJobView = false,
11
+ isVirtualEnv,
12
+ hideStatusMessage = false,
13
+ }: AppStatusType) {
14
+ let status = appStatus
15
+ if (isDeploymentStatus) {
16
+ status = triggerStatus(appStatus)
17
+ }
18
+ const appStatusLowerCase = status?.toLowerCase()
19
+ const isNotDeployed = appStatusLowerCase === StatusConstants.NOT_DEPLOYED.noSpaceLower
20
+ const iconClass = isNotDeployed ? StatusConstants.NOT_DEPLOYED.lowerCase : appStatusLowerCase
21
+ const statusMessage = status || (isVirtualEnv ? StatusConstants.NOT_AVILABLE.normalCase : '-')
22
+ const notDeployed = isJobView ? YET_TO_RUN : StatusConstants.NOT_DEPLOYED.normalCase
23
+ const textContent = isNotDeployed ? notDeployed : statusMessage
24
+
25
+ const renderIcon = () => {
26
+ if (iconClass) {
27
+ return <span className={`dc__app-summary__icon icon-dim-16 ${iconClass} ${iconClass}--node`} />
28
+ } else if (isVirtualEnv) {
29
+ return (
30
+ <span
31
+ className={`dc__app-summary__icon icon-dim-16 ${StatusConstants.NOT_DEPLOYED.lowerCase} ${StatusConstants.NOT_DEPLOYED.lowerCase}--node`}
32
+ />
33
+ )
34
+ } else {
35
+ return (
36
+ <Tippy
37
+ className="default-tt w-200"
38
+ arrow={false}
39
+ placement="top"
40
+ content="To fetch app status for GitOps based deployments open the app detail page"
41
+ >
42
+ <InfoIcon className="icon-dim-16 fcn-6" />
43
+ </Tippy>
44
+ )
45
+ }
46
+ }
47
+
48
+ return hideStatusMessage ? (
49
+ iconClass || isVirtualEnv ? (
50
+ <Tippy className="default-tt" arrow={false} placement="top" content={textContent}>
51
+ <div className="flex">{renderIcon()}</div>
52
+ </Tippy>
53
+ ) : (
54
+ renderIcon()
55
+ )
56
+ ) : (
57
+ <div className="flex left">
58
+ <div className="flex mr-6">{renderIcon()}</div>
59
+ <p data-testid={`${status}-app-status`} className="dc__truncate-text dc__first-letter-capitalize cn-6 m-0">
60
+ {textContent}
61
+ </p>
62
+ </div>
63
+ )
64
+ }
@@ -0,0 +1,53 @@
1
+ export const StatusConstants = {
2
+ NOT_DEPLOYED: {
3
+ noSpaceLower: 'notdeployed',
4
+ normalCase: 'Not deployed',
5
+ lowerCase: 'not-deployed',
6
+ },
7
+ APP_STATUS: {
8
+ noSpaceLower: 'appStatus',
9
+ normalText: 'App status',
10
+ },
11
+ PROJECT: {
12
+ pluralLower: 'projects',
13
+ lowerCase: 'project',
14
+ },
15
+ CLUSTER: {
16
+ pluralLower: 'clusters',
17
+ lowerCase: 'cluster',
18
+ },
19
+ NAMESPACE: {
20
+ pluralLower: 'namespaces',
21
+ lowerCase: 'namespace',
22
+ },
23
+ ENVIRONMENT: {
24
+ pluralLower: 'environments',
25
+ lowerCase: 'environment',
26
+ },
27
+ NOT_AVILABLE: {
28
+ normalCase: 'Not available',
29
+ },
30
+ }
31
+
32
+ export enum TIMELINE_STATUS {
33
+ DEPLOYMENT_INITIATED = 'DEPLOYMENT_INITIATED',
34
+ GIT_COMMIT = 'GIT_COMMIT',
35
+ GIT_COMMIT_FAILED = 'GIT_COMMIT_FAILED',
36
+ KUBECTL_APPLY = 'KUBECTL_APPLY',
37
+ KUBECTL_APPLY_STARTED = 'KUBECTL_APPLY_STARTED',
38
+ KUBECTL_APPLY_SYNCED = 'KUBECTL_APPLY_SYNCED',
39
+ HEALTHY = 'HEALTHY',
40
+ APP_HEALTH = 'APP_HEALTH',
41
+ DEPLOYMENT_FAILED = 'FAILED',
42
+ FETCH_TIMED_OUT = 'TIMED_OUT',
43
+ UNABLE_TO_FETCH_STATUS = 'UNABLE_TO_FETCH_STATUS',
44
+ DEGRADED = 'DEGRADED',
45
+ DEPLOYMENT_SUPERSEDED = 'DEPLOYMENT_SUPERSEDED',
46
+ ABORTED = 'ABORTED',
47
+ INPROGRESS = 'INPROGRESS',
48
+ HELM_PACKAGE_GENERATED = 'HELM_PACKAGE_GENERATED',
49
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO',
50
+ HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED = 'HELM_MANIFEST_PUSHED_TO_HELM_REPO_FAILED',
51
+ }
52
+
53
+ export const YET_TO_RUN = 'Yet to run'
@@ -0,0 +1 @@
1
+ export { default as AppStatus } from './AppStatus'
@@ -0,0 +1,12 @@
1
+ export interface AppStatusType {
2
+ appStatus: string
3
+ isDeploymentStatus?: boolean
4
+ isJobView?: boolean
5
+ isVirtualEnv?: boolean
6
+ /**
7
+ * Hide the status message if true and show status message in tooltip
8
+ *
9
+ * @default false
10
+ */
11
+ hideStatusMessage?: boolean
12
+ }
@@ -0,0 +1,14 @@
1
+ import { TIMELINE_STATUS } from './constants'
2
+
3
+ export const triggerStatus = (triggerDetailStatus: string): string => {
4
+ let triggerStatus = triggerDetailStatus?.toUpperCase()
5
+ if (triggerStatus === TIMELINE_STATUS.ABORTED || triggerStatus === TIMELINE_STATUS.DEGRADED) {
6
+ return 'Failed'
7
+ } else if (triggerStatus === TIMELINE_STATUS.HEALTHY) {
8
+ return 'Succeeded'
9
+ } else if (triggerStatus === TIMELINE_STATUS.INPROGRESS) {
10
+ return 'Inprogress'
11
+ } else {
12
+ return triggerDetailStatus
13
+ }
14
+ }
@@ -487,3 +487,11 @@ export function useAsync<T>(
487
487
 
488
488
  return [state.loading, state.result, state.error, reload, setResult, state.dependencies]
489
489
  }
490
+
491
+ export const processDeployedTime = (lastDeployed, isArgoInstalled) => {
492
+ if (lastDeployed) {
493
+ return handleUTCTime(lastDeployed, true)
494
+ } else {
495
+ return isArgoInstalled ? '' : 'Not deployed'
496
+ }
497
+ }
@@ -0,0 +1,15 @@
1
+ import React, { useEffect } from 'react'
2
+
3
+ export const useClickOutside = (ref: any, callback: () => void) => {
4
+ useEffect(() => {
5
+ const handleClickOutside = (e: any) => {
6
+ if (ref?.current && !ref.current.contains(e.target)) {
7
+ callback()
8
+ }
9
+ }
10
+ document.addEventListener('click', handleClickOutside)
11
+ return () => {
12
+ document.removeEventListener('click', handleClickOutside)
13
+ }
14
+ }, [ref, callback])
15
+ }
@@ -1 +1,2 @@
1
1
  export { useSuperAdmin } from './UseSuperAdmin/UseSuperAdmin'
2
+ export { useClickOutside } from './UseClickOutside/UseClickOutside'
@@ -0,0 +1,28 @@
1
+ import React from 'react'
2
+ import RJSF from '@rjsf/core'
3
+ import validator from '@rjsf/validator-ajv8'
4
+
5
+ import { templates, widgets } from './config'
6
+ import { FormProps } from './types'
7
+ import { translateString } from './utils'
8
+ import './rjsfForm.scss'
9
+
10
+ // Need to use this way because the default import was not working as expected
11
+ // The default import resolves to an object intead of a function
12
+ const Form = (RJSF as any).default as typeof RJSF
13
+
14
+ export const RJSFForm = (props: FormProps) => (
15
+ <Form
16
+ noHtml5Validate
17
+ showErrorList={false}
18
+ autoComplete="off"
19
+ {...props}
20
+ validator={validator}
21
+ templates={{
22
+ ...templates,
23
+ ...props.templates,
24
+ }}
25
+ widgets={{ ...widgets, ...props.widgets }}
26
+ translateString={translateString}
27
+ />
28
+ )
@@ -0,0 +1,31 @@
1
+ import React from 'react'
2
+ import { FieldRowProps } from './types'
3
+
4
+ export const FieldRowWithLabel = ({
5
+ showLabel,
6
+ label,
7
+ required,
8
+ children,
9
+ id,
10
+ shouldAlignCenter = true,
11
+ }: FieldRowProps) => (
12
+ <div
13
+ className={
14
+ showLabel
15
+ ? `display-grid dc__gap-12 rjsf-form-template__field ${shouldAlignCenter ? 'flex-align-center' : ''}`
16
+ : ''
17
+ }
18
+ >
19
+ {showLabel && (
20
+ <label className="cn-7 fs-13 lh-32 fw-4 flexbox mb-0" htmlFor={id}>
21
+ {!!label && (
22
+ <>
23
+ <span className="dc__ellipsis-right">{label}</span>
24
+ {required && <span className="cr-5">&nbsp;*</span>}
25
+ </>
26
+ )}
27
+ </label>
28
+ )}
29
+ {children}
30
+ </div>
31
+ )
@@ -0,0 +1,9 @@
1
+ import { FieldTemplateProps } from '@rjsf/utils'
2
+
3
+ export interface FieldRowProps extends Pick<FieldTemplateProps, 'children' | 'label' | 'required' | 'id'> {
4
+ showLabel?: boolean
5
+ /**
6
+ * @default true
7
+ */
8
+ shouldAlignCenter?: boolean
9
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react'
2
+ import { RegistryWidgetsType } from '@rjsf/utils'
3
+
4
+ import {
5
+ AddButton,
6
+ ArrayFieldItemTemplate,
7
+ ArrayFieldTemplate,
8
+ BaseInputTemplate,
9
+ DescriptionFieldTemplate,
10
+ FieldTemplate,
11
+ FieldErrorTemplate,
12
+ ObjectFieldTemplate,
13
+ RemoveButton,
14
+ SubmitButton,
15
+ TitleFieldTemplate,
16
+ WrapIfAdditionalTemplate,
17
+ } from './templates'
18
+ import { CheckboxWidget, SelectWidget } from './widgets'
19
+ import { FormProps } from './types'
20
+
21
+ export const widgets: RegistryWidgetsType = {
22
+ CheckboxWidget,
23
+ SelectWidget,
24
+ }
25
+
26
+ export const templates: FormProps['templates'] = {
27
+ ArrayFieldItemTemplate,
28
+ ArrayFieldTemplate,
29
+ BaseInputTemplate,
30
+ ButtonTemplates: { AddButton, RemoveButton, SubmitButton },
31
+ DescriptionFieldTemplate,
32
+ FieldTemplate,
33
+ FieldErrorTemplate,
34
+ ObjectFieldTemplate,
35
+ TitleFieldTemplate,
36
+ WrapIfAdditionalTemplate,
37
+ }
@@ -0,0 +1,5 @@
1
+ export const PLACEHOLDERS = {
2
+ SELECT: 'Please select an option',
3
+ INPUT: 'Please enter an input',
4
+ OBJECT_KEY: 'Please enter a value for the key',
5
+ }
@@ -0,0 +1,2 @@
1
+ export { RJSFForm } from './Form'
2
+ export * from './types'
@@ -0,0 +1,17 @@
1
+ .rjsf-form-template {
2
+ &__field {
3
+ grid-template-columns: 250px 1fr;
4
+ }
5
+
6
+ &__additional-fields {
7
+ grid-template-columns: 1fr 1fr minmax(20px, auto);
8
+ }
9
+
10
+ &__array-field-item {
11
+ grid-template-columns: 1fr auto;
12
+
13
+ & :first-child {
14
+ margin: 0;
15
+ }
16
+ }
17
+ }
@@ -0,0 +1,33 @@
1
+ import React, { CSSProperties } from 'react'
2
+ import { ArrayFieldTemplateItemType } from '@rjsf/utils'
3
+
4
+ export const ArrayFieldItemTemplate = ({
5
+ children,
6
+ className,
7
+ disabled,
8
+ hasToolbar,
9
+ hasRemove,
10
+ index,
11
+ onDropIndexClick,
12
+ readonly,
13
+ registry,
14
+ uiSchema,
15
+ }: ArrayFieldTemplateItemType) => {
16
+ const { RemoveButton } = registry.templates.ButtonTemplates
17
+
18
+ return (
19
+ <div className="display-grid rjsf-form-template__array-field-item flex-align-center dc__gap-8 mb-12">
20
+ {children}
21
+ {hasToolbar && hasRemove && (
22
+ <div>
23
+ <RemoveButton
24
+ disabled={disabled || readonly}
25
+ onClick={onDropIndexClick(index)}
26
+ uiSchema={uiSchema}
27
+ registry={registry}
28
+ />
29
+ </div>
30
+ )}
31
+ </div>
32
+ )
33
+ }
@@ -0,0 +1,77 @@
1
+ import React from 'react'
2
+ import { getTemplate, getUiOptions, ArrayFieldTemplateProps, ArrayFieldTemplateItemType } from '@rjsf/utils'
3
+ import { FieldRowWithLabel } from '../common/FieldRow'
4
+
5
+ const ActionButton = ({ canAdd, onAddClick, disabled, readonly, uiSchema, registry }) => {
6
+ const {
7
+ ButtonTemplates: { AddButton },
8
+ } = registry.templates
9
+
10
+ return (
11
+ canAdd && (
12
+ <AddButton onClick={onAddClick} disabled={disabled || readonly} uiSchema={uiSchema} registry={registry} />
13
+ )
14
+ )
15
+ }
16
+
17
+ export const ArrayFieldTemplate = ({
18
+ canAdd,
19
+ className,
20
+ disabled,
21
+ idSchema,
22
+ uiSchema,
23
+ items,
24
+ onAddClick,
25
+ readonly,
26
+ registry,
27
+ required,
28
+ title,
29
+ }: ArrayFieldTemplateProps) => {
30
+ const uiOptions = getUiOptions(uiSchema)
31
+ const ArrayFieldItemTemplate = getTemplate<'ArrayFieldItemTemplate'>('ArrayFieldItemTemplate', registry, uiOptions)
32
+ const label = uiOptions.title || title
33
+
34
+ return (
35
+ <fieldset className={className} id={idSchema.$id}>
36
+ {/* Show the label here in case there are no items, otherwise handled by Field Template */}
37
+ {items.length ? (
38
+ <>
39
+ {items.map(({ key, ...itemProps }: ArrayFieldTemplateItemType, index) => {
40
+ // Show the title as the label for the first field
41
+ const children = {
42
+ ...itemProps.children,
43
+ props: {
44
+ ...itemProps.children.props,
45
+ name: index === 0 ? label : '',
46
+ },
47
+ }
48
+ return (
49
+ <ArrayFieldItemTemplate key={key} {...itemProps}>
50
+ {children}
51
+ </ArrayFieldItemTemplate>
52
+ )
53
+ })}
54
+ <ActionButton
55
+ canAdd={canAdd}
56
+ onAddClick={onAddClick}
57
+ disabled={disabled}
58
+ readonly={readonly}
59
+ uiSchema={uiSchema}
60
+ registry={registry}
61
+ />
62
+ </>
63
+ ) : (
64
+ <FieldRowWithLabel label={label} required={required} showLabel id={idSchema.$id}>
65
+ <ActionButton
66
+ canAdd={canAdd}
67
+ onAddClick={onAddClick}
68
+ disabled={disabled}
69
+ readonly={readonly}
70
+ uiSchema={uiSchema}
71
+ registry={registry}
72
+ />
73
+ </FieldRowWithLabel>
74
+ )}
75
+ </fieldset>
76
+ )
77
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import { getDefaultRegistry } from '@rjsf/core'
3
+ import { BaseInputTemplateProps } from '@rjsf/utils'
4
+ import { PLACEHOLDERS } from '../constants'
5
+
6
+ const {
7
+ templates: { BaseInputTemplate },
8
+ } = getDefaultRegistry()
9
+
10
+ export const BaseInput = ({ placeholder, ...props }: BaseInputTemplateProps) => (
11
+ <BaseInputTemplate
12
+ placeholder={placeholder || PLACEHOLDERS.INPUT}
13
+ {...props}
14
+ className="form__input cn-9 fs-13 lh-20 fw-4"
15
+ />
16
+ )
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+ import { IconButtonProps } from '@rjsf/utils'
3
+
4
+ import { ReactComponent as PlusIcon } from '../../../../Assets/Icon/ic-add.svg'
5
+
6
+ export const AddButton = ({ icon, iconType, registry, uiSchema, ...props }: IconButtonProps) => (
7
+ <div className="flexbox flex-justify-end">
8
+ <button
9
+ {...props}
10
+ type="button"
11
+ className="dc__outline-none-imp p-0 dc__transparent flex dc__gap-4 cursor"
12
+ title="Add"
13
+ >
14
+ <PlusIcon className="icon-dim-16 fcb-5" />
15
+ <span className="cb-5 fs-13 lh-20">Add</span>
16
+ </button>
17
+ </div>
18
+ )
@@ -0,0 +1,10 @@
1
+ import React from 'react'
2
+ import { IconButtonProps } from '@rjsf/utils'
3
+
4
+ import { ReactComponent as CrossIcon } from '../../../../Assets/Icon/ic-cross.svg'
5
+
6
+ export const RemoveButton = ({ icon, iconType, registry, uiSchema, ...props }: IconButtonProps) => (
7
+ <button {...props} type="button" className="dc__outline-none-imp p-0 dc__transparent flex cursor" title="Remove">
8
+ <CrossIcon className="icon-dim-16 fcr-5" />
9
+ </button>
10
+ )
@@ -0,0 +1,18 @@
1
+ import React from 'react'
2
+ import { getSubmitButtonOptions, SubmitButtonProps } from '@rjsf/utils'
3
+
4
+ export const SubmitButton = ({ uiSchema }: SubmitButtonProps) => {
5
+ const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema)
6
+
7
+ return norender ? null : (
8
+ <div className="flexbox flex-justify-end">
9
+ <button
10
+ type="submit"
11
+ {...submitButtonProps}
12
+ className={`cta ${submitButtonProps.className || ''}`}
13
+ >
14
+ {submitText}
15
+ </button>
16
+ </div>
17
+ )
18
+ }
@@ -0,0 +1,3 @@
1
+ export { AddButton } from './AddButton'
2
+ export { RemoveButton } from './RemoveButton'
3
+ export { SubmitButton } from './SubmitButton'
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import { DescriptionFieldProps } from '@rjsf/utils'
3
+
4
+ import { ReactComponent as Info } from '../../../Assets/Icon/ic-info-filled.svg'
5
+
6
+ export const Description = ({ id, description }: DescriptionFieldProps) =>
7
+ description && (
8
+ <div id={id} className="flex left flex-align-center mt-4 dc__gap-4">
9
+ <Info className="icon-dim-16 mw-16 info-icon-n5" />
10
+ <span className="cn-7 fs-11 fw-4 dc__ellipsis-right">{description}</span>
11
+ </div>
12
+ )
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+ import { FieldTemplateProps, getUiOptions, getTemplate, ADDITIONAL_PROPERTY_FLAG } from '@rjsf/utils'
3
+ import { FieldRowWithLabel } from '../common/FieldRow'
4
+
5
+ export const Field = (props: FieldTemplateProps) => {
6
+ const { id, label, children, errors, hidden, required, displayLabel, registry, uiSchema, classNames, schema, description } =
7
+ props
8
+ const uiOptions = getUiOptions(uiSchema)
9
+ const WrapIfAdditionalTemplate = getTemplate<'WrapIfAdditionalTemplate'>(
10
+ 'WrapIfAdditionalTemplate',
11
+ registry,
12
+ uiOptions,
13
+ )
14
+ // Object type fields have additional properties for key/value pairs
15
+ const hasAdditionalProperties = ADDITIONAL_PROPERTY_FLAG in schema
16
+ // Label is not displayed for boolean fields by default and hide for object type fields
17
+ const showLabel = (displayLabel || schema.type === 'boolean') && !hasAdditionalProperties
18
+
19
+ return hidden ? (
20
+ <div className="hidden">{children}</div>
21
+ ) : (
22
+ <div className={`${classNames} mb-12`}>
23
+ <FieldRowWithLabel label={label} showLabel={showLabel} id={id} required={required}>
24
+ <WrapIfAdditionalTemplate {...props}>{children}</WrapIfAdditionalTemplate>
25
+ </FieldRowWithLabel>
26
+ {description}
27
+ {errors}
28
+ </div>
29
+ )
30
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react'
2
+ import { errorId, FieldErrorProps } from '@rjsf/utils'
3
+
4
+ import { ReactComponent as Error } from '../../../Assets/Icon/ic-warning.svg'
5
+
6
+ export const FieldErrorTemplate = ({ errors = [], idSchema }: FieldErrorProps) => {
7
+ const id = errorId(idSchema)
8
+
9
+ return (
10
+ errors.length > 0 && (
11
+ <span id={id}>
12
+ {errors
13
+ .filter((elem) => !!elem)
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
+ })}
22
+ </span>
23
+ )
24
+ )
25
+ }