mui-fast-start 0.2.0 → 0.3.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/README.md +76 -29
- package/README_KR.md +176 -127
- package/dist/components/Object/Checkbox/ObjCheckIcon.d.ts +4 -0
- package/dist/components/Object/Checkbox/ObjCheckIcon.d.ts.map +1 -0
- package/dist/components/Object/Checkbox/ObjCheckbox.d.ts +4 -0
- package/dist/components/Object/Checkbox/ObjCheckbox.d.ts.map +1 -0
- package/dist/components/Object/Select/ObjSelectOne.d.ts +4 -0
- package/dist/components/Object/Select/ObjSelectOne.d.ts.map +1 -0
- package/dist/components/Object/Select/ObjSelectRecord.d.ts +4 -0
- package/dist/components/Object/Select/ObjSelectRecord.d.ts.map +1 -0
- package/dist/components/Object/Textfield/ObjNumber.d.ts +7 -0
- package/dist/components/Object/Textfield/ObjNumber.d.ts.map +1 -0
- package/dist/components/Object/Textfield/ObjText.d.ts +4 -0
- package/dist/components/Object/Textfield/ObjText.d.ts.map +1 -0
- package/dist/components/Single/Checkbox/SingleCheckIcon.d.ts +3 -1
- package/dist/components/Single/Checkbox/SingleCheckIcon.d.ts.map +1 -1
- package/dist/components/Single/Checkbox/SingleCheckbox.d.ts +3 -1
- package/dist/components/Single/Checkbox/SingleCheckbox.d.ts.map +1 -1
- package/dist/components/Single/Select/BaseSingleSelect.d.ts +14 -0
- package/dist/components/Single/Select/BaseSingleSelect.d.ts.map +1 -0
- package/dist/components/Single/Select/SingleSelectOne.d.ts +5 -0
- package/dist/components/Single/Select/SingleSelectOne.d.ts.map +1 -0
- package/dist/components/Single/Select/SingleSelectRecord.d.ts +4 -0
- package/dist/components/Single/Select/SingleSelectRecord.d.ts.map +1 -0
- package/dist/components/Single/TextField/SingleNumber.d.ts +6 -0
- package/dist/components/Single/TextField/SingleNumber.d.ts.map +1 -0
- package/dist/components/Single/TextField/SingleText.d.ts +3 -1
- package/dist/components/Single/TextField/SingleText.d.ts.map +1 -1
- package/dist/components/index.d.ts +12 -10
- package/dist/components/index.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/splits/useSplitNumberProps.d.ts +7 -0
- package/dist/hooks/splits/useSplitNumberProps.d.ts.map +1 -0
- package/dist/hooks/splits/useSplitTextProps.d.ts +6 -0
- package/dist/hooks/splits/useSplitTextProps.d.ts.map +1 -0
- package/dist/hooks/state/useObjToSingle.d.ts +2 -2
- package/dist/hooks/state/useObjToSingle.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +310 -235
- package/dist/styles/FastStartProps.d.ts +29 -0
- package/dist/styles/FastStartProps.d.ts.map +1 -0
- package/dist/styles/FastStartProvider.d.ts +2 -17
- package/dist/styles/FastStartProvider.d.ts.map +1 -1
- package/dist/types/props.d.ts +38 -23
- package/dist/types/props.d.ts.map +1 -1
- package/dist/types/props.internal.d.ts +12 -0
- package/dist/types/props.internal.d.ts.map +1 -0
- package/dist/types/provider.d.ts +20 -30
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/utils/object/error.d.ts +3 -2
- package/dist/utils/object/error.d.ts.map +1 -1
- package/examples/basic/src/main.tsx +26 -33
- package/examples/basic/src/pages/ObjPage.tsx +92 -9
- package/examples/basic/src/pages/SinglePage.tsx +69 -2
- package/examples/basic/tsconfig.app.json +5 -0
- package/examples/basic/tsconfig.node.json +5 -0
- package/examples/basic/vite.config.ts +1 -1
- package/package.json +1 -1
- package/src/components/Object/Checkbox/ObjCheckIcon.tsx +29 -0
- package/src/components/Object/Checkbox/ObjCheckbox.tsx +31 -0
- package/src/components/Object/Select/ObjSelectOne.tsx +34 -0
- package/src/components/Object/Select/ObjSelectRecord.tsx +34 -0
- package/src/components/Object/Textfield/ObjNumber.tsx +51 -0
- package/src/components/Object/Textfield/ObjText.tsx +29 -0
- package/src/components/Single/Checkbox/SingleCheckIcon.tsx +7 -5
- package/src/components/Single/Checkbox/SingleCheckbox.tsx +7 -5
- package/src/components/Single/Select/BaseSingleSelect.tsx +46 -0
- package/src/components/Single/Select/SingleSelectOne.tsx +56 -0
- package/src/components/Single/Select/SingleSelectRecord.tsx +52 -0
- package/src/components/Single/TextField/SingleNumber.tsx +19 -0
- package/src/components/Single/TextField/SingleText.tsx +6 -5
- package/src/components/index.ts +14 -12
- package/src/hooks/index.ts +2 -2
- package/src/hooks/splits/{useSplitSingleNumberProps.ts → useSplitNumberProps.ts} +58 -56
- package/src/hooks/splits/useSplitTextProps.ts +36 -0
- package/src/hooks/state/useObjToSingle.ts +3 -2
- package/src/index.ts +0 -1
- package/src/styles/FastStartProps.ts +82 -0
- package/src/styles/FastStartProvider.tsx +2 -3
- package/src/types/props.internal.ts +21 -0
- package/src/types/props.ts +47 -33
- package/src/types/provider.ts +70 -45
- package/src/utils/number/calculate.ts +2 -2
- package/src/utils/object/error.ts +5 -4
- package/dist/components/Obj/Checkbox/ObjCheckIcon.d.ts +0 -3
- package/dist/components/Obj/Checkbox/ObjCheckIcon.d.ts.map +0 -1
- package/dist/components/Obj/Checkbox/ObjCheckbox.d.ts +0 -3
- package/dist/components/Obj/Checkbox/ObjCheckbox.d.ts.map +0 -1
- package/dist/components/Obj/Textfield/ObjFloat.d.ts +0 -3
- package/dist/components/Obj/Textfield/ObjFloat.d.ts.map +0 -1
- package/dist/components/Obj/Textfield/ObjInteger.d.ts +0 -3
- package/dist/components/Obj/Textfield/ObjInteger.d.ts.map +0 -1
- package/dist/components/Obj/Textfield/ObjText.d.ts +0 -3
- package/dist/components/Obj/Textfield/ObjText.d.ts.map +0 -1
- package/dist/components/Single/TextField/SingleFloat.d.ts +0 -3
- package/dist/components/Single/TextField/SingleFloat.d.ts.map +0 -1
- package/dist/components/Single/TextField/SingleInteger.d.ts +0 -3
- package/dist/components/Single/TextField/SingleInteger.d.ts.map +0 -1
- package/dist/hooks/splits/useSplitSingleNumberProps.d.ts +0 -6
- package/dist/hooks/splits/useSplitSingleNumberProps.d.ts.map +0 -1
- package/dist/hooks/splits/useSplitSingleTextProps.d.ts +0 -5
- package/dist/hooks/splits/useSplitSingleTextProps.d.ts.map +0 -1
- package/dist/styles/createDefaultProps.d.ts +0 -3
- package/dist/styles/createDefaultProps.d.ts.map +0 -1
- package/mui-fast-start-0.1.5.tgz +0 -0
- package/src/components/Obj/Checkbox/ObjCheckIcon.tsx +0 -19
- package/src/components/Obj/Checkbox/ObjCheckbox.tsx +0 -19
- package/src/components/Obj/Textfield/ObjFloat.tsx +0 -22
- package/src/components/Obj/Textfield/ObjInteger.tsx +0 -22
- package/src/components/Obj/Textfield/ObjText.tsx +0 -22
- package/src/components/Single/TextField/SingleFloat.tsx +0 -12
- package/src/components/Single/TextField/SingleInteger.tsx +0 -12
- package/src/hooks/splits/useSplitSingleTextProps.ts +0 -36
- package/src/styles/createDefaultProps.ts +0 -45
- package/src.zip +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type {Dispatch, SetStateAction} from "react";
|
|
2
2
|
import {useCallback} from "react";
|
|
3
|
-
import {
|
|
3
|
+
import {MfsObjectKeys} from "../../types/props.internal.ts";
|
|
4
4
|
|
|
5
5
|
const useObjToSingle = <Type extends object, Target>(
|
|
6
|
-
name:
|
|
6
|
+
name: MfsObjectKeys<Type, Target>,
|
|
7
7
|
get: Type,
|
|
8
8
|
set: Dispatch<SetStateAction<Type>>
|
|
9
9
|
): [Target, Dispatch<SetStateAction<Target>>] => {
|
|
@@ -17,6 +17,7 @@ const useObjToSingle = <Type extends object, Target>(
|
|
|
17
17
|
return ({ ...state, [name]: newValue });
|
|
18
18
|
});
|
|
19
19
|
}, [name, set]);
|
|
20
|
+
|
|
20
21
|
return [value, setValue];
|
|
21
22
|
}
|
|
22
23
|
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
interface FastStartProps {
|
|
16
|
+
Single: Partial<{
|
|
17
|
+
MfsFloat: Partial<MfsSingleNumberProps>,
|
|
18
|
+
MfsInteger: Partial<MfsSingleNumberProps>,
|
|
19
|
+
MfsText: Partial<MfsSingleTextProps>,
|
|
20
|
+
MfsCheckbox: Partial<MfsSingleCheckboxProps>,
|
|
21
|
+
MfsCheckIcon: Partial<MfsSingleCheckIconProps>,
|
|
22
|
+
MfsSelectOne: Partial<MfsSingleSelectOneProps<unknown>>,
|
|
23
|
+
MfsSelectRecord: Partial<MfsSingleSelectRecordProps<Record<string, unknown>>>
|
|
24
|
+
}>,
|
|
25
|
+
Object: Partial<{
|
|
26
|
+
MfsFloat: Partial<MfsObjectNumberProps<object>>,
|
|
27
|
+
MfsInteger: Partial<MfsObjectNumberProps<object>>,
|
|
28
|
+
MfsText: Partial<MfsObjectTextProps<object>>,
|
|
29
|
+
MfsCheckbox: Partial<MfsObjectCheckboxProps<object>>,
|
|
30
|
+
MfsCheckIcon: Partial<MfsObjectCheckIconProps<object>>,
|
|
31
|
+
MfsSelectOne: Partial<MfsObjectSelectOneProps<object, unknown>>,
|
|
32
|
+
MfsSelectRecord: Partial<MfsObjectSelectRecordProps<object, Record<string, unknown>>>
|
|
33
|
+
}>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const mfsDefaultProps: Partial<FastStartProps> = {
|
|
37
|
+
Single: {
|
|
38
|
+
MfsFloat: {
|
|
39
|
+
inputMode: 'decimal',
|
|
40
|
+
type: 'text',
|
|
41
|
+
step: 0.01,
|
|
42
|
+
def: 0
|
|
43
|
+
},
|
|
44
|
+
MfsInteger: {
|
|
45
|
+
inputMode: 'numeric',
|
|
46
|
+
type: 'text',
|
|
47
|
+
step: 1,
|
|
48
|
+
def: 0
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
Object: {
|
|
52
|
+
MfsFloat: {
|
|
53
|
+
inputMode: 'decimal',
|
|
54
|
+
type: 'text',
|
|
55
|
+
step: 0.01,
|
|
56
|
+
def: 0
|
|
57
|
+
},
|
|
58
|
+
MfsInteger: {
|
|
59
|
+
inputMode: 'numeric',
|
|
60
|
+
type: 'text',
|
|
61
|
+
step: 1,
|
|
62
|
+
def: 0
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const createMfsProps = (customProps: Partial<FastStartProps>) => {
|
|
68
|
+
return fastDeepMerge({...mfsDefaultProps}, customProps);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface FastStartProviderProps<Theme> extends ThemeProviderProps<Theme> {
|
|
72
|
+
defaultProps: Partial<FastStartProps>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export {
|
|
76
|
+
createMfsProps
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type {
|
|
80
|
+
FastStartProps,
|
|
81
|
+
FastStartProviderProps
|
|
82
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import {createContext} from "react";
|
|
2
2
|
import {ThemeProvider} from "@mui/material";
|
|
3
3
|
import type {DefaultTheme} from "@mui/system";
|
|
4
|
-
import {
|
|
5
|
-
import {FastStartDefaultProps, FastStartProviderProps} from "../types";
|
|
4
|
+
import {createMfsProps, FastStartProps, FastStartProviderProps} from "./FastStartProps.ts";
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
const FastStartContext = createContext<
|
|
7
|
+
const FastStartContext = createContext<Partial<FastStartProps>>(createMfsProps({}));
|
|
9
8
|
|
|
10
9
|
const FastStartProvider = <T = DefaultTheme>(props: FastStartProviderProps<T>) => {
|
|
11
10
|
const {
|
|
@@ -0,0 +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>>;
|
package/src/types/props.ts
CHANGED
|
@@ -1,67 +1,81 @@
|
|
|
1
|
-
import type {SlotProps, TextFieldOwnerState} from "@mui/material";
|
|
2
|
-
import type {Dispatch, SetStateAction} from "react";
|
|
3
1
|
import * as React from "react";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import {Dispatch, HTMLAttributes, SetStateAction} from "react";
|
|
3
|
+
import {MfsObjectKeys, MfsSelectEmpty} from "./props.internal.ts";
|
|
4
|
+
|
|
6
5
|
|
|
7
|
-
type HtmlInputType = SlotProps<React.ElementType<InputBaseProps['inputProps']>, {}, TextFieldOwnerState>;
|
|
8
|
-
type InputLabelType = SlotProps<React.ElementType<InputLabelProps>, {}, TextFieldOwnerState>;
|
|
9
6
|
type KeysWithValue<Type extends object, Target> = {
|
|
10
7
|
[K in keyof Type]: Type[K] extends Target ? K : never
|
|
11
8
|
}[keyof Type];
|
|
12
9
|
|
|
13
|
-
interface
|
|
10
|
+
export interface MfsPropertyProps<Type> {
|
|
14
11
|
get: Type;
|
|
15
12
|
set: Dispatch<SetStateAction<Type>>;
|
|
16
|
-
label?: React.ReactNode;
|
|
17
|
-
errorData?: Error;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
export interface MfsObjectProps<Type extends object, Target> {
|
|
16
|
+
name: MfsObjectKeys<Type, Target>;
|
|
17
|
+
}
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
// props : property + label
|
|
20
|
+
export interface MfsLabelProps<Type> extends MfsPropertyProps<Type> {
|
|
21
|
+
label?: React.ReactNode;
|
|
25
22
|
}
|
|
26
23
|
|
|
24
|
+
// props : property + label + error
|
|
25
|
+
export interface MfsErrorProps<Type, Error> extends MfsLabelProps<Type> {
|
|
26
|
+
err?: Error;
|
|
27
|
+
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// ==================================================
|
|
30
|
+
// Component props
|
|
31
|
+
// ==================================================
|
|
32
|
+
export interface MfsTextProps {
|
|
29
33
|
minLength?: number;
|
|
30
34
|
maxLength?: number;
|
|
31
35
|
startAdornment?: React.ReactNode;
|
|
32
36
|
endAdornment?: React.ReactNode;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
interface
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
interface BaseNumberProps extends BaseTextProps {
|
|
41
|
-
disappear?: boolean;
|
|
42
|
-
def?: number;
|
|
39
|
+
export interface MfsNumberProps extends MfsTextProps {
|
|
40
|
+
inputMode?: HTMLAttributes<unknown>["inputMode"];
|
|
41
|
+
type?: React.InputHTMLAttributes<unknown>['type'];
|
|
42
|
+
def?: number | null | undefined;
|
|
43
43
|
min?: number;
|
|
44
44
|
max?: number;
|
|
45
45
|
step?: number;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
export interface MfsCheckIconProps {
|
|
49
|
+
on: React.ReactNode;
|
|
50
|
+
off: React.ReactNode;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
export type MfsSelectOneProps<I> = {
|
|
54
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;
|
|
55
76
|
}
|
|
56
77
|
|
|
57
78
|
export type {
|
|
58
79
|
KeysWithValue,
|
|
59
|
-
HtmlInputType,
|
|
60
|
-
InputLabelType,
|
|
61
|
-
BasePropertyProps,
|
|
62
80
|
BaseObjectProps,
|
|
63
|
-
BaseTextProps,
|
|
64
|
-
BaseCheckIconProps,
|
|
65
|
-
BaseNumberProps,
|
|
66
|
-
BaseSelectItemProps
|
|
67
81
|
}
|
package/src/types/provider.ts
CHANGED
|
@@ -1,47 +1,72 @@
|
|
|
1
|
-
import type {CheckboxProps, IconButtonProps, SelectProps, TextFieldProps, ThemeProviderProps} from "@mui/material";
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
MfsCheckIconProps,
|
|
3
|
+
MfsErrorProps,
|
|
4
|
+
MfsLabelProps,
|
|
5
|
+
MfsNumberProps,
|
|
6
|
+
MfsObjectProps,
|
|
7
|
+
MfsPropertyProps,
|
|
8
|
+
MfsSelectOneProps,
|
|
9
|
+
MfsSelectRecordProps,
|
|
10
|
+
MfsTextProps
|
|
9
11
|
} from './props';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
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
|
-
|
|
12
|
+
import {MfsObjectError, MfsSingleError} from "./props.internal.ts";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// Single
|
|
16
|
+
export interface MfsSingleNumberProps extends
|
|
17
|
+
MfsNumberProps,
|
|
18
|
+
MfsErrorProps<number, MfsSingleError> {}
|
|
19
|
+
|
|
20
|
+
export interface MfsSingleTextProps extends
|
|
21
|
+
MfsTextProps,
|
|
22
|
+
MfsErrorProps<string, MfsSingleError> {}
|
|
23
|
+
|
|
24
|
+
export type MfsSingleCheckboxProps =
|
|
25
|
+
MfsLabelProps<boolean>;
|
|
26
|
+
|
|
27
|
+
export interface MfsSingleCheckIconProps extends
|
|
28
|
+
MfsCheckIconProps,
|
|
29
|
+
MfsPropertyProps<boolean> {}
|
|
30
|
+
|
|
31
|
+
export type MfsSingleSelectOneProps<Item> =
|
|
32
|
+
MfsSelectOneProps<Item>
|
|
33
|
+
& MfsErrorProps<Item, MfsSingleError>;
|
|
34
|
+
|
|
35
|
+
export type MfsSingleSelectRecordProps<
|
|
36
|
+
Item extends Record<PropertyKey, unknown>,
|
|
37
|
+
Value = keyof Item | undefined | null
|
|
38
|
+
> = MfsSelectRecordProps<Item>
|
|
39
|
+
& MfsErrorProps<Value, MfsSingleError>;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// Object
|
|
43
|
+
export interface MfsObjectNumberProps<T extends object> extends
|
|
44
|
+
MfsObjectProps<T, number>,
|
|
45
|
+
MfsNumberProps,
|
|
46
|
+
MfsErrorProps<T, MfsObjectError<T, number>> {}
|
|
47
|
+
|
|
48
|
+
export interface MfsObjectTextProps<T extends object> extends
|
|
49
|
+
MfsObjectProps<T, string>,
|
|
50
|
+
MfsTextProps,
|
|
51
|
+
MfsErrorProps<T, MfsObjectError<T, string>> {}
|
|
52
|
+
|
|
53
|
+
export interface MfsObjectCheckboxProps<T extends object> extends
|
|
54
|
+
MfsObjectProps<T, boolean>,
|
|
55
|
+
MfsLabelProps<T> {}
|
|
56
|
+
|
|
57
|
+
export interface MfsObjectCheckIconProps<T extends object> extends
|
|
58
|
+
MfsObjectProps<T, boolean>,
|
|
59
|
+
MfsPropertyProps<T>,
|
|
60
|
+
MfsCheckIconProps {}
|
|
61
|
+
|
|
62
|
+
export type MfsObjectSelectOneProps<T extends object, Item> =
|
|
63
|
+
MfsObjectProps<T, Item>
|
|
64
|
+
& MfsSelectOneProps<Item>
|
|
65
|
+
& MfsErrorProps<T, MfsObjectError<T, Item>>;
|
|
66
|
+
|
|
67
|
+
export type MfsObjectSelectRecordProps<
|
|
68
|
+
T extends object,
|
|
69
|
+
Item extends Record<PropertyKey, unknown>
|
|
70
|
+
> = MfsObjectProps<T, Item>
|
|
71
|
+
& MfsSelectRecordProps<Item>
|
|
72
|
+
& MfsErrorProps<T, MfsObjectError<T, Item>>;
|
|
@@ -21,7 +21,7 @@ const floatCalculate = (
|
|
|
21
21
|
|
|
22
22
|
if (calc != null) {
|
|
23
23
|
if (max != null) calc = Math.min(max, calc);
|
|
24
|
-
if (min != null) calc = Math.
|
|
24
|
+
if (min != null) calc = Math.max(min, calc);
|
|
25
25
|
}
|
|
26
26
|
return calc;
|
|
27
27
|
}
|
|
@@ -45,7 +45,7 @@ const integerCalculate = (
|
|
|
45
45
|
|
|
46
46
|
if (calc != null) {
|
|
47
47
|
if (max != null) calc = Math.min(max, calc);
|
|
48
|
-
if (min != null) calc = Math.
|
|
48
|
+
if (min != null) calc = Math.max(min, calc);
|
|
49
49
|
}
|
|
50
50
|
return calc;
|
|
51
51
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {MfsErrorProps, MfsObjectProps} from "../../types";
|
|
2
|
+
import {MfsObjectError} from "../../types/props.internal.ts";
|
|
2
3
|
|
|
3
|
-
function errorObjectToString<Type extends object, Target>(
|
|
4
|
-
name:
|
|
5
|
-
data:
|
|
4
|
+
function errorObjectToString<Type extends object, Target = unknown>(
|
|
5
|
+
name: MfsObjectProps<Type, Target>['name'],
|
|
6
|
+
data: MfsErrorProps<Type, MfsObjectError<Type, Target>>['err']
|
|
6
7
|
): string | undefined {
|
|
7
8
|
return (name != null && typeof data === 'object')
|
|
8
9
|
? (data as Record<string, string>)[name as string]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjCheckIcon.d.ts","sourceRoot":"","sources":["../../../../src/components/Obj/Checkbox/ObjCheckIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,iBAAiB,EAAuB,MAAM,gBAAgB,CAAC;AAMpF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,iBAAiB,CAAC,CAAC,CAAC,4CAW/E,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjCheckbox.d.ts","sourceRoot":"","sources":["../../../../src/components/Obj/Checkbox/ObjCheckbox.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAc,gBAAgB,EAAsB,MAAM,gBAAgB,CAAC;AAIlF,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,gBAAgB,CAAC,CAAC,CAAC,4CAW7E,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjFloat.d.ts","sourceRoot":"","sources":["../../../../src/components/Obj/Textfield/ObjFloat.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAoB,MAAM,gBAAgB,CAAC;AAQ9E,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,cAAc,CAAC,CAAC,CAAC,4CAYxE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjInteger.d.ts","sourceRoot":"","sources":["../../../../src/components/Obj/Textfield/ObjInteger.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,cAAc,EAAoB,MAAM,gBAAgB,CAAC;AAQ9E,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,cAAc,CAAC,CAAC,CAAC,4CAY1E,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ObjText.d.ts","sourceRoot":"","sources":["../../../../src/components/Obj/Textfield/ObjText.tsx"],"names":[],"mappings":"AACA,OAAO,EAAc,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AAQ1E,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,MAAM,EAAE,aAAa,YAAY,CAAC,CAAC,CAAC,4CAYrE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingleFloat.d.ts","sourceRoot":"","sources":["../../../../src/components/Single/TextField/SingleFloat.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,WAAW,GAAI,aAAa,iBAAiB,4CAIzD,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SingleInteger.d.ts","sourceRoot":"","sources":["../../../../src/components/Single/TextField/SingleInteger.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAIjD,eAAO,MAAM,aAAa,GAAI,aAAa,iBAAiB,4CAI3D,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { TextFieldProps } from "@mui/material";
|
|
2
|
-
import { SingleNumberProps } from "../../types";
|
|
3
|
-
declare const useSplitSingleFloatProps: (defaultProps: SingleNumberProps, customProps: SingleNumberProps) => TextFieldProps;
|
|
4
|
-
declare const useSplitSingleIntegerProps: (defaultProps: SingleNumberProps, customProps: SingleNumberProps) => TextFieldProps;
|
|
5
|
-
export { useSplitSingleFloatProps, useSplitSingleIntegerProps };
|
|
6
|
-
//# sourceMappingURL=useSplitSingleNumberProps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSplitSingleNumberProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/splits/useSplitSingleNumberProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAGlD,OAAO,EAAiB,iBAAiB,EAAC,MAAM,aAAa,CAAC;AAuI9D,QAAA,MAAM,wBAAwB,GAC1B,cAAc,iBAAiB,EAC/B,aAAa,iBAAiB,KAC/B,cAGF,CAAC;AAEF,QAAA,MAAM,0BAA0B,GAC5B,cAAc,iBAAiB,EAC/B,aAAa,iBAAiB,KAC/B,cAIF,CAAA;AAED,OAAO,EACH,wBAAwB,EACxB,0BAA0B,EAC7B,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TextFieldProps } from "@mui/material";
|
|
2
|
-
import { SingleTextProps } from "../../types";
|
|
3
|
-
declare const useSplitSingleTextProps: (defaultProps: SingleTextProps, customProps: SingleTextProps) => TextFieldProps;
|
|
4
|
-
export default useSplitSingleTextProps;
|
|
5
|
-
//# sourceMappingURL=useSplitSingleTextProps.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useSplitSingleTextProps.d.ts","sourceRoot":"","sources":["../../../src/hooks/splits/useSplitSingleTextProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC;AAElD,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAG5C,QAAA,MAAM,uBAAuB,GACzB,cAAc,eAAe,EAC7B,aAAa,eAAe,KAC7B,cAyBF,CAAA;AAED,eAAe,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createDefaultProps.d.ts","sourceRoot":"","sources":["../../src/styles/createDefaultProps.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAIhE,eAAO,MAAM,kBAAkB,GAC3B,QAAQ,qBAAqB,GAAG,SAAS,KAC1C,qBAqCF,CAAA"}
|
package/mui-fast-start-0.1.5.tgz
DELETED
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {useContext} from "react";
|
|
2
|
-
import {DeepPartial, ObjCheckIconProps, SingleCheckIconProps} from "../../../types";
|
|
3
|
-
import {fastDeepMerge} from "../../../utils";
|
|
4
|
-
import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
|
|
5
|
-
import {SingleCheckIcon} from "../../Single/Checkbox/SingleCheckIcon.tsx";
|
|
6
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
7
|
-
|
|
8
|
-
export const ObjCheckIcon = <T extends object>(customProps: ObjCheckIconProps<T>) => {
|
|
9
|
-
const defaultProps = useContext(FastStartContext)?.Obj?.CheckIcon as DeepPartial<ObjCheckIconProps<T>>;
|
|
10
|
-
const {get, set, ...props} = fastDeepMerge<ObjCheckIconProps<T>>(defaultProps, customProps);
|
|
11
|
-
const [value, setValue] = useObjToSingle<T, boolean>(props.name, get, set);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<SingleCheckIcon
|
|
15
|
-
get={value} set={setValue}
|
|
16
|
-
{...(props as unknown as Omit<SingleCheckIconProps, 'get' | 'set'>)}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, {useContext} from "react";
|
|
2
|
-
import useObjToSingle from '../../../hooks/state/useObjToSingle.ts';
|
|
3
|
-
import {fastDeepMerge} from "../../../utils";
|
|
4
|
-
import {DeepPartial, ObjCheckboxProps, SingleCheckboxProps} from "../../../types";
|
|
5
|
-
import {SingleCheckbox} from "../../Single/Checkbox/SingleCheckbox.tsx";
|
|
6
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
7
|
-
|
|
8
|
-
export const ObjCheckbox = <T extends object>(customProps: ObjCheckboxProps<T>) => {
|
|
9
|
-
const defaultProps = useContext(FastStartContext)?.Obj?.Checkbox as DeepPartial<ObjCheckboxProps<T>>;
|
|
10
|
-
const {get, set, ...props} = fastDeepMerge<ObjCheckboxProps<T>>(defaultProps, customProps);
|
|
11
|
-
const [value, setValue] = useObjToSingle<T, boolean>(props.name, get, set);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<SingleCheckbox
|
|
15
|
-
get={value} set={setValue}
|
|
16
|
-
{...(props as unknown as Omit<SingleCheckboxProps, 'set' | 'get'>)}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {useContext} from "react";
|
|
2
|
-
import {DeepPartial, ObjNumberProps, SingleNumberProps} from "../../../types";
|
|
3
|
-
import {fastDeepMerge} from "../../../utils";
|
|
4
|
-
import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
|
|
5
|
-
import {SingleFloat} from "../../Single/TextField/SingleFloat.tsx";
|
|
6
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
7
|
-
import {errorObjectToString} from "../../../utils/object/error.ts";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const ObjFloat = <T extends object>(customProps: ObjNumberProps<T>) => {
|
|
11
|
-
const defaultProps = useContext(FastStartContext)?.Obj?.Float as DeepPartial<ObjNumberProps<T>>;
|
|
12
|
-
const {get, set, errorData, ...props} = fastDeepMerge<ObjNumberProps<T>>(defaultProps, customProps);
|
|
13
|
-
const [value, setValue] = useObjToSingle<T, number>(props.name, get, set);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SingleFloat
|
|
17
|
-
get={value} set={setValue}
|
|
18
|
-
errorData={errorObjectToString(props.name, errorData)}
|
|
19
|
-
{...(props as unknown as Omit<SingleNumberProps, 'get' | 'set' | 'errorData'>)}
|
|
20
|
-
/>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import {DeepPartial, ObjNumberProps, SingleNumberProps} from "../../../types";
|
|
3
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
4
|
-
import {fastDeepMerge} from "../../../utils";
|
|
5
|
-
import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
|
|
6
|
-
import {SingleInteger} from "../../Single/TextField/SingleInteger.tsx";
|
|
7
|
-
import {errorObjectToString} from "../../../utils/object/error.ts";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const ObjInteger = <T extends object>(customProps: ObjNumberProps<T>) => {
|
|
11
|
-
const defaultProps = useContext(FastStartContext)?.Obj?.Integer as DeepPartial<ObjNumberProps<T>>;
|
|
12
|
-
const {get, set, errorData, ...props} = fastDeepMerge<ObjNumberProps<T>>(defaultProps, customProps);
|
|
13
|
-
const [value, setValue] = useObjToSingle<T, number>(props.name, get, set);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SingleInteger
|
|
17
|
-
get={value} set={setValue}
|
|
18
|
-
errorData={errorObjectToString(props.name, errorData)}
|
|
19
|
-
{...(props as unknown as Omit<SingleNumberProps, 'get' | 'set' | 'errorData'>)}
|
|
20
|
-
/>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import {DeepPartial, ObjTextProps, SingleTextProps} from "../../../types";
|
|
3
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
4
|
-
import {fastDeepMerge} from "../../../utils";
|
|
5
|
-
import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
|
|
6
|
-
import {SingleText} from "../../Single/TextField/SingleText.tsx";
|
|
7
|
-
import {errorObjectToString} from "../../../utils/object/error.ts";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export const ObjText = <T extends object>(customProps: ObjTextProps<T>) => {
|
|
11
|
-
const defaultProps = useContext(FastStartContext)?.Obj?.Text as DeepPartial<ObjTextProps<T>>;
|
|
12
|
-
const {get, set, errorData, ...props} = fastDeepMerge<ObjTextProps<T>>(defaultProps, customProps);
|
|
13
|
-
const [value, setValue] = useObjToSingle<T, string>(props.name, get, set);
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<SingleText
|
|
17
|
-
get={value} set={setValue}
|
|
18
|
-
errorData={errorObjectToString(props.name, errorData)}
|
|
19
|
-
{...(props as unknown as Omit<SingleTextProps, 'get' | 'set' | 'errorData'>)}
|
|
20
|
-
/>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import {useContext} from "react";
|
|
2
|
-
import {TextField} from "@mui/material";
|
|
3
|
-
import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
|
|
4
|
-
import {SingleNumberProps} from "../../../types";
|
|
5
|
-
import {useSplitSingleFloatProps} from "../../../hooks";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const SingleFloat = (customProps: SingleNumberProps) => {
|
|
9
|
-
const defaultProps = useContext(FastStartContext)?.Single?.Float as SingleNumberProps;
|
|
10
|
-
const props = useSplitSingleFloatProps(defaultProps, customProps);
|
|
11
|
-
return <TextField {...props}/>;
|
|
12
|
-
}
|