@devtron-labs/devtron-fe-common-lib 0.0.39-beta-2 → 0.0.40

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 (63) hide show
  1. package/dist/Common/Common.service.d.ts +2 -2
  2. package/dist/Common/Constants.d.ts +1 -0
  3. package/dist/Common/Types.d.ts +36 -2
  4. package/dist/Common/index.d.ts +0 -1
  5. package/dist/index.js +339 -441
  6. package/package.json +1 -4
  7. package/src/Common/Common.service.ts +223 -76
  8. package/src/Common/Constants.ts +1 -0
  9. package/src/Common/ImageTags.tsx +11 -2
  10. package/src/Common/Types.ts +44 -2
  11. package/src/Common/index.ts +0 -1
  12. package/dist/Common/RJSF/Form.d.ts +0 -4
  13. package/dist/Common/RJSF/common/FieldRow.d.ts +0 -3
  14. package/dist/Common/RJSF/common/types.d.ts +0 -8
  15. package/dist/Common/RJSF/config.d.ts +0 -4
  16. package/dist/Common/RJSF/constants.d.ts +0 -5
  17. package/dist/Common/RJSF/index.d.ts +0 -2
  18. package/dist/Common/RJSF/templates/ArrayFieldItemTemplate.d.ts +0 -3
  19. package/dist/Common/RJSF/templates/ArrayFieldTemplate.d.ts +0 -3
  20. package/dist/Common/RJSF/templates/BaseInput.d.ts +0 -3
  21. package/dist/Common/RJSF/templates/ButtonTemplates/AddButton.d.ts +0 -3
  22. package/dist/Common/RJSF/templates/ButtonTemplates/RemoveButton.d.ts +0 -3
  23. package/dist/Common/RJSF/templates/ButtonTemplates/SubmitButton.d.ts +0 -3
  24. package/dist/Common/RJSF/templates/ButtonTemplates/index.d.ts +0 -3
  25. package/dist/Common/RJSF/templates/Description.d.ts +0 -3
  26. package/dist/Common/RJSF/templates/Field.d.ts +0 -3
  27. package/dist/Common/RJSF/templates/FieldErrorTemplate.d.ts +0 -3
  28. package/dist/Common/RJSF/templates/ObjectFieldTemplate.d.ts +0 -3
  29. package/dist/Common/RJSF/templates/TitleField.d.ts +0 -3
  30. package/dist/Common/RJSF/templates/WrapIfAdditionalTemplate.d.ts +0 -3
  31. package/dist/Common/RJSF/templates/index.d.ts +0 -10
  32. package/dist/Common/RJSF/types.d.ts +0 -3
  33. package/dist/Common/RJSF/utils.d.ts +0 -14
  34. package/dist/Common/RJSF/widgets/Checkbox.d.ts +0 -3
  35. package/dist/Common/RJSF/widgets/Select.d.ts +0 -3
  36. package/dist/Common/RJSF/widgets/index.d.ts +0 -2
  37. package/src/Assets/Icon/ic-chevron-down.svg +0 -5
  38. package/src/Common/RJSF/Form.tsx +0 -29
  39. package/src/Common/RJSF/common/FieldRow.tsx +0 -31
  40. package/src/Common/RJSF/common/types.ts +0 -9
  41. package/src/Common/RJSF/config.ts +0 -37
  42. package/src/Common/RJSF/constants.ts +0 -5
  43. package/src/Common/RJSF/index.ts +0 -2
  44. package/src/Common/RJSF/rjsfForm.scss +0 -17
  45. package/src/Common/RJSF/templates/ArrayFieldItemTemplate.tsx +0 -33
  46. package/src/Common/RJSF/templates/ArrayFieldTemplate.tsx +0 -77
  47. package/src/Common/RJSF/templates/BaseInput.tsx +0 -16
  48. package/src/Common/RJSF/templates/ButtonTemplates/AddButton.tsx +0 -18
  49. package/src/Common/RJSF/templates/ButtonTemplates/RemoveButton.tsx +0 -10
  50. package/src/Common/RJSF/templates/ButtonTemplates/SubmitButton.tsx +0 -18
  51. package/src/Common/RJSF/templates/ButtonTemplates/index.ts +0 -3
  52. package/src/Common/RJSF/templates/Description.tsx +0 -12
  53. package/src/Common/RJSF/templates/Field.tsx +0 -30
  54. package/src/Common/RJSF/templates/FieldErrorTemplate.tsx +0 -25
  55. package/src/Common/RJSF/templates/ObjectFieldTemplate.tsx +0 -96
  56. package/src/Common/RJSF/templates/TitleField.tsx +0 -9
  57. package/src/Common/RJSF/templates/WrapIfAdditionalTemplate.tsx +0 -51
  58. package/src/Common/RJSF/templates/index.ts +0 -10
  59. package/src/Common/RJSF/types.ts +0 -4
  60. package/src/Common/RJSF/utils.ts +0 -59
  61. package/src/Common/RJSF/widgets/Checkbox.tsx +0 -44
  62. package/src/Common/RJSF/widgets/Select.tsx +0 -72
  63. package/src/Common/RJSF/widgets/index.ts +0 -2
