@opengeoweb/form-fields 4.2.0 → 4.4.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.
@@ -281,16 +281,62 @@ var containsNoCommas = function containsNoCommas(val) {
281
281
  return true;
282
282
  };
283
283
 
284
+ var radioCheckboxStyle = {
285
+ // hides unchecked values
286
+ display: 'none',
287
+ '&+.MuiFormControlLabel-label': {
288
+ display: 'none'
289
+ },
290
+ // shows checked value
291
+ '&.Mui-checked': {
292
+ display: 'inherit',
293
+ '&+.MuiFormControlLabel-label': {
294
+ display: 'inherit'
295
+ }
296
+ },
297
+ '&.Mui-checked+.MuiFormControlLabel-label': {
298
+ color: 'geowebColors.typographyAndIcons.text'
299
+ },
300
+ '&.Mui-disabled.Mui-checked': {
301
+ color: 'geowebColors.typographyAndIcons.iconLinkActive'
302
+ }
303
+ };
304
+
284
305
  var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
285
306
  var children = _a.children,
286
307
  errors = _a.errors,
287
- props = __rest(_a, ["children", "errors"]);
308
+ isReadOnly = _a.isReadOnly,
309
+ _a$sx = _a.sx,
310
+ sx = _a$sx === void 0 ? {} : _a$sx,
311
+ _a$className = _a.className,
312
+ className = _a$className === void 0 ? '' : _a$className,
313
+ props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className"]);
288
314
 
289
315
  return /*#__PURE__*/React.createElement(FormControl, Object.assign({
290
- fullWidth: true
291
- }, props, {
292
- error: !!errors
293
- }), children, errors && /*#__PURE__*/React.createElement(FormHelperText, {
316
+ fullWidth: true,
317
+ error: !!errors,
318
+ className: "".concat(isReadOnly ? 'is-read-only' : '', " ").concat(className),
319
+ sx: Object.assign(Object.assign({}, isReadOnly && {
320
+ // Radio input
321
+ '.MuiRadio-root': radioCheckboxStyle,
322
+ // Checkbox input
323
+ '.MuiCheckbox-root': radioCheckboxStyle,
324
+ // Select input
325
+ '.MuiSelect-select.Mui-disabled': {
326
+ color: 'geowebColors.typographyAndIcons.text',
327
+ WebkitTextFillColor: 'inherit',
328
+ '&:before': {
329
+ borderColor: 'transparent'
330
+ }
331
+ },
332
+ '.MuiSelect-nativeInput+.MuiSvgIcon-root': {
333
+ display: 'none'
334
+ },
335
+ '.Mui-disabled:before': {
336
+ border: 'transparent'
337
+ }
338
+ }), sx)
339
+ }, props), children, errors && /*#__PURE__*/React.createElement(FormHelperText, {
294
340
  variant: "filled"
295
341
  }, errors.message || errorMessages[errors.type]));
296
342
  };
@@ -317,7 +363,8 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
317
363
  disabled = _a.disabled,
318
364
  className = _a.className,
319
365
  sx = _a.sx,
320
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx"]);
366
+ isReadOnly = _a.isReadOnly,
367
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
321
368
 
322
369
  var labelId = "".concat(name, "-label");
323
370
  var inputRef = React.useRef(null);
