@opengeoweb/form-fields 4.2.0 → 4.3.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.esm.js CHANGED
@@ -5,9 +5,9 @@ import { useFormContext, Controller, useForm, FormProvider } from 'react-hook-fo
5
5
  import moment from 'moment';
6
6
  import { isEqual } from 'lodash';
7
7
  import moment$1 from 'moment-timezone';
8
- import { DateTimePicker } from '@mui/lab';
9
- import AdapterMoment from '@mui/lab/AdapterMoment';
10
- import LocalizationProvider from '@mui/lab/LocalizationProvider';
8
+ import { DateTimePicker } from '@mui/x-date-pickers';
9
+ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
10
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
11
11
 
12
12
  /*! *****************************************************************************
13
13
  Copyright (c) Microsoft Corporation.
@@ -284,13 +284,56 @@ var containsNoCommas = function containsNoCommas(val) {
284
284
  var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
285
285
  var children = _a.children,
286
286
  errors = _a.errors,
287
- props = __rest(_a, ["children", "errors"]);
287
+ isReadOnly = _a.isReadOnly,
288
+ _a$sx = _a.sx,
289
+ sx = _a$sx === void 0 ? {} : _a$sx,
290
+ _a$className = _a.className,
291
+ className = _a$className === void 0 ? '' : _a$className,
292
+ props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className"]);
288
293
 
289
294
  return /*#__PURE__*/React.createElement(FormControl, Object.assign({
290
- fullWidth: true
291
- }, props, {
292
- error: !!errors
293
- }), children, errors && /*#__PURE__*/React.createElement(FormHelperText, {
295
+ fullWidth: true,
296
+ error: !!errors,
297
+ className: "".concat(isReadOnly ? 'is-read-only' : '', " ").concat(className),
298
+ sx: Object.assign(Object.assign({}, isReadOnly && {
299
+ // RadioGroup styling
300
+ ' .MuiRadio-root': {
301
+ color: 'geowebColors.typographyAndIcons.iconLinkActive',
302
+ // hides unchecked values
303
+ display: 'none',
304
+ '&+.MuiFormControlLabel-label': {
305
+ display: 'none'
306
+ },
307
+ // shows checked value
308
+ '&.Mui-checked': {
309
+ display: 'inherit',
310
+ '&+.MuiFormControlLabel-label': {
311
+ display: 'inherit'
312
+ }
313
+ }
314
+ },
315
+ ' .MuiFormControlLabel-label.Mui-disabled': {
316
+ color: 'geowebColors.typographyAndIcons.text'
317
+ },
318
+ ' .Mui-disabled.Mui-checked': {
319
+ color: 'geowebColors.typographyAndIcons.iconLinkActive'
320
+ },
321
+ // Select styling
322
+ ' .MuiSelect-select': {
323
+ color: 'geowebColors.typographyAndIcons.text',
324
+ WebkitTextFillColor: 'inherit',
325
+ '&:before': {
326
+ borderColor: 'transparent'
327
+ }
328
+ },
329
+ ' .MuiSelect-nativeInput+.MuiSvgIcon-root': {
330
+ display: 'none'
331
+ },
332
+ ' .Mui-disabled:before': {
333
+ border: 'transparent'
334
+ }
335
+ }), sx)
336
+ }, props), children, errors && /*#__PURE__*/React.createElement(FormHelperText, {
294
337
  variant: "filled"
295
338
  }, errors.message || errorMessages[errors.type]));
296
339
  };
@@ -317,7 +360,8 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
317
360
  disabled = _a.disabled,
318
361
  className = _a.className,
319
362
  sx = _a.sx,
320
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx"]);
363
+ isReadOnly = _a.isReadOnly,
364
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
321
365
 
322
366
  var labelId = "".concat(name, "-label");
323
367
  var inputRef = React.useRef(null);
@@ -331,7 +375,8 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
331
375
  className: className,
332
376
  sx: sx,
333
377
  disabled: disabled,
