mui-fast-start 0.3.2 → 0.3.4

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.
Files changed (62) hide show
  1. package/README.md +403 -403
  2. package/README_KR.md +403 -403
  3. package/dist/components/Object/Select/ObjSelectRecord.d.ts +2 -1
  4. package/dist/components/Object/Select/ObjSelectRecord.d.ts.map +1 -1
  5. package/dist/components/Single/Select/SingleSelectRecord.d.ts +2 -1
  6. package/dist/components/Single/Select/SingleSelectRecord.d.ts.map +1 -1
  7. package/dist/index.js +3 -3
  8. package/dist/styles/FastStartProps.d.ts +2 -1
  9. package/dist/styles/FastStartProps.d.ts.map +1 -1
  10. package/dist/types/props.d.ts +1 -1
  11. package/dist/types/props.d.ts.map +1 -1
  12. package/dist/types/provider.d.ts +2 -1
  13. package/dist/types/provider.d.ts.map +1 -1
  14. package/examples/basic/README.md +73 -73
  15. package/examples/basic/eslint.config.js +23 -23
  16. package/examples/basic/index.html +13 -13
  17. package/examples/basic/package.json +37 -37
  18. package/examples/basic/src/App.css +4 -4
  19. package/examples/basic/src/App.tsx +28 -28
  20. package/examples/basic/src/index.css +29 -29
  21. package/examples/basic/src/main.tsx +50 -50
  22. package/examples/basic/src/pages/ObjPage.tsx +175 -175
  23. package/examples/basic/src/pages/SinglePage.tsx +144 -137
  24. package/examples/basic/tsconfig.app.json +43 -43
  25. package/examples/basic/tsconfig.json +7 -7
  26. package/examples/basic/tsconfig.node.json +40 -40
  27. package/examples/basic/vite.config.ts +28 -28
  28. package/mui-fast-start-0.1.4.tgz +0 -0
  29. package/package.json +67 -67
  30. package/src/components/Object/Checkbox/ObjCheckIcon.tsx +29 -29
  31. package/src/components/Object/Checkbox/ObjCheckbox.tsx +31 -31
  32. package/src/components/Object/Select/ObjSelectOne.tsx +33 -33
  33. package/src/components/Object/Select/ObjSelectRecord.tsx +33 -33
  34. package/src/components/Object/Textfield/ObjNumber.tsx +51 -51
  35. package/src/components/Object/Textfield/ObjText.tsx +29 -29
  36. package/src/components/Single/Checkbox/SingleCheckIcon.tsx +27 -27
  37. package/src/components/Single/Checkbox/SingleCheckbox.tsx +33 -33
  38. package/src/components/Single/Select/BaseSingleSelect.tsx +45 -45
  39. package/src/components/Single/Select/SingleSelectOne.tsx +56 -56
  40. package/src/components/Single/Select/SingleSelectRecord.tsx +51 -51
  41. package/src/components/Single/TextField/SingleNumber.tsx +18 -18
  42. package/src/components/Single/TextField/SingleText.tsx +13 -13
  43. package/src/components/index.ts +15 -15
  44. package/src/hooks/index.ts +3 -3
  45. package/src/hooks/splits/useSplitNumberProps.ts +161 -161
  46. package/src/hooks/splits/useSplitTextProps.ts +36 -36
  47. package/src/hooks/state/useObjToSingle.ts +24 -24
  48. package/src/index.ts +7 -7
  49. package/src/styles/FastStartProps.ts +82 -81
  50. package/src/styles/FastStartProvider.tsx +25 -25
  51. package/src/types/index.ts +3 -3
  52. package/src/types/props.internal.ts +21 -21
  53. package/src/types/props.ts +81 -81
  54. package/src/types/provider.ts +72 -71
  55. package/src/types/types.ts +9 -9
  56. package/src/utils/index.ts +2 -2
  57. package/src/utils/number/calculate.ts +102 -102
  58. package/src/utils/object/error.ts +15 -15
  59. package/src/utils/object/merge.ts +47 -47
  60. package/tsconfig.json +34 -34
  61. package/tsconfig.lib.json +9 -9
  62. package/vite.config.ts +35 -35
