@codeleap/types 4.3.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 +22 -0
- package/package.json.bak +22 -0
- package/src/appSettings.ts +102 -0
- package/src/common.ts +23 -0
- package/src/google-places.ts +96 -0
- package/src/index.ts +7 -0
- package/src/pathMapping.ts +52 -0
- package/src/react-native-masked-text.ts +51 -0
- package/src/typeGuards.ts +57 -0
- package/src/utility.ts +118 -0
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codeleap/types",
|
|
3
|
+
"version": "4.3.0",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
|
|
8
|
+
"type": "git",
|
|
9
|
+
"directory": "packages/types"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@codeleap/config": "4.3.0",
|
|
13
|
+
"ts-node-dev": "1.1.8"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "echo 'No build needed'"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript": "5.0.4",
|
|
20
|
+
"react": "18.1.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json.bak
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codeleap/types",
|
|
3
|
+
"version": "4.3.0",
|
|
4
|
+
"main": "src/index.ts",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
|
|
8
|
+
"type": "git",
|
|
9
|
+
"directory": "packages/types"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@codeleap/config": "workspace:*",
|
|
13
|
+
"ts-node-dev": "1.1.8"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "echo 'No build needed'"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"typescript": "5.0.4",
|
|
20
|
+
"react": "18.1.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { DeepPartial, Matcher, LogType } from '.'
|
|
2
|
+
|
|
3
|
+
export type AppSettings = DeepPartial<{
|
|
4
|
+
AppName: string
|
|
5
|
+
|
|
6
|
+
CompanyName: string
|
|
7
|
+
|
|
8
|
+
CompanySuffix: string
|
|
9
|
+
|
|
10
|
+
Description: string
|
|
11
|
+
|
|
12
|
+
Environment: {
|
|
13
|
+
IsDev: boolean
|
|
14
|
+
Type: 'production' | 'development'
|
|
15
|
+
InitTime: any
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Application: {
|
|
19
|
+
IsBrowser: boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
BaseURL: string
|
|
23
|
+
|
|
24
|
+
Sentry: {
|
|
25
|
+
enable: boolean
|
|
26
|
+
dsn: string
|
|
27
|
+
provider: any
|
|
28
|
+
debug?: boolean
|
|
29
|
+
initArgs?: any
|
|
30
|
+
beforeBreadcrumb?: any
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
PerformanceInspector: {
|
|
34
|
+
enable: boolean
|
|
35
|
+
maxRenders: number
|
|
36
|
+
blacklist?: string[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Logger: {
|
|
40
|
+
Level: LogType | LogType[]
|
|
41
|
+
DeviceIdentifier?: string
|
|
42
|
+
IgnoreWarnings?: string[]
|
|
43
|
+
StringifyObjects?: boolean
|
|
44
|
+
isMain?: boolean
|
|
45
|
+
inspect?: any
|
|
46
|
+
alwaysSendToSentry?: boolean
|
|
47
|
+
Obfuscate: {
|
|
48
|
+
keys: Matcher<'key'>[]
|
|
49
|
+
values: Matcher<'value'>[]
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Vars: {
|
|
54
|
+
GooglePlayURL: string
|
|
55
|
+
AppStoreURL: string
|
|
56
|
+
WebsiteURL: string
|
|
57
|
+
PrivacyPolicy: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Fetch: {
|
|
61
|
+
ProductionURL: string
|
|
62
|
+
DevelopmentURL: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Social: {
|
|
66
|
+
FaceURL: string
|
|
67
|
+
LinkedinURL: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
ContactINFO: {
|
|
71
|
+
Website: string
|
|
72
|
+
TermsAndPrivacy: string
|
|
73
|
+
SupportEMAIL: string
|
|
74
|
+
ContactEMAIL: string
|
|
75
|
+
ContactPHONE: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ApiCredentials: {
|
|
79
|
+
GoogleSignin: {
|
|
80
|
+
WebClientId: string
|
|
81
|
+
}
|
|
82
|
+
FacebookSDK: {
|
|
83
|
+
AppId: string
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Slack: {
|
|
88
|
+
echo: {
|
|
89
|
+
channel?: string
|
|
90
|
+
icon: string
|
|
91
|
+
token: string
|
|
92
|
+
baseURL?: string
|
|
93
|
+
enabled?: boolean
|
|
94
|
+
options?: Record<string, any>
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}>
|
|
98
|
+
|
|
99
|
+
export type ConfigurableSettings = Pick<
|
|
100
|
+
AppSettings,
|
|
101
|
+
'Fetch' | 'Logger' | 'ApiCredentials'
|
|
102
|
+
>
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type CancellablePromise<T> = Promise<T> & { abort?: () => void }
|
|
2
|
+
|
|
3
|
+
export type WebInputFile = {
|
|
4
|
+
file: File
|
|
5
|
+
preview: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type MobileFileBase = {
|
|
9
|
+
fileCopyUri?: string
|
|
10
|
+
name: string
|
|
11
|
+
size: number
|
|
12
|
+
type: string
|
|
13
|
+
uri: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type MobileFile<Extra = {}> = Omit<MobileFileBase, keyof Extra> & Partial<Extra>
|
|
17
|
+
|
|
18
|
+
export type FileWithPreview<Extra = {}> = {
|
|
19
|
+
file: MobileFile<Extra>
|
|
20
|
+
preview: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type MobileInputFile<Extra = {}> = FileWithPreview<Extra> | MobileFile<Extra>
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export type AddressComponent = {
|
|
2
|
+
long_name: string
|
|
3
|
+
short_name: string
|
|
4
|
+
types: string[]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type LatLng = {
|
|
8
|
+
lat: number
|
|
9
|
+
lng: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type GeometryBounds = {
|
|
13
|
+
northeast: LatLng
|
|
14
|
+
southwest: LatLng
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type Geometry = {
|
|
18
|
+
location: LatLng
|
|
19
|
+
location_type: string
|
|
20
|
+
viewport: GeometryBounds
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type PlusCode = {
|
|
24
|
+
compound_code: string
|
|
25
|
+
global_code: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type MatchedSubstring = {
|
|
29
|
+
length: number
|
|
30
|
+
offset: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type Term = {
|
|
34
|
+
offset: number
|
|
35
|
+
value: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type Photo = {
|
|
39
|
+
height: number
|
|
40
|
+
html_attributions: string[]
|
|
41
|
+
photo_reference: string
|
|
42
|
+
width: number
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type PlaceDetails = {
|
|
46
|
+
address_components: AddressComponent[]
|
|
47
|
+
adr_address: string
|
|
48
|
+
formatted_address: string
|
|
49
|
+
geometry: Geometry
|
|
50
|
+
icon: string
|
|
51
|
+
icon_background_color: string
|
|
52
|
+
icon_mask_base_uri: string
|
|
53
|
+
name: string
|
|
54
|
+
place_id: string
|
|
55
|
+
reference: string
|
|
56
|
+
types: string[]
|
|
57
|
+
url: string
|
|
58
|
+
utc_offset: number
|
|
59
|
+
vicinity: string
|
|
60
|
+
|
|
61
|
+
// NOTE - some places return photos when details is true
|
|
62
|
+
// e.g Toronto, Canada
|
|
63
|
+
photos?: Photo[]
|
|
64
|
+
website?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type PlaceLatLngDetails = PlaceDetails & {
|
|
68
|
+
plus_code: PlusCode
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type PlaceAddress = {
|
|
72
|
+
description: string
|
|
73
|
+
matched_substrings: MatchedSubstring[]
|
|
74
|
+
place_id: string
|
|
75
|
+
reference: string
|
|
76
|
+
structured_formatting: {
|
|
77
|
+
main_text: string
|
|
78
|
+
main_text_matched_substrings: MatchedSubstring[]
|
|
79
|
+
secondary_text: string
|
|
80
|
+
}
|
|
81
|
+
terms: Term[]
|
|
82
|
+
types: string[]
|
|
83
|
+
|
|
84
|
+
details?: PlaceDetails
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type PlaceLatLng = {
|
|
88
|
+
address_components: AddressComponent[]
|
|
89
|
+
formatted_address: string
|
|
90
|
+
geometry: Geometry
|
|
91
|
+
place_id: string
|
|
92
|
+
plus_code: PlusCode
|
|
93
|
+
types: string[]
|
|
94
|
+
|
|
95
|
+
details?: PlaceLatLngDetails
|
|
96
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type Prev = [
|
|
2
|
+
never,
|
|
3
|
+
0,
|
|
4
|
+
1,
|
|
5
|
+
2,
|
|
6
|
+
3,
|
|
7
|
+
4,
|
|
8
|
+
5,
|
|
9
|
+
6,
|
|
10
|
+
7,
|
|
11
|
+
8,
|
|
12
|
+
9,
|
|
13
|
+
10,
|
|
14
|
+
11,
|
|
15
|
+
12,
|
|
16
|
+
13,
|
|
17
|
+
14,
|
|
18
|
+
15,
|
|
19
|
+
16,
|
|
20
|
+
17,
|
|
21
|
+
18,
|
|
22
|
+
19,
|
|
23
|
+
20,
|
|
24
|
+
...0[]
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
export type Join<K, P> = K extends string | number
|
|
28
|
+
? P extends string | number
|
|
29
|
+
? `${K}${'' extends P ? '' : '.'}${P}`
|
|
30
|
+
: never
|
|
31
|
+
: never
|
|
32
|
+
|
|
33
|
+
export type Paths<T, D extends number = 2> = [D] extends [never]
|
|
34
|
+
? never
|
|
35
|
+
: (T extends Date
|
|
36
|
+
? ''
|
|
37
|
+
: (T extends object
|
|
38
|
+
? {
|
|
39
|
+
[K in keyof T]-?: K extends string | number
|
|
40
|
+
? `${K}` | Join<K, Paths<T[K], Prev[D]>>
|
|
41
|
+
: never;
|
|
42
|
+
}[keyof T]
|
|
43
|
+
: '')
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export type ExtractPath<T> = T extends object
|
|
47
|
+
? {
|
|
48
|
+
[K in keyof T & (string | number)]: T[K] extends object
|
|
49
|
+
? `${K}` | `${K}.${ExtractPath<T[K]>}`
|
|
50
|
+
: `${K}`
|
|
51
|
+
}[keyof T & (string | number)]
|
|
52
|
+
: never
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Type prop of TextInputMask.
|
|
2
|
+
export type TextInputMaskTypeProp =
|
|
3
|
+
| 'credit-card'
|
|
4
|
+
| 'cpf'
|
|
5
|
+
| 'cnpj'
|
|
6
|
+
| 'zip-code'
|
|
7
|
+
| 'only-numbers'
|
|
8
|
+
| 'money'
|
|
9
|
+
| 'cel-phone'
|
|
10
|
+
| 'datetime'
|
|
11
|
+
| 'custom'
|
|
12
|
+
|
|
13
|
+
// Option prop of TextInputMask.
|
|
14
|
+
export interface TextInputMaskOptionProp {
|
|
15
|
+
// Money type.
|
|
16
|
+
precision?: number
|
|
17
|
+
separator?: string
|
|
18
|
+
delimiter?: string
|
|
19
|
+
unit?: string
|
|
20
|
+
suffixUnit?: string
|
|
21
|
+
zeroCents?: boolean
|
|
22
|
+
|
|
23
|
+
// Phone type.
|
|
24
|
+
withDDD?: boolean
|
|
25
|
+
dddMask?: string
|
|
26
|
+
maskType?: 'BRL' | 'INTERNATIONAL'
|
|
27
|
+
|
|
28
|
+
// Datetime type.
|
|
29
|
+
format?: string
|
|
30
|
+
|
|
31
|
+
// Credit card type.
|
|
32
|
+
obfuscated?: boolean
|
|
33
|
+
issuer?: 'visa-or-mastercard' | 'diners' | 'amex'
|
|
34
|
+
|
|
35
|
+
// Custom type.
|
|
36
|
+
mask?: string
|
|
37
|
+
validator?: (value: string, settings: TextInputMaskOptionProp) => boolean
|
|
38
|
+
getRawValue?: (value: string, settings: TextInputMaskOptionProp) => any
|
|
39
|
+
translation?: { [s: string]: (val: string) => string | null | undefined }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// TextInputMask Props
|
|
43
|
+
export interface TextInputMaskProps {
|
|
44
|
+
type: TextInputMaskTypeProp
|
|
45
|
+
options?: TextInputMaskOptionProp
|
|
46
|
+
checkText?: (previous: string, next: string) => boolean
|
|
47
|
+
customTextInput?: any
|
|
48
|
+
customTextInputProps?: Object
|
|
49
|
+
includeRawValueInChangeText?: boolean
|
|
50
|
+
}
|
|
51
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { AnyFunction } from './utility'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
export function isNumber(x): x is number {
|
|
5
|
+
return typeof x === 'number'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function isString(x): x is string {
|
|
9
|
+
return typeof x === 'string'
|
|
10
|
+
}
|
|
11
|
+
export function isObject(x): x is object {
|
|
12
|
+
return typeof x === 'object'
|
|
13
|
+
}
|
|
14
|
+
export function isBoolean(x): x is boolean {
|
|
15
|
+
return typeof x === 'boolean'
|
|
16
|
+
}
|
|
17
|
+
export function isFunction(x): x is (AnyFunction) {
|
|
18
|
+
return typeof x === 'function'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function isConstructor(x): x is (new (...args) => any) {
|
|
22
|
+
return typeof x === 'function'
|
|
23
|
+
}
|
|
24
|
+
export function isArray(x): x is any[] {
|
|
25
|
+
return Array.isArray(x)
|
|
26
|
+
}
|
|
27
|
+
export function isUndefined(x): x is undefined {
|
|
28
|
+
return typeof x === 'undefined'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function isNull(x): x is null {
|
|
32
|
+
return x === null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isNil(x): x is null | undefined {
|
|
36
|
+
return isNull(x) || isUndefined(x)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function is<T >(x, Enum: T[]): x is T {
|
|
40
|
+
return Enum.includes(x)
|
|
41
|
+
}
|
|
42
|
+
type Abstract<T> = Function & {prototype: T}
|
|
43
|
+
|
|
44
|
+
type Constructor<T> = new (...args: any[]) => T
|
|
45
|
+
type Class<T = any> = Abstract<T> | Constructor<T>
|
|
46
|
+
|
|
47
|
+
export function isInstance<T extends Class, X = T extends Class<infer X> ? X : never>(x, cls: T): x is X {
|
|
48
|
+
return x instanceof cls
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isElement(x): x is React.ReactElement {
|
|
52
|
+
return React.isValidElement(x)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function isComponentOrElement<P>(x: any): x is React.ComponentType<P> | React.ReactElement {
|
|
56
|
+
return isFunction(x) || isElement(x)
|
|
57
|
+
}
|
package/src/utility.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Prev } from './pathMapping'
|
|
2
|
+
/* eslint-disable no-unused-vars */
|
|
3
|
+
export type AnyFunction = (...args: any[]) => any
|
|
4
|
+
|
|
5
|
+
export type AnyRecord = Record<string, any>
|
|
6
|
+
|
|
7
|
+
export type ReadOnly<T> = {
|
|
8
|
+
readonly [Property in keyof T]: T[Property];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type NestedKeys<T> = {
|
|
12
|
+
[K in keyof T]: T[K] extends Record<any, any> ? keyof T[K] : never;
|
|
13
|
+
}[keyof T]
|
|
14
|
+
|
|
15
|
+
export type FunctionType<Args extends any[], Return> = (
|
|
16
|
+
...args: Args
|
|
17
|
+
) => Return
|
|
18
|
+
|
|
19
|
+
export type DeepPartial<T> = Partial<{
|
|
20
|
+
[Property in keyof T]: T[Property] extends Record<string, any>
|
|
21
|
+
? T[Property] extends null|RegExp
|
|
22
|
+
? any
|
|
23
|
+
: DeepPartial<T[Property]>
|
|
24
|
+
: T[Property] extends null|RegExp
|
|
25
|
+
? any
|
|
26
|
+
: Partial<T[Property]>;
|
|
27
|
+
}>
|
|
28
|
+
|
|
29
|
+
type PrependNextNum<A extends Array<unknown>> = A['length'] extends infer T
|
|
30
|
+
? ((t: T, ...a: A) => void) extends (...x: infer X) => void
|
|
31
|
+
? X
|
|
32
|
+
: never
|
|
33
|
+
: never
|
|
34
|
+
|
|
35
|
+
type EnumerateInternal<A extends Array<unknown>, N extends number> = {
|
|
36
|
+
0: A
|
|
37
|
+
1: EnumerateInternal<PrependNextNum<A>, N>
|
|
38
|
+
}[N extends A['length'] ? 0 : 1]
|
|
39
|
+
|
|
40
|
+
export type Enumerate<N extends number> = EnumerateInternal<
|
|
41
|
+
[],
|
|
42
|
+
N
|
|
43
|
+
> extends (infer E)[]
|
|
44
|
+
? E
|
|
45
|
+
: never
|
|
46
|
+
|
|
47
|
+
export type Range<FROM extends number, TO extends number> = Exclude<
|
|
48
|
+
Enumerate<TO>,
|
|
49
|
+
Enumerate<FROM>
|
|
50
|
+
>
|
|
51
|
+
|
|
52
|
+
export type StylesOf<
|
|
53
|
+
C extends string | number | symbol = any,
|
|
54
|
+
CSS = any
|
|
55
|
+
> = Partial<Record<C, CSS>>
|
|
56
|
+
|
|
57
|
+
type IsDict<T> = T extends AnyFunction
|
|
58
|
+
? false
|
|
59
|
+
: T extends Record<string, any>
|
|
60
|
+
? true
|
|
61
|
+
: false
|
|
62
|
+
|
|
63
|
+
export type ReplaceRecursive<T, Replace, With, D extends number = 10> = [D] extends [never] ? never : {
|
|
64
|
+
[Property in keyof T]: T[Property] extends Replace
|
|
65
|
+
? With
|
|
66
|
+
: IsDict<T[Property]> extends true
|
|
67
|
+
? ReplaceRecursive<T[Property], Replace, With, Prev[D]>
|
|
68
|
+
: T[Property];
|
|
69
|
+
}
|
|
70
|
+
export type SmartOmit<T, K extends keyof T> = {
|
|
71
|
+
[Property in Exclude<keyof T, K>]: T[Property];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type PropsOf<T, Exclude extends string = ''> = T extends React.ComponentType<infer P> ? Omit<P, Exclude> : any
|
|
75
|
+
|
|
76
|
+
export type Hashmap<T> = {
|
|
77
|
+
[key: string]: T
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T
|
|
81
|
+
|
|
82
|
+
export type AsyncReturnType<T> = T extends (...args: any[]) => Promise<infer U> ? U : never
|
|
83
|
+
|
|
84
|
+
export type VariantsOf<T> =T extends ((props: {variants: infer V}) => any) ?
|
|
85
|
+
(V extends (string | string[]) ? V : (string[]))
|
|
86
|
+
|
|
87
|
+
: (string[])
|
|
88
|
+
|
|
89
|
+
export type VariantList<T> = Exclude<T, string>
|
|
90
|
+
|
|
91
|
+
export type GetRefType<T> = T extends React.Ref<infer U> ? U : never
|
|
92
|
+
|
|
93
|
+
export type FilterKeys<T, Filter = any> = Exclude<{
|
|
94
|
+
[P in keyof T]: T[P] extends Filter ? P : '__never__'
|
|
95
|
+
}[keyof T], '__never__'>
|
|
96
|
+
|
|
97
|
+
export type ReactState<T = any> = [
|
|
98
|
+
T,
|
|
99
|
+
React.Dispatch<React.SetStateAction<T>>
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
export type ReactStateProps<Name extends string, T = any, State extends ReactState<T> = ReactState<T>> = {
|
|
103
|
+
[P in Name as `set${Capitalize<Name>}`]: State[1]
|
|
104
|
+
} & {
|
|
105
|
+
[P in Name ]: State[0]
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type AnyRef<T> = React.Ref<T> | React.MutableRefObject<T> | ((instance: T | null) => void) | null | React.ForwardedRef<T> | React.LegacyRef<T>
|
|
109
|
+
|
|
110
|
+
export type Indices<T extends readonly any[]> = Exclude<Partial<T>['length'], T['length']>
|
|
111
|
+
|
|
112
|
+
export type Replace<Object, Keys extends keyof Object, With = any> = Omit<Object, Keys> & {
|
|
113
|
+
[P in Keys]: With
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type Matcher<T> = string | Partial<RegExp> | FunctionType<[valueOrKey: any, type: T], boolean>
|
|
117
|
+
|
|
118
|
+
export type LogType = 'info' | 'debug' | 'warn' | 'error' | 'log' | 'silent'
|