334
- errors: errors
378
+ errors: errors,
379
+ isReadOnly: isReadOnly
335
380
  }, /*#__PURE__*/React.createElement(InputLabel, {
336
381
  variant: "filled",
337
382
  id: labelId
@@ -376,7 +421,8 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
376
421
  disabled = _a$disabled === void 0 ? false : _a$disabled,
377
422
  _a$onChange = _a.onChange,
378
423
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
379
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
424
+ isReadOnly = _a.isReadOnly,
425
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
380
426
 
381
427
  var labelId = "".concat(name, "-label");
382
428
  var inputRef = React.useRef(null);
@@ -388,7 +434,8 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
388
434
  var errors = getErrors(name, formErrors);
389
435
  return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
390
436
  disabled: disabled,
391
- errors: errors
437
+ errors: errors,
438
+ isReadOnly: isReadOnly
392
439
  }, /*#__PURE__*/React.createElement(InputLabel, {
393
440
  id: labelId
394
441
  }, label), /*#__PURE__*/React.createElement(Controller, {
@@ -440,7 +487,9 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
440
487
  sx = _a.sx,
441
488
  _a$onChange = _a.onChange,
442
489
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
443
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
490
+ isReadOnly = _a.isReadOnly,
491
+ InputProps = _a.InputProps,
492
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
444
493
 
445
494
  var inputRef = React.useRef(null);
446
495
 
@@ -453,7 +502,8 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
453
502
  className: className,
454
503
  sx: sx,
455
504
  disabled: disabled,
456
- errors: errors
505
+ errors: errors,
506
+ isReadOnly: isReadOnly
457
507
  }, /*#__PURE__*/React.createElement(Controller, {
458
508
  render: function render(_props) {
459
509
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
@@ -473,7 +523,10 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
473
523
  _onChange(null);
474
524
  },
475
525
  disabled: disabled,
476
- inputRef: inputRef
526
+ inputRef: inputRef,
527
+ InputProps: Object.assign(Object.assign({}, InputProps), isReadOnly && {
528
+ readOnly: true
529
+ })
477
530
  }, otherProps));
478
531
  },
479
532
  name: name,
@@ -572,7 +625,8 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
572
625
  sx = _a.sx,
573
626
  _a$onChange = _a.onChange,
574
627
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
575
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
628
+ isReadOnly = _a.isReadOnly,
629
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
576
630
 
577
631
  var inputRef = React.useRef(null);
578
632
 
@@ -600,7 +654,8 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
600
654
  className: className,
601
655
  sx: sx,
602
656
  disabled: disabled,
603
- errors: errors
657
+ errors: errors,
658
+ isReadOnly: isReadOnly
604
659
  }, /*#__PURE__*/React.createElement(Controller, {
605
660
  render: function render(_props) {
606
661
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
@@ -622,7 +677,11 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
622
677
  },
623
678
  onKeyDown: onKeyDown,
624
679
  disabled: disabled,
625
- inputRef: inputRef
680
+ inputRef: inputRef,
681
+ // eslint-disable-next-line react/jsx-no-duplicate-props
682
+ InputProps: Object.assign(Object.assign({}, isReadOnly && {
683
+ readOnly: true
684
+ }), otherProps.InputProps)
626
685
  }, otherProps));
627
686
  },
628
687
  name: name,
@@ -663,7 +722,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
663
722
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
664
723
  className = _a.className,
665
724
  sx = _a.sx,
666
- otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx"]);
725
+ isReadOnly = _a.isReadOnly,
726
+ otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
667
727
 
668
728
  var inputRef = React.useRef(null);
669
729
 
@@ -677,7 +737,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
677
737
  disabled: disabled,
678
738
  errors: errors,
679
739
  className: className,
