@abgov/jsonforms-components 1.47.0 → 1.48.1
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 +371 -337
- package/package.json +1 -1
- package/src/lib/Controls/FormStepper/FormStepperControl.d.ts +2 -1
- package/src/lib/Controls/FormStepper/RenderStepElements.d.ts +3 -5
- package/src/lib/Controls/FormStepper/context/StepperContext.d.ts +27 -0
- package/src/lib/Controls/FormStepper/context/index.d.ts +3 -0
- package/src/lib/Controls/FormStepper/context/reducer.d.ts +26 -0
- package/src/lib/Controls/FormStepper/context/types.d.ts +27 -0
- package/src/lib/Controls/FormStepper/types.d.ts +2 -0
- package/src/lib/Controls/FormStepper/util/helpers.d.ts +1 -0
- package/src/lib/util/layout.d.ts +3 -1
- package/src/lib/Controls/FormStepper/StepperContext.d.ts +0 -19
package/index.esm.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import * as runtime from 'react/jsx-runtime';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
|
|
4
3
|
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
|
|
5
4
|
import styled from 'styled-components';
|
|
5
|
+
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
|
|
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, getAjv, isVisible,
|
|
8
|
+
import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, Paths, or, isObjectArrayControl, isPrimitiveArrayControl, isControl, isScoped, hasType, isCategorization, isLayout } from '@jsonforms/core';
|
|
9
9
|
import { withJsonFormsControlProps, withJsonFormsRendererProps, withJsonFormsEnumProps, withTranslateProps, useJsonForms, JsonFormsDispatch, withJsonFormsLayoutProps, withJsonFormsArrayLayoutProps, withJsonFormsCellProps } from '@jsonforms/react';
|
|
10
|
-
import
|
|
10
|
+
import * as _$b from 'lodash';
|
|
11
|
+
import { isEqual, isObject as isObject$f } from 'lodash';
|
|
11
12
|
import merge from 'lodash/merge';
|
|
12
|
-
import isEmpty
|
|
13
|
+
import isEmpty from 'lodash/isEmpty';
|
|
13
14
|
import range from 'lodash/range';
|
|
14
15
|
import { evaluateSync, compileSync } from '@mdx-js/mdx';
|
|
15
16
|
import Ajv from 'ajv';
|
|
@@ -2787,52 +2788,6 @@ const convertToSentenceCase = input => {
|
|
|
2787
2788
|
return firstWord.concat(newWords).join(' ');
|
|
2788
2789
|
};
|
|
2789
2790
|
|
|
2790
|
-
const StepperContext = /*#__PURE__*/createContext({
|
|
2791
|
-
updateStatus: status => {},
|
|
2792
|
-
// return true because in the default case we don't want the
|
|
2793
|
-
// input controls to take action if it is false.
|
|
2794
|
-
isInitialized: _ => true,
|
|
2795
|
-
stepId: 0
|
|
2796
|
-
});
|
|
2797
|
-
const isEmpty = value => {
|
|
2798
|
-
return value === undefined || value === null || typeof value === 'string' && value.length < 1 || typeof value === 'boolean' && value === false;
|
|
2799
|
-
};
|
|
2800
|
-
const getCompletionStatus = (table, step, isFormChanged = false) => {
|
|
2801
|
-
const nonEmptyCount = getNonEmptyCount(table, step);
|
|
2802
|
-
const requiredCount = getRequiredCount(table, step);
|
|
2803
|
-
if (nonEmptyCount === 0) {
|
|
2804
|
-
if (!isFormChanged) {
|
|
2805
|
-
return undefined;
|
|
2806
|
-
}
|
|
2807
|
-
if (requiredCount === 0) {
|
|
2808
|
-
return 'complete';
|
|
2809
|
-
} else {
|
|
2810
|
-
return 'incomplete';
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
const requiredNonEmptyCount = getNonEmptyRequiredCount(table, step);
|
|
2814
|
-
if (requiredNonEmptyCount === requiredCount) {
|
|
2815
|
-
return 'complete';
|
|
2816
|
-
}
|
|
2817
|
-
return 'incomplete';
|
|
2818
|
-
};
|
|
2819
|
-
const getNonEmptyCount = (table, step) => {
|
|
2820
|
-
const nonEmptyStatuses = Object.keys(table).filter(k => {
|
|
2821
|
-
return table[k].step === step && !isEmpty(table[k].value);
|
|
2822
|
-
});
|
|
2823
|
-
return nonEmptyStatuses.length;
|
|
2824
|
-
};
|
|
2825
|
-
const getRequiredCount = (table, step) => {
|
|
2826
|
-
const requiredStatuses = Object.keys(table).filter(k => {
|
|
2827
|
-
return table[k].step === step && table[k].required;
|
|
2828
|
-
});
|
|
2829
|
-
return requiredStatuses.length;
|
|
2830
|
-
};
|
|
2831
|
-
const getNonEmptyRequiredCount = (table, step) => {
|
|
2832
|
-
const requiredNonEmptyStatuses = Object.keys(table).filter(k => table[k].step === step && table[k].required && !isEmpty(table[k].value));
|
|
2833
|
-
return requiredNonEmptyStatuses.length;
|
|
2834
|
-
};
|
|
2835
|
-
|
|
2836
2791
|
const standardizeDate = date => {
|
|
2837
2792
|
try {
|
|
2838
2793
|
const stdDate = new Date(date).toISOString().substring(0, 10);
|
|
@@ -3124,16 +3079,16 @@ const onChangeForNumericControl = props => {
|
|
|
3124
3079
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3125
3080
|
const onChangeForCheckboxData = (data, name, value) => data ? !value ? data === null || data === void 0 ? void 0 : data.filter(item => item !== name) : [...data, name] : [name];
|
|
3126
3081
|
|
|
3127
|
-
let _$
|
|
3128
|
-
_t$
|
|
3082
|
+
let _$a = t => t,
|
|
3083
|
+
_t$a,
|
|
3129
3084
|
_t2$6;
|
|
3130
|
-
styled.div(_t$
|
|
3085
|
+
styled.div(_t$a || (_t$a = _$a`
|
|
3131
3086
|
height: 70vh;
|
|
3132
3087
|
overflow-y: auto;
|
|
3133
3088
|
padding-left: var(--goa-space-2xs);
|
|
3134
3089
|
padding-right: var(--goa-space-2xs);
|
|
3135
3090
|
`));
|
|
3136
|
-
const Visible = styled.div(_t2$6 || (_t2$6 = _$
|
|
3091
|
+
const Visible = styled.div(_t2$6 || (_t2$6 = _$a`
|
|
3137
3092
|
display: ${0};
|
|
3138
3093
|
`), p => p.visible ? 'initial' : 'none');
|
|
3139
3094
|
|
|
@@ -3893,9 +3848,9 @@ const JsonFormRegisterProvider = ({
|
|
|
3893
3848
|
});
|
|
3894
3849
|
};
|
|
3895
3850
|
|
|
3896
|
-
let _$
|
|
3897
|
-
_t$
|
|
3898
|
-
const FormFieldWrapper = styled.div(_t$
|
|
3851
|
+
let _$9 = t => t,
|
|
3852
|
+
_t$9;
|
|
3853
|
+
const FormFieldWrapper = styled.div(_t$9 || (_t$9 = _$9`
|
|
3899
3854
|
margin-bottom: var(--goa-space-l);
|
|
3900
3855
|
`));
|
|
3901
3856
|
|
|
@@ -3917,30 +3872,6 @@ const GoAInputBaseControl = props => {
|
|
|
3917
3872
|
if (modifiedErrors === 'must be equal to one of the allowed values') {
|
|
3918
3873
|
modifiedErrors = '';
|
|
3919
3874
|
}
|
|
3920
|
-
const getStepStatus = (props, value) => {
|
|
3921
|
-
return {
|
|
3922
|
-
id: props.id,
|
|
3923
|
-
value: value,
|
|
3924
|
-
required: props.required || false,
|
|
3925
|
-
type: props.schema.type,
|
|
3926
|
-
step: stepperContext.stepId
|
|
3927
|
-
};
|
|
3928
|
-
};
|
|
3929
|
-
const stepperContext = useContext(StepperContext);
|
|
3930
|
-
const handlerWithStepperUpdate = (path, value) => {
|
|
3931
|
-
stepperContext.updateStatus(getStepStatus(props, value));
|
|
3932
|
-
props.handleChange(path, value);
|
|
3933
|
-
};
|
|
3934
|
-
const modifiedProps = Object.assign(Object.assign({}, props), {
|
|
3935
|
-
handleChange: handlerWithStepperUpdate
|
|
3936
|
-
});
|
|
3937
|
-
useEffect(() => {
|
|
3938
|
-
if (!stepperContext.isInitialized(props.id)) {
|
|
3939
|
-
const status = getStepStatus(props, props.data);
|
|
3940
|
-
stepperContext.updateStatus(status);
|
|
3941
|
-
}
|
|
3942
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3943
|
-
}, []);
|
|
3944
3875
|
return jsx(JsonFormRegisterProvider, {
|
|
3945
3876
|
defaultRegisters: undefined,
|
|
3946
3877
|
children: jsx(Visible, {
|
|
@@ -3952,7 +3883,7 @@ const GoAInputBaseControl = props => {
|
|
|
3952
3883
|
testId: `${isStepperReview === true && 'review-base-'}${path}`,
|
|
3953
3884
|
label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
|
|
3954
3885
|
helpText: typeof ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.help) === 'string' && !isStepperReview ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help : '',
|
|
3955
|
-
children: jsx(InnerComponent, Object.assign({},
|
|
3886
|
+
children: jsx(InnerComponent, Object.assign({}, props))
|
|
3956
3887
|
})
|
|
3957
3888
|
})
|
|
3958
3889
|
})
|
|
@@ -4169,29 +4100,7 @@ const MultiLineText = props => {
|
|
|
4169
4100
|
const autoCapitalize = ((_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.autoCapitalize) === true || ((_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true;
|
|
4170
4101
|
const readOnly = (_j = (_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.readOnly) !== null && _j !== void 0 ? _j : false;
|
|
4171
4102
|
const textAreaName = `${label || path}-text-area` || '';
|
|
4172
|
-
|
|
4173
|
-
useEffect(() => {
|
|
4174
|
-
if (textarea) {
|
|
4175
|
-
textarea.addEventListener('blur', onBlur);
|
|
4176
|
-
}
|
|
4177
|
-
return () => {
|
|
4178
|
-
if (textarea) {
|
|
4179
|
-
textarea.removeEventListener('blur', onBlur);
|
|
4180
|
-
}
|
|
4181
|
-
};
|
|
4182
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4183
|
-
}, [textarea]);
|
|
4184
|
-
const onBlur = event => {
|
|
4185
|
-
let eventTargetValue = '';
|
|
4186
|
-
if (event.target) {
|
|
4187
|
-
eventTargetValue = event.target.value;
|
|
4188
|
-
}
|
|
4189
|
-
onBlurForTextControl({
|
|
4190
|
-
name: path,
|
|
4191
|
-
controlProps: props,
|
|
4192
|
-
value: autoCapitalize ? eventTargetValue.toUpperCase() : eventTargetValue
|
|
4193
|
-
});
|
|
4194
|
-
};
|
|
4103
|
+
(_k = document.getElementsByName(textAreaName)[0]) !== null && _k !== void 0 ? _k : null;
|
|
4195
4104
|
const txtAreaComponent = jsx(GoATextArea, Object.assign({
|
|
4196
4105
|
error: errorsFormInput.length > 0,
|
|
4197
4106
|
value: textAreaValue,
|
|
@@ -4657,12 +4566,12 @@ const SPACE_KEY = ' ';
|
|
|
4657
4566
|
const ALT_KEY = 'Alt';
|
|
4658
4567
|
const SHIFT_KEY = 'Shift';
|
|
4659
4568
|
|
|
4660
|
-
let _$
|
|
4661
|
-
_t$
|
|
4569
|
+
let _$8 = t => t,
|
|
4570
|
+
_t$8,
|
|
4662
4571
|
_t2$5,
|
|
4663
4572
|
_t3$4,
|
|
4664
4573
|
_t4$3;
|
|
4665
|
-
const GoADropdownTextbox = styled.div(_t$
|
|
4574
|
+
const GoADropdownTextbox = styled.div(_t$8 || (_t$8 = _$8`
|
|
4666
4575
|
border-radius: var(--goa-space-2xs);
|
|
4667
4576
|
box-shadow: ${0};
|
|
4668
4577
|
&:hover {
|
|
@@ -4673,11 +4582,11 @@ const GoADropdownTextbox = styled.div(_t$7 || (_t$7 = _$7`
|
|
|
4673
4582
|
box-shadow: ${0};
|
|
4674
4583
|
}
|
|
4675
4584
|
`), p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus)` : '', p => p.isOpen ? `0 0 0 3px var(--goa-color-interactive-focus) !important` : '');
|
|
4676
|
-
const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$
|
|
4585
|
+
const GoADropdownListContainerWrapper = styled.div(_t2$5 || (_t2$5 = _$8`
|
|
4677
4586
|
position: relative;
|
|
4678
4587
|
display: ${0};
|
|
4679
4588
|
`), p => !(p === null || p === void 0 ? void 0 : p.isOpen) && 'none');
|
|
4680
|
-
const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$
|
|
4589
|
+
const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$8`
|
|
4681
4590
|
border: solid 1px var(--goa-color-greyscale-200);
|
|
4682
4591
|
border-radius: var(--goa-space-2xs);
|
|
4683
4592
|
background: var(--goa-color-greyscale-white);
|
|
@@ -4701,7 +4610,7 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$7`
|
|
|
4701
4610
|
scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
|
|
4702
4611
|
}
|
|
4703
4612
|
`), p => p.optionListMaxHeight || '272px');
|
|
4704
|
-
const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$
|
|
4613
|
+
const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$8`
|
|
4705
4614
|
padding: var(--goa-space-2xs) var(--goa-space-s);
|
|
4706
4615
|
text-overflow: ellipsis;
|
|
4707
4616
|
color: ${0} !important;
|
|
@@ -5202,8 +5111,8 @@ const BooleanRadioControl = props => jsx(GoAInputBaseControl, Object.assign({},
|
|
|
5202
5111
|
const GoABooleanRadioControlTester = rankWith(3, and(isBooleanControl, optionIs('radio', true)));
|
|
5203
5112
|
const GoABooleanRadioControl = withJsonFormsControlProps(BooleanRadioControl);
|
|
5204
5113
|
|
|
5205
|
-
let _$
|
|
5206
|
-
_t$
|
|
5114
|
+
let _$7 = t => t,
|
|
5115
|
+
_t$7;
|
|
5207
5116
|
const Checkboxes = ({
|
|
5208
5117
|
children,
|
|
5209
5118
|
orientation,
|
|
@@ -5215,7 +5124,7 @@ const Checkboxes = ({
|
|
|
5215
5124
|
children: children
|
|
5216
5125
|
});
|
|
5217
5126
|
};
|
|
5218
|
-
const CheckBoxGroupDiv = styled.div(_t$
|
|
5127
|
+
const CheckBoxGroupDiv = styled.div(_t$7 || (_t$7 = _$7`
|
|
5219
5128
|
.horizontal {
|
|
5220
5129
|
display: flex;
|
|
5221
5130
|
flex-direction: row;
|
|
@@ -5295,6 +5204,8 @@ const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, pr
|
|
|
5295
5204
|
}));
|
|
5296
5205
|
const GoInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
|
|
5297
5206
|
|
|
5207
|
+
let _$6 = t => t,
|
|
5208
|
+
_t$6;
|
|
5298
5209
|
const renderLayoutElements = (elements, schema, path, enabled, renderers, cells) => {
|
|
5299
5210
|
return elements.map((child, index) => jsx("div", {
|
|
5300
5211
|
children: jsx(JsonFormsDispatch, {
|
|
@@ -5327,7 +5238,7 @@ const LayoutRenderer = ({
|
|
|
5327
5238
|
visible,
|
|
5328
5239
|
width
|
|
5329
5240
|
}) => {
|
|
5330
|
-
if (isEmpty
|
|
5241
|
+
if (isEmpty(elements)) {
|
|
5331
5242
|
return null;
|
|
5332
5243
|
} else {
|
|
5333
5244
|
if (direction === 'row') {
|
|
@@ -5346,6 +5257,40 @@ const LayoutRenderer = ({
|
|
|
5346
5257
|
}
|
|
5347
5258
|
}
|
|
5348
5259
|
};
|
|
5260
|
+
const ReviewLayoutRenderer = ({
|
|
5261
|
+
elements,
|
|
5262
|
+
schema,
|
|
5263
|
+
path,
|
|
5264
|
+
enabled,
|
|
5265
|
+
direction,
|
|
5266
|
+
renderers,
|
|
5267
|
+
cells,
|
|
5268
|
+
visible,
|
|
5269
|
+
width
|
|
5270
|
+
}) => {
|
|
5271
|
+
if (isEmpty(elements)) {
|
|
5272
|
+
return null;
|
|
5273
|
+
} else {
|
|
5274
|
+
if (direction === 'row') {
|
|
5275
|
+
return jsx(Visible, {
|
|
5276
|
+
visible: visible,
|
|
5277
|
+
children: jsx(ReviewGrid, {
|
|
5278
|
+
children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
|
|
5279
|
+
})
|
|
5280
|
+
});
|
|
5281
|
+
} else {
|
|
5282
|
+
return jsx(Visible, {
|
|
5283
|
+
visible: visible,
|
|
5284
|
+
children: renderLayoutElements(elements, schema, path, enabled, renderers, cells)
|
|
5285
|
+
});
|
|
5286
|
+
}
|
|
5287
|
+
}
|
|
5288
|
+
};
|
|
5289
|
+
const ReviewGrid = styled.div(_t$6 || (_t$6 = _$6`
|
|
5290
|
+
display: grid;
|
|
5291
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
|
5292
|
+
gap: 16px;
|
|
5293
|
+
`));
|
|
5349
5294
|
|
|
5350
5295
|
let _$5 = t => t,
|
|
5351
5296
|
_t$5,
|
|
@@ -5565,73 +5510,21 @@ const ContextProviderFactory = () => new ContextProviderClass().setup;
|
|
|
5565
5510
|
const JsonFormContext = /*#__PURE__*/createContext(null);
|
|
5566
5511
|
|
|
5567
5512
|
const RenderStepElements = props => {
|
|
5568
|
-
return (
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
visible: props.visible,
|
|
5582
|
-
enabled: props.enabled && !props.disabledCategoryMap[props.categoryIndex]
|
|
5583
|
-
}, index);
|
|
5584
|
-
})
|
|
5513
|
+
return jsx(Visible, {
|
|
5514
|
+
visible: props.visible,
|
|
5515
|
+
"date-testid": `${props.path}-categories-${props.categoryIndex}`,
|
|
5516
|
+
children: props.category.elements.map((uiSchema, index) => {
|
|
5517
|
+
return jsx(JsonFormsDispatch, {
|
|
5518
|
+
schema: props.schema,
|
|
5519
|
+
uischema: uiSchema,
|
|
5520
|
+
renderers: props.renderers,
|
|
5521
|
+
cells: props.cells,
|
|
5522
|
+
path: props.path,
|
|
5523
|
+
visible: props.visible,
|
|
5524
|
+
enabled: props.enabled
|
|
5525
|
+
}, `${props.path}-category-page-${index}`);
|
|
5585
5526
|
})
|
|
5586
|
-
);
|
|
5587
|
-
};
|
|
5588
|
-
|
|
5589
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5590
|
-
const validateData = (jsonSchema, data, ajv) => {
|
|
5591
|
-
const newSchema = JSON.parse(JSON.stringify(jsonSchema));
|
|
5592
|
-
Object.keys(newSchema.properties || {}).forEach(propertyName => {
|
|
5593
|
-
var _a, _b, _c, _d, _e;
|
|
5594
|
-
const property = newSchema.properties || {};
|
|
5595
|
-
if (((_a = property[propertyName]) === null || _a === void 0 ? void 0 : _a.enum) && ((_b = property[propertyName]) === null || _b === void 0 ? void 0 : _b.enum[0]) === '') {
|
|
5596
|
-
(_c = property[propertyName]) === null || _c === void 0 ? true : delete _c.enum;
|
|
5597
|
-
}
|
|
5598
|
-
if (((_d = property[propertyName]) === null || _d === void 0 ? void 0 : _d.format) === 'file-urn') {
|
|
5599
|
-
delete property[propertyName].format;
|
|
5600
|
-
}
|
|
5601
|
-
if (((_e = property[propertyName]) === null || _e === void 0 ? void 0 : _e.title) === sinTitle && data && data[propertyName] === '') {
|
|
5602
|
-
delete data[propertyName];
|
|
5603
|
-
}
|
|
5604
5527
|
});
|
|
5605
|
-
try {
|
|
5606
|
-
const validate = ajv.compile(newSchema);
|
|
5607
|
-
return validate(data).valueOf();
|
|
5608
|
-
} catch (e) {
|
|
5609
|
-
return false;
|
|
5610
|
-
}
|
|
5611
|
-
};
|
|
5612
|
-
|
|
5613
|
-
/**
|
|
5614
|
-
* Steps can be hidden:
|
|
5615
|
-
* When the user clicks on a step in the stepper function, it returns
|
|
5616
|
-
* a step number relative to all steps. Map to the step number relative
|
|
5617
|
-
* to the visible steps.
|
|
5618
|
-
*/
|
|
5619
|
-
const mapToVisibleStep = (step, allSteps, visibleSteps) => {
|
|
5620
|
-
if (visibleSteps.length < 1) return 0;
|
|
5621
|
-
if (step < 1) return 1;
|
|
5622
|
-
if (allSteps.length !== visibleSteps.length) {
|
|
5623
|
-
const stepIndex = step - 1;
|
|
5624
|
-
if (step > 1 && step <= allSteps.length) {
|
|
5625
|
-
// Check to see if the the step is visible
|
|
5626
|
-
const selectedLabel = allSteps[stepIndex];
|
|
5627
|
-
const selectedIndex = visibleSteps.indexOf(selectedLabel);
|
|
5628
|
-
step = selectedIndex !== -1 ? selectedIndex + 1 : 1;
|
|
5629
|
-
}
|
|
5630
|
-
if (step > allSteps.length) {
|
|
5631
|
-
step = visibleSteps.length;
|
|
5632
|
-
}
|
|
5633
|
-
}
|
|
5634
|
-
return step;
|
|
5635
5528
|
};
|
|
5636
5529
|
|
|
5637
5530
|
var uncurryThis$2 = functionUncurryThisClause;
|
|
@@ -5802,6 +5695,23 @@ const getProperty = (obj, propName) => {
|
|
|
5802
5695
|
}
|
|
5803
5696
|
}
|
|
5804
5697
|
};
|
|
5698
|
+
// eslint-disable-next-line
|
|
5699
|
+
const pickPropertyValues = (obj, property) => {
|
|
5700
|
+
let values = [];
|
|
5701
|
+
Object.keys(obj).forEach(function (key) {
|
|
5702
|
+
if (key === property) {
|
|
5703
|
+
values.push(obj[key]);
|
|
5704
|
+
} else if (_$b.isObject(obj[key])) {
|
|
5705
|
+
values = [...values, ...pickPropertyValues(obj[key], property)];
|
|
5706
|
+
} else if (_$b.isArray(obj[key])) {
|
|
5707
|
+
const nextValues = obj[key].map(function (arrayObj) {
|
|
5708
|
+
return pickPropertyValues(arrayObj, property);
|
|
5709
|
+
});
|
|
5710
|
+
values = [...values, ...nextValues];
|
|
5711
|
+
}
|
|
5712
|
+
});
|
|
5713
|
+
return values;
|
|
5714
|
+
};
|
|
5805
5715
|
|
|
5806
5716
|
const FormStepperReviewer = props => {
|
|
5807
5717
|
var _a, _b, _c;
|
|
@@ -5811,8 +5721,6 @@ const FormStepperReviewer = props => {
|
|
|
5811
5721
|
schema,
|
|
5812
5722
|
ajv,
|
|
5813
5723
|
cells,
|
|
5814
|
-
renderers,
|
|
5815
|
-
visible,
|
|
5816
5724
|
enabled,
|
|
5817
5725
|
navigationFunc
|
|
5818
5726
|
} = props;
|
|
@@ -5830,12 +5738,14 @@ const FormStepperReviewer = props => {
|
|
|
5830
5738
|
children: [jsx(ReviewItemTitle, {
|
|
5831
5739
|
children: categoryLabel
|
|
5832
5740
|
}), navigationFunc && jsx(Anchor, {
|
|
5833
|
-
onClick: () =>
|
|
5741
|
+
onClick: () => {
|
|
5742
|
+
navigationFunc(index);
|
|
5743
|
+
},
|
|
5834
5744
|
"data-testid": testId,
|
|
5835
5745
|
onKeyDown: e => {
|
|
5836
5746
|
if (!readOnly && (e.key === ' ' || e.key === 'Enter')) {
|
|
5837
5747
|
e.preventDefault();
|
|
5838
|
-
navigationFunc(index
|
|
5748
|
+
navigationFunc(index);
|
|
5839
5749
|
}
|
|
5840
5750
|
},
|
|
5841
5751
|
children: readOnly ? 'View' : 'Edit'
|
|
@@ -5888,38 +5798,257 @@ const FormStepperReviewer = props => {
|
|
|
5888
5798
|
};
|
|
5889
5799
|
const FormStepperReviewControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperReviewer)));
|
|
5890
5800
|
|
|
5801
|
+
const stepperReducer = (state, action) => {
|
|
5802
|
+
const {
|
|
5803
|
+
activeId,
|
|
5804
|
+
categories
|
|
5805
|
+
} = state;
|
|
5806
|
+
const lastId = categories[categories.length - 1].id;
|
|
5807
|
+
switch (action.type) {
|
|
5808
|
+
case 'page/next':
|
|
5809
|
+
{
|
|
5810
|
+
state.activeId += 1;
|
|
5811
|
+
if (activeId === lastId) {
|
|
5812
|
+
state.isOnReview = true;
|
|
5813
|
+
state.hasNextButton = false;
|
|
5814
|
+
state.hasPrevButton = false;
|
|
5815
|
+
} else {
|
|
5816
|
+
state.hasNextButton = true;
|
|
5817
|
+
state.hasPrevButton = true;
|
|
5818
|
+
state.isOnReview = false;
|
|
5819
|
+
}
|
|
5820
|
+
state.categories[activeId].isVisited = true;
|
|
5821
|
+
return Object.assign({}, state);
|
|
5822
|
+
}
|
|
5823
|
+
case 'page/prev':
|
|
5824
|
+
{
|
|
5825
|
+
state.categories[activeId].isVisited = true;
|
|
5826
|
+
if (activeId > 0) {
|
|
5827
|
+
state.activeId -= 1;
|
|
5828
|
+
state.hasPrevButton = state.activeId !== 0;
|
|
5829
|
+
state.hasNextButton = true;
|
|
5830
|
+
state.isOnReview = false;
|
|
5831
|
+
}
|
|
5832
|
+
return Object.assign({}, state);
|
|
5833
|
+
}
|
|
5834
|
+
case 'page/to/index':
|
|
5835
|
+
{
|
|
5836
|
+
const {
|
|
5837
|
+
id
|
|
5838
|
+
} = action.payload;
|
|
5839
|
+
state.activeId = id;
|
|
5840
|
+
if (id > lastId) {
|
|
5841
|
+
state.isOnReview = true;
|
|
5842
|
+
state.hasNextButton = false;
|
|
5843
|
+
state.hasPrevButton = false;
|
|
5844
|
+
return Object.assign({}, state);
|
|
5845
|
+
} else {
|
|
5846
|
+
state.categories[id].isVisited = true;
|
|
5847
|
+
state.hasNextButton = id <= lastId;
|
|
5848
|
+
state.hasPrevButton = id !== 0;
|
|
5849
|
+
state.isOnReview = false;
|
|
5850
|
+
return Object.assign({}, state);
|
|
5851
|
+
}
|
|
5852
|
+
}
|
|
5853
|
+
case 'update/category':
|
|
5854
|
+
{
|
|
5855
|
+
const {
|
|
5856
|
+
id,
|
|
5857
|
+
errors
|
|
5858
|
+
} = action.payload;
|
|
5859
|
+
if (state.isOnReview) {
|
|
5860
|
+
return Object.assign({}, state);
|
|
5861
|
+
}
|
|
5862
|
+
const errorsInCategory = errors.filter(e => categories[id].scopes.map(s => '/' + toDataPath(s)).includes(e.instancePath));
|
|
5863
|
+
state.categories[id].isCompleted = errorsInCategory.filter(e => e.keyword === 'required').length === 0;
|
|
5864
|
+
state.categories[id].isValid = errorsInCategory.length === 0;
|
|
5865
|
+
return Object.assign({}, state);
|
|
5866
|
+
}
|
|
5867
|
+
case 'validate/form':
|
|
5868
|
+
{
|
|
5869
|
+
const {
|
|
5870
|
+
errors
|
|
5871
|
+
} = action.payload;
|
|
5872
|
+
state.isValid = errors.length === 0;
|
|
5873
|
+
return Object.assign({}, state);
|
|
5874
|
+
}
|
|
5875
|
+
default:
|
|
5876
|
+
return state;
|
|
5877
|
+
}
|
|
5878
|
+
};
|
|
5879
|
+
|
|
5880
|
+
const isErrorPathIncluded = (errorPaths, path) => {
|
|
5881
|
+
return errorPaths.some(ePath => {
|
|
5882
|
+
/**
|
|
5883
|
+
* case A: errorPaths: [name] path: [name]
|
|
5884
|
+
*
|
|
5885
|
+
* case B: errorPath: [name] path: [name.firstName]
|
|
5886
|
+
* */
|
|
5887
|
+
return ePath === path || path.startsWith(ePath + '.');
|
|
5888
|
+
});
|
|
5889
|
+
};
|
|
5890
|
+
const getIncompletePaths = (ajv, scopes) => {
|
|
5891
|
+
var _a;
|
|
5892
|
+
const requiredErrorPaths = (_a = ajv === null || ajv === void 0 ? void 0 : ajv.errors) === null || _a === void 0 ? void 0 : _a.filter(e => e.keyword === 'required').map(e => {
|
|
5893
|
+
var _a;
|
|
5894
|
+
return (_a = e === null || e === void 0 ? void 0 : e.schema) === null || _a === void 0 ? void 0 : _a[0];
|
|
5895
|
+
});
|
|
5896
|
+
const _scopes = scopes.map(scope => toDataPath(scope)).filter(path => requiredErrorPaths && isErrorPathIncluded(requiredErrorPaths, path));
|
|
5897
|
+
return _scopes;
|
|
5898
|
+
};
|
|
5899
|
+
const createStepperContextInitData = props => {
|
|
5900
|
+
var _a;
|
|
5901
|
+
const {
|
|
5902
|
+
uischema,
|
|
5903
|
+
data,
|
|
5904
|
+
schema,
|
|
5905
|
+
ajv,
|
|
5906
|
+
t,
|
|
5907
|
+
visible,
|
|
5908
|
+
path
|
|
5909
|
+
} = props;
|
|
5910
|
+
const categorization = uischema;
|
|
5911
|
+
const valid = ajv.validate(schema, data || {});
|
|
5912
|
+
const categories = (_a = categorization.elements) === null || _a === void 0 ? void 0 : _a.map((c, id) => {
|
|
5913
|
+
const scopes = pickPropertyValues(c, 'scope');
|
|
5914
|
+
const incompletePaths = getIncompletePaths(ajv, pickPropertyValues(c, 'scope'));
|
|
5915
|
+
return {
|
|
5916
|
+
id,
|
|
5917
|
+
label: deriveLabelForUISchemaElement(c, t),
|
|
5918
|
+
scopes,
|
|
5919
|
+
isVisited: id === 0,
|
|
5920
|
+
isCompleted: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
|
|
5921
|
+
isValid: (incompletePaths === null || incompletePaths === void 0 ? void 0 : incompletePaths.length) === 0,
|
|
5922
|
+
uischema: c,
|
|
5923
|
+
isEnabled: isEnabled(c, data, '', ajv),
|
|
5924
|
+
visible
|
|
5925
|
+
};
|
|
5926
|
+
});
|
|
5927
|
+
const activeId = (props === null || props === void 0 ? void 0 : props.activeId) || 0;
|
|
5928
|
+
return {
|
|
5929
|
+
categories: categories,
|
|
5930
|
+
activeId,
|
|
5931
|
+
hasNextButton: true,
|
|
5932
|
+
hasPrevButton: activeId > 0,
|
|
5933
|
+
path,
|
|
5934
|
+
isOnReview: activeId === (categories === null || categories === void 0 ? void 0 : categories.length),
|
|
5935
|
+
isValid: valid === true
|
|
5936
|
+
};
|
|
5937
|
+
};
|
|
5938
|
+
const JsonFormsStepperContext = /*#__PURE__*/createContext(undefined);
|
|
5939
|
+
const JsonFormsStepperContextProvider = ({
|
|
5940
|
+
children,
|
|
5941
|
+
StepperProps
|
|
5942
|
+
}) => {
|
|
5943
|
+
const ctx = useJsonForms();
|
|
5944
|
+
const [stepperState, dispatch] = useReducer(stepperReducer, createStepperContextInitData(StepperProps));
|
|
5945
|
+
const stepperDispatch = (StepperProps === null || StepperProps === void 0 ? void 0 : StepperProps.customDispatch) || dispatch;
|
|
5946
|
+
const context = useMemo(() => {
|
|
5947
|
+
return {
|
|
5948
|
+
isProvided: true,
|
|
5949
|
+
stepperDispatch,
|
|
5950
|
+
selectStepperState: () => {
|
|
5951
|
+
return stepperState;
|
|
5952
|
+
},
|
|
5953
|
+
selectIsDisabled: () => {
|
|
5954
|
+
var _a;
|
|
5955
|
+
return !((_a = stepperState.categories[stepperState.activeId]) === null || _a === void 0 ? void 0 : _a.isEnabled);
|
|
5956
|
+
},
|
|
5957
|
+
selectIsActive: id => {
|
|
5958
|
+
return id === stepperState.activeId;
|
|
5959
|
+
},
|
|
5960
|
+
selectPath: () => {
|
|
5961
|
+
return stepperState.path;
|
|
5962
|
+
},
|
|
5963
|
+
selectCategory: id => {
|
|
5964
|
+
return stepperState.categories[id];
|
|
5965
|
+
},
|
|
5966
|
+
goToPage: (id, updateCategoryId) => {
|
|
5967
|
+
var _a, _b, _c;
|
|
5968
|
+
if (updateCategoryId !== undefined) {
|
|
5969
|
+
stepperDispatch({
|
|
5970
|
+
type: 'update/category',
|
|
5971
|
+
payload: {
|
|
5972
|
+
errors: ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.errors) || [],
|
|
5973
|
+
id: updateCategoryId
|
|
5974
|
+
}
|
|
5975
|
+
});
|
|
5976
|
+
}
|
|
5977
|
+
if (stepperState.isOnReview !== true) {
|
|
5978
|
+
stepperDispatch({
|
|
5979
|
+
type: 'update/category',
|
|
5980
|
+
payload: {
|
|
5981
|
+
errors: ((_b = ctx.core) === null || _b === void 0 ? void 0 : _b.errors) || [],
|
|
5982
|
+
id: stepperState.activeId
|
|
5983
|
+
}
|
|
5984
|
+
});
|
|
5985
|
+
}
|
|
5986
|
+
stepperDispatch({
|
|
5987
|
+
type: 'validate/form',
|
|
5988
|
+
payload: {
|
|
5989
|
+
errors: (_c = ctx.core) === null || _c === void 0 ? void 0 : _c.errors
|
|
5990
|
+
}
|
|
5991
|
+
});
|
|
5992
|
+
stepperDispatch({
|
|
5993
|
+
type: 'page/to/index',
|
|
5994
|
+
payload: {
|
|
5995
|
+
id
|
|
5996
|
+
}
|
|
5997
|
+
});
|
|
5998
|
+
}
|
|
5999
|
+
};
|
|
6000
|
+
}, [ctx === null || ctx === void 0 ? void 0 : ctx.core, stepperDispatch, stepperState]);
|
|
6001
|
+
return jsx(JsonFormsStepperContext.Provider, {
|
|
6002
|
+
value: context,
|
|
6003
|
+
children: children
|
|
6004
|
+
});
|
|
6005
|
+
};
|
|
6006
|
+
|
|
5891
6007
|
const summaryLabel = 'Summary';
|
|
5892
6008
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5893
6009
|
const FormStepper = props => {
|
|
5894
|
-
|
|
6010
|
+
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6011
|
+
/**
|
|
6012
|
+
* StepperCtx can only be provided once to prevent issues from categorization in categorization
|
|
6013
|
+
* */
|
|
6014
|
+
if ((formStepperCtx === null || formStepperCtx === void 0 ? void 0 : formStepperCtx.isProvided) === true) {
|
|
6015
|
+
return jsx(FormStepperView, Object.assign({}, props));
|
|
6016
|
+
}
|
|
6017
|
+
return jsx(JsonFormsStepperContextProvider, {
|
|
6018
|
+
StepperProps: Object.assign({}, props),
|
|
6019
|
+
children: jsx(FormStepperView, Object.assign({}, props))
|
|
6020
|
+
});
|
|
6021
|
+
};
|
|
6022
|
+
const FormStepperView = props => {
|
|
6023
|
+
var _a, _b, _c;
|
|
5895
6024
|
const {
|
|
5896
6025
|
uischema,
|
|
5897
6026
|
data,
|
|
5898
6027
|
schema,
|
|
5899
|
-
ajv,
|
|
5900
6028
|
path,
|
|
5901
6029
|
cells,
|
|
5902
6030
|
renderers,
|
|
5903
6031
|
visible,
|
|
5904
|
-
enabled,
|
|
5905
6032
|
t
|
|
5906
6033
|
} = props;
|
|
5907
6034
|
const enumerators = useContext(JsonFormContext);
|
|
6035
|
+
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6036
|
+
const {
|
|
6037
|
+
activeId,
|
|
6038
|
+
categories,
|
|
6039
|
+
hasNextButton,
|
|
6040
|
+
hasPrevButton,
|
|
6041
|
+
isOnReview,
|
|
6042
|
+
isValid
|
|
6043
|
+
} = formStepperCtx.selectStepperState();
|
|
6044
|
+
const {
|
|
6045
|
+
selectIsDisabled,
|
|
6046
|
+
goToPage
|
|
6047
|
+
} = formStepperCtx;
|
|
5908
6048
|
const submitFormFunction = enumerators === null || enumerators === void 0 ? void 0 : enumerators.submitFunction.get('submit-form');
|
|
5909
6049
|
const submitForm = submitFormFunction && submitFormFunction();
|
|
5910
|
-
const categorization = uischema;
|
|
5911
|
-
const allCategories = JSON.parse(JSON.stringify(categorization));
|
|
5912
|
-
const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
|
|
5913
6050
|
const optionProps = uischema.options || {};
|
|
5914
|
-
const [
|
|
5915
|
-
const [staleCategories, setStaleCategories] = React.useState(categorization.elements);
|
|
5916
|
-
const [isFormValid, setIsFormValid] = React.useState(false);
|
|
5917
|
-
const [showNextBtn, setShowNextBtn] = React.useState(true);
|
|
5918
|
-
const [isOpen, setIsOpen] = React.useState(false);
|
|
5919
|
-
const [categories, setCategories] = React.useState(categorization.elements);
|
|
5920
|
-
const [inputStatuses, setInputStatuses] = React.useState({});
|
|
5921
|
-
const [stepStatuses, setStepStatuses] = React.useState([]);
|
|
5922
|
-
const disabledCategoryMap = categories.map(c => !isEnabled(c, data, '', ajv));
|
|
6051
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
5923
6052
|
const handleSubmit = () => {
|
|
5924
6053
|
if (submitForm) {
|
|
5925
6054
|
submitForm(data);
|
|
@@ -5930,130 +6059,40 @@ const FormStepper = props => {
|
|
|
5930
6059
|
const onCloseModal = () => {
|
|
5931
6060
|
setIsOpen(false);
|
|
5932
6061
|
};
|
|
5933
|
-
|
|
5934
|
-
return categories.map(c => deriveLabelForUISchemaElement(c, t));
|
|
5935
|
-
}, [categories, t]);
|
|
5936
|
-
useEffect(() => {}, [categories.length]);
|
|
5937
|
-
useEffect(() => {
|
|
5938
|
-
const cats = categorization.elements.filter(category => isVisible(category, data, '', ajv));
|
|
5939
|
-
setCategories(cats);
|
|
5940
|
-
}, [categorization, data, ajv]);
|
|
5941
|
-
useEffect(() => {
|
|
5942
|
-
const statuses = Array(categories.length);
|
|
5943
|
-
categories.forEach((_, i) => {
|
|
5944
|
-
statuses[i] = isEmpty$2(stepStatuses[i]) ? getCompletionStatus(inputStatuses, i + 1) : stepStatuses[i];
|
|
5945
|
-
});
|
|
5946
|
-
setStepStatuses(statuses);
|
|
5947
|
-
}, [inputStatuses, categories]);
|
|
5948
|
-
useEffect(() => {
|
|
5949
|
-
const isValid = validateData(schema, data, ajv);
|
|
5950
|
-
setIsFormValid(isValid);
|
|
5951
|
-
}, [ajv, data, schema]);
|
|
5952
|
-
useEffect(() => {
|
|
5953
|
-
// Override the "controlled Navigation", if property is supplied
|
|
5954
|
-
// Default: no controlled nav.
|
|
5955
|
-
setStep((componentProps === null || componentProps === void 0 ? void 0 : componentProps.controlledNav) ? 1 : 0);
|
|
5956
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
5957
|
-
}, []);
|
|
5958
|
-
useEffect(() => {
|
|
5959
|
-
setStaleCategories(categories);
|
|
5960
|
-
}, [categories]);
|
|
5961
|
-
/* istanbul ignore next */
|
|
5962
|
-
if ((categories === null || categories === void 0 ? void 0 : categories.length) < 1) {
|
|
5963
|
-
// eslint-disable-next-line
|
|
5964
|
-
return jsx(Fragment, {});
|
|
5965
|
-
}
|
|
5966
|
-
function nextPage(page, disabled) {
|
|
5967
|
-
const pageStatus = getCompletionStatus(inputStatuses, page, true);
|
|
5968
|
-
const statuses = [...stepStatuses];
|
|
5969
|
-
statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
|
|
5970
|
-
setStepStatuses(statuses);
|
|
5971
|
-
page++;
|
|
5972
|
-
while (page <= disabled.length && disabled[page - 1]) {
|
|
5973
|
-
/* istanbul ignore next */
|
|
5974
|
-
page++;
|
|
5975
|
-
}
|
|
5976
|
-
setPage(page);
|
|
5977
|
-
}
|
|
5978
|
-
function prevPage(page, disabled) {
|
|
5979
|
-
const pageStatus = getCompletionStatus(inputStatuses, page, true);
|
|
5980
|
-
const statuses = [...stepStatuses];
|
|
5981
|
-
statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
|
|
5982
|
-
setStepStatuses(statuses);
|
|
5983
|
-
page--;
|
|
5984
|
-
while (page >= 0 && disabled[page - 1]) {
|
|
5985
|
-
/* istanbul ignore next */
|
|
5986
|
-
page--;
|
|
5987
|
-
}
|
|
5988
|
-
setPage(page);
|
|
5989
|
-
}
|
|
5990
|
-
const getAllStatuses = (nextPage, totalVisibleTabs) => {
|
|
5991
|
-
const previouslyActivePage = nextPage - 1;
|
|
5992
|
-
const statuses = [...stepStatuses];
|
|
5993
|
-
for (let currentPage = 1; currentPage <= previouslyActivePage; currentPage++) {
|
|
5994
|
-
const pageStatus = getCompletionStatus(inputStatuses, currentPage, true);
|
|
5995
|
-
statuses[currentPage - 1] = pageStatus ? pageStatus : 'incomplete';
|
|
5996
|
-
}
|
|
5997
|
-
return statuses;
|
|
5998
|
-
};
|
|
5999
|
-
/* istanbul ignore next */
|
|
6000
|
-
function setTab(page) {
|
|
6001
|
-
const categoryLabels = [...allCategories.elements.map(category => category.label), summaryLabel];
|
|
6002
|
-
const visibleLabels = [...visibleCategoryLabels, summaryLabel];
|
|
6003
|
-
const newPage = mapToVisibleStep(page, categoryLabels, visibleLabels);
|
|
6004
|
-
if (Object.keys(inputStatuses).length) {
|
|
6005
|
-
const statuses = getAllStatuses(page, visibleLabels.length);
|
|
6006
|
-
setStepStatuses(statuses);
|
|
6007
|
-
}
|
|
6008
|
-
setPage(newPage);
|
|
6009
|
-
}
|
|
6010
|
-
function setPage(page) {
|
|
6011
|
-
setStep(page);
|
|
6012
|
-
if (page < 1 || page > categories.length + 1) return;
|
|
6013
|
-
setShowNextBtn(categories.length + 1 !== page);
|
|
6014
|
-
}
|
|
6015
|
-
const updateInputStatus = inputStatus => {
|
|
6016
|
-
inputStatuses[inputStatus.id] = inputStatus;
|
|
6017
|
-
setInputStatuses(Object.assign({}, inputStatuses));
|
|
6018
|
-
};
|
|
6019
|
-
const isInputInitialized = inputId => {
|
|
6020
|
-
return inputId in inputStatuses;
|
|
6021
|
-
};
|
|
6022
|
-
const isFormSubmitted = (_c = enumerators === null || enumerators === void 0 ? void 0 : enumerators.isFormSubmitted) !== null && _c !== void 0 ? _c : false;
|
|
6023
|
-
return jsx("div", {
|
|
6062
|
+
return jsxs("div", {
|
|
6024
6063
|
"data-testid": "form-stepper-test-wrapper",
|
|
6025
|
-
children: jsx(
|
|
6064
|
+
children: [jsx("div", {
|
|
6065
|
+
children: ((_a = categories[activeId]) === null || _a === void 0 ? void 0 : _a.isCompleted) && ((_b = categories[activeId]) === null || _b === void 0 ? void 0 : _b.isVisited)
|
|
6066
|
+
}), jsx(Visible, {
|
|
6026
6067
|
visible: visible,
|
|
6027
6068
|
children: jsxs("div", {
|
|
6028
6069
|
id: `${path || `goa`}-form-stepper`,
|
|
6029
6070
|
className: "formStepper",
|
|
6030
|
-
children: [
|
|
6031
|
-
testId: (
|
|
6032
|
-
step: step,
|
|
6071
|
+
children: [jsxs(GoAFormStepper, {
|
|
6072
|
+
testId: `form-stepper-headers-${(_c = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _c === void 0 ? void 0 : _c.testId}` || 'form-stepper-test',
|
|
6033
6073
|
onChange: step => {
|
|
6034
|
-
|
|
6074
|
+
goToPage(step - 1);
|
|
6035
6075
|
},
|
|
6036
|
-
children: [categories === null || categories === void 0 ? void 0 : categories.map((
|
|
6076
|
+
children: [categories === null || categories === void 0 ? void 0 : categories.map((c, index) => {
|
|
6037
6077
|
return jsx(GoAFormStep, {
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6078
|
+
"data-testid": `stepper-tab-${index}`,
|
|
6079
|
+
text: `${c.label}`,
|
|
6080
|
+
status: c.isValid ? 'complete' : 'incomplete'
|
|
6081
|
+
}, `stepper-tab-${index}`);
|
|
6041
6082
|
}), jsx(GoAFormStep, {
|
|
6042
6083
|
text: "Review"
|
|
6043
|
-
})]
|
|
6044
|
-
}), jsxs(GoAPages, {
|
|
6045
|
-
current:
|
|
6084
|
+
}, `stepper-tab-review`)]
|
|
6085
|
+
}, "stepper-form-stepper-wrapper"), jsxs(GoAPages, {
|
|
6086
|
+
current: activeId + 1,
|
|
6046
6087
|
mb: "xl",
|
|
6047
6088
|
children: [categories === null || categories === void 0 ? void 0 : categories.map((category, index) => {
|
|
6048
6089
|
const props = {
|
|
6049
|
-
category,
|
|
6050
|
-
categoryIndex:
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
enabled,
|
|
6054
|
-
visible,
|
|
6090
|
+
category: category.uischema,
|
|
6091
|
+
categoryIndex: category.id,
|
|
6092
|
+
visible: category === null || category === void 0 ? void 0 : category.visible,
|
|
6093
|
+
enabled: category === null || category === void 0 ? void 0 : category.isEnabled,
|
|
6055
6094
|
path,
|
|
6056
|
-
|
|
6095
|
+
schema,
|
|
6057
6096
|
renderers,
|
|
6058
6097
|
cells,
|
|
6059
6098
|
data
|
|
@@ -6063,61 +6102,56 @@ const FormStepper = props => {
|
|
|
6063
6102
|
style: {
|
|
6064
6103
|
marginTop: '1.5rem'
|
|
6065
6104
|
},
|
|
6066
|
-
children: jsx(
|
|
6067
|
-
|
|
6068
|
-
stepId: index + 1,
|
|
6069
|
-
updateStatus: updateInputStatus,
|
|
6070
|
-
isInitialized: isInputInitialized
|
|
6071
|
-
},
|
|
6072
|
-
children: RenderStepElements(props)
|
|
6073
|
-
})
|
|
6074
|
-
}, `${visibleCategoryLabels[index]}`);
|
|
6105
|
+
children: jsx(RenderStepElements, Object.assign({}, props))
|
|
6106
|
+
}, `${category.label}`);
|
|
6075
6107
|
}), jsxs("div", {
|
|
6076
6108
|
"data-testid": "summary_step-content",
|
|
6077
6109
|
children: [jsx(FormStepperSummaryH3, {
|
|
6078
6110
|
children: summaryLabel
|
|
6079
|
-
}), jsx(FormStepperReviewer, Object.assign({
|
|
6080
|
-
navigationFunc:
|
|
6081
|
-
}
|
|
6111
|
+
}), jsx(FormStepperReviewer, Object.assign({}, props, {
|
|
6112
|
+
navigationFunc: goToPage
|
|
6113
|
+
}))]
|
|
6082
6114
|
})]
|
|
6083
|
-
}),
|
|
6115
|
+
}), jsxs(GoAGrid, {
|
|
6084
6116
|
minChildWidth: "100px",
|
|
6085
6117
|
children: [jsx("div", {
|
|
6086
|
-
children:
|
|
6118
|
+
children: hasPrevButton ? jsx(GoAButton, {
|
|
6087
6119
|
type: (optionProps === null || optionProps === void 0 ? void 0 : optionProps.previousButtonType) ? optionProps === null || optionProps === void 0 ? void 0 : optionProps.previousButtonType : 'secondary',
|
|
6088
|
-
disabled:
|
|
6120
|
+
disabled: selectIsDisabled(),
|
|
6089
6121
|
onClick: () => {
|
|
6090
6122
|
const element = document.getElementById(`${path || `goa`}-form-stepper`);
|
|
6091
6123
|
if (element) {
|
|
6092
6124
|
element.scrollIntoView();
|
|
6093
6125
|
}
|
|
6094
|
-
|
|
6126
|
+
goToPage(activeId - 1, activeId);
|
|
6095
6127
|
},
|
|
6096
6128
|
testId: "prev-button",
|
|
6097
6129
|
children: (optionProps === null || optionProps === void 0 ? void 0 : optionProps.previousButtonLabel) ? optionProps === null || optionProps === void 0 ? void 0 : optionProps.previousButtonLabel : 'Previous'
|
|
6098
6130
|
}) : jsx("div", {})
|
|
6099
|
-
}),
|
|
6100
|
-
children:
|
|
6131
|
+
}), hasNextButton && jsx(RightAlignmentDiv, {
|
|
6132
|
+
children: jsx(GoAButton, {
|
|
6101
6133
|
type: (optionProps === null || optionProps === void 0 ? void 0 : optionProps.nextButtonType) ? optionProps === null || optionProps === void 0 ? void 0 : optionProps.nextButtonType : 'primary',
|
|
6102
|
-
disabled:
|
|
6134
|
+
disabled: selectIsDisabled(),
|
|
6103
6135
|
onClick: () => {
|
|
6136
|
+
goToPage(activeId + 1, activeId);
|
|
6104
6137
|
const element = document.getElementById(`${path || `goa`}-form-stepper`);
|
|
6105
6138
|
if (element) {
|
|
6106
6139
|
element.scrollIntoView();
|
|
6107
6140
|
}
|
|
6108
|
-
nextPage(step, disabledCategoryMap);
|
|
6109
6141
|
},
|
|
6110
6142
|
testId: "next-button",
|
|
6111
6143
|
children: (optionProps === null || optionProps === void 0 ? void 0 : optionProps.nextButtonLabel) ? optionProps === null || optionProps === void 0 ? void 0 : optionProps.nextButtonLabel : 'Next'
|
|
6112
|
-
})
|
|
6144
|
+
})
|
|
6145
|
+
}), isOnReview && jsx(RightAlignmentDiv, {
|
|
6146
|
+
children: jsx("div", {
|
|
6113
6147
|
children: jsx(GoAButton, {
|
|
6114
6148
|
type: 'primary',
|
|
6115
6149
|
onClick: handleSubmit,
|
|
6116
|
-
disabled: !
|
|
6150
|
+
disabled: !isValid,
|
|
6117
6151
|
testId: "stepper-submit-btn",
|
|
6118
6152
|
children: "Submit"
|
|
6119
6153
|
})
|
|
6120
|
-
})
|
|
6154
|
+
})
|
|
6121
6155
|
})]
|
|
6122
6156
|
}), jsxs(GoAModal, {
|
|
6123
6157
|
testId: "submit-confirmation",
|
|
@@ -6138,7 +6172,7 @@ const FormStepper = props => {
|
|
|
6138
6172
|
}), "(i.e. no actual form is being submitted)"]
|
|
6139
6173
|
})]
|
|
6140
6174
|
})
|
|
6141
|
-
})
|
|
6175
|
+
})]
|
|
6142
6176
|
});
|
|
6143
6177
|
};
|
|
6144
6178
|
const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
|
|
@@ -7040,7 +7074,7 @@ const NonEmptyCell$1 = ownProps => {
|
|
|
7040
7074
|
const emptyCellProps = ctxToNonEmptyCellProps$1(ctx, Object.assign(Object.assign({}, ownProps), {
|
|
7041
7075
|
data
|
|
7042
7076
|
}));
|
|
7043
|
-
const isValid = isEmpty
|
|
7077
|
+
const isValid = isEmpty(emptyCellProps.errors);
|
|
7044
7078
|
return jsx(NonEmptyCellComponent$1, Object.assign({}, emptyCellProps, {
|
|
7045
7079
|
handleChange: ownProps === null || ownProps === void 0 ? void 0 : ownProps.handleChange,
|
|
7046
7080
|
isInReview: ownProps === null || ownProps === void 0 ? void 0 : ownProps.isInReview,
|
|
@@ -7504,7 +7538,7 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
7504
7538
|
const NonEmptyCell = ownProps => {
|
|
7505
7539
|
const ctx = useJsonForms();
|
|
7506
7540
|
const emptyCellProps = ctxToNonEmptyCellProps(ctx, ownProps);
|
|
7507
|
-
const isValid = isEmpty
|
|
7541
|
+
const isValid = isEmpty(emptyCellProps.errors);
|
|
7508
7542
|
return jsx(NonEmptyCellComponent, Object.assign({}, emptyCellProps, {
|
|
7509
7543
|
isValid: isValid
|
|
7510
7544
|
}));
|
|
@@ -9163,7 +9197,7 @@ const GoAHorizontalReviewLayoutComponent = ({
|
|
|
9163
9197
|
visible,
|
|
9164
9198
|
width: ((_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.review) === null || _b === void 0 ? void 0 : _b.width) || '30ch'
|
|
9165
9199
|
};
|
|
9166
|
-
return jsx(
|
|
9200
|
+
return jsx(ReviewLayoutRenderer, Object.assign({}, childProps, {
|
|
9167
9201
|
renderers: renderers,
|
|
9168
9202
|
cells: cells
|
|
9169
9203
|
}));
|
|
@@ -10577,4 +10611,4 @@ const GoARenderers = [...GoABaseRenderers, {
|
|
|
10577
10611
|
}];
|
|
10578
10612
|
const GoACells = [...InputCells];
|
|
10579
10613
|
|
|
10580
|
-
export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormStepper, FormStepperControl, FormStepperReviewControl, FormStepperReviewer, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, createDefaultAjv, enumControl, errMalformedDate, formatSin, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };
|
|
10614
|
+
export { ADD_DATALIST_ACTION, ADD_NO_ANONYMOUS_ACTION, ADD_REGISTER_DATA_ACTION, ADD_REGISTER_DATA_ERROR, AddressLookUpControl, AddressLookUpControlReview, AddressLookUpTester, ArrayControl, ArrayControlBase, ArrayControlReview, BooleanComponent, BooleanControl, BooleanRadioComponent, BooleanRadioControl, CategorizationRendererTester, CheckboxGroup, ContextProviderC, ContextProviderClass, ContextProviderFactory, EnumCheckboxControl, EnumRadioControl, EnumSelect, FileUploader, FileUploaderReview, FileUploaderTester, FormStepper, FormStepperControl, FormStepperReviewControl, FormStepperReviewer, FormStepperView, FullNameControl, FullNameDobControl, FullNameDobReviewControl, FullNameDobTester, FullNameReviewControl, FullNameTester, GoAArrayControlRenderer, GoAArrayControlReviewRenderer, GoAArrayControlTester, GoABaseInputReviewComponent, GoABaseRenderers, GoABaseReviewRenderers, GoABooleanControl, GoABooleanControlTester, GoABooleanRadioControl, GoABooleanRadioControlTester, GoACells, GoACheckoutGroupControlTester, GoADateControl, GoADateControlTester, GoADateInput, GoADateTimeControl, GoADateTimeControlTester, GoADateTimeInput, GoAEnumCheckboxGroupControl, GoAEnumControl, GoAEnumControlTester, GoAEnumRadioGroupControl, GoAInputBaseControl, GoAInputDateControl, GoAInputDateTimeControl, GoAInputInteger, GoAInputIntegerControl, GoAInputNumberControl, GoAInputText, GoAInputTextControl, GoAInputTimeControl, GoAIntegerControl, GoAIntegerControlTester, GoAListWithDetailsControlRenderer, GoAListWithDetailsTester, GoANumberControl, GoANumberControlTester, GoANumberInput, GoARadioGroupControlTester, GoARenderers, GoAReviewRenderers, GoATextControl, GoATextControlTester, GoATimeControl, GoATimeControlTester, GoATimeInput, GoInputBaseReview, GoInputBaseReviewControl, JsonFormContext, JsonFormRegisterProvider, JsonFormsRegisterContext, ListWithDetailsControl, MultiLineText, MultiLineTextControl, MultiLineTextControlInput, MultiLineTextControlTester, RadioGroup, createDefaultAjv, enumControl, errMalformedDate, formatSin, isAddressLookup, isFullName, isFullNameDoB, registerReducer, resolveRefs, tryResolveRefs };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.48.1",
|
|
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",
|
|
@@ -6,6 +6,7 @@ export interface FormStepperOptionProps {
|
|
|
6
6
|
previousButtonLabel?: string;
|
|
7
7
|
previousButtonType?: GoAButtonType;
|
|
8
8
|
}
|
|
9
|
-
export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
|
|
9
|
+
export declare const FormStepper: (props: CategorizationStepperLayoutRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare const FormStepperView: (props: CategorizationStepperLayoutRendererProps) => JSX.Element;
|
|
10
11
|
export declare const FormStepperControl: (props: CategorizationStepperLayoutRendererProps & import("@jsonforms/core").OwnPropsOfLayout) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
export default FormStepper;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema } from '@jsonforms/core';
|
|
2
|
+
import { CategorizationElement } from './context/types';
|
|
3
3
|
export interface StepProps {
|
|
4
4
|
category: CategorizationElement;
|
|
5
5
|
categoryIndex: number;
|
|
6
|
-
step: number;
|
|
7
6
|
schema: JsonSchema;
|
|
8
|
-
enabled: boolean;
|
|
9
7
|
visible: boolean;
|
|
8
|
+
enabled: boolean;
|
|
10
9
|
path: string;
|
|
11
|
-
disabledCategoryMap: boolean[];
|
|
12
10
|
renderers: JsonFormsRendererRegistryEntry[] | undefined;
|
|
13
11
|
cells: JsonFormsCellRendererRegistryEntry[] | undefined;
|
|
14
12
|
data: Record<string, unknown>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ReactNode, Dispatch } from 'react';
|
|
2
|
+
import { CategorizationStepperLayoutRendererProps } from '../types';
|
|
3
|
+
import { StepperContextDataType, CategoryState } from './types';
|
|
4
|
+
import Ajv from 'ajv';
|
|
5
|
+
import { JsonFormStepperDispatch } from './reducer';
|
|
6
|
+
export interface JsonFormsStepperContextProviderProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
StepperProps: CategorizationStepperLayoutRendererProps & {
|
|
9
|
+
customDispatch?: Dispatch<any> & {
|
|
10
|
+
activeId?: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface JsonFormsStepperContextProps {
|
|
15
|
+
stepperDispatch: JsonFormStepperDispatch;
|
|
16
|
+
selectStepperState: () => StepperContextDataType;
|
|
17
|
+
selectIsDisabled: () => boolean;
|
|
18
|
+
selectIsActive: (id: number) => boolean;
|
|
19
|
+
selectPath: () => string;
|
|
20
|
+
selectCategory: (id: number) => CategoryState;
|
|
21
|
+
goToPage: (id: number, updateCategoryId?: number) => void;
|
|
22
|
+
isProvided?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const isErrorPathIncluded: (errorPaths: string[], path: string) => boolean;
|
|
25
|
+
export declare const getIncompletePaths: (ajv: Ajv, scopes: string[]) => string[];
|
|
26
|
+
export declare const JsonFormsStepperContext: import("react").Context<JsonFormsStepperContextProps | undefined>;
|
|
27
|
+
export declare const JsonFormsStepperContextProvider: ({ children, StepperProps, }: JsonFormsStepperContextProviderProps) => JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StepperContextDataType } from './types';
|
|
2
|
+
import { ErrorObject } from 'ajv';
|
|
3
|
+
import { Dispatch } from 'react';
|
|
4
|
+
export type JsonFormStepperDispatch = Dispatch<StepperAction>;
|
|
5
|
+
export type StepperAction = {
|
|
6
|
+
type: 'page/next';
|
|
7
|
+
} | {
|
|
8
|
+
type: 'page/prev';
|
|
9
|
+
} | {
|
|
10
|
+
type: 'page/to/index';
|
|
11
|
+
payload: {
|
|
12
|
+
id: number;
|
|
13
|
+
};
|
|
14
|
+
} | {
|
|
15
|
+
type: 'update/category';
|
|
16
|
+
payload: {
|
|
17
|
+
errors: ErrorObject[];
|
|
18
|
+
id: number;
|
|
19
|
+
};
|
|
20
|
+
} | {
|
|
21
|
+
type: 'validate/form';
|
|
22
|
+
payload: {
|
|
23
|
+
errors?: ErrorObject[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export declare const stepperReducer: (state: StepperContextDataType, action: StepperAction) => StepperContextDataType;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Categorization, Category } from '@jsonforms/core';
|
|
2
|
+
export interface CategoryInternalState {
|
|
3
|
+
isCompleted?: boolean;
|
|
4
|
+
isVisited?: boolean;
|
|
5
|
+
isValid?: boolean;
|
|
6
|
+
id: number;
|
|
7
|
+
uischema?: CategorizationElement;
|
|
8
|
+
isEnabled?: boolean;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
path?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CategoryConfig {
|
|
13
|
+
label: string;
|
|
14
|
+
scopes: string[];
|
|
15
|
+
}
|
|
16
|
+
export type CategoryState = CategoryInternalState & CategoryConfig;
|
|
17
|
+
export type CategoriesState = Array<CategoryState>;
|
|
18
|
+
export interface StepperContextDataType {
|
|
19
|
+
categories: CategoriesState;
|
|
20
|
+
activeId: number;
|
|
21
|
+
hasNextButton: boolean;
|
|
22
|
+
hasPrevButton: boolean;
|
|
23
|
+
path: string;
|
|
24
|
+
isOnReview: boolean;
|
|
25
|
+
isValid: boolean;
|
|
26
|
+
}
|
|
27
|
+
export type CategorizationElement = Category | Categorization;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Categorization, Category } from '@jsonforms/core';
|
|
1
2
|
import { StatePropsOfLayout } from '@jsonforms/core';
|
|
2
3
|
import { AjvProps } from '../../util/layout';
|
|
3
4
|
import { TranslateProps } from '@jsonforms/react';
|
|
@@ -10,3 +11,4 @@ export interface FormStepperComponentProps {
|
|
|
10
11
|
controlledNav?: number;
|
|
11
12
|
readOnly?: boolean;
|
|
12
13
|
}
|
|
14
|
+
export type CategorizationElement = Category | Categorization;
|
package/src/lib/util/layout.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
2
|
import type { UISchemaElement } from '@jsonforms/core';
|
|
3
3
|
import { JsonFormsCellRendererRegistryEntry, JsonFormsRendererRegistryEntry, JsonSchema, OwnPropsOfRenderer } from '@jsonforms/core';
|
|
4
4
|
import Ajv from 'ajv';
|
|
@@ -14,3 +14,5 @@ export interface AjvProps {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const withAjvProps: <P extends object>(Component: ComponentType<AjvProps & P>) => (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export declare const LayoutRenderer: ({ elements, schema, path, enabled, direction, renderers, cells, visible, width, }: LayoutRendererProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
export declare const ReviewLayoutRenderer: ({ elements, schema, path, enabled, direction, renderers, cells, visible, width, }: LayoutRendererProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export declare const ReviewGrid: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { GoAFormStepStatusType } from '@abgov/react-components-new';
|
|
3
|
-
export type StepInputStatus = {
|
|
4
|
-
id: string;
|
|
5
|
-
value: unknown;
|
|
6
|
-
required: boolean;
|
|
7
|
-
type: string | string[] | undefined;
|
|
8
|
-
step: number;
|
|
9
|
-
};
|
|
10
|
-
export interface StatusTable {
|
|
11
|
-
[key: string]: StepInputStatus;
|
|
12
|
-
}
|
|
13
|
-
export declare const StepperContext: import("react").Context<{
|
|
14
|
-
updateStatus: (status: StepInputStatus) => void;
|
|
15
|
-
isInitialized: (_: string) => boolean;
|
|
16
|
-
stepId: number;
|
|
17
|
-
}>;
|
|
18
|
-
export declare const getCompletionStatus: (table: StatusTable, step: number, isFormChanged?: boolean) => GoAFormStepStatusType | undefined;
|
|
19
|
-
export declare const logRequiredFields: (table: StatusTable, step: number) => void;
|