@abgov/jsonforms-components 0.0.1 → 1.2.0

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 (123) hide show
  1. package/index.esm.d.ts +1 -0
  2. package/index.esm.js +4831 -0
  3. package/package.json +8 -2
  4. package/src/index.d.ts +5 -0
  5. package/src/lib/Additional/HelpContent.d.ts +21 -0
  6. package/src/lib/Additional/styled-components.d.ts +1 -0
  7. package/src/lib/Cells/DateCell.d.ts +6 -0
  8. package/src/lib/Cells/IntegerCell.d.ts +6 -0
  9. package/src/lib/Cells/NumberCell.d.ts +6 -0
  10. package/src/lib/Cells/TextCell.d.ts +6 -0
  11. package/src/lib/Cells/TimeCell.d.ts +6 -0
  12. package/src/lib/Cells/index.d.ts +2 -0
  13. package/src/lib/Context/index.d.ts +39 -0
  14. package/src/lib/Controls/FileUploader/ContextMenu.d.ts +18 -0
  15. package/src/lib/Controls/FileUploader/FileUploaderControl.d.ts +4 -0
  16. package/src/lib/Controls/FileUploader/FileUploaderTester.d.ts +2 -0
  17. package/src/lib/Controls/FileUploader/styled-components.d.ts +1 -0
  18. package/src/lib/Controls/FormStepper/FormStepperControl.d.ts +14 -0
  19. package/src/lib/Controls/FormStepper/FormStepperTester.d.ts +2 -0
  20. package/src/lib/Controls/FormStepper/styled-components.d.ts +7 -0
  21. package/src/lib/Controls/Inputs/InputBaseControl.d.ts +7 -0
  22. package/src/lib/Controls/Inputs/InputBooleanControl.d.ts +6 -0
  23. package/src/lib/Controls/Inputs/InputBooleanRadioControl.d.ts +6 -0
  24. package/src/lib/Controls/Inputs/InputDateControl.d.ts +9 -0
  25. package/src/lib/Controls/Inputs/InputDateTimeControl.d.ts +9 -0
  26. package/src/lib/Controls/Inputs/InputEnum.d.ts +12 -0
  27. package/src/lib/Controls/Inputs/InputEnumAutoComplete.d.ts +10 -0
  28. package/src/lib/Controls/Inputs/InputEnumRadios.d.ts +12 -0
  29. package/src/lib/Controls/Inputs/InputIntegerControl.d.ts +9 -0
  30. package/src/lib/Controls/Inputs/InputMultiLineTextControl.d.ts +9 -0
  31. package/src/lib/Controls/Inputs/InputNumberControl.d.ts +9 -0
  32. package/src/lib/Controls/Inputs/InputTextControl.d.ts +9 -0
  33. package/src/lib/Controls/Inputs/InputTimeControl.d.ts +9 -0
  34. package/src/lib/Controls/Inputs/{type.ts → type.d.ts} +1 -1
  35. package/src/lib/Controls/ObjectArray/DeleteDialog.d.ts +12 -0
  36. package/src/lib/Controls/ObjectArray/ObjectArray.d.ts +6 -0
  37. package/src/lib/Controls/ObjectArray/ObjectArrayToolBar.d.ts +16 -0
  38. package/src/lib/Controls/ObjectArray/ObjectListControl.d.ts +24 -0
  39. package/src/lib/Controls/ObjectArray/styled-components.d.ts +3 -0
  40. package/src/lib/ErrorHandling/GoAErrorControl.d.ts +15 -0
  41. package/src/lib/ErrorHandling/{MessageControl.tsx → MessageControl.d.ts} +1 -8
  42. package/src/lib/ErrorHandling/errorCheck.d.ts +14 -0
  43. package/src/lib/ErrorHandling/schemaValidation.d.ts +11 -0
  44. package/src/lib/common/Grid.d.ts +11 -0
  45. package/src/lib/jsonforms-components.d.ts +4 -0
  46. package/src/lib/layouts/GroupControl.d.ts +5 -0
  47. package/src/lib/layouts/HorizontalLayoutControl.d.ts +5 -0
  48. package/src/lib/layouts/VerticalLayoutControl.d.ts +4 -0
  49. package/src/lib/util/layout.d.ts +8 -0
  50. package/src/lib/util/schemaUtils.d.ts +1 -0
  51. package/src/lib/util/stringUtils.d.ts +33 -0
  52. package/src/lib/util/style-component.d.ts +1 -0
  53. package/.babelrc +0 -12
  54. package/.eslintrc.json +0 -36
  55. package/.releaserc.json +0 -25
  56. package/jest.config.ts +0 -11
  57. package/project.json +0 -55
  58. package/rollup.config.js +0 -14
  59. package/src/index.ts +0 -166
  60. package/src/lib/Additional/HelpContent.tsx +0 -95
  61. package/src/lib/Additional/styled-components.ts +0 -27
  62. package/src/lib/Cells/DateCell.tsx +0 -10
  63. package/src/lib/Cells/IntegerCell.tsx +0 -10
  64. package/src/lib/Cells/NumberCell.tsx +0 -10
  65. package/src/lib/Cells/TextCell.tsx +0 -10
  66. package/src/lib/Cells/TimeCell.tsx +0 -10
  67. package/src/lib/Cells/index.tsx +0 -14
  68. package/src/lib/Context/index.tsx +0 -172
  69. package/src/lib/Controls/FileUploader/ContextMenu.tsx +0 -50
  70. package/src/lib/Controls/FileUploader/FileUploaderControl.tsx +0 -131
  71. package/src/lib/Controls/FileUploader/FileUploaderTester.tsx +0 -3
  72. package/src/lib/Controls/FileUploader/styled-components.tsx +0 -10
  73. package/src/lib/Controls/FormStepper/FormStepperControl.tsx +0 -269
  74. package/src/lib/Controls/FormStepper/FormStepperTester.tsx +0 -22
  75. package/src/lib/Controls/FormStepper/styled-components.tsx +0 -17
  76. package/src/lib/Controls/Inputs/InputBaseControl.tsx +0 -52
  77. package/src/lib/Controls/Inputs/InputBooleanControl.tsx +0 -67
  78. package/src/lib/Controls/Inputs/InputBooleanRadioControl.tsx +0 -74
  79. package/src/lib/Controls/Inputs/InputDateControl.tsx +0 -90
  80. package/src/lib/Controls/Inputs/InputDateTimeControl.tsx +0 -46
  81. package/src/lib/Controls/Inputs/InputEnum.tsx +0 -74
  82. package/src/lib/Controls/Inputs/InputEnumAutoComplete.tsx +0 -73
  83. package/src/lib/Controls/Inputs/InputEnumRadios.tsx +0 -43
  84. package/src/lib/Controls/Inputs/InputIntegerControl.tsx +0 -63
  85. package/src/lib/Controls/Inputs/InputMultiLineTextControl.tsx +0 -63
  86. package/src/lib/Controls/Inputs/InputNumberControl.tsx +0 -63
  87. package/src/lib/Controls/Inputs/InputTextControl.tsx +0 -62
  88. package/src/lib/Controls/Inputs/InputTimeControl.tsx +0 -46
  89. package/src/lib/Controls/Inputs/inputControl.spec.ts +0 -84
  90. package/src/lib/Controls/ObjectArray/DeleteDialog.tsx +0 -49
  91. package/src/lib/Controls/ObjectArray/ObjectArray.tsx +0 -59
  92. package/src/lib/Controls/ObjectArray/ObjectArrayToolBar.tsx +0 -51
  93. package/src/lib/Controls/ObjectArray/ObjectListControl.tsx +0 -368
  94. package/src/lib/Controls/ObjectArray/styled-components.tsx +0 -13
  95. package/src/lib/ErrorHandling/GoAErrorControl.tsx +0 -53
  96. package/src/lib/ErrorHandling/categorizationValidation.spec.ts +0 -98
  97. package/src/lib/ErrorHandling/controlValildation.spec.ts +0 -57
  98. package/src/lib/ErrorHandling/errorCheck.spec.ts +0 -185
  99. package/src/lib/ErrorHandling/errorCheck.tsx +0 -86
  100. package/src/lib/ErrorHandling/layoutValildation.spec.ts +0 -47
  101. package/src/lib/ErrorHandling/otherValildation.spec.ts +0 -74
  102. package/src/lib/ErrorHandling/schemaValidation.ts +0 -115
  103. package/src/lib/common/Grid.tsx +0 -55
  104. package/src/lib/jsonforms-components.module.scss +0 -7
  105. package/src/lib/jsonforms-components.spec.tsx +0 -10
  106. package/src/lib/jsonforms-components.tsx +0 -14
  107. package/src/lib/layouts/GroupControl.tsx +0 -25
  108. package/src/lib/layouts/HorizontalLayoutControl.tsx +0 -30
  109. package/src/lib/layouts/VerticalLayoutControl.tsx +0 -28
  110. package/src/lib/util/layout.tsx +0 -68
  111. package/src/lib/util/schemaUtils.ts +0 -9
  112. package/src/lib/util/stringUtils.ts +0 -98
  113. package/src/lib/util/style-component.ts +0 -8
  114. package/tsconfig.json +0 -20
  115. package/tsconfig.lib.json +0 -19
  116. package/tsconfig.spec.json +0 -20
  117. /package/src/lib/Additional/{index.ts → index.d.ts} +0 -0
  118. /package/src/lib/Controls/FileUploader/{index.tsx → index.d.ts} +0 -0
  119. /package/src/lib/Controls/FormStepper/{index.tsx → index.d.ts} +0 -0
  120. /package/src/lib/Controls/Inputs/{index.tsx → index.d.ts} +0 -0
  121. /package/src/lib/Controls/ObjectArray/{index.tsx → index.d.ts} +0 -0
  122. /package/src/lib/Controls/{index.tsx → index.d.ts} +0 -0
  123. /package/src/lib/layouts/{index.ts → index.d.ts} +0 -0
