@mtes-mct/monitor-ui 2.10.0 → 2.12.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.10.0",
4
+ "version": "2.12.0",
5
5
  "license": "AGPL-3.0",
6
6
  "engines": {
7
7
  "node": ">=18"
@@ -9,7 +9,7 @@
9
9
  "dependencies": {
10
10
  "@babel/runtime": "7.20.6",
11
11
  "prop-types": "15.8.1",
12
- "tslib": "2.4.1"
12
+ "tslib": "2.5.0"
13
13
  },
14
14
  "peerDependencies": {
15
15
  "formik": "^2.0.0",
@@ -31,7 +31,7 @@
31
31
  "bash -c 'npm run test:type'"
32
32
  ]
33
33
  },
34
- "packageManager": "yarn@3.3.0",
34
+ "packageManager": "yarn@3.4.1",
35
35
  "bugs": {
36
36
  "url": "https://github.com/MTES-MCT/monitor-ui/issues"
37
37
  },
@@ -1,8 +1,9 @@
1
1
  import type { CheckboxProps as RsuiteCheckboxProps } from 'rsuite';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type CheckboxProps = Omit<RsuiteCheckboxProps, 'as' | 'checked' | 'id' | 'onChange'> & {
4
+ error?: string | undefined;
4
5
  label: string;
5
6
  name: string;
6
7
  onChange?: ((isCheched: boolean) => Promisable<void>) | undefined;
7
8
  };
8
- export declare function Checkbox({ label, onChange, ...originalProps }: CheckboxProps): JSX.Element;
9
+ export declare function Checkbox({ error, label, onChange, ...originalProps }: CheckboxProps): JSX.Element;
@@ -10,6 +10,7 @@ export interface DatePickerProps extends Omit<HTMLAttributes<HTMLFieldSetElement
10
10
  baseContainer?: Document | HTMLDivElement | null | undefined;
11
11
  defaultValue?: Date | string | undefined;
12
12
  disabled?: boolean | undefined;
13
+ error?: string | undefined;
13
14
  isCompact?: boolean | undefined;
14
15
  /** Only allow past dates until today. */
15
16
  isHistorical?: boolean | undefined;
@@ -11,6 +11,7 @@ export interface DateRangePickerProps extends Omit<HTMLAttributes<HTMLFieldSetEl
11
11
  baseContainer?: Document | HTMLDivElement | null | undefined;
12
12
  defaultValue?: DateRange | DateAsStringRange | undefined;
13
13
  disabled?: boolean | undefined;
14
+ error?: string | undefined;
14
15
  isCompact?: boolean | undefined;
15
16
  /** Only allow past dates until today. */
16
17
  isHistorical?: boolean | undefined;
