@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.
- package/LICENCE.md +21 -0
- package/eslint.config.mjs +58 -0
- package/lib/components/datamap/GDSDataMap.d.ts +4 -14
- package/lib/components/datamap/GDSDataMap.js +9 -29
- package/lib/components/datetime/GDSDatetimeComponent.d.ts +30 -22
- package/lib/components/datetime/GDSDatetimeComponent.js +148 -178
- package/lib/components/index.js +4 -4
- package/lib/components/selectboxes/GDSCheckBoxes.d.ts +4 -2
- package/lib/components/selectboxes/GDSCheckBoxes.js +7 -33
- package/lib/components/time/GDSTimeComponent.d.ts +12 -10
- package/lib/components/time/GDSTimeComponent.js +59 -84
- package/lib/components/util/TimeHelper.d.ts +5 -4
- package/lib/components/util/TimeHelper.js +13 -16
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/templates/gds/button/index.js +1 -1
- package/lib/templates/gds/checkbox/index.js +1 -1
- package/lib/templates/gds/columns/index.js +1 -1
- package/lib/templates/gds/component/index.js +1 -1
- package/lib/templates/gds/container/index.js +1 -1
- package/lib/templates/gds/datagrid/index.js +1 -1
- package/lib/templates/gds/datamap/index.js +1 -1
- package/lib/templates/gds/datetime/index.js +1 -1
- package/lib/templates/gds/day/index.js +1 -1
- package/lib/templates/gds/editgrid/index.js +1 -1
- package/lib/templates/gds/field/index.js +1 -1
- package/lib/templates/gds/fieldset/index.js +1 -1
- package/lib/templates/gds/file/index.js +1 -1
- package/lib/templates/gds/iconClass.d.ts +1 -1
- package/lib/templates/gds/iconClass.js +3 -3
- package/lib/templates/gds/index.d.ts +2 -2
- package/lib/templates/gds/index.js +72 -64
- package/lib/templates/gds/input/index.js +1 -1
- package/lib/templates/gds/label/index.js +1 -1
- package/lib/templates/gds/message/index.js +1 -1
- package/lib/templates/gds/panel/index.js +1 -1
- package/lib/templates/gds/radio/index.js +1 -1
- package/lib/templates/gds/select/index.js +1 -1
- package/lib/templates/gds/selectOption/index.js +1 -1
- package/lib/templates/gds/selectboxes/index.js +1 -1
- package/lib/templates/gds/survey/index.js +1 -1
- package/lib/templates/gds/tab/index.js +1 -1
- package/lib/templates/gds/table/index.js +1 -1
- package/lib/templates/gds/template.css +16 -0
- package/lib/templates/gds/template.css.map +1 -1
- package/lib/templates/gds/time/index.js +1 -1
- package/lib/templates/gds/warning/index.js +1 -1
- package/lib/templates/gds/wizard/index.js +1 -1
- package/lib/templates/gds/wizardHeader/index.js +1 -1
- package/lib/templates/gds/wizardNav/index.js +1 -1
- package/lib/templates/index.d.ts +2 -2
- package/lib/templates/index.js +1 -1
- package/lib/types.d.ts +36 -0
- package/lib/types.js +2 -0
- package/package.json +13 -7
- package/src/components/datamap/GDSDataMap.ts +5 -14
- package/src/components/datetime/GDSDatetimeComponent.ts +109 -91
- package/src/components/selectboxes/GDSCheckBoxes.ts +7 -8
- package/src/components/time/GDSTimeComponent.ts +37 -27
- package/src/components/util/TimeHelper.ts +6 -5
- package/src/css.d.ts +4 -0
- package/src/templates/gds/iconClass.ts +1 -1
- package/src/templates/gds/index.ts +43 -33
- package/src/templates/gds/template.scss +30 -1
- package/src/types.ts +55 -0
- package/tsconfig.json +6 -3
- package/webpack.config.js +1 -1
- 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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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',
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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',
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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',
|
|
141
|
-
|
|
92
|
+
this.addEventListener(this.refs.year, 'input', () => {
|
|
93
|
+
this.timeHelper.validateDateInput(this.refs.year, 4);
|
|
142
94
|
});
|
|
143
|
-
this.addEventListener(this.refs.day, 'input',
|
|
144
|
-
|
|
95
|
+
this.addEventListener(this.refs.day, 'input', () => {
|
|
96
|
+
this.timeHelper.validateDateInput(this.refs.day, 2);
|
|
145
97
|
});
|
|
146
|
-
this.addEventListener(this.refs.month, 'input',
|
|
147
|
-
|
|
98
|
+
this.addEventListener(this.refs.month, 'input', () => {
|
|
99
|
+
this.timeHelper.validateDateInput(this.refs.month, 2);
|
|
148
100
|
});
|
|
149
101
|
return superAttach;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.
|
|
155
|
-
this.
|
|
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',
|
|
162
|
-
|
|
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',
|
|
166
|
-
|
|
120
|
+
type: 'number',
|
|
121
|
+
placeholder: 'MM',
|
|
122
|
+
required: (_j = this.component.validate) === null || _j === void 0 ? void 0 : _j.required,
|
|
167
123
|
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
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
|
-
|
|
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 (
|
|
163
|
+
catch (_a) {
|
|
204
164
|
// ignored
|
|
205
165
|
}
|
|
206
166
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
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
|
-
|
|
227
|
-
|
|
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 (
|
|
209
|
+
catch (_a) {
|
|
248
210
|
return null;
|
|
249
211
|
}
|
|
250
212
|
}
|
|
251
213
|
return null;
|
|
252
|
-
}
|
|
253
|
-
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
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
|
-
|
|
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
|
-
|
|
290
|
-
//
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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 && (
|
|
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 && (
|
|
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
|
-
|
|
327
|
-
|
|
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
|
-
|
|
334
|
-
}(Day));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
335
305
|
exports.default = GDSDatetimeComponent;
|
package/lib/components/index.js
CHANGED
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
1
|
+
import { SelectBoxesComponent } from '../../types';
|
|
2
|
+
declare const SelectBoxes: any;
|
|
2
3
|
export default class GDSCheckBoxes extends SelectBoxes {
|
|
3
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
42
|
-
}(SelectBoxes));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
43
17
|
exports.default = GDSCheckBoxes;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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):
|
|
12
|
+
attach(element: any): Promise<void>;
|
|
11
13
|
setErrorClasses(elements: any, dirty: any, hasError: any): void;
|
|
12
|
-
addInputError(message: any, dirty:
|
|
14
|
+
addInputError(message: any, dirty: any, element: any): void;
|
|
13
15
|
removeInputError(elements: any): void;
|
|
14
16
|
getValue(): string;
|
|
15
|
-
setValue(value: any,
|
|
16
|
-
render():
|
|
17
|
+
setValue(value: any, _flags: any): boolean;
|
|
18
|
+
render(): string;
|
|
17
19
|
}
|
|
18
20
|
export {};
|