@abgov/jsonforms-components 1.55.0 → 1.56.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
|
@@ -4458,8 +4458,6 @@ const GoAInputText = props => {
|
|
|
4458
4458
|
if (schema && schema.title === sinTitle && value !== '') {
|
|
4459
4459
|
formattedValue = formatSin(value);
|
|
4460
4460
|
}
|
|
4461
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4462
|
-
/* istanbul ignore next */
|
|
4463
4461
|
if (isVisited === false && setIsVisited) {
|
|
4464
4462
|
setIsVisited();
|
|
4465
4463
|
}
|
|
@@ -4470,11 +4468,9 @@ const GoAInputText = props => {
|
|
|
4470
4468
|
});
|
|
4471
4469
|
},
|
|
4472
4470
|
onBlur: (name, value) => {
|
|
4473
|
-
/* istanbul ignore next */
|
|
4474
4471
|
if (isVisited === false && setIsVisited) {
|
|
4475
4472
|
setIsVisited();
|
|
4476
4473
|
}
|
|
4477
|
-
/* istanbul ignore next */
|
|
4478
4474
|
onBlurForTextControl({
|
|
4479
4475
|
name,
|
|
4480
4476
|
controlProps: props,
|
|
@@ -4528,8 +4524,6 @@ const MultiLineText = props => {
|
|
|
4528
4524
|
// maxCount={schema.maxLength || 256}
|
|
4529
4525
|
onKeyPress: (name, value, key) => {
|
|
4530
4526
|
const newValue = autoCapitalize ? value.toUpperCase() : value;
|
|
4531
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4532
|
-
/* istanbul ignore next */
|
|
4533
4527
|
if (isVisited === false && setIsVisited) {
|
|
4534
4528
|
setIsVisited();
|
|
4535
4529
|
}
|
|
@@ -4548,8 +4542,6 @@ const MultiLineText = props => {
|
|
|
4548
4542
|
});
|
|
4549
4543
|
},
|
|
4550
4544
|
onChange: (name, value) => {
|
|
4551
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4552
|
-
/* istanbul ignore next */
|
|
4553
4545
|
if (isVisited === false && setIsVisited) {
|
|
4554
4546
|
setIsVisited();
|
|
4555
4547
|
}
|
|
@@ -4642,8 +4634,6 @@ const GoADateInput = props => {
|
|
|
4642
4634
|
disabled: !enabled,
|
|
4643
4635
|
readonly: readOnly,
|
|
4644
4636
|
onChange: (name, value) => {
|
|
4645
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4646
|
-
/* istanbul ignore next */
|
|
4647
4637
|
if (isVisited === false && setIsVisited) {
|
|
4648
4638
|
setIsVisited();
|
|
4649
4639
|
}
|
|
@@ -4662,11 +4652,9 @@ const GoADateInput = props => {
|
|
|
4662
4652
|
});
|
|
4663
4653
|
},
|
|
4664
4654
|
onBlur: (name, value) => {
|
|
4665
|
-
/* istanbul ignore next */
|
|
4666
4655
|
if (isVisited === false && setIsVisited) {
|
|
4667
4656
|
setIsVisited();
|
|
4668
4657
|
}
|
|
4669
|
-
/* istanbul ignore next */
|
|
4670
4658
|
onBlurForDateControl({
|
|
4671
4659
|
name,
|
|
4672
4660
|
value,
|
|
@@ -4719,11 +4707,9 @@ const GoANumberInput = props => {
|
|
|
4719
4707
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
4720
4708
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
4721
4709
|
onBlur: (name, value) => {
|
|
4722
|
-
/* istanbul ignore next */
|
|
4723
4710
|
if (isVisited === false && setIsVisited) {
|
|
4724
4711
|
setIsVisited();
|
|
4725
4712
|
}
|
|
4726
|
-
/* istanbul ignore next */
|
|
4727
4713
|
onBlurForNumericControl({
|
|
4728
4714
|
name,
|
|
4729
4715
|
value,
|
|
@@ -4731,8 +4717,6 @@ const GoANumberInput = props => {
|
|
|
4731
4717
|
});
|
|
4732
4718
|
},
|
|
4733
4719
|
onChange: (name, value) => {
|
|
4734
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4735
|
-
/* istanbul ignore next */
|
|
4736
4720
|
if (isVisited === false && setIsVisited) {
|
|
4737
4721
|
setIsVisited();
|
|
4738
4722
|
}
|
|
@@ -4787,10 +4771,7 @@ const GoAInputInteger = props => {
|
|
|
4787
4771
|
placeholder: placeholder,
|
|
4788
4772
|
name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
|
|
4789
4773
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
4790
|
-
/* istanbul ignore next */
|
|
4791
4774
|
onBlur: (name, value) => {
|
|
4792
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4793
|
-
/* istanbul ignore next */
|
|
4794
4775
|
if (isVisited === false && setIsVisited) {
|
|
4795
4776
|
setIsVisited();
|
|
4796
4777
|
}
|
|
@@ -4801,8 +4782,6 @@ const GoAInputInteger = props => {
|
|
|
4801
4782
|
});
|
|
4802
4783
|
},
|
|
4803
4784
|
onChange: (name, value) => {
|
|
4804
|
-
/* TODO: add the unit test, when the solution is used */
|
|
4805
|
-
/* istanbul ignore next */
|
|
4806
4785
|
if (isVisited === false && setIsVisited) {
|
|
4807
4786
|
setIsVisited();
|
|
4808
4787
|
}
|
|
@@ -4822,7 +4801,6 @@ const GoAInputIntegerControl = withJsonFormsControlProps(GoAIntegerControl);
|
|
|
4822
4801
|
|
|
4823
4802
|
const GoADateTimeInput = props => {
|
|
4824
4803
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
4825
|
-
// eslint-disable-next-line
|
|
4826
4804
|
const {
|
|
4827
4805
|
data,
|
|
4828
4806
|
config,
|
|
@@ -4865,11 +4843,9 @@ const GoADateTimeInput = props => {
|
|
|
4865
4843
|
});
|
|
4866
4844
|
},
|
|
4867
4845
|
onBlur: (name, value) => {
|
|
4868
|
-
/* istanbul ignore next */
|
|
4869
4846
|
if (isVisited === false && setIsVisited) {
|
|
4870
4847
|
setIsVisited();
|
|
4871
4848
|
}
|
|
4872
|
-
/* istanbul ignore next */
|
|
4873
4849
|
onBlurForDateControl({
|
|
4874
4850
|
name,
|
|
4875
4851
|
value,
|
|
@@ -4915,16 +4891,11 @@ const GoATimeInput = props => {
|
|
|
4915
4891
|
readonly: readOnly,
|
|
4916
4892
|
testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
|
|
4917
4893
|
onBlur: (name, value) => {
|
|
4918
|
-
/* istanbul ignore next */
|
|
4919
4894
|
if (isVisited === false && setIsVisited) {
|
|
4920
4895
|
setIsVisited();
|
|
4921
4896
|
}
|
|
4922
|
-
/* istanbul ignore next */
|
|
4923
4897
|
handleChange(path, value === '' ? undefined : value);
|
|
4924
4898
|
},
|
|
4925
|
-
// Dont use handleChange in the onChange event, use the keyPress or onBlur.
|
|
4926
|
-
// If you use it onChange along with keyPress event it will cause a
|
|
4927
|
-
// side effect that causes the validation to render when it shouldnt.
|
|
4928
4899
|
onChange: (name, value) => {},
|
|
4929
4900
|
onKeyPress: (name, value, key) => {
|
|
4930
4901
|
onKeyPressForTimeControl({
|
|
@@ -6009,6 +5980,7 @@ const stepperReducer = (state, action) => {
|
|
|
6009
5980
|
state.hasNextButton = id <= lastId;
|
|
6010
5981
|
state.hasPrevButton = id !== 0;
|
|
6011
5982
|
state.isOnReview = false;
|
|
5983
|
+
state.maxReachedStep = Math.max(state.maxReachedStep, activeId);
|
|
6012
5984
|
return Object.assign({}, state);
|
|
6013
5985
|
}
|
|
6014
5986
|
}
|
|
@@ -6078,7 +6050,8 @@ const createStepperContextInitData = props => {
|
|
|
6078
6050
|
hasPrevButton: activeId > 0 && activeId !== (categories === null || categories === void 0 ? void 0 : categories.length),
|
|
6079
6051
|
path,
|
|
6080
6052
|
isOnReview: activeId === (categories === null || categories === void 0 ? void 0 : categories.length),
|
|
6081
|
-
isValid: valid === true
|
|
6053
|
+
isValid: valid === true,
|
|
6054
|
+
maxReachedStep: 0
|
|
6082
6055
|
};
|
|
6083
6056
|
};
|
|
6084
6057
|
const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
|
|
@@ -6115,6 +6088,17 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6115
6088
|
selectCategory: id => {
|
|
6116
6089
|
return stepperState.categories[id];
|
|
6117
6090
|
},
|
|
6091
|
+
validatePage: id => {
|
|
6092
|
+
var _a;
|
|
6093
|
+
stepperDispatch({
|
|
6094
|
+
type: 'update/category',
|
|
6095
|
+
payload: {
|
|
6096
|
+
errors: (_a = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _a === void 0 ? void 0 : _a.errors,
|
|
6097
|
+
id,
|
|
6098
|
+
ajv
|
|
6099
|
+
}
|
|
6100
|
+
});
|
|
6101
|
+
},
|
|
6118
6102
|
goToPage: (id, updateCategoryId) => {
|
|
6119
6103
|
var _a, _b, _c;
|
|
6120
6104
|
ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
|
|
@@ -6147,6 +6131,7 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6147
6131
|
}, [stepperDispatch, stepperState, (_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors]);
|
|
6148
6132
|
useEffect(() => {
|
|
6149
6133
|
if ((context === null || context === void 0 ? void 0 : context.isProvided) === true) {
|
|
6134
|
+
/* The block is used to cache the state for the tenant web app review editor */
|
|
6150
6135
|
stepperDispatch({
|
|
6151
6136
|
type: 'update/uischema',
|
|
6152
6137
|
payload: {
|
|
@@ -6155,21 +6140,10 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6155
6140
|
}))
|
|
6156
6141
|
}
|
|
6157
6142
|
});
|
|
6143
|
+
context.goToPage(stepperState.maxReachedStep);
|
|
6144
|
+
context.goToPage(stepperState.activeId);
|
|
6158
6145
|
}
|
|
6159
6146
|
}, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
|
|
6160
|
-
useEffect(() => {
|
|
6161
|
-
const newState = createStepperContextInitData(Object.assign(Object.assign({}, StepperProps), {
|
|
6162
|
-
activeId: stepperState === null || stepperState === void 0 ? void 0 : stepperState.activeId
|
|
6163
|
-
}));
|
|
6164
|
-
if (JSON.stringify(newState) !== JSON.stringify(stepperState)) {
|
|
6165
|
-
stepperDispatch({
|
|
6166
|
-
type: 'update/uischema',
|
|
6167
|
-
payload: {
|
|
6168
|
-
state: newState
|
|
6169
|
-
}
|
|
6170
|
-
});
|
|
6171
|
-
}
|
|
6172
|
-
}, [StepperProps]);
|
|
6173
6147
|
return jsx(JsonFormsStepperContext.Provider, {
|
|
6174
6148
|
value: context,
|
|
6175
6149
|
children: children
|
|
@@ -6429,17 +6403,19 @@ const FormPagesView = props => {
|
|
|
6429
6403
|
} = props;
|
|
6430
6404
|
const enumerators = useContext(JsonFormContext);
|
|
6431
6405
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6406
|
+
const {
|
|
6407
|
+
validatePage,
|
|
6408
|
+
goToPage
|
|
6409
|
+
} = formStepperCtx;
|
|
6432
6410
|
const {
|
|
6433
6411
|
categories,
|
|
6434
6412
|
isOnReview,
|
|
6435
|
-
isValid
|
|
6413
|
+
isValid,
|
|
6414
|
+
activeId
|
|
6436
6415
|
} = formStepperCtx.selectStepperState();
|
|
6437
6416
|
const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
|
|
6438
6417
|
const submitForm = submitFormFunction && submitFormFunction();
|
|
6439
|
-
uischema.options || {};
|
|
6440
6418
|
const [isOpen, setIsOpen] = useState(false);
|
|
6441
|
-
useState(false);
|
|
6442
|
-
const [selectedPage, setSelectedPage] = useState(0);
|
|
6443
6419
|
const handleSubmit = () => {
|
|
6444
6420
|
if (submitForm) {
|
|
6445
6421
|
submitForm(data);
|
|
@@ -6450,8 +6426,9 @@ const FormPagesView = props => {
|
|
|
6450
6426
|
const onCloseModal = () => {
|
|
6451
6427
|
setIsOpen(false);
|
|
6452
6428
|
};
|
|
6453
|
-
|
|
6454
|
-
|
|
6429
|
+
useEffect(() => {
|
|
6430
|
+
validatePage(activeId);
|
|
6431
|
+
}, [data]);
|
|
6455
6432
|
return jsxs("div", {
|
|
6456
6433
|
"data-testid": "form-stepper-test-wrapper",
|
|
6457
6434
|
children: [jsx(Visible, {
|
|
@@ -6471,7 +6448,7 @@ const FormPagesView = props => {
|
|
|
6471
6448
|
cells,
|
|
6472
6449
|
data
|
|
6473
6450
|
};
|
|
6474
|
-
if (index ===
|
|
6451
|
+
if (index === activeId && !isOnReview) {
|
|
6475
6452
|
return jsxs("div", {
|
|
6476
6453
|
"data-testid": `step_${index}-content-pages`,
|
|
6477
6454
|
style: {
|
|
@@ -6479,7 +6456,7 @@ const FormPagesView = props => {
|
|
|
6479
6456
|
},
|
|
6480
6457
|
children: [index > 0 && jsx(BackButton, {
|
|
6481
6458
|
testId: "back-button",
|
|
6482
|
-
link: () =>
|
|
6459
|
+
link: () => goToPage(activeId - 1),
|
|
6483
6460
|
text: "Back"
|
|
6484
6461
|
}), jsxs(PageRenderPadding, {
|
|
6485
6462
|
children: [jsxs("h3", {
|
|
@@ -6488,16 +6465,19 @@ const FormPagesView = props => {
|
|
|
6488
6465
|
}), jsx(PageRenderPadding, {
|
|
6489
6466
|
children: index !== categories.length - 1 ? jsx(GoAButton, {
|
|
6490
6467
|
type: "submit",
|
|
6491
|
-
onClick: () =>
|
|
6492
|
-
disabled: !category.isValid,
|
|
6468
|
+
onClick: () => goToPage(activeId + 1),
|
|
6469
|
+
disabled: !(category.isValid && category.isCompleted),
|
|
6493
6470
|
testId: "pages-save-continue-btn",
|
|
6494
6471
|
children: "Save and continue"
|
|
6495
|
-
}) : jsx(
|
|
6496
|
-
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6472
|
+
}) : jsx(GoAButtonGroup, {
|
|
6473
|
+
alignment: "end",
|
|
6474
|
+
children: jsx(GoAButton, {
|
|
6475
|
+
type: 'primary',
|
|
6476
|
+
onClick: handleSubmit,
|
|
6477
|
+
disabled: !isValid,
|
|
6478
|
+
testId: "pages-submit-btn",
|
|
6479
|
+
children: "Submit"
|
|
6480
|
+
})
|
|
6501
6481
|
})
|
|
6502
6482
|
})]
|
|
6503
6483
|
}, `${category.label}`);
|
|
@@ -6543,8 +6523,8 @@ const categoriesAreValid = uischema => {
|
|
|
6543
6523
|
return isValid;
|
|
6544
6524
|
};
|
|
6545
6525
|
const CategorizationStepperRendererTester = rankWith(2, and(uiTypeIs('Categorization'), categoriesAreValid, uischema => {
|
|
6546
|
-
var _a;
|
|
6547
|
-
return ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.variant) === 'stepper';
|
|
6526
|
+
var _a, _b;
|
|
6527
|
+
return ((_a = uischema.options) === null || _a === void 0 ? void 0 : _a.variant) === 'stepper' || ((_b = uischema.options) === null || _b === void 0 ? void 0 : _b.variant) === undefined;
|
|
6548
6528
|
}));
|
|
6549
6529
|
const CategorizationPagesRendererTester = rankWith(2, and(uiTypeIs('Categorization'), categoriesAreValid, uischema => {
|
|
6550
6530
|
var _a;
|
|
@@ -9698,14 +9678,10 @@ const hasElements = schema => {
|
|
|
9698
9678
|
const isEmptyElements = schema => {
|
|
9699
9679
|
return 'elements' in schema && schema.elements !== undefined && schema.elements !== null && Object.keys(schema.elements).length === 0;
|
|
9700
9680
|
};
|
|
9701
|
-
const hasVariant = schema => {
|
|
9702
|
-
return 'options' in schema && schema.options !== undefined && schema.options !== null;
|
|
9703
|
-
};
|
|
9704
9681
|
|
|
9705
9682
|
const errCategorizationHasNonCategories = "Each element of 'Categorizations' must be of type 'Category'";
|
|
9706
9683
|
const errCategorizationHasNoElements = 'A Categorization must contain Categories.';
|
|
9707
9684
|
const errNoElements = type => `A ${type} must contain elements.`;
|
|
9708
|
-
const errCategorizationHasNoVariant = 'A Categorization must contain Options with a variant.';
|
|
9709
9685
|
const errMissingScope = 'A Control must have a scope';
|
|
9710
9686
|
const errMalformedScope = scope => `Scope ${scope} must be prefixed with '#/'.`;
|
|
9711
9687
|
const errUnknownScope = scope => `Failed to render: unknown scope ${scope}`;
|
|
@@ -9750,9 +9726,6 @@ const getUISchemaErrors = (uiSchema, schema) => {
|
|
|
9750
9726
|
if (!hasElements(uiSchema)) {
|
|
9751
9727
|
return errCategorizationHasNoElements;
|
|
9752
9728
|
}
|
|
9753
|
-
if (!hasVariant(uiSchema)) {
|
|
9754
|
-
return errCategorizationHasNoVariant;
|
|
9755
|
-
}
|
|
9756
9729
|
// ensure each element has type Category, and that each category
|
|
9757
9730
|
// has elements
|
|
9758
9731
|
if (isLayout(uiSchema)) {
|
|
@@ -9834,8 +9807,9 @@ const createDefaultAjv = (...schemas) => {
|
|
|
9834
9807
|
});
|
|
9835
9808
|
ajv.addSchema(schemas);
|
|
9836
9809
|
addErrors(ajv);
|
|
9837
|
-
ajv.addFormat('file-urn', /^urn:ads:platform:file-service:v[0-9]:\/files\/[a-zA-Z0-9.-]*$/);
|
|
9838
9810
|
addFormats(ajv);
|
|
9811
|
+
ajv.addFormat('file-urn', /^urn:ads:platform:file-service:v[0-9]:\/files\/[a-zA-Z0-9.-]*$/);
|
|
9812
|
+
ajv.addFormat('time', /^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/);
|
|
9839
9813
|
return ajv;
|
|
9840
9814
|
};
|
|
9841
9815
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.56.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",
|
|
@@ -18,6 +18,7 @@ export interface JsonFormsStepperContextProps {
|
|
|
18
18
|
selectPath: () => string;
|
|
19
19
|
selectCategory: (id: number) => CategoryState;
|
|
20
20
|
goToPage: (id: number, updateCategoryId?: number) => void;
|
|
21
|
+
validatePage: (id: number) => void;
|
|
21
22
|
isProvided?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare const JsonFormsStepperContext: import("react").Context<JsonFormsStepperContextProps | undefined>;
|
|
@@ -2,7 +2,6 @@ import { JsonSchema, UISchemaElement } from '@jsonforms/core';
|
|
|
2
2
|
export declare const errCategorizationHasNonCategories = "Each element of 'Categorizations' must be of type 'Category'";
|
|
3
3
|
export declare const errCategorizationHasNoElements = "A Categorization must contain Categories.";
|
|
4
4
|
export declare const errNoElements: (type: string) => string;
|
|
5
|
-
export declare const errCategorizationHasNoVariant = "A Categorization must contain Options with a variant.";
|
|
6
5
|
export declare const errMissingScope = "A Control must have a scope";
|
|
7
6
|
export declare const errMalformedScope: (scope: string) => string;
|
|
8
7
|
export declare const errUnknownScope: (scope: string) => string;
|