@opengeoweb/form-fields 4.1.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
@@ -375,10 +420,9 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
375
420
  _a$disabled = _a.disabled,
376
421
  disabled = _a$disabled === void 0 ? false : _a$disabled,
377
422
  _a$onChange = _a.onChange,
378
- _onChange = _a$onChange === void 0 ? function () {
379
- return null;
380
- } : _a$onChange,
381
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
423
+ _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
424
+ isReadOnly = _a.isReadOnly,
425
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
382
426
 
383
427
  var labelId = "".concat(name, "-label");
384
428
  var inputRef = React.useRef(null);
@@ -390,7 +434,8 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
390
434
  var errors = getErrors(name, formErrors);
391
435
  return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
392
436
  disabled: disabled,
393
- errors: errors
437
+ errors: errors,
438
+ isReadOnly: isReadOnly
394
439
  }, /*#__PURE__*/React.createElement(InputLabel, {
395
440
  id: labelId
396
441
  }, label), /*#__PURE__*/React.createElement(Controller, {
@@ -422,11 +467,6 @@ var ReactHookFormRadioGroup = function ReactHookFormRadioGroup(_a) {
422
467
  }));
423
468
  };
424
469
 
425
- var styles = {
426
- textEditor: {
427
- backgroundColor: 'rgba(0, 117, 169, 0.05)'
428
- }
429
- };
430
470
  var convertTextInputValue = function convertTextInputValue(value, inCapitals) {
431
471
  return inCapitals ? value.toUpperCase() : value;
432
472
  };
@@ -446,10 +486,10 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
446
486
  className = _a.className,
447
487
  sx = _a.sx,
448
488
  _a$onChange = _a.onChange,
449
- _onChange = _a$onChange === void 0 ? function () {
450
- return null;
451
- } : _a$onChange,
452
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
489
+ _onChange = _a$onChange === void 0 ? function () {} : _a$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"]);
453
493
 
454
494
  var inputRef = React.useRef(null);
455
495
 
@@ -462,12 +502,12 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
462
502
  className: className,
463
503
  sx: sx,
464
504
  disabled: disabled,
465
- errors: errors
505
+ errors: errors,
506
+ isReadOnly: isReadOnly
466
507
  }, /*#__PURE__*/React.createElement(Controller, {
467
508
  render: function render(_props) {
468
509
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
469
510
  label: label,
470
- style: otherProps.multiline ? styles.textEditor : {},
471
511
  error: !!errors,
472
512
  helperText: helperText,
473
513
  value: _props.value,
@@ -483,7 +523,10 @@ var ReactHookFormTextField = function ReactHookFormTextField(_a) {
483
523
  _onChange(null);
484
524
  },
485
525
  disabled: disabled,
486
- inputRef: inputRef
526
+ inputRef: inputRef,
527
+ InputProps: Object.assign(Object.assign({}, InputProps), isReadOnly && {
528
+ readOnly: true
529
+ })
487
530
  }, otherProps));
488
531
  },
489
532
  name: name,
@@ -581,10 +624,9 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
581
624
  className = _a.className,
582
625
  sx = _a.sx,
583
626
  _a$onChange = _a.onChange,
584
- _onChange = _a$onChange === void 0 ? function () {
585
- return null;
586
- } : _a$onChange,
587
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
627
+ _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
628
+ isReadOnly = _a.isReadOnly,
629
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
588
630
 
589
631
  var inputRef = React.useRef(null);
590
632
 
@@ -612,7 +654,8 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
612
654
  className: className,
613
655
  sx: sx,
614
656
  disabled: disabled,
615
- errors: errors
657
+ errors: errors,
658
+ isReadOnly: isReadOnly
616
659
  }, /*#__PURE__*/React.createElement(Controller, {
617
660
  render: function render(_props) {
618
661
  return /*#__PURE__*/React.createElement(TextField, Object.assign({
@@ -634,7 +677,11 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
634
677
  },
635
678
  onKeyDown: onKeyDown,
636
679
  disabled: disabled,
637
- 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)
638
685
  }, otherProps));
639
686
  },
640
687
  name: name,
@@ -672,12 +719,11 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
672
719
  _a$helperText = _a.helperText,
673
720
  helperText = _a$helperText === void 0 ? '' : _a$helperText,
674
721
  _a$onChange = _a.onChange,
