@abgov/jsonforms-components 1.15.5 → 1.15.7
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/README.md
CHANGED
package/index.esm.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import React, { createContext, useContext, useEffect, useMemo, useState, useCallback } from 'react';
|
|
3
3
|
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoADropdown, GoADropdownItem, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADetails } from '@abgov/react-components';
|
|
4
4
|
import styled from 'styled-components';
|
|
5
|
-
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl,
|
|
5
|
+
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, isEnabled, deriveLabelForUISchemaElement, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, withIncreasedRank, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
|
|
6
6
|
import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
7
7
|
import merge from 'lodash/merge';
|
|
8
8
|
import axios from 'axios';
|
|
@@ -3756,144 +3756,160 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
3756
3756
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
3757
3757
|
};
|
|
3758
3758
|
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
};
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3759
|
+
class ContextProviderClass {
|
|
3760
|
+
addDataByUrl(key, url, processDataFunction, token) {
|
|
3761
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3762
|
+
let header = {};
|
|
3763
|
+
const [requestId, axiosWithConfig] = this.getAxiosInterceptorConfig(axios);
|
|
3764
|
+
if (token) {
|
|
3765
|
+
header = Object.assign(Object.assign({}, header), {
|
|
3766
|
+
Authorization: `Bearer ${token}`
|
|
3767
|
+
});
|
|
3768
|
+
}
|
|
3769
|
+
yield axiosWithConfig.get(url, header).then(response => {
|
|
3770
|
+
const processedData = processDataFunction(response.data);
|
|
3771
|
+
this.enumValues.set(key, () => processedData);
|
|
3772
|
+
}).catch(err => {
|
|
3773
|
+
if (err.message.includes('CORS')) {
|
|
3774
|
+
console.warn(err.message);
|
|
3775
|
+
} else {
|
|
3776
|
+
console.warn(`addDataByUrl: ${err.message}`);
|
|
3777
|
+
}
|
|
3778
|
+
});
|
|
3779
|
+
axiosWithConfig.interceptors.request.eject(requestId);
|
|
3774
3780
|
});
|
|
3775
3781
|
}
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
enumValues
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
}
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3782
|
+
constructor() {
|
|
3783
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3784
|
+
this.enumValues = new Map();
|
|
3785
|
+
this.enumFunctions = new Map();
|
|
3786
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3787
|
+
this.enumSubmitFunctions = new Map();
|
|
3788
|
+
this.addFormContextData = (key, data) => {
|
|
3789
|
+
this.enumValues.set(key, () => data);
|
|
3790
|
+
};
|
|
3791
|
+
this.setup = props => {
|
|
3792
|
+
var _a, _b;
|
|
3793
|
+
this.selfProps = props;
|
|
3794
|
+
if (props.fileManagement) {
|
|
3795
|
+
const {
|
|
3796
|
+
fileList,
|
|
3797
|
+
uploadFile,
|
|
3798
|
+
downloadFile,
|
|
3799
|
+
deleteFile
|
|
3800
|
+
} = props.fileManagement;
|
|
3801
|
+
this.enumValues.set('file-list', () => fileList);
|
|
3802
|
+
this.enumFunctions.set('upload-file', () => uploadFile);
|
|
3803
|
+
this.enumFunctions.set('download-file', () => downloadFile);
|
|
3804
|
+
this.enumFunctions.set('delete-file', () => deleteFile);
|
|
3805
|
+
}
|
|
3806
|
+
if (props.submit) {
|
|
3807
|
+
const {
|
|
3808
|
+
submitForm
|
|
3809
|
+
} = props.submit;
|
|
3810
|
+
const submitFunction = submitForm;
|
|
3811
|
+
this.enumSubmitFunctions.set('submit-form', () => submitFunction);
|
|
3812
|
+
}
|
|
3813
|
+
if (props.data) {
|
|
3814
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3815
|
+
(_a = props.data) === null || _a === void 0 ? void 0 : _a.forEach(item => {
|
|
3816
|
+
this.enumValues.set(Object.keys(item)[0], () => item);
|
|
3817
|
+
});
|
|
3818
|
+
}
|
|
3819
|
+
if (!props.children) {
|
|
3820
|
+
return null;
|
|
3821
|
+
}
|
|
3822
|
+
return jsx(JsonFormContext.Provider, {
|
|
3823
|
+
value: this.baseEnumerator,
|
|
3824
|
+
children: (_b = this.selfProps) === null || _b === void 0 ? void 0 : _b.children
|
|
3825
|
+
});
|
|
3826
|
+
};
|
|
3827
|
+
this.getContextProvider = () => {
|
|
3828
|
+
var _a;
|
|
3829
|
+
return jsx(JsonFormContext.Provider, {
|
|
3830
|
+
value: this.baseEnumerator,
|
|
3831
|
+
children: (_a = this.selfProps) === null || _a === void 0 ? void 0 : _a.children
|
|
3832
|
+
});
|
|
3833
|
+
};
|
|
3834
|
+
this.getAxiosInterceptorConfig = axios => {
|
|
3835
|
+
const requestId = axios.interceptors.request.use(req => {
|
|
3836
|
+
if (req.data === undefined) {
|
|
3837
|
+
throw new Error(`The URL: ${req.url} encountered a CORS error.`);
|
|
3838
|
+
}
|
|
3839
|
+
return req;
|
|
3840
|
+
});
|
|
3841
|
+
return [requestId, axios];
|
|
3842
|
+
};
|
|
3843
|
+
this.addDataByOptions = (key, url, location, type, values = ['']) => {
|
|
3802
3844
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3803
|
-
|
|
3804
|
-
let
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3845
|
+
const dataFunction = data => {
|
|
3846
|
+
let dataLink = data;
|
|
3847
|
+
let returnData = [''];
|
|
3848
|
+
const locationArray = location && Array.isArray(location) ? location : [location];
|
|
3849
|
+
const locationArrayTyped = locationArray;
|
|
3850
|
+
locationArrayTyped === null || locationArrayTyped === void 0 ? void 0 : locationArrayTyped.forEach(attribute => {
|
|
3851
|
+
dataLink = dataLink[attribute];
|
|
3852
|
+
});
|
|
3853
|
+
const valuesArray = Array.isArray(values) ? values : [values];
|
|
3854
|
+
if (type === 'keys') {
|
|
3855
|
+
returnData = Object.keys(dataLink);
|
|
3856
|
+
} else {
|
|
3857
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3858
|
+
returnData = dataLink.map(entry => {
|
|
3859
|
+
let parse = '';
|
|
3860
|
+
valuesArray.forEach((v, index) => {
|
|
3861
|
+
parse += `${entry[v]}`;
|
|
3862
|
+
if (index < valuesArray.length - 1) {
|
|
3863
|
+
parse += ' ';
|
|
3864
|
+
}
|
|
3865
|
+
});
|
|
3866
|
+
return parse;
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
return returnData;
|
|
3870
|
+
};
|
|
3871
|
+
this.addDataByUrl(key, url, dataFunction);
|
|
3872
|
+
};
|
|
3873
|
+
/**
|
|
3874
|
+
* Grabs data stored under a given key
|
|
3875
|
+
*
|
|
3876
|
+
*/
|
|
3877
|
+
// FIXME give some clue as to what data is being fetched.
|
|
3878
|
+
// e.g.is it getFormContextData?
|
|
3879
|
+
this.getFormContextData = key => {
|
|
3880
|
+
const dataFunction = this.baseEnumerator.data.get(key);
|
|
3881
|
+
return dataFunction && dataFunction();
|
|
3882
|
+
};
|
|
3883
|
+
/**
|
|
3884
|
+
* Grabs all data
|
|
3885
|
+
*
|
|
3886
|
+
*/
|
|
3887
|
+
this.getAllFormContextData = () => {
|
|
3888
|
+
const allData = [];
|
|
3889
|
+
this.baseEnumerator.data.forEach((d, key) => {
|
|
3890
|
+
allData.push({
|
|
3891
|
+
[key]: d()
|
|
3810
3892
|
});
|
|
3811
|
-
return parse;
|
|
3812
3893
|
});
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
submitFunction: enumSubmitFunctions,
|
|
3827
|
-
isFormSubmitted: false
|
|
3828
|
-
};
|
|
3829
|
-
const JsonFormContext = /*#__PURE__*/createContext(baseEnumerator);
|
|
3830
|
-
function ContextProvider(props) {
|
|
3831
|
-
var _a, _b;
|
|
3832
|
-
baseEnumerator.isFormSubmitted = (_a = props.isFormSubmitted) !== null && _a !== void 0 ? _a : false;
|
|
3833
|
-
if (props.fileManagement) {
|
|
3834
|
-
const {
|
|
3835
|
-
fileList,
|
|
3836
|
-
uploadFile,
|
|
3837
|
-
downloadFile,
|
|
3838
|
-
deleteFile
|
|
3839
|
-
} = props.fileManagement;
|
|
3840
|
-
enumValues.set('file-list', () => fileList);
|
|
3841
|
-
enumFunctions.set('upload-file', () => uploadFile);
|
|
3842
|
-
enumFunctions.set('download-file', () => downloadFile);
|
|
3843
|
-
enumFunctions.set('delete-file', () => deleteFile);
|
|
3844
|
-
}
|
|
3845
|
-
if (props.submit) {
|
|
3846
|
-
const {
|
|
3847
|
-
submitForm
|
|
3848
|
-
} = props.submit;
|
|
3849
|
-
const submitFunction = submitForm;
|
|
3850
|
-
enumSubmitFunctions.set('submit-form', () => submitFunction);
|
|
3851
|
-
}
|
|
3852
|
-
if (props.data) {
|
|
3853
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3854
|
-
(_b = props.data) === null || _b === void 0 ? void 0 : _b.forEach(item => {
|
|
3855
|
-
enumValues.set(Object.keys(item)[0], () => item);
|
|
3856
|
-
});
|
|
3857
|
-
}
|
|
3858
|
-
if (!props.children) {
|
|
3859
|
-
return null;
|
|
3894
|
+
return allData;
|
|
3895
|
+
};
|
|
3896
|
+
this.baseEnumerator = {
|
|
3897
|
+
data: this.enumValues,
|
|
3898
|
+
functions: this.enumFunctions,
|
|
3899
|
+
submitFunction: this.enumSubmitFunctions,
|
|
3900
|
+
addFormContextData: this.addFormContextData,
|
|
3901
|
+
addDataByOptions: this.addDataByOptions,
|
|
3902
|
+
addDataByUrl: this.addDataByUrl,
|
|
3903
|
+
getFormContextData: this.getFormContextData,
|
|
3904
|
+
getAllFormContextData: this.getAllFormContextData
|
|
3905
|
+
};
|
|
3906
|
+
this.selfProps = {};
|
|
3860
3907
|
}
|
|
3861
|
-
return jsx(JsonFormContext.Provider, {
|
|
3862
|
-
value: baseEnumerator,
|
|
3863
|
-
children: props.children
|
|
3864
|
-
});
|
|
3865
|
-
}
|
|
3866
|
-
/**
|
|
3867
|
-
* Grabs data stored under a given key
|
|
3868
|
-
*
|
|
3869
|
-
*/
|
|
3870
|
-
// FIXME give some clue as to what data is being fetched.
|
|
3871
|
-
// e.g.is it getFormContextData?
|
|
3872
|
-
function getData(key) {
|
|
3873
|
-
const dataFunction = baseEnumerator.data.get(key);
|
|
3874
|
-
return dataFunction && dataFunction();
|
|
3875
|
-
}
|
|
3876
|
-
/**
|
|
3877
|
-
* Grabs all data
|
|
3878
|
-
*
|
|
3879
|
-
*/
|
|
3880
|
-
function getAllData() {
|
|
3881
|
-
const allData = [];
|
|
3882
|
-
baseEnumerator.data.forEach((d, key) => {
|
|
3883
|
-
allData.push({
|
|
3884
|
-
[key]: d()
|
|
3885
|
-
});
|
|
3886
|
-
});
|
|
3887
|
-
return allData;
|
|
3888
|
-
}
|
|
3889
|
-
/**
|
|
3890
|
-
* Allows additional data to be added under a given key
|
|
3891
|
-
*
|
|
3892
|
-
* This data will then be available inside the context
|
|
3893
|
-
*/
|
|
3894
|
-
function addData(key, data) {
|
|
3895
|
-
enumValues.set(key, () => data);
|
|
3896
3908
|
}
|
|
3909
|
+
const ContextProviderC = new ContextProviderClass();
|
|
3910
|
+
const ContextProvider = ContextProviderC.setup;
|
|
3911
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3912
|
+
const JsonFormContext = /*#__PURE__*/createContext(null);
|
|
3897
3913
|
|
|
3898
3914
|
const EnumSelect = props => {
|
|
3899
3915
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
@@ -3910,6 +3926,7 @@ const EnumSelect = props => {
|
|
|
3910
3926
|
label,
|
|
3911
3927
|
uischema
|
|
3912
3928
|
} = props;
|
|
3929
|
+
const enumerators = useContext(JsonFormContext);
|
|
3913
3930
|
let enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
|
|
3914
3931
|
const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
|
|
3915
3932
|
const dataKey = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.enumContext) === null || _b === void 0 ? void 0 : _b.key;
|
|
@@ -3920,11 +3937,11 @@ const EnumSelect = props => {
|
|
|
3920
3937
|
const errorsFormInput = checkFieldValidity(props);
|
|
3921
3938
|
useEffect(() => {
|
|
3922
3939
|
if (dataKey && url) {
|
|
3923
|
-
addDataByOptions(dataKey, url, location, type, values);
|
|
3940
|
+
enumerators.addDataByOptions(dataKey, url, location, type, values);
|
|
3924
3941
|
}
|
|
3925
|
-
}, [url, location, type, values, dataKey]);
|
|
3926
|
-
if (dataKey &&
|
|
3927
|
-
const newData =
|
|
3942
|
+
}, [url, location, type, values, dataKey, enumerators]);
|
|
3943
|
+
if (dataKey && enumerators.getFormContextData(dataKey)) {
|
|
3944
|
+
const newData = enumerators.getFormContextData(dataKey);
|
|
3928
3945
|
enumData = newData;
|
|
3929
3946
|
}
|
|
3930
3947
|
return jsx(GoADropdown, Object.assign({
|
|
@@ -3967,6 +3984,7 @@ const EnumSelectAutoComplete = props => {
|
|
|
3967
3984
|
label
|
|
3968
3985
|
} = props;
|
|
3969
3986
|
let enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
|
|
3987
|
+
const enumerators = useContext(JsonFormContext);
|
|
3970
3988
|
const dataKey = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.enumContext) === null || _b === void 0 ? void 0 : _b.key;
|
|
3971
3989
|
const url = (_d = (_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.enumContext) === null || _d === void 0 ? void 0 : _d.url;
|
|
3972
3990
|
const location = (_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.enumContext) === null || _f === void 0 ? void 0 : _f.location;
|
|
@@ -3974,11 +3992,11 @@ const EnumSelectAutoComplete = props => {
|
|
|
3974
3992
|
const values = (_k = (_j = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _j === void 0 ? void 0 : _j.enumContext) === null || _k === void 0 ? void 0 : _k.values;
|
|
3975
3993
|
useEffect(() => {
|
|
3976
3994
|
if (dataKey && url) {
|
|
3977
|
-
addDataByOptions(dataKey, url, location, type, values);
|
|
3995
|
+
enumerators.addDataByOptions(dataKey, url, location, type, values);
|
|
3978
3996
|
}
|
|
3979
|
-
}, [url, location, type, values, dataKey]);
|
|
3980
|
-
if (dataKey &&
|
|
3981
|
-
const newData =
|
|
3997
|
+
}, [url, location, type, values, dataKey, enumerators]);
|
|
3998
|
+
if (dataKey && enumerators.getFormContextData(dataKey)) {
|
|
3999
|
+
const newData = enumerators.getFormContextData(dataKey);
|
|
3982
4000
|
// eslint-disable-next-line
|
|
3983
4001
|
enumData = newData;
|
|
3984
4002
|
}
|
|
@@ -4065,20 +4083,15 @@ const GoARadioGroupControlTester = rankWith(20, and(isEnumControl, optionIs('for
|
|
|
4065
4083
|
|
|
4066
4084
|
const BooleanComponent = ({
|
|
4067
4085
|
data,
|
|
4068
|
-
visible,
|
|
4069
4086
|
enabled,
|
|
4070
4087
|
uischema,
|
|
4071
4088
|
handleChange,
|
|
4072
4089
|
path,
|
|
4073
|
-
config,
|
|
4074
4090
|
label,
|
|
4075
4091
|
required,
|
|
4076
|
-
errors
|
|
4077
|
-
description
|
|
4092
|
+
errors
|
|
4078
4093
|
}) => {
|
|
4079
4094
|
var _a;
|
|
4080
|
-
const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema.options);
|
|
4081
|
-
!isDescriptionHidden(visible, description, false, appliedUiSchemaOptions.showUnfocusedDescription);
|
|
4082
4095
|
const errorsFormInput = checkFieldValidity({
|
|
4083
4096
|
data,
|
|
4084
4097
|
uischema,
|
|
@@ -4086,13 +4099,7 @@ const BooleanComponent = ({
|
|
|
4086
4099
|
required,
|
|
4087
4100
|
errors
|
|
4088
4101
|
});
|
|
4089
|
-
|
|
4090
|
-
if (label && description) {
|
|
4091
|
-
text = description;
|
|
4092
|
-
if (required) {
|
|
4093
|
-
text = `${description} ` + (required ? ' (required)' : '');
|
|
4094
|
-
}
|
|
4095
|
-
}
|
|
4102
|
+
const text = label + (required ? ' (required)' : '');
|
|
4096
4103
|
return jsx(GoACheckbox, Object.assign({
|
|
4097
4104
|
error: errorsFormInput.length > 0,
|
|
4098
4105
|
testId: `${path}-checkbox-test-id`,
|
|
@@ -4100,7 +4107,7 @@ const BooleanComponent = ({
|
|
|
4100
4107
|
text: text,
|
|
4101
4108
|
name: `${path}`,
|
|
4102
4109
|
checked: data,
|
|
4103
|
-
onChange: (
|
|
4110
|
+
onChange: (_, checked) => {
|
|
4104
4111
|
handleChange(path, checked);
|
|
4105
4112
|
}
|
|
4106
4113
|
}, (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps));
|
|
@@ -4559,10 +4566,12 @@ const RenderStepElements = props => {
|
|
|
4559
4566
|
const validateData = (jsonSchema, data, ajv) => {
|
|
4560
4567
|
const newSchema = JSON.parse(JSON.stringify(jsonSchema));
|
|
4561
4568
|
Object.keys(newSchema.properties || {}).forEach(propertyName => {
|
|
4562
|
-
var _a;
|
|
4569
|
+
var _a, _b, _c, _d;
|
|
4563
4570
|
const property = newSchema.properties || {};
|
|
4564
|
-
property[propertyName].enum =
|
|
4565
|
-
|
|
4571
|
+
if (((_a = property[propertyName]) === null || _a === void 0 ? void 0 : _a.enum) && ((_b = property[propertyName]) === null || _b === void 0 ? void 0 : _b.enum[0]) === '') {
|
|
4572
|
+
(_c = property[propertyName]) === null || _c === void 0 ? true : delete _c.enum;
|
|
4573
|
+
}
|
|
4574
|
+
if (((_d = property[propertyName]) === null || _d === void 0 ? void 0 : _d.format) === 'file-urn') {
|
|
4566
4575
|
delete property[propertyName].format;
|
|
4567
4576
|
}
|
|
4568
4577
|
});
|
|
@@ -4614,7 +4623,7 @@ const FormStepper = props => {
|
|
|
4614
4623
|
t
|
|
4615
4624
|
} = props;
|
|
4616
4625
|
const enumerators = useContext(JsonFormContext);
|
|
4617
|
-
const submitFormFunction = enumerators.submitFunction.get('submit-form');
|
|
4626
|
+
const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
|
|
4618
4627
|
const submitForm = submitFormFunction && submitFormFunction();
|
|
4619
4628
|
const categorization = uischema;
|
|
4620
4629
|
const allCategories = JSON.parse(JSON.stringify(categorization));
|
|
@@ -4937,6 +4946,8 @@ const FileUploader = _a => {
|
|
|
4937
4946
|
const deleteTriggerFunction = enumerators.functions.get('delete-file');
|
|
4938
4947
|
const deleteTrigger = deleteTriggerFunction && deleteTriggerFunction();
|
|
4939
4948
|
const fileListValue = enumerators.data.get('file-list');
|
|
4949
|
+
const countries = ['Argentina', 'Brazil', 'Canada', 'Denmark', 'Egypt', 'France', 'Greece', 'India', 'Japan', 'Kenya'];
|
|
4950
|
+
enumerators.addFormContextData('countries', countries);
|
|
4940
4951
|
// eslint-disable-next-line
|
|
4941
4952
|
const fileList = fileListValue && fileListValue();
|
|
4942
4953
|
const {
|
|
@@ -5894,8 +5905,6 @@ const ajv = new Ajv({
|
|
|
5894
5905
|
//Example format: urn:ads:platform:file-service:v1:/files/f6de737e-c5fc-42fe-963b-28bfe14597c4
|
|
5895
5906
|
ajv.addFormat('file-urn', /^urn:ads:platform:file-service:v[0-9]:\/files\/[a-zA-Z0-9.-]*$/);
|
|
5896
5907
|
|
|
5897
|
-
const countries = ['Argentina', 'Brazil', 'Canada', 'Denmark', 'Egypt', 'France', 'Greece', 'India', 'Japan', 'Kenya'];
|
|
5898
|
-
addData('countries', countries);
|
|
5899
5908
|
const GoABaseRenderers = [
|
|
5900
5909
|
// controls
|
|
5901
5910
|
{
|
|
@@ -5972,4 +5981,4 @@ const GoARenderers = [...GoABaseRenderers, {
|
|
|
5972
5981
|
}];
|
|
5973
5982
|
const GoACells = [...InputCells];
|
|
5974
5983
|
|
|
5975
|
-
export { ContextProvider, GoABaseRenderers, GoACells, GoARenderers, JsonFormContext,
|
|
5984
|
+
export { ContextProvider, ContextProviderC, GoABaseRenderers, GoACells, GoARenderers, JsonFormContext, ajv };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.7",
|
|
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,69 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AxiosStatic } from 'axios';
|
|
3
|
+
interface AllData {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
}
|
|
6
|
+
export interface enumerators {
|
|
7
|
+
data: Map<string, () => any>;
|
|
8
|
+
functions: Map<string, () => (file: File, propertyId: string) => void | undefined>;
|
|
9
|
+
submitFunction: Map<string, () => (id: string) => void | undefined>;
|
|
10
|
+
addFormContextData: (key: string, data: Record<string, unknown> | unknown[]) => void;
|
|
11
|
+
addDataByOptions: (key: string, url: string, location: string[] | string, type: string, values?: string[] | string) => string[];
|
|
12
|
+
addDataByUrl: (key: string, url: string, processDataFunction: (data: object) => string[], token?: string) => void;
|
|
13
|
+
getFormContextData: (key: string) => Record<string, any>;
|
|
14
|
+
getAllFormContextData: () => AllData;
|
|
15
|
+
}
|
|
16
|
+
interface FileManagement {
|
|
17
|
+
fileList?: any;
|
|
18
|
+
uploadFile?: (file: File, propertyId: string) => void;
|
|
19
|
+
downloadFile?: (file: File) => void;
|
|
20
|
+
deleteFile?: (file: File) => void;
|
|
21
|
+
}
|
|
22
|
+
interface SubmitManagement {
|
|
23
|
+
submitForm?: (any: any) => void;
|
|
24
|
+
}
|
|
25
|
+
type Props = {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
fileManagement?: FileManagement;
|
|
28
|
+
submit?: SubmitManagement;
|
|
29
|
+
isFormSubmitted?: boolean;
|
|
30
|
+
data?: any;
|
|
31
|
+
};
|
|
32
|
+
declare class ContextProviderClass {
|
|
33
|
+
selfProps: Props | undefined;
|
|
34
|
+
enumValues: Map<string, () => Record<string, any>>;
|
|
35
|
+
enumFunctions: Map<string, () => ((file: File, propertyId: string) => void) | undefined>;
|
|
36
|
+
enumSubmitFunctions: Map<string, () => ((data: any) => void) | undefined>;
|
|
37
|
+
baseEnumerator: {
|
|
38
|
+
data: Map<string, () => Record<string, any>>;
|
|
39
|
+
functions: Map<string, () => ((file: File, propertyId: string) => void) | undefined>;
|
|
40
|
+
submitFunction: Map<string, () => ((data: any) => void) | undefined>;
|
|
41
|
+
addFormContextData: (key: string, data: Record<string, unknown> | unknown[]) => void;
|
|
42
|
+
addDataByOptions: (key: string, url: string, location: string[] | string, type: string, values?: string[] | string) => void;
|
|
43
|
+
addDataByUrl: (key: string, url: string, processDataFunction: (data: object) => string[], token?: string) => void;
|
|
44
|
+
getFormContextData: (key: string) => Record<string, any> | undefined;
|
|
45
|
+
getAllFormContextData: () => AllData;
|
|
46
|
+
isFormSubmitted?: boolean;
|
|
47
|
+
};
|
|
48
|
+
addFormContextData: (key: string, data: Record<string, unknown> | unknown[]) => void;
|
|
49
|
+
addDataByUrl(key: string, url: string, processDataFunction: (data: object) => string[], token?: string): Promise<void>;
|
|
50
|
+
constructor();
|
|
51
|
+
setup: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
52
|
+
getContextProvider: () => import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
getAxiosInterceptorConfig: (axios: AxiosStatic) => [number, AxiosStatic];
|
|
54
|
+
addDataByOptions: (key: string, url: string, location: string[] | string, type: string, values?: string[] | string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Grabs data stored under a given key
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
getFormContextData: (key: string) => Record<string, any> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Grabs all data
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
getAllFormContextData: () => AllData;
|
|
65
|
+
}
|
|
66
|
+
export declare const ContextProviderC: ContextProviderClass;
|
|
67
|
+
export declare const ContextProvider: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
|
|
68
|
+
export declare const JsonFormContext: React.Context<any>;
|
|
69
|
+
export {};
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { AxiosStatic } from 'axios';
|
|
3
|
-
export interface AllData {
|
|
4
|
-
[x: string]: any;
|
|
5
|
-
}
|
|
6
|
-
export declare const getAxiosInterceptorConfig: (axios: AxiosStatic) => [number, AxiosStatic];
|
|
7
|
-
export declare const addDataByUrl: (key: string, url: string, processDataFunction: (data: object) => string[], token?: string) => Promise<void>;
|
|
8
|
-
export declare function addDataByOptions(key: string, url: string, location: string[] | string, type: string, values?: string[] | string): void;
|
|
9
|
-
interface FileManagement {
|
|
10
|
-
fileList?: any;
|
|
11
|
-
uploadFile?: (file: File, propertyId: string) => void;
|
|
12
|
-
downloadFile?: (file: File) => void;
|
|
13
|
-
deleteFile?: (file: File) => void;
|
|
14
|
-
}
|
|
15
|
-
interface SubmitManagement {
|
|
16
|
-
submitForm?: (any: any) => void;
|
|
17
|
-
}
|
|
18
|
-
type Props = {
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
fileManagement?: FileManagement;
|
|
21
|
-
submit?: SubmitManagement;
|
|
22
|
-
isFormSubmitted?: boolean;
|
|
23
|
-
data?: any;
|
|
24
|
-
};
|
|
25
|
-
export declare const JsonFormContext: React.Context<{
|
|
26
|
-
data: Map<string, () => Record<string, any>>;
|
|
27
|
-
functions: Map<string, () => ((file: File, propertyId: string) => void) | undefined>;
|
|
28
|
-
submitFunction: Map<string, () => ((data: any) => void) | undefined>;
|
|
29
|
-
isFormSubmitted: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
export declare function ContextProvider(props: Props): JSX.Element | null;
|
|
32
|
-
/**
|
|
33
|
-
* Grabs data stored under a given key
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
export declare function getData(key: string): Record<string, any> | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* Grabs all data
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
export declare function getAllData(): AllData;
|
|
42
|
-
/**
|
|
43
|
-
* Allows additional data to be added under a given key
|
|
44
|
-
*
|
|
45
|
-
* This data will then be available inside the context
|
|
46
|
-
*/
|
|
47
|
-
export declare function addData(key: string, data: Record<string, unknown> | unknown[]): void;
|
|
48
|
-
export {};
|
|
1
|
+
export * from './ContextProvider';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { RankedTester, ControlProps } from '@jsonforms/core';
|
|
3
|
-
export declare const BooleanComponent: ({ data,
|
|
3
|
+
export declare const BooleanComponent: ({ data, enabled, uischema, handleChange, path, label, required, errors, }: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const BooleanControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
export declare const GoABooleanControlTester: RankedTester;
|
|
6
|
-
export declare const GoABooleanControl:
|
|
6
|
+
export declare const GoABooleanControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
|