@@ -2,6 +2,8 @@ import type { Option } from '../types';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type MultiCheckboxProps = {
4
4
  defaultValue?: string[] | undefined;
5
+ disabled?: boolean | undefined;
6
+ error?: string | undefined;
5
7
  isInline?: boolean | undefined;
6
8
  isLabelHidden?: boolean | undefined;
7
9
  isLight?: boolean | undefined;
@@ -10,4 +12,4 @@ export type MultiCheckboxProps = {
10
12
  onChange?: ((nextValue: string[] | undefined) => Promisable<void>) | undefined;
11
13
  options: Option[];
12
14
  };
13
- export declare function MultiCheckbox({ defaultValue, isInline, isLabelHidden, isLight, label, name, onChange, options }: MultiCheckboxProps): JSX.Element;
15
+ export declare function MultiCheckbox({ defaultValue, disabled, error, isInline, isLabelHidden, isLight, label, name, onChange, options }: MultiCheckboxProps): JSX.Element;
@@ -2,6 +2,8 @@ import type { Option } from '../types';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type MultiRadioProps = {
4
4
  defaultValue?: string | undefined;
5
+ disabled?: boolean | undefined;
6
+ error?: string | undefined;
5
7
  isInline?: boolean | undefined;
6
8
  isLabelHidden?: boolean | undefined;
7
9
  isLight?: boolean | undefined;
@@ -10,4 +12,4 @@ export type MultiRadioProps = {
10
12
  onChange?: ((nextValue: string | undefined) => Promisable<void>) | undefined;
11
13
  options: Option[];
12
14
  };
13
- export declare function MultiRadio({ defaultValue, isInline, isLabelHidden, isLight, label, name, onChange, options }: MultiRadioProps): JSX.Element;
15
+ export declare function MultiRadio({ defaultValue, disabled, error, isInline, isLabelHidden, isLight, label, name, onChange, options }: MultiRadioProps): JSX.Element;
@@ -2,6 +2,7 @@ import type { Promisable } from 'type-fest';
2
2
  export type MultiZoneEditorProps = {
3
3
  addButtonLabel: string;
4
4
  defaultValue?: Record<string, any>[] | undefined;
5
+ error?: string | undefined;
5
6
  initialZone: Record<string, any>;
6
7
  isLabelHidden?: boolean;
7
8
  isLight?: boolean | undefined;
@@ -12,4 +13,4 @@ export type MultiZoneEditorProps = {
12
13
  onDelete?: ((nextZones: Record<string, any>[]) => Promisable<void>) | undefined;
13
14
  onEdit?: ((zone: Record<string, any>, index: number) => Promisable<void>) | undefined;
14
15
  };
15
- export declare function MultiZoneEditor({ addButtonLabel, defaultValue, initialZone, isLabelHidden, isLight, label, labelPropName, onAdd, onCenter, onDelete, onEdit }: MultiZoneEditorProps): JSX.Element;
16
+ export declare function MultiZoneEditor({ addButtonLabel, defaultValue, error, initialZone, isLabelHidden, isLight, label, labelPropName, onAdd, onCenter, onDelete, onEdit }: MultiZoneEditorProps): JSX.Element;
@@ -2,10 +2,11 @@ import type { InputProps } from 'rsuite';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type NumberInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'id' | 'onChange' | 'type' | 'value'> & {
4
4
  defaultValue?: number | undefined;
5
+ error?: string | undefined;
5
6
  isLabelHidden?: boolean | undefined;
6
7
  isLight?: boolean | undefined;
7
8
  label: string;
8
9
  name: string;
9
10
  onChange?: ((nextValue: number | undefined) => Promisable<void>) | undefined;
10
11
  };
11
- export declare function NumberInput({ isLabelHidden, isLight, label, onChange, ...originalProps }: NumberInputProps): JSX.Element;
12
+ export declare function NumberInput({ error, isLabelHidden, isLight, label, onChange, ...originalProps }: NumberInputProps): JSX.Element;
@@ -2,10 +2,11 @@ import type { InputProps } from 'rsuite';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type TextInputProps = Omit<InputProps, 'as' | 'defaultValue' | 'id' | 'onChange' | 'type' | 'value'> & {
4
4
  defaultValue?: string | undefined;
5
+ error?: string | undefined;
5
6
  isLabelHidden?: boolean | undefined;
6
7
  isLight?: boolean | undefined;
7
8
  label: string;
8
9
  name: string;
9
10
  onChange?: ((nextValue: string | undefined) => Promisable<void>) | undefined;
10
11
  };
11
- export declare function TextInput({ isLabelHidden, isLight, label, onChange, ...originalProps }: TextInputProps): JSX.Element;
12
+ export declare function TextInput({ error, isLabelHidden, isLight, label, onChange, ...originalProps }: TextInputProps): JSX.Element;
@@ -2,10 +2,11 @@ import type { TextareaHTMLAttributes } from 'react';
2
2
  import type { Promisable } from 'type-fest';
3
3
  export type TextareaProps = Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'defaultValue' | 'id' | 'onChange' | 'value'> & {
4
4
  defaultValue?: string | undefined;
5
+ error?: string | undefined;
5
6
  isLabelHidden?: boolean | undefined;
6
7
  isLight?: boolean | undefined;
7
8
  label: string;
8
9
  name: string;
9
10
  onChange?: ((nextValue: string | undefined) => Promisable<void>) | undefined;
10
11
  };
11
- export declare function Textarea({ isLabelHidden, isLight, label, onChange, rows, ...originalProps }: TextareaProps): JSX.Element;
12
+ export declare function Textarea({ error, isLabelHidden, isLight, label, onChange, rows, ...originalProps }: TextareaProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { AutoCompleteProps } from '../fields/AutoComplete';
2
- export type FormikAutoCompleteProps = Omit<AutoCompleteProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikAutoCompleteProps = Omit<AutoCompleteProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikAutoComplete({ name, ...originalProps }: FormikAutoCompleteProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { CheckboxProps } from '../fields/Checkbox';
2
- export type FormikCheckboxProps = Omit<CheckboxProps, 'checked' | 'defaultChecked' | 'onChange'>;
2
+ export type FormikCheckboxProps = Omit<CheckboxProps, 'checked' | 'defaultChecked' | 'error' | 'onChange'>;
3
3
  export declare function FormikCheckbox({ name, ...originalProps }: FormikCheckboxProps): JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { DatePickerWithDateDateProps, DatePickerWithStringDateProps } from '../fields/DatePicker';
2
- export interface FormikDatePickerWithDateDateProps extends Omit<DatePickerWithDateDateProps, 'onChange'> {
2
+ export interface FormikDatePickerWithDateDateProps extends Omit<DatePickerWithDateDateProps, 'defaultValue' | 'error' | 'onChange'> {
3
3
  name: string;
4
4
  }
5
- export interface FormikDatePickerWithStringDateProps extends Omit<DatePickerWithStringDateProps, 'onChange'> {
5
+ export interface FormikDatePickerWithStringDateProps extends Omit<DatePickerWithStringDateProps, 'defaultValue' | 'error' | 'onChange'> {
6
6
  name: string;
7
7
  }
8
8
  export declare function FormikDatePicker(props: FormikDatePickerWithDateDateProps): JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { DateRangePickerWithDateDateProps, DateRangePickerWithStringDateProps } from '../fields/DateRangePicker';
2
- export interface FormikDateRangePickerWithDateDateProps extends Omit<DateRangePickerWithDateDateProps, 'onChange'> {
2
+ export interface FormikDateRangePickerWithDateDateProps extends Omit<DateRangePickerWithDateDateProps, 'defaultValue' | 'error' | 'onChange'> {
3
3
  name: string;
4
4
  }
5
- export interface FormikDateRangePickerWithStringDateProps extends Omit<DateRangePickerWithStringDateProps, 'onChange'> {
5
+ export interface FormikDateRangePickerWithStringDateProps extends Omit<DateRangePickerWithStringDateProps, 'defaultValue' | 'error' | 'onChange'> {
6
6
  name: string;
7
7
  }
8
8
  export declare function FormikDateRangePicker(props: FormikDateRangePickerWithDateDateProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { MultiCheckboxProps } from '../fields/MultiCheckbox';
2
- export type FormikMultiCheckboxProps = Omit<MultiCheckboxProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikMultiCheckboxProps = Omit<MultiCheckboxProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikMultiCheckbox({ name, ...originalProps }: FormikMultiCheckboxProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { MultiRadioProps } from '../fields/MultiRadio';
2
- export type FormikMultiRadioProps = Omit<MultiRadioProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikMultiRadioProps = Omit<MultiRadioProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikMultiRadio({ name, ...originalProps }: FormikMultiRadioProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { MultiSelectProps } from '../fields/MultiSelect';
2
- export type FormikMultiSelectProps = Omit<MultiSelectProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikMultiSelectProps = Omit<MultiSelectProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikMultiSelect({ name, ...originalProps }: FormikMultiSelectProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { NumberInputProps } from '../fields/NumberInput';
2
- export type FormikNumberInputProps = Omit<NumberInputProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikNumberInputProps = Omit<NumberInputProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikNumberInput({ name, ...originalProps }: FormikNumberInputProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { SelectProps } from '../fields/Select';
2
- export type FormikSelectProps = Omit<SelectProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikSelectProps = Omit<SelectProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikSelect({ name, ...originalProps }: FormikSelectProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { TextInputProps } from '../fields/TextInput';
2
- export type FormikTextInputProps = Omit<TextInputProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikTextInputProps = Omit<TextInputProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikTextInput({ name, ...originalProps }: FormikTextInputProps): JSX.Element;
@@ -1,3 +1,3 @@
1
1
  import type { TextareaProps } from '../fields/Textarea';
2
- export type FormikTextareaProps = Omit<TextareaProps, 'defaultValue' | 'onChange'>;
2
+ export type FormikTextareaProps = Omit<TextareaProps, 'defaultValue' | 'error' | 'onChange'>;
3
3
  export declare function FormikTextarea({ name, ...originalProps }: FormikTextareaProps): JSX.Element;
@@ -0,0 +1,3 @@
1
+ import type { MutableRefObject } from 'react';
2
+ import type { Promisable } from 'type-fest';
3
+ export declare const useClickOutsideEffect: (zoneRefOrzoneRefs: MutableRefObject<any> | MutableRefObject<any>[], action: () => Promisable<void>, baseContainer?: Document | HTMLDivElement | null) => void;
@@ -0,0 +1,2 @@
1
+ import type { Promisable } from 'type-fest';
2
+ export declare function useFieldUndefineEffect(disabled: boolean | undefined, onChange: ((nextValue: any) => Promisable<void>) | undefined): void;
package/src/index.d.ts CHANGED
@@ -37,7 +37,7 @@ export { FormikSelect } from './formiks/FormikSelect';
37
37
  export { FormikTextarea } from './formiks/FormikTextarea';
38
38
  export { FormikTextInput } from './formiks/FormikTextInput';
39
39
  export * as Icon from './icons';
40
- export { useClickOutside } from './hooks/useClickOutside';
40
+ export { useClickOutsideEffect } from './hooks/useClickOutsideEffect';
41
41
  export { useForceUpdate } from './hooks/useForceUpdate';
42
42
  export { dayjs } from './utils/dayjs';
43
43
  export { getLocalizedDayjs } from './utils/getLocalizedDayjs';
@@ -45,7 +45,7 @@ export { getUtcizedDayjs } from './utils/getUtcizedDayjs';
45
45
  export { noop } from './utils/noop';
46
46
  export { stopMouseEventPropagation } from './utils/stopMouseEventPropagation';
47
47
  export type { PartialTheme, Theme } from './theme';
48
- export type { DateAsStringRange, DateRange, IconProps, Option } from './types';
48
+ export type { DateAsStringRange, DateRange, IconProps, Option, Undefine } from './types';
49
49
  export type { DropdownProps, DropdownItemProps } from './components/Dropdown';
50
50
  export type { ButtonProps } from './elements/Button';
51
51
  export type { FieldProps } from './elements/Field';
package/src/types.d.ts CHANGED
@@ -10,3 +10,13 @@ export type Option<V = string> = {
10
10
  label: string;
11
11
  value: V;
12
12
  };
13
+ /**
14
+ * Mark all the props type of an interface/type as `| undefined`
15
+ *
16
+ * @description
17
+ * When `exactOptionalPropertyTypes` is enabled in tsconfig.json,
18
+ * this is useful to create "partial" objects while keeping their props mandatory.
19
+ */
20
+ export type Undefine<T> = {
21
+ [K in keyof T]: T[K] | undefined;
22
+ };
@@ -1,3 +0,0 @@
1
- import type { MutableRefObject } from 'react';
2
- import type { Promisable } from 'type-fest';
3
- export declare const useClickOutside: (zoneRefOrzoneRefs: MutableRefObject<any> | MutableRefObject<any>[], action: () => Promisable<void>, baseContainer?: Document | HTMLDivElement | null) => void;