675
- _onChange = _a$onChange === void 0 ? function () {
676
- return null;
677
- } : _a$onChange,
722
+ _onChange = _a$onChange === void 0 ? function () {} : _a$onChange,
678
723
  className = _a.className,
679
724
  sx = _a.sx,
680
- 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"]);
681
727
 
682
728
  var inputRef = React.useRef(null);
683
729
 
@@ -691,7 +737,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
691
737
  disabled: disabled,
692
738
  errors: errors,
693
739
  className: className,
694
- sx: sx
740
+ sx: sx,
741
+ isReadOnly: isReadOnly
695
742
  }, /*#__PURE__*/React.createElement(Controller, {
696
743
  render: function render(_props) {
697
744
  return /*#__PURE__*/React.createElement(DateTimePicker, Object.assign({
@@ -708,18 +755,25 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
708
755
 
709
756
  _onChange(getFormattedValue(value));
710
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",
711
762
  inputRef: inputRef,
712
763
  InputAdornmentProps: {
713
764
  position: 'start'
714
765
  },
715
- InputProps: {
766
+ InputProps: Object.assign(Object.assign({
716
767
  endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
717
768
  style: {
718
769
  paddingTop: '16px'
719
770
  },
720
771
  position: "end"
721
772
  }, "UTC")
722
- },
773
+ }, isReadOnly && {
774
+ readOnly: true
775
+ }), otherProps.InputProps),
776
+ hideTabs: false,
723
777
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
724
778
  // @ts-ignore
725
779
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -808,8 +862,8 @@ var ReactHookFormProviderWrapper = function ReactHookFormProviderWrapper(_ref2)
808
862
  * See the License for the specific language governing permissions and
809
863
  * limitations under the License.
810
864
  *
811
- * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
812
- * Copyright 2021 - Finnish Meteorological Institute (FMI)
865
+ * Copyright 2022 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
866
+ * Copyright 2022 - Finnish Meteorological Institute (FMI)
813
867
  * */
814
868
 
815
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
@@ -442,10 +485,9 @@
442
485
  _c = _a.disabled,
443
486
  disabled = _c === void 0 ? false : _c,
444
487
  _d = _a.onChange,
445
- _onChange = _d === void 0 ? function () {
446
- return null;
447
- } : _d,
448
- otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange"]);
488
+ _onChange = _d === void 0 ? function () {} : _d,
489
+ isReadOnly = _a.isReadOnly,
490
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "children", "rules", "disabled", "onChange", "isReadOnly"]);
449
491
 
450
492
  var labelId = name + "-label";
451
493
  var inputRef = React__namespace.useRef(null);
@@ -457,7 +499,8 @@
457
499
  var errors = getErrors(name, formErrors);
458
500
  return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
459
501
  disabled: disabled,
460
- errors: errors
502
+ errors: errors,
503
+ isReadOnly: isReadOnly
461
504
  }, /*#__PURE__*/React__namespace.createElement(material.InputLabel, {
462
505
  id: labelId
463
506
  }, label), /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
@@ -489,11 +532,6 @@
489
532
  }));
490
533
  };
491
534
 
492
- var styles = {
493
- textEditor: {
494
- backgroundColor: 'rgba(0, 117, 169, 0.05)'
495
- }
496
- };
497
535
  var convertTextInputValue = function convertTextInputValue(value, inCapitals) {
498
536
  return inCapitals ? value.toUpperCase() : value;
499
537
  };
@@ -513,10 +551,10 @@
513
551
  className = _a.className,
514
552
  sx = _a.sx,
515
553
  _f = _a.onChange,
516
- _onChange = _f === void 0 ? function () {
517
- return null;
518
- } : _f,
519
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange"]);
554
+ _onChange = _f === void 0 ? function () {} : _f,
555
+ isReadOnly = _a.isReadOnly,
556
+ InputProps = _a.InputProps,
557
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "upperCase", "helperText", "className", "sx", "onChange", "isReadOnly", "InputProps"]);
520
558
 
521
559
  var inputRef = React__namespace.useRef(null);
522
560
 
@@ -529,12 +567,12 @@
529
567
  className: className,
530
568
  sx: sx,
531
569
  disabled: disabled,
