@opengeoweb/form-fields 4.17.0 → 4.19.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 +45 -41
- package/index.umd.js +45 -40
- package/lib/components/ReactHookFormDateTime.d.ts +6 -4
- package/lib/components/index.d.ts +1 -0
- package/package.json +4 -4
package/index.esm.js
CHANGED
|
@@ -115,11 +115,17 @@ var isXHoursAfter = function isXHoursAfter(ownDate, otherDate) {
|
|
|
115
115
|
return inHours <= hours;
|
|
116
116
|
};
|
|
117
117
|
var isLatitude = function isLatitude(lat) {
|
|
118
|
-
if (!lat)
|
|
118
|
+
if (!lat) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
|
|
119
122
|
return isFinite(lat) && Math.abs(lat) <= 90 && regexMaxTwoDecimals.test(lat.toString());
|
|
120
123
|
};
|
|
121
124
|
var isLongitude = function isLongitude(lng) {
|
|
122
|
-
if (!lng)
|
|
125
|
+
if (!lng) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
|
|
123
129
|
return isFinite(lng) && Math.abs(lng) <= 180 && lng >= -180 && regexMaxTwoDecimals.test(lng.toString());
|
|
124
130
|
}; // Pass null if no maxValue
|
|
125
131
|
|
|
@@ -717,7 +723,11 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_a) {
|
|
|
717
723
|
}, otherProps)));
|
|
718
724
|
};
|
|
719
725
|
|
|
720
|
-
moment$1.tz.setDefault('Etc/GMT-0');
|
|
726
|
+
moment$1.tz.setDefault('Etc/GMT-0'); // TODO: remove when issue is fixed in upcoming release https://github.com/mui/mui-x/issues/8150
|
|
727
|
+
|
|
728
|
+
var temporaryStripChineseCharacters = function temporaryStripChineseCharacters(dirtyString) {
|
|
729
|
+
return dirtyString.replace(/[\u2066\u2067\u2068\u2069\u200e]/g, '');
|
|
730
|
+
};
|
|
721
731
|
var getFormattedValue = function getFormattedValue(value) {
|
|
722
732
|
var isMoment = moment$1(value).isValid();
|
|
723
733
|
return isMoment ? moment$1.utc(value).format() : value;
|
|
@@ -742,7 +752,8 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
742
752
|
className = _a.className,
|
|
743
753
|
sx = _a.sx,
|
|
744
754
|
isReadOnly = _a.isReadOnly,
|
|
745
|
-
|
|
755
|
+
inputAdornment = _a.inputAdornment,
|
|
756
|
+
otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "inputAdornment"]);
|
|
746
757
|
|
|
747
758
|
var _useFormContext = useFormContext(),
|
|
748
759
|
control = _useFormContext.control;
|
|
@@ -759,7 +770,9 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
759
770
|
ref = _useController$field.ref,
|
|
760
771
|
formErrors = _useController.formState.errors;
|
|
761
772
|
|
|
762
|
-
var errors = getErrors(name, formErrors);
|
|
773
|
+
var errors = getErrors(name, formErrors); // Ensure value is a Moment object
|
|
774
|
+
|
|
775
|
+
var dateValue = value ? moment$1(value) : null;
|
|
763
776
|
return /*#__PURE__*/React.createElement(ReactHookFormFormControl, {
|
|
764
777
|
disabled: disabled,
|
|
765
778
|
errors: errors,
|
|
@@ -769,10 +782,9 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
769
782
|
}, /*#__PURE__*/React.createElement(DateTimePicker, Object.assign({
|
|
770
783
|
desktopModeMediaQuery: "@media (min-width: 720px)",
|
|
771
784
|
ampm: false,
|
|
772
|
-
|
|
773
|
-
inputFormat: format,
|
|
785
|
+
format: format,
|
|
774
786
|
label: label,
|
|
775
|
-
value:
|
|
787
|
+
value: dateValue,
|
|
776
788
|
openTo: openTo,
|
|
777
789
|
disabled: disabled,
|
|
778
790
|
onChange: function onChange(value) {
|
|
@@ -780,42 +792,34 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
|
|
|
780
792
|
|
|
781
793
|
_onChange(getFormattedValue(value));
|
|
782
794
|
},
|
|
783
|
-
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
784
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
785
|
-
// @ts-ignore
|
|
786
|
-
focusedView: "month",
|
|
787
795
|
inputRef: ref,
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
InputProps: Object.assign(Object.assign({
|
|
792
|
-
endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
793
|
-
style: {
|
|
794
|
-
paddingTop: '16px'
|
|
795
|
-
},
|
|
796
|
-
position: "end"
|
|
797
|
-
}, "UTC")
|
|
798
|
-
}, isReadOnly && {
|
|
799
|
-
readOnly: true
|
|
800
|
-
}), otherProps.InputProps),
|
|
801
|
-
hideTabs: false,
|
|
802
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
-
// @ts-ignore
|
|
804
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
805
|
-
inputProps: disabled ? {
|
|
806
|
-
placeholder: ''
|
|
807
|
-
} : undefined,
|
|
808
|
-
renderInput: function renderInput(_a) {
|
|
809
|
-
_a.error;
|
|
810
|
-
var props = __rest(_a, ["error"]);
|
|
811
|
-
|
|
812
|
-
return /*#__PURE__*/React.createElement(TextField, Object.assign({
|
|
796
|
+
slotProps: {
|
|
797
|
+
textField: {
|
|
798
|
+
variant: 'filled',
|
|
813
799
|
helperText: helperText,
|
|
814
800
|
error: !!errors,
|
|
815
801
|
name: name,
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
802
|
+
placeholder: disabled ? '' : format.toLowerCase(),
|
|
803
|
+
InputProps: Object.assign({
|
|
804
|
+
endAdornment: /*#__PURE__*/React.createElement(InputAdornment, {
|
|
805
|
+
style: {
|
|
806
|
+
paddingTop: '16px'
|
|
807
|
+
},
|
|
808
|
+
position: "end"
|
|
809
|
+
}, "UTC")
|
|
810
|
+
}, isReadOnly && {
|
|
811
|
+
readOnly: true
|
|
812
|
+
}),
|
|
813
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
814
|
+
// @ts-ignore
|
|
815
|
+
'data-testid': otherProps['data-testid']
|
|
816
|
+
},
|
|
817
|
+
inputAdornment: Object.assign({}, inputAdornment || {
|
|
818
|
+
position: 'start'
|
|
819
|
+
}),
|
|
820
|
+
tabs: {
|
|
821
|
+
hidden: false
|
|
822
|
+
}
|
|
819
823
|
}
|
|
820
824
|
}, otherProps)));
|
|
821
825
|
};
|
|
@@ -966,4 +970,4 @@ var useDraftFormHelpers = function useDraftFormHelpers() {
|
|
|
966
970
|
};
|
|
967
971
|
};
|
|
968
972
|
|
|
969
|
-
export { HIDDEN_INPUT_HELPER_IS_DRAFT, ReactHookKeyboardDateTimePicker as ReactHookFormDateTime, ReactHookFormFormControl, ReactHookFormHiddenInput, ReactHookFormNumberField, ReactHookFormProviderWrapper as ReactHookFormProvider, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormTextField, defaultFormOptions, errorMessages, getDeepProperty, hasIntersectionWithFIR, hasMaxFeaturePoints, hasMulitpleIntersections, isAfter, isBefore, isBetween, isEmpty, isGeometryDirty, isInteger, isLatitude, isLongitude, isMaximumOneDrawing, isNonOrBothCoordinates, isValidDate, isValidGeoJsonCoordinates, isValidMax, isValidMin, isXHoursAfter, isXHoursBefore, useDraftFormHelpers };
|
|
973
|
+
export { HIDDEN_INPUT_HELPER_IS_DRAFT, ReactHookKeyboardDateTimePicker as ReactHookFormDateTime, ReactHookFormFormControl, ReactHookFormHiddenInput, ReactHookFormNumberField, ReactHookFormProviderWrapper as ReactHookFormProvider, ReactHookFormRadioGroup, ReactHookFormSelect, ReactHookFormTextField, defaultFormOptions, errorMessages, getDeepProperty, hasIntersectionWithFIR, hasMaxFeaturePoints, hasMulitpleIntersections, isAfter, isBefore, isBetween, isEmpty, isGeometryDirty, isInteger, isLatitude, isLongitude, isMaximumOneDrawing, isNonOrBothCoordinates, isValidDate, isValidGeoJsonCoordinates, isValidMax, isValidMin, isXHoursAfter, isXHoursBefore, temporaryStripChineseCharacters, useDraftFormHelpers };
|
package/index.umd.js
CHANGED
|
@@ -177,11 +177,17 @@
|
|
|
177
177
|
return inHours <= hours;
|
|
178
178
|
};
|
|
179
179
|
var isLatitude = function isLatitude(lat) {
|
|
180
|
-
if (!lat)
|
|
180
|
+
if (!lat) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
|
|
181
184
|
return isFinite(lat) && Math.abs(lat) <= 90 && regexMaxTwoDecimals.test(lat.toString());
|
|
182
185
|
};
|
|
183
186
|
var isLongitude = function isLongitude(lng) {
|
|
184
|
-
if (!lng)
|
|
187
|
+
if (!lng) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
185
191
|
return isFinite(lng) && Math.abs(lng) <= 180 && lng >= -180 && regexMaxTwoDecimals.test(lng.toString());
|
|
186
192
|
}; // Pass null if no maxValue
|
|
187
193
|
|
|
@@ -707,7 +713,11 @@
|
|
|
707
713
|
}, otherProps)));
|
|
708
714
|
};
|
|
709
715
|
|
|
710
|
-
moment__default$1["default"].tz.setDefault('Etc/GMT-0');
|
|
716
|
+
moment__default$1["default"].tz.setDefault('Etc/GMT-0'); // TODO: remove when issue is fixed in upcoming release https://github.com/mui/mui-x/issues/8150
|
|
717
|
+
|
|
718
|
+
var temporaryStripChineseCharacters = function temporaryStripChineseCharacters(dirtyString) {
|
|
719
|
+
return dirtyString.replace(/[\u2066\u2067\u2068\u2069\u200e]/g, '');
|
|
720
|
+
};
|
|
711
721
|
var getFormattedValue = function getFormattedValue(value) {
|
|
712
722
|
var isMoment = moment__default$1["default"](value).isValid();
|
|
713
723
|
return isMoment ? moment__default$1["default"].utc(value).format() : value;
|
|
@@ -732,7 +742,8 @@
|
|
|
732
742
|
className = _a.className,
|
|
733
743
|
sx = _a.sx,
|
|
734
744
|
isReadOnly = _a.isReadOnly,
|
|
735
|
-
|
|
745
|
+
inputAdornment = _a.inputAdornment,
|
|
746
|
+
otherProps = __rest(_a, ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "inputAdornment"]);
|
|
736
747
|
|
|
737
748
|
var control = reactHookForm.useFormContext().control;
|
|
738
749
|
|
|
@@ -748,7 +759,9 @@
|
|
|
748
759
|
ref = _j.ref,
|
|
749
760
|
formErrors = _h.formState.errors;
|
|
750
761
|
|
|
751
|
-
var errors = getErrors(name, formErrors);
|
|
762
|
+
var errors = getErrors(name, formErrors); // Ensure value is a Moment object
|
|
763
|
+
|
|
764
|
+
var dateValue = value ? moment__default$1["default"](value) : null;
|
|
752
765
|
return /*#__PURE__*/React__namespace.createElement(ReactHookFormFormControl, {
|
|
753
766
|
disabled: disabled,
|
|
754
767
|
errors: errors,
|
|
@@ -758,10 +771,9 @@
|
|
|
758
771
|
}, /*#__PURE__*/React__namespace.createElement(xDatePickers.DateTimePicker, __assign({
|
|
759
772
|
desktopModeMediaQuery: "@media (min-width: 720px)",
|
|
760
773
|
ampm: false,
|
|
761
|
-
|
|
762
|
-
inputFormat: format,
|
|
774
|
+
format: format,
|
|
763
775
|
label: label,
|
|
764
|
-
value:
|
|
776
|
+
value: dateValue,
|
|
765
777
|
openTo: openTo,
|
|
766
778
|
disabled: disabled,
|
|
767
779
|
onChange: function onChange(value) {
|
|
@@ -769,42 +781,34 @@
|
|
|
769
781
|
|
|
770
782
|
_onChange(getFormattedValue(value));
|
|
771
783
|
},
|
|
772
|
-
// if focusedView is removed, it will throw an error when switching day to month mode
|
|
773
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
774
|
-
// @ts-ignore
|
|
775
|
-
focusedView: "month",
|
|
776
784
|
inputRef: ref,
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
InputProps: __assign(__assign({
|
|
781
|
-
endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
|
|
782
|
-
style: {
|
|
783
|
-
paddingTop: '16px'
|
|
784
|
-
},
|
|
785
|
-
position: "end"
|
|
786
|
-
}, "UTC")
|
|
787
|
-
}, isReadOnly && {
|
|
788
|
-
readOnly: true
|
|
789
|
-
}), otherProps.InputProps),
|
|
790
|
-
hideTabs: false,
|
|
791
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
792
|
-
// @ts-ignore
|
|
793
|
-
// eslint-disable-next-line react/jsx-no-duplicate-props
|
|
794
|
-
inputProps: disabled ? {
|
|
795
|
-
placeholder: ''
|
|
796
|
-
} : undefined,
|
|
797
|
-
renderInput: function renderInput(_a) {
|
|
798
|
-
_a.error;
|
|
799
|
-
var props = __rest(_a, ["error"]);
|
|
800
|
-
|
|
801
|
-
return /*#__PURE__*/React__namespace.createElement(material.TextField, __assign({
|
|
785
|
+
slotProps: {
|
|
786
|
+
textField: {
|
|
787
|
+
variant: 'filled',
|
|
802
788
|
helperText: helperText,
|
|
803
789
|
error: !!errors,
|
|
804
790
|
name: name,
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
791
|
+
placeholder: disabled ? '' : format.toLowerCase(),
|
|
792
|
+
InputProps: __assign({
|
|
793
|
+
endAdornment: /*#__PURE__*/React__namespace.createElement(material.InputAdornment, {
|
|
794
|
+
style: {
|
|
795
|
+
paddingTop: '16px'
|
|
796
|
+
},
|
|
797
|
+
position: "end"
|
|
798
|
+
}, "UTC")
|
|
799
|
+
}, isReadOnly && {
|
|
800
|
+
readOnly: true
|
|
801
|
+
}),
|
|
802
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
803
|
+
// @ts-ignore
|
|
804
|
+
'data-testid': otherProps['data-testid']
|
|
805
|
+
},
|
|
806
|
+
inputAdornment: __assign({}, inputAdornment || {
|
|
807
|
+
position: 'start'
|
|
808
|
+
}),
|
|
809
|
+
tabs: {
|
|
810
|
+
hidden: false
|
|
811
|
+
}
|
|
808
812
|
}
|
|
809
813
|
}, otherProps)));
|
|
810
814
|
};
|
|
@@ -933,6 +937,7 @@
|
|
|
933
937
|
exports.isValidMin = isValidMin;
|
|
934
938
|
exports.isXHoursAfter = isXHoursAfter;
|
|
935
939
|
exports.isXHoursBefore = isXHoursBefore;
|
|
940
|
+
exports.temporaryStripChineseCharacters = temporaryStripChineseCharacters;
|
|
936
941
|
exports.useDraftFormHelpers = useDraftFormHelpers;
|
|
937
942
|
|
|
938
943
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -1,16 +1,18 @@
|
|
|
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/x-date-pickers';
|
|
5
|
-
import { DateTimePickerSlotsComponent } from '@mui/x-date-pickers/DateTimePicker/DateTimePicker';
|
|
4
|
+
import { DateTimePickerProps, DateTimePickerSlotsComponentsProps } from '@mui/x-date-pickers';
|
|
6
5
|
import { ReactHookFormInput } from './types';
|
|
6
|
+
export declare const temporaryStripChineseCharacters: (dirtyString: string) => string;
|
|
7
7
|
export declare const getFormattedValue: (value: Moment | string) => string | Moment;
|
|
8
|
-
declare type ReactHookKeyboardDateTimePickerProps =
|
|
8
|
+
declare type ReactHookKeyboardDateTimePickerProps = DateTimePickerProps<Moment> & DateTimePickerSlotsComponentsProps<Moment> & ReactHookFormInput<{
|
|
9
9
|
defaultNullValue?: string | null;
|
|
10
10
|
value?: string;
|
|
11
11
|
onChange?: (value: string | Moment) => void;
|
|
12
12
|
format?: string;
|
|
13
13
|
sx?: SxProps<Theme>;
|
|
14
|
-
}
|
|
14
|
+
}> & {
|
|
15
|
+
'data-testid'?: string;
|
|
16
|
+
};
|
|
15
17
|
declare const ReactHookKeyboardDateTimePicker: React.FC<ReactHookKeyboardDateTimePickerProps>;
|
|
16
18
|
export default ReactHookKeyboardDateTimePicker;
|
|
@@ -9,3 +9,4 @@ export { default as ReactHookFormHiddenInput } from './ReactHookFormHiddenInput'
|
|
|
9
9
|
export { defaultFormOptions } from './ReactHookFormProvider';
|
|
10
10
|
export { errorMessages, isMaximumOneDrawing, isGeometryDirty, isValidGeoJsonCoordinates, hasIntersectionWithFIR, isValidMax, isValidMin, isInteger, isAfter, isBefore, isBetween, isValidDate, hasMaxFeaturePoints, hasMulitpleIntersections, isXHoursBefore, isXHoursAfter, isLatitude, isLongitude, isNonOrBothCoordinates, isEmpty, } from './utils';
|
|
11
11
|
export { getDeepProperty } from './formUtils';
|
|
12
|
+
export { temporaryStripChineseCharacters } from './ReactHookFormDateTime';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/form-fields",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.19.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": "^7.41.5",
|
|
16
16
|
"react": "^18.2.0",
|
|
17
|
-
"@mui/material": "^5.
|
|
18
|
-
"@opengeoweb/theme": "4.
|
|
17
|
+
"@mui/material": "^5.12.0",
|
|
18
|
+
"@opengeoweb/theme": "4.19.0",
|
|
19
|
+
"@mui/x-date-pickers": "^6.2.1",
|
|
19
20
|
"moment": "^2.29.0",
|
|
20
21
|
"moment-timezone": "^0.5.31",
|
|
21
|
-
"@mui/x-date-pickers": "^5.0.4",
|
|
22
22
|
"lodash": "^4.17.20"
|
|
23
23
|
}
|
|
24
24
|
}
|