@mtes-mct/monitor-ui 4.0.0 → 4.0.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ # [4.0.0](https://github.com/MTES-MCT/monitor-ui/compare/v3.7.1...v4.0.0) (2023-03-29)
2
+
3
+
4
+ * feat(fields)!: switch from uncontrolled to controlled values ([e308e1c](https://github.com/MTES-MCT/monitor-ui/commit/e308e1cdf68aea33805e11aba2b7278233286acf))
5
+
6
+
7
+ ### Features
8
+
9
+ * **fields:** handle object options in Select & MultiSelect ([cc280c9](https://github.com/MTES-MCT/monitor-ui/commit/cc280c91c4fd374a154996f511f8f76c767b2d27))
10
+
11
+
12
+ ### BREAKING CHANGES
13
+
14
+ * `defaultValue` is replaced by `value` in Checkbox,
15
+ MultiCheckbox, MultiRadio, MultiSelect, NumberInput, Select, Textarea & TextInput
16
+
1
17
  ## [3.7.1](https://github.com/MTES-MCT/monitor-ui/compare/v3.7.0...v3.7.1) (2023-03-17)
2
18
 
3
19
 
@@ -1,6 +1,6 @@
1
- import type { Option } from '../types';
1
+ import type { Option, OptionValueType } from '../types';
2
2
  import type { Promisable } from 'type-fest';
3
- export type MultiCheckboxProps<OptionValue extends number | string | Record<string, any> = string> = {
3
+ export type MultiCheckboxProps<OptionValue extends OptionValueType = string> = {
4
4
  disabled?: boolean | undefined;
5
5
  error?: string | undefined;
6
6
  isInline?: boolean | undefined;
@@ -13,4 +13,4 @@ export type MultiCheckboxProps<OptionValue extends number | string | Record<stri
13
13
  options: Option<OptionValue>[];
14
14
  value?: OptionValue[] | undefined;
15
15
  };
16
- export declare function MultiCheckbox<OptionValue extends number | string | Record<string, any> = string>({ value, disabled, error, isInline, isLabelHidden, isLight, isUndefinedWhenDisabled, label, name, onChange, options }: MultiCheckboxProps<OptionValue>): JSX.Element;
16
+ export declare function MultiCheckbox<OptionValue extends OptionValueType = string>({ value, disabled, error, isInline, isLabelHidden, isLight, isUndefinedWhenDisabled, label, name, onChange, options }: MultiCheckboxProps<OptionValue>): JSX.Element;
@@ -1,6 +1,6 @@
1
- import type { Option } from '../types';
1
+ import type { Option, OptionValueType } from '../types';
2
2
  import type { Promisable } from 'type-fest';
3
- export type MultiRadioProps<OptionValue extends number | string | Record<string, any> = string> = {
3
+ export type MultiRadioProps<OptionValue extends OptionValueType = string> = {
4
4
  disabled?: boolean | undefined;
5
5
  error?: string | undefined;
6
6
  isInline?: boolean | undefined;
@@ -13,4 +13,4 @@ export type MultiRadioProps<OptionValue extends number | string | Record<string,
13
13
  options: Option<OptionValue>[];
14
14
  value?: OptionValue | undefined;
15
15
  };
16
- export declare function MultiRadio<OptionValue extends number | string | Record<string, any> = string>({ disabled, error, isInline, isLabelHidden, isLight, isUndefinedWhenDisabled, label, name, onChange, options, value }: MultiRadioProps<OptionValue>): JSX.Element;
16
+ export declare function MultiRadio<OptionValue extends OptionValueType = string>({ disabled, error, isInline, isLabelHidden, isLight, isUndefinedWhenDisabled, label, name, onChange, options, value }: MultiRadioProps<OptionValue>): JSX.Element;
@@ -1,7 +1,7 @@
1
- import type { Option } from '../types';
1
+ import type { Option, OptionValueType } from '../types';
2
2
  import type { TagPickerProps } from 'rsuite';
3
3
  import type { Promisable } from 'type-fest';
4
- export type MultiSelectProps<OptionValue extends number | string | Record<string, any> = string> = Omit<TagPickerProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'renderMenuItem' | 'value'> & {
4
+ export type MultiSelectProps<OptionValue extends OptionValueType = string> = Omit<TagPickerProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'renderMenuItem' | 'value'> & {
5
5
  /** Used to pass something else than `window.document` as a base container to attach global events listeners. */
6
6
  baseContainer?: Document | HTMLDivElement | null | undefined;
7
7
  error?: string | undefined;
@@ -17,4 +17,4 @@ export type MultiSelectProps<OptionValue extends number | string | Record<string
17
17
  options: Option<OptionValue>[];
18
18
  value?: OptionValue[] | undefined;
19
19
  };
20
- export declare function MultiSelect<OptionValue extends number | string | Record<string, any> = string>({ baseContainer, error, isLabelHidden, isLight, isUndefinedWhenDisabled, label, onChange, options, optionValueKey, searchable, value, ...originalProps }: MultiSelectProps<OptionValue>): JSX.Element;
20
+ export declare function MultiSelect<OptionValue extends OptionValueType = string>({ baseContainer, error, isLabelHidden, isLight, isUndefinedWhenDisabled, label, onChange, options, optionValueKey, searchable, value, ...originalProps }: MultiSelectProps<OptionValue>): JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import type { Option } from '../types';
2
+ import type { Option, OptionValueType } from '../types';
3
3
  import type { AutoCompleteProps as RsuiteAutoCompleteProps } from 'rsuite';
4
4
  import type { Promisable } from 'type-fest';
5
- export type SearchProps<OptionValue extends number | string | Record<string, any> = string> = Omit<RsuiteAutoCompleteProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'onSelect' | 'value'> & {
5
+ export type SearchProps<OptionValue extends OptionValueType = string> = Omit<RsuiteAutoCompleteProps, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'onSelect' | 'value'> & {
6
6
  MenuItem?: React.ElementType | undefined;
7
7
  /** Used to pass something else than `window.document` as a base container to attach global events listeners. */
8
8
  baseContainer?: Document | HTMLDivElement | null | undefined;
@@ -21,4 +21,4 @@ export type SearchProps<OptionValue extends number | string | Record<string, any
21
21
  /** Duration in milliseconds */
22
22
  throttleDuration?: number;
23
23
  };
24
- export declare function Search<OptionValue extends number | string | Record<string, any> = string>({ baseContainer, defaultValue, error, isLabelHidden, isLight, isSearchIconHidden, label, MenuItem, onChange, onQuery, options, queryMap, queryUrl, throttleDuration, ...originalProps }: SearchProps<OptionValue>): JSX.Element;
24
+ export declare function Search<OptionValue extends OptionValueType = string>({ baseContainer, defaultValue, error, isLabelHidden, isLight, isSearchIconHidden, label, MenuItem, onChange, onQuery, options, queryMap, queryUrl, throttleDuration, ...originalProps }: SearchProps<OptionValue>): JSX.Element;
@@ -1,7 +1,7 @@
1
- import type { Option } from '../types';
1
+ import type { Option, OptionValueType } from '../types';
2
2
  import type { SelectPickerProps } from 'rsuite';
3
3
  import type { Promisable } from 'type-fest';
4
- export type SelectProps<OptionValue extends number | string | Record<string, any> = string> = Omit<SelectPickerProps<any>, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'renderMenuItem' | 'renderValue' | 'value' | 'valueKey'> & {
4
+ export type SelectProps<OptionValue extends OptionValueType = string> = Omit<SelectPickerProps<any>, 'as' | 'container' | 'data' | 'defaultValue' | 'id' | 'onChange' | 'open' | 'renderMenuItem' | 'renderValue' | 'value' | 'valueKey'> & {
5
5
  /** Used to pass something else than `window.document` as a base container to attach global events listeners. */
6
6
  baseContainer?: Document | HTMLDivElement | null | undefined;
7
7
  error?: string | undefined;
@@ -15,4 +15,4 @@ export type SelectProps<OptionValue extends number | string | Record<string, any
15
15
  options: Option<OptionValue>[];
16
16
  value?: OptionValue | undefined;
17
17
  };
18
- export declare function Select<OptionValue extends number | string | Record<string, any> = string>({ baseContainer, error, isLabelHidden, isLight, isUndefinedWhenDisabled, label, onChange, options, optionValueKey, searchable, value, ...originalProps }: SelectProps<OptionValue>): JSX.Element;
18
+ export declare function Select<OptionValue extends OptionValueType = string>({ baseContainer, error, isLabelHidden, isLight, isUndefinedWhenDisabled, label, onChange, options, optionValueKey, searchable, value, ...originalProps }: SelectProps<OptionValue>): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import type { MultiCheckboxProps } from '../fields/MultiCheckbox';
2
- export type FormikMultiCheckboxProps<OptionValue extends number | string | Record<string, any> = string> = Omit<MultiCheckboxProps<OptionValue>, 'defaultValue' | 'error' | 'onChange'>;
3
- export declare function FormikMultiCheckbox<OptionValue extends number | string | Record<string, any> = string>({ name, ...originalProps }: FormikMultiCheckboxProps<OptionValue>): JSX.Element;
2
+ import type { OptionValueType } from '../types';
3
+ export type FormikMultiCheckboxProps<OptionValue extends OptionValueType = string> = Omit<MultiCheckboxProps<OptionValue>, 'defaultValue' | 'error' | 'onChange'>;
4
+ export declare function FormikMultiCheckbox<OptionValue extends OptionValueType = string>({ name, ...originalProps }: FormikMultiCheckboxProps<OptionValue>): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import type { MultiRadioProps } from '../fields/MultiRadio';
2
- export type FormikMultiRadioProps<OptionValue extends number | string | Record<string, any> = string> = Omit<MultiRadioProps<OptionValue>, 'error' | 'onChange' | 'value'>;
3
- export declare function FormikMultiRadio<OptionValue extends number | string | Record<string, any> = string>({ name, ...originalProps }: FormikMultiRadioProps<OptionValue>): JSX.Element;
2
+ import type { OptionValueType } from '../types';
3
+ export type FormikMultiRadioProps<OptionValue extends OptionValueType = string> = Omit<MultiRadioProps<OptionValue>, 'error' | 'onChange' | 'value'>;
4
+ export declare function FormikMultiRadio<OptionValue extends OptionValueType = string>({ name, ...originalProps }: FormikMultiRadioProps<OptionValue>): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import type { MultiSelectProps } from '../fields/MultiSelect';
2
- export type FormikMultiSelectProps<OptionValue extends number | string | Record<string, any> = string> = Omit<MultiSelectProps<OptionValue>, 'error' | 'onChange' | 'value'>;
3
- export declare function FormikMultiSelect<OptionValue extends number | string | Record<string, any> = string>({ name, ...originalProps }: FormikMultiSelectProps<OptionValue>): JSX.Element;
2
+ import type { OptionValueType } from '../types';
3
+ export type FormikMultiSelectProps<OptionValue extends OptionValueType = string> = Omit<MultiSelectProps<OptionValue>, 'error' | 'onChange' | 'value'>;
4
+ export declare function FormikMultiSelect<OptionValue extends OptionValueType = string>({ name, ...originalProps }: FormikMultiSelectProps<OptionValue>): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import type { SearchProps } from '../fields/Search';
2
- export type FormikSearchProps<OptionValue extends number | string | Record<string, any> = string> = Omit<SearchProps<OptionValue>, 'defaultValue' | 'error' | 'onChange'>;
3
- export declare function FormikSearch<OptionValue extends number | string | Record<string, any> = string>({ name, ...originalProps }: FormikSearchProps<OptionValue>): JSX.Element;
2
+ import type { OptionValueType } from '../types';
3
+ export type FormikSearchProps<OptionValue extends OptionValueType = string> = Omit<SearchProps<OptionValue>, 'defaultValue' | 'error' | 'onChange'>;
4
+ export declare function FormikSearch<OptionValue extends OptionValueType = string>({ name, ...originalProps }: FormikSearchProps<OptionValue>): JSX.Element;
@@ -1,3 +1,4 @@
1
1
  import type { SelectProps } from '../fields/Select';
2
- export type FormikSelectProps<OptionValue extends number | string | Record<string, any> = string> = Omit<SelectProps<OptionValue>, 'error' | 'onChange' | 'value'>;
3
- export declare function FormikSelect<OptionValue extends number | string | Record<string, any> = string>({ name, ...originalProps }: FormikSelectProps<OptionValue>): JSX.Element;
2
+ import type { OptionValueType } from '../types';
3
+ export type FormikSelectProps<OptionValue extends OptionValueType = string> = Omit<SelectProps<OptionValue>, 'error' | 'onChange' | 'value'>;
4
+ export declare function FormikSelect<OptionValue extends OptionValueType = string>({ name, ...originalProps }: FormikSelectProps<OptionValue>): JSX.Element;
package/index.d.ts CHANGED
@@ -53,7 +53,7 @@ export { noop } from './utils/noop';
53
53
  export { isNumeric } from './utils/isNumeric';
54
54
  export { stopMouseEventPropagation } from './utils/stopMouseEventPropagation';
55
55
  export type { PartialTheme, Theme } from './theme';
56
- export type { Coordinates, DateAsStringRange, DateRange, IconProps, Option, Undefine } from './types';
56
+ export type { Coordinates, DateAsStringRange, DateRange, IconProps, Option, OptionValueType, Undefine } from './types';
57
57
  export type { DropdownProps, DropdownItemProps } from './components/Dropdown';
58
58
  export type { SingleTagProps } from './components/SingleTag';
59
59
  export type { ButtonProps } from './elements/Button';