@@ -1,115 +0,0 @@
1
- import { JsonSchema, UISchemaElement, hasType, isCategorization, isControl, isLayout } from '@jsonforms/core';
2
- import {
3
- hasElements,
4
- hasVariant,
5
- isControlWithNoScope,
6
- isEmptyElements,
7
- isEmptyObject,
8
- isKnownType,
9
- isLayoutType,
10
- isListWithDetail,
11
- isNullSchema,
12
- isScopedPrefixed,
13
- isValidScope,
14
- } from './errorCheck';
15
-
16
- export const errCategorizationHasNonCategories = "Each element of 'Categorizations' must be of type 'Category'";
17
- export const errCategorizationHasNoElements = 'A Categorization must contain Categories.';
18
- export const errNoElements = (type: string) => `A ${type} must contain elements.`;
19
- export const errCategorizationHasNoVariant = 'A Categorization must contain Options with a variant.';
20
- export const errMissingScope = 'A Control must have a scope';
21
- export const errMalformedScope = (scope: string): string => `Scope ${scope} must be prefixed with '#/'.`;
22
- export const errUnknownScope = (scope: string): string => `Failed to render: unknown scope ${scope}`;
23
- export const errMissingType = 'UI schema element must have a type';
24
- export const errUnknownType = (type: string) => `Unknown schema type: ${type}. (Names are case sensitive)`;
25
-
26
- export const getUISchemaErrors = (uiSchema: UISchemaElement, schema: JsonSchema): string | null => {
27
- // Sometimes the UISchema is null. Ignore those cases, as all checks are done on the UIschema.
28
- if (isNullSchema(uiSchema)) {
29
- return null;
30
- }
31
-
32
- // silently ignore empty objects
33
- if (isEmptyObject(uiSchema)) {
34
- return '';
35
- }
36
-
37
- // Check control elements
38
- if (isControl(uiSchema) && hasType(uiSchema, 'Control')) {
39
- if (!isScopedPrefixed(uiSchema.scope)) {
40
- return errMalformedScope(uiSchema.scope);
41
- }
42
- if (!isValidScope(uiSchema, schema)) {
43
- return errUnknownScope(uiSchema.scope);
44
- }
45
- }
46
-
47
- // isControl will fail if scope is not present, so make the test explicit...
48
- if (isControlWithNoScope(uiSchema)) {
49
- return errMissingScope;
50
- }
51
-
52
- if (isListWithDetail(uiSchema)) {
53
- if ('scope' in uiSchema) {
54
- const scope = uiSchema.scope as string;
55
- if (!isValidScope(uiSchema, schema)) {
56
- return errUnknownScope(scope);
57
- }
58
- } else {
59
- return errMissingScope;
60
- }
61
- }
62
-
63
- // Make an explicit check for Categorization, as this requires Category elements.
64
- // Is layout will fail if some of these conditions are not met, so we do that
65
- // check later.
66
- if (isCategorization(uiSchema)) {
67
- if (!hasElements(uiSchema)) {
68
- return errCategorizationHasNoElements;
69
- }
70
-
71
- if (!hasVariant(uiSchema)) {
72
- return errCategorizationHasNoVariant;
73
- }
74
-
75
- // ensure each element has type Category, and that each category
76
- // has elements
77
- if (isLayout(uiSchema)) {
78
- const invalidCategorizations: string[] = [];
79
- const invalidCategories: UISchemaElement[] = [];
80
- (uiSchema.elements as UISchemaElement[]).forEach((e) => {
81
- if (e.type !== 'Category') {
82
- invalidCategorizations.push(e.type);
83
- }
84
- if (!hasElements(e) || isEmptyElements(e)) {
85
- invalidCategories.push(e);
86
- }
87
- });
88
- if (invalidCategorizations.length > 0) {
89
- return errCategorizationHasNonCategories;
90
- }
91
- if (invalidCategories.length > 0) {
92
- return errNoElements('Category');
93
- }
94
- }
95
- }
96
-
97
- // Check layout
98
- if (isLayoutType(uiSchema)) {
99
- if (!hasElements(uiSchema)) {
100
- return errNoElements(uiSchema.type);
101
- }
102
- if (isEmptyElements(uiSchema)) {
103
- return errNoElements(uiSchema.type);
104
- }
105
- }
106
-
107
- if (!isKnownType(uiSchema)) {
108
- if (uiSchema.type === undefined || uiSchema.type.length < 1) {
109
- return errMissingType;
110
- }
111
- return errUnknownType(uiSchema.type);
112
- }
113
-
114
- return null;
115
- };
@@ -1,55 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- export const Grid = styled.div`
4
- display: flex;
5
- flex-direction: row;
6
- flex-wrap: wrap;
7
- justify-content: space-between;
8
- align-items: stretch;
9
- `;
10
-
11
- interface GridItemProps {
12
- sm?: number;
13
- md?: number;
14
- lg?: number;
15
- xl?: number;
16
-
17
- hSpacing?: number;
18
- vSpacing?: number;
19
- }
20
-
21
- export const GridItem = styled.div<GridItemProps>`
22
- margin-bottom: ${(props: GridItemProps) => `${props.vSpacing ?? 0}rem`};
23
-
24
- > .goa-card {
25
- height: 100% !important;
26
- width: 100% !important;
27
- }
28
-
29
- > img {
30
- width: 100%;
31
- }
32
-
33
- flex: 0 1
34
- ${(props: GridItemProps) =>
35
- props.sm === 12 || props.sm === undefined
36
- ? '100%'
37
- : `calc(${(100 * (props?.sm ?? 12)) / 12}% - ${props.hSpacing ?? 0}rem)`};
38
-
39
- @media (min-width: 768px) {
40
- flex-basis: ${(props: GridItemProps) =>
41
- props.md === 12 ? '100%' : `calc(${(100 * (props?.md ?? props.sm ?? 12)) / 12}% - ${props.hSpacing ?? 0}rem)`};
42
- }
43
- @media (min-width: 1024px) {
44
- flex-basis: ${(props: GridItemProps) =>
45
- props.lg === 12
46
- ? '100%'
47
- : `calc(${(100 * (props?.lg ?? props?.md ?? props.sm ?? 12)) / 12}% - ${props.hSpacing ?? 0}rem)`};
48
- }
49
- @media (min-width: 1280px) {
50
- flex-basis: ${(props: GridItemProps) =>
51
- props.xl === 12
52
- ? '100%'
53
- : `calc(${(100 * (props?.xl ?? props?.md ?? props.sm ?? 12)) / 12}% - ${props.hSpacing ?? 0}rem)`};
54
- }
55
- `;
@@ -1,7 +0,0 @@
1
- /*
2
- * Replace this with your own classes
3
- *
4
- * e.g.
5
- * .container {
6
- * }
7
- */
@@ -1,10 +0,0 @@
1
- import { render } from '@testing-library/react';
2
-
3
- import JsonformsComponents from './jsonforms-components';
4
-
5
- describe('JsonformsComponents', () => {
6
- it('should render successfully', () => {
7
- const { baseElement } = render(<JsonformsComponents />);
8
- expect(baseElement).toBeTruthy();
9
- });
10
- });
@@ -1,14 +0,0 @@
1
- import styles from './jsonforms-components.module.scss';
2
-
3
- /* eslint-disable-next-line */
4
- export interface JsonformsComponentsProps {}
5
-
6
- export function JsonformsComponents(props: JsonformsComponentsProps) {
7
- return (
8
- <div className={styles['container']}>
9
- <h1>Welcome to JsonformsComponents!</h1>
10
- </div>
11
- );
12
- }
13
-
14
- export default JsonformsComponents;
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { GoAContainer } from '@abgov/react-components-new';
3
- import { GroupLayout, LayoutProps, RankedTester, rankWith, uiTypeIs, withIncreasedRank } from '@jsonforms/core';
4
- import { withJsonFormsLayoutProps } from '@jsonforms/react';
5
- import { renderLayoutElements } from '../util/layout';
6
- import { Hidden } from '@mui/material';
7
-
8
- export const groupTester: RankedTester = rankWith(1, uiTypeIs('Group'));
9
-
10
- const GoAGroupControlComponent = (props: LayoutProps): JSX.Element => {
11
- const { uischema, schema, path, enabled, renderers, cells, visible } = props;
12
- const group = uischema as GroupLayout;
13
-
14
- return (
15
- <Hidden xsUp={!visible}>
16
- <GoAContainer {...group.options} {...uischema?.options?.componentProps}>
17
- {renderLayoutElements(group.elements, schema, path, enabled, renderers, cells)}
18
- </GoAContainer>
19
- </Hidden>
20
- );
21
- };
22
-
23
- export const GoAGroupLayoutTester: RankedTester = withIncreasedRank(1, groupTester);
24
-
25
- export const GoAGroupControl = withJsonFormsLayoutProps(GoAGroupControlComponent);
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- import { LayoutProps, RankedTester, rankWith, uiTypeIs, HorizontalLayout } from '@jsonforms/core';
3
- import { LayoutRenderer, LayoutRendererProps } from '../util/layout';
4
- import { withJsonFormsLayoutProps } from '@jsonforms/react';
5
-
6
- export const materialHorizontalLayoutTester: RankedTester = rankWith(2, uiTypeIs('HorizontalLayout'));
7
-
8
- export const GoAHorizontalLayoutComponent = ({
9
- uischema,
10
- renderers,
11
- cells,
12
- schema,
13
- path,
14
- enabled,
15
- visible,
16
- }: LayoutProps) => {
17
- const layout = uischema as HorizontalLayout;
18
- const childProps: LayoutRendererProps = {
19
- elements: layout.elements,
20
- schema,
21
- path,
22
- enabled,
23
- direction: 'row',
24
- visible,
25
- };
26
-
27
- return <LayoutRenderer {...childProps} renderers={renderers} cells={cells} />;
28
- };
29
-
30
- export const GoAHorizontalLayout = withJsonFormsLayoutProps(GoAHorizontalLayoutComponent, true);
@@ -1,28 +0,0 @@
1
- import React from 'react';
2
- import { LayoutProps, VerticalLayout } from '@jsonforms/core';
3
- import { LayoutRenderer, LayoutRendererProps } from '../util/layout';
4
- import { withJsonFormsLayoutProps } from '@jsonforms/react';
5
-
6
- export const GoAVerticalLayoutComponent = ({
7
- uischema,
8
- schema,
9
- path,
10
- enabled,
11
- renderers,
12
- cells,
13
- visible,
14
- }: LayoutProps) => {
15
- const verticalLayout = uischema as VerticalLayout;
16
- const childProps: LayoutRendererProps = {
17
- elements: verticalLayout.elements,
18
- schema,
19
- path,
20
- enabled,
21
- direction: 'column',
22
- visible,
23
- };
24
-
25
- return <LayoutRenderer {...childProps} renderers={renderers} cells={cells} />;
26
- };
27
-
28
- export const GoAVerticalLayout = withJsonFormsLayoutProps(GoAVerticalLayoutComponent, true);
@@ -1,68 +0,0 @@
1
- import isEmpty from 'lodash/isEmpty';
2
- import React from 'react';
3
-
4
- import type { UISchemaElement } from '@jsonforms/core';
5
- import {
6
- JsonFormsCellRendererRegistryEntry,
7
- JsonFormsRendererRegistryEntry,
8
- JsonSchema,
9
- OwnPropsOfRenderer,
10
- } from '@jsonforms/core';
11
- import { JsonFormsDispatch } from '@jsonforms/react';
12
- import { GoAGrid } from '@abgov/react-components-new';
13
- import { Hidden } from '@mui/material';
14
-
15
- export const renderLayoutElements = (
16
- elements: UISchemaElement[],
17
- schema?: JsonSchema,
18
- path?: string,
19
- enabled?: boolean,
20
- renderers?: JsonFormsRendererRegistryEntry[],
21
- cells?: JsonFormsCellRendererRegistryEntry[]
22
- ) => {
23
- return elements.map((child, index) => (
24
- <div key={index}>
25
- <JsonFormsDispatch
26
- uischema={child}
27
- schema={schema}
28
- key={path}
29
- path={path}
30
- enabled={enabled}
31
- renderers={renderers}
32
- cells={cells}
33
- />
34
- </div>
35
- ));
36
- };
37
-
38
- export interface LayoutRendererProps extends OwnPropsOfRenderer {
39
- elements: UISchemaElement[];
40
- direction: 'row' | 'column';
41
- }
42
-
43
- export const LayoutRenderer = ({
44
- elements,
45
- schema,
46
- path,
47
- enabled,
48
- direction,
49
- renderers,
50
- cells,
51
- visible,
52
- }: LayoutRendererProps) => {
53
- if (isEmpty(elements)) {
54
- return null;
55
- } else {
56
- if (direction === 'row') {
57
- return (
58
- <Hidden xsUp={!visible}>
59
- <GoAGrid minChildWidth="10ch">
60
- {renderLayoutElements(elements, schema, path, enabled, renderers, cells)}
61
- </GoAGrid>
62
- </Hidden>
63
- );
64
- } else {
65
- return <Hidden xsUp={!visible}>{renderLayoutElements(elements, schema, path, enabled, renderers, cells)}</Hidden>;
66
- }
67
- }
68
- };
@@ -1,9 +0,0 @@
1
- export const parseSchema = (schema: string) => {
2
- try {
3
- return JSON.parse(schema);
4
- } catch (e) {
5
- const err = e as Error;
6
- console.debug(err.message);
7
- return {};
8
- }
9
- };
@@ -1,98 +0,0 @@
1
- import { ControlProps, JsonSchema } from '@jsonforms/core';
2
-
3
- /**
4
- * Sets the first word to be capitalized so that it is sentence cased.
5
- * @param words
6
- * @returns sentence word string.
7
- */
8
- export const capitalizeFirstLetter = (words: string) => {
9
- const value = words.charAt(0).toUpperCase() + words.slice(1).toLowerCase();
10
- return value;
11
- };
12
-
13
- /**
14
- * Compares the scope name and the label to determine if it matches so that it can be sentence case.
15
- * @param scope - format eg: '#/properties/firstName'
16
- * @param label - The label text
17
- * @returns true if the scope and label matches, otherwise false
18
- */
19
- export const controlScopeMatchesLabel = (scope: string, label: string) => {
20
- // Get the property name in the string from the scope
21
- const splitIdName = scope.replace(' ', '').split('/')?.at(-1)?.toLowerCase() ?? '';
22
- const labelWithNoSpaces = label.replace(' ', '').toLowerCase();
23
- if (splitIdName === labelWithNoSpaces) {
24
- return true;
25
- }
26
- return false;
27
- };
28
-
29
- /**
30
- * Gets the label text in sentence case
31
- * @param scope
32
- * @param label
33
- * @returns
34
- */
35
- export const getLabelText = (scope: string, label: string): string => {
36
- let labelToUpdate: string = '';
37
-
38
- if (controlScopeMatchesLabel(scope, label || '')) {
39
- labelToUpdate = capitalizeFirstLetter(label || '');
40
- } else {
41
- labelToUpdate = label || '';
42
- }
43
-
44
- return labelToUpdate;
45
- };
46
- // This message is thrown when the isNotEmpty is triggered by Ajv checkInput.ts configuration
47
- export const FIELD_REQUIRED = 'data should pass "isNotEmpty" keyword validation';
48
-
49
- const isEmptyBoolean = (schema: JsonSchema, data: unknown): boolean => {
50
- return schema.type !== undefined && schema.type === 'boolean' && (data === null || data === undefined);
51
- };
52
- const isEmptyNumber = (schema: JsonSchema, data: unknown): boolean => {
53
- return (
54
- data === '' ||
55
- data === undefined ||
56
- data === null ||
57
- ((schema.type === 'number' || schema.type === 'integer') && isNaN(+data))
58
- );
59
- };
60
- /**
61
- * Check if a required, defined input value is valid. Returns an appropriate
62
- * error message if not.
63
- * @param props
64
- * @returns error message
65
- */
66
- export const checkFieldValidity = (props: ControlProps): string => {
67
- const { data, errors: ajvErrors, required, label, uischema, schema } = props;
68
- const labelToUpdate = getLabelText(uischema.scope, label);
69
-
70
- if (required) {
71
- if (data === undefined) return '';
72
-
73
- if (schema) {
74
- if (isEmptyBoolean(schema, data)) {
75
- return `${labelToUpdate} is required`;
76
- }
77
-
78
- if (isEmptyNumber(schema, data)) {
79
- return `${labelToUpdate} is required`;
80
- }
81
- }
82
- }
83
-
84
- return ajvErrors;
85
- };
86
-
87
- /**
88
- * Check if the date is a valid date/time
89
- */
90
- export const isValidDate = function (date: Date | string) {
91
- if (date instanceof Date && isFinite(date.getTime())) {
92
- return true;
93
- } else if (typeof date === 'string' && date.length > 0) {
94
- return true;
95
- } else {
96
- return false;
97
- }
98
- };
@@ -1,8 +0,0 @@
1
- import styled from 'styled-components';
2
-
3
- export const VerticalLayout = styled.div`
4
- height: 70vh;
5
- overflow-y: auto;
6
- padding-left: 0.2rem;
7
- padding-right: 0.2rem;
8
- `;
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react-jsx",
4
- "allowJs": false,
5
- "esModuleInterop": false,
6
- "allowSyntheticDefaultImports": true,
7
- "strict": true
8
- },
9
- "files": [],
10
- "include": [],
11
- "references": [
12
- {
13
- "path": "./tsconfig.lib.json"
14
- },
15
- {
16
- "path": "./tsconfig.spec.json"
17
- }
18
- ],
19
- "extends": "../../tsconfig.base.json"
20
- }
package/tsconfig.lib.json DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "types": ["node", "../../node_modules/@nx/react/typings/cssmodule.d.ts", "../../node_modules/@nx/react/typings/image.d.ts"]
6
- },
7
- "exclude": [
8
- "jest.config.ts",
9
- "src/**/*.spec.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.tsx",
12
- "src/**/*.test.tsx",
13
- "src/**/*.spec.js",
14
- "src/**/*.test.js",
15
- "src/**/*.spec.jsx",
16
- "src/**/*.test.jsx"
17
- ],
18
- "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
19
- }
@@ -1,20 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "../../dist/out-tsc",
5
- "module": "commonjs",
6
- "types": ["jest", "node"]
7
- },
8
- "include": [
9
- "jest.config.ts",
10
- "src/**/*.test.ts",
11
- "src/**/*.spec.ts",
12
- "src/**/*.test.tsx",
13
- "src/**/*.spec.tsx",
14
- "src/**/*.test.js",
15
- "src/**/*.spec.js",
16
- "src/**/*.test.jsx",
17
- "src/**/*.spec.jsx",
18
- "src/**/*.d.ts"
19
- ]
20
- }
File without changes
File without changes
File without changes