@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,105 +1,83 @@
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
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
7
  }
24
- return to.concat(ar || Array.prototype.slice.call(from));
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
27
  };
26
28
  Object.defineProperty(exports, "__esModule", { value: true });
27
- var formiojs_1 = require("formiojs");
28
- var utils_1 = require("formiojs/utils");
29
- var _ = require("lodash");
30
- var moment = require("moment");
31
- var TimeHelper_1 = require("../util/TimeHelper");
32
- var Field = formiojs_1.Components.components.field;
33
- var Day = formiojs_1.Components.components.day;
34
- // @ts-ignore
35
- var GDSDatetimeComponent = /** @class */ (function (_super) {
36
- __extends(GDSDatetimeComponent, _super);
37
- function GDSDatetimeComponent() {
38
- var _this = _super !== null && _super.apply(this, arguments) || this;
39
- _this.timeHelper = new TimeHelper_1.default();
40
- return _this;
29
+ const js_1 = require("@formio/js");
30
+ const js_2 = require("@formio/js");
31
+ const _ = __importStar(require("lodash"));
32
+ const moment_1 = __importDefault(require("moment"));
33
+ const TimeHelper_1 = __importDefault(require("../util/TimeHelper"));
34
+ const Field = js_1.Components.components.field;
35
+ const Day = js_1.Components.components.day;
36
+ class GDSDatetimeComponent extends Day {
37
+ constructor() {
38
+ super(...arguments);
39
+ this.timeHelper = new TimeHelper_1.default();
41
40
  }
42
- Object.defineProperty(GDSDatetimeComponent.prototype, "format", {
43
- get: function () {
44
- return 'DD-MM-YYYY';
45
- },
46
- enumerable: false,
47
- configurable: true
48
- });
49
- Object.defineProperty(GDSDatetimeComponent.prototype, "defaultValue", {
50
- // @ts-ignore
51
- get: function () {
52
- var defaultValue = this.component.defaultValue;
53
- if (!defaultValue && this.component.defaultDate) {
54
- defaultValue = utils_1.default.getDateSetting(this.component.defaultDate);
55
- defaultValue = defaultValue ? moment(defaultValue).format() : '';
56
- }
57
- return defaultValue;
58
- },
59
- enumerable: false,
60
- configurable: true
61
- });
62
- Object.defineProperty(GDSDatetimeComponent.prototype, "emptyValue", {
63
- // @ts-ignore
64
- get: function () {
65
- return null;
66
- },
67
- enumerable: false,
68
- configurable: true
69
- });
70
- Object.defineProperty(GDSDatetimeComponent.prototype, "parts", {
71
- get: function () {
72
- return {
73
- day: this.getFieldValue('day'),
74
- month: this.getFieldValue('month'),
75
- year: this.getFieldValue('year'),
76
- hour: this.getFieldValue('hour'),
77
- minute: this.getFieldValue('minute'),
78
- };
79
- },
80
- enumerable: false,
81
- configurable: true
82
- });
83
- GDSDatetimeComponent.prototype.attach = function (element) {
84
- var _this = this;
41
+ get format() {
42
+ return 'DD-MM-YYYY';
43
+ }
44
+ get defaultValue() {
45
+ let defaultValue = this.component.defaultValue;
46
+ if (!defaultValue && this.component.defaultDate) {
47
+ defaultValue = js_2.Utils.getDateSetting(this.component.defaultDate);
48
+ defaultValue = defaultValue ? (0, moment_1.default)(defaultValue).format() : '';
49
+ }
50
+ return defaultValue !== null && defaultValue !== void 0 ? defaultValue : '';
51
+ }
52
+ get emptyValue() {
53
+ return null;
54
+ }
55
+ get parts() {
56
+ return {
57
+ day: this.getFieldValue('day'),
58
+ month: this.getFieldValue('month'),
59
+ year: this.getFieldValue('year'),
60
+ hour: this.getFieldValue('hour'),
61
+ minute: this.getFieldValue('minute'),
62
+ };
63
+ }
64
+ // element typed as `any` to match the base Day.attach(element: any) override signature
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
+ attach(element) {
85
67
  this.loadRefs(element, { hour: 'single', minute: 'single' });
86
- this.addEventListener(this.refs.hour, 'input', function () {
87
- _this.timeHelper.checkAndValidateHour(_this.refs.hour);
88
- _this.setPristine(false);
89
- _this.checkComponentValidity(_this.data, true);
90
- _this.updateValue(null, {
91
- modified: true,
92
- });
93
- _this.triggerChange();
68
+ this.addEventListener(this.refs.hour, 'input', () => {
69
+ this.timeHelper.checkAndValidateHour(this.refs.hour);
70
+ this.setPristine(false);
71
+ this.checkComponentValidity(this.data, true);
72
+ this.updateValue(null, { modified: true });
73
+ this.triggerChange();
94
74
  });
95
- this.addEventListener(this.refs.minute, 'input', function () {
96
- _this.timeHelper.checkAndValidateMinutes(_this.refs.minute);
97
- _this.setPristine(false);
98
- _this.checkComponentValidity(_this.data, true);
99
- _this.updateValue(null, {
100
- modified: true,
101
- });
102
- _this.triggerChange();
75
+ this.addEventListener(this.refs.minute, 'input', () => {
76
+ this.timeHelper.checkAndValidateMinutes(this.refs.minute);
77
+ this.setPristine(false);
78
+ this.checkComponentValidity(this.data, true);
79
+ this.updateValue(null, { modified: true });
80
+ this.triggerChange();
103
81
  });
104
82
  this.addEventListener(this.refs.hour, 'keypress', this.timeHelper.preventNonNumericKeyPress);
105
83
  this.addEventListener(this.refs.minute, 'keypress', this.timeHelper.preventNonNumericKeyPress);
@@ -107,48 +85,54 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
107
85
  this.setDisabled(this.refs.hour, true);
108
86
  this.setDisabled(this.refs.minute, true);
109
87
  }
110
- var superAttach = _super.prototype.attach.call(this, element);
88
+ const superAttach = super.attach(element);
111
89
  this.addEventListener(this.refs.year, 'keypress', this.timeHelper.preventNonNumericKeyPress);
112
90
  this.addEventListener(this.refs.month, 'keypress', this.timeHelper.preventNonNumericKeyPress);
113
91
  this.addEventListener(this.refs.day, 'keypress', this.timeHelper.preventNonNumericKeyPress);
114
- this.addEventListener(this.refs.year, 'input', function () {
115
- _this.timeHelper.validateDateInput(_this.refs.year, 4);
92
+ this.addEventListener(this.refs.year, 'input', () => {
93
+ this.timeHelper.validateDateInput(this.refs.year, 4);
116
94
  });
117
- this.addEventListener(this.refs.day, 'input', function () {
118
- _this.timeHelper.validateDateInput(_this.refs.day, 2);
95
+ this.addEventListener(this.refs.day, 'input', () => {
96
+ this.timeHelper.validateDateInput(this.refs.day, 2);
119
97
  });
120
- this.addEventListener(this.refs.month, 'input', function () {
121
- _this.timeHelper.validateDateInput(_this.refs.month, 2);
98
+ this.addEventListener(this.refs.month, 'input', () => {
99
+ this.timeHelper.validateDateInput(this.refs.month, 2);
122
100
  });
123
101
  return superAttach;
124
- };
125
- GDSDatetimeComponent.prototype.init = function () {
126
- _super.prototype.init.call(this);
127
- this.validators = this.validators.filter(function (v) { return v !== 'day'; }).concat(['date']);
128
- this.component.maxDate = this.component.datePicker.maxDate;
129
- this.component.minDate = this.component.datePicker.minDate;
102
+ }
103
+ init() {
104
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
105
+ super.init();
106
+ // @formio/js@5.x: this.validators is not pre-populated by the base class; guard before filtering
107
+ this.validators = (this.validators || []).filter((v) => v !== 'day').concat(['date']);
108
+ this.component.maxDate = (_b = (_a = this.component.datePicker) === null || _a === void 0 ? void 0 : _a.maxDate) !== null && _b !== void 0 ? _b : undefined;
109
+ this.component.minDate = (_d = (_c = this.component.datePicker) === null || _c === void 0 ? void 0 : _c.minDate) !== null && _d !== void 0 ? _d : undefined;
130
110
  this.component.suffix = null;
131
- this.component.fields.day.required = this.component.validate.required;
132
- this.component.fields.month.required = this.component.validate.required;
133
- this.component.fields.year.required = this.component.validate.required;
111
+ this.component.fields.day.required = (_e = this.component.validate) === null || _e === void 0 ? void 0 : _e.required;
112
+ this.component.fields.month.required = (_f = this.component.validate) === null || _f === void 0 ? void 0 : _f.required;
113
+ this.component.fields.year.required = (_g = this.component.validate) === null || _g === void 0 ? void 0 : _g.required;
134
114
  this.component.fields.hour = {
135
- type: 'number', placeholder: 'HH',
136
- required: this.component.validate.required,
115
+ type: 'number',
116
+ placeholder: 'HH',
117
+ required: (_h = this.component.validate) === null || _h === void 0 ? void 0 : _h.required,
137
118
  };
138
119
  this.component.fields.minute = {
139
- type: 'number', placeholder: 'MM',
140
- required: this.component.validate.required,
120
+ type: 'number',
121
+ placeholder: 'MM',
122
+ required: (_j = this.component.validate) === null || _j === void 0 ? void 0 : _j.required,
141
123
  };
142
- };
143
- GDSDatetimeComponent.prototype.setErrorClasses = function (elements, dirty, hasError) {
144
- // @ts-ignore
145
- _super.prototype.setErrorClasses.call(this, __spreadArray([this.refs.hour, this.refs.minute], elements, true), dirty, hasError);
146
- };
147
- GDSDatetimeComponent.prototype.removeInputError = function (elements) {
148
- // @ts-ignore
149
- _super.prototype.removeInputError.call(this, __spreadArray([this.refs.hour, this.refs.minute], elements, true));
150
- };
151
- GDSDatetimeComponent.prototype.render = function () {
124
+ }
125
+ // elements typed as `any` to match the base Day.setErrorClasses(elements: any, ...) override signature
126
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
+ setErrorClasses(elements, dirty, hasError) {
128
+ super.setErrorClasses([this.refs.hour, this.refs.minute, ...elements], dirty, hasError);
129
+ }
130
+ // elements typed as `any` to match the base Component.removeInputError(elements: any) signature
131
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
132
+ removeInputError(elements) {
133
+ super.removeInputError([this.refs.hour, this.refs.minute, ...elements]);
134
+ }
135
+ render() {
152
136
  return Field.prototype.render.call(this, this.renderTemplate('datetime', {
153
137
  component: this.component,
154
138
  dataValue: this.dataValue,
@@ -160,45 +144,49 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
160
144
  hour: this.renderField('hour'),
161
145
  minute: this.renderField('minute'),
162
146
  }));
163
- };
164
- GDSDatetimeComponent.prototype.getDate = function (value) {
165
- var defaults = [];
166
- var _a = [0, 1, 2, 3, 4], DAY = _a[0], MONTH = _a[1], YEAR = _a[2], HOUR = _a[3], MINUTE = _a[4];
167
- var defaultValue = value || this.component.defaultValue;
147
+ }
148
+ // value typed as `any` to match the base Day.getDate(value: any): null | string signature
149
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
150
+ getDate(value) {
151
+ const defaults = [];
152
+ const [DAY, MONTH, YEAR, HOUR, MINUTE] = [0, 1, 2, 3, 4];
153
+ const defaultValue = value || this.component.defaultValue;
168
154
  if (defaultValue) {
169
155
  try {
170
- var defaultDate = moment(defaultValue);
156
+ const defaultDate = (0, moment_1.default)(defaultValue);
171
157
  defaults[DAY] = defaultDate.format('DD');
172
158
  defaults[MONTH] = defaultDate.format('MM');
173
159
  defaults[YEAR] = defaultDate.format('YYYY');
174
160
  defaults[HOUR] = defaultDate.format('HH');
175
161
  defaults[MINUTE] = defaultDate.format('mm');
176
162
  }
177
- catch (e) {
163
+ catch (_a) {
178
164
  // ignored
179
165
  }
180
166
  }
181
- var day = this.processField('day', defaults, DAY);
182
- var month = this.processField('month', defaults, MONTH);
183
- var year = this.processField('year', defaults, YEAR);
184
- var hour = this.processField('hour', defaults, HOUR);
185
- var minute = this.processField('minute', defaults, MINUTE);
167
+ const day = this.processField('day', defaults, DAY);
168
+ const month = this.processField('month', defaults, MONTH);
169
+ const year = this.processField('year', defaults, YEAR);
170
+ const hour = this.processField('hour', defaults, HOUR);
171
+ const minute = this.processField('minute', defaults, MINUTE);
186
172
  if (!day && !month && !year && (!hour && !minute)) {
187
173
  return null;
188
174
  }
189
- day = day.toString().padStart(2, 0);
190
- month = month.toString().padStart(2, 0);
191
- year = year.toString().padStart(4, 0);
192
- hour = hour.toString().padStart(2, 0);
193
- minute = minute.toString().padStart(2, 0);
194
- var toMoment = moment("".concat(year, "-").concat(month, "-").concat(day, " ").concat(hour, ":").concat(minute), 'YYYY-MM-DD HH:mm');
175
+ const dayStr = day.toString().padStart(2, '0');
176
+ const monthStr = month.toString().padStart(2, '0');
177
+ const yearStr = year.toString().padStart(4, '0');
178
+ const hourStr = hour.toString().padStart(2, '0');
179
+ const minuteStr = minute.toString().padStart(2, '0');
180
+ const toMoment = (0, moment_1.default)(`${yearStr}-${monthStr}-${dayStr} ${hourStr}:${minuteStr}`, 'YYYY-MM-DD HH:mm');
195
181
  return toMoment.format();
196
- };
197
- GDSDatetimeComponent.prototype.getFieldValue = function (name) {
182
+ }
183
+ // name typed as `any` to match the base Day.getFieldValue(name: any): number signature
184
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
+ getFieldValue(name) {
198
186
  if (this.dataValue && this.dataValue !== 'Invalid date') {
199
187
  try {
200
- var val = null;
201
- var date = moment(this.dataValue, 'YYYY-MM-DD HH:mm');
188
+ let val = null;
189
+ const date = (0, moment_1.default)(this.dataValue, 'YYYY-MM-DD HH:mm');
202
190
  switch (name) {
203
191
  case 'month':
204
192
  val = date.format('MM');
@@ -218,13 +206,13 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
218
206
  }
219
207
  return val;
220
208
  }
221
- catch (e) {
209
+ catch (_a) {
222
210
  return null;
223
211
  }
224
212
  }
225
213
  return null;
226
- };
227
- GDSDatetimeComponent.prototype.boolValue = function (value) {
214
+ }
215
+ boolValue(value) {
228
216
  if (_.isBoolean(value)) {
229
217
  return value;
230
218
  }
@@ -234,14 +222,15 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
234
222
  else {
235
223
  return !!value;
236
224
  }
237
- };
238
- GDSDatetimeComponent.prototype.setValueAt = function (index, value) {
239
- // temporary solution to avoid input reset
240
- // on invalid date.
225
+ }
226
+ // value typed as `any` to match the base Day.setValueAt(index: number, value: any) signature
227
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
228
+ setValueAt(index, value) {
229
+ // temporary solution to avoid input reset on invalid date.
241
230
  if (!value || value === 'Invalid date') {
242
231
  return;
243
232
  }
244
- var date = moment(value, moment.ISO_8601);
233
+ const date = (0, moment_1.default)(value, moment_1.default.ISO_8601);
245
234
  if (date.isValid()) {
246
235
  if (this.refs.day) {
247
236
  this.refs.day.value = date.format('DD');
@@ -259,10 +248,10 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
259
248
  this.refs.minute.value = date.format('mm');
260
249
  }
261
250
  }
262
- };
263
- GDSDatetimeComponent.prototype.getValueAt = function (index) {
264
- // @ts-ignore
265
- var date = this.date;
251
+ }
252
+ getValueAt(index) {
253
+ // `date` is a public getter declared on DayComponent: get date(): string | null
254
+ const date = this.date;
266
255
  if (date) {
267
256
  this.refs.input[index].value = date;
268
257
  return this.refs.input[index].value;
@@ -271,39 +260,46 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
271
260
  this.refs.input[index].value = '';
272
261
  return null;
273
262
  }
274
- };
275
- GDSDatetimeComponent.prototype.normalizeValue = function (value) {
263
+ }
264
+ // value typed as `any` to match the base Component.normalizeValue(value: any): any signature
265
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
266
+ normalizeValue(value) {
276
267
  return value;
277
- };
278
- GDSDatetimeComponent.prototype.validateRequired = function (setting, value) {
279
- var _a = this.parts, day = _a.day, month = _a.month, year = _a.year, minute = _a.minute, hour = _a.hour;
280
- if (this.component.validate.required && (!day || parseInt(day, 10) === 0)) {
268
+ }
269
+ // setting/value typed as `any` to match the base Day.validateRequired(setting: any, value: any) signature
270
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
271
+ validateRequired(setting, value) {
272
+ var _a, _b, _c, _d, _e;
273
+ const { day, month, year, minute, hour } = this.parts;
274
+ if (((_a = this.component.validate) === null || _a === void 0 ? void 0 : _a.required) && (!day || parseInt(day, 10) === 0)) {
281
275
  return false;
282
276
  }
283
- if (this.component.validate.required && (!month || parseInt(month, 10) === 0)) {
277
+ if (((_b = this.component.validate) === null || _b === void 0 ? void 0 : _b.required) && (!month || parseInt(month, 10) === 0)) {
284
278
  return false;
285
279
  }
286
- if (this.component.validate.required && (!year || parseInt(year, 10) === 0)) {
280
+ if (((_c = this.component.validate) === null || _c === void 0 ? void 0 : _c.required) && (!year || parseInt(year, 10) === 0)) {
287
281
  return false;
288
282
  }
289
- if (this.component.validate.required && ((this.refs.minute && this.refs.minute.value === '') || !minute)) {
283
+ if (((_d = this.component.validate) === null || _d === void 0 ? void 0 : _d.required) && (this.refs.minute.value === '' || !minute)) {
290
284
  return false;
291
285
  }
292
- if (this.component.validate.required && ((this.refs.hour && this.refs.hour.value === '') || !hour)) {
286
+ if (((_e = this.component.validate) === null || _e === void 0 ? void 0 : _e.required) && (this.refs.hour.value === '' || !hour)) {
293
287
  return false;
294
288
  }
295
289
  if (!this.boolValue(setting)) {
296
290
  return true;
297
291
  }
298
292
  return !this.isEmpty(value);
299
- };
300
- GDSDatetimeComponent.prototype.processField = function (field, defaults, fieldIndex) {
301
- var fieldValue = this.refs["".concat(field)] ? parseInt(this.refs["".concat(field)].value, 10) : undefined;
293
+ }
294
+ processField(field, defaults, fieldIndex) {
295
+ const refKey = field;
296
+ const ref = this.refs[refKey];
297
+ const inputRef = ref instanceof HTMLInputElement ? ref : undefined;
298
+ let fieldValue = inputRef ? parseInt(inputRef.value, 10) : undefined;
302
299
  if (fieldValue === undefined || _.isNaN(fieldValue)) {
303
- fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? defaults[fieldIndex] : 0;
300
+ fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? Number(defaults[fieldIndex]) : 0;
304
301
  }
305
302
  return fieldValue;
306
- };
307
- return GDSDatetimeComponent;
308
- }(Day));
303
+ }
304
+ }
309
305
  exports.default = GDSDatetimeComponent;
@@ -1,9 +1,12 @@
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 GDSDataMap_1 = require("./datamap/GDSDataMap");
4
- var GDSDatetimeComponent_1 = require("./datetime/GDSDatetimeComponent");
5
- var GDSCheckBoxes_1 = require("./selectboxes/GDSCheckBoxes");
6
- var GDSTimeComponent_1 = require("./time/GDSTimeComponent");
6
+ const GDSDataMap_1 = __importDefault(require("./datamap/GDSDataMap"));
7
+ const GDSDatetimeComponent_1 = __importDefault(require("./datetime/GDSDatetimeComponent"));
8
+ const GDSCheckBoxes_1 = __importDefault(require("./selectboxes/GDSCheckBoxes"));
9
+ const GDSTimeComponent_1 = __importDefault(require("./time/GDSTimeComponent"));
7
10
  exports.default = {
8
11
  datamap: GDSDataMap_1.default,
9
12
  datetime: GDSDatetimeComponent_1.default,
@@ -1,5 +1,7 @@
1
- declare const SelectBoxes: import("formiojs").ClassWithEditForm<typeof import("formiojs/types/components/_classes/field/field").Field>;
1
+ import { SelectBoxesComponent } from '../../types';
2
+ declare const SelectBoxes: any;
2
3
  export default class GDSCheckBoxes extends SelectBoxes {
3
- render(): any;
4
+ component: SelectBoxesComponent;
5
+ render(): string;
4
6
  }
5
7
  export {};
@@ -1,43 +1,17 @@
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 SelectBoxes = formiojs_1.Components.components.selectboxes;
21
- var GDSCheckBoxes = /** @class */ (function (_super) {
22
- __extends(GDSCheckBoxes, _super);
23
- function GDSCheckBoxes() {
24
- return _super !== null && _super.apply(this, arguments) || this;
25
- }
26
- GDSCheckBoxes.prototype.render = function () {
27
- // @ts-ignore
3
+ const js_1 = require("@formio/js");
4
+ const Field = js_1.Components.components.field;
5
+ const SelectBoxes = js_1.Components.components.selectboxes;
6
+ class GDSCheckBoxes extends SelectBoxes {
7
+ render() {
28
8
  return Field.prototype.render.call(this, this.renderTemplate('selectboxes', {
29
- // @ts-ignore
30
9
  input: this.inputInfo,
31
- // @ts-ignore
32
10
  inline: this.component.inline,
33
- // @ts-ignore
34
11
  values: this.component.values,
35
- // @ts-ignore
36
12
  value: this.dataValue,
37
- // @ts-ignore
38
13
  row: this.row,
39
14
  }));
40
- };
41
- return GDSCheckBoxes;
42
- }(SelectBoxes));
15
+ }
16
+ }
43
17
  exports.default = GDSCheckBoxes;
@@ -1,18 +1,20 @@
1
- declare const Time: import("formiojs").ClassWithEditForm<typeof import("formiojs/types/components/_classes/widgetcomponent/widgetComponent").WidgetComponent>;
1
+ import { CoreTimeComponent } from '../../types';
2
+ declare const Time: any;
2
3
  export default class GDSTimeComponent extends Time {
3
4
  static MAX_LENGTH: number;
4
- private refs;
5
- private component;
6
- private loadRefs;
7
- private checkComponentValidity;
8
- private updateValue;
5
+ component: CoreTimeComponent;
6
+ refs: {
7
+ hour: HTMLInputElement;
8
+ minute: HTMLInputElement;
9
+ };
10
+ data: Record<string, unknown>;
9
11
  private timeHelper;
10
- attach(element: any): any;
12
+ attach(element: any): Promise<void>;
11
13
  setErrorClasses(elements: any, dirty: any, hasError: any): void;
12
- addInputError(message: any, dirty: boolean, element: any): void;
14
+ addInputError(message: any, dirty: any, element: any): void;
13
15
  removeInputError(elements: any): void;
14
16
  getValue(): string;
15
- setValue(value: any, flags: any): boolean;
16
- render(): any;
17
+ setValue(value: any, _flags: any): boolean;
18
+ render(): string;
17
19
  }
18
20
  export {};