@ukhomeoffice/formio-gds-template 2.0.1 → 3.0.0-alpha

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.
Files changed (73) hide show
  1. package/LICENCE.md +21 -0
  2. package/README.md +3 -1
  3. package/eslint.config.mjs +58 -0
  4. package/lib/components/datamap/GDSDataMap.d.ts +4 -14
  5. package/lib/components/datamap/GDSDataMap.js +9 -29
  6. package/lib/components/datetime/GDSDatetimeComponent.d.ts +30 -22
  7. package/lib/components/datetime/GDSDatetimeComponent.js +172 -176
  8. package/lib/components/index.js +7 -4
  9. package/lib/components/selectboxes/GDSCheckBoxes.d.ts +4 -2
  10. package/lib/components/selectboxes/GDSCheckBoxes.js +7 -33
  11. package/lib/components/time/GDSTimeComponent.d.ts +12 -10
  12. package/lib/components/time/GDSTimeComponent.js +62 -84
  13. package/lib/components/util/TimeHelper.d.ts +5 -4
  14. package/lib/components/util/TimeHelper.js +13 -16
  15. package/lib/index.d.ts +2 -2
  16. package/lib/index.js +5 -2
  17. package/lib/templates/gds/button/index.js +4 -1
  18. package/lib/templates/gds/checkbox/index.js +4 -1
  19. package/lib/templates/gds/columns/index.js +4 -1
  20. package/lib/templates/gds/component/index.js +4 -1
  21. package/lib/templates/gds/container/index.js +4 -1
  22. package/lib/templates/gds/datagrid/form.ejs.js +1 -1
  23. package/lib/templates/gds/datagrid/index.js +4 -1
  24. package/lib/templates/gds/datamap/index.js +4 -1
  25. package/lib/templates/gds/datetime/index.js +4 -1
  26. package/lib/templates/gds/day/index.js +4 -1
  27. package/lib/templates/gds/editgrid/index.js +4 -1
  28. package/lib/templates/gds/field/index.js +4 -1
  29. package/lib/templates/gds/fieldset/index.js +4 -1
  30. package/lib/templates/gds/file/index.js +4 -1
  31. package/lib/templates/gds/iconClass.d.ts +1 -1
  32. package/lib/templates/gds/iconClass.js +3 -3
  33. package/lib/templates/gds/index.d.ts +2 -2
  34. package/lib/templates/gds/index.js +75 -64
  35. package/lib/templates/gds/input/index.js +4 -1
  36. package/lib/templates/gds/label/index.js +4 -1
  37. package/lib/templates/gds/message/index.js +4 -1
  38. package/lib/templates/gds/panel/index.js +4 -1
  39. package/lib/templates/gds/radio/index.js +4 -1
  40. package/lib/templates/gds/select/index.js +4 -1
  41. package/lib/templates/gds/selectOption/index.js +4 -1
  42. package/lib/templates/gds/selectboxes/index.js +4 -1
  43. package/lib/templates/gds/survey/index.js +4 -1
  44. package/lib/templates/gds/tab/index.js +4 -1
  45. package/lib/templates/gds/table/index.js +4 -1
  46. package/lib/templates/gds/template.css +16 -0
  47. package/lib/templates/gds/template.css.map +1 -1
  48. package/lib/templates/gds/time/index.js +4 -1
  49. package/lib/templates/gds/warning/index.js +4 -1
  50. package/lib/templates/gds/wizard/index.js +4 -1
  51. package/lib/templates/gds/wizardHeader/index.js +4 -1
  52. package/lib/templates/gds/wizardNav/index.js +4 -1
  53. package/lib/templates/index.d.ts +2 -2
  54. package/lib/templates/index.js +4 -1
  55. package/lib/types.d.ts +36 -0
  56. package/lib/types.js +2 -0
  57. package/package.json +13 -7
  58. package/src/components/datamap/GDSDataMap.ts +5 -14
  59. package/src/components/datetime/GDSDatetimeComponent.ts +110 -92
  60. package/src/components/selectboxes/GDSCheckBoxes.ts +7 -8
  61. package/src/components/time/GDSTimeComponent.ts +38 -28
  62. package/src/components/util/TimeHelper.ts +6 -5
  63. package/src/css.d.ts +4 -0
  64. package/src/templates/gds/datagrid/form.ejs +1 -1
  65. package/src/templates/gds/iconClass.ts +1 -1
  66. package/src/templates/gds/index.ts +43 -33
  67. package/src/templates/gds/template.scss +30 -1
  68. package/src/types.ts +55 -0
  69. package/tsconfig.json +8 -4
  70. package/webpack.config.js +1 -1
  71. package/dist/gds.js +0 -2
  72. package/dist/gds.js.LICENSE.txt +0 -41
  73. package/tslint.json +0 -22
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -112,6 +112,18 @@
112
112
  .govuk-details {
113
113
  margin-bottom: 0 !important;
114
114
  }
