@abgov/jsonforms-components 2.32.4 → 2.32.6
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 +115 -101
- package/package.json +1 -1
package/index.esm.js
CHANGED
|
@@ -7259,8 +7259,9 @@ const SummaryRowLink = styled.a(_t21 || (_t21 = _$6`
|
|
|
7259
7259
|
position: relative;
|
|
7260
7260
|
top: var(--goa-space-xs);
|
|
7261
7261
|
`));
|
|
7262
|
-
styled.td(_t22 || (_t22 = _$6`
|
|
7262
|
+
const SummaryTd = styled.td(_t22 || (_t22 = _$6`
|
|
7263
7263
|
border: 0 !important;
|
|
7264
|
+
padding: 0 !important;
|
|
7264
7265
|
`));
|
|
7265
7266
|
|
|
7266
7267
|
class ContextProviderClass {
|
|
@@ -7786,7 +7787,11 @@ const subErrorInParent = (error, paths) => {
|
|
|
7786
7787
|
const getErrorsInScopes = (errors, scopes) => {
|
|
7787
7788
|
return errors.filter(e => {
|
|
7788
7789
|
// transfer scope #properties/value to data path /value
|
|
7789
|
-
const dataPaths = scopes.map(s =>
|
|
7790
|
+
const dataPaths = scopes.map(s => {
|
|
7791
|
+
const dot = toDataPath(s);
|
|
7792
|
+
const slash = '/' + dot.replace(/\./g, '/');
|
|
7793
|
+
return slash;
|
|
7794
|
+
});
|
|
7790
7795
|
return dataPaths.includes(e.instancePath) || subErrorInParent(e, dataPaths);
|
|
7791
7796
|
});
|
|
7792
7797
|
};
|
|
@@ -7832,51 +7837,51 @@ const stepperReducer = (state, action) => {
|
|
|
7832
7837
|
}
|
|
7833
7838
|
case 'page/next':
|
|
7834
7839
|
{
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
}
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7840
|
+
const newActive = activeId + 1;
|
|
7841
|
+
const newCategories = categories.map((c, idx) => idx === activeId ? Object.assign({}, c, {
|
|
7842
|
+
isVisited: true
|
|
7843
|
+
}) : c);
|
|
7844
|
+
const isOnReview = newActive === lastId + 1;
|
|
7845
|
+
return Object.assign({}, state, {
|
|
7846
|
+
activeId: newActive,
|
|
7847
|
+
categories: newCategories,
|
|
7848
|
+
isOnReview,
|
|
7849
|
+
hasNextButton: !isOnReview,
|
|
7850
|
+
hasPrevButton: newActive !== 0
|
|
7851
|
+
});
|
|
7847
7852
|
}
|
|
7848
7853
|
case 'page/prev':
|
|
7849
7854
|
{
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7855
|
+
const newActive = Math.max(0, activeId - 1);
|
|
7856
|
+
const newCategories = categories.map((c, idx) => idx === activeId ? Object.assign({}, c, {
|
|
7857
|
+
isVisited: true
|
|
7858
|
+
}) : c);
|
|
7859
|
+
return Object.assign({}, state, {
|
|
7860
|
+
activeId: newActive,
|
|
7861
|
+
categories: newCategories,
|
|
7862
|
+
isOnReview: false,
|
|
7863
|
+
hasNextButton: true,
|
|
7864
|
+
hasPrevButton: newActive !== 0
|
|
7865
|
+
});
|
|
7858
7866
|
}
|
|
7859
7867
|
case 'page/to/index':
|
|
7860
7868
|
{
|
|
7861
7869
|
const {
|
|
7862
7870
|
id
|
|
7863
7871
|
} = action.payload;
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
state.
|
|
7876
|
-
|
|
7877
|
-
state.maxReachedStep = Math.max(state.maxReachedStep, activeId);
|
|
7878
|
-
return Object.assign({}, state);
|
|
7879
|
-
}
|
|
7872
|
+
const newActive = id;
|
|
7873
|
+
const newCategories = categories.map((c, idx) => idx === id ? Object.assign({}, c, {
|
|
7874
|
+
isVisited: true
|
|
7875
|
+
}) : c);
|
|
7876
|
+
const isOnReview = newActive === lastId + 1;
|
|
7877
|
+
return Object.assign({}, state, {
|
|
7878
|
+
activeId: newActive,
|
|
7879
|
+
categories: newCategories,
|
|
7880
|
+
isOnReview,
|
|
7881
|
+
hasNextButton: !isOnReview,
|
|
7882
|
+
hasPrevButton: newActive !== 0,
|
|
7883
|
+
maxReachedStep: Math.max(state.maxReachedStep, activeId)
|
|
7884
|
+
});
|
|
7880
7885
|
}
|
|
7881
7886
|
case 'update/category':
|
|
7882
7887
|
{
|
|
@@ -7887,40 +7892,43 @@ const stepperReducer = (state, action) => {
|
|
|
7887
7892
|
schema,
|
|
7888
7893
|
data
|
|
7889
7894
|
} = action.payload;
|
|
7890
|
-
if (id >=
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
ajv.validate(schema, data);
|
|
7896
|
-
} catch (err) {
|
|
7897
|
-
console.warn('AJV validation error:', err);
|
|
7898
|
-
}
|
|
7899
|
-
}
|
|
7900
|
-
const incompletePaths = getIncompletePaths(ajv, schema, data, ((_a = state.categories[id]) === null || _a === void 0 ? void 0 : _a.scopes) || []);
|
|
7901
|
-
const errorsInCategory = getErrorsInScopes(errors, ((_b = state.categories[id]) === null || _b === void 0 ? void 0 : _b.scopes) || []);
|
|
7902
|
-
if (state.categories[id]) {
|
|
7903
|
-
state.categories[id].isCompleted = (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0;
|
|
7904
|
-
state.categories[id].isValid = errorsInCategory.length === 0;
|
|
7905
|
-
state.categories[id].isVisited = true;
|
|
7895
|
+
if (id >= categories.length) return state;
|
|
7896
|
+
try {
|
|
7897
|
+
ajv.validate(schema, data);
|
|
7898
|
+
} catch (err) {
|
|
7899
|
+
console.warn('AJV validation error:', err);
|
|
7906
7900
|
}
|
|
7907
|
-
|
|
7901
|
+
const incompletePaths = getIncompletePaths(ajv, schema, data, ((_a = categories[id]) === null || _a === void 0 ? void 0 : _a.scopes) || []);
|
|
7902
|
+
const errorsInCategory = getErrorsInScopes(errors, ((_b = categories[id]) === null || _b === void 0 ? void 0 : _b.scopes) || []);
|
|
7903
|
+
const newCategories = categories.map((cat, idx) => idx === id ? Object.assign({}, cat, {
|
|
7904
|
+
isCompleted: incompletePaths.length === 0,
|
|
7905
|
+
isValid: errorsInCategory.length === 0,
|
|
7906
|
+
isVisited: true
|
|
7907
|
+
}) : cat);
|
|
7908
|
+
return Object.assign({}, state, {
|
|
7909
|
+
categories: newCategories
|
|
7910
|
+
});
|
|
7908
7911
|
}
|
|
7909
7912
|
case 'validate/form':
|
|
7910
7913
|
{
|
|
7911
7914
|
const {
|
|
7912
7915
|
errors = []
|
|
7913
7916
|
} = action.payload;
|
|
7914
|
-
|
|
7915
|
-
|
|
7917
|
+
return Object.assign({}, state, {
|
|
7918
|
+
isValid: errors.length === 0
|
|
7919
|
+
});
|
|
7916
7920
|
}
|
|
7917
7921
|
case 'toggle/category/review-link':
|
|
7918
7922
|
{
|
|
7919
7923
|
const {
|
|
7920
7924
|
id
|
|
7921
7925
|
} = action.payload;
|
|
7922
|
-
|
|
7923
|
-
|
|
7926
|
+
const newCategories = categories.map((cat, idx) => idx === id ? Object.assign({}, cat, {
|
|
7927
|
+
showReviewPageLink: !cat.showReviewPageLink
|
|
7928
|
+
}) : cat);
|
|
7929
|
+
return Object.assign({}, state, {
|
|
7930
|
+
categories: newCategories
|
|
7931
|
+
});
|
|
7924
7932
|
}
|
|
7925
7933
|
default:
|
|
7926
7934
|
return state;
|
|
@@ -7982,7 +7990,7 @@ const JsonFormsStepperContextProvider = ({
|
|
|
7982
7990
|
children,
|
|
7983
7991
|
StepperProps
|
|
7984
7992
|
}) => {
|
|
7985
|
-
var _a, _b;
|
|
7993
|
+
var _a, _b, _c;
|
|
7986
7994
|
const ctx = useJsonForms();
|
|
7987
7995
|
/* istanbul ignore next */
|
|
7988
7996
|
const {
|
|
@@ -7994,6 +8002,20 @@ const JsonFormsStepperContextProvider = ({
|
|
|
7994
8002
|
const [stepperState, dispatch] = useReducer(stepperReducer, createStepperContextInitData(StepperProps));
|
|
7995
8003
|
const stepperDispatch = (StepperProps === null || StepperProps === void 0 ? void 0 : StepperProps.customDispatch) || dispatch;
|
|
7996
8004
|
const isCacheStatus = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.cacheStatus;
|
|
8005
|
+
//prevents infinite loop refresh
|
|
8006
|
+
const doValidatePage = useCallback(id => {
|
|
8007
|
+
var _a;
|
|
8008
|
+
stepperDispatch({
|
|
8009
|
+
type: 'update/category',
|
|
8010
|
+
payload: {
|
|
8011
|
+
errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
|
|
8012
|
+
id,
|
|
8013
|
+
ajv,
|
|
8014
|
+
schema,
|
|
8015
|
+
data
|
|
8016
|
+
}
|
|
8017
|
+
});
|
|
8018
|
+
}, [stepperDispatch, (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors, ajv, schema, data]);
|
|
7997
8019
|
const context = useMemo(() => {
|
|
7998
8020
|
return {
|
|
7999
8021
|
isProvided: true,
|
|
@@ -8037,35 +8059,22 @@ const JsonFormsStepperContextProvider = ({
|
|
|
8037
8059
|
}
|
|
8038
8060
|
});
|
|
8039
8061
|
},
|
|
8040
|
-
validatePage:
|
|
8041
|
-
var _a;
|
|
8042
|
-
stepperDispatch({
|
|
8043
|
-
type: 'update/category',
|
|
8044
|
-
payload: {
|
|
8045
|
-
errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
|
|
8046
|
-
id,
|
|
8047
|
-
ajv,
|
|
8048
|
-
schema,
|
|
8049
|
-
data
|
|
8050
|
-
}
|
|
8051
|
-
});
|
|
8052
|
-
},
|
|
8062
|
+
validatePage: doValidatePage,
|
|
8053
8063
|
goToPage: id => {
|
|
8054
8064
|
var _a, _b, _c;
|
|
8055
8065
|
ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
}
|
|
8066
|
+
// Only update the current category
|
|
8067
|
+
if (!stepperState.isOnReview && id < stepperState.categories.length) {
|
|
8068
|
+
stepperDispatch({
|
|
8069
|
+
type: 'update/category',
|
|
8070
|
+
payload: {
|
|
8071
|
+
errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
|
|
8072
|
+
id,
|
|
8073
|
+
ajv,
|
|
8074
|
+
schema,
|
|
8075
|
+
data
|
|
8076
|
+
}
|
|
8077
|
+
});
|
|
8069
8078
|
}
|
|
8070
8079
|
stepperDispatch({
|
|
8071
8080
|
type: 'validate/form',
|
|
@@ -8089,7 +8098,7 @@ const JsonFormsStepperContextProvider = ({
|
|
|
8089
8098
|
});
|
|
8090
8099
|
}
|
|
8091
8100
|
};
|
|
8092
|
-
}, [stepperDispatch, stepperState, (
|
|
8101
|
+
}, [stepperDispatch, stepperState, (_c = ctx.core) === null || _c === void 0 ? void 0 : _c.errors, ajv, schema, data]);
|
|
8093
8102
|
/* istanbul ignore next */
|
|
8094
8103
|
useEffect(() => {
|
|
8095
8104
|
const handleBeforeUnload = () => {
|
|
@@ -8130,6 +8139,7 @@ const summaryLabel = 'Summary';
|
|
|
8130
8139
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8131
8140
|
const FormStepper = props => {
|
|
8132
8141
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
8142
|
+
const memoStepperProps = useMemo(() => Object.assign({}, props), [props]);
|
|
8133
8143
|
/**
|
|
8134
8144
|
* StepperCtx can only be provided once to prevent issues from categorization in categorization
|
|
8135
8145
|
* */
|
|
@@ -8139,7 +8149,7 @@ const FormStepper = props => {
|
|
|
8139
8149
|
return jsx(FormStepperView, Object.assign({}, props));
|
|
8140
8150
|
}
|
|
8141
8151
|
return jsx(JsonFormsStepperContextProvider, {
|
|
8142
|
-
StepperProps:
|
|
8152
|
+
StepperProps: memoStepperProps,
|
|
8143
8153
|
children: jsx(FormStepperView, Object.assign({}, props))
|
|
8144
8154
|
});
|
|
8145
8155
|
};
|
|
@@ -8816,18 +8826,20 @@ const SummaryRow = ({
|
|
|
8816
8826
|
onClick
|
|
8817
8827
|
}) => {
|
|
8818
8828
|
return jsx("tr", {
|
|
8819
|
-
children: jsx(
|
|
8820
|
-
|
|
8821
|
-
|
|
8822
|
-
|
|
8823
|
-
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
e
|
|
8828
|
-
|
|
8829
|
-
|
|
8830
|
-
|
|
8829
|
+
children: jsx(SummaryTd, {
|
|
8830
|
+
children: jsx(GoAText, {
|
|
8831
|
+
size: "heading-m",
|
|
8832
|
+
mt: "xl",
|
|
8833
|
+
mb: "xl",
|
|
8834
|
+
children: jsx(SummaryRowLink, {
|
|
8835
|
+
"data-testid": `page-ref-${index}`,
|
|
8836
|
+
href: "#",
|
|
8837
|
+
onClick: e => {
|
|
8838
|
+
e.preventDefault();
|
|
8839
|
+
onClick(index);
|
|
8840
|
+
},
|
|
8841
|
+
children: "Summary"
|
|
8842
|
+
})
|
|
8831
8843
|
})
|
|
8832
8844
|
})
|
|
8833
8845
|
});
|
|
@@ -9273,6 +9285,7 @@ function hasDataInScopes(data, scopes) {
|
|
|
9273
9285
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9274
9286
|
const FormPageStepper = props => {
|
|
9275
9287
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
9288
|
+
const memoStepperProps = useMemo(() => Object.assign({}, props), [props]);
|
|
9276
9289
|
/**
|
|
9277
9290
|
* StepperCtx can only be provided once to prevent issues from categorization in categorization
|
|
9278
9291
|
* */
|
|
@@ -9280,7 +9293,7 @@ const FormPageStepper = props => {
|
|
|
9280
9293
|
return jsx(FormPagesView, Object.assign({}, props));
|
|
9281
9294
|
}
|
|
9282
9295
|
return jsx(JsonFormsStepperContextProvider, {
|
|
9283
|
-
StepperProps:
|
|
9296
|
+
StepperProps: memoStepperProps,
|
|
9284
9297
|
children: jsx(FormPagesView, Object.assign({}, props))
|
|
9285
9298
|
});
|
|
9286
9299
|
};
|
|
@@ -11891,6 +11904,7 @@ const AddressLookUpControl = props => {
|
|
|
11891
11904
|
}));
|
|
11892
11905
|
};
|
|
11893
11906
|
useEffect(() => {
|
|
11907
|
+
if (!debouncedRenderAddress) return;
|
|
11894
11908
|
handleInputChange('addressLine1', debouncedRenderAddress);
|
|
11895
11909
|
}, [debouncedRenderAddress]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
11896
11910
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.32.
|
|
3
|
+
"version": "2.32.6",
|
|
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",
|