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
package/src/types/provider.ts
CHANGED
|
@@ -1,72 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MfsCheckIconProps,
|
|
3
|
-
MfsErrorProps,
|
|
4
|
-
MfsLabelProps,
|
|
5
|
-
MfsNumberProps,
|
|
6
|
-
MfsObjectProps,
|
|
7
|
-
MfsPropertyProps,
|
|
8
|
-
MfsSelectOneProps,
|
|
9
|
-
MfsSelectRecordProps,
|
|
10
|
-
MfsTextProps
|
|
11
|
-
} from './props';
|
|
12
|
-
import {MfsObjectError, MfsSingleError} from "./props.internal.ts";
|
|
13
|
-
|
|
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
|
-
|
|
1
|
+
import {
|
|
2
|
+
MfsCheckIconProps,
|
|
3
|
+
MfsErrorProps,
|
|
4
|
+
MfsLabelProps,
|
|
5
|
+
MfsNumberProps,
|
|
6
|
+
MfsObjectProps,
|
|
7
|
+
MfsPropertyProps,
|
|
8
|
+
MfsSelectOneProps,
|
|
9
|
+
MfsSelectRecordProps,
|
|
10
|
+
MfsTextProps
|
|
11
|
+
} from './props';
|
|
12
|
+
import {MfsObjectError, MfsSingleError} from "./props.internal.ts";
|
|
13
|
+
import React from "react";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Single
|
|
17
|
+
export interface MfsSingleNumberProps extends
|
|
18
|
+
MfsNumberProps,
|
|
19
|
+
MfsErrorProps<number, MfsSingleError> {}
|
|
20
|
+
|
|
21
|
+
export interface MfsSingleTextProps extends
|
|
22
|
+
MfsTextProps,
|
|
23
|
+
MfsErrorProps<string, MfsSingleError> {}
|
|
24
|
+
|
|
25
|
+
export type MfsSingleCheckboxProps =
|
|
26
|
+
MfsLabelProps<boolean>;
|
|
27
|
+
|
|
28
|
+
export interface MfsSingleCheckIconProps extends
|
|
29
|
+
MfsCheckIconProps,
|
|
30
|
+
MfsPropertyProps<boolean> {}
|
|
31
|
+
|
|
32
|
+
export type MfsSingleSelectOneProps<Item> =
|
|
33
|
+
MfsSelectOneProps<Item>
|
|
34
|
+
& MfsErrorProps<Item, MfsSingleError>;
|
|
35
|
+
|
|
36
|
+
export type MfsSingleSelectRecordProps<
|
|
37
|
+
Item extends Record<PropertyKey, unknown>,
|
|
38
|
+
Value = keyof Item | undefined | null
|
|
39
|
+
> = MfsSelectRecordProps<Item>
|
|
40
|
+
& MfsErrorProps<Value, MfsSingleError>;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
// Object
|
|
44
|
+
export interface MfsObjectNumberProps<T extends object> extends
|
|
45
|
+
MfsObjectProps<T, number>,
|
|
46
|
+
MfsNumberProps,
|
|
47
|
+
MfsErrorProps<T, MfsObjectError<T, number>> {}
|
|
48
|
+
|
|
49
|
+
export interface MfsObjectTextProps<T extends object> extends
|
|
50
|
+
MfsObjectProps<T, string>,
|
|
51
|
+
MfsTextProps,
|
|
52
|
+
MfsErrorProps<T, MfsObjectError<T, string>> {}
|
|
53
|
+
|
|
54
|
+
export interface MfsObjectCheckboxProps<T extends object> extends
|
|
55
|
+
MfsObjectProps<T, boolean>,
|
|
56
|
+
MfsLabelProps<T> {}
|
|
57
|
+
|
|
58
|
+
export interface MfsObjectCheckIconProps<T extends object> extends
|
|
59
|
+
MfsObjectProps<T, boolean>,
|
|
60
|
+
MfsPropertyProps<T>,
|
|
61
|
+
MfsCheckIconProps {}
|
|
62
|
+
|
|
63
|
+
export type MfsObjectSelectOneProps<T extends object, Item> =
|
|
64
|
+
MfsObjectProps<T, Item>
|
|
65
|
+
& MfsSelectOneProps<Item>
|
|
66
|
+
& MfsErrorProps<T, MfsObjectError<T, Item>>;
|
|
67
|
+
|
|
68
|
+
export type MfsObjectSelectRecordProps<
|
|
69
|
+
T extends object,
|
|
70
|
+
Item extends Record<PropertyKey, React.ReactNode>
|
|
71
|
+
> = MfsObjectProps<T, Item>
|
|
72
|
+
& MfsSelectRecordProps<Item>
|
|
72
73
|
& MfsErrorProps<T, MfsObjectError<T, Item>>;
|
package/src/types/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
type DeepPartial<T> = {
|
|
2
|
-
[K in keyof T]?: T[K] extends object
|
|
3
|
-
? DeepPartial<T[K]>
|
|
4
|
-
: T[K];
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type {
|
|
8
|
-
DeepPartial
|
|
9
|
-
}
|
|
1
|
+
type DeepPartial<T> = {
|
|
2
|
+
[K in keyof T]?: T[K] extends object
|
|
3
|
+
? DeepPartial<T[K]>
|
|
4
|
+
: T[K];
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
DeepPartial
|
|
9
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './number/calculate';
|
|
2
|
-
export * from './object/merge';
|
|
1
|
+
export * from './number/calculate';
|
|
2
|
+
export * from './object/merge';
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
type CalculateNumber = number | null | undefined;
|
|
2
|
-
|
|
3
|
-
const floatCalculate = (
|
|
4
|
-
value: string | null,
|
|
5
|
-
min: CalculateNumber,
|
|
6
|
-
max: CalculateNumber,
|
|
7
|
-
def: CalculateNumber
|
|
8
|
-
): CalculateNumber => {
|
|
9
|
-
let calc: CalculateNumber = 0;
|
|
10
|
-
if (value == null || isEmpty(value)) {
|
|
11
|
-
calc = def;
|
|
12
|
-
} else {
|
|
13
|
-
for (const token of value.split(/(?=[+-])/g)) {
|
|
14
|
-
if (/^[+-]?\d+\.\d+$/.test(token)) {
|
|
15
|
-
calc += parseFloat(token);
|
|
16
|
-
} else if (/^[+-]?\d+$/.test(token)) {
|
|
17
|
-
calc += parseInt(token, 10);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (calc != null) {
|
|
23
|
-
if (max != null) calc = Math.min(max, calc);
|
|
24
|
-
if (min != null) calc = Math.max(min, calc);
|
|
25
|
-
}
|
|
26
|
-
return calc;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const integerCalculate = (
|
|
30
|
-
value: string | null,
|
|
31
|
-
min: CalculateNumber,
|
|
32
|
-
max: CalculateNumber,
|
|
33
|
-
def: CalculateNumber
|
|
34
|
-
): CalculateNumber => {
|
|
35
|
-
let calc: CalculateNumber = 0;
|
|
36
|
-
if (value == null || isEmpty(value)) {
|
|
37
|
-
calc = def;
|
|
38
|
-
} else {
|
|
39
|
-
for (const token of value.split(/(?=[+-])/g)) {
|
|
40
|
-
if (/^[+-]?\d+$/.test(token)) {
|
|
41
|
-
calc += parseInt(token, 10);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (calc != null) {
|
|
47
|
-
if (max != null) calc = Math.min(max, calc);
|
|
48
|
-
if (min != null) calc = Math.max(min, calc);
|
|
49
|
-
}
|
|
50
|
-
return calc;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const processFloat = (text: string): string => {
|
|
54
|
-
const value: string = text
|
|
55
|
-
.replace(/[^0-9+.-]/g, '')
|
|
56
|
-
.replace(/([+-]){2,}/g, (match, op) => op);
|
|
57
|
-
|
|
58
|
-
let result: string = '';
|
|
59
|
-
let token: string = '';
|
|
60
|
-
let decimalUsed: boolean = false;
|
|
61
|
-
|
|
62
|
-
for (let i = 0; i < value.length; i++) {
|
|
63
|
-
const char = value[i];
|
|
64
|
-
|
|
65
|
-
if (char >= '0' && char <= '9') {
|
|
66
|
-
token += char;
|
|
67
|
-
} else if (char === '.') {
|
|
68
|
-
if (!decimalUsed) {
|
|
69
|
-
if (token === '') {
|
|
70
|
-
token = '0';
|
|
71
|
-
}
|
|
72
|
-
token += '.';
|
|
73
|
-
decimalUsed = true;
|
|
74
|
-
}
|
|
75
|
-
} else if (char === '+' || char === '-') {
|
|
76
|
-
if (token !== '') {
|
|
77
|
-
result += token;
|
|
78
|
-
}
|
|
79
|
-
result += char;
|
|
80
|
-
token = '';
|
|
81
|
-
decimalUsed = false;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return result + token;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const processInteger = (text: string): string => text
|
|
88
|
-
.replace(/[^0-9+-]/g, '')
|
|
89
|
-
.replace(/\./g, '')
|
|
90
|
-
.replace(/([+-]){2,}/g, (match, op) => op.charAt(0))
|
|
91
|
-
.replace(/^([+-]{2,})/, match => match.charAt(0));
|
|
92
|
-
|
|
93
|
-
function isEmpty(str: string): boolean {
|
|
94
|
-
return str.length === 0 || !str.trim();
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export {
|
|
98
|
-
floatCalculate,
|
|
99
|
-
integerCalculate,
|
|
100
|
-
processFloat,
|
|
101
|
-
processInteger
|
|
102
|
-
}
|
|
1
|
+
type CalculateNumber = number | null | undefined;
|
|
2
|
+
|
|
3
|
+
const floatCalculate = (
|
|
4
|
+
value: string | null,
|
|
5
|
+
min: CalculateNumber,
|
|
6
|
+
max: CalculateNumber,
|
|
7
|
+
def: CalculateNumber
|
|
8
|
+
): CalculateNumber => {
|
|
9
|
+
let calc: CalculateNumber = 0;
|
|
10
|
+
if (value == null || isEmpty(value)) {
|
|
11
|
+
calc = def;
|
|
12
|
+
} else {
|
|
13
|
+
for (const token of value.split(/(?=[+-])/g)) {
|
|
14
|
+
if (/^[+-]?\d+\.\d+$/.test(token)) {
|
|
15
|
+
calc += parseFloat(token);
|
|
16
|
+
} else if (/^[+-]?\d+$/.test(token)) {
|
|
17
|
+
calc += parseInt(token, 10);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (calc != null) {
|
|
23
|
+
if (max != null) calc = Math.min(max, calc);
|
|
24
|
+
if (min != null) calc = Math.max(min, calc);
|
|
25
|
+
}
|
|
26
|
+
return calc;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const integerCalculate = (
|
|
30
|
+
value: string | null,
|
|
31
|
+
min: CalculateNumber,
|
|
32
|
+
max: CalculateNumber,
|
|
33
|
+
def: CalculateNumber
|
|
34
|
+
): CalculateNumber => {
|
|
35
|
+
let calc: CalculateNumber = 0;
|
|
36
|
+
if (value == null || isEmpty(value)) {
|
|
37
|
+
calc = def;
|
|
38
|
+
} else {
|
|
39
|
+
for (const token of value.split(/(?=[+-])/g)) {
|
|
40
|
+
if (/^[+-]?\d+$/.test(token)) {
|
|
41
|
+
calc += parseInt(token, 10);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (calc != null) {
|
|
47
|
+
if (max != null) calc = Math.min(max, calc);
|
|
48
|
+
if (min != null) calc = Math.max(min, calc);
|
|
49
|
+
}
|
|
50
|
+
return calc;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const processFloat = (text: string): string => {
|
|
54
|
+
const value: string = text
|
|
55
|
+
.replace(/[^0-9+.-]/g, '')
|
|
56
|
+
.replace(/([+-]){2,}/g, (match, op) => op);
|
|
57
|
+
|
|
58
|
+
let result: string = '';
|
|
59
|
+
let token: string = '';
|
|
60
|
+
let decimalUsed: boolean = false;
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < value.length; i++) {
|
|
63
|
+
const char = value[i];
|
|
64
|
+
|
|
65
|
+
if (char >= '0' && char <= '9') {
|
|
66
|
+
token += char;
|
|
67
|
+
} else if (char === '.') {
|
|
68
|
+
if (!decimalUsed) {
|
|
69
|
+
if (token === '') {
|
|
70
|
+
token = '0';
|
|
71
|
+
}
|
|
72
|
+
token += '.';
|
|
73
|
+
decimalUsed = true;
|
|
74
|
+
}
|
|
75
|
+
} else if (char === '+' || char === '-') {
|
|
76
|
+
if (token !== '') {
|
|
77
|
+
result += token;
|
|
78
|
+
}
|
|
79
|
+
result += char;
|
|
80
|
+
token = '';
|
|
81
|
+
decimalUsed = false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return result + token;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const processInteger = (text: string): string => text
|
|
88
|
+
.replace(/[^0-9+-]/g, '')
|
|
89
|
+
.replace(/\./g, '')
|
|
90
|
+
.replace(/([+-]){2,}/g, (match, op) => op.charAt(0))
|
|
91
|
+
.replace(/^([+-]{2,})/, match => match.charAt(0));
|
|
92
|
+
|
|
93
|
+
function isEmpty(str: string): boolean {
|
|
94
|
+
return str.length === 0 || !str.trim();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {
|
|
98
|
+
floatCalculate,
|
|
99
|
+
integerCalculate,
|
|
100
|
+
processFloat,
|
|
101
|
+
processInteger
|
|
102
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {MfsErrorProps, MfsObjectProps} from "../../types";
|
|
2
|
-
import {MfsObjectError} from "../../types/props.internal.ts";
|
|
3
|
-
|
|
4
|
-
function errorObjectToString<Type extends object, Target = unknown>(
|
|
5
|
-
name: MfsObjectProps<Type, Target>['name'],
|
|
6
|
-
data: MfsErrorProps<Type, MfsObjectError<Type, Target>>['err']
|
|
7
|
-
): string | undefined {
|
|
8
|
-
return (name != null && typeof data === 'object')
|
|
9
|
-
? (data as Record<string, string>)[name as string]
|
|
10
|
-
: undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
errorObjectToString
|
|
15
|
-
}
|
|
1
|
+
import {MfsErrorProps, MfsObjectProps} from "../../types";
|
|
2
|
+
import {MfsObjectError} from "../../types/props.internal.ts";
|
|
3
|
+
|
|
4
|
+
function errorObjectToString<Type extends object, Target = unknown>(
|
|
5
|
+
name: MfsObjectProps<Type, Target>['name'],
|
|
6
|
+
data: MfsErrorProps<Type, MfsObjectError<Type, Target>>['err']
|
|
7
|
+
): string | undefined {
|
|
8
|
+
return (name != null && typeof data === 'object')
|
|
9
|
+
? (data as Record<string, string>)[name as string]
|
|
10
|
+
: undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
errorObjectToString
|
|
15
|
+
}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import {DeepPartial} from "../../types";
|
|
2
|
-
|
|
3
|
-
type AnyObj = Record<string, any>;
|
|
4
|
-
|
|
5
|
-
function isPlainObject(v: any): v is AnyObj {
|
|
6
|
-
return v !== null && typeof v === "object" && v.constructor === Object;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function isEmpty(v: object): boolean {
|
|
10
|
-
return Object.keys(v).length === 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function fastDeepMerge<T extends object>(target: DeepPartial<T> | undefined, source: T): T {
|
|
14
|
-
if (target === source || !isPlainObject(source) || isEmpty(source)) {
|
|
15
|
-
return target as T;
|
|
16
|
-
} else if (!isPlainObject(target) || isEmpty(target)) {
|
|
17
|
-
return source;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const result: AnyObj = {...target};
|
|
21
|
-
const stack: [AnyObj, AnyObj][] = [[result, source as AnyObj]];
|
|
22
|
-
|
|
23
|
-
while (stack.length) {
|
|
24
|
-
const [tNode, sNode] = stack.pop()!;
|
|
25
|
-
|
|
26
|
-
for (const key in sNode) {
|
|
27
|
-
if (!Object.prototype.hasOwnProperty.call(sNode, key)) continue;
|
|
28
|
-
|
|
29
|
-
const sVal = sNode[key];
|
|
30
|
-
const tVal = tNode[key];
|
|
31
|
-
|
|
32
|
-
if (isPlainObject(tVal) && isPlainObject(sVal)) {
|
|
33
|
-
const copy = {...tVal};
|
|
34
|
-
tNode[key] = copy;
|
|
35
|
-
stack.push([copy, sVal]);
|
|
36
|
-
} else {
|
|
37
|
-
tNode[key] = sVal;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return result as T;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
fastDeepMerge
|
|
47
|
-
}
|
|
1
|
+
import {DeepPartial} from "../../types";
|
|
2
|
+
|
|
3
|
+
type AnyObj = Record<string, any>;
|
|
4
|
+
|
|
5
|
+
function isPlainObject(v: any): v is AnyObj {
|
|
6
|
+
return v !== null && typeof v === "object" && v.constructor === Object;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function isEmpty(v: object): boolean {
|
|
10
|
+
return Object.keys(v).length === 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function fastDeepMerge<T extends object>(target: DeepPartial<T> | undefined, source: T): T {
|
|
14
|
+
if (target === source || !isPlainObject(source) || isEmpty(source)) {
|
|
15
|
+
return target as T;
|
|
16
|
+
} else if (!isPlainObject(target) || isEmpty(target)) {
|
|
17
|
+
return source;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const result: AnyObj = {...target};
|
|
21
|
+
const stack: [AnyObj, AnyObj][] = [[result, source as AnyObj]];
|
|
22
|
+
|
|
23
|
+
while (stack.length) {
|
|
24
|
+
const [tNode, sNode] = stack.pop()!;
|
|
25
|
+
|
|
26
|
+
for (const key in sNode) {
|
|
27
|
+
if (!Object.prototype.hasOwnProperty.call(sNode, key)) continue;
|
|
28
|
+
|
|
29
|
+
const sVal = sNode[key];
|
|
30
|
+
const tVal = tNode[key];
|
|
31
|
+
|
|
32
|
+
if (isPlainObject(tVal) && isPlainObject(sVal)) {
|
|
33
|
+
const copy = {...tVal};
|
|
34
|
+
tNode[key] = copy;
|
|
35
|
+
stack.push([copy, sVal]);
|
|
36
|
+
} else {
|
|
37
|
+
tNode[key] = sVal;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return result as T;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
fastDeepMerge
|
|
47
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"useDefineForClassFields": true,
|
|
4
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
-
|
|
6
|
-
"allowImportingTsExtensions": true,
|
|
7
|
-
"moduleDetection": "force",
|
|
8
|
-
|
|
9
|
-
/* Build options */
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"declarationMap": true,
|
|
12
|
-
"emitDeclarationOnly": true,
|
|
13
|
-
"noEmit": false,
|
|
14
|
-
"rootDir": "src",
|
|
15
|
-
"outDir": "dist",
|
|
16
|
-
"declarationDir": "dist",
|
|
17
|
-
|
|
18
|
-
/* Bundler mode */
|
|
19
|
-
"strict": true,
|
|
20
|
-
"jsx": "react-jsx",
|
|
21
|
-
"moduleResolution": "bundler",
|
|
22
|
-
"module": "ESNext",
|
|
23
|
-
"target": "ES2022",
|
|
24
|
-
|
|
25
|
-
/* Interop */
|
|
26
|
-
"allowSyntheticDefaultImports": true,
|
|
27
|
-
"esModuleInterop": true,
|
|
28
|
-
|
|
29
|
-
/* Library options */
|
|
30
|
-
"skipLibCheck": true,
|
|
31
|
-
"skipDefaultLibCheck": true,
|
|
32
|
-
},
|
|
33
|
-
"include": ["src"],
|
|
34
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"useDefineForClassFields": true,
|
|
4
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
5
|
+
|
|
6
|
+
"allowImportingTsExtensions": true,
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
|
|
9
|
+
/* Build options */
|
|
10
|
+
"declaration": true,
|
|
11
|
+
"declarationMap": true,
|
|
12
|
+
"emitDeclarationOnly": true,
|
|
13
|
+
"noEmit": false,
|
|
14
|
+
"rootDir": "src",
|
|
15
|
+
"outDir": "dist",
|
|
16
|
+
"declarationDir": "dist",
|
|
17
|
+
|
|
18
|
+
/* Bundler mode */
|
|
19
|
+
"strict": true,
|
|
20
|
+
"jsx": "react-jsx",
|
|
21
|
+
"moduleResolution": "bundler",
|
|
22
|
+
"module": "ESNext",
|
|
23
|
+
"target": "ES2022",
|
|
24
|
+
|
|
25
|
+
/* Interop */
|
|
26
|
+
"allowSyntheticDefaultImports": true,
|
|
27
|
+
"esModuleInterop": true,
|
|
28
|
+
|
|
29
|
+
/* Library options */
|
|
30
|
+
"skipLibCheck": true,
|
|
31
|
+
"skipDefaultLibCheck": true,
|
|
32
|
+
},
|
|
33
|
+
"include": ["src"],
|
|
34
|
+
}
|
package/tsconfig.lib.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"noEmit": false,
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"emitDeclarationOnly": true,
|
|
7
|
-
"outDir": "dist"
|
|
8
|
-
}
|
|
9
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"emitDeclarationOnly": true,
|
|
7
|
+
"outDir": "dist"
|
|
8
|
+
}
|
|
9
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import {defineConfig} from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
3
|
-
import {resolve} from 'path'
|
|
4
|
-
|
|
5
|
-
// https://vite.dev/config/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [react()],
|
|
8
|
-
resolve: {
|
|
9
|
-
},
|
|
10
|
-
build: {
|
|
11
|
-
lib: {
|
|
12
|
-
entry: resolve(__dirname, "src/index.ts"),
|
|
13
|
-
name: 'MuiFastStart',
|
|
14
|
-
fileName: 'index',
|
|
15
|
-
formats: ['es']
|
|
16
|
-
},
|
|
17
|
-
rolldownOptions: {
|
|
18
|
-
external: [
|
|
19
|
-
'react',
|
|
20
|
-
'react-dom',
|
|
21
|
-
'react/jsx-runtime',
|
|
22
|
-
'@mui/material',
|
|
23
|
-
'@emotion/react',
|
|
24
|
-
'@emotion/styled'
|
|
25
|
-
],
|
|
26
|
-
output: {
|
|
27
|
-
globals: {
|
|
28
|
-
'react': 'React',
|
|
29
|
-
'react-dom': 'ReactDOM',
|
|
30
|
-
'@mui/material': 'MaterialUI'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
})
|
|
1
|
+
import {defineConfig} from 'vite'
|
|
2
|
+
import react from '@vitejs/plugin-react'
|
|
3
|
+
import {resolve} from 'path'
|
|
4
|
+
|
|
5
|
+
// https://vite.dev/config/
|
|
6
|
+
export default defineConfig({
|
|
7
|
+
plugins: [react()],
|
|
8
|
+
resolve: {
|
|
9
|
+
},
|
|
10
|
+
build: {
|
|
11
|
+
lib: {
|
|
12
|
+
entry: resolve(__dirname, "src/index.ts"),
|
|
13
|
+
name: 'MuiFastStart',
|
|
14
|
+
fileName: 'index',
|
|
15
|
+
formats: ['es']
|
|
16
|
+
},
|
|
17
|
+
rolldownOptions: {
|
|
18
|
+
external: [
|
|
19
|
+
'react',
|
|
20
|
+
'react-dom',
|
|
21
|
+
'react/jsx-runtime',
|
|
22
|
+
'@mui/material',
|
|
23
|
+
'@emotion/react',
|
|
24
|
+
'@emotion/styled'
|
|
25
|
+
],
|
|
26
|
+
output: {
|
|
27
|
+
globals: {
|
|
28
|
+
'react': 'React',
|
|
29
|
+
'react-dom': 'ReactDOM',
|
|
30
|
+
'@mui/material': 'MaterialUI'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
})
|