@abgov/jsonforms-components 2.1.6 → 2.2.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, 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, GoATable, GoABadge, 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';
|
|
@@ -5435,7 +5435,9 @@ let _$6 = t => t,
|
|
|
5435
5435
|
_t14$1,
|
|
5436
5436
|
_t15$1,
|
|
5437
5437
|
_t16$1,
|
|
5438
|
-
_t17$1
|
|
5438
|
+
_t17$1,
|
|
5439
|
+
_t18$1,
|
|
5440
|
+
_t19$1;
|
|
5439
5441
|
const ReviewItem = styled.div(_t$6 || (_t$6 = _$6`
|
|
5440
5442
|
display: flex;
|
|
5441
5443
|
flex-direction: column;
|
|
@@ -5536,6 +5538,13 @@ const TableReviewPageTitleRow = styled.div(_t16$1 || (_t16$1 = _$6`
|
|
|
5536
5538
|
const TableReviewCategoryLabel = styled.h3(_t17$1 || (_t17$1 = _$6`
|
|
5537
5539
|
color: var(--goa-color-text-secondary) !important;
|
|
5538
5540
|
`));
|
|
5541
|
+
const TocStatus = styled.td(_t18$1 || (_t18$1 = _$6`
|
|
5542
|
+
width: var(--goa-space-xl);
|
|
5543
|
+
padding-right: var(--goa-space-xl);
|
|
5544
|
+
`));
|
|
5545
|
+
const TocPageRef = styled.td(_t19$1 || (_t19$1 = _$6`
|
|
5546
|
+
padding-left: var(--goa-space-xl);
|
|
5547
|
+
`));
|
|
5539
5548
|
|
|
5540
5549
|
class ContextProviderClass {
|
|
5541
5550
|
addDataByUrl(key, url, processDataFunction, token) {
|
|
@@ -6485,6 +6494,55 @@ const BackButton = ({
|
|
|
6485
6494
|
});
|
|
6486
6495
|
};
|
|
6487
6496
|
|
|
6497
|
+
var PageStatus;
|
|
6498
|
+
(function (PageStatus) {
|
|
6499
|
+
PageStatus["Complete"] = "Completed";
|
|
6500
|
+
PageStatus["Incomplete"] = "Incomplete";
|
|
6501
|
+
PageStatus["NotStarted"] = "Not started";
|
|
6502
|
+
})(PageStatus || (PageStatus = {}));
|
|
6503
|
+
const getPageStatus = category => {
|
|
6504
|
+
const status = category.isVisited ? category.isCompleted && category.isValid ? PageStatus.Complete : PageStatus.Incomplete : PageStatus.NotStarted;
|
|
6505
|
+
const badgeType = status === PageStatus.Complete ? 'success' : 'information';
|
|
6506
|
+
return jsx(GoABadge, {
|
|
6507
|
+
type: badgeType,
|
|
6508
|
+
content: status,
|
|
6509
|
+
ariaLabel: status
|
|
6510
|
+
});
|
|
6511
|
+
};
|
|
6512
|
+
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
6513
|
+
const TableOfContents = props => {
|
|
6514
|
+
var _a;
|
|
6515
|
+
const testid = 'table-of-contents';
|
|
6516
|
+
return jsx(PageBorder, {
|
|
6517
|
+
children: jsx("div", {
|
|
6518
|
+
"data-testid": testid,
|
|
6519
|
+
children: jsx(GoATable, {
|
|
6520
|
+
width: "100%",
|
|
6521
|
+
children: jsx("tbody", {
|
|
6522
|
+
children: (_a = props.categories) === null || _a === void 0 ? void 0 : _a.map((category, index) => {
|
|
6523
|
+
return jsxs("tr", {
|
|
6524
|
+
children: [jsx(TocPageRef, {
|
|
6525
|
+
children: jsx("a", {
|
|
6526
|
+
"data-testid": `page-ref-${index}`,
|
|
6527
|
+
href: "#",
|
|
6528
|
+
onClick: e => {
|
|
6529
|
+
e.preventDefault();
|
|
6530
|
+
props.onClick(index);
|
|
6531
|
+
},
|
|
6532
|
+
children: category.label
|
|
6533
|
+
})
|
|
6534
|
+
}), jsx(TocStatus, {
|
|
6535
|
+
children: getPageStatus(category)
|
|
6536
|
+
})]
|
|
6537
|
+
});
|
|
6538
|
+
})
|
|
6539
|
+
})
|
|
6540
|
+
})
|
|
6541
|
+
})
|
|
6542
|
+
});
|
|
6543
|
+
};
|
|
6544
|
+
rankWith(1, uiTypeIs('TaskSection'));
|
|
6545
|
+
|
|
6488
6546
|
const FormStepperPageReviewer = props => {
|
|
6489
6547
|
const {
|
|
6490
6548
|
uischema,
|
|
@@ -6579,35 +6637,18 @@ const FormStepperPageReviewer = props => {
|
|
|
6579
6637
|
};
|
|
6580
6638
|
withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormStepperPageReviewer)));
|
|
6581
6639
|
|
|
6582
|
-
|
|
6583
|
-
const FormPageStepper = props => {
|
|
6584
|
-
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6585
|
-
/**
|
|
6586
|
-
* StepperCtx can only be provided once to prevent issues from categorization in categorization
|
|
6587
|
-
* */
|
|
6588
|
-
if ((formStepperCtx === null || formStepperCtx === void 0 ? void 0 : formStepperCtx.isProvided) === true) {
|
|
6589
|
-
return jsx(FormPagesView, Object.assign({}, props));
|
|
6590
|
-
}
|
|
6591
|
-
return jsx(JsonFormsStepperContextProvider, {
|
|
6592
|
-
StepperProps: Object.assign({}, props),
|
|
6593
|
-
children: jsx(FormPagesView, Object.assign({}, props))
|
|
6594
|
-
});
|
|
6595
|
-
};
|
|
6596
|
-
const FormPagesView = props => {
|
|
6640
|
+
const RenderPages = props => {
|
|
6597
6641
|
const {
|
|
6598
|
-
uischema,
|
|
6599
6642
|
data,
|
|
6600
6643
|
schema,
|
|
6601
6644
|
path,
|
|
6602
6645
|
cells,
|
|
6603
6646
|
renderers,
|
|
6604
|
-
visible
|
|
6605
|
-
|
|
6606
|
-
} = props;
|
|
6647
|
+
visible
|
|
6648
|
+
} = props.categoryProps;
|
|
6607
6649
|
const enumerators = useContext(JsonFormContext);
|
|
6608
6650
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6609
6651
|
const {
|
|
6610
|
-
validatePage,
|
|
6611
6652
|
goToPage,
|
|
6612
6653
|
toggleShowReviewLink
|
|
6613
6654
|
} = formStepperCtx;
|
|
@@ -6630,9 +6671,6 @@ const FormPagesView = props => {
|
|
|
6630
6671
|
const onCloseModal = () => {
|
|
6631
6672
|
setIsOpen(false);
|
|
6632
6673
|
};
|
|
6633
|
-
useEffect(() => {
|
|
6634
|
-
validatePage(activeId);
|
|
6635
|
-
}, [data]);
|
|
6636
6674
|
return jsxs("div", {
|
|
6637
6675
|
"data-testid": "form-stepper-test-wrapper",
|
|
6638
6676
|
children: [jsx(Visible, {
|
|
@@ -6658,11 +6696,7 @@ const FormPagesView = props => {
|
|
|
6658
6696
|
style: {
|
|
6659
6697
|
marginTop: '1.5rem'
|
|
6660
6698
|
},
|
|
6661
|
-
children: [index
|
|
6662
|
-
testId: "back-button",
|
|
6663
|
-
link: () => goToPage(activeId - 1),
|
|
6664
|
-
text: "Back"
|
|
6665
|
-
}), jsxs(PageRenderPadding, {
|
|
6699
|
+
children: [props.renderBackButton(index, activeId), jsxs(PageRenderPadding, {
|
|
6666
6700
|
children: [jsxs("h3", {
|
|
6667
6701
|
children: ["Step ", index + 1, " of ", categories.length]
|
|
6668
6702
|
}), jsx(RenderStepElements, Object.assign({}, categoryProps))]
|
|
@@ -6690,7 +6724,7 @@ const FormPagesView = props => {
|
|
|
6690
6724
|
}
|
|
6691
6725
|
}), isOnReview && jsxs("div", {
|
|
6692
6726
|
"data-testid": "stepper-pages-review-page",
|
|
6693
|
-
children: [jsx(FormStepperPageReviewer, Object.assign({}, props, {
|
|
6727
|
+
children: [jsx(FormStepperPageReviewer, Object.assign({}, props.categoryProps, {
|
|
6694
6728
|
navigationFunc: goToPage
|
|
6695
6729
|
})), jsx(PageRenderPadding, {
|
|
6696
6730
|
children: jsx(GoAButtonGroup, {
|
|
@@ -6727,6 +6761,68 @@ const FormPagesView = props => {
|
|
|
6727
6761
|
})]
|
|
6728
6762
|
});
|
|
6729
6763
|
};
|
|
6764
|
+
|
|
6765
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6766
|
+
const FormPageStepper = props => {
|
|
6767
|
+
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6768
|
+
/**
|
|
6769
|
+
* StepperCtx can only be provided once to prevent issues from categorization in categorization
|
|
6770
|
+
* */
|
|
6771
|
+
if ((formStepperCtx === null || formStepperCtx === void 0 ? void 0 : formStepperCtx.isProvided) === true) {
|
|
6772
|
+
return jsx(FormPagesView, Object.assign({}, props));
|
|
6773
|
+
}
|
|
6774
|
+
return jsx(JsonFormsStepperContextProvider, {
|
|
6775
|
+
StepperProps: Object.assign({}, props),
|
|
6776
|
+
children: jsx(FormPagesView, Object.assign({}, props))
|
|
6777
|
+
});
|
|
6778
|
+
};
|
|
6779
|
+
const FormPagesView = props => {
|
|
6780
|
+
const data = props.data;
|
|
6781
|
+
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
6782
|
+
const {
|
|
6783
|
+
validatePage,
|
|
6784
|
+
goToPage
|
|
6785
|
+
} = formStepperCtx;
|
|
6786
|
+
const {
|
|
6787
|
+
categories,
|
|
6788
|
+
activeId
|
|
6789
|
+
} = formStepperCtx.selectStepperState();
|
|
6790
|
+
useEffect(() => {
|
|
6791
|
+
validatePage(activeId);
|
|
6792
|
+
}, [data]);
|
|
6793
|
+
const [showTOC, setShowTOC] = useState(true);
|
|
6794
|
+
const handleGoToPage = index => {
|
|
6795
|
+
setShowTOC(false);
|
|
6796
|
+
goToPage(index);
|
|
6797
|
+
};
|
|
6798
|
+
// Make sure the back button on the first page takes us to the Table of Contents.
|
|
6799
|
+
const renderBackButton = (index, activeId) => {
|
|
6800
|
+
if (index > 0) {
|
|
6801
|
+
return jsx(BackButton, {
|
|
6802
|
+
testId: "back-button",
|
|
6803
|
+
link: () => goToPage(activeId - 1),
|
|
6804
|
+
text: "Back"
|
|
6805
|
+
});
|
|
6806
|
+
}
|
|
6807
|
+
return jsx(BackButton, {
|
|
6808
|
+
testId: "back-button",
|
|
6809
|
+
link: () => setShowTOC(true),
|
|
6810
|
+
text: "Back"
|
|
6811
|
+
});
|
|
6812
|
+
};
|
|
6813
|
+
if (showTOC) {
|
|
6814
|
+
const tocProps = {
|
|
6815
|
+
categories,
|
|
6816
|
+
onClick: handleGoToPage
|
|
6817
|
+
};
|
|
6818
|
+
return jsx(TableOfContents, Object.assign({}, tocProps));
|
|
6819
|
+
} else {
|
|
6820
|
+
return jsx(RenderPages, {
|
|
6821
|
+
categoryProps: props,
|
|
6822
|
+
renderBackButton: renderBackButton
|
|
6823
|
+
});
|
|
6824
|
+
}
|
|
6825
|
+
};
|
|
6730
6826
|
const FormStepperPagesControl = withAjvProps(withTranslateProps(withJsonFormsLayoutProps(FormPageStepper)));
|
|
6731
6827
|
|
|
6732
6828
|
// Ensure that all children (Category) have valid elements or things tend
|
|
@@ -8186,7 +8282,7 @@ const GenerateRows = (Cell, schema, rowPath, enabled, cells, uischema) => {
|
|
|
8186
8282
|
cellPath: rowPath,
|
|
8187
8283
|
enabled
|
|
8188
8284
|
};
|
|
8189
|
-
return jsx(Cell, Object.assign({}, props), rowPath);
|
|
8285
|
+
return jsx(Cell, Object.assign({}, props), `${rowPath}`);
|
|
8190
8286
|
}
|
|
8191
8287
|
};
|
|
8192
8288
|
const getValidColumnProps = scopedSchema => {
|
|
@@ -8274,19 +8370,19 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
8274
8370
|
return jsxs(Fragment, {
|
|
8275
8371
|
children: [
|
|
8276
8372
|
// eslint-disable-next-line
|
|
8277
|
-
(_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.map(element => {
|
|
8373
|
+
(_a = uischema === null || uischema === void 0 ? void 0 : uischema.elements) === null || _a === void 0 ? void 0 : _a.map((element, index) => {
|
|
8278
8374
|
return jsx(JsonFormsDispatch, {
|
|
8279
8375
|
"data-testid": `jsonforms-object-list-defined-elements-dispatch`,
|
|
8280
8376
|
schema: schema,
|
|
8281
8377
|
uischema: element,
|
|
8282
|
-
path: rowPath
|
|
8378
|
+
path: `${rowPath}-${index}`,
|
|
8283
8379
|
enabled: enabled,
|
|
8284
8380
|
renderers: renderers,
|
|
8285
8381
|
cells: cells
|
|
8286
8382
|
}, rowPath);
|
|
8287
8383
|
}),
|
|
8288
8384
|
// eslint-disable-next-line
|
|
8289
|
-
(_d = (_c = (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.elements) === null || _d === void 0 ? void 0 : _d.map(element => {
|
|
8385
|
+
(_d = (_c = (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.detail) === null || _c === void 0 ? void 0 : _c.elements) === null || _d === void 0 ? void 0 : _d.map((element, index) => {
|
|
8290
8386
|
return jsx(JsonFormsDispatch, {
|
|
8291
8387
|
"data-testid": `jsonforms-object-list-defined-elements-dispatch`,
|
|
8292
8388
|
schema: schema,
|
|
@@ -8295,7 +8391,7 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
8295
8391
|
enabled: enabled,
|
|
8296
8392
|
renderers: renderers,
|
|
8297
8393
|
cells: cells
|
|
8298
|
-
}, rowPath);
|
|
8394
|
+
}, `${rowPath}-${index}`);
|
|
8299
8395
|
}), ((_e = uiSchemaElementsForNotDefined === null || uiSchemaElementsForNotDefined === void 0 ? void 0 : uiSchemaElementsForNotDefined.elements) === null || _e === void 0 ? void 0 : _e.length) > 0 && jsx(JsonFormsDispatch, {
|
|
8300
8396
|
schema: schema,
|
|
8301
8397
|
uischema: uiSchemaElementsForNotDefined,
|
|
@@ -8303,7 +8399,7 @@ const NonEmptyCellComponent = /*#__PURE__*/React.memo(function NonEmptyCellCompo
|
|
|
8303
8399
|
enabled: enabled,
|
|
8304
8400
|
renderers: renderers,
|
|
8305
8401
|
cells: cells
|
|
8306
|
-
})]
|
|
8402
|
+
}, `${rowPath}`)]
|
|
8307
8403
|
});
|
|
8308
8404
|
});
|
|
8309
8405
|
const NonEmptyCell = ownProps => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.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",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CategorizationStepperLayoutRendererProps } from './types';
|
|
3
|
+
export interface PageRenderingProps {
|
|
4
|
+
categoryProps: CategorizationStepperLayoutRendererProps;
|
|
5
|
+
renderBackButton: (index: number, activeId: number) => JSX.Element;
|
|
6
|
+
}
|
|
7
|
+
export declare const RenderPages: (props: PageRenderingProps) => JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RankedTester } from '@jsonforms/core';
|
|
2
|
+
import { CategoriesState } from './context';
|
|
3
|
+
export interface TocProps {
|
|
4
|
+
categories: CategoriesState;
|
|
5
|
+
onClick: (id: number) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const TableOfContents: (props: TocProps) => JSX.Element;
|
|
8
|
+
export declare const TableOfContentsTester: RankedTester;
|
|
@@ -16,3 +16,5 @@ export declare const TableReviewItemSection: import("styled-components/dist/type
|
|
|
16
16
|
export declare const TableReviewItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
17
17
|
export declare const TableReviewPageTitleRow: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
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
|
+
export declare const TocStatus: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, never>> & string;
|
|
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;
|