@@ -331,7 +378,8 @@ var ReactHookFormSelect = function ReactHookFormSelect(_a) {
331
378
  className: className,
332
379
  sx: sx,
333
380
  disabled: disabled,
334
- errors: errors
381
+ errors: errors,
382
+ isReadOnly: isReadOnly
335
383
  }, /*#__PURE__*/React.createElement(InputLabel, {
336
384
  variant: "filled",
337
385
  id: labelId
@@ -376,7 +424,8 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
376
424
  disabled = _a$disabled === void 0 ? false : _a$disabled,
377
425
  _a$onChange = _a.onChange,
378
426
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
379
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
427
+ isReadOnly = _a.isReadOnly,
428
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
380
429
 
381
430
  var labelId = "".concat(name, "-label");
382
431
  var inputRef = React.useRef(null);
@@ -388,7 +437,8 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
388
437
  var errors = getErrors(name, formErrors);
389
438
  return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
390
439
  disabled: disabled,
391
- errors: errors
440
+ errors: errors,
441
+ isReadOnly: isReadOnly
392
442
  }, /*#__PURE__*/React.createElement(InputLabel, {
393
443
  id: labelId
394
444
  }, label), /*#__PURE__*/React.createElement(Controller, {
@@ -440,7 +490,9 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
440
490
  sx = _a.sx,
441
491
  _a$onChange = _a.onChange,
442
492
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
443
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
493
+ isReadOnly = _a.isReadOnly,
494
+ InputProps = _a.InputProps,
495
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
444
496
 
445
497
  var inputRef = React.useRef(null);
446
498
 
@@ -453,7 +505,8 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
453
505
  className: className,
454
506
  sx: sx,
455
507
  disabled: disabled,
456
- errors: errors
508
+ errors: errors,
509
+ isReadOnly: isReadOnly
457
510
  }, /*#__PURE__*/React.createElement(Controller, {
458
511
  render: function render(_props) {
459
512
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
@@ -473,7 +526,10 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
473
526
  _onChange(null);
474
527
  },
475
528
  disabled: disabled,
476
- inputRef: inputRef
529
+ inputRef: inputRef,
530
+ InputProps: Object.assign(Object.assign({}, InputProps), isReadOnly && {
531
+ readOnly: true
532
+ })
477
533
  }, otherProps));
478
534
  },
479
535
  name: name,
@@ -572,7 +628,8 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
572
628
  sx = _a.sx,
573
629
  _a$onChange = _a.onChange,
574
630
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
575
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
631
+ isReadOnly = _a.isReadOnly,
632
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
576
633
 
577
634
  var inputRef = React.useRef(null);
578
635
 
@@ -600,7 +657,8 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
600
657
  className: className,
601
658
  sx: sx,
602
659
  disabled: disabled,
603
- errors: errors
660
+ errors: errors,
661
+ isReadOnly: isReadOnly
604
662
  }, /*#__PURE__*/React.createElement(Controller, {
605
663
  render: function render(_props) {
606
664
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
@@ -622,7 +680,11 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
622
680
  },
623
681
  onKeyDown: onKeyDown,
624
682
  disabled: disabled,
625
- inputRef: inputRef
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)
626
688
  }, otherProps));
627
689
  },
628
690
  name: name,
@@ -663,7 +725,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
663
725
  _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
664
726
  className = _a.className,
665
727
  sx = _a.sx,
666
- otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx"]);
728
+ isReadOnly = _a.isReadOnly,
729
+ otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
667
730
 
668
731
  var inputRef = React.useRef(null);
669
732
 
@@ -677,7 +740,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
677
740
  disabled: disabled,
678
741
  errors: errors,
679
742
  className: className,
