@opengeoweb/form-fields 19.6.0 → 19.6.1-nightly-20260912

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/dist/index.esm.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { FormControl, FormHelperText, InputLabel, Select, RadioGroup, TextField, InputAdornment } from '@mui/material';
2
+ import { FormControl, FormHelperText, InputLabel, Select, RadioGroup, TextField } from '@mui/material';
3
3
  import { useFormContext, useController, useForm, FormProvider, Controller } from 'react-hook-form';
4
4
  import { isEqual } from 'lodash';
5
- import { dateUtils } from '@opengeoweb/shared';
5
+ import { dateUtils, getAllowedKeys, convertNumericInputValue, DateTimePicker } from '@opengeoweb/shared';
6
6
  import 'i18next';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import React, { useState } from 'react';
9
- import { DateTimePicker } from '@mui/x-date-pickers';
10
- import { CalendarToday } from '@opengeoweb/theme';
11
9
  import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
12
10
  import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
13
11
 
@@ -638,19 +636,6 @@ var ReactHookFormTextField = function ReactHookFormTextField(_ref) {
638
636
  };
639
637
 
640
638
  var _excluded$2 = ["name", "label", "defaultValue", "rules", "disabled", "inputMode", "helperText", "className", "size", "sx", "onBeforeChange", "onChange", "isReadOnly"];
