@abgov/jsonforms-components 2.6.13 → 2.8.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
@@ -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 TocTitle = styled.h1(_t21 || (_t21 = _$5`
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);
@@ -7993,14 +7980,49 @@ const ApplicationStatus = () => {
7993
7980
  });
7994
7981
  };
7995
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
+
7996
8018
  var PageStatus;
7997
8019
  (function (PageStatus) {
7998
8020
  PageStatus["Complete"] = "Completed";
7999
- PageStatus["Incomplete"] = "Incomplete";
8021
+ PageStatus["Inprogress"] = "In progress";
8000
8022
  PageStatus["NotStarted"] = "Not started";
8001
8023
  })(PageStatus || (PageStatus = {}));
8002
8024
  const getCategoryStatus = category => {
8003
- return category.isVisited ? category.isCompleted && category.isValid ? PageStatus.Complete : PageStatus.Incomplete : PageStatus.NotStarted;
8025
+ return category.isVisited ? category.isCompleted && category.isValid ? PageStatus.Complete : PageStatus.Inprogress : PageStatus.NotStarted;
8004
8026
  };
8005
8027
  const getCategoryStatusBadge = category => {
8006
8028
  const status = getCategoryStatus(category);
@@ -8013,56 +8035,102 @@ const getCategoryStatusBadge = category => {
8013
8035
  };
8014
8036
 
8015
8037
  /* eslint-disable jsx-a11y/anchor-is-valid */
8016
- const TableOfContents = props => {
8017
- var _a, _b;
8038
+ const CategoryRow = ({
8039
+ category,
8040
+ index,
8041
+ onClick
8042
+ }) => {
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
+ })]
8060
+ });
8061
+ };
8062
+
8063
+ /* eslint-disable jsx-a11y/anchor-is-valid */
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
+ }) => {
8018
8094
  const testid = 'table-of-contents';
8095
+ const sectioned = getCategorySections(categories);
8096
+ let globalIndex = 0;
8097
+ let sectionIndex = 1;
8019
8098
  return jsx(PageBorder, {
8020
8099
  children: jsxs("div", {
8021
8100
  "data-testid": testid,
8022
- children: [props.title && jsx(TocTitle, {
8023
- children: props.title
8024
- }), jsx(ApplicationStatus, {}), props.subtitle && jsx(TocSubtitle, {
8025
- children: props.subtitle
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
8026
8112
  }), jsx(GoATable, {
8027
8113
  width: "100%",
8028
8114
  children: jsxs("tbody", {
8029
- children: [(_a = props.categories) === null || _a === void 0 ? void 0 : _a.map((category, index) => {
8030
- return jsxs("tr", {
8031
- children: [jsx(TocPageRef, {
8032
- children: jsx("a", {
8033
- "data-testid": `page-ref-${index}`,
8034
- href: "#",
8035
- onClick: e => {
8036
- e.preventDefault();
8037
- props.onClick(index);
8038
- },
8039
- children: category.label
8040
- })
8041
- }), jsx(CategoryStatus, {
8042
- children: getCategoryStatusBadge(category)
8043
- })]
8044
- });
8045
- }), jsxs("tr", {
8046
- children: [jsx(TocPageRef, {
8047
- children: jsx("a", {
8048
- "data-testid": `page-ref-${(_b = props.categories) === null || _b === void 0 ? void 0 : _b.length}`,
8049
- href: "#",
8050
- onClick: e => {
8051
- var _a;
8052
- e.preventDefault();
8053
- props.onClick((_a = props.categories) === null || _a === void 0 ? void 0 : _a.length);
8054
- },
8055
- children: jsx("b", {
8056
- children: "Summary"
8057
- })
8058
- })
8059
- }), jsxs(CategoryStatus, {
8060
- children: [jsx(GoABadge, {
8061
- type: props.isValid ? 'success' : 'information',
8062
- content: props.isValid ? 'Completed' : 'Incomplete',
8063
- ariaLabel: props.isValid ? 'Completed' : 'Incomplete'
8064
- }), 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}`);
8065
8129
  })]
8130
+ })), jsx(SummaryRow, {
8131
+ index: globalIndex,
8132
+ isValid: isValid,
8133
+ onClick: onClick
8066
8134
  })]
8067
8135
  })
8068
8136
  })]
@@ -8393,7 +8461,7 @@ const FormPagesView = props => {
8393
8461
  subtitle: (_d = (_c = props.uischema) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.subtitle,
8394
8462
  isValid: selectNumberOfCompletedCategories() === categories.length
8395
8463
  };
8396
- return jsx(TableOfContents, Object.assign({}, tocProps));
8464
+ return jsx(TaskList, Object.assign({}, tocProps));
8397
8465
  } else {
8398
8466
  return jsx(RenderPages, {
8399
8467
  categoryProps: props
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "2.6.13",
3
+ "version": "2.8.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,7 @@
1
1
  import { CategoryState } from './context';
2
2
  export declare enum PageStatus {
3
3
  Complete = "Completed",
4
- Incomplete = "Incomplete",
4
+ Inprogress = "In progress",
5
5
  NotStarted = "Not started"
6
6
  }
7
7
  export declare const getCategoryStatus: (category: CategoryState) => string;
@@ -1,11 +1,11 @@
1
1
  import { RankedTester } from '@jsonforms/core';
2
- import { CategoriesState } from './context';
2
+ import { CategoriesState } from '../context';
3
3
  export interface TocProps {
4
4
  categories: CategoriesState;
5
5
  onClick: (id: number) => void;
6
- title: string | undefined;
7
- subtitle: string | undefined;
6
+ title?: string;
7
+ subtitle?: string;
8
8
  isValid: boolean;
9
9
  }
10
- export declare const TableOfContents: (props: TocProps) => JSX.Element;
10
+ export declare const TaskList: ({ categories, onClick, title, subtitle, isValid }: TocProps) => JSX.Element;
11
11
  export declare const TableOfContentsTester: RankedTester;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { CategoryState } from '../context';
3
+ interface CategoryRowProps {
4
+ category: CategoryState;
5
+ index: number;
6
+ onClick: (id: number) => void;
7
+ }
8
+ export declare const CategoryRow: React.FC<CategoryRowProps>;
9
+ export {};
@@ -0,0 +1,7 @@
1
+ import { CategoriesState, CategoryState } from '../context';
2
+ interface SectionMap {
3
+ sectionTitle: string;
4
+ categories: CategoryState[];
5
+ }
6
+ export declare const getCategorySections: (categories: CategoriesState) => SectionMap[];
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface SectionHeaderRowProps {
3
+ title: string;
4
+ index: number;
5
+ }
6
+ export declare const SectionHeaderRow: React.FC<SectionHeaderRowProps>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface SummaryRowProps {
3
+ index: number;
4
+ isValid: boolean;
5
+ onClick: (id: number) => void;
6
+ }
7
+ export declare const SummaryRow: React.FC<SummaryRowProps>;
8
+ export {};
@@ -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;