mui-fast-start 0.3.1 → 0.3.3
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/README.md +403 -403
- package/README_KR.md +403 -403
- package/dist/components/Object/Select/ObjSelectRecord.d.ts +2 -1
- package/dist/components/Object/Select/ObjSelectRecord.d.ts.map +1 -1
- package/dist/components/Single/Select/SingleSelectRecord.d.ts +2 -1
- package/dist/components/Single/Select/SingleSelectRecord.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/FastStartProps.d.ts +2 -1
- package/dist/styles/FastStartProps.d.ts.map +1 -1
- package/dist/types/props.d.ts +1 -1
- package/dist/types/props.d.ts.map +1 -1
- package/dist/types/props.internal.d.ts +1 -1
- package/dist/types/props.internal.d.ts.map +1 -1
- package/dist/types/provider.d.ts +2 -1
- package/dist/types/provider.d.ts.map +1 -1
- package/examples/basic/README.md +73 -73
- package/examples/basic/eslint.config.js +23 -23
- package/examples/basic/index.html +13 -13
- package/examples/basic/package.json +37 -37
- package/examples/basic/src/App.css +4 -4
- package/examples/basic/src/App.tsx +28 -28
- package/examples/basic/src/index.css +29 -29
- package/examples/basic/src/main.tsx +50 -50
- package/examples/basic/src/pages/ObjPage.tsx +175 -175
- package/examples/basic/src/pages/SinglePage.tsx +137 -137
- package/examples/basic/tsconfig.app.json +43 -43
- package/examples/basic/tsconfig.json +7 -7
- package/examples/basic/tsconfig.node.json +40 -40
- package/examples/basic/vite.config.ts +28 -28
- package/mui-fast-start-0.1.4.tgz +0 -0
- package/package.json +67 -67
- package/src/components/Object/Checkbox/ObjCheckIcon.tsx +29 -29
- package/src/components/Object/Checkbox/ObjCheckbox.tsx +31 -31
- package/src/components/Object/Select/ObjSelectOne.tsx +33 -33
- package/src/components/Object/Select/ObjSelectRecord.tsx +33 -33
- package/src/components/Object/Textfield/ObjNumber.tsx +51 -51
- package/src/components/Object/Textfield/ObjText.tsx +29 -29
- package/src/components/Single/Checkbox/SingleCheckIcon.tsx +27 -27
- package/src/components/Single/Checkbox/SingleCheckbox.tsx +33 -33
- package/src/components/Single/Select/BaseSingleSelect.tsx +45 -45
- package/src/components/Single/Select/SingleSelectOne.tsx +56 -56
- package/src/components/Single/Select/SingleSelectRecord.tsx +51 -51
- package/src/components/Single/TextField/SingleNumber.tsx +18 -18
- package/src/components/Single/TextField/SingleText.tsx +13 -13
- package/src/components/index.ts +15 -15
- package/src/hooks/index.ts +3 -3
- package/src/hooks/splits/useSplitNumberProps.ts +161 -161
- package/src/hooks/splits/useSplitTextProps.ts +36 -36
- package/src/hooks/state/useObjToSingle.ts +24 -24
- package/src/index.ts +7 -7
- package/src/styles/FastStartProps.ts +82 -81
- package/src/styles/FastStartProvider.tsx +25 -25
- package/src/types/index.ts +3 -3
- package/src/types/props.internal.ts +21 -21
- package/src/types/props.ts +81 -81
- package/src/types/provider.ts +72 -71
- package/src/types/types.ts +9 -9
- package/src/utils/index.ts +2 -2
- package/src/utils/number/calculate.ts +102 -102
- package/src/utils/object/error.ts +15 -15
- package/src/utils/object/merge.ts +47 -47
- package/tsconfig.json +34 -34
- package/tsconfig.lib.json +9 -9
- package/vite.config.ts +35 -35
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import type {TextFieldProps} from "@mui/material";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {fastDeepMerge} from "../../utils";
|
|
4
|
-
import {MfsSingleTextProps} from "../../types";
|
|
5
|
-
import {SingleTextProps} from "../../components/Single/TextField/SingleText.tsx";
|
|
6
|
-
|
|
7
|
-
const useSplitTextProps = (
|
|
8
|
-
defaultProps: Partial<MfsSingleTextProps> | undefined,
|
|
9
|
-
customProps: SingleTextProps
|
|
10
|
-
): TextFieldProps => {
|
|
11
|
-
const {
|
|
12
|
-
get, set, err,
|
|
13
|
-
minLength, maxLength,
|
|
14
|
-
startAdornment, endAdornment,
|
|
15
|
-
...props
|
|
16
|
-
} = defaultProps == null ? customProps : Object.assign({...defaultProps}, customProps);
|
|
17
|
-
|
|
18
|
-
const onChange = (
|
|
19
|
-
event: React.ChangeEvent<HTMLInputElement>
|
|
20
|
-
) => {
|
|
21
|
-
set(event.currentTarget.value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return fastDeepMerge<TextFieldProps>({
|
|
25
|
-
error: !!err,
|
|
26
|
-
helperText: err,
|
|
27
|
-
value: get,
|
|
28
|
-
onChange,
|
|
29
|
-
slotProps: {
|
|
30
|
-
htmlInput: {minLength, maxLength},
|
|
31
|
-
input: {startAdornment, endAdornment}
|
|
32
|
-
}
|
|
33
|
-
}, (props as TextFieldProps));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export default useSplitTextProps;
|
|
1
|
+
import type {TextFieldProps} from "@mui/material";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import {fastDeepMerge} from "../../utils";
|
|
4
|
+
import {MfsSingleTextProps} from "../../types";
|
|
5
|
+
import {SingleTextProps} from "../../components/Single/TextField/SingleText.tsx";
|
|
6
|
+
|
|
7
|
+
const useSplitTextProps = (
|
|
8
|
+
defaultProps: Partial<MfsSingleTextProps> | undefined,
|
|
9
|
+
customProps: SingleTextProps
|
|
10
|
+
): TextFieldProps => {
|
|
11
|
+
const {
|
|
12
|
+
get, set, err,
|
|
13
|
+
minLength, maxLength,
|
|
14
|
+
startAdornment, endAdornment,
|
|
15
|
+
...props
|
|
16
|
+
} = defaultProps == null ? customProps : Object.assign({...defaultProps}, customProps);
|
|
17
|
+
|
|
18
|
+
const onChange = (
|
|
19
|
+
event: React.ChangeEvent<HTMLInputElement>
|
|
20
|
+
) => {
|
|
21
|
+
set(event.currentTarget.value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return fastDeepMerge<TextFieldProps>({
|
|
25
|
+
error: !!err,
|
|
26
|
+
helperText: err,
|
|
27
|
+
value: get,
|
|
28
|
+
onChange,
|
|
29
|
+
slotProps: {
|
|
30
|
+
htmlInput: {minLength, maxLength},
|
|
31
|
+
input: {startAdornment, endAdornment}
|
|
32
|
+
}
|
|
33
|
+
}, (props as TextFieldProps));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default useSplitTextProps;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import type {Dispatch, SetStateAction} from "react";
|
|
2
|
-
import {useCallback} from "react";
|
|
3
|
-
import {MfsObjectKeys} from "../../types/props.internal.ts";
|
|
4
|
-
|
|
5
|
-
const useObjToSingle = <Type extends object, Target>(
|
|
6
|
-
name: MfsObjectKeys<Type, Target>,
|
|
7
|
-
get: Type,
|
|
8
|
-
set: Dispatch<SetStateAction<Type>>
|
|
9
|
-
): [Target, Dispatch<SetStateAction<Target>>] => {
|
|
10
|
-
const value: Target = (get as Record<string, Target>)?.[name as string];
|
|
11
|
-
|
|
12
|
-
const setValue: Dispatch<SetStateAction<Target>> = useCallback((action: SetStateAction<Target>) => {
|
|
13
|
-
set((state) => {
|
|
14
|
-
const newValue = typeof action === "function"
|
|
15
|
-
? (action as (prev: Target) => Target)((state as Record<string, Target>)?.[name as string])
|
|
16
|
-
: action;
|
|
17
|
-
return ({ ...state, [name]: newValue });
|
|
18
|
-
});
|
|
19
|
-
}, [name, set]);
|
|
20
|
-
|
|
21
|
-
return [value, setValue];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default useObjToSingle;
|
|
1
|
+
import type {Dispatch, SetStateAction} from "react";
|
|
2
|
+
import {useCallback} from "react";
|
|
3
|
+
import {MfsObjectKeys} from "../../types/props.internal.ts";
|
|
4
|
+
|
|
5
|
+
const useObjToSingle = <Type extends object, Target>(
|
|
6
|
+
name: MfsObjectKeys<Type, Target>,
|
|
7
|
+
get: Type,
|
|
8
|
+
set: Dispatch<SetStateAction<Type>>
|
|
9
|
+
): [Target, Dispatch<SetStateAction<Target>>] => {
|
|
10
|
+
const value: Target = (get as Record<string, Target>)?.[name as string];
|
|
11
|
+
|
|
12
|
+
const setValue: Dispatch<SetStateAction<Target>> = useCallback((action: SetStateAction<Target>) => {
|
|
13
|
+
set((state) => {
|
|
14
|
+
const newValue = typeof action === "function"
|
|
15
|
+
? (action as (prev: Target) => Target)((state as Record<string, Target>)?.[name as string])
|
|
16
|
+
: action;
|
|
17
|
+
return ({ ...state, [name]: newValue });
|
|
18
|
+
});
|
|
19
|
+
}, [name, set]);
|
|
20
|
+
|
|
21
|
+
return [value, setValue];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default useObjToSingle;
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
FastStartProvider,
|
|
3
|
-
FastStartContext
|
|
4
|
-
} from "./styles/FastStartProvider.tsx";
|
|
5
|
-
|
|
6
|
-
export * from "./components";
|
|
7
|
-
export * from "./types";
|
|
1
|
+
export {
|
|
2
|
+
FastStartProvider,
|
|
3
|
+
FastStartContext
|
|
4
|
+
} from "./styles/FastStartProvider.tsx";
|
|
5
|
+
|
|
6
|
+
export * from "./components";
|
|
7
|
+
export * from "./types";
|
|
@@ -1,82 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MfsObjectCheckboxProps,
|
|
3
|
-
MfsObjectCheckIconProps,
|
|
4
|
-
MfsObjectNumberProps, MfsObjectSelectOneProps, MfsObjectSelectRecordProps,
|
|
5
|
-
MfsObjectTextProps,
|
|
6
|
-
MfsSingleCheckboxProps,
|
|
7
|
-
MfsSingleCheckIconProps,
|
|
8
|
-
MfsSingleNumberProps,
|
|
9
|
-
MfsSingleSelectOneProps, MfsSingleSelectRecordProps,
|
|
10
|
-
MfsSingleTextProps
|
|
11
|
-
} from "../types";
|
|
12
|
-
import type {ThemeProviderProps} from "@mui/material";
|
|
13
|
-
import {fastDeepMerge} from "../utils";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
1
|
+
import {
|
|
2
|
+
MfsObjectCheckboxProps,
|
|
3
|
+
MfsObjectCheckIconProps,
|
|
4
|
+
MfsObjectNumberProps, MfsObjectSelectOneProps, MfsObjectSelectRecordProps,
|
|
5
|
+
MfsObjectTextProps,
|
|
6
|
+
MfsSingleCheckboxProps,
|
|
7
|
+
MfsSingleCheckIconProps,
|
|
8
|
+
MfsSingleNumberProps,
|
|
9
|
+
MfsSingleSelectOneProps, MfsSingleSelectRecordProps,
|
|
10
|
+
MfsSingleTextProps
|
|
11
|
+
} from "../types";
|
|
12
|
+
import type {ThemeProviderProps} from "@mui/material";
|
|
13
|
+
import {fastDeepMerge} from "../utils";
|
|
14
|
+
import React from "react";
|
|
15
|
+
|
|
16
|
+
interface FastStartProps {
|
|
17
|
+
Single: Partial<{
|
|
18
|
+
MfsFloat: Partial<MfsSingleNumberProps>,
|
|
19
|
+
MfsInteger: Partial<MfsSingleNumberProps>,
|
|
20
|
+
MfsText: Partial<MfsSingleTextProps>,
|
|
21
|
+
MfsCheckbox: Partial<MfsSingleCheckboxProps>,
|
|
22
|
+
MfsCheckIcon: Partial<MfsSingleCheckIconProps>,
|
|
23
|
+
MfsSelectOne: Partial<MfsSingleSelectOneProps<unknown>>,
|
|
24
|
+
MfsSelectRecord: Partial<MfsSingleSelectRecordProps<Record<string, unknown>>>
|
|
25
|
+
}>,
|
|
26
|
+
Object: Partial<{
|
|
27
|
+
MfsFloat: Partial<MfsObjectNumberProps<object>>,
|
|
28
|
+
MfsInteger: Partial<MfsObjectNumberProps<object>>,
|
|
29
|
+
MfsText: Partial<MfsObjectTextProps<object>>,
|
|
30
|
+
MfsCheckbox: Partial<MfsObjectCheckboxProps<object>>,
|
|
31
|
+
MfsCheckIcon: Partial<MfsObjectCheckIconProps<object>>,
|
|
32
|
+
MfsSelectOne: Partial<MfsObjectSelectOneProps<object, unknown>>,
|
|
33
|
+
MfsSelectRecord: Partial<MfsObjectSelectRecordProps<object, Record<string, React.ReactNode>>>
|
|
34
|
+
}>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const mfsDefaultProps: Partial<FastStartProps> = {
|
|
38
|
+
Single: {
|
|
39
|
+
MfsFloat: {
|
|
40
|
+
inputMode: 'decimal',
|
|
41
|
+
type: 'text',
|
|
42
|
+
step: 0.01,
|
|
43
|
+
def: 0
|
|
44
|
+
},
|
|
45
|
+
MfsInteger: {
|
|
46
|
+
inputMode: 'numeric',
|
|
47
|
+
type: 'text',
|
|
48
|
+
step: 1,
|
|
49
|
+
def: 0
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
Object: {
|
|
53
|
+
MfsFloat: {
|
|
54
|
+
inputMode: 'decimal',
|
|
55
|
+
type: 'text',
|
|
56
|
+
step: 0.01,
|
|
57
|
+
def: 0
|
|
58
|
+
},
|
|
59
|
+
MfsInteger: {
|
|
60
|
+
inputMode: 'numeric',
|
|
61
|
+
type: 'text',
|
|
62
|
+
step: 1,
|
|
63
|
+
def: 0
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const createMfsProps = (customProps: Partial<FastStartProps>) => {
|
|
69
|
+
return fastDeepMerge({...mfsDefaultProps}, customProps);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
interface FastStartProviderProps<Theme> extends ThemeProviderProps<Theme> {
|
|
73
|
+
defaultProps: Partial<FastStartProps>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
createMfsProps
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type {
|
|
81
|
+
FastStartProps,
|
|
82
|
+
FastStartProviderProps
|
|
82
83
|
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {createContext} from "react";
|
|
2
|
-
import {ThemeProvider} from "@mui/material";
|
|
3
|
-
import type {DefaultTheme} from "@mui/system";
|
|
4
|
-
import {createMfsProps, FastStartProps, FastStartProviderProps} from "./FastStartProps.ts";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const FastStartContext = createContext<Partial<FastStartProps>>(createMfsProps({}));
|
|
8
|
-
|
|
9
|
-
const FastStartProvider = <T = DefaultTheme>(props: FastStartProviderProps<T>) => {
|
|
10
|
-
const {
|
|
11
|
-
defaultProps,
|
|
12
|
-
...themeProps
|
|
13
|
-
} = props;
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<FastStartContext value={defaultProps}>
|
|
17
|
-
<ThemeProvider<T> {...themeProps}/>
|
|
18
|
-
</FastStartContext>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
FastStartContext,
|
|
24
|
-
FastStartProvider
|
|
25
|
-
}
|
|
1
|
+
import {createContext} from "react";
|
|
2
|
+
import {ThemeProvider} from "@mui/material";
|
|
3
|
+
import type {DefaultTheme} from "@mui/system";
|
|
4
|
+
import {createMfsProps, FastStartProps, FastStartProviderProps} from "./FastStartProps.ts";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const FastStartContext = createContext<Partial<FastStartProps>>(createMfsProps({}));
|
|
8
|
+
|
|
9
|
+
const FastStartProvider = <T = DefaultTheme>(props: FastStartProviderProps<T>) => {
|
|
10
|
+
const {
|
|
11
|
+
defaultProps,
|
|
12
|
+
...themeProps
|
|
13
|
+
} = props;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<FastStartContext value={defaultProps}>
|
|
17
|
+
<ThemeProvider<T> {...themeProps}/>
|
|
18
|
+
</FastStartContext>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
FastStartContext,
|
|
24
|
+
FastStartProvider
|
|
25
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './props';
|
|
2
|
-
export * from './types';
|
|
3
|
-
export * from './provider';
|
|
1
|
+
export * from './props';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './provider';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
// internal types
|
|
2
|
-
// Do not export index.ts
|
|
3
|
-
|
|
4
|
-
import React from "react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export type KeysWithValue<Type extends object, Target = unknown> = {
|
|
8
|
-
[K in keyof Type]: Type[K] extends Target ? K : never
|
|
9
|
-
}[keyof Type];
|
|
10
|
-
|
|
11
|
-
export type MfsObjectKeys<Type extends object, Target = unknown> =
|
|
12
|
-
KeysWithValue<Type, Target>;
|
|
13
|
-
|
|
14
|
-
export type MfsSelectEmpty<I> = {
|
|
15
|
-
emptyItem?: React.ReactNode;
|
|
16
|
-
emptyValue?: '' | null | undefined | I;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type MfsSingleError = React.ReactNode;
|
|
20
|
-
export type MfsObjectError<Type extends object, Target = unknown> =
|
|
21
|
-
Partial<Record<MfsObjectKeys<Type, Target>, React.ReactNode>>;
|
|
1
|
+
// internal types
|
|
2
|
+
// Do not export index.ts
|
|
3
|
+
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export type KeysWithValue<Type extends object, Target = unknown> = {
|
|
8
|
+
[K in keyof Type]: Type[K] extends Target ? K : never
|
|
9
|
+
}[keyof Type];
|
|
10
|
+
|
|
11
|
+
export type MfsObjectKeys<Type extends object, Target = unknown> =
|
|
12
|
+
keyof Type | KeysWithValue<Type, Target>;
|
|
13
|
+
|
|
14
|
+
export type MfsSelectEmpty<I> = {
|
|
15
|
+
emptyItem?: React.ReactNode;
|
|
16
|
+
emptyValue?: '' | null | undefined | I;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type MfsSingleError = React.ReactNode;
|
|
20
|
+
export type MfsObjectError<Type extends object, Target = unknown> =
|
|
21
|
+
Partial<Record<MfsObjectKeys<Type, Target>, React.ReactNode>>;
|
package/src/types/props.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import {Dispatch, HTMLAttributes, SetStateAction} from "react";
|
|
3
|
-
import {MfsObjectKeys, MfsSelectEmpty} from "./props.internal.ts";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type KeysWithValue<Type extends object, Target> = {
|
|
7
|
-
[K in keyof Type]: Type[K] extends Target ? K : never
|
|
8
|
-
}[keyof Type];
|
|
9
|
-
|
|
10
|
-
export interface MfsPropertyProps<Type> {
|
|
11
|
-
get: Type;
|
|
12
|
-
set: Dispatch<SetStateAction<Type>>;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface MfsObjectProps<Type extends object, Target> {
|
|
16
|
-
name: MfsObjectKeys<Type, Target>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// props : property + label
|
|
20
|
-
export interface MfsLabelProps<Type> extends MfsPropertyProps<Type> {
|
|
21
|
-
label?: React.ReactNode;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// props : property + label + error
|
|
25
|
-
export interface MfsErrorProps<Type, Error> extends MfsLabelProps<Type> {
|
|
26
|
-
err?: Error;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// ==================================================
|
|
30
|
-
// Component props
|
|
31
|
-
// ==================================================
|
|
32
|
-
export interface MfsTextProps {
|
|
33
|
-
minLength?: number;
|
|
34
|
-
maxLength?: number;
|
|
35
|
-
startAdornment?: React.ReactNode;
|
|
36
|
-
endAdornment?: React.ReactNode;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface MfsNumberProps extends MfsTextProps {
|
|
40
|
-
inputMode?: HTMLAttributes<unknown>["inputMode"];
|
|
41
|
-
type?: React.InputHTMLAttributes<unknown>['type'];
|
|
42
|
-
def?: number | null | undefined;
|
|
43
|
-
min?: number;
|
|
44
|
-
max?: number;
|
|
45
|
-
step?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface MfsCheckIconProps {
|
|
49
|
-
on: React.ReactNode;
|
|
50
|
-
off: React.ReactNode;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type MfsSelectOneProps<I> = {
|
|
54
|
-
items: I[];
|
|
55
|
-
renderMenuItem?: (item: I, i: number) => React.ReactNode;
|
|
56
|
-
} & MfsSelectEmpty<I> & ([NonNullable<I>] extends [string | number]
|
|
57
|
-
? { getKey?: (item: I) => string | number }
|
|
58
|
-
: { getKey: (item: I) => string | number });
|
|
59
|
-
|
|
60
|
-
export type MfsSelectRecordProps<Item extends Record<PropertyKey, unknown>> = {
|
|
61
|
-
items: Item;
|
|
62
|
-
renderMenuItem?: (key: keyof Item, value: Item[keyof Item], i: number) => React.ReactNode;
|
|
63
|
-
} & MfsSelectEmpty<Item>;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
interface BaseProps<Type, Error> {
|
|
67
|
-
get: Type;
|
|
68
|
-
set: Dispatch<SetStateAction<Type>>;
|
|
69
|
-
label?: React.ReactNode;
|
|
70
|
-
err?: Error;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface BaseObjectProps<Type extends object, Target>
|
|
74
|
-
extends BaseProps<Type, Partial<Type> | object> {
|
|
75
|
-
name: KeysWithValue<Type, Target> | string;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export type {
|
|
79
|
-
KeysWithValue,
|
|
80
|
-
BaseObjectProps,
|
|
81
|
-
}
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {Dispatch, HTMLAttributes, SetStateAction} from "react";
|
|
3
|
+
import {MfsObjectKeys, MfsSelectEmpty} from "./props.internal.ts";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
type KeysWithValue<Type extends object, Target> = {
|
|
7
|
+
[K in keyof Type]: Type[K] extends Target ? K : never
|
|
8
|
+
}[keyof Type];
|
|
9
|
+
|
|
10
|
+
export interface MfsPropertyProps<Type> {
|
|
11
|
+
get: Type;
|
|
12
|
+
set: Dispatch<SetStateAction<Type>>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface MfsObjectProps<Type extends object, Target> {
|
|
16
|
+
name: MfsObjectKeys<Type, Target>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// props : property + label
|
|
20
|
+
export interface MfsLabelProps<Type> extends MfsPropertyProps<Type> {
|
|
21
|
+
label?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// props : property + label + error
|
|
25
|
+
export interface MfsErrorProps<Type, Error> extends MfsLabelProps<Type> {
|
|
26
|
+
err?: Error;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ==================================================
|
|
30
|
+
// Component props
|
|
31
|
+
// ==================================================
|
|
32
|
+
export interface MfsTextProps {
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
startAdornment?: React.ReactNode;
|
|
36
|
+
endAdornment?: React.ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface MfsNumberProps extends MfsTextProps {
|
|
40
|
+
inputMode?: HTMLAttributes<unknown>["inputMode"];
|
|
41
|
+
type?: React.InputHTMLAttributes<unknown>['type'];
|
|
42
|
+
def?: number | null | undefined;
|
|
43
|
+
min?: number;
|
|
44
|
+
max?: number;
|
|
45
|
+
step?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface MfsCheckIconProps {
|
|
49
|
+
on: React.ReactNode;
|
|
50
|
+
off: React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type MfsSelectOneProps<I> = {
|
|
54
|
+
items: I[];
|
|
55
|
+
renderMenuItem?: (item: I, i: number) => React.ReactNode;
|
|
56
|
+
} & MfsSelectEmpty<I> & ([NonNullable<I>] extends [string | number]
|
|
57
|
+
? { getKey?: (item: I) => string | number }
|
|
58
|
+
: { getKey: (item: I) => string | number });
|
|
59
|
+
|
|
60
|
+
export type MfsSelectRecordProps<Item extends Record<PropertyKey, React.ReactNode | unknown>> = {
|
|
61
|
+
items: Item;
|
|
62
|
+
renderMenuItem?: (key: keyof Item, value: Item[keyof Item], i: number) => React.ReactNode;
|
|
63
|
+
} & MfsSelectEmpty<Item>;
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
interface BaseProps<Type, Error> {
|
|
67
|
+
get: Type;
|
|
68
|
+
set: Dispatch<SetStateAction<Type>>;
|
|
69
|
+
label?: React.ReactNode;
|
|
70
|
+
err?: Error;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface BaseObjectProps<Type extends object, Target>
|
|
74
|
+
extends BaseProps<Type, Partial<Type> | object> {
|
|
75
|
+
name: KeysWithValue<Type, Target> | string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type {
|
|
79
|
+
KeysWithValue,
|
|
80
|
+
BaseObjectProps,
|
|
81
|
+
}
|