@opengeoweb/form-fields 4.20.0 → 4.22.0
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/index.js +40770 -0
- package/package.json +13 -13
- package/index.esm.js +0 -973
- package/index.umd.js +0 -945
- /package/{index.d.ts → src/index.d.ts} +0 -0
- /package/{lib → src/lib}/components/Providers.d.ts +0 -0
- /package/{lib → src/lib}/components/Providers.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormDateTime.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormDateTime.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormDateTime.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormFormControl.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormFormControl.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormHiddenInput.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormHiddenInput.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormHiddenInput.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormNumberField.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormNumberField.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormNumberField.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormProvider.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormProvider.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormRadioGroup.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormRadioGroup.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormRadioGroup.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormSelect.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormSelect.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormSelect.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormTextField.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormTextField.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/ReactHookFormTextField.stories.d.ts +0 -0
- /package/{lib → src/lib}/components/formUtils.d.ts +0 -0
- /package/{lib → src/lib}/components/formUtils.spec.d.ts +0 -0
- /package/{lib → src/lib}/components/index.d.ts +0 -0
- /package/{lib → src/lib}/components/types.d.ts +0 -0
- /package/{lib → src/lib}/components/utils.d.ts +0 -0
- /package/{lib → src/lib}/components/utils.spec.d.ts +0 -0
- /package/{lib → src/lib}/hooks/useDraftFormHelpers/useDraftFormHelpers.d.ts +0 -0
- /package/{lib → src/lib}/hooks/useDraftFormHelpers/useDraftFormHelpers.spec.d.ts +0 -0
- /package/{lib → src/lib}/storyshots/Storyshots.spec.d.ts +0 -0
package/index.umd.js
DELETED
|
@@ -1,945 +0,0 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@mui/material'), require('react-hook-form'), require('moment'), require('lodash'), require('moment-timezone'), require('@mui/x-date-pickers'), require('@mui/x-date-pickers/AdapterMoment'), require('@mui/x-date-pickers/LocalizationProvider')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'moment', 'lodash', 'moment-timezone', '@mui/x-date-pickers', '@mui/x-date-pickers/AdapterMoment', '@mui/x-date-pickers/LocalizationProvider'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FormFields = {}, global.React, global.material, global.reactHookForm, global.moment, global.lodash, global.moment$1, global.xDatePickers, global.AdapterMoment, global.LocalizationProvider));
|
|
5
|
-
})(this, (function (exports, React, material, reactHookForm, moment, lodash, moment$1, xDatePickers, AdapterMoment, LocalizationProvider) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
-
|
|
9
|
-
function _interopNamespace(e) {
|
|
10
|
-
if (e && e.__esModule) return e;
|
|
11
|
-
var n = Object.create(null);
|
|
12
|
-
if (e) {
|
|
13
|
-
Object.keys(e).forEach(function (k) {
|
|
14
|
-
if (k !== 'default') {
|
|
15
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () { return e[k]; }
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
n["default"] = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
29
|
-
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
30
|
-
var moment__default$1 = /*#__PURE__*/_interopDefaultLegacy(moment$1);
|
|
31
|
-
|
|
32
|
-
/*! *****************************************************************************
|
|
33
|
-
Copyright (c) Microsoft Corporation.
|
|
34
|
-
|
|
35
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
36
|
-
purpose with or without fee is hereby granted.
|
|
37
|
-
|
|
38
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
39
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
40
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
41
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
42
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
43
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
44
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
45
|
-
***************************************************************************** */
|
|
46
|
-
|
|
47
|
-
var __assign = function() {
|
|
48
|
-
__assign = Object.assign || function __assign(t) {
|
|
49
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
50
|
-
s = arguments[i];
|
|
51
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
52
|
-
}
|
|
53
|
-
return t;
|
|
54
|
-
};
|
|
55
|
-
return __assign.apply(this, arguments);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
function __rest(s, e) {
|
|
59
|
-
var t = {};
|
|
60
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
61
|
-
t[p] = s[p];
|
|
62
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
63
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
64
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
65
|
-
t[p[i]] = s[p[i]];
|
|
66
|
-
}
|
|
67
|
-
return t;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function __read(o, n) {
|
|
71
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
72
|
-
if (!m) return o;
|
|
73
|
-
var i = m.call(o), r, ar = [], e;
|
|
74
|
-
try {
|
|
75
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
76
|
-
}
|
|
77
|
-
catch (error) { e = { error: error }; }
|
|
78
|
-
finally {
|
|
79
|
-
try {
|
|
80
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
81
|
-
}
|
|
82
|
-
finally { if (e) throw e.error; }
|
|
83
|
-
}
|
|
84
|
-
return ar;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function __spreadArray(to, from, pack) {
|
|
88
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
89
|
-
if (ar || !(i in from)) {
|
|
90
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
91
|
-
ar[i] = from[i];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* *
|
|
98
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
99
|
-
* you may not use this file except in compliance with the License.
|
|
100
|
-
* You may obtain a copy of the License at
|
|
101
|
-
*
|
|
102
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
103
|
-
*
|
|
104
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
105
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
106
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
107
|
-
* See the License for the specific language governing permissions and
|
|
108
|
-
* limitations under the License.
|
|
109
|
-
*
|
|
110
|
-
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
111
|
-
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
112
|
-
* */
|
|
113
|
-
var defaultProps = {
|
|
114
|
-
shouldUnregister: false
|
|
115
|
-
};
|
|
116
|
-
var errorMessages = {
|
|
117
|
-
required: 'This field is required',
|
|
118
|
-
isValidDate: 'Not a valid date',
|
|
119
|
-
isAfter: 'Date should not be before',
|
|
120
|
-
isXHoursBefore: 'Date is too far in the past',
|
|
121
|
-
isXHoursAfter: 'Date is too far in the future',
|
|
122
|
-
isBefore: 'Timestamp too late',
|
|
123
|
-
minLevel: 'The minimum level is 1',
|
|
124
|
-
isLatitude: 'Invalid latitude, expected number with maximum two decimal degrees between -90.00 and 90.00',
|
|
125
|
-
isLongitude: 'Invalid longitude, expected number with maximum two decimal degrees between -180.00 and 180.00',
|
|
126
|
-
isValidMax: 'The maximum value is exceeded',
|
|
127
|
-
isLevelLower: 'The lower level has to be below the upper level',
|
|
128
|
-
isNonOrBothCoordinates: 'Please enter both coordinates',
|
|
129
|
-
isInteger: 'Invalid entry, enter a non-decimal number',
|
|
130
|
-
isNumeric: 'Invalid entry, enter a numeric value'
|
|
131
|
-
};
|
|
132
|
-
var regexMaxTwoDecimals = /^\s*-?\d+(\.\d{1,2})?\s*$/; // validations
|
|
133
|
-
|
|
134
|
-
var isEmpty = function isEmpty(value) {
|
|
135
|
-
if (typeof value === 'string' && !value.trim().length || value === null || value === undefined) {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return false;
|
|
140
|
-
};
|
|
141
|
-
var isValidDate = function isValidDate(value) {
|
|
142
|
-
return value ? moment__default["default"](value).isValid() : true;
|
|
143
|
-
};
|
|
144
|
-
var isBefore = function isBefore(ownDate, referenceDate) {
|
|
145
|
-
return ownDate ? moment__default["default"].utc(ownDate) < moment__default["default"].utc(referenceDate) : true;
|
|
146
|
-
};
|
|
147
|
-
var isAfter = function isAfter(ownDate, otherDate) {
|
|
148
|
-
return ownDate ? moment__default["default"].utc(ownDate).isAfter(moment__default["default"].utc(otherDate)) : true;
|
|
149
|
-
};
|
|
150
|
-
var isBetween = function isBetween(ownDate, otherDateStart, otherDateEnd) {
|
|
151
|
-
return moment__default["default"].utc(ownDate) >= moment__default["default"].utc(otherDateStart) && moment__default["default"].utc(ownDate) <= moment__default["default"].utc(otherDateEnd);
|
|
152
|
-
};
|
|
153
|
-
var isXHoursBefore = function isXHoursBefore(ownDate, otherDate, hours) {
|
|
154
|
-
if (hours === void 0) {
|
|
155
|
-
hours = 4;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
if (isEmpty(ownDate) || isEmpty(otherDate)) {
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
var duration = moment__default["default"].duration(moment__default["default"].utc(ownDate).diff(otherDate));
|
|
163
|
-
var inHours = duration.asHours();
|
|
164
|
-
return inHours >= -hours;
|
|
165
|
-
};
|
|
166
|
-
var isXHoursAfter = function isXHoursAfter(ownDate, otherDate, hours) {
|
|
167
|
-
if (hours === void 0) {
|
|
168
|
-
hours = 4;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
if (isEmpty(ownDate) || isEmpty(otherDate)) {
|
|
172
|
-
return true;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
var duration = moment__default["default"].duration(moment__default["default"].utc(ownDate).diff(otherDate));
|
|
176
|
-
var inHours = duration.asHours();
|
|
177
|
-
return inHours <= hours;
|
|
178
|
-
};
|
|
179
|
-
var isLatitude = function isLatitude(lat) {
|
|
180
|
-
if (!lat) {
|
|
181
|
-
return true;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return isFinite(lat) && Math.abs(lat) <= 90 && regexMaxTwoDecimals.test(lat.toString());
|
|
185
|
-
};
|
|
186
|
-
var isLongitude = function isLongitude(lng) {
|
|
187
|
-
if (!lng) {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return isFinite(lng) && Math.abs(lng) <= 180 && lng >= -180 && regexMaxTwoDecimals.test(lng.toString());
|
|
192
|
-
}; // Pass null if no maxValue
|
|
193
|
-
|
|
194
|
-
var isValidMax = function isValidMax(value, maxValue) {
|
|
195
|
-
if (isEmpty(value) || maxValue === null) {
|
|
196
|
-
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return !(value > maxValue);
|
|
200
|
-
}; // Pass null if no minValue
|
|
201
|
-
|
|
202
|
-
var isValidMin = function isValidMin(value, minValue) {
|
|
203
|
-
if (isEmpty(value) || minValue === null) {
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return !(value < minValue);
|
|
208
|
-
};
|
|
209
|
-
var hasValidGeometry = function hasValidGeometry(geojson) {
|
|
210
|
-
if (!geojson || !geojson.features || !geojson.features.length || !geojson.features[0].geometry || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
211
|
-
// @ts-ignore
|
|
212
|
-
!geojson.features[0].geometry.coordinates || !geojson.features[0].geometry.type) {
|
|
213
|
-
return false;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return true;
|
|
217
|
-
};
|
|
218
|
-
var isValidGeoJsonCoordinates = function isValidGeoJsonCoordinates(geojson) {
|
|
219
|
-
var hasGeometry = hasValidGeometry(geojson);
|
|
220
|
-
|
|
221
|
-
if (!hasGeometry) {
|
|
222
|
-
return false;
|
|
223
|
-
} // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
var _a = geojson.features[0].geometry,
|
|
228
|
-
coordinates = _a.coordinates,
|
|
229
|
-
type = _a.type; // For type POINT coordinates is an array of 2
|
|
230
|
-
|
|
231
|
-
if (coordinates.length === 2 && type === 'Point') {
|
|
232
|
-
return true;
|
|
233
|
-
} // For type POLYGON coordinates is an array of arrays
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
if (coordinates.length === 1 && coordinates[0].length > 0 && type === 'Polygon') {
|
|
237
|
-
return true;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return false;
|
|
241
|
-
};
|
|
242
|
-
var isMaximumOneDrawing = function isMaximumOneDrawing(geojson) {
|
|
243
|
-
var hasGeometry = hasValidGeometry(geojson);
|
|
244
|
-
|
|
245
|
-
if (!hasGeometry) {
|
|
246
|
-
return true; // no need to check further when there is no drawing yet
|
|
247
|
-
} // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
248
|
-
// @ts-ignore
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
var _a = geojson.features[0].geometry,
|
|
252
|
-
coordinates = _a.coordinates,
|
|
253
|
-
type = _a.type; // For type POLYGON only one array of coordinates is allowed
|
|
254
|
-
|
|
255
|
-
if (type === 'Polygon' && coordinates.length > 1) {
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return true;
|
|
260
|
-
};
|
|
261
|
-
var hasIntersectionWithFIR = function hasIntersectionWithFIR(geojson, intersection) {
|
|
262
|
-
if (!hasValidGeometry(geojson) || // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
263
|
-
// @ts-ignore
|
|
264
|
-
!geojson.features[0].geometry.coordinates.length || geojson.features[0].geometry.type === 'Polygon' && !geojson.features[0].geometry.coordinates[0].length) {
|
|
265
|
-
return true; // no need to check further when there is no drawing yet
|
|
266
|
-
} // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
267
|
-
// @ts-ignore
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
var coordinates = intersection.features[0].geometry.coordinates;
|
|
271
|
-
|
|
272
|
-
if (coordinates.length > 0 && coordinates[0].length === 0) {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return true;
|
|
277
|
-
};
|
|
278
|
-
var hasMaxFeaturePoints = function hasMaxFeaturePoints(geojson, maxPoints) {
|
|
279
|
-
if (maxPoints === void 0) {
|
|
280
|
-
maxPoints = 7;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
var hasGeometry = hasValidGeometry(geojson);
|
|
284
|
-
|
|
285
|
-
if (!hasGeometry) {
|
|
286
|
-
return false;
|
|
287
|
-
} // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
var _a = geojson.features[0].geometry,
|
|
292
|
-
coordinates = _a.coordinates,
|
|
293
|
-
type = _a.type;
|
|
294
|
-
|
|
295
|
-
if (type === 'Polygon' && coordinates[0].length > maxPoints) {
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return false;
|
|
300
|
-
};
|
|
301
|
-
var hasMulitpleIntersections = function hasMulitpleIntersections(geojson) {
|
|
302
|
-
var hasGeometry = hasValidGeometry(geojson);
|
|
303
|
-
|
|
304
|
-
if (!hasGeometry) {
|
|
305
|
-
return false;
|
|
306
|
-
} // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
307
|
-
// @ts-ignore
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var _a = geojson.features[0].geometry,
|
|
311
|
-
coordinates = _a.coordinates,
|
|
312
|
-
type = _a.type;
|
|
313
|
-
|
|
314
|
-
if (type === 'MultiPolygon' || coordinates.length > 1 && type !== 'Point') {
|
|
315
|
-
return true;
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
return false;
|
|
319
|
-
};
|
|
320
|
-
var isGeometryDirty = function isGeometryDirty(geoJSON, formGeoJSON) {
|
|
321
|
-
if (geoJSON === (undefined) || formGeoJSON === (undefined) || !hasValidGeometry(geoJSON) || !hasValidGeometry(formGeoJSON)) {
|
|
322
|
-
return false;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return !lodash.isEqual( // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
326
|
-
// @ts-ignore
|
|
327
|
-
geoJSON.features[0].geometry.coordinates, // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
328
|
-
// @ts-ignore
|
|
329
|
-
formGeoJSON.features[0].geometry.coordinates);
|
|
330
|
-
};
|
|
331
|
-
var isInteger = function isInteger(value) {
|
|
332
|
-
if (isEmpty(value)) {
|
|
333
|
-
return true;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return Number.isInteger(value);
|
|
337
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
338
|
-
var isNonOrBothCoordinates = function isNonOrBothCoordinates(coordinate, otherCoordinate) {
|
|
339
|
-
if (typeof coordinate === 'number' && typeof otherCoordinate === 'number' || coordinate === null && otherCoordinate === null || coordinate === undefined && otherCoordinate === undefined) {
|
|
340
|
-
return true;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (typeof coordinate === 'number') {
|
|
344
|
-
return true;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return false;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
var radioCheckboxStyle = {
|
|
351
|
-
// hides unchecked values
|
|
352
|
-
display: 'none',
|
|
353
|
-
'&+.MuiFormControlLabel-label': {
|
|
354
|
-
display: 'none'
|
|
355
|
-
},
|
|
356
|
-
// shows checked value
|
|
357
|
-
'&.Mui-checked': {
|
|
358
|
-
display: 'inherit',
|
|
359
|
-
'&+.MuiFormControlLabel-label': {
|
|
360
|
-
display: 'inherit'
|
|
361
|
-
}
|
|
362
|
-
},
|
|
363
|
-
'&.Mui-checked+.MuiFormControlLabel-label': {
|
|
364
|
-
color: 'geowebColors.typographyAndIcons.text'
|
|
365
|
-
},
|
|
366
|
-
'&.Mui-disabled.Mui-checked': {
|
|
367
|
-
color: 'geowebColors.typographyAndIcons.iconLinkActive'
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
var getErrorMessage = function getErrorMessage(errors) {
|
|
371
|
-
if (errors && errors.message && typeof errors.message === 'string') {
|
|
372
|
-
return errors.message;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
if (errors && errors.type && typeof errors.type === 'string') {
|
|
376
|
-
return errorMessages[errors.type];
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
return '';
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
|
|
383
|
-
var children = _a.children,
|
|
384
|
-
errors = _a.errors,
|
|
385
|
-
isReadOnly = _a.isReadOnly,
|
|
386
|
-
_b = _a.sx,
|
|
387
|
-
sx = _b === void 0 ? {} : _b,
|
|
388
|
-
_c = _a.className,
|
|
389
|
-
className = _c === void 0 ? '' : _c,
|
|
390
|
-
props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className"]);
|
|
391
|
-
|
|
392
|
-
return /*#__PURE__*/React__namespace.createElement(material.FormControl, __assign({
|
|
393
|
-
fullWidth: true,
|
|
394
|
-
error: !!errors,
|
|
395
|
-
className: (isReadOnly ? 'is-read-only' : '') + " " + className,
|
|
396
|
-
sx: __assign(__assign({}, isReadOnly && {
|
|
397
|
-
// Radio input
|
|
398
|
-
'.MuiRadio-root': radioCheckboxStyle,
|
|
399
|
-
// Checkbox input
|
|
400
|
-
'.MuiCheckbox-root': radioCheckboxStyle,
|
|
401
|
-
// Select input
|
|
402
|
-
'.MuiSelect-select.Mui-disabled': {
|
|
403
|
-
color: 'geowebColors.typographyAndIcons.text',
|
|
404
|
-
WebkitTextFillColor: 'inherit',
|
|
405
|
-
'&:before': {
|
|
406
|
-
borderColor: 'transparent'
|
|
407
|
-
}
|
|
408
|
-
},
|
|
409
|
-
'.MuiSelect-nativeInput+.MuiSvgIcon-root': {
|
|
410
|
-
display: 'none'
|
|
411
|
-
},
|
|
412
|
-
'.Mui-disabled:before': {
|
|
413
|
-
border: 'transparent'
|
|
414
|
-
}
|
|
415
|
-
}), sx)
|
|
416
|
-
}, props), children, errors && /*#__PURE__*/React__namespace.createElement(material.FormHelperText, {
|
|
417
|
-
variant: "filled"
|
|
418
|
-
}, getErrorMessage(errors)));
|
|
419
|
-
};
|
|
420
|
-
|
|
421
|
-
function getDeepProperty(p, o) {
|
|
422
|
-
return p.reduce(function (xs, x) {
|
|
423
|
-
return xs && xs[x] ? xs[x] : null;
|
|
424
|
-
}, o);
|
|
425
|
-
}
|
|
426
|
-
var getErrors = function getErrors(name, errors) {
|
|
427
|
-
var nameAsArray = name.split('.');
|
|
428
|
-
return getDeepProperty(nameAsArray, errors);
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
var ReactHookFormSelect = function ReactHookFormSelect(_a) {
|
|
432
|
-
var name = _a.name,
|
|
433
|
-
label = _a.label,
|
|
434
|
-
_b = _a.defaultValue,
|
|
435
|
-
defaultValue = _b === void 0 ? '' : _b,
|
|
436
|
-
children = _a.children,
|
|
437
|
-
rules = _a.rules,
|
|
438
|
-
_c = _a.onChange,
|
|
439
|
-
_onChange = _c === void 0 ? function () {} : _c,
|
|
440
|
-
disabled = _a.disabled,
|
|
441
|
-
className = _a.className,
|
|
442
|
-
sx = _a.sx,
|
|
443
|
-
isReadOnly = _a.isReadOnly,
|
|
444
|
-
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
|
|
445
|
-
|
|
446
|
-
var labelId = name + "-label";
|
|
447
|
-
var control = reactHookForm.useFormContext().control;
|
|
448
|
-
|
|
449
|
-
var _d = reactHookForm.useController(__assign({
|
|
450
|
-
name: name,
|
|
451
|
-
control: control,
|
|
452
|
-
rules: rules,
|
|
453
|
-
defaultValue: defaultValue
|
|
454
|
-
}, defaultProps)),
|
|
455
|
-
_e = _d.field,
|
|
456
|
-
onChangeField = _e.onChange,
|
|
457
|
-
value = _e.value,
|
|
458
|
-
ref = _e.ref,
|
|
459
|
-
formErrors = _d.formState.errors;
|
|
460
|
-
|
|
461
|
-
var errors = getErrors(name, formErrors);
|
|
462
|
-
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
463
|
-
className: className,
|
|
464
|
-
sx: sx,
|
|
465
|
-
disabled: disabled,
|
|
466
|
-
errors: errors,
|
|
467
|
-
isReadOnly: isReadOnly
|
|
468
|
-
}, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
|
|
469
|
-
variant: "filled",
|
|
470
|
-
id: labelId
|
|
471
|
-
}, label), /*#__PURE__*/React__namespace.createElement(material.Select, __assign({
|
|
472
|
-
labelId: labelId,
|
|
473
|
-
label: label,
|
|
474
|
-
inputRef: ref,
|
|
475
|
-
name: name,
|
|
476
|
-
onChange: function onChange(changeEvent) {
|
|
477
|
-
onChangeField(changeEvent.target.value); // default props
|
|
478
|
-
|
|
479
|
-
_onChange(changeEvent);
|
|
480
|
-
},
|
|
481
|
-
value: value || '',
|
|
482
|
-
variant: "filled"
|
|
483
|
-
}, otherProps), children));
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
|
|
487
|
-
var name = _a.name,
|
|
488
|
-
label = _a.label,
|
|
489
|
-
_b = _a.defaultValue,
|
|
490
|
-
defaultValue = _b === void 0 ? '' : _b,
|
|
491
|
-
children = _a.children,
|
|
492
|
-
rules = _a.rules,
|
|
493
|
-
_c = _a.disabled,
|
|
494
|
-
disabled = _c === void 0 ? false : _c,
|
|
495
|
-
_d = _a.onChange,
|
|
496
|
-
_onChange = _d === void 0 ? function () {} : _d,
|
|
497
|
-
isReadOnly = _a.isReadOnly,
|
|
498
|
-
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
|
|
499
|
-
|
|
500
|
-
var labelId = name + "-label";
|
|
501
|
-
var control = reactHookForm.useFormContext().control;
|
|
502
|
-
|
|
503
|
-
var _e = reactHookForm.useController(__assign({
|
|
504
|
-
name: name,
|
|
505
|
-
control: control,
|
|
506
|
-
rules: rules,
|
|
507
|
-
defaultValue: defaultValue
|
|
508
|
-
}, defaultProps)),
|
|
509
|
-
_f = _e.field,
|
|
510
|
-
onChangeField = _f.onChange,
|
|
511
|
-
value = _f.value,
|
|
512
|
-
ref = _f.ref,
|
|
513
|
-
formErrors = _e.formState.errors;
|
|
514
|
-
|
|
515
|
-
var errors = getErrors(name, formErrors);
|
|
516
|
-
React__namespace.useEffect(function () {
|
|
517
|
-
if (errors) {
|
|
518
|
-
var firstError = Object.keys(formErrors)[0];
|
|
519
|
-
|
|
520
|
-
if (firstError === name) {
|
|
521
|
-
// if first error in form is same, focus on that input
|
|
522
|
-
var inputNode = document.querySelector("[name=\"" + name + "\"]");
|
|
523
|
-
|
|
524
|
-
if (inputNode !== null) {
|
|
525
|
-
inputNode.focus();
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}, [errors, formErrors, name]);
|
|
530
|
-
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
531
|
-
disabled: disabled,
|
|
532
|
-
errors: errors,
|
|
533
|
-
isReadOnly: isReadOnly
|
|
534
|
-
}, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
|
|
535
|
-
id: labelId
|
|
536
|
-
}, label), /*#__PURE__*/React__namespace.createElement(material.RadioGroup, __assign({
|
|
537
|
-
value: value,
|
|
538
|
-
onChange: function onChange(changeEvent) {
|
|
539
|
-
onChangeField(changeEvent.target.value);
|
|
540
|
-
|
|
541
|
-
_onChange(changeEvent, changeEvent.target.value);
|
|
542
|
-
},
|
|
543
|
-
ref: ref,
|
|
544
|
-
name: name
|
|
545
|
-
}, otherProps), children));
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
var convertTextInputValue = function convertTextInputValue(value, inCapitals) {
|
|
549
|
-
return inCapitals ? value.toUpperCase() : value;
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
var ReactHookFormTextField = function ReactHookFormTextField(_a) {
|
|
553
|
-
var name = _a.name,
|
|
554
|
-
label = _a.label,
|
|
555
|
-
_b = _a.defaultValue,
|
|
556
|
-
defaultValue = _b === void 0 ? '' : _b,
|
|
557
|
-
rules = _a.rules,
|
|
558
|
-
_c = _a.disabled,
|
|
559
|
-
disabled = _c === void 0 ? false : _c,
|
|
560
|
-
_d = _a.upperCase,
|
|
561
|
-
upperCase = _d === void 0 ? false : _d,
|
|
562
|
-
_e = _a.helperText,
|
|
563
|
-
helperText = _e === void 0 ? '' : _e,
|
|
564
|
-
className = _a.className,
|
|
565
|
-
sx = _a.sx,
|
|
566
|
-
_f = _a.onChange,
|
|
567
|
-
_onChange = _f === void 0 ? function () {} : _f,
|
|
568
|
-
isReadOnly = _a.isReadOnly,
|
|
569
|
-
InputProps = _a.InputProps,
|
|
570
|
-
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
|
|
571
|
-
|
|
572
|
-
var control = reactHookForm.useFormContext().control;
|
|
573
|
-
|
|
574
|
-
var _g = reactHookForm.useController(__assign({
|
|
575
|
-
name: name,
|
|
576
|
-
control: control,
|
|
577
|
-
rules: rules,
|
|
578
|
-
defaultValue: defaultValue
|
|
579
|
-
}, defaultProps)),
|
|
580
|
-
_h = _g.field,
|
|
581
|
-
onChangeField = _h.onChange,
|
|
582
|
-
value = _h.value,
|
|
583
|
-
ref = _h.ref,
|
|
584
|
-
formErrors = _g.formState.errors;
|
|
585
|
-
|
|
586
|
-
var errors = getErrors(name, formErrors);
|
|
587
|
-
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
588
|
-
className: className,
|
|
589
|
-
sx: sx,
|
|
590
|
-
disabled: disabled,
|
|
591
|
-
errors: errors,
|
|
592
|
-
isReadOnly: isReadOnly
|
|
593
|
-
}, /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
594
|
-
label: label,
|
|
595
|
-
error: !!errors,
|
|
596
|
-
helperText: helperText,
|
|
597
|
-
value: value,
|
|
598
|
-
variant: "filled",
|
|
599
|
-
type: "text",
|
|
600
|
-
name: name,
|
|
601
|
-
onChange: function onChange(evt) {
|
|
602
|
-
var value = evt.target.value;
|
|
603
|
-
var convertedValue = convertTextInputValue(value, upperCase);
|
|
604
|
-
onChangeField(convertedValue);
|
|
605
|
-
|
|
606
|
-
_onChange(null);
|
|
607
|
-
},
|
|
608
|
-
disabled: disabled,
|
|
609
|
-
inputRef: ref,
|
|
610
|
-
InputProps: __assign(__assign({}, InputProps), isReadOnly && {
|
|
611
|
-
readOnly: true
|
|
612
|
-
})
|
|
613
|
-
}, otherProps)));
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
var convertNumericInputValue = function convertNumericInputValue(value, inputMode) {
|
|
617
|
-
if (value !== '' && !isNaN(parseFloat(value))) {
|
|
618
|
-
return inputMode === 'numeric' ? parseInt(value, 10) : parseFloat(value);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
return null;
|
|
622
|
-
};
|
|
623
|
-
var getAllowedKeys = function getAllowedKeys(inputMode) {
|
|
624
|
-
if (inputMode === void 0) {
|
|
625
|
-
inputMode = 'numeric';
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
var allowedKeys = __spreadArray(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', 'Backspace', 'ArrowRight', 'ArrowLeft', 'Tab', 'Home', 'End', 'PageDown', 'PageUp', 'Delete'], __read(inputMode === 'decimal' ? ['.'] : []));
|
|
629
|
-
|
|
630
|
-
return allowedKeys;
|
|
631
|
-
};
|
|
632
|
-
|
|
633
|
-
var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
|
|
634
|
-
var name = _a.name,
|
|
635
|
-
label = _a.label,
|
|
636
|
-
_b = _a.defaultValue,
|
|
637
|
-
defaultValue = _b === void 0 ? null : _b,
|
|
638
|
-
rules = _a.rules,
|
|
639
|
-
_c = _a.disabled,
|
|
640
|
-
disabled = _c === void 0 ? false : _c,
|
|
641
|
-
_d = _a.inputMode,
|
|
642
|
-
inputMode = _d === void 0 ? 'numeric' : _d,
|
|
643
|
-
_e = _a.helperText,
|
|
644
|
-
helperText = _e === void 0 ? '' : _e,
|
|
645
|
-
className = _a.className,
|
|
646
|
-
sx = _a.sx,
|
|
647
|
-
_f = _a.onChange,
|
|
648
|
-
_onChange = _f === void 0 ? function () {} : _f,
|
|
649
|
-
isReadOnly = _a.isReadOnly,
|
|
650
|
-
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
|
|
651
|
-
|
|
652
|
-
var control = reactHookForm.useFormContext().control;
|
|
653
|
-
|
|
654
|
-
var _g = reactHookForm.useController(__assign({
|
|
655
|
-
name: name,
|
|
656
|
-
control: control,
|
|
657
|
-
rules: rules,
|
|
658
|
-
defaultValue: defaultValue
|
|
659
|
-
}, defaultProps)),
|
|
660
|
-
_h = _g.field,
|
|
661
|
-
onChangeField = _h.onChange,
|
|
662
|
-
value = _h.value,
|
|
663
|
-
ref = _h.ref,
|
|
664
|
-
formErrors = _g.formState.errors;
|
|
665
|
-
|
|
666
|
-
var errors = getErrors(name, formErrors);
|
|
667
|
-
var allowedKeyes = getAllowedKeys(inputMode);
|
|
668
|
-
|
|
669
|
-
var onKeyDown = function onKeyDown(event) {
|
|
670
|
-
if (!allowedKeyes.includes(event.key) || // only allow one seperator
|
|
671
|
-
event.key === '.' && event.target.value.includes('.') || // only allow one -
|
|
672
|
-
event.key === '-' && event.target.value.includes('-')) {
|
|
673
|
-
event.preventDefault();
|
|
674
|
-
}
|
|
675
|
-
};
|
|
676
|
-
|
|
677
|
-
var _j = __read(React__namespace.useState(value === null || isNaN(value) ? '' : value), 2),
|
|
678
|
-
displayValue = _j[0],
|
|
679
|
-
setDisplayValue = _j[1];
|
|
680
|
-
|
|
681
|
-
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
682
|
-
className: className,
|
|
683
|
-
sx: sx,
|
|
684
|
-
disabled: disabled,
|
|
685
|
-
errors: errors,
|
|
686
|
-
isReadOnly: isReadOnly
|
|
687
|
-
}, /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
688
|
-
label: label,
|
|
689
|
-
error: !!errors,
|
|
690
|
-
helperText: helperText,
|
|
691
|
-
inputMode: inputMode,
|
|
692
|
-
value: displayValue,
|
|
693
|
-
variant: "filled",
|
|
694
|
-
type: "text",
|
|
695
|
-
inputProps: {
|
|
696
|
-
inputMode: inputMode
|
|
697
|
-
},
|
|
698
|
-
name: name,
|
|
699
|
-
onChange: function onChange(evt) {
|
|
700
|
-
var value = evt.target.value;
|
|
701
|
-
setDisplayValue(value);
|
|
702
|
-
onChangeField(convertNumericInputValue(value, inputMode));
|
|
703
|
-
|
|
704
|
-
_onChange(null);
|
|
705
|
-
},
|
|
706
|
-
onKeyDown: onKeyDown,
|
|
707
|
-
disabled: disabled,
|
|
708
|
-
inputRef: ref,
|
|
709
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
710
|
-
InputProps: __assign(__assign({}, isReadOnly && {
|
|
711
|
-
readOnly: true
|
|
712
|
-
}), otherProps.InputProps)
|
|
713
|
-
}, otherProps)));
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
moment__default$1["default"].tz.setDefault('Etc/GMT-0'); // TODO: remove when issue is fixed in upcoming release https://github.com/mui/mui-x/issues/8150
|
|
717
|
-
|
|
718
|
-
var temporaryStripChineseCharacters = function temporaryStripChineseCharacters(dirtyString) {
|
|
719
|
-
return dirtyString.replace(/[\u2066\u2067\u2068\u2069\u200e]/g, '');
|
|
720
|
-
};
|
|
721
|
-
var getFormattedValue = function getFormattedValue(value) {
|
|
722
|
-
var isMoment = moment__default$1["default"](value).isValid();
|
|
723
|
-
return isMoment ? moment__default$1["default"].utc(value).format() : value;
|
|
724
|
-
};
|
|
725
|
-
|
|
726
|
-
var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_a) {
|
|
727
|
-
var name = _a.name,
|
|
728
|
-
rules = _a.rules,
|
|
729
|
-
disabled = _a.disabled,
|
|
730
|
-
_b = _a.label,
|
|
731
|
-
label = _b === void 0 ? 'Select date and time' : _b,
|
|
732
|
-
_c = _a.format,
|
|
733
|
-
format = _c === void 0 ? 'YYYY/MM/DD HH:mm' : _c,
|
|
734
|
-
_d = _a.openTo,
|
|
735
|
-
openTo = _d === void 0 ? 'hours' : _d,
|
|
736
|
-
_e = _a.defaultNullValue,
|
|
737
|
-
defaultNullValue = _e === void 0 ? null : _e,
|
|
738
|
-
_f = _a.helperText,
|
|
739
|
-
helperText = _f === void 0 ? '' : _f,
|
|
740
|
-
_g = _a.onChange,
|
|
741
|
-
_onChange = _g === void 0 ? function () {} : _g,
|
|
742
|
-
className = _a.className,
|
|
743
|
-
sx = _a.sx,
|
|
744
|
-
isReadOnly = _a.isReadOnly,
|
|
745
|
-
inputAdornment = _a.inputAdornment,
|
|
746
|
-
otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "inputAdornment"]);
|
|
747
|
-
|
|
748
|
-
var control = reactHookForm.useFormContext().control;
|
|
749
|
-
|
|
750
|
-
var _h = reactHookForm.useController(__assign({
|
|
751
|
-
name: name,
|
|
752
|
-
control: control,
|
|
753
|
-
rules: rules,
|
|
754
|
-
defaultValue: defaultNullValue
|
|
755
|
-
}, defaultProps)),
|
|
756
|
-
_j = _h.field,
|
|
757
|
-
onChangeField = _j.onChange,
|
|
758
|
-
value = _j.value,
|
|
759
|
-
ref = _j.ref,
|
|
760
|
-
formErrors = _h.formState.errors;
|
|
761
|
-
|
|
762
|
-
var errors = getErrors(name, formErrors); // Ensure value is a Moment object
|
|
763
|
-
|
|
764
|
-
var dateValue = value ? moment__default$1["default"](value) : null;
|
|
765
|
-
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
766
|
-
disabled: disabled,
|
|
767
|
-
errors: errors,
|
|
768
|
-
className: className,
|
|
769
|
-
sx: sx,
|
|
770
|
-
isReadOnly: isReadOnly
|
|
771
|
-
}, /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
|
|
772
|
-
desktopModeMediaQuery: "@media (min-width: 720px)",
|
|
773
|
-
ampm: false,
|
|
774
|
-
format: format,
|
|
775
|
-
label: label,
|
|
776
|
-
value: dateValue,
|
|
777
|
-
openTo: openTo,
|
|
778
|
-
disabled: disabled,
|
|
779
|
-
onChange: function onChange(value) {
|
|
780
|
-
onChangeField(getFormattedValue(value));
|
|
781
|
-
|
|
782
|
-
_onChange(getFormattedValue(value));
|
|
783
|
-
},
|
|
784
|
-
inputRef: ref,
|
|
785
|
-
slotProps: {
|
|
786
|
-
textField: {
|
|
787
|
-
variant: 'filled',
|
|
788
|
-
helperText: helperText,
|
|
789
|
-
error: !!errors,
|
|
790
|
-
name: name,
|
|
791
|
-
placeholder: disabled ? '' : format.toLowerCase(),
|
|
792
|
-
InputProps: __assign({
|
|
793
|
-
endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
|
|
794
|
-
style: {
|
|
795
|
-
paddingTop: '16px'
|
|
796
|
-
},
|
|
797
|
-
position: "end"
|
|
798
|
-
}, "UTC")
|
|
799
|
-
}, isReadOnly && {
|
|
800
|
-
readOnly: true
|
|
801
|
-
}),
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
-
// @ts-ignore
|
|
804
|
-
'data-testid': otherProps['data-testid']
|
|
805
|
-
},
|
|
806
|
-
inputAdornment: __assign({}, inputAdornment || {
|
|
807
|
-
position: 'start'
|
|
808
|
-
}),
|
|
809
|
-
tabs: {
|
|
810
|
-
hidden: false
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
}, otherProps)));
|
|
814
|
-
};
|
|
815
|
-
|
|
816
|
-
var defaultFormOptions = {
|
|
817
|
-
mode: 'onChange',
|
|
818
|
-
reValidateMode: 'onChange'
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
var ReactHookFormProvider = function ReactHookFormProvider(_a) {
|
|
822
|
-
var children = _a.children,
|
|
823
|
-
_b = _a.options,
|
|
824
|
-
options = _b === void 0 ? defaultFormOptions : _b;
|
|
825
|
-
var formMethods = reactHookForm.useForm(options); // added this ignore as the build is failing otherwise on: Type instantiation is excessively deep and possibly infinite.
|
|
826
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
827
|
-
// @ts-ignore
|
|
828
|
-
|
|
829
|
-
return /*#__PURE__*/React__default["default"].createElement(reactHookForm.FormProvider, __assign({}, formMethods), children);
|
|
830
|
-
};
|
|
831
|
-
|
|
832
|
-
var ReactHookFormProviderWrapper = function ReactHookFormProviderWrapper(_a) {
|
|
833
|
-
var children = _a.children,
|
|
834
|
-
_b = _a.options,
|
|
835
|
-
options = _b === void 0 ? defaultFormOptions : _b;
|
|
836
|
-
return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider.LocalizationProvider, {
|
|
837
|
-
dateAdapter: AdapterMoment.AdapterMoment
|
|
838
|
-
}, /*#__PURE__*/React__default["default"].createElement(ReactHookFormProvider, {
|
|
839
|
-
options: options
|
|
840
|
-
}, children));
|
|
841
|
-
};
|
|
842
|
-
|
|
843
|
-
var ReactHookFormHiddenInput = function ReactHookFormHiddenInput(_a) {
|
|
844
|
-
var name = _a.name,
|
|
845
|
-
_b = _a.defaultValue,
|
|
846
|
-
defaultValue = _b === void 0 ? null : _b,
|
|
847
|
-
rules = _a.rules;
|
|
848
|
-
var control = reactHookForm.useFormContext().control;
|
|
849
|
-
var field = reactHookForm.useController(__assign({
|
|
850
|
-
name: name,
|
|
851
|
-
control: control,
|
|
852
|
-
rules: rules,
|
|
853
|
-
defaultValue: defaultValue
|
|
854
|
-
}, defaultProps)).field;
|
|
855
|
-
return field.value !== null ? /*#__PURE__*/React__namespace.createElement("input", __assign({}, field, {
|
|
856
|
-
type: "hidden"
|
|
857
|
-
})) : null;
|
|
858
|
-
};
|
|
859
|
-
|
|
860
|
-
var HIDDEN_INPUT_HELPER_IS_DRAFT = 'IS_DRAFT';
|
|
861
|
-
var useDraftFormHelpers = function useDraftFormHelpers(isDefaultDraft) {
|
|
862
|
-
if (isDefaultDraft === void 0) {
|
|
863
|
-
isDefaultDraft = false;
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
var _a = reactHookForm.useFormContext(),
|
|
867
|
-
getValues = _a.getValues,
|
|
868
|
-
setValue = _a.setValue,
|
|
869
|
-
register = _a.register;
|
|
870
|
-
|
|
871
|
-
React__namespace.useEffect(function () {
|
|
872
|
-
setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDefaultDraft, {
|
|
873
|
-
shouldDirty: false
|
|
874
|
-
}); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
875
|
-
}, []);
|
|
876
|
-
|
|
877
|
-
var isDraft = function isDraft() {
|
|
878
|
-
return getValues(HIDDEN_INPUT_HELPER_IS_DRAFT) === true;
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
var isRequired = function isRequired(value) {
|
|
882
|
-
if (!isDraft() && isEmpty(value)) {
|
|
883
|
-
return errorMessages.required;
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
return true;
|
|
887
|
-
};
|
|
888
|
-
|
|
889
|
-
var toggleIsDraft = function toggleIsDraft(isDraft) {
|
|
890
|
-
return setValue(HIDDEN_INPUT_HELPER_IS_DRAFT, isDraft, {
|
|
891
|
-
shouldDirty: false
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
|
|
895
|
-
var DraftFieldHelper = function DraftFieldHelper() {
|
|
896
|
-
return /*#__PURE__*/React__namespace.createElement("input", __assign({}, register(HIDDEN_INPUT_HELPER_IS_DRAFT), {
|
|
897
|
-
type: "hidden"
|
|
898
|
-
}));
|
|
899
|
-
};
|
|
900
|
-
|
|
901
|
-
return {
|
|
902
|
-
isRequired: isRequired,
|
|
903
|
-
toggleIsDraft: toggleIsDraft,
|
|
904
|
-
isDraft: isDraft,
|
|
905
|
-
DraftFieldHelper: DraftFieldHelper
|
|
906
|
-
};
|
|
907
|
-
};
|
|
908
|
-
|
|
909
|
-
exports.HIDDEN_INPUT_HELPER_IS_DRAFT = HIDDEN_INPUT_HELPER_IS_DRAFT;
|
|
910
|
-
exports.ReactHookFormDateTime = ReactHookKeyboardDateTimePicker;
|
|
911
|
-
exports.ReactHookFormFormControl = ReactHookFormFormControl;
|
|
912
|
-
exports.ReactHookFormHiddenInput = ReactHookFormHiddenInput;
|
|
913
|
-
exports.ReactHookFormNumberField = ReactHookFormNumberField;
|
|
914
|
-
exports.ReactHookFormProvider = ReactHookFormProviderWrapper;
|
|
915
|
-
exports.ReactHookFormRadioGroup = ReactHookFormRadioGroup;
|
|
916
|
-
exports.ReactHookFormSelect = ReactHookFormSelect;
|
|
917
|
-
exports.ReactHookFormTextField = ReactHookFormTextField;
|
|
918
|
-
exports.defaultFormOptions = defaultFormOptions;
|
|
919
|
-
exports.errorMessages = errorMessages;
|
|
920
|
-
exports.getDeepProperty = getDeepProperty;
|
|
921
|
-
exports.hasIntersectionWithFIR = hasIntersectionWithFIR;
|
|
922
|
-
exports.hasMaxFeaturePoints = hasMaxFeaturePoints;
|
|
923
|
-
exports.hasMulitpleIntersections = hasMulitpleIntersections;
|
|
924
|
-
exports.isAfter = isAfter;
|
|
925
|
-
exports.isBefore = isBefore;
|
|
926
|
-
exports.isBetween = isBetween;
|
|
927
|
-
exports.isEmpty = isEmpty;
|
|
928
|
-
exports.isGeometryDirty = isGeometryDirty;
|
|
929
|
-
exports.isInteger = isInteger;
|
|
930
|
-
exports.isLatitude = isLatitude;
|
|
931
|
-
exports.isLongitude = isLongitude;
|
|
932
|
-
exports.isMaximumOneDrawing = isMaximumOneDrawing;
|
|
933
|
-
exports.isNonOrBothCoordinates = isNonOrBothCoordinates;
|
|
934
|
-
exports.isValidDate = isValidDate;
|
|
935
|
-
exports.isValidGeoJsonCoordinates = isValidGeoJsonCoordinates;
|
|
936
|
-
exports.isValidMax = isValidMax;
|
|
937
|
-
exports.isValidMin = isValidMin;
|
|
938
|
-
exports.isXHoursAfter = isXHoursAfter;
|
|
939
|
-
exports.isXHoursBefore = isXHoursBefore;
|
|
940
|
-
exports.temporaryStripChineseCharacters = temporaryStripChineseCharacters;
|
|
941
|
-
exports.useDraftFormHelpers = useDraftFormHelpers;
|
|
942
|
-
|
|
943
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
944
|
-
|
|
945
|
-
}));
|