@abgov/jsonforms-components 2.84.0 → 2.84.2
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/README.md +66 -44
- package/index.esm.js +6 -2
- package/package.json +1 -1
- package/renderer-catalog.json +2 -2
package/README.md
CHANGED
|
@@ -1,72 +1,94 @@
|
|
|
1
1
|
# jsonforms-components
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React renderers for [JSON Forms](https://jsonforms.io) built on the Government of Alberta [design system](https://design.alberta.ca/) components. The ADSP form app and the form editor preview use them, and they are published to npm as `@abgov/jsonforms-components` so product teams can render ADSP form definitions in their own applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Inside this monorepo, import it through the `@abgov/jsonforms-components` path alias in `tsconfig.base.json`.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# Folder hierarchy
|
|
7
|
+
## Install
|
|
10
8
|
|
|
9
|
+
```bash
|
|
10
|
+
npm install @abgov/jsonforms-components
|
|
11
11
|
```
|
|
12
|
-
- src
|
|
13
|
-
- lib
|
|
14
|
-
- Additional
|
|
15
|
-
- Cells
|
|
16
|
-
- common
|
|
17
|
-
- Components
|
|
18
|
-
- Controls
|
|
19
|
-
- Context
|
|
20
|
-
- ErrorHandling
|
|
21
|
-
- layouts
|
|
22
|
-
- util
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
These packages are peer dependencies, so install them in your application too (see `package.json` for the exact ranges):
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
- `react`, `@jsonforms/core`, `@jsonforms/react`
|
|
16
|
+
- `@abgov/react-components`, `@abgov/ui-components-common`
|
|
17
|
+
- `ajv`, `ajv-errors`, `ajv-formats`
|
|
18
|
+
- `@mdx-js/mdx`, `react-markdown`, `rehype-sanitize`, `dompurify`, `xss`
|
|
19
|
+
- `expr-eval-fork`, `pluralize`
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
`@apidevtools/json-schema-ref-parser` is an optional dependency, used by `resolveRefs` and `tryResolveRefs`.
|
|
29
22
|
|
|
30
|
-
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Pass `GoARenderers` and `GoACells` to the `JsonForms` component. Wrap it in the two context providers the renderers read from:
|
|
26
|
+
|
|
27
|
+
- the provider returned by `ContextProviderFactory()`, which supplies file management, submit and save callbacks, auto-populated data and stepper navigation to the renderers;
|
|
28
|
+
- `JsonFormRegisterProvider`, which supplies data register values to dropdown and text controls that use the `register` option.
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
31
|
import { JsonForms } from '@jsonforms/react';
|
|
32
32
|
import {
|
|
33
|
+
ContextProviderFactory,
|
|
34
|
+
createDefaultAjv,
|
|
35
|
+
GoACells,
|
|
33
36
|
GoARenderers,
|
|
37
|
+
JsonFormRegisterProvider,
|
|
34
38
|
} from '@abgov/jsonforms-components';
|
|
35
|
-
```
|
|
36
39
|
|
|
37
|
-
|
|
40
|
+
// Create both once, at module level. JsonForms recompiles the schema when the ajv instance changes.
|
|
41
|
+
const ContextProvider = ContextProviderFactory();
|
|
42
|
+
const ajv = createDefaultAjv();
|
|
43
|
+
|
|
44
|
+
export const MyForm = ({ schema, uischema, data, onChange }) => (
|
|
45
|
+
<ContextProvider>
|
|
46
|
+
<JsonFormRegisterProvider defaultRegisters={undefined}>
|
|
38
47
|
<JsonForms
|
|
39
|
-
schema={
|
|
40
|
-
uischema={
|
|
48
|
+
schema={schema}
|
|
49
|
+
uischema={uischema}
|
|
41
50
|
data={data}
|
|
42
|
-
validationMode="ValidateAndShow"
|
|
43
51
|
renderers={GoARenderers}
|
|
52
|
+
cells={GoACells}
|
|
53
|
+
ajv={ajv}
|
|
54
|
+
validationMode="ValidateAndShow"
|
|
44
55
|
onChange={onChange}
|
|
45
56
|
/>
|
|
57
|
+
</JsonFormRegisterProvider>
|
|
58
|
+
</ContextProvider>
|
|
59
|
+
);
|
|
46
60
|
```
|
|
47
61
|
|
|
48
|
-
|
|
62
|
+
To show a read-only summary of submitted data, pass `GoAReviewRenderers` instead of `GoARenderers`.
|
|
49
63
|
|
|
50
|
-
|
|
51
|
-
https://govalta.github.io/adsp-monorepo/tutorials/form-service/building-forms.html
|
|
64
|
+
The UI schema selects and configures these renderers through its `options`. The [Form service tutorials](https://govalta.github.io/adsp-monorepo/tutorials/form-service/form-service.html) cover the schema side; the [Cheat sheet](https://govalta.github.io/adsp-monorepo/tutorials/form-service/cheat-sheet.html) has examples for each control, layout and stepper.
|
|
52
65
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
## Reference
|
|
67
|
+
|
|
68
|
+
Main exports from `src/index.ts`:
|
|
69
|
+
|
|
70
|
+
- **Renderer sets**: `GoARenderers` (full form, including stepper, file uploader, address lookup, name, phone, calculation and contact controls), `GoAReviewRenderers` (read-only review), `GoABaseRenderers`, `GoABaseReviewRenderers` and `GoABaseTableReviewRenderers` (subsets to build your own set), and `GoACells`.
|
|
71
|
+
- **Context**: `ContextProviderFactory`, `JsonFormContext`, `useShowChangeButtons`, `ReviewRenderProvider`, `useReviewContext`.
|
|
72
|
+
- **Data registers**: `JsonFormRegisterProvider`, `JsonFormsRegisterContext`, `useRegisterUser`, and the register types.
|
|
73
|
+
- **Validation and schemas**: `createDefaultAjv` (an Ajv instance with the formats the renderers use, such as `phone`, `sin` and `file-urn`), `resolveRefs`, `tryResolveRefs`.
|
|
74
|
+
- **Auto-populate**: `getAutoPopulatedData`, `mergeAutoPopulatedData`, `createAutoPopulateMiddleware`.
|
|
75
|
+
- **Controls**: the individual controls and their testers, for example `GoAInputTextControl` and `GoATextControlTester`, plus the stepper navigation helpers such as `getNavigationTargets` and `useStepChange`.
|
|
76
|
+
- **Performance**: `memoizeTester` and `memoizeRendererTesters`, which cache tester ranks so large forms don't re-run every tester on each render.
|
|
77
|
+
|
|
78
|
+
## Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx nx test jsonforms-components
|
|
82
|
+
npx nx lint jsonforms-components
|
|
83
|
+
npx nx build jsonforms-components
|
|
66
84
|
```
|
|
67
85
|
|
|
68
|
-
The
|
|
86
|
+
The package is published to npm with semantic-release through the `release` target (`.releaserc.json`). Commits with the scope `jsonforms-components` trigger a release, for example `feat(jsonforms-components): add a new control`. See [AGENTS.md](../../AGENTS.md#commit-conventions) for the commit conventions.
|
|
69
87
|
|
|
70
|
-
|
|
88
|
+
## Related guides
|
|
71
89
|
|
|
72
|
-
|
|
90
|
+
- [Integration](../../docs/tutorials/form-service/Integration.md): adding the renderers to your application.
|
|
91
|
+
- [Data registers](../../docs/tutorials/form-service/data-registers.md): `JsonFormRegisterProvider` and the `register` option.
|
|
92
|
+
- [File uploader](../../docs/tutorials/form-service/file-uploader.md): the `fileManagement` callbacks on the context provider.
|
|
93
|
+
- [External navigation](../../docs/tutorials/form-service/external-navigation.md): driving the stepper and review "Change" links from the host.
|
|
94
|
+
- [Building forms](../../docs/tutorials/form-service/building-forms.md) and the [Cheat sheet](../../docs/tutorials/form-service/cheat-sheet.md): UI schema options for each renderer.
|
package/index.esm.js
CHANGED
|
@@ -12789,6 +12789,7 @@ const FlexTabsWithMargin = styled.div(_t15$1 || (_t15$1 = _$8`
|
|
|
12789
12789
|
flex: 1;
|
|
12790
12790
|
overflow-y: auto !important;
|
|
12791
12791
|
margin-right: 1.5rem;
|
|
12792
|
+
min-width: 10rem;
|
|
12792
12793
|
|
|
12793
12794
|
flex-shrink: 1;
|
|
12794
12795
|
// max-height: 500px;
|
|
@@ -12797,6 +12798,7 @@ const FlexTabsWithMargin = styled.div(_t15$1 || (_t15$1 = _$8`
|
|
|
12797
12798
|
@media (max-width: 639px) {
|
|
12798
12799
|
flex: none;
|
|
12799
12800
|
height: auto !important;
|
|
12801
|
+
min-width: 0;
|
|
12800
12802
|
margin-right: 0;
|
|
12801
12803
|
margin-bottom: var(--goa-space-m);
|
|
12802
12804
|
}
|
|
@@ -12804,7 +12806,8 @@ const FlexTabsWithMargin = styled.div(_t15$1 || (_t15$1 = _$8`
|
|
|
12804
12806
|
const FlexForm = styled.div(_t16$1 || (_t16$1 = _$8`
|
|
12805
12807
|
flex-direction: column;
|
|
12806
12808
|
flex: 3;
|
|
12807
|
-
|
|
12809
|
+
/* Shrink rather than squeeze the item tabs to nothing at tablet widths. */
|
|
12810
|
+
min-width: 0;
|
|
12808
12811
|
overflow-y: visible;
|
|
12809
12812
|
|
|
12810
12813
|
@media (max-width: 639px) {
|
|
@@ -13341,7 +13344,8 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
|
|
|
13341
13344
|
};
|
|
13342
13345
|
const hasNoElements = () => {
|
|
13343
13346
|
var _uischema$elements2, _uischema$options9;
|
|
13344
|
-
|
|
13347
|
+
// A missing elements or detail list counts as empty, so a bare ListWithDetail still gets generated inputs.
|
|
13348
|
+
const hasNoLayoutElements = !(uischema != null && (_uischema$elements2 = uischema.elements) != null && _uischema$elements2.length) && !(uischema != null && (_uischema$options9 = uischema.options) != null && (_uischema$options9 = _uischema$options9.detail) != null && (_uischema$options9 = _uischema$options9.elements) != null && _uischema$options9.length);
|
|
13345
13349
|
return hasNoLayoutElements;
|
|
13346
13350
|
};
|
|
13347
13351
|
return jsxs(Fragment, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.84.
|
|
3
|
+
"version": "2.84.2",
|
|
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",
|
package/renderer-catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-11-
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"generatedAt": "2026-11-11T00:09:20.655Z",
|
|
4
|
+
"sourceCommit": "67c78c695314f569c36b626a6acf0d320ff7be61",
|
|
5
5
|
"sourcePath": "libs/jsonforms-components/src/index.ts",
|
|
6
6
|
"rendererCount": 23,
|
|
7
7
|
"renderers": [
|