@abgov/jsonforms-components 2.6.12 → 2.7.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 +163 -83
- package/package.json +1 -1
- package/src/lib/Controls/FormStepper/ApplicationStatus.d.ts +1 -5
- package/src/lib/Controls/FormStepper/{TableOfContents.d.ts → TaskList/TaskList.d.ts} +4 -4
- package/src/lib/Controls/FormStepper/TaskList/categoryRow.d.ts +9 -0
- package/src/lib/Controls/FormStepper/TaskList/categorySections.d.ts +7 -0
- package/src/lib/Controls/FormStepper/TaskList/sectionHeaderRow.d.ts +7 -0
- package/src/lib/Controls/FormStepper/TaskList/summaryRow.d.ts +8 -0
- package/src/lib/Controls/FormStepper/context/StepperContext.d.ts +1 -0
- package/src/lib/Controls/FormStepper/styled-components.d.ts +0 -2
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as runtime from 'react/jsx-runtime';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
|
|
4
|
-
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoABadge, GoATable, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
|
|
4
|
+
import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAText, GoABadge, GoATable, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
|
|
5
5
|
import styled from 'styled-components';
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import get$1 from 'lodash/get';
|
|
@@ -6878,9 +6878,7 @@ let _$5 = t => t,
|
|
|
6878
6878
|
_t18$1,
|
|
6879
6879
|
_t19$1,
|
|
6880
6880
|
_t20$1,
|
|
6881
|
-
_t21
|
|
6882
|
-
_t22,
|
|
6883
|
-
_t23;
|
|
6881
|
+
_t21;
|
|
6884
6882
|
const ReviewItem = styled.div(_t$6 || (_t$6 = _$5`
|
|
6885
6883
|
display: flex;
|
|
6886
6884
|
flex-direction: column;
|
|
@@ -6990,18 +6988,7 @@ const CategoryStatus = styled.td(_t19$1 || (_t19$1 = _$5`
|
|
|
6990
6988
|
const TocPageRef = styled.td(_t20$1 || (_t20$1 = _$5`
|
|
6991
6989
|
padding-left: var(--goa-space-xl);
|
|
6992
6990
|
`));
|
|
6993
|
-
const
|
|
6994
|
-
padding: 0;
|
|
6995
|
-
margin: 0;
|
|
6996
|
-
padding-left: var(--goa-space-xl);
|
|
6997
|
-
padding-bottom: var(--goa-space-3xl);
|
|
6998
|
-
`));
|
|
6999
|
-
const TocSubtitle = styled.h2(_t22 || (_t22 = _$5`
|
|
7000
|
-
padding: 0;
|
|
7001
|
-
margin: 0;
|
|
7002
|
-
padding-left: var(--goa-space-xl);
|
|
7003
|
-
`));
|
|
7004
|
-
const CompletionStatus = styled.div(_t23 || (_t23 = _$5`
|
|
6991
|
+
const CompletionStatus = styled.div(_t21 || (_t21 = _$5`
|
|
7005
6992
|
padding: 0;
|
|
7006
6993
|
margin: 0;
|
|
7007
6994
|
padding-left: var(--goa-space-xl);
|
|
@@ -7695,6 +7682,9 @@ const JsonFormsStepperContextProvider = ({
|
|
|
7695
7682
|
const category = (_a = stepperState.categories) === null || _a === void 0 ? void 0 : _a[stepperState.activeId];
|
|
7696
7683
|
return category === undefined ? false : !(category === null || category === void 0 ? void 0 : category.isEnabled);
|
|
7697
7684
|
},
|
|
7685
|
+
selectNumberOfCompletedCategories: () => {
|
|
7686
|
+
return stepperState === null || stepperState === void 0 ? void 0 : stepperState.categories.reduce((acc, cat) => acc + (cat.isValid && cat.isCompleted && cat.isVisited ? 1 : 0), 0);
|
|
7687
|
+
},
|
|
7698
7688
|
selectIsActive: id => {
|
|
7699
7689
|
return id === stepperState.activeId;
|
|
7700
7690
|
},
|
|
@@ -7966,6 +7956,65 @@ const FormStepperView = props => {
|
|
|
7966
7956
|
};
|
|
7967
7957
|
const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
|
|
7968
7958
|
|
|
7959
|
+
const ApplicationStatus = () => {
|
|
7960
|
+
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
7961
|
+
const {
|
|
7962
|
+
selectNumberOfCompletedCategories
|
|
7963
|
+
} = formStepperCtx;
|
|
7964
|
+
const {
|
|
7965
|
+
categories
|
|
7966
|
+
} = formStepperCtx.selectStepperState();
|
|
7967
|
+
const total = categories.length;
|
|
7968
|
+
const completed = selectNumberOfCompletedCategories();
|
|
7969
|
+
const type = total === completed ? 'success' : 'important';
|
|
7970
|
+
const heading = total === completed ? 'Application complete' : 'Application incomplete';
|
|
7971
|
+
const message = `You have completed ${completed} of ${total} sections.`;
|
|
7972
|
+
return jsx(CompletionStatus, {
|
|
7973
|
+
children: jsx(GoACallout, {
|
|
7974
|
+
type: type,
|
|
7975
|
+
heading: heading,
|
|
7976
|
+
size: "medium",
|
|
7977
|
+
maxWidth: '50%',
|
|
7978
|
+
children: message
|
|
7979
|
+
})
|
|
7980
|
+
});
|
|
7981
|
+
};
|
|
7982
|
+
|
|
7983
|
+
const getCategorySections = categories => {
|
|
7984
|
+
const sectionMap = new Map();
|
|
7985
|
+
categories.forEach(category => {
|
|
7986
|
+
var _a, _b;
|
|
7987
|
+
const section = ((_b = (_a = category.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.sectionTitle) || '';
|
|
7988
|
+
if (!sectionMap.has(section)) {
|
|
7989
|
+
sectionMap.set(section, []);
|
|
7990
|
+
}
|
|
7991
|
+
sectionMap.get(section).push(category);
|
|
7992
|
+
});
|
|
7993
|
+
return Array.from(sectionMap.entries()).map(([sectionTitle, categories]) => ({
|
|
7994
|
+
sectionTitle,
|
|
7995
|
+
categories
|
|
7996
|
+
}));
|
|
7997
|
+
};
|
|
7998
|
+
|
|
7999
|
+
const SectionHeaderRow = ({
|
|
8000
|
+
title,
|
|
8001
|
+
index
|
|
8002
|
+
}) => {
|
|
8003
|
+
const section = `${index}. ${title}`;
|
|
8004
|
+
return jsx("tr", {
|
|
8005
|
+
children: jsx("td", {
|
|
8006
|
+
colSpan: 2,
|
|
8007
|
+
children: jsx(GoAText, {
|
|
8008
|
+
size: "heading-m",
|
|
8009
|
+
mt: "none",
|
|
8010
|
+
mb: "m",
|
|
8011
|
+
ml: "m",
|
|
8012
|
+
children: section
|
|
8013
|
+
})
|
|
8014
|
+
})
|
|
8015
|
+
});
|
|
8016
|
+
};
|
|
8017
|
+
|
|
7969
8018
|
var PageStatus;
|
|
7970
8019
|
(function (PageStatus) {
|
|
7971
8020
|
PageStatus["Complete"] = "Completed";
|
|
@@ -7985,78 +8034,103 @@ const getCategoryStatusBadge = category => {
|
|
|
7985
8034
|
});
|
|
7986
8035
|
};
|
|
7987
8036
|
|
|
7988
|
-
|
|
7989
|
-
|
|
8037
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
8038
|
+
const CategoryRow = ({
|
|
8039
|
+
category,
|
|
8040
|
+
index,
|
|
8041
|
+
onClick
|
|
7990
8042
|
}) => {
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
|
|
8043
|
+
return jsxs("tr", {
|
|
8044
|
+
children: [jsx(TocPageRef, {
|
|
8045
|
+
children: jsx("a", {
|
|
8046
|
+
"data-testid": `page-ref-${index}`,
|
|
8047
|
+
href: "#",
|
|
8048
|
+
onClick: e => {
|
|
8049
|
+
e.preventDefault();
|
|
8050
|
+
onClick(index);
|
|
8051
|
+
},
|
|
8052
|
+
children: jsx(GoAText, {
|
|
8053
|
+
ml: "l",
|
|
8054
|
+
children: category.label
|
|
8055
|
+
})
|
|
8056
|
+
})
|
|
8057
|
+
}), jsx(CategoryStatus, {
|
|
8058
|
+
children: getCategoryStatusBadge(category)
|
|
8059
|
+
})]
|
|
8004
8060
|
});
|
|
8005
8061
|
};
|
|
8006
8062
|
|
|
8007
8063
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
8008
|
-
const
|
|
8009
|
-
|
|
8064
|
+
const SummaryRow = ({
|
|
8065
|
+
index,
|
|
8066
|
+
isValid,
|
|
8067
|
+
onClick
|
|
8068
|
+
}) => {
|
|
8069
|
+
return jsxs("tr", {
|
|
8070
|
+
children: [jsx(TocPageRef, {
|
|
8071
|
+
children: jsx("a", {
|
|
8072
|
+
"data-testid": `page-ref-${index}`,
|
|
8073
|
+
href: "#",
|
|
8074
|
+
onClick: e => {
|
|
8075
|
+
e.preventDefault();
|
|
8076
|
+
onClick(index);
|
|
8077
|
+
},
|
|
8078
|
+
children: jsx("b", {
|
|
8079
|
+
children: "Summary"
|
|
8080
|
+
})
|
|
8081
|
+
})
|
|
8082
|
+
}), jsx(CategoryStatus, {})]
|
|
8083
|
+
});
|
|
8084
|
+
};
|
|
8085
|
+
|
|
8086
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
8087
|
+
const TaskList = ({
|
|
8088
|
+
categories,
|
|
8089
|
+
onClick,
|
|
8090
|
+
title,
|
|
8091
|
+
subtitle,
|
|
8092
|
+
isValid
|
|
8093
|
+
}) => {
|
|
8010
8094
|
const testid = 'table-of-contents';
|
|
8095
|
+
const sectioned = getCategorySections(categories);
|
|
8096
|
+
let globalIndex = 0;
|
|
8097
|
+
let sectionIndex = 1;
|
|
8011
8098
|
return jsx(PageBorder, {
|
|
8012
8099
|
children: jsxs("div", {
|
|
8013
8100
|
"data-testid": testid,
|
|
8014
|
-
children: [
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
8101
|
+
children: [title && jsx(GoAText, {
|
|
8102
|
+
size: "heading-xl",
|
|
8103
|
+
ml: "xl",
|
|
8104
|
+
mb: "xl",
|
|
8105
|
+
children: title
|
|
8106
|
+
}), jsx(ApplicationStatus, {}), subtitle && jsx(GoAText, {
|
|
8107
|
+
size: "heading-l",
|
|
8108
|
+
mt: "none",
|
|
8109
|
+
mb: "xl",
|
|
8110
|
+
ml: "xl",
|
|
8111
|
+
children: subtitle
|
|
8020
8112
|
}), jsx(GoATable, {
|
|
8021
8113
|
width: "100%",
|
|
8022
8114
|
children: jsxs("tbody", {
|
|
8023
|
-
children: [
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
})]
|
|
8038
|
-
});
|
|
8039
|
-
}), jsxs("tr", {
|
|
8040
|
-
children: [jsx(TocPageRef, {
|
|
8041
|
-
children: jsx("a", {
|
|
8042
|
-
"data-testid": `page-ref-${(_b = props.categories) === null || _b === void 0 ? void 0 : _b.length}`,
|
|
8043
|
-
href: "#",
|
|
8044
|
-
onClick: e => {
|
|
8045
|
-
var _a;
|
|
8046
|
-
e.preventDefault();
|
|
8047
|
-
props.onClick((_a = props.categories) === null || _a === void 0 ? void 0 : _a.length);
|
|
8048
|
-
},
|
|
8049
|
-
children: jsx("b", {
|
|
8050
|
-
children: "Summary"
|
|
8051
|
-
})
|
|
8052
|
-
})
|
|
8053
|
-
}), jsxs(CategoryStatus, {
|
|
8054
|
-
children: [jsx(GoABadge, {
|
|
8055
|
-
type: props.isValid ? 'success' : 'information',
|
|
8056
|
-
content: props.isValid ? 'Completed' : 'Incomplete',
|
|
8057
|
-
ariaLabel: props.isValid ? 'Completed' : 'Incomplete'
|
|
8058
|
-
}), props.isValid]
|
|
8115
|
+
children: [sectioned.map(({
|
|
8116
|
+
sectionTitle,
|
|
8117
|
+
categories: group
|
|
8118
|
+
}) => jsxs(Fragment, {
|
|
8119
|
+
children: [sectionTitle && jsx(SectionHeaderRow, {
|
|
8120
|
+
title: sectionTitle,
|
|
8121
|
+
index: sectionIndex++
|
|
8122
|
+
}, `section-${sectionTitle}`), group.map(category => {
|
|
8123
|
+
const index = globalIndex++;
|
|
8124
|
+
return jsx(CategoryRow, {
|
|
8125
|
+
category: category,
|
|
8126
|
+
index: index,
|
|
8127
|
+
onClick: onClick
|
|
8128
|
+
}, `cat-${category.label}`);
|
|
8059
8129
|
})]
|
|
8130
|
+
})), jsx(SummaryRow, {
|
|
8131
|
+
index: globalIndex,
|
|
8132
|
+
isValid: isValid,
|
|
8133
|
+
onClick: onClick
|
|
8060
8134
|
})]
|
|
8061
8135
|
})
|
|
8062
8136
|
})]
|
|
@@ -8218,7 +8292,8 @@ const RenderPages = props => {
|
|
|
8218
8292
|
const {
|
|
8219
8293
|
goToPage,
|
|
8220
8294
|
toggleShowReviewLink,
|
|
8221
|
-
goToTableOfContext
|
|
8295
|
+
goToTableOfContext,
|
|
8296
|
+
validatePage
|
|
8222
8297
|
} = formStepperCtx;
|
|
8223
8298
|
const {
|
|
8224
8299
|
categories,
|
|
@@ -8266,7 +8341,10 @@ const RenderPages = props => {
|
|
|
8266
8341
|
},
|
|
8267
8342
|
children: [jsx(BackButton, {
|
|
8268
8343
|
testId: "back-button",
|
|
8269
|
-
link: () =>
|
|
8344
|
+
link: () => {
|
|
8345
|
+
validatePage(index);
|
|
8346
|
+
goToTableOfContext();
|
|
8347
|
+
},
|
|
8270
8348
|
text: "Back"
|
|
8271
8349
|
}), jsxs(PageRenderPadding, {
|
|
8272
8350
|
children: [jsxs("h3", {
|
|
@@ -8299,7 +8377,9 @@ const RenderPages = props => {
|
|
|
8299
8377
|
children: [jsx(PageRenderPaddingBottom, {
|
|
8300
8378
|
children: jsx(BackButton, {
|
|
8301
8379
|
testId: "review-back-button",
|
|
8302
|
-
link: () =>
|
|
8380
|
+
link: () => {
|
|
8381
|
+
goToTableOfContext();
|
|
8382
|
+
},
|
|
8303
8383
|
text: "Back"
|
|
8304
8384
|
})
|
|
8305
8385
|
}), jsx(FormStepperPageReviewer, Object.assign({}, props.categoryProps, {
|
|
@@ -8360,12 +8440,12 @@ const FormPagesView = props => {
|
|
|
8360
8440
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
8361
8441
|
const {
|
|
8362
8442
|
validatePage,
|
|
8363
|
-
goToPage
|
|
8443
|
+
goToPage,
|
|
8444
|
+
selectNumberOfCompletedCategories
|
|
8364
8445
|
} = formStepperCtx;
|
|
8365
8446
|
const {
|
|
8366
8447
|
categories,
|
|
8367
|
-
activeId
|
|
8368
|
-
isValid
|
|
8448
|
+
activeId
|
|
8369
8449
|
} = formStepperCtx.selectStepperState();
|
|
8370
8450
|
useEffect(() => {
|
|
8371
8451
|
validatePage(activeId);
|
|
@@ -8379,9 +8459,9 @@ const FormPagesView = props => {
|
|
|
8379
8459
|
onClick: handleGoToPage,
|
|
8380
8460
|
title: (_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.title,
|
|
8381
8461
|
subtitle: (_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.subtitle,
|
|
8382
|
-
isValid:
|
|
8462
|
+
isValid: selectNumberOfCompletedCategories() === categories.length
|
|
8383
8463
|
};
|
|
8384
|
-
return jsx(
|
|
8464
|
+
return jsx(TaskList, Object.assign({}, tocProps));
|
|
8385
8465
|
} else {
|
|
8386
8466
|
return jsx(RenderPages, {
|
|
8387
8467
|
categoryProps: props
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.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,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export interface ApplicationStatusProps {
|
|
3
|
-
categories: CategoriesState;
|
|
4
|
-
}
|
|
5
|
-
export declare const ApplicationStatus: ({ categories }: ApplicationStatusProps) => JSX.Element;
|
|
1
|
+
export declare const ApplicationStatus: () => JSX.Element;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RankedTester } from '@jsonforms/core';
|
|
2
|
-
import { CategoriesState } from '
|
|
2
|
+
import { CategoriesState } from '../context';
|
|
3
3
|
export interface TocProps {
|
|
4
4
|
categories: CategoriesState;
|
|
5
5
|
onClick: (id: number) => void;
|
|
6
|
-
title
|
|
7
|
-
subtitle
|
|
6
|
+
title?: string;
|
|
7
|
+
subtitle?: string;
|
|
8
8
|
isValid: boolean;
|
|
9
9
|
}
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const TaskList: ({ categories, onClick, title, subtitle, isValid }: TocProps) => JSX.Element;
|
|
11
11
|
export declare const TableOfContentsTester: RankedTester;
|
|
@@ -23,6 +23,7 @@ export interface JsonFormsStepperContextProps {
|
|
|
23
23
|
goToTableOfContext: () => void;
|
|
24
24
|
toggleShowReviewLink: (id: number) => void;
|
|
25
25
|
validatePage: (id: number) => void;
|
|
26
|
+
selectNumberOfCompletedCategories: () => number;
|
|
26
27
|
isProvided?: boolean;
|
|
27
28
|
}
|
|
28
29
|
export declare const JsonFormsStepperContext: import("react").Context<JsonFormsStepperContextProps | undefined>;
|
|
@@ -18,6 +18,4 @@ export declare const TableReviewPageTitleRow: import("styled-components/dist/typ
|
|
|
18
18
|
export declare const TableReviewCategoryLabel: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
19
19
|
export declare const CategoryStatus: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
|
|
20
20
|
export declare const TocPageRef: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
|
|
21
|
-
export declare const TocTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
22
|
-
export declare const TocSubtitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
|
|
23
21
|
export declare const CompletionStatus: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|