@abgov/jsonforms-components 2.3.8 → 2.4.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
|
@@ -6516,6 +6516,8 @@ const FormStepperReviewer = props => {
|
|
|
6516
6516
|
};
|
|
6517
6517
|
const FormStepperReviewControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperReviewer)));
|
|
6518
6518
|
|
|
6519
|
+
const TABLE_CONTEXT_ID = 100001;
|
|
6520
|
+
|
|
6519
6521
|
const isErrorPathIncluded = (errorPaths, path) => {
|
|
6520
6522
|
return errorPaths.some(ePath => {
|
|
6521
6523
|
/**
|
|
@@ -6608,7 +6610,10 @@ const stepperReducer = (state, action) => {
|
|
|
6608
6610
|
id
|
|
6609
6611
|
} = action.payload;
|
|
6610
6612
|
state.activeId = id;
|
|
6611
|
-
if (id
|
|
6613
|
+
if (id === TABLE_CONTEXT_ID) {
|
|
6614
|
+
return Object.assign({}, state);
|
|
6615
|
+
}
|
|
6616
|
+
if (id === lastId + 1) {
|
|
6612
6617
|
state.isOnReview = true;
|
|
6613
6618
|
state.hasNextButton = false;
|
|
6614
6619
|
state.hasPrevButton = true;
|
|
@@ -6629,7 +6634,7 @@ const stepperReducer = (state, action) => {
|
|
|
6629
6634
|
ajv,
|
|
6630
6635
|
errors
|
|
6631
6636
|
} = action.payload;
|
|
6632
|
-
if (id === state.categories.length) {
|
|
6637
|
+
if (id === state.categories.length || id === TABLE_CONTEXT_ID) {
|
|
6633
6638
|
return Object.assign({}, state);
|
|
6634
6639
|
}
|
|
6635
6640
|
/*
|
|
@@ -6664,7 +6669,7 @@ const stepperReducer = (state, action) => {
|
|
|
6664
6669
|
};
|
|
6665
6670
|
|
|
6666
6671
|
const createStepperContextInitData = props => {
|
|
6667
|
-
var _a;
|
|
6672
|
+
var _a, _b;
|
|
6668
6673
|
const {
|
|
6669
6674
|
uischema,
|
|
6670
6675
|
data,
|
|
@@ -6676,7 +6681,8 @@ const createStepperContextInitData = props => {
|
|
|
6676
6681
|
} = props;
|
|
6677
6682
|
const categorization = uischema;
|
|
6678
6683
|
const valid = ajv.validate(schema, data || {});
|
|
6679
|
-
const
|
|
6684
|
+
const isPage = ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.variant) === 'pages';
|
|
6685
|
+
const categories = (_b = categorization.elements) === null || _b === void 0 ? void 0 : _b.map((c, id) => {
|
|
6680
6686
|
const scopes = pickPropertyValues(c, 'scope', 'ListWithDetail');
|
|
6681
6687
|
const incompletePaths = getIncompletePaths(ajv, scopes);
|
|
6682
6688
|
return {
|
|
@@ -6692,7 +6698,7 @@ const createStepperContextInitData = props => {
|
|
|
6692
6698
|
visible
|
|
6693
6699
|
};
|
|
6694
6700
|
});
|
|
6695
|
-
const activeId = (props === null || props === void 0 ? void 0 : props.activeId) || 0;
|
|
6701
|
+
const activeId = (props === null || props === void 0 ? void 0 : props.activeId) || (isPage ? TABLE_CONTEXT_ID : 0);
|
|
6696
6702
|
return {
|
|
6697
6703
|
categories: categories,
|
|
6698
6704
|
activeId,
|
|
@@ -6738,6 +6744,14 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6738
6744
|
selectCategory: id => {
|
|
6739
6745
|
return stepperState.categories[id];
|
|
6740
6746
|
},
|
|
6747
|
+
goToTableOfContext: () => {
|
|
6748
|
+
stepperDispatch({
|
|
6749
|
+
type: 'page/to/index',
|
|
6750
|
+
payload: {
|
|
6751
|
+
id: TABLE_CONTEXT_ID
|
|
6752
|
+
}
|
|
6753
|
+
});
|
|
6754
|
+
},
|
|
6741
6755
|
validatePage: id => {
|
|
6742
6756
|
var _a;
|
|
6743
6757
|
stepperDispatch({
|
|
@@ -6749,7 +6763,7 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6749
6763
|
}
|
|
6750
6764
|
});
|
|
6751
6765
|
},
|
|
6752
|
-
goToPage:
|
|
6766
|
+
goToPage: id => {
|
|
6753
6767
|
var _a, _b, _c;
|
|
6754
6768
|
ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
|
|
6755
6769
|
if (stepperState.isOnReview !== true) {
|
|
@@ -6798,8 +6812,10 @@ const JsonFormsStepperContextProvider = ({
|
|
|
6798
6812
|
}))
|
|
6799
6813
|
}
|
|
6800
6814
|
});
|
|
6801
|
-
|
|
6802
|
-
|
|
6815
|
+
if (stepperState.activeId != TABLE_CONTEXT_ID) {
|
|
6816
|
+
context.goToPage(stepperState.maxReachedStep);
|
|
6817
|
+
context.goToPage(stepperState.activeId);
|
|
6818
|
+
}
|
|
6803
6819
|
}
|
|
6804
6820
|
}, [JSON.stringify(StepperProps.uischema), JSON.stringify(StepperProps.schema)]);
|
|
6805
6821
|
return jsx(JsonFormsStepperContext.Provider, {
|
|
@@ -6990,56 +7006,6 @@ const FormStepperView = props => {
|
|
|
6990
7006
|
};
|
|
6991
7007
|
const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
|
|
6992
7008
|
|
|
6993
|
-
let _$5 = t => t,
|
|
6994
|
-
_t$5;
|
|
6995
|
-
const BackButtonWrapper = styled.span(_t$5 || (_t$5 = _$5`
|
|
6996
|
-
.back-link::before {
|
|
6997
|
-
content: '';
|
|
6998
|
-
display: inline-block;
|
|
6999
|
-
width: 42px;
|
|
7000
|
-
height: 24px;
|
|
7001
|
-
vertical-align: middle;
|
|
7002
|
-
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%230070C4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
|
|
7003
|
-
center center no-repeat;
|
|
7004
|
-
}
|
|
7005
|
-
|
|
7006
|
-
.back-link:visited::before,
|
|
7007
|
-
.back-link:hover::before {
|
|
7008
|
-
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%23004f84" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
|
|
7009
|
-
center center no-repeat;
|
|
7010
|
-
}
|
|
7011
|
-
|
|
7012
|
-
.back-link {
|
|
7013
|
-
margin-top: var(--goa-space-m);
|
|
7014
|
-
}
|
|
7015
|
-
display: inline-block;
|
|
7016
|
-
color: #0070c4;
|
|
7017
|
-
cursor: pointer;
|
|
7018
|
-
|
|
7019
|
-
on .goa-icon {
|
|
7020
|
-
display: inline-block !important;
|
|
7021
|
-
position: relative;
|
|
7022
|
-
top: 3px;
|
|
7023
|
-
right: 2px;
|
|
7024
|
-
color: #0070c4;
|
|
7025
|
-
margin-left: 4px;
|
|
7026
|
-
}
|
|
7027
|
-
`));
|
|
7028
|
-
const BackButton = ({
|
|
7029
|
-
text,
|
|
7030
|
-
testId,
|
|
7031
|
-
link
|
|
7032
|
-
}) => {
|
|
7033
|
-
return jsx(BackButtonWrapper, {
|
|
7034
|
-
"data-testid": "back-button-click",
|
|
7035
|
-
onClick: link,
|
|
7036
|
-
children: jsx("div", {
|
|
7037
|
-
className: "back-link",
|
|
7038
|
-
children: text
|
|
7039
|
-
})
|
|
7040
|
-
});
|
|
7041
|
-
};
|
|
7042
|
-
|
|
7043
7009
|
var aCallable$6 = aCallable$g;
|
|
7044
7010
|
var toObject = toObject$8;
|
|
7045
7011
|
var IndexedObject = indexedObject;
|
|
@@ -7341,6 +7307,56 @@ const FormStepperPageReviewer = props => {
|
|
|
7341
7307
|
};
|
|
7342
7308
|
withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperPageReviewer)));
|
|
7343
7309
|
|
|
7310
|
+
let _$5 = t => t,
|
|
7311
|
+
_t$5;
|
|
7312
|
+
const BackButtonWrapper = styled.span(_t$5 || (_t$5 = _$5`
|
|
7313
|
+
.back-link::before {
|
|
7314
|
+
content: '';
|
|
7315
|
+
display: inline-block;
|
|
7316
|
+
width: 42px;
|
|
7317
|
+
height: 24px;
|
|
7318
|
+
vertical-align: middle;
|
|
7319
|
+
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%230070C4" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
|
|
7320
|
+
center center no-repeat;
|
|
7321
|
+
}
|
|
7322
|
+
|
|
7323
|
+
.back-link:visited::before,
|
|
7324
|
+
.back-link:hover::before {
|
|
7325
|
+
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 2 22 22" fill="none" stroke="%23004f84" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 18 9 12 15 6"></polyline></svg>')
|
|
7326
|
+
center center no-repeat;
|
|
7327
|
+
}
|
|
7328
|
+
|
|
7329
|
+
.back-link {
|
|
7330
|
+
margin-top: var(--goa-space-m);
|
|
7331
|
+
}
|
|
7332
|
+
display: inline-block;
|
|
7333
|
+
color: #0070c4;
|
|
7334
|
+
cursor: pointer;
|
|
7335
|
+
|
|
7336
|
+
on .goa-icon {
|
|
7337
|
+
display: inline-block !important;
|
|
7338
|
+
position: relative;
|
|
7339
|
+
top: 3px;
|
|
7340
|
+
right: 2px;
|
|
7341
|
+
color: #0070c4;
|
|
7342
|
+
margin-left: 4px;
|
|
7343
|
+
}
|
|
7344
|
+
`));
|
|
7345
|
+
const BackButton = ({
|
|
7346
|
+
text,
|
|
7347
|
+
testId,
|
|
7348
|
+
link
|
|
7349
|
+
}) => {
|
|
7350
|
+
return jsx(BackButtonWrapper, {
|
|
7351
|
+
"data-testid": "back-button-click",
|
|
7352
|
+
onClick: link,
|
|
7353
|
+
children: jsx("div", {
|
|
7354
|
+
className: "back-link",
|
|
7355
|
+
children: text
|
|
7356
|
+
})
|
|
7357
|
+
});
|
|
7358
|
+
};
|
|
7359
|
+
|
|
7344
7360
|
const RenderPages = props => {
|
|
7345
7361
|
const {
|
|
7346
7362
|
data,
|
|
@@ -7354,7 +7370,8 @@ const RenderPages = props => {
|
|
|
7354
7370
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
7355
7371
|
const {
|
|
7356
7372
|
goToPage,
|
|
7357
|
-
toggleShowReviewLink
|
|
7373
|
+
toggleShowReviewLink,
|
|
7374
|
+
goToTableOfContext
|
|
7358
7375
|
} = formStepperCtx;
|
|
7359
7376
|
const {
|
|
7360
7377
|
categories,
|
|
@@ -7400,7 +7417,11 @@ const RenderPages = props => {
|
|
|
7400
7417
|
style: {
|
|
7401
7418
|
marginTop: '1.5rem'
|
|
7402
7419
|
},
|
|
7403
|
-
children: [
|
|
7420
|
+
children: [jsx(BackButton, {
|
|
7421
|
+
testId: "back-button",
|
|
7422
|
+
link: () => goToTableOfContext(),
|
|
7423
|
+
text: "Back"
|
|
7424
|
+
}), jsxs(PageRenderPadding, {
|
|
7404
7425
|
children: [jsxs("h3", {
|
|
7405
7426
|
children: ["Step ", index + 1, " of ", categories.length]
|
|
7406
7427
|
}), jsx(RenderStepElements, Object.assign({}, categoryProps))]
|
|
@@ -7496,27 +7517,10 @@ const FormPagesView = props => {
|
|
|
7496
7517
|
useEffect(() => {
|
|
7497
7518
|
validatePage(activeId);
|
|
7498
7519
|
}, [data]);
|
|
7499
|
-
const [showTOC, setShowTOC] = useState(true);
|
|
7500
7520
|
const handleGoToPage = index => {
|
|
7501
|
-
setShowTOC(false);
|
|
7502
7521
|
goToPage(index);
|
|
7503
7522
|
};
|
|
7504
|
-
|
|
7505
|
-
const renderBackButton = (index, activeId) => {
|
|
7506
|
-
if (index > 0) {
|
|
7507
|
-
return jsx(BackButton, {
|
|
7508
|
-
testId: "back-button",
|
|
7509
|
-
link: () => goToPage(activeId - 1),
|
|
7510
|
-
text: "Back"
|
|
7511
|
-
});
|
|
7512
|
-
}
|
|
7513
|
-
return jsx(BackButton, {
|
|
7514
|
-
testId: "back-button",
|
|
7515
|
-
link: () => setShowTOC(true),
|
|
7516
|
-
text: "Back"
|
|
7517
|
-
});
|
|
7518
|
-
};
|
|
7519
|
-
if (showTOC) {
|
|
7523
|
+
if (TABLE_CONTEXT_ID === activeId) {
|
|
7520
7524
|
const tocProps = {
|
|
7521
7525
|
categories,
|
|
7522
7526
|
onClick: handleGoToPage,
|
|
@@ -7527,8 +7531,7 @@ const FormPagesView = props => {
|
|
|
7527
7531
|
return jsx(TableOfContents, Object.assign({}, tocProps));
|
|
7528
7532
|
} else {
|
|
7529
7533
|
return jsx(RenderPages, {
|
|
7530
|
-
categoryProps: props
|
|
7531
|
-
renderBackButton: renderBackButton
|
|
7534
|
+
categoryProps: props
|
|
7532
7535
|
});
|
|
7533
7536
|
}
|
|
7534
7537
|
};
|
|
@@ -9816,6 +9819,27 @@ const HelpContentTester = rankWith(1, uiTypeIs('HelpContent'));
|
|
|
9816
9819
|
const HelpContent = withJsonFormsControlProps(HelpContentComponent);
|
|
9817
9820
|
const HelpReviewContent = withJsonFormsControlProps(HelpContentReviewComponent);
|
|
9818
9821
|
|
|
9822
|
+
/**
|
|
9823
|
+
* A helper util to return a value at a certain delay. The delay is reset if the value arg changes
|
|
9824
|
+
* @param value value to be returned after a period of delay
|
|
9825
|
+
* @param delay time in ms to apply the delay
|
|
9826
|
+
* @returns value after the delay timer
|
|
9827
|
+
*/
|
|
9828
|
+
function useDebounce(value, delay) {
|
|
9829
|
+
const [debouncedValue, setDebouncedValue] = useState(value);
|
|
9830
|
+
useEffect(() => {
|
|
9831
|
+
// Update debounced value after delay
|
|
9832
|
+
const handler = setTimeout(() => {
|
|
9833
|
+
setDebouncedValue(value);
|
|
9834
|
+
}, delay);
|
|
9835
|
+
// Cancel the timeout if value changes (also on delay change or unmount)
|
|
9836
|
+
return () => {
|
|
9837
|
+
clearTimeout(handler);
|
|
9838
|
+
};
|
|
9839
|
+
}, [value, delay]);
|
|
9840
|
+
return debouncedValue;
|
|
9841
|
+
}
|
|
9842
|
+
|
|
9819
9843
|
const ADDRESS_PATH = 'api/gateway/v1/address/v1/find';
|
|
9820
9844
|
const AddressLookUpControl = props => {
|
|
9821
9845
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -9848,7 +9872,6 @@ const AddressLookUpControl = props => {
|
|
|
9848
9872
|
}
|
|
9849
9873
|
const [address, setAddress] = useState(data || defaultAddress);
|
|
9850
9874
|
const [searchTerm, setSearchTerm] = useState('');
|
|
9851
|
-
const [saveSearchTerm, setSaveSearchTerm] = useState(false);
|
|
9852
9875
|
const [suggestions, setSuggestions] = useState([]);
|
|
9853
9876
|
const [loading, setLoading] = useState(false);
|
|
9854
9877
|
const [errors, setErrors] = useState({});
|
|
@@ -9858,6 +9881,7 @@ const AddressLookUpControl = props => {
|
|
|
9858
9881
|
setAddress(updatedAddress);
|
|
9859
9882
|
handleChange(path, updatedAddress);
|
|
9860
9883
|
};
|
|
9884
|
+
const debouncedRenderAddress = useDebounce(searchTerm, 500);
|
|
9861
9885
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
9862
9886
|
const dropdownRef = useRef(null);
|
|
9863
9887
|
const handleInputChange = (field, value) => {
|
|
@@ -9893,11 +9917,8 @@ const AddressLookUpControl = props => {
|
|
|
9893
9917
|
}));
|
|
9894
9918
|
};
|
|
9895
9919
|
useEffect(() => {
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
setSaveSearchTerm(false);
|
|
9899
|
-
}
|
|
9900
|
-
}, [saveSearchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9920
|
+
handleInputChange('addressLine1', searchTerm);
|
|
9921
|
+
}, [debouncedRenderAddress]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9901
9922
|
useEffect(() => {
|
|
9902
9923
|
const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
9903
9924
|
if (searchTerm.length > 2 && dropdownSelected === false) {
|
|
@@ -9921,7 +9942,6 @@ const AddressLookUpControl = props => {
|
|
|
9921
9942
|
}, [searchTerm]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
9922
9943
|
const handleDropdownChange = value => {
|
|
9923
9944
|
setSearchTerm(value);
|
|
9924
|
-
setSaveSearchTerm(true);
|
|
9925
9945
|
};
|
|
9926
9946
|
const handleSuggestionClick = suggestion => {
|
|
9927
9947
|
const suggestAddress = mapSuggestionToAddress(suggestion);
|
|
@@ -10105,6 +10125,7 @@ const AddressViews = ({
|
|
|
10105
10125
|
children: [jsx(GoAFormItem, {
|
|
10106
10126
|
label: "Address line 1",
|
|
10107
10127
|
error: (data === null || data === void 0 ? void 0 : data.addressLine1) === undefined ? 'addressLine1 is required' : '',
|
|
10128
|
+
requirement: "required",
|
|
10108
10129
|
children: jsx(TextWrap, {
|
|
10109
10130
|
children: data === null || data === void 0 ? void 0 : data.addressLine1
|
|
10110
10131
|
})
|
|
@@ -10120,12 +10141,14 @@ const AddressViews = ({
|
|
|
10120
10141
|
children: [jsx(GoAFormItem, {
|
|
10121
10142
|
error: (data === null || data === void 0 ? void 0 : data.municipality) === undefined ? 'city is required' : '',
|
|
10122
10143
|
label: "City",
|
|
10144
|
+
requirement: "required",
|
|
10123
10145
|
children: jsx(TextWrap, {
|
|
10124
10146
|
children: data === null || data === void 0 ? void 0 : data.municipality
|
|
10125
10147
|
})
|
|
10126
10148
|
}), jsx(GoAFormItem, {
|
|
10127
10149
|
error: (data === null || data === void 0 ? void 0 : data.postalCode) === undefined ? 'postalCode is required' : '',
|
|
10128
10150
|
label: "Postal Code",
|
|
10151
|
+
requirement: "required",
|
|
10129
10152
|
children: jsx(TextWrap, {
|
|
10130
10153
|
children: data === null || data === void 0 ? void 0 : data.postalCode
|
|
10131
10154
|
})
|
|
@@ -10136,6 +10159,7 @@ const AddressViews = ({
|
|
|
10136
10159
|
children: [jsxs(GoAFormItem, {
|
|
10137
10160
|
label: "Province",
|
|
10138
10161
|
error: !isAlbertaAddress && (data === null || data === void 0 ? void 0 : data.subdivisionCode) === undefined ? 'Province is required' : '',
|
|
10162
|
+
requirement: "required",
|
|
10139
10163
|
children: [isAlbertaAddress && jsx("div", {
|
|
10140
10164
|
"data-testid": "address-form-province-view",
|
|
10141
10165
|
children: "Alberta"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { CategorizationStepperLayoutRendererProps } from './types';
|
|
3
2
|
export interface PageRenderingProps {
|
|
4
3
|
categoryProps: CategorizationStepperLayoutRendererProps;
|
|
5
|
-
renderBackButton: (index: number, activeId: number) => JSX.Element;
|
|
6
4
|
}
|
|
7
5
|
export declare const RenderPages: (props: PageRenderingProps) => JSX.Element;
|
|
@@ -20,6 +20,7 @@ export interface JsonFormsStepperContextProps {
|
|
|
20
20
|
selectPath: () => string;
|
|
21
21
|
selectCategory: (id: number) => CategoryState;
|
|
22
22
|
goToPage: (id: number, updateCategoryId?: number) => void;
|
|
23
|
+
goToTableOfContext: () => void;
|
|
23
24
|
toggleShowReviewLink: (id: number) => void;
|
|
24
25
|
validatePage: (id: number) => void;
|
|
25
26
|
isProvided?: boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type DebounceValueType = string | boolean | number | Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* A helper util to return a value at a certain delay. The delay is reset if the value arg changes
|
|
4
|
+
* @param value value to be returned after a period of delay
|
|
5
|
+
* @param delay time in ms to apply the delay
|
|
6
|
+
* @returns value after the delay timer
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDebounce(value: DebounceValueType, delay: number): DebounceValueType;
|
|
9
|
+
export {};
|