532
- errors: errors
570
+ errors: errors,
571
+ isReadOnly: isReadOnly
533
572
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
534
573
  render: function render(_props) {
535
574
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
536
575
  label: label,
537
- style: otherProps.multiline ? styles.textEditor : {},
538
576
  error: !!errors,
539
577
  helperText: helperText,
540
578
  value: _props.value,
@@ -550,7 +588,10 @@
550
588
  _onChange(null);
551
589
  },
552
590
  disabled: disabled,
553
- inputRef: inputRef
591
+ inputRef: inputRef,
592
+ InputProps: __assign(__assign({}, InputProps), isReadOnly && {
593
+ readOnly: true
594
+ })
554
595
  }, otherProps));
555
596
  },
556
597
  name: name,
@@ -619,10 +660,9 @@
619
660
  className = _a.className,
620
661
  sx = _a.sx,
621
662
  _f = _a.onChange,
622
- _onChange = _f === void 0 ? function () {
623
- return null;
624
- } : _f,
625
- otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange"]);
663
+ _onChange = _f === void 0 ? function () {} : _f,
664
+ isReadOnly = _a.isReadOnly,
665
+ otherProps = __rest(_a, ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "sx", "onChange", "isReadOnly"]);
626
666
 
627
667
  var inputRef = React__namespace.useRef(null);
628
668
 
@@ -652,7 +692,8 @@
652
692
  className: className,
653
693
  sx: sx,
654
694
  disabled: disabled,
655
- errors: errors
695
+ errors: errors,
696
+ isReadOnly: isReadOnly
656
697
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
657
698
  render: function render(_props) {
658
699
  return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
@@ -674,7 +715,11 @@
674
715
  },
675
716
  onKeyDown: onKeyDown,
676
717
  disabled: disabled,
677
- 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)
678
723
  }, otherProps));
679
724
  },
680
725
  name: name,
@@ -712,12 +757,11 @@
712
757
  _f = _a.helperText,
713
758
  helperText = _f === void 0 ? '' : _f,
714
759
  _g = _a.onChange,
715
- _onChange = _g === void 0 ? function () {
716
- return null;
717
- } : _g,
760
+ _onChange = _g === void 0 ? function () {} : _g,
718
761
  className = _a.className,
719
762
  sx = _a.sx,
720
- 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"]);
721
765
 
722
766
  var inputRef = React__namespace.useRef(null);
723
767
 
@@ -731,10 +775,11 @@
731
775
  disabled: disabled,
732
776
  errors: errors,
733
777
  className: className,
