@abgov/jsonforms-components 2.3.9 → 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
|
};
|
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;
|