641
- var convertNumericInputValue = function convertNumericInputValue(value, inputMode) {
642
- if (value !== '' && !isNaN(parseFloat(value))) {
643
- return inputMode === 'numeric' ? parseInt(value, 10) : parseFloat(value);
644
- }
645
- return null;
646
- };
647
- var getAllowedKeys = function getAllowedKeys(inputMode) {
648
- if (inputMode === void 0) {
649
- inputMode = 'numeric';
650
- }
651
- var allowedKeys = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', 'Backspace', 'ArrowRight', 'ArrowLeft', 'Tab', 'Home', 'End', 'PageDown', 'PageUp', 'Delete'].concat(inputMode === 'decimal' ? ['.'] : []);
652
- return allowedKeys;
653
- };
654
639
  var ReactHookFormNumberField = function ReactHookFormNumberField(_ref) {
655
640
  var _otherProps$slotProps;
656
641
  var name = _ref.name,
@@ -821,18 +806,6 @@ var ReactHookFormNumberField = function ReactHookFormNumberField(_ref) {
821
806
  };
822
807
 
823
808
  var _excluded$1 = ["name", "rules", "disabled", "label", "format", "openTo", "defaultNullValue", "helperText", "onChange", "className", "sx", "isReadOnly", "shouldHideUTC", "disablePast", "disableFuture"];
824
- var OpenPicker = function OpenPicker() {
825
- return jsx(CalendarToday, {});
826
- };
827
- var getTimezoneOffset = function getTimezoneOffset(value) {
828
- return value.getTimezoneOffset() * 60000;
829
- };
830
- var makeLocalAppearUTC = function makeLocalAppearUTC(value) {
831
- return new Date(value.getTime() + getTimezoneOffset(value));
832
- };
833
- var localToUTC = function localToUTC(dateTime) {
834
- return new Date(dateTime.getTime() - getTimezoneOffset(dateTime));
835
- };
836
809
  /**
837
810
  * Should return an isostring in the form "YYYY-MM-DDThh:mmZ";
838
811
  * The milli seconds section should not be included, strictly YYYY-MM-DDThh:mm:ssZ is important
@@ -846,9 +819,9 @@ var getFormattedValueForDatePicker = function getFormattedValueForDatePicker(val
846
819
  var getDateValue = function getDateValue(value) {
847
820
  if (value) {
848
821
  var _ref, _dateUtils$stringToDa;
849
- var dateValue = (_ref = (_dateUtils$stringToDa = dateUtils.stringToDate(value, 'yyyy/MM/dd HH:mm', false)) != null ? _dateUtils$stringToDa : dateUtils.isoStringToDate(value, false)) != null ? _ref : null;
822
+ var dateValue = (_ref = (_dateUtils$stringToDa = dateUtils.stringToDate(value, 'yyyy/MM/dd HH:mm', true)) != null ? _dateUtils$stringToDa : dateUtils.isoStringToDate(value, false)) != null ? _ref : null;
850
823
  if (dateValue) {
851
- return makeLocalAppearUTC(dateUtils.setSeconds(dateValue, 0));
824
+ return dateUtils.setSeconds(dateValue, 0);
852
825
  }
853
826
  return null;
854
827
  }
@@ -893,7 +866,7 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
893
866
  var errors = getErrors(name, formErrors);
894
867
  // Ensure value is a Date object
895
868
  var dateValue = getDateValue(value);
896
- var now = makeLocalAppearUTC(dateUtils.utc());
869
+ var now = dateUtils.utc();
897
870
  var minDateTime = disablePast ? now : null;
898
871
  var maxDateTime = disableFuture ? now : null;
899
872
  return jsx(ReactHookFormFormControl, {
@@ -903,8 +876,6 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
903
876
  isReadOnly: isReadOnly,
904
877
  sx: sx,
905
878
  children: jsx(DateTimePicker, Object.assign({
906
- ampm: false,
907
- desktopModeMediaQuery: "@media (min-width: 720px)",
908
879
  disabled: disabled,
909
880
  format: format,
910
881
  inputRef: ref,
@@ -917,52 +888,28 @@ var ReactHookKeyboardDateTimePicker = function ReactHookKeyboardDateTimePicker(_
917
888
  onChangeField(null);
918
889
  return;
919
890
  }
920
- var formattedDate = getFormattedValueForDatePicker(localToUTC(value));
891
+ var formattedDate = getFormattedValueForDatePicker(value);
921
892
  onChangeField(formattedDate);
922
893
  _onChange(formattedDate);
923
894
  },
924
895
  openTo: openTo,
896
+ showUTCAdornment: !shouldHideUTC,
925
897
  slotProps: {
926
898
  textField: Object.assign({
927
- variant: 'filled',
928
899
  helperText: helperText,
929
900
  error: !!errors,
930
901
  name: name,
931
902
  slotProps: {
932
903
  htmlInput: {
933
904
  placeholder: disabled ? '' : format.toLowerCase()
934
- },
935
- input: Object.assign({}, !shouldHideUTC && {
936
- endAdornment: jsx(InputAdornment, {
937
- position: "end",
938
- style: {
939
- paddingTop: '16px'
940
- },
941
- children: "UTC"
942
- })
943
- })
905
+ }
944
906
  },
945
907
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
946
908
  // @ts-ignore
947
909
  'data-testid': otherProps['data-testid']
948
910
  }, isReadOnly && {
949
911
  readOnly: true
950
- }),
951
- field: {
952
- openPickerButtonPosition: 'start'
953
- },
954
- openPickerButton: {
955
- size: 'small',
956
- sx: {
957
- padding: 0
958
- }
959
- }
960
- },
961
- slots: {
962
- openPickerIcon: OpenPicker
963
- },
964
- timeSteps: {
965
- minutes: 1
912
+ })
966
913
  },
967
914
  value: dateValue
968
915
  }, otherProps))
@@ -1,11 +1,9 @@
1
1
  import type { TextFieldProps } from '@mui/material';
2
2
  import React from 'react';
3
+ import type { NumberInputMode } from '@opengeoweb/shared';
3
4
  import type { ReactHookFormInput } from './types';
4
- type InputMode = 'numeric' | 'decimal';
5
- export declare const convertNumericInputValue: (value: string, inputMode: InputMode) => number | null;
6
- export declare const getAllowedKeys: (inputMode?: InputMode) => string[];
7
5
  type ReactHookFormNumberFieldProps = Partial<TextFieldProps> & ReactHookFormInput<{
8
- inputMode?: InputMode;
6
+ inputMode?: NumberInputMode;
9
7
  onBeforeChange?: () => void;
10
8
  }>;
11
9
  declare const ReactHookFormNumberField: React.FC<ReactHookFormNumberFieldProps>;
package/package.json CHANGED
@@ -1,47 +1,47 @@
1
1
  {
2
- "name": "@opengeoweb/form-fields",
3
- "version": "19.6.0",
4
- "description": "GeoWeb form-fields library for the opengeoweb project",
5
- "license": "Apache-2.0",
6
- "repository": {
7
- "type": "git",
8
- "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
- },
10
- "main": "./dist/index.esm.js",
11
- "module": "./dist/index.esm.js",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- "./package.json": "./package.json",
15
- ".": {
16
- "@opengeoweb/source": "./src/index.ts",
17
- "types": "./dist/index.d.ts",
18
- "import": "./dist/index.esm.js",
19
- "default": "./dist/index.esm.js"
20
- }
21
- },
22
- "dependencies": {
23
- "@opengeoweb/theme": "*",
24
- "react-hook-form": "^7.50.1",
25
- "@mui/x-date-pickers": "^9.3.0",
26
- "lodash": "^4.18.1",
27
- "@opengeoweb/shared": "*",
28
- "react-i18next": "^15.1.1",
29
- "@mui/material": "^9.0.1",
30
- "i18next": "^25.0.1",
31
- "@types/geojson": "^7946.0.14"
32
- },
33
- "peerDependencies": {
34
- "react": "19",
35
- "@emotion/react": "*",
36
- "@emotion/styled": "*"
37
- },
38
- "devDependencies": {
39
- "eslint-plugin-storybook": "10.3.3"
40
- },
41
- "files": [
42
- "dist",
43
- "!dist/package.json",
44
- "README.md",
45
- "package.json"
46
- ]
47
- }
2
+ "name": "@opengeoweb/form-fields",
3
+ "version": "19.6.1-nightly-20260912",
4
+ "description": "GeoWeb form-fields library for the opengeoweb project",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
+ },
10
+ "main": "./dist/index.esm.js",
11
+ "module": "./dist/index.esm.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "@opengeoweb/source": "./src/index.ts",
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.esm.js",
19
+ "default": "./dist/index.esm.js"
20
+ }
21
+ },
22
+ "dependencies": {
23
+ "@opengeoweb/theme": "19.6.1-nightly-20260912",
24
+ "react-hook-form": "^7.50.1",
25
+ "@mui/x-date-pickers": "^9.3.0",
26
+ "lodash": "^4.18.1",
27
+ "@opengeoweb/shared": "19.6.1-nightly-20260912",
28
+ "react-i18next": "^15.1.1",
29
+ "@mui/material": "^9.0.1",
30
+ "i18next": "^25.0.1",
31
+ "@types/geojson": "^7946.0.14"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "19",
35
+ "@emotion/react": "*",
36
+ "@emotion/styled": "*"
37
+ },
38
+ "devDependencies": {
39
+ "eslint-plugin-storybook": "10.3.3"
40
+ },
41
+ "files": [
42
+ "dist",
43
+ "!dist/package.json",
44
+ "README.md",
45
+ "package.json"
46
+ ]
47
+ }