@abgov/jsonforms-components 2.28.2 → 2.30.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
CHANGED
|
@@ -5,10 +5,10 @@ import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputD
|
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import get$1 from 'lodash/get';
|
|
8
|
-
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl,
|
|
8
|
+
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isControl, isEnumControl, isBooleanControl, schemaMatches, getAjv, isVisible, toDataPath, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, hasType, isCategorization, isLayout } from '@jsonforms/core';
|
|
9
9
|
import { withJsonFormsControlProps, withJsonFormsEnumProps, withTranslateProps, JsonFormsDispatch, useJsonForms, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsAllOfProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
10
10
|
import * as _$c from 'lodash';
|
|
11
|
-
import { isEqual, isEmpty as isEmpty$1, isObject as isObject$f } from 'lodash';
|
|
11
|
+
import ___default, { isEqual, isEmpty as isEmpty$1, isObject as isObject$f } from 'lodash';
|
|
12
12
|
import merge from 'lodash/merge';
|
|
13
13
|
import isEmpty from 'lodash/isEmpty';
|
|
14
14
|
import range from 'lodash/range';
|
|
@@ -6367,7 +6367,7 @@ function fetchRegisterConfigFromOptions(options) {
|
|
|
6367
6367
|
return config;
|
|
6368
6368
|
}
|
|
6369
6369
|
const EnumSelect = props => {
|
|
6370
|
-
var _a, _b, _c, _d, _e, _f;
|
|
6370
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
6371
6371
|
const {
|
|
6372
6372
|
data,
|
|
6373
6373
|
enabled,
|
|
@@ -6378,18 +6378,20 @@ const EnumSelect = props => {
|
|
|
6378
6378
|
uischema,
|
|
6379
6379
|
required,
|
|
6380
6380
|
setIsVisited,
|
|
6381
|
-
isVisited
|
|
6381
|
+
isVisited,
|
|
6382
|
+
schema
|
|
6382
6383
|
} = props;
|
|
6383
6384
|
const registerCtx = useContext(JsonFormsRegisterContext);
|
|
6384
6385
|
const registerConfig = fetchRegisterConfigFromOptions((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
|
|
6385
|
-
|
|
6386
|
+
const labelPath = ((_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.label) || 'label';
|
|
6387
|
+
const valuePath = ((_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.value) || 'value';
|
|
6386
6388
|
let registerData = [];
|
|
6387
6389
|
let error = '';
|
|
6388
6390
|
if (registerConfig) {
|
|
6389
6391
|
registerData = registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.selectRegisterData(registerConfig);
|
|
6390
6392
|
error = (registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.fetchErrors(registerConfig)) || '';
|
|
6391
6393
|
}
|
|
6392
|
-
const autoCompletion = ((
|
|
6394
|
+
const autoCompletion = ((_f = (_e = props.uischema) === null || _e === void 0 ? void 0 : _e.options) === null || _f === void 0 ? void 0 : _f.autoComplete) === true;
|
|
6393
6395
|
const mergedOptions = useMemo(() => {
|
|
6394
6396
|
const newOptions = [...(options || []), ...((registerData === null || registerData === void 0 ? void 0 : registerData.map(d => {
|
|
6395
6397
|
if (typeof d === 'string') {
|
|
@@ -6397,9 +6399,16 @@ const EnumSelect = props => {
|
|
|
6397
6399
|
value: d,
|
|
6398
6400
|
label: d
|
|
6399
6401
|
};
|
|
6400
|
-
} else {
|
|
6401
|
-
return
|
|
6402
|
+
} else if (typeof d === 'object' && d !== null) {
|
|
6403
|
+
return {
|
|
6404
|
+
value: ___default.get(d, valuePath) || '',
|
|
6405
|
+
label: ___default.get(d, labelPath) || ''
|
|
6406
|
+
};
|
|
6402
6407
|
}
|
|
6408
|
+
return {
|
|
6409
|
+
label: '',
|
|
6410
|
+
value: ''
|
|
6411
|
+
};
|
|
6403
6412
|
})) || [])];
|
|
6404
6413
|
const hasNonEmptyOptions = newOptions.some(option => option.value !== '');
|
|
6405
6414
|
if (!hasNonEmptyOptions && newOptions.length === 1 && newOptions[0].value === '') {
|
|
@@ -6413,7 +6422,7 @@ const EnumSelect = props => {
|
|
|
6413
6422
|
}
|
|
6414
6423
|
return newOptions.filter(option => option.value !== '');
|
|
6415
6424
|
}, [registerData, options]);
|
|
6416
|
-
const width = ((
|
|
6425
|
+
const width = ((_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.width) || '100%';
|
|
6417
6426
|
useEffect(() => {
|
|
6418
6427
|
if (registerConfig) {
|
|
6419
6428
|
registerCtx === null || registerCtx === void 0 ? void 0 : registerCtx.fetchRegisterByUrl(registerConfig);
|
|
@@ -6425,13 +6434,19 @@ const EnumSelect = props => {
|
|
|
6425
6434
|
}) : jsx(Dropdown, {
|
|
6426
6435
|
items: mergedOptions,
|
|
6427
6436
|
enabled: enabled,
|
|
6428
|
-
selected: data,
|
|
6437
|
+
selected: typeof data === 'object' ? ___default.get(data, valuePath) : data,
|
|
6429
6438
|
width: width,
|
|
6430
6439
|
id: `jsonforms-${label}-dropdown`,
|
|
6431
6440
|
label: label,
|
|
6432
6441
|
isAutoCompletion: autoCompletion,
|
|
6433
6442
|
onChange: value => {
|
|
6434
|
-
|
|
6443
|
+
if (schema.type === 'object') {
|
|
6444
|
+
handleChange(path, registerData.find(o => {
|
|
6445
|
+
return ___default.get(o, valuePath) === value;
|
|
6446
|
+
}));
|
|
6447
|
+
} else {
|
|
6448
|
+
handleChange(path, value);
|
|
6449
|
+
}
|
|
6435
6450
|
}
|
|
6436
6451
|
}, `jsonforms-${label}-dropdown`)
|
|
6437
6452
|
});
|
|
@@ -6441,8 +6456,10 @@ const enumControl = props => {
|
|
|
6441
6456
|
input: EnumSelect
|
|
6442
6457
|
}));
|
|
6443
6458
|
};
|
|
6444
|
-
const GoAEnumControlTester = rankWith(
|
|
6445
|
-
|
|
6459
|
+
const GoAEnumControlTester = rankWith(4, (uischema, schema, context) => {
|
|
6460
|
+
var _a;
|
|
6461
|
+
return (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && isControl(uischema) && ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.format) === 'enum' || isEnumControl(uischema, schema, context);
|
|
6462
|
+
});
|
|
6446
6463
|
const GoAEnumControl = withJsonFormsEnumProps(withTranslateProps(enumControl), true);
|
|
6447
6464
|
|
|
6448
6465
|
const RadioGroup = props => {
|
|
@@ -13085,7 +13102,9 @@ const errMalformedScope = scope => `Scope ${scope} must be prefixed with '#/'.`;
|
|
|
13085
13102
|
const errUnknownScope = scope => `Failed to render: unknown scope ${scope}`;
|
|
13086
13103
|
const errMissingType = 'UI schema element must have a type';
|
|
13087
13104
|
const errUnknownType = type => `Unknown schema type: ${type}. (Names are case sensitive)`;
|
|
13105
|
+
const errMissingRegister = 'Register configuration is missing in the UISchema options';
|
|
13088
13106
|
const getUISchemaErrors = (uiSchema, schema) => {
|
|
13107
|
+
var _a, _b;
|
|
13089
13108
|
// Sometimes the UISchema is null. Ignore those cases, as all checks are done on the UIschema.
|
|
13090
13109
|
if (isNullSchema(uiSchema)) {
|
|
13091
13110
|
return null;
|
|
@@ -13094,6 +13113,9 @@ const getUISchemaErrors = (uiSchema, schema) => {
|
|
|
13094
13113
|
if (isEmptyObject(uiSchema)) {
|
|
13095
13114
|
return '';
|
|
13096
13115
|
}
|
|
13116
|
+
if (isControl(uiSchema) && (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((_a = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.options) === null || _a === void 0 ? void 0 : _a.format) === 'enum' && ((_b = uiSchema === null || uiSchema === void 0 ? void 0 : uiSchema.options) === null || _b === void 0 ? void 0 : _b.register) === undefined) {
|
|
13117
|
+
return errMissingRegister;
|
|
13118
|
+
}
|
|
13097
13119
|
// Check control elements
|
|
13098
13120
|
if (isControl(uiSchema) && hasType(uiSchema, 'Control')) {
|
|
13099
13121
|
if (!isScopedPrefixed(uiSchema.scope)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.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",
|
|
@@ -7,4 +7,5 @@ export declare const errMalformedScope: (scope: string) => string;
|
|
|
7
7
|
export declare const errUnknownScope: (scope: string) => string;
|
|
8
8
|
export declare const errMissingType = "UI schema element must have a type";
|
|
9
9
|
export declare const errUnknownType: (type: string) => string;
|
|
10
|
+
export declare const errMissingRegister = "Register configuration is missing in the UISchema options";
|
|
10
11
|
export declare const getUISchemaErrors: (uiSchema: UISchemaElement, schema: JsonSchema) => string | null;
|