@abgov/jsonforms-components 2.6.12 → 2.6.13

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
@@ -7695,6 +7695,9 @@ const JsonFormsStepperContextProvider = ({
7695
7695
  const category = (_a = stepperState.categories) === null || _a === void 0 ? void 0 : _a[stepperState.activeId];
7696
7696
  return category === undefined ? false : !(category === null || category === void 0 ? void 0 : category.isEnabled);
7697
7697
  },
7698
+ selectNumberOfCompletedCategories: () => {
7699
+ return stepperState === null || stepperState === void 0 ? void 0 : stepperState.categories.reduce((acc, cat) => acc + (cat.isValid && cat.isCompleted && cat.isVisited ? 1 : 0), 0);
7700
+ },
7698
7701
  selectIsActive: id => {
7699
7702
  return id === stepperState.activeId;
7700
7703
  },
@@ -7966,6 +7969,30 @@ const FormStepperView = props => {
7966
7969
  };
7967
7970
  const FormStepperControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepper)));
7968
7971
 
7972
+ const ApplicationStatus = () => {
7973
+ const formStepperCtx = useContext(JsonFormsStepperContext);
7974
+ const {
7975
+ selectNumberOfCompletedCategories
7976
+ } = formStepperCtx;
7977
+ const {
7978
+ categories
7979
+ } = formStepperCtx.selectStepperState();
7980
+ const total = categories.length;
7981
+ const completed = selectNumberOfCompletedCategories();
7982
+ const type = total === completed ? 'success' : 'important';
7983
+ const heading = total === completed ? 'Application complete' : 'Application incomplete';
7984
+ const message = `You have completed ${completed} of ${total} sections.`;
7985
+ return jsx(CompletionStatus, {
7986
+ children: jsx(GoACallout, {
7987
+ type: type,
7988
+ heading: heading,
7989
+ size: "medium",
7990
+ maxWidth: '50%',
7991
+ children: message
7992
+ })
7993
+ });
7994
+ };
7995
+
7969
7996
  var PageStatus;
7970
7997
  (function (PageStatus) {
7971
7998
  PageStatus["Complete"] = "Completed";
@@ -7985,25 +8012,6 @@ const getCategoryStatusBadge = category => {
7985
8012
  });
7986
8013
  };
7987
8014
 
7988
- const ApplicationStatus = ({
7989
- categories
7990
- }) => {
7991
- const total = categories.length;
7992
- const completed = categories.reduce((acc, cat) => acc + (getCategoryStatus(cat) === PageStatus.Complete ? 1 : 0), 0);
7993
- const type = total === completed ? 'success' : 'important';
7994
- const heading = total === completed ? 'Application complete' : 'Application incomplete';
7995
- const message = `You have completed ${completed} of ${total} sections.`;
7996
- return jsx(CompletionStatus, {
7997
- children: jsx(GoACallout, {
7998
- type: type,
7999
- heading: heading,
8000
- size: "medium",
8001
- maxWidth: '50%',
8002
- children: message
8003
- })
8004
- });
8005
- };
8006
-
8007
8015
  /* eslint-disable jsx-a11y/anchor-is-valid */
8008
8016
  const TableOfContents = props => {
8009
8017
  var _a, _b;
@@ -8013,9 +8021,7 @@ const TableOfContents = props => {
8013
8021
  "data-testid": testid,
8014
8022
  children: [props.title && jsx(TocTitle, {
8015
8023
  children: props.title
8016
- }), jsx(ApplicationStatus, {
8017
- categories: props.categories
8018
- }), props.subtitle && jsx(TocSubtitle, {
8024
+ }), jsx(ApplicationStatus, {}), props.subtitle && jsx(TocSubtitle, {
8019
8025
  children: props.subtitle
8020
8026
  }), jsx(GoATable, {
8021
8027
  width: "100%",
@@ -8218,7 +8224,8 @@ const RenderPages = props => {
8218
8224
  const {
8219
8225
  goToPage,
8220
8226
  toggleShowReviewLink,
8221
- goToTableOfContext
8227
+ goToTableOfContext,
8228
+ validatePage
8222
8229
  } = formStepperCtx;
8223
8230
  const {
8224
8231
  categories,
@@ -8266,7 +8273,10 @@ const RenderPages = props => {
8266
8273
  },
8267
8274
  children: [jsx(BackButton, {
8268
8275
  testId: "back-button",
8269
- link: () => goToTableOfContext(),
8276
+ link: () => {
8277
+ validatePage(index);
8278
+ goToTableOfContext();
8279
+ },
8270
8280
  text: "Back"
8271
8281
  }), jsxs(PageRenderPadding, {
8272
8282
  children: [jsxs("h3", {
@@ -8299,7 +8309,9 @@ const RenderPages = props => {
8299
8309
  children: [jsx(PageRenderPaddingBottom, {
8300
8310
  children: jsx(BackButton, {
8301
8311
  testId: "review-back-button",
8302
- link: () => goToTableOfContext(),
8312
+ link: () => {
8313
+ goToTableOfContext();
8314
+ },
8303
8315
  text: "Back"
8304
8316
  })
8305
8317
  }), jsx(FormStepperPageReviewer, Object.assign({}, props.categoryProps, {
@@ -8360,12 +8372,12 @@ const FormPagesView = props => {
8360
8372
  const formStepperCtx = useContext(JsonFormsStepperContext);
8361
8373
  const {
8362
8374
  validatePage,
8363
- goToPage
8375
+ goToPage,
8376
+ selectNumberOfCompletedCategories
8364
8377
  } = formStepperCtx;
8365
8378
  const {
8366
8379
  categories,
8367
- activeId,
8368
- isValid
8380
+ activeId
8369
8381
  } = formStepperCtx.selectStepperState();
8370
8382
  useEffect(() => {
8371
8383
  validatePage(activeId);
@@ -8379,7 +8391,7 @@ const FormPagesView = props => {
8379
8391
  onClick: handleGoToPage,
8380
8392
  title: (_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.title,
8381
8393
  subtitle: (_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.subtitle,
8382
- isValid: isValid
8394
+ isValid: selectNumberOfCompletedCategories() === categories.length
8383
8395
  };
8384
8396
  return jsx(TableOfContents, Object.assign({}, tocProps));
8385
8397
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.6.12",
3
+ "version": "2.6.13",
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
- import { CategoriesState } from './context';
2
- export interface ApplicationStatusProps {
3
- categories: CategoriesState;
4
- }
5
- export declare const ApplicationStatus: ({ categories }: ApplicationStatusProps) => JSX.Element;
1
+ export declare const ApplicationStatus: () => JSX.Element;
@@ -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>;