@@ -1,29 +0,0 @@
1
- import React from 'react'
2
- import RJSF from '@rjsf/core'
3
- import RJSFValidator 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
- const validator = (RJSFValidator as any).default as typeof RJSFValidator
14
-
15
- export const RJSFForm = (props: FormProps) => (
16
- <Form
17
- noHtml5Validate
18
- showErrorList={false}
19
- autoComplete="off"
20
- {...props}
21
- validator={validator}
22
- templates={{
23
- ...templates,
24
- ...props.templates,
25
- }}
26
- widgets={{ ...widgets, ...props.widgets }}
27
- translateString={translateString}
28
- />
29
- )
@@ -1,31 +0,0 @@
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
- )
@@ -1,9 +0,0 @@
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
- }
@@ -1,37 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export { RJSFForm } from './Form'
2
- export * from './types'
@@ -1,17 +0,0 @@
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
- }
@@ -1,33 +0,0 @@
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
- }
@@ -1,77 +0,0 @@
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
- }
@@ -1,16 +0,0 @@
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
- )
@@ -1,18 +0,0 @@
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
- )
@@ -1,10 +0,0 @@
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
- )
@@ -1,18 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export { AddButton } from './AddButton'
2
- export { RemoveButton } from './RemoveButton'
3
- export { SubmitButton } from './SubmitButton'
@@ -1,12 +0,0 @@
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
- )
@@ -1,30 +0,0 @@
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
- }
@@ -1,25 +0,0 @@
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
- }
@@ -1,96 +0,0 @@
1
- import React from 'react'
2
- import {
3
- ObjectFieldTemplatePropertyType,
4
- ObjectFieldTemplateProps,
5
- canExpand,
6
- getTemplate,
7
- getUiOptions,
8
- titleId,
9
- } from '@rjsf/utils'
10
- import { FieldRowWithLabel } from '../common/FieldRow'
11
-
12
- const Field = ({
13
- disabled,
14
- formData,
15
- idSchema,
16
- onAddClick,
17
- properties,
18
- readonly,
19
- registry,
20
- required,
21
- schema,
22
- title,
23
- uiSchema,
24
- }: ObjectFieldTemplateProps) => {
25
- const {
26
- ButtonTemplates: { AddButton },
27
- } = registry.templates
28
- const hasAdditionalProperties = !!schema.additionalProperties
29
-
30
- const ActionButton = canExpand(schema, uiSchema, formData) && (
31
- <AddButton
32
- className="object-property-expand"
33
- onClick={onAddClick(schema)}
34
- disabled={disabled || readonly}
35
- uiSchema={uiSchema}
36
- registry={registry}
37
- />
38
- )
39
-
40
- const Properties = properties.map((prop: ObjectFieldTemplatePropertyType) => prop.content)
41
-
42
- if (hasAdditionalProperties) {
43
- if (properties.length) {
44
- return (
45
- <>
46
- <FieldRowWithLabel
47
- label={title}
48
- required={required}
49
- showLabel
50
- id={idSchema.$id}
51
- shouldAlignCenter={false}
52
- >
53
- <div>{Properties}</div>
54
- </FieldRowWithLabel>
55
- {ActionButton}
56
- </>
57
- )
58
- } else {
59
- return (
60
- <FieldRowWithLabel label={title} required={required} showLabel id={idSchema.$id}>
61
- {ActionButton}
62
- </FieldRowWithLabel>
63
- )
64
- }
65
- }
66
- return (
67
- <>
68
- {Properties}
69
- {ActionButton}
70
- </>
71
- )
72
- }
73
-
74
- export const ObjectFieldTemplate = (props: ObjectFieldTemplateProps) => {
75
- const { idSchema, registry, required, schema, title, uiSchema } = props
76
- const options = getUiOptions(uiSchema)
77
- const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options)
78
- const hasAdditionalProperties = !!schema.additionalProperties
79
- const showTitle = title && !hasAdditionalProperties
80
-
81
- return (
82
- <fieldset id={idSchema.$id}>
83
- {showTitle && (
84
- <TitleFieldTemplate
85
- id={titleId(idSchema)}
86
- title={title}
87
- required={required}
88
- schema={schema}
89
- uiSchema={uiSchema}
90
- registry={registry}
91
- />
92
- )}
93
- <Field {...props} />
94
- </fieldset>
95
- )
96
- }
@@ -1,9 +0,0 @@
1
- import React from 'react'
2
- import { TitleFieldProps } from '@rjsf/utils'
3
-
4
- export const TitleField = ({ id, title, required }: TitleFieldProps) => (
5
- <legend className="fs-13 fw-6 cn-9 lh-20 pb-8 dc__border-bottom en-1 mb-12" id={id}>
6
- <span>{title}</span>
7
- {required && <span className="cr-5">&nbsp;*</span>}
8
- </legend>
9
- )
@@ -1,51 +0,0 @@
1
- import React from 'react'
2
- import { ADDITIONAL_PROPERTY_FLAG, WrapIfAdditionalTemplateProps } from '@rjsf/utils'
3
-
4
- import { PLACEHOLDERS } from '../constants'
5
-
6
- export const WrapIfAdditionalTemplate = ({
7
- id,
8
- disabled,
9
- label,
10
- onKeyChange,
11
- onDropPropertyClick,
12
- readonly,
13
- schema,
14
- children,
15
- uiSchema,
16
- registry,
17
- }: WrapIfAdditionalTemplateProps) => {
18
- const { templates } = registry
19
- const { RemoveButton } = templates.ButtonTemplates
20
- const additional = ADDITIONAL_PROPERTY_FLAG in schema
21
-
22
- return (
23
- <>
24
- {additional ? (
25
- <div className="rjsf-form-template__additional-fields display-grid dc__gap-8 flex-align-center">
26
- <div>
27
- <input
28
- type="text"
29
- className="form__input cn-9 fs-13 lh-20 fw-4"
30
- id={`${id}-key`}
31
- onBlur={(event) => onKeyChange(event.target.value)}
32
- placeholder={PLACEHOLDERS.OBJECT_KEY}
33
- defaultValue={label}
34
- />
35
- </div>
36
- <div>{children}</div>
37
- <div>
38
- <RemoveButton
39
- disabled={disabled || readonly}
40
- onClick={onDropPropertyClick(label)}
41
- uiSchema={uiSchema}
42
- registry={registry}
43
- />
44
- </div>
45
- </div>
46
- ) : (
47
- children
48
- )}
49
- </>
50
- )
51
- }
@@ -1,10 +0,0 @@
1
- export { ArrayFieldTemplate } from './ArrayFieldTemplate'
2
- export { ArrayFieldItemTemplate } from './ArrayFieldItemTemplate'
3
- export { BaseInput as BaseInputTemplate } from './BaseInput'
4
- export * from './ButtonTemplates'
5
- export { Description as DescriptionFieldTemplate } from './Description'
6
- export { Field as FieldTemplate } from './Field'
7
- export { FieldErrorTemplate } from './FieldErrorTemplate'
8
- export { ObjectFieldTemplate } from './ObjectFieldTemplate'
9
- export { TitleField as TitleFieldTemplate } from './TitleField'
10
- export { WrapIfAdditionalTemplate } from './WrapIfAdditionalTemplate'
@@ -1,4 +0,0 @@
1
- import { ComponentProps } from 'react'
2
- import RJSFForm from '@rjsf/core'
3
-
4
- export type FormProps = Omit<ComponentProps<typeof RJSFForm>, 'validator'>
@@ -1,59 +0,0 @@
1
- import { TranslatableString, englishStringTranslator } from '@rjsf/utils'
2
-
3
- /**
4
- * Override for the TranslatableString from RJSF
5
- */
6
- export const translateString = (stringToTranslate: TranslatableString, params?: string[]): string => {
7
- switch (stringToTranslate) {
8
- case TranslatableString.NewStringDefault:
9
- // Use an empty string for the new additionalProperties string default value
10
- return ''
11
- default:
12
- return englishStringTranslator(stringToTranslate, params)
13
- }
14
- }
15
-
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) => ({
45
- ...base,
46
- padding: '0 8px',
47
- fontWeight: '400',
48
- }),
49
- loadingMessage: (base) => ({
50
- ...base,
51
- color: 'var(--N600)',
52
- }),
53
- noOptionsMessage: (base) => ({
54
- ...base,
55
- color: 'var(--N600)',
56
- }),
57
- ...styleOverrides,
58
- }
59
- }
@@ -1,44 +0,0 @@
1
- import React, { ChangeEvent } from 'react'
2
- import Toggle from '../../Toggle/Toggle'
3
- import { WidgetProps } from '@rjsf/utils'
4
-
5
- export const Checkbox = ({
6
- id,
7
- onChange,
8
- value,
9
- required,
10
- disabled,
11
- readonly,
12
- autofocus,
13
- onBlur,
14
- onFocus,
15
- }: WidgetProps) => {
16
- const handleEvent = (e: ChangeEvent<HTMLInputElement>, type: 'blur' | 'focus') => {
17
- const { id, checked } = e.target
18
- if (type === 'blur') {
19
- onBlur(id, checked)
20
- } else if (type === 'focus') {
21
- onFocus(id, checked)
22
- }
23
- }
24
-
25
- const isSelected: boolean = typeof value === 'undefined' ? false : value
26
-
27
- return (
28
- <div>
29
- <Toggle
30
- selected={isSelected}
31
- onSelect={onChange}
32
- id={id}
33
- name={id}
34
- required={required}
35
- disabled={disabled || readonly}
36
- autoFocus={autofocus}
37
- rootClassName="w-32 mb-0 dc__height-inherit"
38
- onBlur={(e) => handleEvent(e, 'blur')}
39
- onFocus={(e) => handleEvent(e, 'focus')}
40
- />
41
- <span className="dc__capitalize ml-8">{isSelected.toString()}</span>
42
- </div>
43
- )
44
- }