Skip to content

Commit deec1ac

Browse files
committed
Import CHEFS components
1 parent 6d69def commit deec1ac

8 files changed

Lines changed: 247 additions & 4 deletions

File tree

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "common-hosted-form-service"]
2+
path = common-hosted-form-service
3+
url = https://github.com/bcgov/common-hosted-form-service.git

CHANGELOG.MD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## June 23, 2026
2+
3+
- **Feature** Imported CHEFS components into DEP [🎟️ DEP-273](https://citz-gdx.atlassian.net/browse/DEP-273)
4+
- Imported `@bcgov/common-hosted-form-service` package as a Git submodule
5+
- Imported the CHEFS components from the package into the DEP codebase, allowing for the use of these components in the application.
6+
- Updated the FormBuilderOptions to enable the CHEFS components, including `simpleradios` and `simpleselect`, while disabling any corresponding legacy MET-Formio components to avoid conflicts.
7+
- Updated build, start, and test scripts to include the CHEFS components in the build process, ensuring that they are available for use in the application.
8+
19
## June 22, 2026
210

311
- **Feature** Added dynamic tab titles based on the current chain of route matches [🎟️ DEP-263](https://citz-gdx.atlassian.net/browse/DEP-263)

web/package-lock.json

Lines changed: 75 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@babel/core": "^7.29.6",
77
"@bcgov/bc-sans": "^2.1.0",
88
"@bcgov/design-tokens": "^3.2.0",
9+
"@bcgov/formio": "file:../common-hosted-form-service/components",
910
"@emotion/react": "^11.14.0",
1011
"@emotion/styled": "^11.14.1",
1112
"@formio/react": "^5.3.0",
@@ -123,9 +124,13 @@
123124
"yup": "^0.32.11"
124125
},
125126
"scripts": {
127+
"ensure:bcgov-formio": "node scripts/ensure-bcgov-formio.js",
126128
"analyze": "source-map-explorer 'build/static/js/*.js' --no-border-checks",
129+
"prestart": "npm run ensure:bcgov-formio",
127130
"start": "node scripts/start.js",
131+
"prebuild": "npm run ensure:bcgov-formio",
128132
"build": "node scripts/build.js",
133+
"pretest": "npm run ensure:bcgov-formio",
129134
"test": "jest",
130135
"lint": "eslint \"src/**/*.{ts,tsx}\"",
131136
"lintfix": "eslint \"src/**/*.{ts,tsx}\" --fix"

web/scripts/ensure-bcgov-formio.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
const fs = require('node:fs');
4+
const path = require('node:path');
5+
const { spawnSync } = require('node:child_process');
6+
7+
const formioPath = path.resolve(
8+
__dirname,
9+
'../../common-hosted-form-service/components'
10+
);
11+
const formioNodeModules = path.join(formioPath, 'node_modules');
12+
const formioLibEntry = path.join(formioPath, 'lib/index.js');
13+
14+
function run(command, args) {
15+
const result = spawnSync(command, args, {
16+
cwd: formioPath,
17+
stdio: 'inherit',
18+
shell: process.platform === 'win32',
19+
});
20+
21+
if (result.status !== 0) {
22+
process.exit(result.status || 1);
23+
}
24+
}
25+
26+
function shouldInstallDependencies() {
27+
return !fs.existsSync(formioNodeModules);
28+
}
29+
30+
function shouldBuildPackage() {
31+
return !fs.existsSync(formioLibEntry);
32+
}
33+
34+
if (!fs.existsSync(formioPath)) {
35+
console.warn(
36+
`Skipping @bcgov/formio bootstrap; missing path: ${formioPath}`
37+
);
38+
process.exit(0);
39+
}
40+
41+
if (shouldInstallDependencies()) {
42+
run('npm', ['ci']);
43+
}
44+
45+
if (shouldBuildPackage()) {
46+
run('npm', ['run', 'build']);
47+
}

web/src/components/Form/FormBuilderOptions.ts

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export const formioOptions = {
1111
title: '',
1212
weight: 20,
1313
components: {
14-
simpletextfield: true,
15-
simpletextarea: true,
16-
simpleradios: true,
14+
// "MET-Formio" components
15+
// simpletextfield: true, // overridden by BC Gov formio components
16+
// simpletextarea: true, // overridden
17+
// simpleradios: true, // overridden
1718
simplecheckboxes: true,
1819
header: true,
1920
paragraph: true,
@@ -25,7 +26,56 @@ export const formioOptions = {
2526
simplehtmlelement: true,
2627
simplecontent: true,
2728
simplesurvey: true,
29+
// simpleselect: true, // overridden
30+
31+
// BC Gov formio components
32+
orgbook: true,
33+
simplebtnreset: true,
34+
simplebtnsubmit: true,
35+
simplecheckbox: true,
36+
simplecols2: true,
37+
simplecols3: true,
38+
simplecols4: true,
39+
simpledatetime: true,
40+
simpleday: true,
41+
simpleemail: true,
42+
simplefieldset: true,
43+
simplefile: true,
44+
simpleheading: true,
45+
simplenumber: true,
46+
simplepanel: true,
47+
simpleparagraph: true,
48+
simplephonenumber: true,
49+
simpleradios: true,
2850
simpleselect: true,
51+
simpletabs: true,
52+
simpletextarea: true,
53+
simpletextfield: true,
54+
simpletime: true,
55+
simpletextfieldadvanced: true,
56+
simpleemailadvanced: true,
57+
simpletextareaadvanced: true,
58+
simplenumberadvanced: true,
59+
simpleurladvanced: true,
60+
simplephonenumberadvanced: true,
61+
simpletagsadvanced: true,
62+
simpleaddressadvanced: true,
63+
simplepasswordadvanced: true,
64+
simpledatetimeadvanced: true,
65+
simplecheckboxadvanced: true,
66+
simpledayadvanced: true,
67+
simpletimeadvanced: true,
68+
simpleselectboxesadvanced: true,
69+
simpleselectadvanced: true,
70+
simplecurrencyadvanced: true,
71+
simpleradioadvanced: true,
72+
simplesurveyadvanced: true,
73+
simplesignatureadvanced: true,
74+
simplebuttonadvanced: true,
75+
bcaddress: true,
76+
simplebcaddress: true,
77+
map: true,
78+
idirusers: false,
2979
},
3080
default: true,
3181
},
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const useMock = jest.fn();
2+
3+
jest.mock('@formio/react', () => ({
4+
Formio: {
5+
use: useMock,
6+
Utils: {
7+
Evaluator: {
8+
noeval: true,
9+
},
10+
},
11+
},
12+
}));
13+
14+
jest.mock('met-formio', () => ({
15+
__esModule: true,
16+
default: { name: 'met-formio-components' },
17+
}));
18+
19+
jest.mock('@bcgov/formio', () => ({
20+
__esModule: true,
21+
default: { name: 'bcgov-formio-components' },
22+
}));
23+
24+
jest.mock('components/Form/formio.scss', () => ({}));
25+
26+
describe('setupFormio', () => {
27+
beforeEach(() => {
28+
jest.resetModules();
29+
useMock.mockReset();
30+
});
31+
32+
it('registers met-formio and common-hosted-form-service components once', async () => {
33+
const setupFormio = (await import('./setup')).default;
34+
const metFormio = (await import('met-formio')).default;
35+
const bcgovFormio = (await import('@bcgov/formio')).default;
36+
const { Formio } = await import('@formio/react');
37+
38+
setupFormio();
39+
40+
expect(useMock).toHaveBeenCalledTimes(2);
41+
expect(useMock).toHaveBeenNthCalledWith(1, metFormio);
42+
expect(useMock).toHaveBeenNthCalledWith(2, bcgovFormio);
43+
expect(Formio.Utils.Evaluator.noeval).toBe(false);
44+
});
45+
46+
it('does not re-register components after initialization', async () => {
47+
const setupFormio = (await import('./setup')).default;
48+
49+
setupFormio();
50+
setupFormio();
51+
52+
expect(useMock).toHaveBeenCalledTimes(2);
53+
});
54+
});
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// components/Form/formio/setup.ts
22
import { Formio } from '@formio/react';
33
import FormioComponents from 'met-formio';
4+
import BCGovFormioComponents from '@bcgov/formio';
45
import 'components/Form/formio.scss';
56

67
let initialized = false;
78

89
export default function setupFormio() {
910
if (initialized) return;
1011
Formio.use(FormioComponents);
12+
Formio.use(BCGovFormioComponents);
1113
Formio.Utils.Evaluator.noeval = false;
1214
initialized = true;
1315
}

0 commit comments

Comments
 (0)