@abgov/jsonforms-components 1.2.3 → 1.3.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.
- package/index.esm.js +45 -52
- package/package.json +1 -1
- package/src/lib/Additional/GoACalloutControl.d.ts +12 -0
- package/src/lib/Controls/Inputs/style-component.d.ts +1 -0
- package/src/lib/ErrorHandling/errorCheck.d.ts +0 -1
- package/src/lib/layouts/GroupControl.d.ts +1 -0
- package/src/lib/ErrorHandling/MessageControl.d.ts +0 -12
package/index.esm.js
CHANGED
|
@@ -2,14 +2,14 @@ import { withAjvProps, materialSliderControlTester, MaterialSliderControl, mater
|
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { GoAFormItem, GoACallout, GoAInputDate, GoAInput, GoATextArea, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAIconButton, GoAFileUploadInput, GoAModal, GoACircularProgress, GoAGrid, GoAContainer, GoAButtonGroup, GoADetails } from '@abgov/react-components';
|
|
4
4
|
import { Hidden, Typography, FormHelperText } from '@mui/material';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { rankWith, uiTypeIs, isDateControl, isStringControl, and, optionIs, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, isDescriptionHidden, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
|
|
7
|
+
import { withJsonFormsRendererProps, withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, withJsonFormsLayoutProps, JsonFormsDispatch, useJsonForms, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
7
8
|
import React, { createContext, useEffect, useState, useMemo, useContext, useCallback } from 'react';
|
|
8
9
|
import merge from 'lodash/merge';
|
|
9
10
|
import axios from 'axios';
|
|
10
11
|
import TextField from '@mui/material/TextField';
|
|
11
12
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
12
|
-
import styled from 'styled-components';
|
|
13
13
|
import isEmpty from 'lodash/isEmpty';
|
|
14
14
|
import range from 'lodash/range';
|
|
15
15
|
|
|
@@ -1739,6 +1739,12 @@ $$3({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
|
|
|
1739
1739
|
assign: assign
|
|
1740
1740
|
});
|
|
1741
1741
|
|
|
1742
|
+
let _$6 = t => t,
|
|
1743
|
+
_t$6;
|
|
1744
|
+
const FormFieldWrapper = styled.div(_t$6 || (_t$6 = _$6`
|
|
1745
|
+
margin-bottom: var(--goa-space-l);
|
|
1746
|
+
`));
|
|
1747
|
+
|
|
1742
1748
|
var anObject$3 = anObject$9;
|
|
1743
1749
|
|
|
1744
1750
|
// `RegExp.prototype.flags` getter implementation
|
|
@@ -2389,34 +2395,35 @@ const GoAInputBaseControl = props => {
|
|
|
2389
2395
|
}
|
|
2390
2396
|
return jsx(Hidden, {
|
|
2391
2397
|
xsUp: !visible,
|
|
2392
|
-
children: jsx(
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
+
children: jsx(FormFieldWrapper, {
|
|
2399
|
+
children: jsx(GoAFormItem, {
|
|
2400
|
+
requirement: required ? 'required' : undefined,
|
|
2401
|
+
error: modifiedErrors,
|
|
2402
|
+
label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
|
|
2403
|
+
helpText: typeof ((_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help) === 'string' ? (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.help : '',
|
|
2404
|
+
children: jsx(InnerComponent, Object.assign({}, props))
|
|
2405
|
+
})
|
|
2398
2406
|
})
|
|
2399
2407
|
});
|
|
2400
2408
|
};
|
|
2401
2409
|
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
*/
|
|
2413
|
-
// TODO: Add styling
|
|
2414
|
-
const MessageControl = message => {
|
|
2415
|
-
return jsx(GoACallout, {
|
|
2416
|
-
type: "emergency",
|
|
2417
|
-
children: message
|
|
2418
|
-
});
|
|
2410
|
+
// Used locally for callout presentation
|
|
2411
|
+
const callout = props => {
|
|
2412
|
+
const componentProps = Object.assign({
|
|
2413
|
+
size: 'medium',
|
|
2414
|
+
type: 'emergency',
|
|
2415
|
+
message: 'unknown'
|
|
2416
|
+
}, props);
|
|
2417
|
+
return jsx(GoACallout, Object.assign({}, componentProps, {
|
|
2418
|
+
children: componentProps.message
|
|
2419
|
+
}));
|
|
2419
2420
|
};
|
|
2421
|
+
const CalloutControl = props => {
|
|
2422
|
+
var _a, _b;
|
|
2423
|
+
return callout(((_b = (_a = props === null || props === void 0 ? void 0 : props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.componentProps) || {});
|
|
2424
|
+
};
|
|
2425
|
+
const GoACalloutControlTester = rankWith(1, uiTypeIs('Callout'));
|
|
2426
|
+
var GoACalloutControl = withJsonFormsRendererProps(CalloutControl);
|
|
2420
2427
|
|
|
2421
2428
|
const errMalformedDate = (scope, type) => {
|
|
2422
2429
|
return `${type}-date for variable '${scope}' has an incorrect format.`;
|
|
@@ -2434,7 +2441,9 @@ const isValidDateFormat = date => {
|
|
|
2434
2441
|
return standardized !== undefined;
|
|
2435
2442
|
};
|
|
2436
2443
|
const invalidDateFormat = (scope, type) => {
|
|
2437
|
-
return
|
|
2444
|
+
return callout({
|
|
2445
|
+
message: errMalformedDate(scope, type)
|
|
2446
|
+
});
|
|
2438
2447
|
};
|
|
2439
2448
|
const reformatDateProps = props => {
|
|
2440
2449
|
if (props) {
|
|
@@ -4704,7 +4713,7 @@ const GoAGroupControlComponent = props => {
|
|
|
4704
4713
|
const group = uischema;
|
|
4705
4714
|
return jsx(Hidden, {
|
|
4706
4715
|
xsUp: !visible,
|
|
4707
|
-
children: jsx(GoAContainer, Object.assign({},
|
|
4716
|
+
children: jsx(GoAContainer, Object.assign({}, (_a = group.options) === null || _a === void 0 ? void 0 : _a.componentProps, {
|
|
4708
4717
|
children: renderLayoutElements(group.elements, schema, path, enabled, renderers, cells)
|
|
4709
4718
|
}))
|
|
4710
4719
|
});
|
|
@@ -4841,7 +4850,7 @@ const isLayoutType = schema => {
|
|
|
4841
4850
|
return hasType(schema, 'VerticalLayout') || hasType(schema, 'HorizontalLayout') || hasType(schema, 'Categorization') || hasType(schema, 'Group');
|
|
4842
4851
|
};
|
|
4843
4852
|
const isKnownType = schema => {
|
|
4844
|
-
return hasType(schema, 'Control') || isLayoutType(schema) || hasType(schema, 'HelpContent') || isListWithDetail(schema);
|
|
4853
|
+
return hasType(schema, 'Control') || isLayoutType(schema) || hasType(schema, 'HelpContent') || isListWithDetail(schema) || hasType(schema, 'Callout');
|
|
4845
4854
|
};
|
|
4846
4855
|
const isListWithDetail = schema => {
|
|
4847
4856
|
return hasType(schema, 'ListWithDetail');
|
|
@@ -4865,9 +4874,6 @@ const isEmptyElements = schema => {
|
|
|
4865
4874
|
const hasVariant = schema => {
|
|
4866
4875
|
return 'options' in schema && schema.options !== undefined && schema.options !== null && 'variant' in schema.options;
|
|
4867
4876
|
};
|
|
4868
|
-
const isValidJsonObject = schema => {
|
|
4869
|
-
return typeof schema === 'object' && Object.keys(schema).length === 0 || 'properties' in schema && ('type' in schema && schema.type === 'object' || !('type' in schema));
|
|
4870
|
-
};
|
|
4871
4877
|
|
|
4872
4878
|
const errCategorizationHasNonCategories = "Each element of 'Categorizations' must be of type 'Category'";
|
|
4873
4879
|
const errCategorizationHasNoElements = 'A Categorization must contain Categories.';
|
|
@@ -4959,15 +4965,6 @@ const getUISchemaErrors = (uiSchema, schema) => {
|
|
|
4959
4965
|
return null;
|
|
4960
4966
|
};
|
|
4961
4967
|
|
|
4962
|
-
const isValidJsonSchema = schema => {
|
|
4963
|
-
if (isNullSchema(schema)) {
|
|
4964
|
-
return '';
|
|
4965
|
-
}
|
|
4966
|
-
if (!isValidJsonObject(schema)) {
|
|
4967
|
-
return 'Unable to render: json schema is not valid.';
|
|
4968
|
-
}
|
|
4969
|
-
return null;
|
|
4970
|
-
};
|
|
4971
4968
|
// Some 'errors' need not be reported, but we want to handle them
|
|
4972
4969
|
// here. e.g. A layout with empty elements should be quietly ignored.
|
|
4973
4970
|
// this is handled by the errors !== '' check.
|
|
@@ -4976,17 +4973,11 @@ const ErrorControl = props => {
|
|
|
4976
4973
|
schema,
|
|
4977
4974
|
uischema
|
|
4978
4975
|
} = props;
|
|
4979
|
-
// Report data schema errors over ui schema ones, as errors in the former
|
|
4980
|
-
// can cause cascading errors in the latter.
|
|
4981
|
-
const dataSchemaErrors = isValidJsonSchema(schema);
|
|
4982
|
-
if (dataSchemaErrors && dataSchemaErrors !== '') {
|
|
4983
|
-
return jsx("p", {
|
|
4984
|
-
children: dataSchemaErrors
|
|
4985
|
-
});
|
|
4986
|
-
}
|
|
4987
4976
|
const uiSchemaErrors = getUISchemaErrors(uischema, schema);
|
|
4988
4977
|
if (uiSchemaErrors && uiSchemaErrors !== '') {
|
|
4989
|
-
return
|
|
4978
|
+
return callout({
|
|
4979
|
+
message: uiSchemaErrors
|
|
4980
|
+
});
|
|
4990
4981
|
}
|
|
4991
4982
|
return jsx("span", {});
|
|
4992
4983
|
};
|
|
@@ -4995,9 +4986,8 @@ const ErrorControl = props => {
|
|
|
4995
4986
|
* one that must get used if there are any errors whatsoever.
|
|
4996
4987
|
*/
|
|
4997
4988
|
const GoAErrorControlTester = rankWith(1000, (uischema, schema, context) => {
|
|
4998
|
-
const validJsonSchema = isValidJsonSchema(schema);
|
|
4999
4989
|
const validUiSchema = getUISchemaErrors(uischema, schema);
|
|
5000
|
-
return validUiSchema != null
|
|
4990
|
+
return validUiSchema != null;
|
|
5001
4991
|
});
|
|
5002
4992
|
var GoAErrorControl = withJsonFormsControlProps(ErrorControl);
|
|
5003
4993
|
|
|
@@ -5029,6 +5019,9 @@ const GoABaseRenderers = [
|
|
|
5029
5019
|
}, {
|
|
5030
5020
|
tester: GoATimeControlTester,
|
|
5031
5021
|
renderer: GoAInputTimeControl
|
|
5022
|
+
}, {
|
|
5023
|
+
tester: GoACalloutControlTester,
|
|
5024
|
+
renderer: GoACalloutControl
|
|
5032
5025
|
}, {
|
|
5033
5026
|
tester: materialSliderControlTester,
|
|
5034
5027
|
renderer: MaterialSliderControl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
|
|
6
6
|
"repository": "https://github.com/GovAlta/adsp-monorepo",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RankedTester } from '@jsonforms/core';
|
|
3
|
+
import { GoACalloutSize, GoACalloutType } from '@abgov/react-components-new';
|
|
4
|
+
export interface CalloutProps {
|
|
5
|
+
size?: GoACalloutSize;
|
|
6
|
+
type?: GoACalloutType;
|
|
7
|
+
message?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const callout: (props: CalloutProps) => JSX.Element;
|
|
10
|
+
export declare const GoACalloutControlTester: RankedTester;
|
|
11
|
+
declare const _default: React.ComponentType<import("@jsonforms/core").OwnPropsOfJsonFormsRenderer>;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FormFieldWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -11,4 +11,3 @@ export declare const isCategorization: (uiSchema: UISchemaElement) => boolean;
|
|
|
11
11
|
export declare const hasElements: (schema: object) => boolean;
|
|
12
12
|
export declare const isEmptyElements: (schema: object) => boolean;
|
|
13
13
|
export declare const hasVariant: (schema: UISchemaElement) => boolean;
|
|
14
|
-
export declare const isValidJsonObject: (schema: JsonSchema) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LayoutProps, RankedTester } from '@jsonforms/core';
|
|
3
3
|
export declare const groupTester: RankedTester;
|
|
4
|
+
export declare const GoAGroupControlComponent: (props: LayoutProps) => JSX.Element;
|
|
4
5
|
export declare const GoAGroupLayoutTester: RankedTester;
|
|
5
6
|
export declare const GoAGroupControl: React.ComponentType<LayoutProps & import("@jsonforms/core").OwnPropsOfLayout>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Used internally by registered Controls, the MessageControl
|
|
3
|
-
* is used to display an error message if a component cannot be rendered
|
|
4
|
-
* due to input errors - typically from options.componentProps.
|
|
5
|
-
*
|
|
6
|
-
* NOTE: The component itself is not, and should not, be registered.
|
|
7
|
-
*
|
|
8
|
-
* @param message the message to be displayed
|
|
9
|
-
*
|
|
10
|
-
* @returns component for displaying the message in the correct style
|
|
11
|
-
*/
|
|
12
|
-
export declare const MessageControl: (message: string) => JSX.Element;
|