@ukhomeoffice/formio-gds-template 2.0.2 → 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 (68) hide show
  1. package/LICENCE.md +21 -0
  2. package/eslint.config.mjs +58 -0
  3. package/lib/components/datamap/GDSDataMap.d.ts +4 -14
  4. package/lib/components/datamap/GDSDataMap.js +9 -29
  5. package/lib/components/datetime/GDSDatetimeComponent.d.ts +30 -22
  6. package/lib/components/datetime/GDSDatetimeComponent.js +148 -178
  7. package/lib/components/index.js +4 -4
  8. package/lib/components/selectboxes/GDSCheckBoxes.d.ts +4 -2
  9. package/lib/components/selectboxes/GDSCheckBoxes.js +7 -33
  10. package/lib/components/time/GDSTimeComponent.d.ts +12 -10
  11. package/lib/components/time/GDSTimeComponent.js +59 -84
  12. package/lib/components/util/TimeHelper.d.ts +5 -4
  13. package/lib/components/util/TimeHelper.js +13 -16
  14. package/lib/index.d.ts +2 -2
  15. package/lib/index.js +2 -2
  16. package/lib/templates/gds/button/index.js +1 -1
  17. package/lib/templates/gds/checkbox/index.js +1 -1
  18. package/lib/templates/gds/columns/index.js +1 -1
  19. package/lib/templates/gds/component/index.js +1 -1
  20. package/lib/templates/gds/container/index.js +1 -1
  21. package/lib/templates/gds/datagrid/index.js +1 -1
  22. package/lib/templates/gds/datamap/index.js +1 -1
  23. package/lib/templates/gds/datetime/index.js +1 -1
  24. package/lib/templates/gds/day/index.js +1 -1
  25. package/lib/templates/gds/editgrid/index.js +1 -1
  26. package/lib/templates/gds/field/index.js +1 -1
  27. package/lib/templates/gds/fieldset/index.js +1 -1
  28. package/lib/templates/gds/file/index.js +1 -1
  29. package/lib/templates/gds/iconClass.d.ts +1 -1
  30. package/lib/templates/gds/iconClass.js +3 -3
  31. package/lib/templates/gds/index.d.ts +2 -2
  32. package/lib/templates/gds/index.js +72 -64
  33. package/lib/templates/gds/input/index.js +1 -1
  34. package/lib/templates/gds/label/index.js +1 -1
  35. package/lib/templates/gds/message/index.js +1 -1
  36. package/lib/templates/gds/panel/index.js +1 -1
  37. package/lib/templates/gds/radio/index.js +1 -1
  38. package/lib/templates/gds/select/index.js +1 -1
  39. package/lib/templates/gds/selectOption/index.js +1 -1
  40. package/lib/templates/gds/selectboxes/index.js +1 -1
  41. package/lib/templates/gds/survey/index.js +1 -1
  42. package/lib/templates/gds/tab/index.js +1 -1
  43. package/lib/templates/gds/table/index.js +1 -1
  44. package/lib/templates/gds/template.css +16 -0
  45. package/lib/templates/gds/template.css.map +1 -1
  46. package/lib/templates/gds/time/index.js +1 -1
  47. package/lib/templates/gds/warning/index.js +1 -1
  48. package/lib/templates/gds/wizard/index.js +1 -1
  49. package/lib/templates/gds/wizardHeader/index.js +1 -1
  50. package/lib/templates/gds/wizardNav/index.js +1 -1
  51. package/lib/templates/index.d.ts +2 -2
  52. package/lib/templates/index.js +1 -1
  53. package/lib/types.d.ts +36 -0
  54. package/lib/types.js +2 -0
  55. package/package.json +13 -7
  56. package/src/components/datamap/GDSDataMap.ts +5 -14
  57. package/src/components/datetime/GDSDatetimeComponent.ts +109 -91
  58. package/src/components/selectboxes/GDSCheckBoxes.ts +7 -8
  59. package/src/components/time/GDSTimeComponent.ts +37 -27
  60. package/src/components/util/TimeHelper.ts +6 -5
  61. package/src/css.d.ts +4 -0
  62. package/src/templates/gds/iconClass.ts +1 -1
  63. package/src/templates/gds/index.ts +43 -33
  64. package/src/templates/gds/template.scss +30 -1
  65. package/src/types.ts +55 -0
  66. package/tsconfig.json +6 -3
  67. package/webpack.config.js +1 -1
  68. package/tslint.json +0 -22