680
- sx: sx
740
+ sx: sx,
741
+ isReadOnly: isReadOnly
681
742
  }, /*#__PURE__*/React.createElement(Controller, {
682
743
  render: function render(_props) {
683
744
  return /*#__PURE__*/React.createElement(DateTimePicker, Object.assign({
@@ -694,18 +755,25 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
694
755
 
695
756
  _onChange(getFormattedValue(value));
696
757
  },
758
+ // if focusedView is removed, it will throw an error when switching day to month mode
759
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
760
+ // @ts-ignore
761
+ focusedView: "month",
697
762
  inputRef: inputRef,
698
763
  InputAdornmentProps: {
699
764
  position: 'start'
700
765
  },
701
- InputProps: {
766
+ InputProps: Object.assign(Object.assign({
702
767
  endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
703
768
  style: {
704
769
  paddingTop: '16px'
705
770
  },
706
771
  position: "end"
707
772
  }, "UTC")
708
- },
773
+ }, isReadOnly && {
774
+ readOnly: true
775
+ }), otherProps.InputProps),
776
+ hideTabs: false,
709
777
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
710
778
  // @ts-ignore
711
779
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -794,8 +862,8 @@ var ReactHookFormProviderWrapper = function ReactHookFormProviderWrapper(_ref2)
794
862
  * See the License for the specific language governing permissions and
795
863
  * limitations under the License.
796
864
  *
797
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
798
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
865
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
866
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
799
867
  * */
800
868
 
801
869
  var ReactHookFormHiddenInput = function ReactHookFormHiddenInput(_ref) {
package/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
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/lab'), require('@mui/lab/AdapterMoment'), require('@mui/lab/LocalizationProvider')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@mui/material', 'react-hook-form', 'moment', 'lodash', 'moment-timezone', '@mui/lab', '@mui/lab/AdapterMoment', '@mui/lab/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.lab, global.AdapterMoment, global.LocalizationProvider));
5
- })(this, (function (exports, React, material, reactHookForm, moment, lodash, moment$1, lab, AdapterMoment, LocalizationProvider) { 'use strict';
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
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -28,8 +28,6 @@
28
28
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
29
29
  var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
30
30
  var moment__default$1 = /*#__PURE__*/_interopDefaultLegacy(moment$1);
31
- var AdapterMoment__default = /*#__PURE__*/_interopDefaultLegacy(AdapterMoment);
32
- var LocalizationProvider__default = /*#__PURE__*/_interopDefaultLegacy(LocalizationProvider);
33
31
 
34
32
  /*! *****************************************************************************
35
33
  Copyright (c) Microsoft Corporation.
@@ -351,13 +349,56 @@
351
349
  var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
352
350
  var children = _a.children,
353
351
  errors = _a.errors,
354
- props = __rest(_a, ["children", "errors"]);
352
+ isReadOnly = _a.isReadOnly,
353
+ _b = _a.sx,
354
+ sx = _b === void 0 ? {} : _b,
355
+ _c = _a.className,
356
+ className = _c === void 0 ? '' : _c,
357
+ props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className"]);
355
358
 
356
359
  return /*#__PURE__*/React__namespace.createElement(material.FormControl, __assign({
357
- fullWidth: true
358
- }, props, {
359
- error: !!errors
360
- }), children, errors && /*#__PURE__*/React__namespace.createElement(material.FormHelperText, {
360
+ fullWidth: true,
361
+ error: !!errors,
362
+ className: (isReadOnly ? 'is-read-only' : '') + " " + className,
363
+ sx: __assign(__assign({}, isReadOnly && {
364
+ // RadioGroup styling
365
+ ' .MuiRadio-root': {
366
+ color: 'geowebColors.typographyAndIcons.iconLinkActive',
367
+ // hides unchecked values
368
+ display: 'none',
369
+ '&+.MuiFormControlLabel-label': {
370
+ display: 'none'
371
+ },
372
+ // shows checked value
373
+ '&.Mui-checked': {
374
+ display: 'inherit',
375
+ '&+.MuiFormControlLabel-label': {
376
+ display: 'inherit'
377
+ }
378
+ }
379
+ },
380
+ ' .MuiFormControlLabel-label.Mui-disabled': {
381
+ color: 'geowebColors.typographyAndIcons.text'
382
+ },
383
+ ' .Mui-disabled.Mui-checked': {
384
+ color: 'geowebColors.typographyAndIcons.iconLinkActive'
385
+ },
386
+ // Select styling
387
+ ' .MuiSelect-select': {
388
+ color: 'geowebColors.typographyAndIcons.text',
389
+ WebkitTextFillColor: 'inherit',
390
+ '&:before': {
391
+ borderColor: 'transparent'
392
+ }
393
+ },
394
+ ' .MuiSelect-nativeInput+.MuiSvgIcon-root': {
395
+ display: 'none'
396
+ },
397
+ ' .Mui-disabled:before': {
398
+ border: 'transparent'
399
+ }
400
+ }), sx)
401
+ }, props), children, errors && /*#__PURE__*/React__namespace.createElement(material.FormHelperText, {
361
402
  variant: "filled"
362
403
  }, errors.message || errorMessages[errors.type]));
363
404
  };
@@ -384,7 +425,8 @@
384
425
  disabled = _a.disabled,
385
426
  className = _a.className,
386
427
  sx = _a.sx,
387
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx"]);
428
+ isReadOnly = _a.isReadOnly,
429
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
388
430
 
389
431
  var labelId = name + "-label";
390
432
  var inputRef = React__namespace.useRef(null);
@@ -398,7 +440,8 @@
398
440
  className: className,
399
441
  sx: sx,
400
442
  disabled: disabled,
401
- errors: errors
443
+ errors: errors,
444
+ isReadOnly: isReadOnly
402
445
  }, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
403
446
  variant: "filled",
404
447
  id: labelId
@@ -443,7 +486,8 @@
443
486
  disabled = _c === void 0 ? false : _c,
444
487
  _d = _a.onChange,
445
488
  _onChange = _d === void 0 ? function () {} : _d,
446
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
489
+ isReadOnly = _a.isReadOnly,
490
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
447
491
 
448
492
  var labelId = name + "-label";
449
493
  var inputRef = React__namespace.useRef(null);
@@ -455,7 +499,8 @@
455
499
  var errors = getErrors(name, formErrors);
456
500
  return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
457
501
  disabled: disabled,
458
- errors: errors
502
+ errors: errors,
503
+ isReadOnly: isReadOnly
459
504
  }, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
460
505
  id: labelId
461
506
  }, label), /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
