@mtes-mct/monitor-ui 8.4.0 → 8.5.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/CHANGELOG.md +18 -0
- package/index.js +182 -30
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.d.ts +8 -1
- package/src/types.d.ts +34 -0
- package/src/utils/getOptionsFromIdAndName.d.ts +5 -0
- package/src/utils/getOptionsFromLabelledEnum.d.ts +2 -0
- package/src/utils/isArray.d.ts +1 -0
- package/src/utils/isDefined.d.ts +4 -0
- package/src/utils/isObject.d.ts +3 -0
- package/src/utils/nullify.d.ts +14 -0
- package/src/utils/undefine.d.ts +14 -0
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -65,13 +65,20 @@ export { CustomSearch } from './libs/CustomSearch';
|
|
|
65
65
|
export { customDayjs } from './utils/customDayjs';
|
|
66
66
|
export { getCoordinates, coordinatesAreDistinct } from './utils/coordinates';
|
|
67
67
|
export { getLocalizedDayjs } from './utils/getLocalizedDayjs';
|
|
68
|
+
export { getOptionsFromIdAndName } from './utils/getOptionsFromIdAndName';
|
|
69
|
+
export { getOptionsFromLabelledEnum } from './utils/getOptionsFromLabelledEnum';
|
|
68
70
|
export { getPseudoRandomString } from './utils/getPseudoRandomString';
|
|
69
71
|
export { getUtcizedDayjs } from './utils/getUtcizedDayjs';
|
|
72
|
+
export { isArray } from './utils/isArray';
|
|
73
|
+
export { isDefined } from './utils/isDefined';
|
|
70
74
|
export { isNumeric } from './utils/isNumeric';
|
|
75
|
+
export { isObject } from './utils/isObject';
|
|
71
76
|
export { logSoftError } from './utils/logSoftError';
|
|
77
|
+
export { nullify } from './utils/nullify';
|
|
72
78
|
export { stopMouseEventPropagation } from './utils/stopMouseEventPropagation';
|
|
79
|
+
export { undefine } from './utils/undefine';
|
|
73
80
|
export type { PartialTheme, Theme } from './theme';
|
|
74
|
-
export type { Coordinates, DateAsStringRange, DateRange, Defined, IconProps, Option, OptionValueType, Undefine } from './types';
|
|
81
|
+
export type { Coordinates, DateAsStringRange, DateRange, Defined, IconProps, Option, OptionValueType, Undefine, UndefineExceptArrays } from './types';
|
|
75
82
|
export type { DialogProps } from './components/Dialog';
|
|
76
83
|
export type { DropdownProps, DropdownItemProps } from './components/Dropdown';
|
|
77
84
|
export type { NewWindowProps } from './components/NewWindow';
|
package/src/types.d.ts
CHANGED
|
@@ -66,6 +66,40 @@ export type Define<T> = {
|
|
|
66
66
|
export type Undefine<T> = {
|
|
67
67
|
[K in keyof T]: T[K] | undefined;
|
|
68
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Mark all the prop types of an interface/type as `prop: <MyType> | undefined` while preserving array props.
|
|
71
|
+
*
|
|
72
|
+
* @description
|
|
73
|
+
* When `exactOptionalPropertyTypes` is enabled in tsconfig.json,
|
|
74
|
+
* this is useful to create objects allowing undefined prop values while keeping all their props required.
|
|
75
|
+
*
|
|
76
|
+
* Opposite of `Defined`.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```
|
|
80
|
+
* type MyType {
|
|
81
|
+
* aRequiredProp: string
|
|
82
|
+
* anOptionalProp?: string
|
|
83
|
+
* anArrayProp: number[]
|
|
84
|
+
* }
|
|
85
|
+
*
|
|
86
|
+
* // `type MyPartialType = UndefineExceptArrays<MyType>` is the same as typing:
|
|
87
|
+
* type MyPartialType {
|
|
88
|
+
* aRequiredProp: string | undefined
|
|
89
|
+
* anOptionalProp?: string | undefined
|
|
90
|
+
* anArrayProp: number[]
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export type UndefineExceptArrays<T> = {
|
|
95
|
+
[K in keyof T]: T[K] extends (infer U)[] ? U[] : T[K] | undefined;
|
|
96
|
+
};
|
|
97
|
+
export type Native = boolean | null | number | string | undefined;
|
|
98
|
+
export type NativeAny = boolean | NativeArray | NativeObject | null | number | string | undefined;
|
|
99
|
+
export type NativeArray = Array<NativeAny>;
|
|
100
|
+
export type NativeObject = {
|
|
101
|
+
[x: string]: NativeAny;
|
|
102
|
+
} | {};
|
|
69
103
|
/**
|
|
70
104
|
* Since Rsuite restricts `value` to `string | number`, we use this proxy type,
|
|
71
105
|
* allowing us to use conventioned option values that can include objects
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isArray<T>(value: any): value is T[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NativeAny } from '../types';
|
|
2
|
+
type Nullify<T> = T extends undefined ? null : T extends Array<any> ? {
|
|
3
|
+
[K in keyof T]: T[K] extends (infer U)[] ? Nullify<U>[] : Nullify<T[K]>;
|
|
4
|
+
} : T extends Record<string, any> ? {
|
|
5
|
+
[K in keyof T]: T[K] extends (infer U)[] ? Nullify<U>[] : Nullify<T[K]>;
|
|
6
|
+
} : T;
|
|
7
|
+
/**
|
|
8
|
+
* Transform all `undefined` values into `null` ones in any type of value
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* The value must be of native type and only contains native types.
|
|
12
|
+
*/
|
|
13
|
+
export declare function nullify<T extends NativeAny>(value: T): Nullify<T> | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { NativeAny } from '../types';
|
|
2
|
+
type Undefine<T> = T extends null ? undefined : T extends Array<any> ? {
|
|
3
|
+
[K in keyof T]: T[K] extends (infer U)[] ? Undefine<U>[] : Undefine<T[K]>;
|
|
4
|
+
} : T extends Record<string, any> ? {
|
|
5
|
+
[K in keyof T]: T[K] extends (infer U)[] ? Undefine<U>[] : Undefine<T[K]>;
|
|
6
|
+
} : T;
|
|
7
|
+
/**
|
|
8
|
+
* Transform all `null` values into `undefined` ones in any type of value
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* The value must be of native type and only contains native types.
|
|
12
|
+
*/
|
|
13
|
+
export declare function undefine<T extends NativeAny>(value: T): Undefine<T> | undefined;
|
|
14
|
+
export {};
|