@opengeoweb/form-fields 4.7.1 → 4.9.1
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.esm.js +269 -258
- package/index.umd.js +220 -261
- package/lib/components/Providers.d.ts +3 -3
- package/lib/components/ReactHookFormFormControl.d.ts +1 -0
- package/lib/components/ReactHookFormNumberField.d.ts +1 -2
- package/lib/components/ReactHookFormProvider.d.ts +3 -14
- package/lib/components/index.d.ts +1 -1
- package/lib/components/utils.d.ts +3 -2
- package/package.json +3 -3
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { FormControl, FormHelperText, InputLabel, Select, RadioGroup, TextField, InputAdornment } from '@mui/material';
|
|
4
|
-
import { useFormContext,
|
|
4
|
+
import { useFormContext, useController, useForm, FormProvider } from 'react-hook-form';
|
|
5
5
|
import moment from 'moment';
|
|
6
6
|
import { isEqual } from 'lodash';
|
|
7
7
|
import moment$1 from 'moment-timezone';
|
|
@@ -52,6 +52,9 @@ function __rest(s, e) {
|
|
|
52
52
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
53
53
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
54
54
|
* */
|
|
55
|
+
var defaultProps = {
|
|
56
|
+
shouldUnregister: true
|
|
57
|
+
};
|
|
55
58
|
var errorMessages = {
|
|
56
59
|
required: 'This field is required',
|
|
57
60
|
isValidDate: 'Not a valid date',
|
|
@@ -67,7 +70,6 @@ var errorMessages = {
|
|
|
67
70
|
isNonOrBothCoordinates: 'Please enter both coordinates',
|
|
68
71
|
isInteger: 'Invalid entry, enter a non-decimal number',
|
|
69
72
|
isNumeric: 'Invalid entry, enter a numeric value',
|
|
70
|
-
containsNoCommas: 'Please use a dot (.) as decimal separator',
|
|
71
73
|
minVisibility: 'The minimum visibility is 0',
|
|
72
74
|
maxVisibility: 'The maximum visibility is 4900'
|
|
73
75
|
};
|
|
@@ -263,23 +265,16 @@ var isInteger = function isInteger(value) {
|
|
|
263
265
|
return Number.isInteger(value);
|
|
264
266
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
265
267
|
var isNonOrBothCoordinates = function isNonOrBothCoordinates(coordinate, otherCoordinate) {
|
|
266
|
-
if (coordinate && otherCoordinate ||
|
|
268
|
+
if (typeof coordinate === 'number' && typeof otherCoordinate === 'number' || coordinate === null && otherCoordinate === null || coordinate === undefined && otherCoordinate === undefined) {
|
|
267
269
|
return true;
|
|
268
270
|
}
|
|
269
271
|
|
|
270
|
-
if (coordinate) {
|
|
272
|
+
if (typeof coordinate === 'number') {
|
|
271
273
|
return true;
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
return false;
|
|
275
277
|
};
|
|
276
|
-
var containsNoCommas = function containsNoCommas(val) {
|
|
277
|
-
if (typeof val === 'string' && val.includes(',')) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return true;
|
|
282
|
-
};
|
|
283
278
|
|
|
284
279
|
var radioCheckboxStyle = {
|
|
285
280
|
// hides unchecked values
|
|
@@ -301,6 +296,17 @@ var radioCheckboxStyle = {
|
|
|
301
296
|
color: 'geowebColors.typographyAndIcons.iconLinkActive'
|
|
302
297
|
}
|
|
303
298
|
};
|
|
299
|
+
var getErrorMessage = function getErrorMessage(errors) {
|
|
300
|
+
if (errors && errors.message && typeof errors.message === 'string') {
|
|
301
|
+
return errors.message;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (errors && errors.type && typeof errors.type === 'string') {
|
|
305
|
+
return errorMessages[errors.type];
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return '';
|
|
309
|
+
};
|
|
304
310
|
|
|
305
311
|
var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
|
|
306
312
|
var children = _a.children,
|
|
@@ -338,7 +344,7 @@ var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
|
|
|
338
344
|
}), sx)
|
|
339
345
|
}, props), children, errors && /*#__PURE__*/React.createElement(FormHelperText, {
|
|
340
346
|
variant: "filled"
|
|
341
|
-
}, errors
|
|
347
|
+
}, getErrorMessage(errors)));
|
|
342
348
|
};
|
|
343
349
|
|
|
344
350
|
function getDeepProperty(p, o) {
|
|
@@ -367,11 +373,21 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
|
|
|
367
373
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
|
|
368
374
|
|
|
369
375
|
var labelId = "".concat(name, "-label");
|
|
370
|
-
var inputRef = React.useRef(null);
|
|
371
376
|
|
|
372
377
|
var _useFormContext = useFormContext(),
|
|
373
|
-
control = _useFormContext.control
|
|
374
|
-
|
|
378
|
+
control = _useFormContext.control;
|
|
379
|
+
|
|
380
|
+
var _useController = useController(Object.assign({
|
|
381
|
+
name: name,
|
|
382
|
+
control: control,
|
|
383
|
+
rules: rules,
|
|
384
|
+
defaultValue: defaultValue
|
|
385
|
+
}, defaultProps)),
|
|
386
|
+
_useController$field = _useController.field,
|
|
387
|
+
onChangeField = _useController$field.onChange,
|
|
388
|
+
value = _useController$field.value,
|
|
389
|
+
ref = _useController$field.ref,
|
|
390
|
+
formErrors = _useController.formState.errors;
|
|
375
391
|
|
|
376
392
|
var errors = getErrors(name, formErrors);
|
|
377
393
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
@@ -383,34 +399,19 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
|
|
|
383
399
|
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
384
400
|
variant: "filled",
|
|
385
401
|
id: labelId
|
|
386
|
-
}, label), /*#__PURE__*/React.createElement(
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
label: label,
|
|
391
|
-
inputRef: inputRef,
|
|
392
|
-
name: name,
|
|
393
|
-
onChange: function onChange(changeEvent) {
|
|
394
|
-
_props.onChange(changeEvent.target.value); // default props
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
_onChange(changeEvent);
|
|
398
|
-
},
|
|
399
|
-
value: _props.value,
|
|
400
|
-
variant: "filled"
|
|
401
|
-
}, otherProps), children);
|
|
402
|
-
},
|
|
402
|
+
}, label), /*#__PURE__*/React.createElement(Select, Object.assign({
|
|
403
|
+
labelId: labelId,
|
|
404
|
+
label: label,
|
|
405
|
+
inputRef: ref,
|
|
403
406
|
name: name,
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
rules: rules,
|
|
407
|
-
onFocus: function onFocus() {
|
|
408
|
-
var _a;
|
|
407
|
+
onChange: function onChange(changeEvent) {
|
|
408
|
+
onChangeField(changeEvent.target.value); // default props
|
|
409
409
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
410
|
+
_onChange(changeEvent);
|
|
411
|
+
},
|
|
412
|
+
value: value || '',
|
|
413
|
+
variant: "filled"
|
|
414
|
+
}, otherProps), children));
|
|
414
415
|
};
|
|
415
416
|
|
|
416
417
|
var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
|
|
@@ -428,46 +429,53 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
|
|
|
428
429
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
|
|
429
430
|
|
|
430
431
|
var labelId = "".concat(name, "-label");
|
|
431
|
-
var inputRef = React.useRef(null);
|
|
432
432
|
|
|
433
433
|
var _useFormContext = useFormContext(),
|
|
434
|
-
control = _useFormContext.control
|
|
435
|
-
|
|
434
|
+
control = _useFormContext.control;
|
|
435
|
+
|
|
436
|
+
var _useController = useController(Object.assign({
|
|
437
|
+
name: name,
|
|
438
|
+
control: control,
|
|
439
|
+
rules: rules,
|
|
440
|
+
defaultValue: defaultValue
|
|
441
|
+
}, defaultProps)),
|
|
442
|
+
_useController$field = _useController.field,
|
|
443
|
+
onChangeField = _useController$field.onChange,
|
|
444
|
+
value = _useController$field.value,
|
|
445
|
+
ref = _useController$field.ref,
|
|
446
|
+
formErrors = _useController.formState.errors;
|
|
436
447
|
|
|
437
448
|
var errors = getErrors(name, formErrors);
|
|
449
|
+
React.useEffect(function () {
|
|
450
|
+
if (errors) {
|
|
451
|
+
var firstError = Object.keys(formErrors)[0];
|
|
452
|
+
|
|
453
|
+
if (firstError === name) {
|
|
454
|
+
// if first error in form is same, focus on that input
|
|
455
|
+
var inputNode = document.querySelector("[name=\"".concat(name, "\"]"));
|
|
456
|
+
|
|
457
|
+
if (inputNode !== null) {
|
|
458
|
+
inputNode.focus();
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}, [errors, formErrors, name]);
|
|
438
463
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
439
464
|
disabled: disabled,
|
|
440
465
|
errors: errors,
|
|
441
466
|
isReadOnly: isReadOnly
|
|
442
467
|
}, /*#__PURE__*/React.createElement(InputLabel, {
|
|
443
468
|
id: labelId
|
|
444
|
-
}, label), /*#__PURE__*/React.createElement(
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
onChange: function onChange(changeEvent) {
|
|
449
|
-
_props.onChange(changeEvent.target.value);
|
|
450
|
-
|
|
451
|
-
_onChange(changeEvent, changeEvent.target.value);
|
|
452
|
-
},
|
|
453
|
-
ref: inputRef,
|
|
454
|
-
name: name
|
|
455
|
-
}, otherProps), children);
|
|
456
|
-
},
|
|
457
|
-
name: name,
|
|
458
|
-
control: control,
|
|
459
|
-
defaultValue: defaultValue,
|
|
460
|
-
rules: rules,
|
|
461
|
-
onFocus: function onFocus() {
|
|
462
|
-
// move focus to first radio on error
|
|
463
|
-
var firstElement = inputRef.current.querySelector('input');
|
|
469
|
+
}, label), /*#__PURE__*/React.createElement(RadioGroup, Object.assign({
|
|
470
|
+
value: value,
|
|
471
|
+
onChange: function onChange(changeEvent) {
|
|
472
|
+
onChangeField(changeEvent.target.value);
|
|
464
473
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}));
|
|
474
|
+
_onChange(changeEvent, changeEvent.target.value);
|
|
475
|
+
},
|
|
476
|
+
ref: ref,
|
|
477
|
+
name: name
|
|
478
|
+
}, otherProps), children));
|
|
471
479
|
};
|
|
472
480
|
|
|
473
481
|
var convertTextInputValue = function convertTextInputValue(value, inCapitals) {
|
|
@@ -494,11 +502,20 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
|
|
|
494
502
|
InputProps = _a.InputProps,
|
|
495
503
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
|
|
496
504
|
|
|
497
|
-
var inputRef = React.useRef(null);
|
|
498
|
-
|
|
499
505
|
var _useFormContext = useFormContext(),
|
|
500
|
-
control = _useFormContext.control
|
|
501
|
-
|
|
506
|
+
control = _useFormContext.control;
|
|
507
|
+
|
|
508
|
+
var _useController = useController(Object.assign({
|
|
509
|
+
name: name,
|
|
510
|
+
control: control,
|
|
511
|
+
rules: rules,
|
|
512
|
+
defaultValue: defaultValue
|
|
513
|
+
}, defaultProps)),
|
|
514
|
+
_useController$field = _useController.field,
|
|
515
|
+
onChangeField = _useController$field.onChange,
|
|
516
|
+
value = _useController$field.value,
|
|
517
|
+
ref = _useController$field.ref,
|
|
518
|
+
formErrors = _useController.formState.errors;
|
|
502
519
|
|
|
503
520
|
var errors = getErrors(name, formErrors);
|
|
504
521
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
@@ -507,45 +524,33 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
|
|
|
507
524
|
disabled: disabled,
|
|
508
525
|
errors: errors,
|
|
509
526
|
isReadOnly: isReadOnly
|
|
510
|
-
}, /*#__PURE__*/React.createElement(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
var convertedValue = convertTextInputValue(value, upperCase);
|
|
523
|
-
|
|
524
|
-
_props.onChange(convertedValue);
|
|
527
|
+
}, /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
528
|
+
label: label,
|
|
529
|
+
error: !!errors,
|
|
530
|
+
helperText: helperText,
|
|
531
|
+
value: value,
|
|
532
|
+
variant: "filled",
|
|
533
|
+
type: "text",
|
|
534
|
+
name: name,
|
|
535
|
+
onChange: function onChange(evt) {
|
|
536
|
+
var value = evt.target.value;
|
|
537
|
+
var convertedValue = convertTextInputValue(value, upperCase);
|
|
538
|
+
onChangeField(convertedValue);
|
|
525
539
|
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
disabled: disabled,
|
|
529
|
-
inputRef: inputRef,
|
|
530
|
-
InputProps: Object.assign(Object.assign({}, InputProps), isReadOnly && {
|
|
531
|
-
readOnly: true
|
|
532
|
-
})
|
|
533
|
-
}, otherProps));
|
|
540
|
+
_onChange(null);
|
|
534
541
|
},
|
|
535
|
-
name: name,
|
|
536
|
-
control: control,
|
|
537
|
-
defaultValue: defaultValue,
|
|
538
|
-
rules: rules,
|
|
539
542
|
disabled: disabled,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
}));
|
|
543
|
+
inputRef: ref,
|
|
544
|
+
InputProps: Object.assign(Object.assign({}, InputProps), isReadOnly && {
|
|
545
|
+
readOnly: true
|
|
546
|
+
})
|
|
547
|
+
}, otherProps)));
|
|
547
548
|
};
|
|
548
549
|
|
|
550
|
+
function _slicedToArray(arr, i) {
|
|
551
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
552
|
+
}
|
|
553
|
+
|
|
549
554
|
function _toConsumableArray(arr) {
|
|
550
555
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
551
556
|
}
|
|
@@ -554,10 +559,41 @@ function _arrayWithoutHoles(arr) {
|
|
|
554
559
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
555
560
|
}
|
|
556
561
|
|
|
562
|
+
function _arrayWithHoles(arr) {
|
|
563
|
+
if (Array.isArray(arr)) return arr;
|
|
564
|
+
}
|
|
565
|
+
|
|
557
566
|
function _iterableToArray(iter) {
|
|
558
567
|
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
559
568
|
}
|
|
560
569
|
|
|
570
|
+
function _iterableToArrayLimit(arr, i) {
|
|
571
|
+
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
572
|
+
var _arr = [];
|
|
573
|
+
var _n = true;
|
|
574
|
+
var _d = false;
|
|
575
|
+
var _e = undefined;
|
|
576
|
+
|
|
577
|
+
try {
|
|
578
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
579
|
+
_arr.push(_s.value);
|
|
580
|
+
|
|
581
|
+
if (i && _arr.length === i) break;
|
|
582
|
+
}
|
|
583
|
+
} catch (err) {
|
|
584
|
+
_d = true;
|
|
585
|
+
_e = err;
|
|
586
|
+
} finally {
|
|
587
|
+
try {
|
|
588
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
589
|
+
} finally {
|
|
590
|
+
if (_d) throw _e;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return _arr;
|
|
595
|
+
}
|
|
596
|
+
|
|
561
597
|
function _unsupportedIterableToArray(o, minLen) {
|
|
562
598
|
if (!o) return;
|
|
563
599
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -579,32 +615,16 @@ function _nonIterableSpread() {
|
|
|
579
615
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
580
616
|
}
|
|
581
617
|
|
|
618
|
+
function _nonIterableRest() {
|
|
619
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
620
|
+
}
|
|
621
|
+
|
|
582
622
|
var convertNumericInputValue = function convertNumericInputValue(value, inputMode) {
|
|
583
623
|
if (value !== '' && !isNaN(parseFloat(value))) {
|
|
584
|
-
|
|
585
|
-
return inputMode === 'numeric' ? parseInt(value, 10) : value;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
return value;
|
|
589
|
-
};
|
|
590
|
-
var parseInput = function parseInput(value) {
|
|
591
|
-
// allow '-' at the start of the value
|
|
592
|
-
if (typeof value === 'string' && value.includes('-')) {
|
|
593
|
-
return value.split('-').reduce(function (list, el) {
|
|
594
|
-
if (!el.length && !list.length) {
|
|
595
|
-
return '-';
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
return list.concat(el);
|
|
599
|
-
}, '');
|
|
600
|
-
} // return value when '.' is given
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
if (typeof value === 'string' && value.includes('.')) {
|
|
604
|
-
return value;
|
|
624
|
+
return inputMode === 'numeric' ? parseInt(value, 10) : parseFloat(value);
|
|
605
625
|
}
|
|
606
626
|
|
|
607
|
-
return
|
|
627
|
+
return null;
|
|
608
628
|
};
|
|
609
629
|
var getAllowedKeys = function getAllowedKeys() {
|
|
610
630
|
var inputMode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'numeric';
|
|
@@ -616,7 +636,7 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
|
|
|
616
636
|
var name = _a.name,
|
|
617
637
|
label = _a.label,
|
|
618
638
|
_a$defaultValue = _a.defaultValue,
|
|
619
|
-
defaultValue = _a$defaultValue === void 0 ?
|
|
639
|
+
defaultValue = _a$defaultValue === void 0 ? null : _a$defaultValue,
|
|
620
640
|
rules = _a.rules,
|
|
621
641
|
_a$disabled = _a.disabled,
|
|
622
642
|
disabled = _a$disabled === void 0 ? false : _a$disabled,
|
|
@@ -631,18 +651,22 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
|
|
|
631
651
|
isReadOnly = _a.isReadOnly,
|
|
632
652
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
|
|
633
653
|
|
|
634
|
-
var inputRef = React.useRef(null);
|
|
635
|
-
|
|
636
654
|
var _useFormContext = useFormContext(),
|
|
637
|
-
control = _useFormContext.control
|
|
638
|
-
|
|
655
|
+
control = _useFormContext.control;
|
|
656
|
+
|
|
657
|
+
var _useController = useController(Object.assign({
|
|
658
|
+
name: name,
|
|
659
|
+
control: control,
|
|
660
|
+
rules: rules,
|
|
661
|
+
defaultValue: defaultValue
|
|
662
|
+
}, defaultProps)),
|
|
663
|
+
_useController$field = _useController.field,
|
|
664
|
+
onChangeField = _useController$field.onChange,
|
|
665
|
+
value = _useController$field.value,
|
|
666
|
+
ref = _useController$field.ref,
|
|
667
|
+
formErrors = _useController.formState.errors;
|
|
639
668
|
|
|
640
669
|
var errors = getErrors(name, formErrors);
|
|
641
|
-
var validationRules = Object.assign(Object.assign({}, rules), {
|
|
642
|
-
setValueAs: function setValueAs(value) {
|
|
643
|
-
return parseFloat(value);
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
670
|
var allowedKeyes = getAllowedKeys(inputMode);
|
|
647
671
|
|
|
648
672
|
var onKeyDown = function onKeyDown(event) {
|
|
@@ -653,52 +677,44 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
|
|
|
653
677
|
}
|
|
654
678
|
};
|
|
655
679
|
|
|
680
|
+
var _React$useState = React.useState(value === null || isNaN(value) ? '' : value),
|
|
681
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
682
|
+
displayValue = _React$useState2[0],
|
|
683
|
+
setDisplayValue = _React$useState2[1];
|
|
684
|
+
|
|
656
685
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
657
686
|
className: className,
|
|
658
687
|
sx: sx,
|
|
659
688
|
disabled: disabled,
|
|
660
689
|
errors: errors,
|
|
661
690
|
isReadOnly: isReadOnly
|
|
662
|
-
}, /*#__PURE__*/React.createElement(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
inputProps: {
|
|
673
|
-
inputMode: inputMode
|
|
674
|
-
},
|
|
675
|
-
name: name,
|
|
676
|
-
onChange: function onChange(evt) {
|
|
677
|
-
_props.onChange(convertNumericInputValue(evt.target.value, inputMode));
|
|
678
|
-
|
|
679
|
-
_onChange(null);
|
|
680
|
-
},
|
|
681
|
-
onKeyDown: onKeyDown,
|
|
682
|
-
disabled: disabled,
|
|
683
|
-
inputRef: inputRef,
|
|
684
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
685
|
-
InputProps: Object.assign(Object.assign({}, isReadOnly && {
|
|
686
|
-
readOnly: true
|
|
687
|
-
}), otherProps.InputProps)
|
|
688
|
-
}, otherProps));
|
|
691
|
+
}, /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
692
|
+
label: label,
|
|
693
|
+
error: !!errors,
|
|
694
|
+
helperText: helperText,
|
|
695
|
+
inputMode: inputMode,
|
|
696
|
+
value: displayValue,
|
|
697
|
+
variant: "filled",
|
|
698
|
+
type: "text",
|
|
699
|
+
inputProps: {
|
|
700
|
+
inputMode: inputMode
|
|
689
701
|
},
|
|
690
702
|
name: name,
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
onFocus: function onFocus() {
|
|
696
|
-
var _a;
|
|
703
|
+
onChange: function onChange(evt) {
|
|
704
|
+
var value = evt.target.value;
|
|
705
|
+
setDisplayValue(value);
|
|
706
|
+
onChangeField(convertNumericInputValue(value, inputMode));
|
|
697
707
|
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
708
|
+
_onChange(null);
|
|
709
|
+
},
|
|
710
|
+
onKeyDown: onKeyDown,
|
|
711
|
+
disabled: disabled,
|
|
712
|
+
inputRef: ref,
|
|
713
|
+
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
714
|
+
InputProps: Object.assign(Object.assign({}, isReadOnly && {
|
|
715
|
+
readOnly: true
|
|
716
|
+
}), otherProps.InputProps)
|
|
717
|
+
}, otherProps)));
|
|
702
718
|
};
|
|
703
719
|
|
|
704
720
|
moment$1.tz.setDefault('Etc/GMT-0');
|
|
@@ -728,12 +744,20 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
728
744
|
isReadOnly = _a.isReadOnly,
|
|
729
745
|
otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
|
|
730
746
|
|
|
731
|
-
var inputRef = React.useRef(null);
|
|
732
|
-
|
|
733
747
|
var _useFormContext = useFormContext(),
|
|
734
|
-
control = _useFormContext.control
|
|
735
|
-
|
|
736
|
-
|
|
748
|
+
control = _useFormContext.control;
|
|
749
|
+
|
|
750
|
+
var _useController = useController(Object.assign({
|
|
751
|
+
name: name,
|
|
752
|
+
control: control,
|
|
753
|
+
rules: rules,
|
|
754
|
+
defaultValue: defaultNullValue
|
|
755
|
+
}, defaultProps)),
|
|
756
|
+
_useController$field = _useController.field,
|
|
757
|
+
onChangeField = _useController$field.onChange,
|
|
758
|
+
value = _useController$field.value,
|
|
759
|
+
ref = _useController$field.ref,
|
|
760
|
+
formErrors = _useController.formState.errors;
|
|
737
761
|
|
|
738
762
|
var errors = getErrors(name, formErrors);
|
|
739
763
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
@@ -742,74 +766,58 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
742
766
|
className: className,
|
|
743
767
|
sx: sx,
|
|
744
768
|
isReadOnly: isReadOnly
|
|
745
|
-
}, /*#__PURE__*/React.createElement(
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
_onChange(getFormattedValue(value));
|
|
760
|
-
},
|
|
761
|
-
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
762
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
763
|
-
// @ts-ignore
|
|
764
|
-
focusedView: "month",
|
|
765
|
-
inputRef: inputRef,
|
|
766
|
-
InputAdornmentProps: {
|
|
767
|
-
position: 'start'
|
|
768
|
-
},
|
|
769
|
-
InputProps: Object.assign(Object.assign({
|
|
770
|
-
endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
771
|
-
style: {
|
|
772
|
-
paddingTop: '16px'
|
|
773
|
-
},
|
|
774
|
-
position: "end"
|
|
775
|
-
}, "UTC")
|
|
776
|
-
}, isReadOnly && {
|
|
777
|
-
readOnly: true
|
|
778
|
-
}), otherProps.InputProps),
|
|
779
|
-
hideTabs: false,
|
|
780
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
781
|
-
// @ts-ignore
|
|
782
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
783
|
-
inputProps: disabled ? {
|
|
784
|
-
placeholder: ''
|
|
785
|
-
} : undefined,
|
|
786
|
-
renderInput: function renderInput(_a) {
|
|
787
|
-
_a.error;
|
|
788
|
-
var props = __rest(_a, ["error"]);
|
|
789
|
-
|
|
790
|
-
return /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
791
|
-
helperText: helperText,
|
|
792
|
-
error: !!errors,
|
|
793
|
-
name: name,
|
|
794
|
-
"data-testid": otherProps['data-testid'],
|
|
795
|
-
variant: "filled"
|
|
796
|
-
}, props));
|
|
797
|
-
}
|
|
798
|
-
}, otherProps));
|
|
769
|
+
}, /*#__PURE__*/React.createElement(DateTimePicker, Object.assign({
|
|
770
|
+
desktopModeMediaQuery: "@media (min-width: 720px)",
|
|
771
|
+
ampm: false,
|
|
772
|
+
mask: "____/__/__ __:__",
|
|
773
|
+
inputFormat: format,
|
|
774
|
+
label: label,
|
|
775
|
+
value: value,
|
|
776
|
+
openTo: openTo,
|
|
777
|
+
disabled: disabled,
|
|
778
|
+
onChange: function onChange(value) {
|
|
779
|
+
onChangeField(getFormattedValue(value));
|
|
780
|
+
|
|
781
|
+
_onChange(getFormattedValue(value));
|
|
799
782
|
},
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
783
|
+
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
784
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
785
|
+
// @ts-ignore
|
|
786
|
+
focusedView: "month",
|
|
787
|
+
inputRef: ref,
|
|
788
|
+
InputAdornmentProps: {
|
|
789
|
+
position: 'start'
|
|
790
|
+
},
|
|
791
|
+
InputProps: Object.assign(Object.assign({
|
|
792
|
+
endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
793
|
+
style: {
|
|
794
|
+
paddingTop: '16px'
|
|
795
|
+
},
|
|
796
|
+
position: "end"
|
|
797
|
+
}, "UTC")
|
|
798
|
+
}, isReadOnly && {
|
|
799
|
+
readOnly: true
|
|
800
|
+
}), otherProps.InputProps),
|
|
801
|
+
hideTabs: false,
|
|
802
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
+
// @ts-ignore
|
|
804
|
+
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
805
|
+
inputProps: disabled ? {
|
|
806
|
+
placeholder: ''
|
|
807
|
+
} : undefined,
|
|
808
|
+
renderInput: function renderInput(_a) {
|
|
809
|
+
_a.error;
|
|
810
|
+
var props = __rest(_a, ["error"]);
|
|
806
811
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
812
|
+
return /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
813
|
+
helperText: helperText,
|
|
814
|
+
error: !!errors,
|
|
815
|
+
name: name,
|
|
816
|
+
"data-testid": otherProps['data-testid'],
|
|
817
|
+
variant: "filled"
|
|
818
|
+
}, props));
|
|
811
819
|
}
|
|
812
|
-
}));
|
|
820
|
+
}, otherProps)));
|
|
813
821
|
};
|
|
814
822
|
|
|
815
823
|
/* *
|
|
@@ -837,7 +845,10 @@ var ReactHookFormProvider = function ReactHookFormProvider(_ref) {
|
|
|
837
845
|
var children = _ref.children,
|
|
838
846
|
_ref$options = _ref.options,
|
|
839
847
|
options = _ref$options === void 0 ? defaultFormOptions : _ref$options;
|
|
840
|
-
var formMethods = useForm(options);
|
|
848
|
+
var formMethods = useForm(options); // added this ignore as the build is failing otherwise on: Type instantiation is excessively deep and possibly infinite.
|
|
849
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
850
|
+
// @ts-ignore
|
|
851
|
+
|
|
841
852
|
return /*#__PURE__*/React__default.createElement(FormProvider, Object.assign({}, formMethods), children);
|
|
842
853
|
};
|
|
843
854
|
|
|
@@ -878,17 +889,17 @@ var ReactHookFormHiddenInput = function ReactHookFormHiddenInput(_ref) {
|
|
|
878
889
|
var _useFormContext = useFormContext(),
|
|
879
890
|
control = _useFormContext.control;
|
|
880
891
|
|
|
881
|
-
|
|
882
|
-
render: function render(field) {
|
|
883
|
-
return field.value !== null ? /*#__PURE__*/React.createElement("input", Object.assign({}, field, {
|
|
884
|
-
type: "hidden"
|
|
885
|
-
})) : null;
|
|
886
|
-
},
|
|
892
|
+
var _useController = useController(Object.assign({
|
|
887
893
|
name: name,
|
|
888
894
|
control: control,
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
})
|
|
895
|
+
rules: rules,
|
|
896
|
+
defaultValue: defaultValue
|
|
897
|
+
}, defaultProps)),
|
|
898
|
+
field = _useController.field;
|
|
899
|
+
|
|
900
|
+
return field.value !== null ? /*#__PURE__*/React.createElement("input", Object.assign({}, field, {
|
|
901
|
+
type: "hidden"
|
|
902
|
+
})) : null;
|
|
892
903
|
};
|
|
893
904
|
|
|
894
|
-
export { ReactHookKeyboardDateTimePicker as ReactHookFormDateTime, ReactHookFormFormControl, ReactHookFormHiddenInput, ReactHookFormNumberField, ReactHookFormProviderWrapper as ReactHookFormProvider, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormTextField,
|
|
905
|
+
export { ReactHookKeyboardDateTimePicker as ReactHookFormDateTime, ReactHookFormFormControl, ReactHookFormHiddenInput, ReactHookFormNumberField, ReactHookFormProviderWrapper as ReactHookFormProvider, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormTextField, defaultFormOptions, errorMessages, getDeepProperty, hasIntersectionWithFIR, hasMaxFeaturePoints, hasMulitpleIntersections, isAfter, isBefore, isBetween, isEmpty, isGeometryDirty, isInteger, isLatitude, isLongitude, isMaximumOneDrawing, isNonOrBothCoordinates, isValidDate, isValidGeoJsonCoordinates, isValidMax, isValidMin, isXHoursAfter, isXHoursBefore };
|