package/package.json CHANGED
@@ -1,67 +1,67 @@
1
- {
2
- "name": "mui-fast-start",
3
- "version": "0.3.2",
4
- "description": "Fast and easy-to-use MUI components for React",
5
- "keywords": [
6
- "mui",
7
- "material-ui",
8
- "react",
9
- "components",
10
- "form"
11
- ],
12
- "author": "PersesTitan",
13
- "license": "MIT",
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/PersesTitan/mui-fast-start.git"
17
- },
18
-
19
- "type": "module",
20
- "main": "dist/index.js",
21
- "module": "dist/index.js",
22
- "types": "dist/index.d.ts",
23
- "sideEffects": false,
24
- "scripts": {
25
- "dev": "vite",
26
- "build": "vite build && tsc -p tsconfig.json",
27
- "lint": "eslint .",
28
- "preview": "vite preview",
29
- "prepublishOnly": "npm run build"
30
- },
31
- "exports": {
32
- ".": {
33
- "import": "./dist/index.js",
34
- "types": "./dist/index.d.ts"
35
- }
36
- },
37
- "peerDependencies": {
38
- "@emotion/react": ">=11",
39
- "@emotion/styled": ">=11",
40
- "@mui/material": ">=6",
41
- "react": ">=18",
42
- "react-dom": ">=18"
43
- },
44
- "devDependencies": {
45
- "@emotion/react": "^11.14.0",
46
- "@emotion/styled": "^11.14.1",
47
- "@eslint/js": "^9.39.1",
48
- "@mui/material": "^7.1.1",
49
- "@types/node": "^24.10.1",
50
- "@types/react": "^19.2.5",
51
- "@types/react-dom": "^19.2.3",
52
- "@vitejs/plugin-react": "^5.1.1",
53
- "eslint": "^9.39.1",
54
- "eslint-plugin-react-hooks": "^7.0.1",
55
- "eslint-plugin-react-refresh": "^0.4.24",
56
- "globals": "^16.5.0",
57
- "react": "^19.2.0",
58
- "react-dom": "^19.2.0",
59
- "tsc-alias": "^1.8.16",
60
- "typescript": "~5.9.3",
61
- "typescript-eslint": "^8.46.4",
62
- "vite": "npm:rolldown-vite@7.2.5"
63
- },
64
- "overrides": {
65
- "vite": "npm:rolldown-vite@7.2.5"
66
- }
67
- }
1
+ {
2
+ "name": "mui-fast-start",
3
+ "version": "0.3.4",
4
+ "description": "Fast and easy-to-use MUI components for React",
5
+ "keywords": [
6
+ "mui",
7
+ "material-ui",
8
+ "react",
9
+ "components",
10
+ "form"
11
+ ],
12
+ "author": "PersesTitan",
13
+ "license": "MIT",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/PersesTitan/mui-fast-start.git"
17
+ },
18
+
19
+ "type": "module",
20
+ "main": "dist/index.js",
21
+ "module": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "sideEffects": false,
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "vite build && tsc -p tsconfig.json",
27
+ "lint": "eslint .",
28
+ "preview": "vite preview",
29
+ "prepublishOnly": "npm run build"
30
+ },
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.js",
34
+ "types": "./dist/index.d.ts"
35
+ }
36
+ },
37
+ "peerDependencies": {
38
+ "@emotion/react": ">=11",
39
+ "@emotion/styled": ">=11",
40
+ "@mui/material": ">=6",
41
+ "react": ">=18",
42
+ "react-dom": ">=18"
43
+ },
44
+ "devDependencies": {
45
+ "@emotion/react": "^11.14.0",
46
+ "@emotion/styled": "^11.14.1",
47
+ "@eslint/js": "^9.39.1",
48
+ "@mui/material": "^7.1.1",
49
+ "@types/node": "^24.10.1",
50
+ "@types/react": "^19.2.5",
51
+ "@types/react-dom": "^19.2.3",
52
+ "@vitejs/plugin-react": "^5.1.1",
53
+ "eslint": "^9.39.1",
54
+ "eslint-plugin-react-hooks": "^7.0.1",
55
+ "eslint-plugin-react-refresh": "^0.4.24",
56
+ "globals": "^16.5.0",
57
+ "react": "^19.2.0",
58
+ "react-dom": "^19.2.0",
59
+ "tsc-alias": "^1.8.16",
60
+ "typescript": "~5.9.3",
61
+ "typescript-eslint": "^8.46.4",
62
+ "vite": "npm:rolldown-vite@7.2.5"
63
+ },
64
+ "overrides": {
65
+ "vite": "npm:rolldown-vite@7.2.5"
66
+ }
67
+ }
@@ -1,29 +1,29 @@
1
- import {useContext} from "react";
2
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
3
- import {SingleCheckIcon} from "../../Single/Checkbox/SingleCheckIcon.tsx";
4
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
5
- import {IconButtonProps} from "@mui/material";
6
- import {MfsObjectCheckIconProps} from "../../../types";
7
-
8
-
9
- export const ObjCheckIcon = <T extends object>(
10
- customProps: Omit<IconButtonProps, 'name'> & MfsObjectCheckIconProps<T>
11
- ) => {
12
- const defaultProps = useContext(FastStartContext)?.Object?.MfsCheckIcon;
13
- const {
14
- get, set, name,
15
- ...props
16
- } = defaultProps == null
17
- ? customProps
18
- : Object.assign({...defaultProps}, customProps);
19
-
20
- const [value, setValue] = useObjToSingle<T, boolean>(name, get, set);
21
-
22
- return (
23
- <SingleCheckIcon
24
- get={value} set={setValue}
25
- name={name?.toString()}
26
- {...props}
27
- />
28
- );
29
- }
1
+ import {useContext} from "react";
2
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
3
+ import {SingleCheckIcon} from "../../Single/Checkbox/SingleCheckIcon.tsx";
4
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
5
+ import {IconButtonProps} from "@mui/material";
6
+ import {MfsObjectCheckIconProps} from "../../../types";
7
+
8
+
9
+ export const ObjCheckIcon = <T extends object>(
10
+ customProps: Omit<IconButtonProps, 'name'> & MfsObjectCheckIconProps<T>
11
+ ) => {
12
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsCheckIcon;
13
+ const {
14
+ get, set, name,
15
+ ...props
16
+ } = defaultProps == null
17
+ ? customProps
18
+ : Object.assign({...defaultProps}, customProps);
19
+
20
+ const [value, setValue] = useObjToSingle<T, boolean>(name, get, set);
21
+
22
+ return (
23
+ <SingleCheckIcon
24
+ get={value} set={setValue}
25
+ name={name?.toString()}
26
+ {...props}
27
+ />
28
+ );
29
+ }
@@ -1,31 +1,31 @@
1
- import React, {useContext} from "react";
2
- import {SingleCheckbox} from "../../Single/Checkbox/SingleCheckbox.tsx";
3
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
- import {CheckboxProps} from "@mui/material";
5
- import {MfsObjectCheckboxProps} from "../../../types";
6
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
7
-
8
-
9
- export const ObjCheckbox = <T extends object>(
10
- customProps: Omit<CheckboxProps, 'name'> & MfsObjectCheckboxProps<T>
11
- ) => {
12
- const defaultProps = useContext(FastStartContext)?.Object?.MfsCheckbox;
13
- const {
14
- get, set, label, name,
15
- ...props
16
- } = defaultProps == null
17
- ? customProps
18
- : Object.assign({...defaultProps}, customProps);
19
-
20
- const [value, setValue] = useObjToSingle<T, boolean>(name, get, set);
21
-
22
- return (
23
- <SingleCheckbox
24
- get={value}
25
- set={setValue}
26
- label={label}
27
- name={name?.toString()}
28
- {...props}
29
- />
30
- );
31
- }
1
+ import React, {useContext} from "react";
2
+ import {SingleCheckbox} from "../../Single/Checkbox/SingleCheckbox.tsx";
3
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
+ import {CheckboxProps} from "@mui/material";
5
+ import {MfsObjectCheckboxProps} from "../../../types";
6
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
7
+
8
+
9
+ export const ObjCheckbox = <T extends object>(
10
+ customProps: Omit<CheckboxProps, 'name'> & MfsObjectCheckboxProps<T>
11
+ ) => {
12
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsCheckbox;
13
+ const {
14
+ get, set, label, name,
15
+ ...props
16
+ } = defaultProps == null
17
+ ? customProps
18
+ : Object.assign({...defaultProps}, customProps);
19
+
20
+ const [value, setValue] = useObjToSingle<T, boolean>(name, get, set);
21
+
22
+ return (
23
+ <SingleCheckbox
24
+ get={value}
25
+ set={setValue}
26
+ label={label}
27
+ name={name?.toString()}
28
+ {...props}
29
+ />
30
+ );
31
+ }
@@ -1,34 +1,34 @@
1
- import {useContext} from "react";
2
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
3
- import {SingleSelectOne} from "../../Single/Select/SingleSelectOne.tsx";
4
- import {SelectProps} from "@mui/material";
5
- import {MfsObjectSelectOneProps} from "../../../types";
6
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
7
- import {errorObjectToString} from "../../../utils/object/error.ts";
8
-
9
-
10
- export const ObjSelectOne = <
11
- T extends object,
12
- Item
13
- >(customProps: Omit<SelectProps, 'name'> & MfsObjectSelectOneProps<T, Item>) => {
14
- const defaultProps = useContext(FastStartContext)?.Object?.MfsSelectOne;
15
- const {
16
- get, set, err, name,
17
- variant,
18
- ...props
19
- } = defaultProps == null
20
- ? customProps
21
- : Object.assign({...defaultProps}, customProps);
22
-
23
- const [value, setValue] = useObjToSingle<T, Item>(name, get, set);
24
-
25
- return (
26
- <SingleSelectOne<Item>
27
- get={value} set={setValue}
28
- name={name?.toString()}
29
- err={errorObjectToString(name, err)}
30
- variant={variant}
31
- {...props}
32
- />
33
- )
1
+ import {useContext} from "react";
2
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
3
+ import {SingleSelectOne} from "../../Single/Select/SingleSelectOne.tsx";
4
+ import {SelectProps} from "@mui/material";
5
+ import {MfsObjectSelectOneProps} from "../../../types";
6
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
7
+ import {errorObjectToString} from "../../../utils/object/error.ts";
8
+
9
+
10
+ export const ObjSelectOne = <
11
+ T extends object,
12
+ Item
13
+ >(customProps: Omit<SelectProps, 'name'> & MfsObjectSelectOneProps<T, Item>) => {
14
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsSelectOne;
15
+ const {
16
+ get, set, err, name,
17
+ variant,
18
+ ...props
19
+ } = defaultProps == null
20
+ ? customProps
21
+ : Object.assign({...defaultProps}, customProps);
22
+
23
+ const [value, setValue] = useObjToSingle<T, Item>(name, get, set);
24
+
25
+ return (
26
+ <SingleSelectOne<Item>
27
+ get={value} set={setValue}
28
+ name={name?.toString()}
29
+ err={errorObjectToString(name, err)}
30
+ variant={variant}
31
+ {...props}
32
+ />
33
+ )
34
34
  }
@@ -1,34 +1,34 @@
1
- import {useContext} from "react";
2
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
3
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
4
- import {SingleSelectRecord} from "../../Single/Select/SingleSelectRecord.tsx";
5
- import {MfsObjectSelectRecordProps} from "../../../types";
6
- import {SelectProps} from "@mui/material";
7
- import {errorObjectToString} from "../../../utils/object/error.ts";
8
-
9
-
10
- export const ObjSelectRecord = <
11
- T extends object,
12
- Item extends Record<PropertyKey, unknown>
13
- >(customProps: Omit<SelectProps, 'name'> & MfsObjectSelectRecordProps<T, Item>) => {
14
- const defaultProps = useContext(FastStartContext)?.Single?.MfsSelectRecord;
15
- const {
16
- get, set, err, name,
17
- variant,
18
- ...props
19
- } = defaultProps == null
20
- ? customProps
21
- : Object.assign({...defaultProps}, customProps);
22
-
23
- const [value, setValue] = useObjToSingle<T, Item>(name, get, set);
24
-
25
- return (
26
- <SingleSelectRecord
27
- get={value} set={setValue}
28
- name={name?.toString()}
29
- err={errorObjectToString(name, err)}
30
- variant={variant}
31
- {...props}
32
- />
33
- )
1
+ import React, {useContext} from "react";
2
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
3
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
4
+ import {SingleSelectRecord} from "../../Single/Select/SingleSelectRecord.tsx";
5
+ import {MfsObjectSelectRecordProps} from "../../../types";
6
+ import {SelectProps} from "@mui/material";
7
+ import {errorObjectToString} from "../../../utils/object/error.ts";
8
+
9
+
10
+ export const ObjSelectRecord = <
11
+ T extends object,
12
+ Item extends Record<PropertyKey, React.ReactNode>
13
+ >(customProps: Omit<SelectProps, 'name'> & MfsObjectSelectRecordProps<T, Item>) => {
14
+ const defaultProps = useContext(FastStartContext)?.Single?.MfsSelectRecord;
15
+ const {
16
+ get, set, err, name,
17
+ variant,
18
+ ...props
19
+ } = defaultProps == null
20
+ ? customProps
21
+ : Object.assign({...defaultProps}, customProps);
22
+
23
+ const [value, setValue] = useObjToSingle<T, Item>(name, get, set);
24
+
25
+ return (
26
+ <SingleSelectRecord
27
+ get={value} set={setValue}
28
+ name={name?.toString()}
29
+ err={errorObjectToString(name, err)}
30
+ variant={variant}
31
+ {...props}
32
+ />
33
+ )
34
34
  }
@@ -1,51 +1,51 @@
1
- import {useContext} from "react";
2
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
3
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
- import {errorObjectToString} from "../../../utils/object/error.ts";
5
- import {SingleFloat, SingleInteger} from "../../Single/TextField/SingleNumber.tsx";
6
- import {MfsObjectNumberProps} from "../../../types";
7
- import {TextFieldProps} from "@mui/material";
8
-
9
- type ObjNumberProps<T extends object> = Omit<TextFieldProps, 'name'> & MfsObjectNumberProps<T>;
10
-
11
- export const ObjFloat = <T extends object>(customProps: ObjNumberProps<T>) => {
12
- const defaultProps = useContext(FastStartContext)?.Object?.MfsFloat;
13
- const {
14
- get, set, err, name,
15
- ...props
16
- } = defaultProps == null
17
- ? customProps
18
- : Object.assign({...defaultProps}, customProps);
19
-
20
- const [value, setValue] = useObjToSingle<T, number>(name, get, set);
21
-
22
- return (
23
- <SingleFloat
24
- get={value} set={setValue}
25
- name={name?.toString()}
26
- err={errorObjectToString(name, err)}
27
- {...props}
28
- />
29
- )
30
- }
31
-
32
- export const ObjInteger = <T extends object>(customProps: ObjNumberProps<T>) => {
33
- const defaultProps = useContext(FastStartContext)?.Object?.MfsInteger;
34
- const {
35
- get, set, err, name,
36
- ...props
37
- } = defaultProps == null
38
- ? customProps
39
- : Object.assign({...defaultProps}, customProps);
40
-
41
- const [value, setValue] = useObjToSingle<T, number>(name, get, set);
42
-
43
- return (
44
- <SingleInteger
45
- get={value} set={setValue}
46
- name={name?.toString()}
47
- err={errorObjectToString(name, err)}
48
- {...props}
49
- />
50
- )
51
- }
1
+ import {useContext} from "react";
2
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
3
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
+ import {errorObjectToString} from "../../../utils/object/error.ts";
5
+ import {SingleFloat, SingleInteger} from "../../Single/TextField/SingleNumber.tsx";
6
+ import {MfsObjectNumberProps} from "../../../types";
7
+ import {TextFieldProps} from "@mui/material";
8
+
9
+ type ObjNumberProps<T extends object> = Omit<TextFieldProps, 'name'> & MfsObjectNumberProps<T>;
10
+
11
+ export const ObjFloat = <T extends object>(customProps: ObjNumberProps<T>) => {
12
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsFloat;
13
+ const {
14
+ get, set, err, name,
15
+ ...props
16
+ } = defaultProps == null
17
+ ? customProps
18
+ : Object.assign({...defaultProps}, customProps);
19
+
20
+ const [value, setValue] = useObjToSingle<T, number>(name, get, set);
21
+
22
+ return (
23
+ <SingleFloat
24
+ get={value} set={setValue}
25
+ name={name?.toString()}
26
+ err={errorObjectToString(name, err)}
27
+ {...props}
28
+ />
29
+ )
30
+ }
31
+
32
+ export const ObjInteger = <T extends object>(customProps: ObjNumberProps<T>) => {
33
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsInteger;
34
+ const {
35
+ get, set, err, name,
36
+ ...props
37
+ } = defaultProps == null
38
+ ? customProps
39
+ : Object.assign({...defaultProps}, customProps);
40
+
41
+ const [value, setValue] = useObjToSingle<T, number>(name, get, set);
42
+
43
+ return (
44
+ <SingleInteger
45
+ get={value} set={setValue}
46
+ name={name?.toString()}
47
+ err={errorObjectToString(name, err)}
48
+ {...props}
49
+ />
50
+ )
51
+ }
@@ -1,29 +1,29 @@
1
- import {useContext} from "react";
2
- import {MfsObjectTextProps} from "../../../types";
3
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
- import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
5
- import {SingleText} from "../../Single/TextField/SingleText.tsx";
6
- import {errorObjectToString} from "../../../utils/object/error.ts";
7
- import {TextFieldProps} from "@mui/material";
8
-
9
-
10
- export const ObjText = <T extends object>(
11
- customProps: Omit<TextFieldProps, 'name'> & MfsObjectTextProps<T>
12
- ) => {
13
- const defaultProps = useContext(FastStartContext)?.Object?.MfsText;
14
- const {
15
- get, set, err, name,
16
- ...props
17
- } = defaultProps == null ? customProps : Object.assign({...defaultProps}, customProps);
18
-
19
- const [value, setValue] = useObjToSingle<T, string>(name, get, set);
20
-
21
- return (
22
- <SingleText
23
- get={value} set={setValue}
24
- name={name?.toString()}
25
- err={errorObjectToString(name, err)}
26
- {...props}
27
- />
28
- );
29
- };
1
+ import {useContext} from "react";
2
+ import {MfsObjectTextProps} from "../../../types";
3
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
+ import useObjToSingle from "../../../hooks/state/useObjToSingle.ts";
5
+ import {SingleText} from "../../Single/TextField/SingleText.tsx";
6
+ import {errorObjectToString} from "../../../utils/object/error.ts";
7
+ import {TextFieldProps} from "@mui/material";
8
+
9
+
10
+ export const ObjText = <T extends object>(
11
+ customProps: Omit<TextFieldProps, 'name'> & MfsObjectTextProps<T>
12
+ ) => {
13
+ const defaultProps = useContext(FastStartContext)?.Object?.MfsText;
14
+ const {
15
+ get, set, err, name,
16
+ ...props
17
+ } = defaultProps == null ? customProps : Object.assign({...defaultProps}, customProps);
18
+
19
+ const [value, setValue] = useObjToSingle<T, string>(name, get, set);
20
+
21
+ return (
22
+ <SingleText
23
+ get={value} set={setValue}
24
+ name={name?.toString()}
25
+ err={errorObjectToString(name, err)}
26
+ {...props}
27
+ />
28
+ );
29
+ };
@@ -1,27 +1,27 @@
1
- import {useCallback, useContext} from "react";
2
- import {IconButton, IconButtonProps} from "@mui/material";
3
- import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
- import {MfsSingleCheckIconProps} from "../../../types";
5
-
6
- export type SingleCheckIconProps = IconButtonProps & MfsSingleCheckIconProps;
7
-
8
- export const SingleCheckIcon = (customProps: SingleCheckIconProps) => {
9
- const defaultProps = useContext(FastStartContext)?.Single?.MfsCheckIcon;
10
- const {
11
- get, set, on, off,
12
- ...props
13
- } = defaultProps == null
14
- ? customProps
15
- : Object.assign({...defaultProps}, customProps);
16
-
17
- const onClick = useCallback(() => set((state) => !state), [set]);
18
-
19
- return (
20
- <IconButton
21
- onClick={onClick}
22
- {...props}
23
- >
24
- {get ? on : off}
25
- </IconButton>
26
- )
27
- }
1
+ import {useCallback, useContext} from "react";
2
+ import {IconButton, IconButtonProps} from "@mui/material";
3
+ import {FastStartContext} from "../../../styles/FastStartProvider.tsx";
4
+ import {MfsSingleCheckIconProps} from "../../../types";
5
+
6
+ export type SingleCheckIconProps = IconButtonProps & MfsSingleCheckIconProps;
7
+
8
+ export const SingleCheckIcon = (customProps: SingleCheckIconProps) => {
9
+ const defaultProps = useContext(FastStartContext)?.Single?.MfsCheckIcon;
10
+ const {
11
+ get, set, on, off,
12
+ ...props
13
+ } = defaultProps == null
14
+ ? customProps
15
+ : Object.assign({...defaultProps}, customProps);
16
+
17
+ const onClick = useCallback(() => set((state) => !state), [set]);
18
+
19
+ return (
20
+ <IconButton
21
+ onClick={onClick}
22
+ {...props}
23
+ >
24
+ {get ? on : off}
25
+ </IconButton>
26
+ )
27
+ }