@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.umd.js
CHANGED
|
@@ -110,6 +110,9 @@
|
|
|
110
110
|
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
111
111
|
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
112
112
|
* */
|
|
113
|
+
var defaultProps = {
|
|
114
|
+
shouldUnregister: true
|
|
115
|
+
};
|
|
113
116
|
var errorMessages = {
|
|
114
117
|
required: 'This field is required',
|
|
115
118
|
isValidDate: 'Not a valid date',
|
|
@@ -125,7 +128,6 @@
|
|
|
125
128
|
isNonOrBothCoordinates: 'Please enter both coordinates',
|
|
126
129
|
isInteger: 'Invalid entry, enter a non-decimal number',
|
|
127
130
|
isNumeric: 'Invalid entry, enter a numeric value',
|
|
128
|
-
containsNoCommas: 'Please use a dot (.) as decimal separator',
|
|
129
131
|
minVisibility: 'The minimum visibility is 0',
|
|
130
132
|
maxVisibility: 'The maximum visibility is 4900'
|
|
131
133
|
};
|
|
@@ -328,23 +330,16 @@
|
|
|
328
330
|
return Number.isInteger(value);
|
|
329
331
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
330
332
|
var isNonOrBothCoordinates = function isNonOrBothCoordinates(coordinate, otherCoordinate) {
|
|
331
|
-
if (coordinate && otherCoordinate ||
|
|
333
|
+
if (typeof coordinate === 'number' && typeof otherCoordinate === 'number' || coordinate === null && otherCoordinate === null || coordinate === undefined && otherCoordinate === undefined) {
|
|
332
334
|
return true;
|
|
333
335
|
}
|
|
334
336
|
|
|
335
|
-
if (coordinate) {
|
|
337
|
+
if (typeof coordinate === 'number') {
|
|
336
338
|
return true;
|
|
337
339
|
}
|
|
338
340
|
|
|
339
341
|
return false;
|
|
340
342
|
};
|
|
341
|
-
var containsNoCommas = function containsNoCommas(val) {
|
|
342
|
-
if (typeof val === 'string' && val.includes(',')) {
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return true;
|
|
347
|
-
};
|
|
348
343
|
|
|
349
344
|
var radioCheckboxStyle = {
|
|
350
345
|
// hides unchecked values
|
|
@@ -366,6 +361,17 @@
|
|
|
366
361
|
color: 'geowebColors.typographyAndIcons.iconLinkActive'
|
|
367
362
|
}
|
|
368
363
|
};
|
|
364
|
+
var getErrorMessage = function getErrorMessage(errors) {
|
|
365
|
+
if (errors && errors.message && typeof errors.message === 'string') {
|
|
366
|
+
return errors.message;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (errors && errors.type && typeof errors.type === 'string') {
|
|
370
|
+
return errorMessages[errors.type];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return '';
|
|
374
|
+
};
|
|
369
375
|
|
|
370
376
|
var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
|
|
371
377
|
var children = _a.children,
|
|
@@ -403,7 +409,7 @@
|
|
|
403
409
|
}), sx)
|
|
404
410
|
}, props), children, errors && /*#__PURE__*/React__namespace.createElement(material.FormHelperText, {
|
|
405
411
|
variant: "filled"
|
|
406
|
-
}, errors
|
|
412
|
+
}, getErrorMessage(errors)));
|
|
407
413
|
};
|
|
408
414
|
|
|
409
415
|
function getDeepProperty(p, o) {
|
|
@@ -432,11 +438,19 @@
|
|
|
432
438
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
|
|
433
439
|
|
|
434
440
|
var labelId = name + "-label";
|
|
435
|
-
var
|
|
441
|
+
var control = reactHookForm.useFormContext().control;
|
|
436
442
|
|
|
437
|
-
var _d = reactHookForm.
|
|
438
|
-
|
|
439
|
-
|
|
443
|
+
var _d = reactHookForm.useController(__assign({
|
|
444
|
+
name: name,
|
|
445
|
+
control: control,
|
|
446
|
+
rules: rules,
|
|
447
|
+
defaultValue: defaultValue
|
|
448
|
+
}, defaultProps)),
|
|
449
|
+
_e = _d.field,
|
|
450
|
+
onChangeField = _e.onChange,
|
|
451
|
+
value = _e.value,
|
|
452
|
+
ref = _e.ref,
|
|
453
|
+
formErrors = _d.formState.errors;
|
|
440
454
|
|
|
441
455
|
var errors = getErrors(name, formErrors);
|
|
442
456
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
@@ -448,34 +462,19 @@
|
|
|
448
462
|
}, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
|
|
449
463
|
variant: "filled",
|
|
450
464
|
id: labelId
|
|
451
|
-
}, label), /*#__PURE__*/React__namespace.createElement(
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
label: label,
|
|
456
|
-
inputRef: inputRef,
|
|
457
|
-
name: name,
|
|
458
|
-
onChange: function onChange(changeEvent) {
|
|
459
|
-
_props.onChange(changeEvent.target.value); // default props
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
_onChange(changeEvent);
|
|
463
|
-
},
|
|
464
|
-
value: _props.value,
|
|
465
|
-
variant: "filled"
|
|
466
|
-
}, otherProps), children);
|
|
467
|
-
},
|
|
465
|
+
}, label), /*#__PURE__*/React__namespace.createElement(material.Select, __assign({
|
|
466
|
+
labelId: labelId,
|
|
467
|
+
label: label,
|
|
468
|
+
inputRef: ref,
|
|
468
469
|
name: name,
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
rules: rules,
|
|
472
|
-
onFocus: function onFocus() {
|
|
473
|
-
var _a;
|
|
470
|
+
onChange: function onChange(changeEvent) {
|
|
471
|
+
onChangeField(changeEvent.target.value); // default props
|
|
474
472
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
473
|
+
_onChange(changeEvent);
|
|
474
|
+
},
|
|
475
|
+
value: value || '',
|
|
476
|
+
variant: "filled"
|
|
477
|
+
}, otherProps), children));
|
|
479
478
|
};
|
|
480
479
|
|
|
481
480
|
var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
|
|
@@ -493,46 +492,51 @@
|
|
|
493
492
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
|
|
494
493
|
|
|
495
494
|
var labelId = name + "-label";
|
|
496
|
-
var
|
|
495
|
+
var control = reactHookForm.useFormContext().control;
|
|
497
496
|
|
|
498
|
-
var _e = reactHookForm.
|
|
499
|
-
|
|
500
|
-
|
|
497
|
+
var _e = reactHookForm.useController(__assign({
|
|
498
|
+
name: name,
|
|
499
|
+
control: control,
|
|
500
|
+
rules: rules,
|
|
501
|
+
defaultValue: defaultValue
|
|
502
|
+
}, defaultProps)),
|
|
503
|
+
_f = _e.field,
|
|
504
|
+
onChangeField = _f.onChange,
|
|
505
|
+
value = _f.value,
|
|
506
|
+
ref = _f.ref,
|
|
507
|
+
formErrors = _e.formState.errors;
|
|
501
508
|
|
|
502
509
|
var errors = getErrors(name, formErrors);
|
|
510
|
+
React__namespace.useEffect(function () {
|
|
511
|
+
if (errors) {
|
|
512
|
+
var firstError = Object.keys(formErrors)[0];
|
|
513
|
+
|
|
514
|
+
if (firstError === name) {
|
|
515
|
+
// if first error in form is same, focus on that input
|
|
516
|
+
var inputNode = document.querySelector("[name=\"" + name + "\"]");
|
|
517
|
+
|
|
518
|
+
if (inputNode !== null) {
|
|
519
|
+
inputNode.focus();
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}, [errors, formErrors, name]);
|
|
503
524
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
504
525
|
disabled: disabled,
|
|
505
526
|
errors: errors,
|
|
506
527
|
isReadOnly: isReadOnly
|
|
507
528
|
}, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
|
|
508
529
|
id: labelId
|
|
509
|
-
}, label), /*#__PURE__*/React__namespace.createElement(
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
onChange: function onChange(changeEvent) {
|
|
514
|
-
_props.onChange(changeEvent.target.value);
|
|
515
|
-
|
|
516
|
-
_onChange(changeEvent, changeEvent.target.value);
|
|
517
|
-
},
|
|
518
|
-
ref: inputRef,
|
|
519
|
-
name: name
|
|
520
|
-
}, otherProps), children);
|
|
521
|
-
},
|
|
522
|
-
name: name,
|
|
523
|
-
control: control,
|
|
524
|
-
defaultValue: defaultValue,
|
|
525
|
-
rules: rules,
|
|
526
|
-
onFocus: function onFocus() {
|
|
527
|
-
// move focus to first radio on error
|
|
528
|
-
var firstElement = inputRef.current.querySelector('input');
|
|
530
|
+
}, label), /*#__PURE__*/React__namespace.createElement(material.RadioGroup, __assign({
|
|
531
|
+
value: value,
|
|
532
|
+
onChange: function onChange(changeEvent) {
|
|
533
|
+
onChangeField(changeEvent.target.value);
|
|
529
534
|
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}));
|
|
535
|
+
_onChange(changeEvent, changeEvent.target.value);
|
|
536
|
+
},
|
|
537
|
+
ref: ref,
|
|
538
|
+
name: name
|
|
539
|
+
}, otherProps), children));
|
|
536
540
|
};
|
|
537
541
|
|
|
538
542
|
var convertTextInputValue = function convertTextInputValue(value, inCapitals) {
|
|
@@ -559,11 +563,19 @@
|
|
|
559
563
|
InputProps = _a.InputProps,
|
|
560
564
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
|
|
561
565
|
|
|
562
|
-
var
|
|
566
|
+
var control = reactHookForm.useFormContext().control;
|
|
563
567
|
|
|
564
|
-
var _g = reactHookForm.
|
|
565
|
-
|
|
566
|
-
|
|
568
|
+
var _g = reactHookForm.useController(__assign({
|
|
569
|
+
name: name,
|
|
570
|
+
control: control,
|
|
571
|
+
rules: rules,
|
|
572
|
+
defaultValue: defaultValue
|
|
573
|
+
}, defaultProps)),
|
|
574
|
+
_h = _g.field,
|
|
575
|
+
onChangeField = _h.onChange,
|
|
576
|
+
value = _h.value,
|
|
577
|
+
ref = _h.ref,
|
|
578
|
+
formErrors = _g.formState.errors;
|
|
567
579
|
|
|
568
580
|
var errors = getErrors(name, formErrors);
|
|
569
581
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
@@ -572,71 +584,35 @@
|
|
|
572
584
|
disabled: disabled,
|
|
573
585
|
errors: errors,
|
|
574
586
|
isReadOnly: isReadOnly
|
|
575
|
-
}, /*#__PURE__*/React__namespace.createElement(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
var convertedValue = convertTextInputValue(value, upperCase);
|
|
588
|
-
|
|
589
|
-
_props.onChange(convertedValue);
|
|
587
|
+
}, /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
588
|
+
label: label,
|
|
589
|
+
error: !!errors,
|
|
590
|
+
helperText: helperText,
|
|
591
|
+
value: value,
|
|
592
|
+
variant: "filled",
|
|
593
|
+
type: "text",
|
|
594
|
+
name: name,
|
|
595
|
+
onChange: function onChange(evt) {
|
|
596
|
+
var value = evt.target.value;
|
|
597
|
+
var convertedValue = convertTextInputValue(value, upperCase);
|
|
598
|
+
onChangeField(convertedValue);
|
|
590
599
|
|
|
591
|
-
|
|
592
|
-
},
|
|
593
|
-
disabled: disabled,
|
|
594
|
-
inputRef: inputRef,
|
|
595
|
-
InputProps: __assign(__assign({}, InputProps), isReadOnly && {
|
|
596
|
-
readOnly: true
|
|
597
|
-
})
|
|
598
|
-
}, otherProps));
|
|
600
|
+
_onChange(null);
|
|
599
601
|
},
|
|
600
|
-
name: name,
|
|
601
|
-
control: control,
|
|
602
|
-
defaultValue: defaultValue,
|
|
603
|
-
rules: rules,
|
|
604
602
|
disabled: disabled,
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
}));
|
|
603
|
+
inputRef: ref,
|
|
604
|
+
InputProps: __assign(__assign({}, InputProps), isReadOnly && {
|
|
605
|
+
readOnly: true
|
|
606
|
+
})
|
|
607
|
+
}, otherProps)));
|
|
612
608
|
};
|
|
613
609
|
|
|
614
610
|
var convertNumericInputValue = function convertNumericInputValue(value, inputMode) {
|
|
615
611
|
if (value !== '' && !isNaN(parseFloat(value))) {
|
|
616
|
-
|
|
617
|
-
return inputMode === 'numeric' ? parseInt(value, 10) : value;
|
|
612
|
+
return inputMode === 'numeric' ? parseInt(value, 10) : parseFloat(value);
|
|
618
613
|
}
|
|
619
614
|
|
|
620
|
-
return
|
|
621
|
-
};
|
|
622
|
-
var parseInput = function parseInput(value) {
|
|
623
|
-
// allow '-' at the start of the value
|
|
624
|
-
if (typeof value === 'string' && value.includes('-')) {
|
|
625
|
-
return value.split('-').reduce(function (list, el) {
|
|
626
|
-
if (!el.length && !list.length) {
|
|
627
|
-
return '-';
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
return list.concat(el);
|
|
631
|
-
}, '');
|
|
632
|
-
} // return value when '.' is given
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
if (typeof value === 'string' && value.includes('.')) {
|
|
636
|
-
return value;
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
return value == null || isNaN(value) ? '' : value.toString();
|
|
615
|
+
return null;
|
|
640
616
|
};
|
|
641
617
|
var getAllowedKeys = function getAllowedKeys(inputMode) {
|
|
642
618
|
if (inputMode === void 0) {
|
|
@@ -652,7 +628,7 @@
|
|
|
652
628
|
var name = _a.name,
|
|
653
629
|
label = _a.label,
|
|
654
630
|
_b = _a.defaultValue,
|
|
655
|
-
defaultValue = _b === void 0 ?
|
|
631
|
+
defaultValue = _b === void 0 ? null : _b,
|
|
656
632
|
rules = _a.rules,
|
|
657
633
|
_c = _a.disabled,
|
|
658
634
|
disabled = _c === void 0 ? false : _c,
|
|
@@ -667,20 +643,21 @@
|
|
|
667
643
|
isReadOnly = _a.isReadOnly,
|
|
668
644
|
otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
|
|
669
645
|
|
|
670
|
-
var
|
|
646
|
+
var control = reactHookForm.useFormContext().control;
|
|
671
647
|
|
|
672
|
-
var _g = reactHookForm.
|
|
673
|
-
|
|
674
|
-
|
|
648
|
+
var _g = reactHookForm.useController(__assign({
|
|
649
|
+
name: name,
|
|
650
|
+
control: control,
|
|
651
|
+
rules: rules,
|
|
652
|
+
defaultValue: defaultValue
|
|
653
|
+
}, defaultProps)),
|
|
654
|
+
_h = _g.field,
|
|
655
|
+
onChangeField = _h.onChange,
|
|
656
|
+
value = _h.value,
|
|
657
|
+
ref = _h.ref,
|
|
658
|
+
formErrors = _g.formState.errors;
|
|
675
659
|
|
|
676
660
|
var errors = getErrors(name, formErrors);
|
|
677
|
-
|
|
678
|
-
var validationRules = __assign(__assign({}, rules), {
|
|
679
|
-
setValueAs: function setValueAs(value) {
|
|
680
|
-
return parseFloat(value);
|
|
681
|
-
}
|
|
682
|
-
});
|
|
683
|
-
|
|
684
661
|
var allowedKeyes = getAllowedKeys(inputMode);
|
|
685
662
|
|
|
686
663
|
var onKeyDown = function onKeyDown(event) {
|
|
@@ -691,52 +668,43 @@
|
|
|
691
668
|
}
|
|
692
669
|
};
|
|
693
670
|
|
|
671
|
+
var _j = __read(React__namespace.useState(value === null || isNaN(value) ? '' : value), 2),
|
|
672
|
+
displayValue = _j[0],
|
|
673
|
+
setDisplayValue = _j[1];
|
|
674
|
+
|
|
694
675
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
695
676
|
className: className,
|
|
696
677
|
sx: sx,
|
|
697
678
|
disabled: disabled,
|
|
698
679
|
errors: errors,
|
|
699
680
|
isReadOnly: isReadOnly
|
|
700
|
-
}, /*#__PURE__*/React__namespace.createElement(
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
inputProps: {
|
|
711
|
-
inputMode: inputMode
|
|
712
|
-
},
|
|
713
|
-
name: name,
|
|
714
|
-
onChange: function onChange(evt) {
|
|
715
|
-
_props.onChange(convertNumericInputValue(evt.target.value, inputMode));
|
|
716
|
-
|
|
717
|
-
_onChange(null);
|
|
718
|
-
},
|
|
719
|
-
onKeyDown: onKeyDown,
|
|
720
|
-
disabled: disabled,
|
|
721
|
-
inputRef: inputRef,
|
|
722
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
723
|
-
InputProps: __assign(__assign({}, isReadOnly && {
|
|
724
|
-
readOnly: true
|
|
725
|
-
}), otherProps.InputProps)
|
|
726
|
-
}, otherProps));
|
|
681
|
+
}, /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
682
|
+
label: label,
|
|
683
|
+
error: !!errors,
|
|
684
|
+
helperText: helperText,
|
|
685
|
+
inputMode: inputMode,
|
|
686
|
+
value: displayValue,
|
|
687
|
+
variant: "filled",
|
|
688
|
+
type: "text",
|
|
689
|
+
inputProps: {
|
|
690
|
+
inputMode: inputMode
|
|
727
691
|
},
|
|
728
692
|
name: name,
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
onFocus: function onFocus() {
|
|
734
|
-
var _a;
|
|
693
|
+
onChange: function onChange(evt) {
|
|
694
|
+
var value = evt.target.value;
|
|
695
|
+
setDisplayValue(value);
|
|
696
|
+
onChangeField(convertNumericInputValue(value, inputMode));
|
|
735
697
|
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
698
|
+
_onChange(null);
|
|
699
|
+
},
|
|
700
|
+
onKeyDown: onKeyDown,
|
|
701
|
+
disabled: disabled,
|
|
702
|
+
inputRef: ref,
|
|
703
|
+
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
704
|
+
InputProps: __assign(__assign({}, isReadOnly && {
|
|
705
|
+
readOnly: true
|
|
706
|
+
}), otherProps.InputProps)
|
|
707
|
+
}, otherProps)));
|
|
740
708
|
};
|
|
741
709
|
|
|
742
710
|
moment__default$1["default"].tz.setDefault('Etc/GMT-0');
|
|
@@ -766,12 +734,19 @@
|
|
|
766
734
|
isReadOnly = _a.isReadOnly,
|
|
767
735
|
otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
|
|
768
736
|
|
|
769
|
-
var
|
|
737
|
+
var control = reactHookForm.useFormContext().control;
|
|
770
738
|
|
|
771
|
-
var _h = reactHookForm.
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
739
|
+
var _h = reactHookForm.useController(__assign({
|
|
740
|
+
name: name,
|
|
741
|
+
control: control,
|
|
742
|
+
rules: rules,
|
|
743
|
+
defaultValue: defaultNullValue
|
|
744
|
+
}, defaultProps)),
|
|
745
|
+
_j = _h.field,
|
|
746
|
+
onChangeField = _j.onChange,
|
|
747
|
+
value = _j.value,
|
|
748
|
+
ref = _j.ref,
|
|
749
|
+
formErrors = _h.formState.errors;
|
|
775
750
|
|
|
776
751
|
var errors = getErrors(name, formErrors);
|
|
777
752
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
@@ -780,74 +755,58 @@
|
|
|
780
755
|
className: className,
|
|
781
756
|
sx: sx,
|
|
782
757
|
isReadOnly: isReadOnly
|
|
783
|
-
}, /*#__PURE__*/React__namespace.createElement(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
_onChange(getFormattedValue(value));
|
|
798
|
-
},
|
|
799
|
-
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
800
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
801
|
-
// @ts-ignore
|
|
802
|
-
focusedView: "month",
|
|
803
|
-
inputRef: inputRef,
|
|
804
|
-
InputAdornmentProps: {
|
|
805
|
-
position: 'start'
|
|
806
|
-
},
|
|
807
|
-
InputProps: __assign(__assign({
|
|
808
|
-
endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
|
|
809
|
-
style: {
|
|
810
|
-
paddingTop: '16px'
|
|
811
|
-
},
|
|
812
|
-
position: "end"
|
|
813
|
-
}, "UTC")
|
|
814
|
-
}, isReadOnly && {
|
|
815
|
-
readOnly: true
|
|
816
|
-
}), otherProps.InputProps),
|
|
817
|
-
hideTabs: false,
|
|
818
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
819
|
-
// @ts-ignore
|
|
820
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
821
|
-
inputProps: disabled ? {
|
|
822
|
-
placeholder: ''
|
|
823
|
-
} : undefined,
|
|
824
|
-
renderInput: function renderInput(_a) {
|
|
825
|
-
_a.error;
|
|
826
|
-
var props = __rest(_a, ["error"]);
|
|
827
|
-
|
|
828
|
-
return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
829
|
-
helperText: helperText,
|
|
830
|
-
error: !!errors,
|
|
831
|
-
name: name,
|
|
832
|
-
"data-testid": otherProps['data-testid'],
|
|
833
|
-
variant: "filled"
|
|
834
|
-
}, props));
|
|
835
|
-
}
|
|
836
|
-
}, otherProps));
|
|
758
|
+
}, /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
|
|
759
|
+
desktopModeMediaQuery: "@media (min-width: 720px)",
|
|
760
|
+
ampm: false,
|
|
761
|
+
mask: "____/__/__ __:__",
|
|
762
|
+
inputFormat: format,
|
|
763
|
+
label: label,
|
|
764
|
+
value: value,
|
|
765
|
+
openTo: openTo,
|
|
766
|
+
disabled: disabled,
|
|
767
|
+
onChange: function onChange(value) {
|
|
768
|
+
onChangeField(getFormattedValue(value));
|
|
769
|
+
|
|
770
|
+
_onChange(getFormattedValue(value));
|
|
837
771
|
},
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
772
|
+
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
773
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
774
|
+
// @ts-ignore
|
|
775
|
+
focusedView: "month",
|
|
776
|
+
inputRef: ref,
|
|
777
|
+
InputAdornmentProps: {
|
|
778
|
+
position: 'start'
|
|
779
|
+
},
|
|
780
|
+
InputProps: __assign(__assign({
|
|
781
|
+
endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
|
|
782
|
+
style: {
|
|
783
|
+
paddingTop: '16px'
|
|
784
|
+
},
|
|
785
|
+
position: "end"
|
|
786
|
+
}, "UTC")
|
|
787
|
+
}, isReadOnly && {
|
|
788
|
+
readOnly: true
|
|
789
|
+
}), otherProps.InputProps),
|
|
790
|
+
hideTabs: false,
|
|
791
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
792
|
+
// @ts-ignore
|
|
793
|
+
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
794
|
+
inputProps: disabled ? {
|
|
795
|
+
placeholder: ''
|
|
796
|
+
} : undefined,
|
|
797
|
+
renderInput: function renderInput(_a) {
|
|
798
|
+
_a.error;
|
|
799
|
+
var props = __rest(_a, ["error"]);
|
|
844
800
|
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
801
|
+
return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
802
|
+
helperText: helperText,
|
|
803
|
+
error: !!errors,
|
|
804
|
+
name: name,
|
|
805
|
+
"data-testid": otherProps['data-testid'],
|
|
806
|
+
variant: "filled"
|
|
807
|
+
}, props));
|
|
849
808
|
}
|
|
850
|
-
}));
|
|
809
|
+
}, otherProps)));
|
|
851
810
|
};
|
|
852
811
|
|
|
853
812
|
var defaultFormOptions = {
|
|
@@ -859,7 +818,10 @@
|
|
|
859
818
|
var children = _a.children,
|
|
860
819
|
_b = _a.options,
|
|
861
820
|
options = _b === void 0 ? defaultFormOptions : _b;
|
|
862
|
-
var formMethods = reactHookForm.useForm(options);
|
|
821
|
+
var formMethods = reactHookForm.useForm(options); // added this ignore as the build is failing otherwise on: Type instantiation is excessively deep and possibly infinite.
|
|
822
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
823
|
+
// @ts-ignore
|
|
824
|
+
|
|
863
825
|
return /*#__PURE__*/React__default["default"].createElement(reactHookForm.FormProvider, __assign({}, formMethods), children);
|
|
864
826
|
};
|
|
865
827
|
|
|
@@ -880,17 +842,15 @@
|
|
|
880
842
|
defaultValue = _b === void 0 ? null : _b,
|
|
881
843
|
rules = _a.rules;
|
|
882
844
|
var control = reactHookForm.useFormContext().control;
|
|
883
|
-
|
|
884
|
-
render: function render(field) {
|
|
885
|
-
return field.value !== null ? /*#__PURE__*/React__namespace.createElement("input", __assign({}, field, {
|
|
886
|
-
type: "hidden"
|
|
887
|
-
})) : null;
|
|
888
|
-
},
|
|
845
|
+
var field = reactHookForm.useController(__assign({
|
|
889
846
|
name: name,
|
|
890
847
|
control: control,
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
});
|
|
848
|
+
rules: rules,
|
|
849
|
+
defaultValue: defaultValue
|
|
850
|
+
}, defaultProps)).field;
|
|
851
|
+
return field.value !== null ? /*#__PURE__*/React__namespace.createElement("input", __assign({}, field, {
|
|
852
|
+
type: "hidden"
|
|
853
|
+
})) : null;
|
|
894
854
|
};
|
|
895
855
|
|
|
896
856
|
exports.ReactHookFormDateTime = ReactHookKeyboardDateTimePicker;
|
|
@@ -901,7 +861,6 @@
|
|
|
901
861
|
exports.ReactHookFormRadioGroup = ReactHookFormRadioGroup;
|
|
902
862
|
exports.ReactHookFormSelect = ReactHookFormSelect;
|
|
903
863
|
exports.ReactHookFormTextField = ReactHookFormTextField;
|
|
904
|
-
exports.containsNoCommas = containsNoCommas;
|
|
905
864
|
exports.defaultFormOptions = defaultFormOptions;
|
|
906
865
|
exports.errorMessages = errorMessages;
|
|
907
866
|
exports.getDeepProperty = getDeepProperty;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { UseFormProps } from 'react-hook-form';
|
|
3
3
|
export declare const zeplinLinks: {
|
|
4
4
|
name: string;
|
|
5
5
|
link: string;
|
|
@@ -9,13 +9,13 @@ export interface StoryLayoutProps {
|
|
|
9
9
|
}
|
|
10
10
|
export interface FormFieldsWrapperProps {
|
|
11
11
|
children?: React.ReactNode;
|
|
12
|
-
options?:
|
|
12
|
+
options?: UseFormProps;
|
|
13
13
|
isDarkTheme?: boolean;
|
|
14
14
|
}
|
|
15
15
|
export declare const FormFieldsWrapper: React.FC<FormFieldsWrapperProps>;
|
|
16
16
|
interface FormFieldsWrapperOldThemeProps {
|
|
17
17
|
children: React.ReactNode;
|
|
18
|
-
options?:
|
|
18
|
+
options?: UseFormProps;
|
|
19
19
|
}
|
|
20
20
|
export declare const FormFieldsWrapperOldTheme: React.FC<FormFieldsWrapperOldThemeProps>;
|
|
21
21
|
export {};
|