@@ -507,7 +552,9 @@
507
552
  sx = _a.sx,
508
553
  _f = _a.onChange,
509
554
  _onChange = _f === void 0 ? function () {} : _f,
510
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
555
+ isReadOnly = _a.isReadOnly,
556
+ InputProps = _a.InputProps,
557
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
511
558
 
512
559
  var inputRef = React__namespace.useRef(null);
513
560
 
@@ -520,7 +567,8 @@
520
567
  className: className,
521
568
  sx: sx,
522
569
  disabled: disabled,
523
- errors: errors
570
+ errors: errors,
571
+ isReadOnly: isReadOnly
524
572
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
525
573
  render: function render(_props) {
526
574
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
@@ -540,7 +588,10 @@
540
588
  _onChange(null);
541
589
  },
542
590
  disabled: disabled,
543
- inputRef: inputRef
591
+ inputRef: inputRef,
592
+ InputProps: __assign(__assign({}, InputProps), isReadOnly && {
593
+ readOnly: true
594
+ })
544
595
  }, otherProps));
545
596
  },
546
597
  name: name,
@@ -610,7 +661,8 @@
610
661
  sx = _a.sx,
611
662
  _f = _a.onChange,
612
663
  _onChange = _f === void 0 ? function () {} : _f,
613
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
664
+ isReadOnly = _a.isReadOnly,
665
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
614
666
 
615
667
  var inputRef = React__namespace.useRef(null);
616
668
 
@@ -640,7 +692,8 @@
640
692
  className: className,
641
693
  sx: sx,
642
694
  disabled: disabled,
643
- errors: errors
695
+ errors: errors,
696
+ isReadOnly: isReadOnly
644
697
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
645
698
  render: function render(_props) {
646
699
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
@@ -662,7 +715,11 @@
662
715
  },
663
716
  onKeyDown: onKeyDown,
664
717
  disabled: disabled,
665
- inputRef: inputRef
718
+ inputRef: inputRef,
719
+ // eslint-disable-next-line react/jsx-no-duplicate-props
720
+ InputProps: __assign(__assign({}, isReadOnly && {
721
+ readOnly: true
722
+ }), otherProps.InputProps)
666
723
  }, otherProps));
