@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,34 +1,54 @@
1
- import {Components} from 'formiojs';
2
- import FormioUtils from 'formiojs/utils';
1
+ import { Components } from '@formio/js';
2
+ import { Utils as FormioUtils } from '@formio/js';
3
3
  import * as _ from 'lodash';
4
- import * as moment from 'moment';
4
+ import moment from 'moment';
5
5
  import TimeHelper from '../util/TimeHelper';
6
+ import { GDSDatetimeComponentSchema } from '../../types';
6
7
 
7
8
  const Field = Components.components.field;
8
9
  const Day = Components.components.day;
9
10
 
10
- // @ts-ignore
11
11
  export default class GDSDatetimeComponent extends Day {
12
12
 
13
- get format() {
13
+ // Narrow the inherited `component: any` to the GDS datetime schema type.
14
+ // @formio/core provides the DayComponent + DateTimeComponent shapes;
15
+ // GDSDatetimeComponentSchema extends them with hour/minute fields.
16
+ declare component: GDSDatetimeComponentSchema;
17
+
18
+ // Narrow inherited base-class properties from `any` / `{}` to precise types.
19
+ // `declare` emits no runtime code — it only refines the type in this subclass.
20
+ declare refs: {
21
+ hour: HTMLInputElement;
22
+ minute: HTMLInputElement;
23
+ day: HTMLInputElement;
24
+ month: HTMLInputElement;
25
+ year: HTMLInputElement;
26
+ input: HTMLInputElement[];
27
+ };
28
+ declare dataValue: string;
29
+ declare data: Record<string, unknown>;
30
+ declare validators: string[];
31
+ declare shouldDisabled: boolean;
32
+ declare triggerChange: () => void;
33
+
34
+ get format(): string {
14
35
  return 'DD-MM-YYYY';
15
36
  }
16
- // @ts-ignore
17
- get defaultValue() {
37
+
38
+ get defaultValue(): string {
18
39
  let defaultValue = this.component.defaultValue;
19
40
  if (!defaultValue && this.component.defaultDate) {
20
41
  defaultValue = FormioUtils.getDateSetting(this.component.defaultDate);
21
42
  defaultValue = defaultValue ? moment(defaultValue).format() : '';
22
43
  }
23
- return defaultValue;
44
+ return defaultValue ?? '';
24
45
  }
25
46
 
26
- // @ts-ignore
27
- get emptyValue() {
47
+ get emptyValue(): null {
28
48
  return null;
29
49
  }
30
50
 
31
- get parts() {
51
+ get parts(): { day: string | null; month: string | null; year: string | null; hour: string | null; minute: string | null } {
32
52
  return {
33
53
  day: this.getFieldValue('day'),
34
54
  month: this.getFieldValue('month'),
@@ -38,25 +58,18 @@ export default class GDSDatetimeComponent extends Day {
38
58
  };
39
59
  }
40
60
 
41
- private refs: any;
42
- private component: any;
43
- private updateValue: any;
44
- private renderField: any;
45
- private inputDefinition: any;
46
- private checkComponentValidity: any;
47
- private triggerChange: any;
48
-
49
61
  private timeHelper: TimeHelper = new TimeHelper();
50
62
 
51
- public attach(element: any) {
52
- this.loadRefs(element, {hour: 'single', minute: 'single'});
63
+ // element typed as `any` to match the base Day.attach(element: any) override signature
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ public attach(element: any): Promise<void> {
66
+ this.loadRefs(element, { hour: 'single', minute: 'single' });
67
+
53
68
  this.addEventListener(this.refs.hour, 'input', () => {
54
69
  this.timeHelper.checkAndValidateHour(this.refs.hour);
55
70
  this.setPristine(false);
56
71
  this.checkComponentValidity(this.data, true);
57
- this.updateValue(null, {
58
- modified: true,
59
- });
72
+ this.updateValue(null, { modified: true });
60
73
  this.triggerChange();
61
74
  });
62
75
 
@@ -64,9 +77,7 @@ export default class GDSDatetimeComponent extends Day {
64
77
  this.timeHelper.checkAndValidateMinutes(this.refs.minute);
65
78
  this.setPristine(false);
66
79
  this.checkComponentValidity(this.data, true);
67
- this.updateValue(null, {
68
- modified: true,
69
- });
80
+ this.updateValue(null, { modified: true });
70
81
  this.triggerChange();
71
82
  });
72
83
 
@@ -94,42 +105,46 @@ export default class GDSDatetimeComponent extends Day {
94
105
  this.timeHelper.validateDateInput(this.refs.month, 2);
95
106
  });
96
107
 
97
-
98
108
  return superAttach;
99
109
  }
100
110
 
101
- public init() {
111
+ public init(): void {
102
112
  super.init();
103
- this.validators = this.validators.filter((v) => v !== 'day').concat(['date']);
113
+ // @formio/js@5.x: this.validators is not pre-populated by the base class; guard before filtering
114
+ this.validators = (this.validators || []).filter((v) => v !== 'day').concat(['date']);
104
115
 
105
- this.component.maxDate = this.component.datePicker.maxDate;
106
- this.component.minDate = this.component.datePicker.minDate;
116
+ this.component.maxDate = this.component.datePicker?.maxDate ?? undefined;
117
+ this.component.minDate = this.component.datePicker?.minDate ?? undefined;
107
118
  this.component.suffix = null;
108
119
 
109
- this.component.fields.day.required = this.component.validate.required;
110
- this.component.fields.month.required = this.component.validate.required;
111
- this.component.fields.year.required = this.component.validate.required;
120
+ this.component.fields.day.required = this.component.validate?.required;
121
+ this.component.fields.month.required = this.component.validate?.required;
122
+ this.component.fields.year.required = this.component.validate?.required;
112
123
  this.component.fields.hour = {
113
- type: 'number', placeholder: 'HH',
114
- required: this.component.validate.required,
124
+ type: 'number',
125
+ placeholder: 'HH',
126
+ required: this.component.validate?.required,
115
127
  };
116
128
  this.component.fields.minute = {
117
- type: 'number', placeholder: 'MM',
118
- required: this.component.validate.required,
129
+ type: 'number',
130
+ placeholder: 'MM',
131
+ required: this.component.validate?.required,
119
132
  };
120
133
  }
121
134
 
122
- public setErrorClasses(elements, dirty, hasError) {
123
- // @ts-ignore
124
- super.setErrorClasses( [this.refs.hour, this.refs.minute, ...elements], dirty, hasError);
135
+ // elements typed as `any` to match the base Day.setErrorClasses(elements: any, ...) override signature
136
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
+ public setErrorClasses(elements: any, dirty: any, hasError: any): void {
138
+ super.setErrorClasses([this.refs.hour, this.refs.minute, ...elements], dirty, hasError);
125
139
  }
126
140
 
127
- public removeInputError(elements) {
128
- // @ts-ignore
141
+ // elements typed as `any` to match the base Component.removeInputError(elements: any) signature
142
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
+ public removeInputError(elements: any): void {
129
144
  super.removeInputError([this.refs.hour, this.refs.minute, ...elements]);
130
145
  }
131
146
 
132
- public render() {
147
+ public render(): string {
133
148
  return Field.prototype.render.call(this, this.renderTemplate('datetime', {
134
149
  component: this.component,
135
150
  dataValue: this.dataValue,
@@ -143,8 +158,10 @@ export default class GDSDatetimeComponent extends Day {
143
158
  }));
144
159
  }
145
160
 
146
- public getDate(value) {
147
- const defaults = [];
161
+ // value typed as `any` to match the base Day.getDate(value: any): null | string signature
162
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
163
+ public getDate(value: any): string | null {
164
+ const defaults: Array<string | number | undefined> = [];
148
165
  const [DAY, MONTH, YEAR, HOUR, MINUTE] = [0, 1, 2, 3, 4];
149
166
  const defaultValue = value || this.component.defaultValue;
150
167
 
@@ -156,35 +173,37 @@ export default class GDSDatetimeComponent extends Day {
156
173
  defaults[YEAR] = defaultDate.format('YYYY');
157
174
  defaults[HOUR] = defaultDate.format('HH');
158
175
  defaults[MINUTE] = defaultDate.format('mm');
159
- } catch (e) {
176
+ } catch {
160
177
  // ignored
161
178
  }
162
179
  }
163
180
 
164
- let day: any = this.processField('day', defaults, DAY);
165
- let month: any = this.processField('month', defaults, MONTH);
166
- let year: any = this.processField('year', defaults, YEAR);
167
- let hour: any = this.processField('hour', defaults, HOUR);
168
- let minute: any = this.processField('minute', defaults, MINUTE);
181
+ const day: number = this.processField('day', defaults, DAY);
182
+ const month: number = this.processField('month', defaults, MONTH);
183
+ const year: number = this.processField('year', defaults, YEAR);
184
+ const hour: number = this.processField('hour', defaults, HOUR);
185
+ const minute: number = this.processField('minute', defaults, MINUTE);
169
186
 
170
187
  if (!day && !month && !year && (!hour && !minute)) {
171
188
  return null;
172
189
  }
173
190
 
174
- day = day.toString().padStart(2, 0);
175
- month = month.toString().padStart(2, 0);
176
- year = year.toString().padStart(4, 0);
177
- hour = hour.toString().padStart(2, 0);
178
- minute = minute.toString().padStart(2, 0);
191
+ const dayStr = day.toString().padStart(2, '0');
192
+ const monthStr = month.toString().padStart(2, '0');
193
+ const yearStr = year.toString().padStart(4, '0');
194
+ const hourStr = hour.toString().padStart(2, '0');
195
+ const minuteStr = minute.toString().padStart(2, '0');
179
196
 
180
- const toMoment = moment(`${year}-${month}-${day} ${hour}:${minute}`, 'YYYY-MM-DD HH:mm');
197
+ const toMoment = moment(`${yearStr}-${monthStr}-${dayStr} ${hourStr}:${minuteStr}`, 'YYYY-MM-DD HH:mm');
181
198
  return toMoment.format();
182
199
  }
183
200
 
184
- public getFieldValue(name) {
201
+ // name typed as `any` to match the base Day.getFieldValue(name: any): number signature
202
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
203
+ public getFieldValue(name: any): string | null {
185
204
  if (this.dataValue && this.dataValue !== 'Invalid date') {
186
205
  try {
187
- let val = null;
206
+ let val: string | null = null;
188
207
  const date = moment(this.dataValue, 'YYYY-MM-DD HH:mm');
189
208
 
190
209
  switch (name) {
@@ -205,27 +224,27 @@ export default class GDSDatetimeComponent extends Day {
205
224
  break;
206
225
  }
207
226
  return val;
208
- } catch (e) {
227
+ } catch {
209
228
  return null;
210
229
  }
211
230
  }
212
231
  return null;
213
232
  }
214
233
 
215
- public boolValue(value) {
234
+ public boolValue(value: unknown): boolean {
216
235
  if (_.isBoolean(value)) {
217
236
  return value;
218
- }
219
- else if (_.isString(value)) {
237
+ } else if (_.isString(value)) {
220
238
  return (value.toLowerCase() === 'true');
221
- }
222
- else {
239
+ } else {
223
240
  return !!value;
224
241
  }
225
242
  }
226
- public setValueAt(index, value) {
227
- // temporary solution to avoid input reset
228
- // on invalid date.
243
+
244
+ // value typed as `any` to match the base Day.setValueAt(index: number, value: any) signature
245
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
246
+ public setValueAt(index: number, value: any): void {
247
+ // temporary solution to avoid input reset on invalid date.
229
248
  if (!value || value === 'Invalid date') {
230
249
  return;
231
250
  }
@@ -243,51 +262,48 @@ export default class GDSDatetimeComponent extends Day {
243
262
  if (this.refs.hour) {
244
263
  this.refs.hour.value = date.format('HH');
245
264
  }
246
-
247
265
  if (this.refs.minute) {
248
266
  this.refs.minute.value = date.format('mm');
249
267
  }
250
268
  }
251
-
252
269
  }
253
270
 
254
- public getValueAt(index) {
255
- // @ts-ignore
271
+ public getValueAt(index: number): string | null {
272
+ // `date` is a public getter declared on DayComponent: get date(): string | null
256
273
  const date = this.date;
257
274
  if (date) {
258
275
  this.refs.input[index].value = date;
259
276
  return this.refs.input[index].value;
260
- }
261
- else {
277
+ } else {
262
278
  this.refs.input[index].value = '';
263
279
  return null;
264
280
  }
265
281
  }
266
282
 
267
- public normalizeValue(value) {
283
+ // value typed as `any` to match the base Component.normalizeValue(value: any): any signature
284
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
285
+ public normalizeValue(value: any): any {
268
286
  return value;
269
287
  }
270
288
 
271
- public validateRequired(setting, value) {
272
- const {day, month, year, minute, hour} = this.parts;
289
+ // setting/value typed as `any` to match the base Day.validateRequired(setting: any, value: any) signature
290
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
291
+ public validateRequired(setting: any, value: any): boolean {
292
+ const { day, month, year, minute, hour } = this.parts;
273
293
 
274
- if (this.component.validate.required && (!day || parseInt(day, 10) === 0)) {
294
+ if (this.component.validate?.required && (!day || parseInt(day, 10) === 0)) {
275
295
  return false;
276
296
  }
277
-
278
- if (this.component.validate.required && (!month || parseInt(month, 10) === 0)) {
297
+ if (this.component.validate?.required && (!month || parseInt(month, 10) === 0)) {
279
298
  return false;
280
299
  }
281
-
282
- if (this.component.validate.required && (!year || parseInt(year, 10) === 0)) {
300
+ if (this.component.validate?.required && (!year || parseInt(year, 10) === 0)) {
283
301
  return false;
284
302
  }
285
-
286
- if (this.component.validate.required && ((this.refs.minute && this.refs.minute.value === '') || !minute)) {
303
+ if (this.component.validate?.required && (this.refs.minute.value === '' || !minute)) {
287
304
  return false;
288
305
  }
289
-
290
- if (this.component.validate.required && ((this.refs.hour && this.refs.hour.value === '') || !hour)) {
306
+ if (this.component.validate?.required && (this.refs.hour.value === '' || !hour)) {
291
307
  return false;
292
308
  }
293
309
 
@@ -297,13 +313,15 @@ export default class GDSDatetimeComponent extends Day {
297
313
  return !this.isEmpty(value);
298
314
  }
299
315
 
300
- private processField(field: string, defaults: any[], fieldIndex: number) {
301
- let fieldValue = this.refs[`${field}`] ? parseInt(this.refs[`${field}`].value, 10) : undefined;
316
+ private processField(field: string, defaults: Array<string | number | undefined>, fieldIndex: number): number {
317
+ const refKey = field as keyof typeof this.refs;
318
+ const ref = this.refs[refKey];
319
+ const inputRef = ref instanceof HTMLInputElement ? ref : undefined;
320
+ let fieldValue: number | undefined = inputRef ? parseInt(inputRef.value, 10) : undefined;
302
321
  if (fieldValue === undefined || _.isNaN(fieldValue)) {
303
- fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? defaults[fieldIndex] : 0;
322
+ fieldValue = defaults[fieldIndex] && !_.isNaN(defaults[fieldIndex]) ? Number(defaults[fieldIndex]) : 0;
304
323
  }
305
324
  return fieldValue;
306
-
307
325
  }
308
326
 
309
327
  }
@@ -1,20 +1,19 @@
1
- import {Components} from 'formiojs';
1
+ import { Components } from '@formio/js';
2
+ import { SelectBoxesComponent } from '../../types';
3
+
2
4
  const Field = Components.components.field;
3
5
  const SelectBoxes = Components.components.selectboxes;
4
6
 
5
7
  export default class GDSCheckBoxes extends SelectBoxes {
6
- public render() {
7
- // @ts-ignore
8
+ // Narrow the inherited `component: any` using the @formio/core SelectBoxesComponent schema.
9
+ declare component: SelectBoxesComponent;
10
+
11
+ public render(): string {
8
12
  return Field.prototype.render.call(this, this.renderTemplate('selectboxes', {
9
- // @ts-ignore
10
13
  input: this.inputInfo,
11
- // @ts-ignore
12
14
  inline: this.component.inline,
13
- // @ts-ignore
14
15
  values: this.component.values,
15
- // @ts-ignore
16
16
  value: this.dataValue,
17
- // @ts-ignore
18
17
  row: this.row,
19
18
  }));
20
19
  }
@@ -1,23 +1,31 @@
1
- import {Components} from 'formiojs';
2
- import * as moment from 'moment';
1
+ import { Components } from '@formio/js';
2
+ import moment from 'moment';
3
3
  import TimeHelper from '../util/TimeHelper';
4
+ import { CoreTimeComponent } from '../../types';
4
5
 
5
6
  const Field = Components.components.field;
6
7
  const Time = Components.components.time;
7
8
 
8
- // @ts-ignore
9
9
  export default class GDSTimeComponent extends Time {
10
10
  public static MAX_LENGTH = 2;
11
11
 
12
- private refs: any;
13
- private component: any;
14
- private loadRefs: any;
15
- private checkComponentValidity: any;
16
- private updateValue: any;
12
+ // Narrow the inherited `component: any` using the @formio/core TimeComponent schema.
13
+ declare component: CoreTimeComponent;
14
+
15
+ // Narrow `refs: {}` to the specific refs loaded by this component.
16
+ declare refs: {
17
+ hour: HTMLInputElement;
18
+ minute: HTMLInputElement;
19
+ };
20
+
21
+ // Narrow `data: any` to a typed record.
22
+ declare data: Record<string, unknown>;
17
23
 
18
24
  private timeHelper: TimeHelper = new TimeHelper();
19
25
 
20
- public attach(element) {
26
+ // element typed as `any` to match the base component attach(element: any) override signature
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ public attach(element: any): Promise<void> {
21
29
  this.loadRefs(element, {
22
30
  hour: 'single',
23
31
  minute: 'single',
@@ -27,47 +35,48 @@ export default class GDSTimeComponent extends Time {
27
35
  this.timeHelper.checkAndValidateHour(this.refs.hour);
28
36
  this.setPristine(false);
29
37
  this.checkComponentValidity(this.data, true);
30
- this.updateValue(null, {modified: true});
38
+ this.updateValue(null, { modified: true });
31
39
  });
32
40
 
33
41
  this.addEventListener(this.refs.minute, 'input', () => {
34
42
  this.timeHelper.checkAndValidateMinutes(this.refs.minute);
35
43
  this.setPristine(false);
36
44
  this.checkComponentValidity(this.data, true);
37
- this.updateValue(null, {modified: true});
45
+ this.updateValue(null, { modified: true });
38
46
  });
39
47
 
40
- this.addEventListener(this.refs.hour, 'keypress', (evt) => {
48
+ this.addEventListener(this.refs.hour, 'keypress', (evt: KeyboardEvent) => {
41
49
  this.timeHelper.preventNonNumericKeyPress(evt);
42
50
  });
43
51
 
44
- this.addEventListener(this.refs.minute, 'keypress', (evt) => {
52
+ this.addEventListener(this.refs.minute, 'keypress', (evt: KeyboardEvent) => {
45
53
  this.timeHelper.preventNonNumericKeyPress(evt);
46
54
  });
55
+
47
56
  return super.attach(element);
48
57
  }
49
58
 
50
- public setErrorClasses(elements, dirty, hasError) {
51
- // @ts-ignore
52
- super.setErrorClasses( [this.refs.hour, this.refs.minute, ...elements], dirty, hasError);
59
+ // elements typed as `any` to match the base Day.setErrorClasses(elements: any, ...) override signature
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ public setErrorClasses(elements: any, dirty: any, hasError: any): void {
62
+ super.setErrorClasses([this.refs.hour, this.refs.minute, ...elements], dirty, hasError);
53
63
  }
54
64
 
55
- // @ts-ignore
56
- public addInputError(message: any, dirty: boolean, element: any): void {
57
- // @ts-ignore
65
+ // message/dirty/element typed as `any` to match the base Component.addInputError(message: any, dirty: any, elements: any) signature
66
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
+ public addInputError(message: any, dirty: any, element: any): void {
58
68
  super.addInputError(message, dirty, [this.refs.hour, this.refs.minute]);
59
- // @ts-ignore
60
69
  super.addInputError(message, dirty, element);
61
70
  }
62
71
 
63
- public removeInputError(elements) {
64
- // @ts-ignore
72
+ // elements typed as `any` to match the base Component.removeInputError(elements: any) signature
73
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
+ public removeInputError(elements: any): void {
65
75
  super.removeInputError([this.refs.hour, this.refs.minute]);
66
- // @ts-ignore
67
76
  super.removeInputError(elements);
68
77
  }
69
78
 
70
- public getValue() {
79
+ public getValue(): string {
71
80
  if (!this.refs.hour.value || !this.refs.minute.value) {
72
81
  return '';
73
82
  }
@@ -75,10 +84,11 @@ export default class GDSTimeComponent extends Time {
75
84
  return moment(value, this.component.format).format(this.component.dataFormat);
76
85
  }
77
86
 
78
- public setValue(value: any, flags: any) {
79
-
87
+ // value/flags typed as `any` to match the base Component.setValue(value: any, flags: any) override signature
88
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
+ public setValue(value: any, _flags: any): boolean {
80
90
  if (this.refs.hour && this.refs.minute && value) {
81
- const parts = value.split(':');
91
+ const parts = (value as string).split(':');
82
92
  this.refs.hour.value = parts[0];
83
93
  this.refs.minute.value = parts[1];
84
94
  return true;
@@ -86,7 +96,7 @@ export default class GDSTimeComponent extends Time {
86
96
  return false;
87
97
  }
88
98
 
89
- public render() {
99
+ public render(): string {
90
100
  return Field.prototype.render.call(this, this.renderTemplate('time', {
91
101
  hour: super.getValue().split(':')[0],
92
102
  minute: super.getValue().split(':')[1],
@@ -1,8 +1,10 @@
1
+ import { InputElementLike } from '../../types';
2
+
1
3
  export default class TimeHelper {
2
4
 
3
5
  public static MAX_LENGTH = 2;
4
6
 
5
- public checkAndValidateMinutes(element: any): void {
7
+ public checkAndValidateMinutes(element: InputElementLike): void {
6
8
  if (element.value) {
7
9
  if (element.value.length > TimeHelper.MAX_LENGTH) {
8
10
  element.value = element.value.slice(0, 2);
@@ -17,8 +19,7 @@ export default class TimeHelper {
17
19
  }
18
20
  }
19
21
 
20
- public checkAndValidateHour(element: any): void {
21
-
22
+ public checkAndValidateHour(element: InputElementLike): void {
22
23
  if (element.value) {
23
24
  if (element.value.length > TimeHelper.MAX_LENGTH) {
24
25
  element.value = element.value.slice(0, 2);
@@ -34,13 +35,13 @@ export default class TimeHelper {
34
35
  }
35
36
  }
36
37
 
37
- public preventNonNumericKeyPress(evt: any) {
38
+ public preventNonNumericKeyPress(evt: KeyboardEvent): void {
38
39
  if (evt.which !== 8 && evt.which !== 0 && evt.which < 48 || evt.which > 57) {
39
40
  evt.preventDefault();
40
41
  }
41
42
  }
42
43
 
43
- validateDateInput(element: any, length: number) {
44
+ public validateDateInput(element: InputElementLike, length: number): void {
44
45
  if (element.value && element.value.length > length) {
45
46
  element.value = element.value.slice(0, length);
46
47
  }
package/src/css.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ declare module '*.css' {
2
+ const content: string;
3
+ export default content;
4
+ }
@@ -1,5 +1,5 @@
1
1
  {%
2
- let columnWidth;
2
+ var columnWidth;
3
3
  var columnLength = ctx.columns.length;
4
4
  switch(columnLength) {
5
5
  case 1:
@@ -1,4 +1,4 @@
1
- export default (iconset, name, spinning) => {
1
+ export default (iconset: string, name: string, spinning: boolean): string => {
2
2
  if (iconset === 'fa') {
3
3
  switch (name) {
4
4
  case 'save':