@mtes-mct/monitor-ui 2.16.0 → 2.18.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mtes-mct/monitor-ui",
3
3
  "description": "Common React UI components and styles for Monitorfish and Monitorenv.",
4
- "version": "2.16.0",
4
+ "version": "2.18.0",
5
5
  "license": "AGPL-3.0",
6
6
  "engines": {
7
7
  "node": ">=18"
@@ -9,7 +9,8 @@
9
9
  "dependencies": {
10
10
  "@babel/runtime": "7.20.6",
11
11
  "prop-types": "15.8.1",
12
- "tslib": "2.5.0"
12
+ "tslib": "2.5.0",
13
+ "use-debounce": "^9.0.3"
13
14
  },
14
15
  "peerDependencies": {
15
16
  "formik": "^2.0.0",
@@ -8,3 +8,5 @@ export declare enum Size {
8
8
  NORMAL = "NORMAL",
9
9
  SMALL = "SMALL"
10
10
  }
11
+ export declare const WSG84_PROJECTION = "EPSG:4326";
12
+ export declare const OPENLAYERS_PROJECTION = "EPSG:3857";
@@ -1,9 +1,10 @@
1
1
  import { Accent, Size } from '../constants';
2
2
  import type { IconProps } from '../types';
3
3
  import type { ButtonHTMLAttributes, FunctionComponent } from 'react';
4
- export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
4
+ export type ButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'> & {
5
5
  Icon?: FunctionComponent<IconProps> | undefined;
6
6
  accent?: Accent | undefined;
7
+ children?: string | undefined;
7
8
  isFullWidth?: boolean | undefined;
8
9
  size?: Size | undefined;
9
10
  };
@@ -0,0 +1,6 @@
1
+ type DDCoordinatesInputProps = {
2
+ coordinates: [number, number];
3
+ onChange: (nextCoordinates: [number, number], coordinates: [number, number]) => void;
4
+ };
5
+ export declare function DDCoordinatesInput({ coordinates, onChange }: DDCoordinatesInputProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,8 @@
1
+ import { CoordinatesFormat } from './constants';
2
+ type DMDCoordinatesInputProps = {
3
+ coordinates: number[];
4
+ coordinatesFormat: CoordinatesFormat;
5
+ onChange: (nextCoordinates: number[], coordinates: number[]) => void;
6
+ };
7
+ export declare function DMDCoordinatesInput({ coordinates, coordinatesFormat, onChange }: DMDCoordinatesInputProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { CoordinatesFormat } from './constants';
2
+ type DMSCoordinatesInputProps = {
3
+ coordinates: number[];
4
+ coordinatesFormat: CoordinatesFormat;
5
+ onChange: (nextCoordinates: number[], coordinates: number[]) => void;
6
+ };
7
+ export declare function DMSCoordinatesInput({ coordinates, coordinatesFormat, onChange }: DMSCoordinatesInputProps): JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ export declare enum CoordinatesFormat {
2
+ DECIMAL_DEGREES = "DD",
3
+ DEGREES_MINUTES_DECIMALS = "DMD",
4
+ DEGREES_MINUTES_SECONDS = "DMS"
5
+ }
@@ -0,0 +1,8 @@
1
+ import { CoordinatesFormat } from './constants';
2
+ import type { Promisable } from 'type-fest';
3
+ export type CoordinatesInputProps = {
4
+ coordinatesFormat: CoordinatesFormat;
5
+ defaultValue: number[];
6
+ onChange: (nextCoordinates: number[], coordinates: number[]) => Promisable<void>;
7
+ };
8
+ export declare function CoordinatesInput({ coordinatesFormat, defaultValue, onChange }: CoordinatesInputProps): JSX.Element;
package/src/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
- export { Accent, Size } from './constants';
1
+ export { Accent, Size, OPENLAYERS_PROJECTION, WSG84_PROJECTION } from './constants';
2
2
  export { GlobalStyle } from './GlobalStyle';
3
3
  export { OnlyFontGlobalStyle } from './OnlyFontGlobalStyle';
4
4
  export { THEME } from './theme';
5
5
  export { ThemeProvider } from './ThemeProvider';
6
+ export { CoordinatesFormat } from './fields/CoordinatesInput/constants';
6
7
  export { Dropdown } from './components/Dropdown';
7
8
  export { SingleTag } from './components/SingleTag';
8
9
  export { Button } from './elements/Button';
@@ -22,6 +23,7 @@ export { MultiSelect } from './fields/MultiSelect';
22
23
  export { MultiRadio } from './fields/MultiRadio';
23
24
  export { MultiZoneEditor } from './fields/MultiZoneEditor';
24
25
  export { NumberInput } from './fields/NumberInput';
26
+ export { CoordinatesInput } from './fields/CoordinatesInput';
25
27
  export { Select } from './fields/Select';
26
28
  export { Textarea } from './fields/Textarea';
27
29
  export { TextInput } from './fields/TextInput';
@@ -43,9 +45,11 @@ export { useKey } from './hooks/useKey';
43
45
  export { useForceUpdate } from './hooks/useForceUpdate';
44
46
  export { usePrevious } from './hooks/usePrevious';
45
47
  export { dayjs } from './utils/dayjs';
48
+ export { getCoordinates, coordinatesAreDistinct } from './utils/coordinates';
46
49
  export { getLocalizedDayjs } from './utils/getLocalizedDayjs';
47
50
  export { getUtcizedDayjs } from './utils/getUtcizedDayjs';
48
51
  export { noop } from './utils/noop';
52
+ export { isNumeric } from './utils/isNumeric';
49
53
  export { stopMouseEventPropagation } from './utils/stopMouseEventPropagation';
50
54
  export type { PartialTheme, Theme } from './theme';
51
55
  export type { DateAsStringRange, DateRange, IconProps, Option, Undefine } from './types';
@@ -68,6 +72,7 @@ export type { MultiSelectProps } from './fields/MultiSelect';
68
72
  export type { MultiRadioProps } from './fields/MultiRadio';
69
73
  export type { MultiZoneEditorProps } from './fields/MultiZoneEditor';
70
74
  export type { NumberInputProps } from './fields/NumberInput';
75
+ export type { CoordinatesInputProps } from './fields/CoordinatesInput';
71
76
  export type { SelectProps } from './fields/Select';
72
77
  export type { TextareaProps } from './fields/Textarea';
73
78
  export type { TextInputProps } from './fields/TextInput';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Get coordinates in the specified format
3
+ * @param {number[]} coordinates - Coordinates ([longitude, latitude]) in decimal format.
4
+ * @param {string} projection - The project of the entered coordinates.
5
+ * @param {string} coordinatesFormat - The wanted format of the returned coordinates (DMS, DMD or DD)
6
+ * @param {boolean} isForPrint - If it's for print or not. Default to true
7
+ * @returns {string[]} coordinates - The [latitude, longitude] coordinates
8
+ */
9
+ export declare const getCoordinates: (coordinates: any, projection: any, coordinatesFormat: any, isForPrint?: boolean) => string[];
10
+ /**
11
+ * Check if coordinates are the same or roughly the same (to the 0.000001 decimal degree - to avoid infinite rounding loop)
12
+ * @param nextCoordinates - Next coordinates ([longitude, latitude]) in decimal format.
13
+ * @param coordinates - Coordinates ([longitude, latitude]) in decimal format.
14
+ */
15
+ export declare const coordinatesAreDistinct: (nextCoordinates: number[], coordinates: number[]) => boolean;
@@ -0,0 +1 @@
1
+ export declare function isNumeric(val: any): val is number | string;