115
+ .govuk-details__summary {
116
+ font-weight: 400 !important;
117
+ }
118
+
119
+ .formio-component-datagrid > [ref=messageContainer],
120
+ .formio-component-editgrid > [ref=messageContainer],
121
+ .formio-component-datamap > [ref=messageContainer],
122
+ .formio-component-panel > [ref=messageContainer],
123
+ .formio-component-container > [ref=messageContainer],
124
+ .formio-component-fieldset > [ref=messageContainer] {
125
+ display: none;
126
+ }
115
127
 
116
128
  .small-button {
117
129
  padding: 0.25rem 0.5rem;
@@ -168,4 +180,8 @@
168
180
  height: auto;
169
181
  }
170
182
 
183
+ .govuk-form-group--error .govuk-form-group {
184
+ overflow: visible;
185
+ }
186
+
171
187
  /*# sourceMappingURL=template.css.map */
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../../../src/templates/gds/template.scss","../../../node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKE;EACE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;IACE;;EAEF;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAGF;IACE;;EAGF;IACE;IACA;;EAGF;IACE;;EAEF;IACE;;;AAKJ;EACE;;;AAGF;EACE;EACA;EACA;;;AAIF;EACE;;AAEA;EACE;EAGA;;;AAKJ;EACE;EACA;;;AAGF;EACE;;;ACqHM;EDhHJ;IACE;;;;AAMJ;EADF;IAEI;IACA;IACA;IACA;IACA;;;;AAIJ;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE","file":"template.css"}
1
+ {"version":3,"sourceRoot":"","sources":["../../../src/templates/gds/template.scss","../../../node_modules/govuk-frontend/dist/govuk/vendor/_sass-mq.scss"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKE;EACE;EACA;EACA;;AAGF;AAAA;EAEE;EACA;EACA;;;AAKJ;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;;;AAGF;EACE;IACE;;EAEF;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;EAGF;IACE;;EAGF;IACE;IACA;;EAGF;IACE;;EAEF;IACE;;;AAKJ;EACE;;AAGA;EACE;;;AAaF;AAAA;AAAA;AAAA;AAAA;AAAA;EACE;;;AAIJ;EACE;EACA;EACA;;;AAIF;EACE;;AAEA;EACE;EAGA;;;AAKJ;EACE;EACA;;;AAGF;EACE;;;ACkGM;ED7FJ;IACE;;;;AAMJ;EADF;IAEI;IACA;IACA;IACA;IACA;;;;AAIJ;EACE;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAQA;EACE","file":"template.css"}
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,4 +1,7 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var form_ejs_1 = require("./form.ejs");
6
+ const form_ejs_1 = __importDefault(require("./form.ejs"));
4
7
  exports.default = { form: form_ejs_1.default };
@@ -1,8 +1,8 @@
1
1
  declare const _default: {
2
2
  gds: {
3
- transform(type: any, text: any): any;
3
+ transform(type: string, text: string): any;
4
4
  defaultIconset: string;
5
- iconClass: (iconset: any, name: any, spinning: any) => string;
5
+ iconClass: (iconset: string, name: string, spinning: boolean) => string;
6
6
  cssClasses: {
7
7
  'has-error': string;
8
8
  'formio-tab-link-container-active': string;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var gds_1 = require("./gds");
6
+ const gds_1 = __importDefault(require("./gds"));
4
7
  exports.default = {
5
8
  gds: gds_1.default,
6
9
  };
package/lib/types.d.ts ADDED
@@ -0,0 +1,36 @@
1
+ import type { DayComponent, DateTimeComponent, TimeComponent as CoreTimeComponent, SelectBoxesComponent, DataMapComponent } from '@formio/core';
2
+ /**
3
+ * Minimal interface for DOM input-like elements.
4
+ * Used as the typed parameter in TimeHelper methods so callers can pass any
5
+ * object that has a writable `.value: string` (e.g. HTMLInputElement).
6
+ */
7
+ export interface InputElementLike {
8
+ value: string;
9
+ }
10
+ /**
11
+ * The shape of a single GDS date/time field definition.
12
+ * Extends the base formio field definition with an optional placeholder.
13
+ */
14
+ export type GDSFieldDefinition = {
15
+ type?: string;
16
+ placeholder?: string;
17
+ required?: boolean;
18
+ };
19
+ /**
20
+ * Component schema for GDSDatetimeComponent.
21
+ *
22
+ * GDSDatetimeComponent extends the formio Day component but adds hour/minute
23
+ * fields (from a datetime hybrid) and uses datePicker / defaultDate from
24
+ * DateTimeComponent. This type captures the full shape of `this.component`
25
+ * as used in GDSDatetimeComponent.
26
+ */
27
+ export type GDSDatetimeComponentSchema = Omit<DayComponent, 'suffix' | 'fields'> & Pick<DateTimeComponent, 'datePicker' | 'defaultDate'> & {
28
+ /** suffix is set to null in init() — null must be allowed */
29
+ suffix?: string | null;
30
+ /** fields extended with GDS hour/minute additions */
31
+ fields: DayComponent['fields'] & {
32
+ hour?: GDSFieldDefinition;
33
+ minute?: GDSFieldDefinition;
34
+ };
35
+ };
36
+ export type { CoreTimeComponent, SelectBoxesComponent, DataMapComponent };
package/lib/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@ukhomeoffice/formio-gds-template",
3
- "version": "2.0.1",
4
- "description": "Gov UK design system formio templates",
3
+ "version": "3.0.0-alpha",
4
+ "description": "Gov UK design system formio templates — upgraded to @formio/js@5.x",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "main": "lib/index.js",
9
+ "types": "lib/index.d.ts",
9
10
  "scripts": {
11
+ "prepack": "npm run build",
10
12
  "test:coverage": "nyc --reporter=text mocha --reporter spec './{,!(node_modules)/**/}*.spec.js'",
11
13
  "test": "mocha --require ts-node/register --reporter spec './{,!(node_modules)/**/}*.spec.ts'",
12
14
  "build-sass": "sass src/templates/gds/template.scss lib/templates/gds/template.css",
@@ -15,8 +17,8 @@
15
17
  "watch": "concurrently \"npm run watch-ts\" \"npm run watch-sass\"",
16
18
  "build": "tsc && gulp templates && npm run build-sass && webpack",
17
19
  "tag": "VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]');git add -A; git commit -nm \"Build $Version\";git push origin master;git tag v$VERSION;git push origin --tags;",
18
- "lint": "tslint --project tsconfig.json",
19
- "lint:fix": "tslint --project tsconfig.json --fix",
20
+ "lint": "eslint 'src/**/*.ts'",
21
+ "lint:fix": "eslint 'src/**/*.ts' --fix",
20
22
  "prepublish": "npm run build"
21
23
  },
22
24
  "pre-commit": [
@@ -40,13 +42,15 @@
40
42
  },
41
43
  "homepage": "https://github.com/UKHomeOffice/formio-gds-template#readme",
42
44
  "peerDependencies": {
43
- "formiojs": "^4.9.26",
45
+ "@formio/core": "^2.0.0",
46
+ "@formio/js": "^5.0.0",
44
47
  "govuk-frontend": "^5.0.0"
45
48
  },
46
49
  "dependencies": {
47
50
  "lodash": "4.17.21"
48
51
  },
49
52
  "devDependencies": {
53
+ "@formio/core": "^2.0.0",
50
54
  "@types/chai": "^4.3.16",
51
55
  "@types/ejs": "^3.1.5",
52
56
  "@types/lodash": "^4.17.5",
@@ -58,7 +62,7 @@
58
62
  "chai": "^5.1.1",
59
63
  "concurrently": "^8.2.2",
60
64
  "css-loader": "^7.1.2",
61
- "formiojs": "^4.19.4",
65
+ "@formio/js": "^5.0.0",
62
66
  "govuk-frontend": "^5.4.0",
63
67
  "gulp": "^4.0.2",
64
68
  "gulp-insert": "^0.5.0",
@@ -74,7 +78,9 @@
74
78
  "style-loader": "^4.0.0",
75
79
  "ts-node": "^10.9.2",
76
80
  "ts-sinon": "^2.0.2",
77
- "tslint": "^6.1.2",
81
+ "eslint": "^9.0.0",
82
+ "@typescript-eslint/parser": "^8.0.0",
83
+ "@typescript-eslint/eslint-plugin": "^8.0.0",
78
84
  "typed-scss-modules": "^8.0.1",
79
85
  "typescript": "^5.5.2",
80
86
  "webpack": "^5.92.1",
@@ -1,23 +1,14 @@
1
- import {Components} from 'formiojs';
1
+ import { Components } from '@formio/js';
2
+ import { DataMapComponent } from '../../types';
2
3
 
3
4
  const Field = Components.components.field;
4
5
  const DataMap = Components.components.datamap;
5
6
 
6
7
  export default class GDSDataMap extends DataMap {
7
- private getRows: any;
8
- private hasRowGroups: any;
9
- private getGroups: any;
10
- private visibleColumns: any;
11
- private hasAddButton: any;
12
- private hasRemoveButtons: any;
13
- private hasTopSubmit: any;
14
- private hasBottomSubmit: any;
15
- private hasExtraColumn: any;
16
- private datagridKey: any;
17
- private allowReorder: any;
18
- private getColumns: any;
8
+ // Narrow the inherited `component: any` using the @formio/core DataMapComponent schema.
9
+ declare component: DataMapComponent;
19
10
 
20
- public render() {
11
+ public render(): string {
21
12
  const columns = this.getColumns();
22
13
  return Field.prototype.render.call(this, this.renderTemplate('datamap', {
23
14
  rows: this.getRows(),