680
- sx: sx
743
+ sx: sx,
744
+ isReadOnly: isReadOnly
681
745
  }, /*#__PURE__*/React.createElement(Controller, {
682
746
  render: function render(_props) {
683
747
  return /*#__PURE__*/React.createElement(DateTimePicker, Object.assign({
@@ -694,18 +758,25 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
694
758
 
695
759
  _onChange(getFormattedValue(value));
696
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",
697
765
  inputRef: inputRef,
698
766
  InputAdornmentProps: {
699
767
  position: 'start'
700
768
  },
701
- InputProps: {
769
+ InputProps: Object.assign(Object.assign({
702
770
  endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
703
771
  style: {
704
772
  paddingTop: '16px'
705
773
  },
706
774
  position: "end"
707
775
  }, "UTC")
708
- },
776
+ }, isReadOnly && {
777
+ readOnly: true
778
+ }), otherProps.InputProps),
779
+ hideTabs: false,
709
780
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
710
781
  // @ts-ignore
711
782
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -794,8 +865,8 @@ var ReactHookFormProviderWrapper = function ReactHookFormProviderWrapper(_ref2)
794
865
  * See the License for the specific language governing permissions and
795
866
  * limitations under the License.
796
867
  *
797
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
798
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
868
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
869
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
799
870
  * */
800
871
 
801
872
  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.
@@ -348,16 +346,62 @@
348
346
  return true;
349
347
  };
350
348
 
349
+ var radioCheckboxStyle = {
350
+ // hides unchecked values
351
+ display: 'none',
352
+ '&+.MuiFormControlLabel-label': {
353
+ display: 'none'
354
+ },
355
+ // shows checked value
356
+ '&.Mui-checked': {
357
+ display: 'inherit',
358
+ '&+.MuiFormControlLabel-label': {
359
+ display: 'inherit'
360
+ }
361
+ },
362
+ '&.Mui-checked+.MuiFormControlLabel-label': {
363
+ color: 'geowebColors.typographyAndIcons.text'
364
+ },
365
+ '&.Mui-disabled.Mui-checked': {
366
+ color: 'geowebColors.typographyAndIcons.iconLinkActive'
367
+ }
368
+ };
369
+
351
370
  var ReactHookFormFormControl = function ReactHookFormFormControl(_a) {
352
371
  var children = _a.children,
353
372
  errors = _a.errors,
354
- props = __rest(_a, ["children", "errors"]);
373
+ isReadOnly = _a.isReadOnly,
374
+ _b = _a.sx,
375
+ sx = _b === void 0 ? {} : _b,
376
+ _c = _a.className,
377
+ className = _c === void 0 ? '' : _c,
378
+ props = __rest(_a, ["children", "errors", "isReadOnly", "sx", "className"]);
355
379
 
356
380
  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, {
381
+ fullWidth: true,
382
+ error: !!errors,
383
+ className: (isReadOnly ? 'is-read-only' : '') + " " + className,
384
+ sx: __assign(__assign({}, isReadOnly && {
385
+ // Radio input
386
+ '.MuiRadio-root': radioCheckboxStyle,
387
+ // Checkbox input
388
+ '.MuiCheckbox-root': radioCheckboxStyle,
389
+ // Select input
390
+ '.MuiSelect-select.Mui-disabled': {
391
+ color: 'geowebColors.typographyAndIcons.text',
392
+ WebkitTextFillColor: 'inherit',
393
+ '&:before': {
394
+ borderColor: 'transparent'
395
+ }
396
+ },
397
+ '.MuiSelect-nativeInput+.MuiSvgIcon-root': {
398
+ display: 'none'
399
+ },
400
+ '.Mui-disabled:before': {
401
+ border: 'transparent'
402
+ }
403
+ }), sx)
404
+ }, props), children, errors && /*#__PURE__*/React__namespace.createElement(material.FormHelperText, {
361
405
  variant: "filled"
362
406
  }, errors.message || errorMessages[errors.type]));
363
407
  };
@@ -384,7 +428,8 @@
384
428
  disabled = _a.disabled,
385
429
  className = _a.className,
386
430
  sx = _a.sx,
387
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx"]);
431
+ isReadOnly = _a.isReadOnly,
432
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "onChange", "disabled", "className", "sx", "isReadOnly"]);
388
433
 
389
434
  var labelId = name + "-label";
390
435
  var inputRef = React__namespace.useRef(null);
@@ -398,7 +443,8 @@
398
443
  className: className,
399
444
  sx: sx,
400
445
  disabled: disabled,
401
- errors: errors
446
+ errors: errors,
447
+ isReadOnly: isReadOnly
402
448
  }, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
403
449
  variant: "filled",
404
450
  id: labelId
@@ -443,7 +489,8 @@
443
489
  disabled = _c === void 0 ? false : _c,
444
490
  _d = _a.onChange,
445
491
  _onChange = _d === void 0 ? function () {} : _d,
446
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
492
+ isReadOnly = _a.isReadOnly,
493
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
447
494
 
448
495
  var labelId = name + "-label";
449
496
  var inputRef = React__namespace.useRef(null);
@@ -455,7 +502,8 @@
455
502
  var errors = getErrors(name, formErrors);
456
503
  return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
457
504
  disabled: disabled,
458
- errors: errors
505
+ errors: errors,
506
+ isReadOnly: isReadOnly
459
507
  }, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
460
508
  id: labelId
461
509
  }, label), /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
@@ -507,7 +555,9 @@
507
555
  sx = _a.sx,
508
556
  _f = _a.onChange,
509
557
  _onChange = _f === void 0 ? function () {} : _f,
