@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
@@ -1,19 +1,4 @@
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
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
3
  if (k2 === undefined) k2 = k;
19
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -37,95 +22,62 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
22
  __setModuleDefault(result, mod);
38
23
  return result;
39
24
  };
40
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
41
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
42
- if (ar || !(i in from)) {
43
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
44
- ar[i] = from[i];
45
- }
46
- }
47
- return to.concat(ar || Array.prototype.slice.call(from));
48
- };
49
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
27
  };
52
28
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var formiojs_1 = require("formiojs");
54
- var utils_1 = __importDefault(require("formiojs/utils"));
55
- var _ = __importStar(require("lodash"));
56
- var moment_1 = __importDefault(require("moment"));
57
- var TimeHelper_1 = __importDefault(require("../util/TimeHelper"));
58
- var Field = formiojs_1.Components.components.field;
59
- var Day = formiojs_1.Components.components.day;
60
- // @ts-ignore
61
- var GDSDatetimeComponent = /** @class */ (function (_super) {
62
- __extends(GDSDatetimeComponent, _super);
63
- function GDSDatetimeComponent() {
64
- var _this = _super !== null && _super.apply(this, arguments) || this;
65
- _this.timeHelper = new TimeHelper_1.default();
66
- 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();
67
40
  }
68
- Object.defineProperty(GDSDatetimeComponent.prototype, "format", {
69
- get: function () {
70
- return 'DD-MM-YYYY';
71
- },
72
- enumerable: false,
73
- configurable: true
74
- });
75
- Object.defineProperty(GDSDatetimeComponent.prototype, "defaultValue", {
76
- // @ts-ignore
77
- get: function () {
78
- var defaultValue = this.component.defaultValue;
79
- if (!defaultValue && this.component.defaultDate) {
80
- defaultValue = utils_1.default.getDateSetting(this.component.defaultDate);
81
- defaultValue = defaultValue ? (0, moment_1.default)(defaultValue).format() : '';
82
- }
83
- return defaultValue;
84
- },
85
- enumerable: false,
86
- configurable: true
87
- });
88
- Object.defineProperty(GDSDatetimeComponent.prototype, "emptyValue", {
89
- // @ts-ignore
90
- get: function () {
91
- return null;
92
- },
93
- enumerable: false,
94
- configurable: true
95
- });
96
- Object.defineProperty(GDSDatetimeComponent.prototype, "parts", {
97
- get: function () {
98
- return {
99
- day: this.getFieldValue('day'),
100
- month: this.getFieldValue('month'),
101
- year: this.getFieldValue('year'),
102
- hour: this.getFieldValue('hour'),
103
- minute: this.getFieldValue('minute'),
104
- };
105
- },
106
- enumerable: false,
107
- configurable: true
108
- });
109
- GDSDatetimeComponent.prototype.attach = function (element) {
110
- 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) {
111
67
  this.loadRefs(element, { hour: 'single', minute: 'single' });
112
- this.addEventListener(this.refs.hour, 'input', function () {
113
- _this.timeHelper.checkAndValidateHour(_this.refs.hour);
114
- _this.setPristine(false);
115
- _this.checkComponentValidity(_this.data, true);
116
- _this.updateValue(null, {
117
- modified: true,
118
- });
119
- _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();
120
74
  });
121
- this.addEventListener(this.refs.minute, 'input', function () {
122
- _this.timeHelper.checkAndValidateMinutes(_this.refs.minute);
123
- _this.setPristine(false);
124
- _this.checkComponentValidity(_this.data, true);
125
- _this.updateValue(null, {
126
- modified: true,
127
- });
128
- _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();
129
81
  });
130
82
  this.addEventListener(this.refs.hour, 'keypress', this.timeHelper.preventNonNumericKeyPress);
131
83
  this.addEventListener(this.refs.minute, 'keypress', this.timeHelper.preventNonNumericKeyPress);
@@ -133,48 +85,54 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
133
85
  this.setDisabled(this.refs.hour, true);
134
86
  this.setDisabled(this.refs.minute, true);
135
87
  }
136
- var superAttach = _super.prototype.attach.call(this, element);
88
+ const superAttach = super.attach(element);
137
89
  this.addEventListener(this.refs.year, 'keypress', this.timeHelper.preventNonNumericKeyPress);
138
90
  this.addEventListener(this.refs.month, 'keypress', this.timeHelper.preventNonNumericKeyPress);
139
91
  this.addEventListener(this.refs.day, 'keypress', this.timeHelper.preventNonNumericKeyPress);
140
- this.addEventListener(this.refs.year, 'input', function () {
141
- _this.timeHelper.validateDateInput(_this.refs.year, 4);
92
+ this.addEventListener(this.refs.year, 'input', () => {
93
+ this.timeHelper.validateDateInput(this.refs.year, 4);
142
94
  });
143
- this.addEventListener(this.refs.day, 'input', function () {
144
- _this.timeHelper.validateDateInput(_this.refs.day, 2);
95
+ this.addEventListener(this.refs.day, 'input', () => {
96
+ this.timeHelper.validateDateInput(this.refs.day, 2);
145
97
  });
146
- this.addEventListener(this.refs.month, 'input', function () {
147
- _this.timeHelper.validateDateInput(_this.refs.month, 2);
98
+ this.addEventListener(this.refs.month, 'input', () => {
99
+ this.timeHelper.validateDateInput(this.refs.month, 2);
148
100
  });
149
101
  return superAttach;
150
- };
151
- GDSDatetimeComponent.prototype.init = function () {
152
- _super.prototype.init.call(this);
153
- this.validators = this.validators.filter(function (v) { return v !== 'day'; }).concat(['date']);
154
- this.component.maxDate = this.component.datePicker.maxDate;
155
- 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;
156
110
  this.component.suffix = null;
157
- this.component.fields.day.required = this.component.validate.required;
158
- this.component.fields.month.required = this.component.validate.required;
159
- 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;
160
114
  this.component.fields.hour = {
161
- type: 'number', placeholder: 'HH',
162
- 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,
163
118
  };
164
119
  this.component.fields.minute = {
165
- type: 'number', placeholder: 'MM',
166
- 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,
167
123
  };
168
- };
169
- GDSDatetimeComponent.prototype.setErrorClasses = function (elements, dirty, hasError) {
170
- // @ts-ignore
171
- _super.prototype.setErrorClasses.call(this, __spreadArray([this.refs.hour, this.refs.minute], elements, true), dirty, hasError);
172
- };
173
- GDSDatetimeComponent.prototype.removeInputError = function (elements) {
174
- // @ts-ignore
175
- _super.prototype.removeInputError.call(this, __spreadArray([this.refs.hour, this.refs.minute], elements, true));
176
- };
177
- 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() {
178
136
  return Field.prototype.render.call(this, this.renderTemplate('datetime', {
179
137
  component: this.component,
180
138
  dataValue: this.dataValue,
@@ -186,45 +144,49 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
186
144
  hour: this.renderField('hour'),
187
145
  minute: this.renderField('minute'),
188
146
  }));
189
- };
190
- GDSDatetimeComponent.prototype.getDate = function (value) {
191
- var defaults = [];
192
- var _a = [0, 1, 2, 3, 4], DAY = _a[0], MONTH = _a[1], YEAR = _a[2], HOUR = _a[3], MINUTE = _a[4];
193
- 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;
194
154
  if (defaultValue) {
195
155
  try {
196
- var defaultDate = (0, moment_1.default)(defaultValue);
156
+ const defaultDate = (0, moment_1.default)(defaultValue);
197
157
  defaults[DAY] = defaultDate.format('DD');
198
158
  defaults[MONTH] = defaultDate.format('MM');
199
159
  defaults[YEAR] = defaultDate.format('YYYY');
200
160
  defaults[HOUR] = defaultDate.format('HH');
201
161
  defaults[MINUTE] = defaultDate.format('mm');
202
162
  }
203
- catch (e) {
163
+ catch (_a) {
204
164
  // ignored
205
165
  }
206
166
  }
207
- var day = this.processField('day', defaults, DAY);
208
- var month = this.processField('month', defaults, MONTH);
209
- var year = this.processField('year', defaults, YEAR);
210
- var hour = this.processField('hour', defaults, HOUR);
211
- 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);
212
172
  if (!day && !month && !year && (!hour && !minute)) {
213
173
  return null;
214
174
  }
215
- day = day.toString().padStart(2, 0);
216
- month = month.toString().padStart(2, 0);
217
- year = year.toString().padStart(4, 0);
218
- hour = hour.toString().padStart(2, 0);
219
- minute = minute.toString().padStart(2, 0);
220
- var toMoment = (0, moment_1.default)("".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');
221
181
  return toMoment.format();
222
- };
223
- 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) {
224
186
  if (this.dataValue && this.dataValue !== 'Invalid date') {
225
187
  try {
226
- var val = null;
227
- var date = (0, moment_1.default)(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');
228
190
  switch (name) {
229
191
  case 'month':
230
192
  val = date.format('MM');
@@ -244,13 +206,13 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
244
206
  }
245
207
  return val;
246
208
  }
247
- catch (e) {
209
+ catch (_a) {
248
210
  return null;
249
211
  }
250
212
  }
251
213
  return null;
252
- };
253
- GDSDatetimeComponent.prototype.boolValue = function (value) {
214
+ }
215
+ boolValue(value) {
254
216
  if (_.isBoolean(value)) {
255
217
  return value;
256
218
  }
@@ -260,14 +222,15 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
260
222
  else {
261
223
  return !!value;
262
224
  }
263
- };
264
- GDSDatetimeComponent.prototype.setValueAt = function (index, value) {
265
- // temporary solution to avoid input reset
266
- // 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.
267
230
  if (!value || value === 'Invalid date') {
268
231
  return;
269
232
  }
270
- var date = (0, moment_1.default)(value, moment_1.default.ISO_8601);
233
+ const date = (0, moment_1.default)(value, moment_1.default.ISO_8601);
271
234
  if (date.isValid()) {
272
235
  if (this.refs.day) {
273
236
  this.refs.day.value = date.format('DD');
@@ -285,10 +248,10 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
285
248
  this.refs.minute.value = date.format('mm');
286
249
  }
287
250
  }
288
- };
289
- GDSDatetimeComponent.prototype.getValueAt = function (index) {
290
- // @ts-ignore
291
- 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;
292
255
  if (date) {
293
256
  this.refs.input[index].value = date;
294
257
  return this.refs.input[index].value;
@@ -297,39 +260,46 @@ var GDSDatetimeComponent = /** @class */ (function (_super) {
297
260
  this.refs.input[index].value = '';
298
261
  return null;
299
262
  }
300
- };
301
- 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) {
302
267
  return value;
303
- };
304
- GDSDatetimeComponent.prototype.validateRequired = function (setting, value) {
305
- var _a = this.parts, day = _a.day, month = _a.month, year = _a.year, minute = _a.minute, hour = _a.hour;
306
- 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)) {
307
275
  return false;
308
276
  }
309
- 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)) {
310
278
  return false;
311
279
  }
312
- 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)) {
313
281
  return false;
314
282
  }
315
- 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)) {
316
284
  return false;
317
285
  }
318
- 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)) {
319
287
  return false;
320
288
  }
321
289
  if (!this.boolValue(setting)) {
322
290
  return true;
323
291
  }
324
292
  return !this.isEmpty(value);
325
- };
326
- GDSDatetimeComponent.prototype.processField = function (field, defaults, fieldIndex) {
327
- 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;
328
299
  if (fieldValue === undefined || _.isNaN(fieldValue)) {
329
- fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? defaults[fieldIndex] : 0;
300
+ fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? Number(defaults[fieldIndex]) : 0;
330
301
  }
331
302
  return fieldValue;
332
- };
333
- return GDSDatetimeComponent;
334
- }(Day));
303
+ }
304
+ }
335
305
  exports.default = GDSDatetimeComponent;
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var GDSDataMap_1 = __importDefault(require("./datamap/GDSDataMap"));
7
- var GDSDatetimeComponent_1 = __importDefault(require("./datetime/GDSDatetimeComponent"));
8
- var GDSCheckBoxes_1 = __importDefault(require("./selectboxes/GDSCheckBoxes"));
9
- var GDSTimeComponent_1 = __importDefault(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"));
10
10
  exports.default = {
11
11
  datamap: GDSDataMap_1.default,
12
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 {};