667
724
  },
668
725
  name: name,
@@ -703,7 +760,8 @@
703
760
  _onChange = _g === void 0 ? function () {} : _g,
704
761
  className = _a.className,
705
762
  sx = _a.sx,
706
- otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx"]);
763
+ isReadOnly = _a.isReadOnly,
764
+ otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
707
765
 
708
766
  var inputRef = React__namespace.useRef(null);
709
767
 
@@ -717,10 +775,11 @@
717
775
  disabled: disabled,
718
776
  errors: errors,
719
777
  className: className,
720
- sx: sx
778
+ sx: sx,
779
+ isReadOnly: isReadOnly
721
780
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
722
781
  render: function render(_props) {
723
- return /*#__PURE__*/React__namespace.createElement(lab.DateTimePicker, __assign({
782
+ return /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
724
783
  desktopModeMediaQuery: "@media (min-width: 720px)",
725
784
  ampm: false,
726
785
  mask: "____/__/__ __:__",
@@ -734,18 +793,25 @@
734
793
 
735
794
  _onChange(getFormattedValue(value));
736
795
  },
796
+ // if focusedView is removed, it will throw an error when switching day to month mode
797
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
798
+ // @ts-ignore
799
+ focusedView: "month",
737
800
  inputRef: inputRef,
738
801
  InputAdornmentProps: {
739
802
  position: 'start'
740
803
  },
741
- InputProps: {
804
+ InputProps: __assign(__assign({
742
805
  endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
743
806
  style: {
744
807
  paddingTop: '16px'
745
808
  },
746
809
  position: "end"
747
810
  }, "UTC")
748
- },
811
+ }, isReadOnly && {
812
+ readOnly: true
813
+ }), otherProps.InputProps),
814
+ hideTabs: false,
749
815
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
750
816
  // @ts-ignore
751
817
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -798,8 +864,8 @@
798
864
  var children = _a.children,
799
865
  _b = _a.options,
800
866
  options = _b === void 0 ? defaultFormOptions : _b;
801
- return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider__default["default"], {
802
- dateAdapter: AdapterMoment__default["default"]
867
+ return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider.LocalizationProvider, {
868
+ dateAdapter: AdapterMoment.AdapterMoment
803
869
  }, /*#__PURE__*/React__default["default"].createElement(ReactHookFormProvider, {
804
870
  options: options
805
871
  }, children));
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { UseFormOptions } from 'react-hook-form';
3
+ export declare const zeplinLinks: {
4
+ name: string;
5
+ link: string;
6
+ }[];
7
+ export interface StoryLayoutProps {
8
+ children?: React.ReactNode;
9
+ }
10
+ export interface FormFieldsWrapperProps {
11
+ children?: React.ReactNode;
12
+ options?: UseFormOptions;
13
+ isDarkTheme?: boolean;
14
+ }
15
+ export declare const FormFieldsWrapper: React.FC<FormFieldsWrapperProps>;
16
+ interface FormFieldsWrapperOldThemeProps {
17
+ children: React.ReactNode;
18
+ options?: UseFormOptions;
19
+ }
20
+ export declare const FormFieldsWrapperOldTheme: React.FC<FormFieldsWrapperOldThemeProps>;
21
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,19 +1,16 @@
1
1
  import * as React from 'react';
2
2
  import { SxProps, Theme } from '@mui/material';
3
3
  import { Moment } from 'moment-timezone';
4
- import { DateTimePickerProps } from '@mui/lab';
5
- import { Rules } from './types';
4
+ import { DateTimePickerProps } from '@mui/x-date-pickers';
5
+ import { DateTimePickerSlotsComponent } from '@mui/x-date-pickers/DateTimePicker/DateTimePicker';
6
+ import { ReactHookFormInput } from './types';
6
7
  export declare const getFormattedValue: (value: Moment | string) => string | Moment;
7
- declare type ReactHookKeyboardDateTimePickerProps = Partial<DateTimePickerProps> & {
8
- rules: Rules;
8
+ declare type ReactHookKeyboardDateTimePickerProps = Partial<Partial<DateTimePickerProps<DateTimePickerSlotsComponent, Moment>>> & ReactHookFormInput<{
9
9
  defaultNullValue?: string | null;
10
10
  value?: string;
11
11
  onChange?: (value: any) => void;
12
- name: string;
13
- helperText?: string;
14
- label?: string;
15
12
  format?: string;
16
13
  sx?: SxProps<Theme>;
17
- };
14
+ }>;
18
15
  declare const ReactHookKeyboardDateTimePicker: React.FC<ReactHookKeyboardDateTimePickerProps>;
19
16
  export default ReactHookKeyboardDateTimePicker;
@@ -3,8 +3,36 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const DateTime: () => React.ReactElement;
7
- export declare const DateTimeSnapshot: {
6
+ export declare const DateTime: {
7
+ (): React.ReactElement;
8
+ parameters: {
9
+ zeplinLink: {
10
+ name: string;
11
+ link: string;
12
+ }[];
13
+ };
14
+ };
15
+ export declare const DateTimeLightTheme: {
16
+ (): React.ReactElement;
17
+ storyName: string;
18
+ parameters: {
19
+ zeplinLink: {
20
+ name: string;
21
+ link: string;
22
+ }[];
23
+ };
24
+ };
25
+ export declare const DateTimeDarkTheme: {
26
+ (): React.ReactElement;
27
+ storyName: string;
28
+ parameters: {
29
+ zeplinLink: {
30
+ name: string;
31
+ link: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare const DateTimeOldTheme: {
8
36
  (): React.ReactElement;
9
37
  storyName: string;
10
38
  };
@@ -2,7 +2,9 @@ import * as React from 'react';
2
2
  import { FormControlProps } from '@mui/material';
3
3
  import { FieldErrors } from 'react-hook-form';
4
4
  interface ReactHookFormFormControlProps extends FormControlProps {
5
+ children?: React.ReactNode;
5
6
  errors?: FieldErrors;
7
+ isReadOnly?: boolean;
6
8
  }
7
9
  declare const ReactHookFormFormControl: React.FC<ReactHookFormFormControlProps>;
8
10
  export default ReactHookFormFormControl;
@@ -1,9 +1,7 @@
1
1
  import * as React from 'react';
2
- import { RegisterOptions } from 'react-hook-form';
3
- interface ReactHookFormHiddenInputProps {
4
- name: string;
2
+ import { ReactHookFormInput } from './types';
3
+ declare type ReactHookFormHiddenInputProps = ReactHookFormInput<{
5
4
  defaultValue?: unknown;
6
- rules?: RegisterOptions;
7
- }
5
+ }>;
8
6
  declare const ReactHookFormHiddenInput: React.FC<ReactHookFormHiddenInputProps>;
9
7
  export default ReactHookFormHiddenInput;
@@ -4,3 +4,5 @@ declare const _default: {
4
4
  };
5
5
  export default _default;
6
6
  export declare const HiddenInput: () => React.ReactElement;
7
+ export declare const HiddenInputDarkTheme: () => React.ReactElement;
8
+ export declare const HiddenInputOldTheme: () => React.ReactElement;
@@ -1,13 +1,12 @@
1
1
  import * as React from 'react';
2
2
  import { TextFieldProps } from '@mui/material';
3
- import { Rules } from './types';
3
+ import { ReactHookFormInput } from './types';
4
4
  declare type InputMode = 'numeric' | 'decimal';
5
5
  export declare const convertNumericInputValue: (value: string, inputMode: InputMode) => number | string;
6
6
  export declare const parseInput: (value?: string | number | null | undefined) => string;
7
7
  export declare const getAllowedKeys: (inputMode?: InputMode) => string[];
8
- declare type ReactHookFormNumberFieldProps = Partial<TextFieldProps> & {
9
- rules: Rules;
8
+ declare type ReactHookFormNumberFieldProps = Partial<TextFieldProps> & ReactHookFormInput<{
10
9
  inputMode?: InputMode;
11
- };
10
+ }>;
12
11
  declare const ReactHookFormNumberField: React.FC<ReactHookFormNumberFieldProps>;
13
12
  export default ReactHookFormNumberField;
@@ -3,8 +3,36 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const NumberField: () => React.ReactElement;
7
- export declare const NumberFieldSnapshotWrapped: {
6
+ export declare const NumberField: {
7
+ (): React.ReactElement;
8
+ parameters: {
9
+ zeplinLinks: {
10
+ name: string;
11
+ link: string;
12
+ }[];
13
+ };
14
+ };
15
+ export declare const NumberFieldLightTheme: {
16
+ (): React.ReactElement;
17
+ storyName: string;
18
+ parameters: {
19
+ zeplinLink: {
20
+ name: string;
21
+ link: string;
22
+ }[];
23
+ };
24
+ };
25
+ export declare const NumberFieldDarkTheme: {
26
+ (): React.ReactElement;
27
+ storyName: string;
28
+ parameters: {
29
+ zeplinLink: {
30
+ name: string;
31
+ link: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare const NumberFieldOldTheme: {
8
36
  (): React.ReactElement;
9
37
  storyName: string;
10
38
  };
@@ -3,4 +3,36 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const FormProvider: () => React.ReactElement;
6
+ export declare const FormProvider: {
7
+ (): React.ReactElement;
8
+ parameters: {
9
+ zeplinLink: {
10
+ name: string;
11
+ link: string;
12
+ }[];
13
+ };
14
+ };
15
+ export declare const FormProviderLightTheme: {
16
+ (): React.ReactElement;
17
+ storyName: string;
18
+ parameters: {
19
+ zeplinLink: {
20
+ name: string;
21
+ link: string;
22
+ }[];
23
+ };
24
+ };
25
+ export declare const FormProviderDarkTheme: {
26
+ (): React.ReactElement;
27
+ storyName: string;
28
+ parameters: {
29
+ zeplinLink: {
30
+ name: string;
31
+ link: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare const FormProviderOldTheme: {
36
+ (): React.ReactElement;
37
+ storyName: string;
38
+ };
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { RadioGroupProps } from '@mui/material';
3
- import { Rules } from './types';
4
- declare type ReactHookFormRadioGroupProps = Partial<RadioGroupProps> & {
5
- rules: Rules;
6
- label?: string;
3
+ import { ReactHookFormInput } from './types';
4
+ declare type ReactHookFormRadioGroupProps = Partial<RadioGroupProps> & ReactHookFormInput<{
7
5
  disabled?: boolean;
8
- };
6
+ children?: React.ReactNode;
7
+ }>;
9
8
  declare const ReactHookFormRadioGroup: React.FC<ReactHookFormRadioGroupProps>;
10
9
  export default ReactHookFormRadioGroup;
@@ -3,8 +3,36 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const RadioGroup: () => React.ReactElement;
7
- export declare const RadioGroupSnapshot: {
6
+ export declare const RadioGroup: {
7
+ (): React.ReactElement;
8
+ parameters: {
9
+ zeplinLink: {
10
+ name: string;
11
+ link: string;
12
+ }[];
13
+ };
14
+ };
15
+ export declare const RadioGroupLightTheme: {
16
+ (): React.ReactElement;
17
+ storyName: string;
18
+ parameters: {
19
+ zeplinLink: {
20
+ name: string;
21
+ link: string;
22
+ }[];
23
+ };
24
+ };
25
+ export declare const RadioGroupDarkTheme: {
26
+ (): React.ReactElement;
27
+ storyName: string;
28
+ parameters: {
29
+ zeplinLink: {
30
+ name: string;
31
+ link: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare const RadioGroupOldTheme: {
8
36
  (): React.ReactElement;
9
37
  storyName: string;
10
38
  };
@@ -1,9 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { SelectProps } from '@mui/material';
3
- import { Rules } from './types';
4
- declare type ReactHookFormSelectProps = Partial<SelectProps> & {
5
- rules: Rules;
3
+ import { ReactHookFormInput } from './types';
4
+ declare type ReactHookFormSelectProps = Partial<SelectProps> & ReactHookFormInput<{
6
5
  onChange?: (value: any) => void;
7
- };
6
+ }>;
8
7
  declare const ReactHookFormSelect: React.FC<ReactHookFormSelectProps>;
9
8
  export default ReactHookFormSelect;
@@ -4,7 +4,27 @@ declare const _default: {
4
4
  };
5
5
  export default _default;
6
6
  export declare const Select: () => React.ReactElement;
7
- export declare const SelectSnapshot: {
7
+ export declare const SelectLightTheme: {
8
+ (): React.ReactElement;
9
+ storyName: string;
10
+ parameters: {
11
+ zeplinLink: {
12
+ name: string;
13
+ link: string;
14
+ }[];
15
+ };
16
+ };
17
+ export declare const SelectDarkTheme: {
18
+ (): React.ReactElement;
19
+ storyName: string;
20
+ parameters: {
21
+ zeplinLink: {
22
+ name: string;
23
+ link: string;
24
+ }[];
25
+ };
26
+ };
27
+ export declare const SelectOldTheme: {
8
28
  (): React.ReactElement;
9
29
  storyName: string;
10
30
  };
@@ -1,10 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { TextFieldProps } from '@mui/material';
3
- import { Rules } from './types';
3
+ import { ReactHookFormInput } from './types';
4
4
  export declare const convertTextInputValue: (value: string, inCapitals: boolean) => number | string;
5
- declare type ReactHookFormTextFieldProps = Partial<TextFieldProps> & {
6
- rules: Rules;
5
+ declare type ReactHookFormTextFieldProps = Partial<TextFieldProps> & ReactHookFormInput<{
7
6
  upperCase?: boolean;
8
- };
7
+ }>;
9
8
  declare const ReactHookFormTextField: React.FC<ReactHookFormTextFieldProps>;
10
9
  export default ReactHookFormTextField;
@@ -3,8 +3,36 @@ declare const _default: {
3
3
  title: string;
4
4
  };
5
5
  export default _default;
6
- export declare const TextField: () => React.ReactElement;
7
- export declare const TextFieldSnapshot: {
6
+ export declare const TextField: {
7
+ (): React.ReactElement;
8
+ parameters: {
9
+ zeplinLink: {
10
+ name: string;
11
+ link: string;
12
+ }[];
13
+ };
14
+ };
15
+ export declare const TextFieldLightTheme: {
16
+ (): React.ReactElement;
17
+ storyName: string;
18
+ parameters: {
19
+ zeplinLink: {
20
+ name: string;
21
+ link: string;
22
+ }[];
23
+ };
24
+ };
25
+ export declare const TextFieldDarkTheme: {
26
+ (): React.ReactElement;
27
+ storyName: string;
28
+ parameters: {
29
+ zeplinLink: {
30
+ name: string;
31
+ link: string;
32
+ }[];
33
+ };
34
+ };
35
+ export declare const TextFieldOldTheme: {
8
36
  (): React.ReactElement;
9
37
  storyName: string;
10
38
  };
@@ -1,9 +1,8 @@
1
- import { FormControlProps } from '@mui/material';
2
1
  import { RegisterOptions } from 'react-hook-form';
3
- export declare type Rules = RegisterOptions;
4
- export interface ReactHookFormInput extends FormControlProps {
2
+ export declare type ReactHookFormInput<T> = T & {
5
3
  name: string;
6
4
  label?: string;
7
- rules?: Rules;
5
+ rules?: RegisterOptions;
8
6
  helperText?: string;
9
- }
7
+ isReadOnly?: boolean;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/form-fields",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "GeoWeb form-fields library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -14,11 +14,11 @@
14
14
  "peerDependencies": {
15
15
  "react-hook-form": "^6.12.1",
16
16
  "react": "^17.0.2",
17
- "@mui/material": "^5.2.8",
17
+ "@mui/material": "^5.10.8",
18
+ "@opengeoweb/theme": "4.3.0",
18
19
  "moment": "^2.29.0",
19
- "@opengeoweb/theme": "4.2.0",
20
20
  "moment-timezone": "^0.5.31",
21
- "@mui/lab": "^5.0.0-alpha.64",
21
+ "@mui/x-date-pickers": "^5.0.4",
22
22
  "lodash": "^4.17.20"
23
23
  }
24
24
  }