@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.
- package/LICENCE.md +21 -0
- package/README.md +3 -1
- 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 +172 -176
- package/lib/components/index.js +7 -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 +62 -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 +5 -2
- package/lib/templates/gds/button/index.js +4 -1
- package/lib/templates/gds/checkbox/index.js +4 -1
- package/lib/templates/gds/columns/index.js +4 -1
- package/lib/templates/gds/component/index.js +4 -1
- package/lib/templates/gds/container/index.js +4 -1
- package/lib/templates/gds/datagrid/form.ejs.js +1 -1
- package/lib/templates/gds/datagrid/index.js +4 -1
- package/lib/templates/gds/datamap/index.js +4 -1
- package/lib/templates/gds/datetime/index.js +4 -1
- package/lib/templates/gds/day/index.js +4 -1
- package/lib/templates/gds/editgrid/index.js +4 -1
- package/lib/templates/gds/field/index.js +4 -1
- package/lib/templates/gds/fieldset/index.js +4 -1
- package/lib/templates/gds/file/index.js +4 -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 +75 -64
- package/lib/templates/gds/input/index.js +4 -1
- package/lib/templates/gds/label/index.js +4 -1
- package/lib/templates/gds/message/index.js +4 -1
- package/lib/templates/gds/panel/index.js +4 -1
- package/lib/templates/gds/radio/index.js +4 -1
- package/lib/templates/gds/select/index.js +4 -1
- package/lib/templates/gds/selectOption/index.js +4 -1
- package/lib/templates/gds/selectboxes/index.js +4 -1
- package/lib/templates/gds/survey/index.js +4 -1
- package/lib/templates/gds/tab/index.js +4 -1
- package/lib/templates/gds/table/index.js +4 -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 +4 -1
- package/lib/templates/gds/warning/index.js +4 -1
- package/lib/templates/gds/wizard/index.js +4 -1
- package/lib/templates/gds/wizardHeader/index.js +4 -1
- package/lib/templates/gds/wizardNav/index.js +4 -1
- package/lib/templates/index.d.ts +2 -2
- package/lib/templates/index.js +4 -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 +110 -92
- package/src/components/selectboxes/GDSCheckBoxes.ts +7 -8
- package/src/components/time/GDSTimeComponent.ts +38 -28
- package/src/components/util/TimeHelper.ts +6 -5
- package/src/css.d.ts +4 -0
- package/src/templates/gds/datagrid/form.ejs +1 -1
- 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 +8 -4
- package/webpack.config.js +1 -1
- package/dist/gds.js +0 -2
- package/dist/gds.js.LICENSE.txt +0 -41
- package/tslint.json +0 -22
|
@@ -1,105 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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',
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
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',
|
|
115
|
-
|
|
92
|
+
this.addEventListener(this.refs.year, 'input', () => {
|
|
93
|
+
this.timeHelper.validateDateInput(this.refs.year, 4);
|
|
116
94
|
});
|
|
117
|
-
this.addEventListener(this.refs.day, 'input',
|
|
118
|
-
|
|
95
|
+
this.addEventListener(this.refs.day, 'input', () => {
|
|
96
|
+
this.timeHelper.validateDateInput(this.refs.day, 2);
|
|
119
97
|
});
|
|
120
|
-
this.addEventListener(this.refs.month, 'input',
|
|
121
|
-
|
|
98
|
+
this.addEventListener(this.refs.month, 'input', () => {
|
|
99
|
+
this.timeHelper.validateDateInput(this.refs.month, 2);
|
|
122
100
|
});
|
|
123
101
|
return superAttach;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
this.
|
|
129
|
-
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;
|
|
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',
|
|
136
|
-
|
|
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',
|
|
140
|
-
|
|
120
|
+
type: 'number',
|
|
121
|
+
placeholder: 'MM',
|
|
122
|
+
required: (_j = this.component.validate) === null || _j === void 0 ? void 0 : _j.required,
|
|
141
123
|
};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
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 (
|
|
163
|
+
catch (_a) {
|
|
178
164
|
// ignored
|
|
179
165
|
}
|
|
180
166
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
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
|
-
|
|
201
|
-
|
|
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 (
|
|
209
|
+
catch (_a) {
|
|
222
210
|
return null;
|
|
223
211
|
}
|
|
224
212
|
}
|
|
225
213
|
return null;
|
|
226
|
-
}
|
|
227
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
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
|
-
|
|
264
|
-
//
|
|
265
|
-
|
|
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
|
-
|
|
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
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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 && (
|
|
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 && (
|
|
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
|
-
|
|
301
|
-
|
|
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
|
-
|
|
308
|
-
}(Day));
|
|
303
|
+
}
|
|
304
|
+
}
|
|
309
305
|
exports.default = GDSDatetimeComponent;
|
package/lib/components/index.js
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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 {};
|