510
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
558
+ isReadOnly = _a.isReadOnly,
559
+ InputProps = _a.InputProps,
560
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
511
561
 
512
562
  var inputRef = React__namespace.useRef(null);
513
563
 
@@ -520,7 +570,8 @@
520
570
  className: className,
521
571
  sx: sx,
522
572
  disabled: disabled,
523
- errors: errors
573
+ errors: errors,
574
+ isReadOnly: isReadOnly
524
575
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
525
576
  render: function render(_props) {
526
577
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
@@ -540,7 +591,10 @@
540
591
  _onChange(null);
541
592
  },
542
593
  disabled: disabled,
543
- inputRef: inputRef
594
+ inputRef: inputRef,
595
+ InputProps: __assign(__assign({}, InputProps), isReadOnly && {
596
+ readOnly: true
597
+ })
544
598
  }, otherProps));
545
599
  },
546
600
  name: name,
@@ -610,7 +664,8 @@
610
664
  sx = _a.sx,
611
665
  _f = _a.onChange,
612
666
  _onChange = _f === void 0 ? function () {} : _f,
613
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
667
+ isReadOnly = _a.isReadOnly,
668
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
614
669
 
615
670
  var inputRef = React__namespace.useRef(null);
616
671
 
@@ -640,7 +695,8 @@
640
695
  className: className,
641
696
  sx: sx,
642
697
  disabled: disabled,
643
- errors: errors
698
+ errors: errors,
699
+ isReadOnly: isReadOnly
644
700
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
645
701
  render: function render(_props) {
646
702
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
@@ -662,7 +718,11 @@
662
718
  },
663
719
  onKeyDown: onKeyDown,
664
720
  disabled: disabled,
665
- inputRef: inputRef
721
+ inputRef: inputRef,
722
+ // eslint-disable-next-line react/jsx-no-duplicate-props
723
+ InputProps: __assign(__assign({}, isReadOnly && {
724
+ readOnly: true
725
+ }), otherProps.InputProps)
666
726
  }, otherProps));
667
727
  },
668
728
  name: name,
@@ -703,7 +763,8 @@
703
763
  _onChange = _g === void 0 ? function () {} : _g,
704
764
  className = _a.className,
705
765
  sx = _a.sx,
706
- otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx"]);
766
+ isReadOnly = _a.isReadOnly,
767
+ otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly"]);
707
768
 
708
769
  var inputRef = React__namespace.useRef(null);
709
770
 
@@ -717,10 +778,11 @@
717
778
  disabled: disabled,
718
779
  errors: errors,
719
780
  className: className,
720
- sx: sx
781
+ sx: sx,
782
+ isReadOnly: isReadOnly
721
783
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
722
784
  render: function render(_props) {
723
- return /*#__PURE__*/React__namespace.createElement(lab.DateTimePicker, __assign({
785
+ return /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
724
786
  desktopModeMediaQuery: "@media (min-width: 720px)",
725
787
  ampm: false,
726
788
  mask: "____/__/__ __:__",
@@ -734,18 +796,25 @@
734
796
 
735
797
  _onChange(getFormattedValue(value));
736
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",
737
803
  inputRef: inputRef,
738
804
  InputAdornmentProps: {
739
805
  position: 'start'
740
806
  },
741
- InputProps: {
807
+ InputProps: __assign(__assign({
742
808
  endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
743
809
  style: {
744
810
  paddingTop: '16px'
745
811
  },
746
812
  position: "end"
747
813
  }, "UTC")
748
- },
814
+ }, isReadOnly && {
815
+ readOnly: true
816
+ }), otherProps.InputProps),
817
+ hideTabs: false,
749
818
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
750
819
  // @ts-ignore
751
820
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -798,8 +867,8 @@
798
867
  var children = _a.children,
799
868
  _b = _a.options,
800
869
  options = _b === void 0 ? defaultFormOptions : _b;
801
- return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider__default["default"], {
802
- dateAdapter: AdapterMoment__default["default"]
870
+ return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider.LocalizationProvider, {
871
+ dateAdapter: AdapterMoment.AdapterMoment
803
872
  }, /*#__PURE__*/React__default["default"].createElement(ReactHookFormProvider, {
804
873
  options: options
805
874
  }, 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.4.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.4.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
  }