package/LICENCE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 UKHomeOffice
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ // ESLint flat config (ESLint 9.x)
2
+ // Replaces tslint.json — equivalent rules migrated from tslint:recommended subset used in tslint.json
3
+ import tseslint from '@typescript-eslint/eslint-plugin';
4
+ import tsParser from '@typescript-eslint/parser';
5
+
6
+ export default [
7
+ {
8
+ // Exclude spec files — they are excluded from tsconfig.json so @typescript-eslint/parser
9
+ // cannot resolve them under parserOptions.project.
10
+ ignores: ['**/*.spec.ts'],
11
+ },
12
+ {
13
+ files: ['src/**/*.ts'],
14
+ languageOptions: {
15
+ parser: tsParser,
16
+ parserOptions: {
17
+ project: './tsconfig.json',
18
+ tsconfigRootDir: import.meta.dirname,
19
+ },
20
+ },
21
+ plugins: {
22
+ '@typescript-eslint': tseslint,
23
+ },
24
+ rules: {
25
+ // Equivalent of tslint quotemark: [true, 'single', 'avoid-escape', 'avoid-template']
26
+ // Note: @typescript-eslint/quotes was removed in v6; use the base ESLint rule instead.
27
+ 'quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
28
+
29
+ // tslint no-shadowed-variable: false — off
30
+ 'no-shadow': 'off',
31
+ '@typescript-eslint/no-shadow': 'off',
32
+
33
+ // tslint variable-name: allow-leading-underscore, allow-pascal-case, ban-keywords
34
+ '@typescript-eslint/naming-convention': [
35
+ 'error',
36
+ {
37
+ selector: 'variableLike',
38
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
39
+ leadingUnderscore: 'allow',
40
+ },
41
+ {
42
+ selector: 'typeLike',
43
+ format: ['PascalCase'],
44
+ },
45
+ ],
46
+
47
+ // tslint max-classes-per-file: false — off (default)
48
+ 'max-classes-per-file': 'off',
49
+
50
+ // Remaining `any` annotations are intentional — each is accompanied by a comment
51
+ // explaining it matches a base-class override signature in @formio/js. Warn rather
52
+ // than error so new unintentional `any` is surfaced without breaking CI.
53
+ '@typescript-eslint/no-explicit-any': 'warn',
54
+ // Parameters prefixed with _ are intentionally unused (e.g. _flags in override signatures).
55
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
56
+ },
57
+ },
58
+ ];
@@ -1,17 +1,7 @@
1
- declare const DataMap: import("formiojs").ClassWithEditForm<typeof import("formiojs/types/components/_classes/nested/nestedComponent").NestedComponent>;
1
+ import { DataMapComponent } from '../../types';
2
+ declare const DataMap: any;
2
3
  export default class GDSDataMap extends DataMap {
3
- private getRows;
4
- private hasRowGroups;
5
- private getGroups;
6
- private visibleColumns;
7
- private hasAddButton;
8
- private hasRemoveButtons;
9
- private hasTopSubmit;
10
- private hasBottomSubmit;
11
- private hasExtraColumn;
12
- private datagridKey;
13
- private allowReorder;
14
- private getColumns;
15
- render(): any;
4
+ component: DataMapComponent;
5
+ render(): string;
16
6
  }
17
7
  export {};
@@ -1,33 +1,14 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
- var formiojs_1 = require("formiojs");
19
- var Field = formiojs_1.Components.components.field;
20
- var DataMap = formiojs_1.Components.components.datamap;
21
- var GDSDataMap = /** @class */ (function (_super) {
22
- __extends(GDSDataMap, _super);
23
- function GDSDataMap() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- GDSDataMap.prototype.render = function () {
27
- var columns = this.getColumns();
3
+ const js_1 = require("@formio/js");
4
+ const Field = js_1.Components.components.field;
5
+ const DataMap = js_1.Components.components.datamap;
6
+ class GDSDataMap extends DataMap {
7
+ render() {
8
+ const columns = this.getColumns();
28
9
  return Field.prototype.render.call(this, this.renderTemplate('datamap', {
29
10
  rows: this.getRows(),
30
- columns: columns,
11
+ columns,
31
12
  groups: this.hasRowGroups() ? this.getGroups() : [],
32
13
  visibleColumns: this.visibleColumns,
33
14
  hasAddButton: this.hasAddButton(),
@@ -39,7 +20,6 @@ var GDSDataMap = /** @class */ (function (_super) {
39
20
  allowReorder: this.allowReorder,
40
21
  builder: this.builderMode,
41
22
  }));
42
- };
43
- return GDSDataMap;
44
- }(DataMap));
23
+ }
24
+ }
45
25
  exports.default = GDSDataMap;
@@ -1,33 +1,41 @@
1
- declare const Day: import("formiojs").ClassWithEditForm<typeof import("formiojs/types/components/_classes/field/field").Field>;
1
+ import { GDSDatetimeComponentSchema } from '../../types';
2
+ declare const Day: any;
2
3
  export default class GDSDatetimeComponent extends Day {
4
+ component: GDSDatetimeComponentSchema;
5
+ refs: {
6
+ hour: HTMLInputElement;
7
+ minute: HTMLInputElement;
8
+ day: HTMLInputElement;
9
+ month: HTMLInputElement;
10
+ year: HTMLInputElement;
11
+ input: HTMLInputElement[];
12
+ };
13
+ dataValue: string;
14
+ data: Record<string, unknown>;
15
+ validators: string[];
16
+ shouldDisabled: boolean;
17
+ triggerChange: () => void;
3
18
  get format(): string;
4
- get defaultValue(): any;
5
- get emptyValue(): any;
19
+ get defaultValue(): string;
20
+ get emptyValue(): null;
6
21
  get parts(): {
7
- day: any;
8
- month: any;
9
- year: any;
10
- hour: any;
11
- minute: any;
22
+ day: string | null;
23
+ month: string | null;
24
+ year: string | null;
25
+ hour: string | null;
26
+ minute: string | null;
12
27
  };
13
- private refs;
14
- private component;
15
- private updateValue;
16
- private renderField;
17
- private inputDefinition;
18
- private checkComponentValidity;
19
- private triggerChange;
20
28
  private timeHelper;
21
- attach(element: any): any;
29
+ attach(element: any): Promise<void>;
22
30
  init(): void;
23
31
  setErrorClasses(elements: any, dirty: any, hasError: any): void;
24
32
  removeInputError(elements: any): void;
25
- render(): any;
26
- getDate(value: any): string;
27
- getFieldValue(name: any): any;
28
- boolValue(value: any): boolean;
29
- setValueAt(index: any, value: any): void;
30
- getValueAt(index: any): any;
33
+ render(): string;
34
+ getDate(value: any): string | null;
35
+ getFieldValue(name: any): string | null;
36
+ boolValue(value: unknown): boolean;
37
+ setValueAt(index: number, value: any): void;
38
+ getValueAt(index: number): string | null;
31
39
  normalizeValue(value: any): any;
32
40
  validateRequired(setting: any, value: any): boolean;
33
41
  private processField;