734
- sx: sx
778
+ sx: sx,
779
+ isReadOnly: isReadOnly
735
780
  }, /*#__PURE__*/React__namespace.createElement(reactHookForm.Controller, {
736
781
  render: function render(_props) {
737
- return /*#__PURE__*/React__namespace.createElement(lab.DateTimePicker, __assign({
782
+ return /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
738
783
  desktopModeMediaQuery: "@media (min-width: 720px)",
739
784
  ampm: false,
740
785
  mask: "____/__/__ __:__",
@@ -748,18 +793,25 @@
748
793
 
749
794
  _onChange(getFormattedValue(value));
750
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",
751
800
  inputRef: inputRef,
752
801
  InputAdornmentProps: {
753
802
  position: 'start'
754
803
  },
755
- InputProps: {
804
+ InputProps: __assign(__assign({
756
805
  endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
757
806
  style: {
758
807
  paddingTop: '16px'
759
808
  },
760
809
  position: "end"
761
810
  }, "UTC")
762
- },
811
+ }, isReadOnly && {
812
+ readOnly: true
813
+ }), otherProps.InputProps),
814
+ hideTabs: false,
763
815
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
764
816
  // @ts-ignore
765
817
  // eslint-disable-next-line react/jsx-no-duplicate-props
@@ -812,8 +864,8 @@
812
864
  var children = _a.children,
813
865
  _b = _a.options,
814
866
  options = _b === void 0 ? defaultFormOptions : _b;
815
- return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider__default["default"], {
816
- dateAdapter: AdapterMoment__default["default"]
867
+ return /*#__PURE__*/React__default["default"].createElement(LocalizationProvider.LocalizationProvider, {
868
+ dateAdapter: AdapterMoment.AdapterMoment
817
869
  }, /*#__PURE__*/React__default["default"].createElement(ReactHookFormProvider, {
818
870
  options: options
819
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;
9
- defaultNullValue?: string;
8
+ declare type ReactHookKeyboardDateTimePickerProps = Partial<Partial<DateTimePickerProps<DateTimePickerSlotsComponent, Moment>>> & ReactHookFormInput<{
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,8 +1,7 @@
1
1
  import * as React from 'react';
2
- interface ReactHookFormHiddenInputProps {
3
- name: string;
2
+ import { ReactHookFormInput } from './types';
3
+ declare type ReactHookFormHiddenInputProps = ReactHookFormInput<{
4
4
  defaultValue?: unknown;
5
- rules?: unknown;
6
- }
5
+ }>;
7
6
  declare const ReactHookFormHiddenInput: React.FC<ReactHookFormHiddenInputProps>;
8
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
- export declare const parseInput: (value: number | string) => string;
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
+ };
@@ -1,4 +1,4 @@
1
- import { Moment } from 'moment';
1
+ import moment from 'moment';
2
2
  export declare const errorMessages: {
3
3
  required: string;
4
4
  isValidDate: string;
@@ -18,25 +18,25 @@ export declare const errorMessages: {
18
18
  minVisibility: string;
19
19
  maxVisibility: string;
20
20
  };
21
- export declare const isEmpty: (value: number | string) => boolean;
22
- export declare const isValidDate: (value: Moment | string) => boolean;
21
+ export declare const isEmpty: (value?: string | number | null | undefined) => boolean;
22
+ export declare const isValidDate: (value?: string | moment.Moment | null | undefined) => boolean;
23
23
  export declare const isBefore: (ownDate: string, referenceDate: string) => boolean;
24
24
  export declare const isAfter: (ownDate: string, otherDate: string) => boolean;
25
25
  export declare const isBetween: (ownDate: string, otherDateStart: string, otherDateEnd: string) => boolean;
26
26
  export declare const isXHoursBefore: (ownDate: string, otherDate: string, hours?: number) => boolean;
27
27
  export declare const isXHoursAfter: (ownDate: string, otherDate: string, hours?: number) => boolean;
28
- export declare const isLatitude: (lat: number) => boolean;
29
- export declare const isLongitude: (lng: number) => boolean;
28
+ export declare const isLatitude: (lat?: number | null | undefined) => boolean;
29
+ export declare const isLongitude: (lng?: number | null | undefined) => boolean;
30
30
  export declare const isValidMax: (value: number, maxValue: number) => boolean;
31
31
  export declare const isValidMin: (value: number, minValue: number) => boolean;
32
- export declare const hasValidGeometry: (geojson: GeoJSON.FeatureCollection) => boolean;
32
+ export declare const hasValidGeometry: (geojson?: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | null | undefined) => boolean;
33
33
  export declare const isValidGeoJsonCoordinates: (geojson: GeoJSON.FeatureCollection) => boolean;
34
34
  export declare const isMaximumOneDrawing: (geojson: GeoJSON.FeatureCollection) => boolean;
35
35
  export declare const hasIntersectionWithFIR: (geojson: GeoJSON.FeatureCollection, intersection: GeoJSON.FeatureCollection) => boolean;
36
36
  export declare const hasMaxFeaturePoints: (geojson: GeoJSON.FeatureCollection, maxPoints?: number) => boolean;
37
37
  export declare const hasMulitpleIntersections: (geojson: GeoJSON.FeatureCollection) => boolean;
38
- export declare const isGeometryDirty: (geoJSON: GeoJSON.FeatureCollection, formGeoJSON: GeoJSON.FeatureCollection) => boolean;
38
+ export declare const isGeometryDirty: (geoJSON?: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | null | undefined, formGeoJSON?: import("geojson").FeatureCollection<import("geojson").Geometry, import("geojson").GeoJsonProperties> | null | undefined) => boolean;
39
39
  export declare const isInteger: (value: number) => boolean;
40
40
  export declare const isNumeric: (value: any) => boolean;
41
- export declare const isNonOrBothCoordinates: (coordinate: number, otherCoordinate: number) => boolean;
41
+ export declare const isNonOrBothCoordinates: (coordinate?: number | null | undefined, otherCoordinate?: number | null | undefined) => boolean;
42
42
  export declare const containsNoCommas: (val: string | number) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/form-fields",
3
- "version": "4.1.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.1.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
  }