mui-fast-start 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +73 -0
  2. package/dist/index.cjs.js +1 -0
  3. package/dist/index.esm.js +254 -0
  4. package/dist/types/components/Obj/Checkbox/ObjCheckIcon.d.ts +3 -0
  5. package/dist/types/components/Obj/Checkbox/ObjCheckbox.d.ts +3 -0
  6. package/dist/types/components/Obj/Textfield/ObjFloat.d.ts +3 -0
  7. package/dist/types/components/Obj/Textfield/ObjInteger.d.ts +3 -0
  8. package/dist/types/components/Obj/Textfield/ObjText.d.ts +3 -0
  9. package/dist/types/components/Single/Checkbox/SingleCheckIcon.d.ts +3 -0
  10. package/dist/types/components/Single/Checkbox/SingleCheckbox.d.ts +3 -0
  11. package/dist/types/components/Single/TextField/SingleFloat.d.ts +3 -0
  12. package/dist/types/components/Single/TextField/SingleInteger.d.ts +3 -0
  13. package/dist/types/components/Single/TextField/SingleText.d.ts +3 -0
  14. package/dist/types/components/index.d.ts +11 -0
  15. package/dist/types/hooks/index.d.ts +3 -0
  16. package/dist/types/hooks/splits/useSplitSingleNumberProps.d.ts +5 -0
  17. package/dist/types/hooks/splits/useSplitSingleTextProps.d.ts +4 -0
  18. package/dist/types/hooks/state/useObjToSingle.d.ts +4 -0
  19. package/dist/types/styles/FastStartProvider.d.ts +20 -0
  20. package/dist/types/styles/createDefaultProps.d.ts +3 -0
  21. package/dist/types/types/index.d.ts +3 -0
  22. package/dist/types/types/props.d.ts +38 -0
  23. package/dist/types/types/provider.d.ts +31 -0
  24. package/dist/types/types/types.d.ts +4 -0
  25. package/dist/types/utils/index.d.ts +2 -0
  26. package/dist/types/utils/number/calculate.d.ts +5 -0
  27. package/dist/types/utils/object/merge.d.ts +3 -0
  28. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);let l=require(`@mui/material`),u=require(`react/jsx-runtime`);var d=(e,t,n,r)=>{let i=0;if(e==null||h(e))i=r;else for(let t of e.split(/(?=[+-])/g))/^[+-]?\d+\.\d+$/.test(t)?i+=parseFloat(t):/^[+-]?\d+$/.test(t)&&(i+=parseInt(t,10));return n!=null&&(i=Math.min(n,i)),t!=null&&(i=Math.max(t,i)),i},f=(e,t,n,r)=>{let i=0;if(e==null||h(e))i=r;else for(let t of e.split(/(?=[+-])/g))/^[+-]?\d+$/.test(t)&&(i+=parseInt(t,10));return n!=null&&(i=Math.min(n,i)),t!=null&&(i=Math.max(t,i)),i},p=e=>{let t=e.replace(/[^0-9+.-]/g,``).replace(/([+-]){2,}/g,(e,t)=>t),n=``,r=``,i=!1;for(let e=0;e<t.length;e++){let a=t[e];a>=`0`&&a<=`9`?r+=a:a===`.`?i||=(r===``&&(r=`0`),r+=`.`,!0):(a===`+`||a===`-`)&&(r!==``&&(n+=r),n+=a,r=``,i=!1)}return n+r},m=e=>e.replace(/[^0-9+-]/g,``).replace(/\./g,``).replace(/([+-]){2,}/g,(e,t)=>t.charAt(0)).replace(/^([+-]{2,})/,e=>e.charAt(0));function h(e){return e.length===0||!e.trim()}function g(e){return typeof e==`object`&&!!e&&e.constructor===Object}function _(e){return Object.keys(e).length===0}function v(e,t){if(e===t||!g(t)||_(t))return e;if(!g(e)||_(e))return t;let n={...e},r=[[n,t]];for(;r.length;){let[e,t]=r.pop();for(let n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;let i=t[n],a=e[n];if(g(a)&&g(i)){let t={...a};e[n]=t,r.push([t,i])}else e[n]=i}}return n}var y=e=>{let t={fullWidth:!0,autoComplete:`off`,variant:`outlined`,size:`small`},n=Object.assign({inputMode:`decimal`,type:`text`,step:.01,def:0},t),r=Object.assign({inputMode:`numeric`,type:`text`,step:1,def:0},t);return v({Single:{Float:{...n},Integer:{...r},Text:{...t},Checkbox:{size:`small`},CheckIcon:{size:`small`}},Obj:{Float:{...n},Integer:{...r},Text:{...t},Checkbox:{size:`small`},CheckIcon:{size:`small`}}},e)},b=y;const x=(0,c.createContext)(b());var S=(e,t,n)=>[t?.[e],(0,c.useCallback)(t=>{n(n=>({...n,[e]:typeof t==`function`?t(n?.[e]):t}))},[e,n])],C=S,w=e=>{let t=(0,c.useContext)(x).Obj.Checkbox,{get:n,set:r,...i}=v(t,e),[a,o]=C(i.name,n,r);return(0,u.jsx)(G,{get:a,set:o,...i})},T=w,E=e=>{let t=(0,c.useContext)(x).Obj.CheckIcon,{get:n,set:r,...i}=v(t,e),[a,o]=C(i.name,n,r);return(0,u.jsx)(q,{get:a,set:o,...i})},D=E,O=e=>{let t=(0,c.useContext)(x).Obj.Float,{get:n,set:r,...i}=v(t,e),[a,o]=C(i.name,n,r);return(0,u.jsx)(Y,{get:a,set:o,...i})},k=O,A=(e,t,n,r,i=[])=>{let[a,o]=(0,c.useState)(null),{get:s,set:l,errorData:u,minLength:d,maxLength:f,startAdornment:p,endAdornment:m,disappear:h,def:g,min:_,max:y,step:b,...x}=(0,c.useMemo)(()=>v({...e},t),[e,t]),S=(0,c.useCallback)(e=>r(e,_,y,g),[r,_,y,g]),C=(0,c.useCallback)(e=>{let{value:t,valueAsNumber:n}=e.currentTarget;return isNaN(n)?S(t):n},[S]),w=(0,c.useCallback)(e=>{let t=e.currentTarget,r=n(t.value);return r!=t.value&&(t.value=r),r},[n]),T=(0,c.useCallback)(()=>{a??o(s.toString())},[a,s]),E=(0,c.useCallback)(e=>{let t=S(w(e));!isNaN(t)&&s!=t&&l(t),o(e.currentTarget.value)},[w,S,l,s]),D=(0,c.useCallback)(e=>{let{value:t}=e.currentTarget;o(null);let n=S(t);s!=n&&l(n)},[S,s,l]),O=(0,c.useCallback)(e=>{if(i.includes(e.key)){e.preventDefault();return}let t=e.currentTarget;if(e.key===`ArrowUp`){e.preventDefault();let n=C(e)+b;y!=null&&n>y?t.value=y.toString():t.value=j(n,b).toString()}else if(e.key===`ArrowDown`){e.preventDefault();let n=C(e)-b;_!=null&&n<_?t.value=_.toString():t.value=j(n,b).toString()}},[C,y,_,b]),k=(0,c.useMemo)(()=>a??s,[s,a]),A=(0,c.useMemo)(()=>a==null&&(s==null||isNaN(s))?{}:{shrink:!0},[a,s]);return v({error:!!u,helperText:u,value:k,onChange:E,onSelect:T,onBlur:D,slotProps:{htmlInput:{step:b,min:_,max:y,minLength:d,maxLength:f,onKeyDown:O},inputLabel:A,input:{startAdornment:p,endAdornment:m}}},x)},j=(e,t)=>{if(t=Math.abs(t),t===0)return e;let n=-Math.floor(Math.log10(t));return n>0?Number(Math.round(e*10**n)/10**n):e},M=(e,t)=>A(e,t,p,d),N=(e,t)=>A(e,t,m,f,[`.`,`e`,`E`]),P=(e,t)=>{let{get:n,set:r,errorData:i,minLength:a,maxLength:o,startAdornment:s,endAdornment:l,...u}=v({...e},t),d=(0,c.useCallback)(e=>{r(e.currentTarget.value)},[r]);return v({error:!!i,helperText:i,value:n,onChange:d,slotProps:{htmlInput:{minLength:a,maxLength:o},input:{startAdornment:s,endAdornment:l}}},u)},F=P,I=e=>{let t=(0,c.useContext)(x).Single.Integer;return(0,u.jsx)(l.TextField,{...N(t,e)})},L=I,R=e=>{let t=(0,c.useContext)(x).Obj.Integer,{get:n,set:r,...i}=v(t,e),[a,o]=C(i.name,n,r);return(0,u.jsx)(L,{get:a,set:o,...i})},z=R,B=e=>{let t=(0,c.useContext)(x).Single.Text;return(0,u.jsx)(l.TextField,{...F(t,e)})},V=B,H=e=>{let t=(0,c.useContext)(x).Obj.Text,{get:n,set:r,...i}=v(t,e),[a,o]=C(i.name,n,r);return(0,u.jsx)(V,{get:a,set:o,...i})},U=H,W=e=>{let t=(0,c.useContext)(x).Single.Checkbox,{get:n,set:r,label:i,...a}=v(t,e),o=(0,c.useCallback)(()=>r(e=>!e),[r]);return i==null?(0,u.jsx)(l.Checkbox,{checked:n,onChange:o,...a}):(0,u.jsx)(l.FormControlLabel,{checked:n,label:i,onChange:o,control:(0,u.jsx)(l.Checkbox,{...a})})},G=W,K=e=>{let t=(0,c.useContext)(x).Single.CheckIcon,{get:n,set:r,on:i,off:a,...o}=v(t,e);return(0,u.jsx)(l.IconButton,{onClick:(0,c.useCallback)(()=>r(e=>!e),[r]),...o,children:n?i:a})},q=K,J=e=>{let t=(0,c.useContext)(x).Single.Float;return(0,u.jsx)(l.TextField,{...M(t,e)})},Y=J;exports.ObjCheckIcon=D,exports.ObjCheckbox=T,exports.ObjFloat=k,exports.ObjInteger=z,exports.ObjText=U,exports.SingleCheckIcon=q,exports.SingleCheckbox=G,exports.SingleFloat=Y,exports.SingleInteger=L,exports.SingleText=V;
@@ -0,0 +1,254 @@
1
+ import { createContext, useCallback, useContext, useMemo, useState } from "react";
2
+ import { Checkbox, FormControlLabel, IconButton, TextField } from "@mui/material";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var floatCalculate = (n, i, a, o) => {
5
+ let s = 0;
6
+ if (n == null || isEmpty$1(n)) s = o;
7
+ else for (let i of n.split(/(?=[+-])/g)) /^[+-]?\d+\.\d+$/.test(i) ? s += parseFloat(i) : /^[+-]?\d+$/.test(i) && (s += parseInt(i, 10));
8
+ return a != null && (s = Math.min(a, s)), i != null && (s = Math.max(i, s)), s;
9
+ }, integerCalculate = (n, i, a, o) => {
10
+ let s = 0;
11
+ if (n == null || isEmpty$1(n)) s = o;
12
+ else for (let i of n.split(/(?=[+-])/g)) /^[+-]?\d+$/.test(i) && (s += parseInt(i, 10));
13
+ return a != null && (s = Math.min(a, s)), i != null && (s = Math.max(i, s)), s;
14
+ }, processFloat = (n) => {
15
+ let i = n.replace(/[^0-9+.-]/g, "").replace(/([+-]){2,}/g, (n, i) => i), a = "", o = "", s = !1;
16
+ for (let n = 0; n < i.length; n++) {
17
+ let c = i[n];
18
+ c >= "0" && c <= "9" ? o += c : c === "." ? s ||= (o === "" && (o = "0"), o += ".", !0) : (c === "+" || c === "-") && (o !== "" && (a += o), a += c, o = "", s = !1);
19
+ }
20
+ return a + o;
21
+ }, processInteger = (n) => n.replace(/[^0-9+-]/g, "").replace(/\./g, "").replace(/([+-]){2,}/g, (n, i) => i.charAt(0)).replace(/^([+-]{2,})/, (n) => n.charAt(0));
22
+ function isEmpty$1(n) {
23
+ return n.length === 0 || !n.trim();
24
+ }
25
+ function isPlainObject(n) {
26
+ return typeof n == "object" && !!n && n.constructor === Object;
27
+ }
28
+ function isEmpty(n) {
29
+ return Object.keys(n).length === 0;
30
+ }
31
+ function fastDeepMerge(n, i) {
32
+ if (n === i || !isPlainObject(i) || isEmpty(i)) return n;
33
+ if (!isPlainObject(n) || isEmpty(n)) return i;
34
+ let a = { ...n }, o = [[a, i]];
35
+ for (; o.length;) {
36
+ let [n, i] = o.pop();
37
+ for (let a in i) {
38
+ if (!Object.prototype.hasOwnProperty.call(i, a)) continue;
39
+ let s = i[a], c = n[a];
40
+ if (isPlainObject(c) && isPlainObject(s)) {
41
+ let i = { ...c };
42
+ n[a] = i, o.push([i, s]);
43
+ } else n[a] = s;
44
+ }
45
+ }
46
+ return a;
47
+ }
48
+ const FastStartContext = createContext(((n) => {
49
+ let i = {
50
+ fullWidth: !0,
51
+ autoComplete: "off",
52
+ variant: "outlined",
53
+ size: "small"
54
+ }, a = Object.assign({
55
+ inputMode: "decimal",
56
+ type: "text",
57
+ step: .01,
58
+ def: 0
59
+ }, i), o = Object.assign({
60
+ inputMode: "numeric",
61
+ type: "text",
62
+ step: 1,
63
+ def: 0
64
+ }, i);
65
+ return fastDeepMerge({
66
+ Single: {
67
+ Float: { ...a },
68
+ Integer: { ...o },
69
+ Text: { ...i },
70
+ Checkbox: { size: "small" },
71
+ CheckIcon: { size: "small" }
72
+ },
73
+ Obj: {
74
+ Float: { ...a },
75
+ Integer: { ...o },
76
+ Text: { ...i },
77
+ Checkbox: { size: "small" },
78
+ CheckIcon: { size: "small" }
79
+ }
80
+ }, n);
81
+ })());
82
+ var useObjToSingle_default = (n, a, o) => [a?.[n], useCallback((i) => {
83
+ o((a) => ({
84
+ ...a,
85
+ [n]: typeof i == "function" ? i(a?.[n]) : i
86
+ }));
87
+ }, [n, o])], ObjCheckbox_default = (n) => {
88
+ let i = useContext(FastStartContext).Obj.Checkbox, { get: o, set: s, ...c } = fastDeepMerge(i, n), [l, u] = useObjToSingle_default(c.name, o, s);
89
+ return /* @__PURE__ */ jsx(SingleCheckbox_default, {
90
+ get: l,
91
+ set: u,
92
+ ...c
93
+ });
94
+ }, ObjCheckIcon_default = (n) => {
95
+ let i = useContext(FastStartContext).Obj.CheckIcon, { get: o, set: s, ...c } = fastDeepMerge(i, n), [l, u] = useObjToSingle_default(c.name, o, s);
96
+ return /* @__PURE__ */ jsx(SingleCheckIcon_default, {
97
+ get: l,
98
+ set: u,
99
+ ...c
100
+ });
101
+ }, ObjFloat_default = (n) => {
102
+ let i = useContext(FastStartContext).Obj.Float, { get: o, set: s, ...c } = fastDeepMerge(i, n), [l, u] = useObjToSingle_default(c.name, o, s);
103
+ return /* @__PURE__ */ jsx(SingleFloat_default, {
104
+ get: l,
105
+ set: u,
106
+ ...c
107
+ });
108
+ }, useSplitSingleNumberProps = (n, a, c, l, u = []) => {
109
+ let [d, f] = useState(null), { get: p, set: m, errorData: h, minLength: g, maxLength: _, startAdornment: v, endAdornment: y, disappear: b, def: x, min: S, max: C, step: w, ...T } = useMemo(() => fastDeepMerge({ ...n }, a), [n, a]), E = useCallback((n) => l(n, S, C, x), [
110
+ l,
111
+ S,
112
+ C,
113
+ x
114
+ ]), D = useCallback((n) => {
115
+ let { value: i, valueAsNumber: a } = n.currentTarget;
116
+ return isNaN(a) ? E(i) : a;
117
+ }, [E]), O = useCallback((n) => {
118
+ let i = n.currentTarget, a = c(i.value);
119
+ return a != i.value && (i.value = a), a;
120
+ }, [c]), k = useCallback(() => {
121
+ d ?? f(p.toString());
122
+ }, [d, p]), A = useCallback((n) => {
123
+ let i = E(O(n));
124
+ !isNaN(i) && p != i && m(i), f(n.currentTarget.value);
125
+ }, [
126
+ O,
127
+ E,
128
+ m,
129
+ p
130
+ ]), j = useCallback((n) => {
131
+ let { value: i } = n.currentTarget;
132
+ f(null);
133
+ let a = E(i);
134
+ p != a && m(a);
135
+ }, [
136
+ E,
137
+ p,
138
+ m
139
+ ]), M = useCallback((n) => {
140
+ if (u.includes(n.key)) {
141
+ n.preventDefault();
142
+ return;
143
+ }
144
+ let i = n.currentTarget;
145
+ if (n.key === "ArrowUp") {
146
+ n.preventDefault();
147
+ let a = D(n) + w;
148
+ C != null && a > C ? i.value = C.toString() : i.value = digitRound(a, w).toString();
149
+ } else if (n.key === "ArrowDown") {
150
+ n.preventDefault();
151
+ let a = D(n) - w;
152
+ S != null && a < S ? i.value = S.toString() : i.value = digitRound(a, w).toString();
153
+ }
154
+ }, [
155
+ D,
156
+ C,
157
+ S,
158
+ w
159
+ ]), N = useMemo(() => d ?? p, [p, d]), P = useMemo(() => d == null && (p == null || isNaN(p)) ? {} : { shrink: !0 }, [d, p]);
160
+ return fastDeepMerge({
161
+ error: !!h,
162
+ helperText: h,
163
+ value: N,
164
+ onChange: A,
165
+ onSelect: k,
166
+ onBlur: j,
167
+ slotProps: {
168
+ htmlInput: {
169
+ step: w,
170
+ min: S,
171
+ max: C,
172
+ minLength: g,
173
+ maxLength: _,
174
+ onKeyDown: M
175
+ },
176
+ inputLabel: P,
177
+ input: {
178
+ startAdornment: v,
179
+ endAdornment: y
180
+ }
181
+ }
182
+ }, T);
183
+ }, digitRound = (n, i) => {
184
+ if (i = Math.abs(i), i === 0) return n;
185
+ let a = -Math.floor(Math.log10(i));
186
+ return a > 0 ? Number(Math.round(n * 10 ** a) / 10 ** a) : n;
187
+ }, useSplitSingleFloatProps = (n, i) => useSplitSingleNumberProps(n, i, processFloat, floatCalculate), useSplitSingleIntegerProps = (n, i) => useSplitSingleNumberProps(n, i, processInteger, integerCalculate, [
188
+ ".",
189
+ "e",
190
+ "E"
191
+ ]), useSplitSingleTextProps_default = (n, a) => {
192
+ let { get: o, set: s, errorData: c, minLength: l, maxLength: u, startAdornment: d, endAdornment: f, ...p } = fastDeepMerge({ ...n }, a), m = useCallback((n) => {
193
+ s(n.currentTarget.value);
194
+ }, [s]);
195
+ return fastDeepMerge({
196
+ error: !!c,
197
+ helperText: c,
198
+ value: o,
199
+ onChange: m,
200
+ slotProps: {
201
+ htmlInput: {
202
+ minLength: l,
203
+ maxLength: u
204
+ },
205
+ input: {
206
+ startAdornment: d,
207
+ endAdornment: f
208
+ }
209
+ }
210
+ }, p);
211
+ }, SingleInteger_default = (n) => {
212
+ let i = useContext(FastStartContext).Single.Integer;
213
+ return /* @__PURE__ */ jsx(TextField, { ...useSplitSingleIntegerProps(i, n) });
214
+ }, ObjInteger_default = (n) => {
215
+ let i = useContext(FastStartContext).Obj.Integer, { get: o, set: s, ...c } = fastDeepMerge(i, n), [l, u] = useObjToSingle_default(c.name, o, s);
216
+ return /* @__PURE__ */ jsx(SingleInteger_default, {
217
+ get: l,
218
+ set: u,
219
+ ...c
220
+ });
221
+ }, SingleText_default = (n) => {
222
+ let i = useContext(FastStartContext).Single.Text;
223
+ return /* @__PURE__ */ jsx(TextField, { ...useSplitSingleTextProps_default(i, n) });
224
+ }, ObjText_default = (n) => {
225
+ let i = useContext(FastStartContext).Obj.Text, { get: o, set: s, ...c } = fastDeepMerge(i, n), [l, u] = useObjToSingle_default(c.name, o, s);
226
+ return /* @__PURE__ */ jsx(SingleText_default, {
227
+ get: l,
228
+ set: u,
229
+ ...c
230
+ });
231
+ }, SingleCheckbox_default = (n) => {
232
+ let o = useContext(FastStartContext).Single.Checkbox, { get: s, set: u, label: d, ...p } = fastDeepMerge(o, n), m = useCallback(() => u((n) => !n), [u]);
233
+ return d == null ? /* @__PURE__ */ jsx(Checkbox, {
234
+ checked: s,
235
+ onChange: m,
236
+ ...p
237
+ }) : /* @__PURE__ */ jsx(FormControlLabel, {
238
+ checked: s,
239
+ label: d,
240
+ onChange: m,
241
+ control: /* @__PURE__ */ jsx(Checkbox, { ...p })
242
+ });
243
+ }, SingleCheckIcon_default = (n) => {
244
+ let o = useContext(FastStartContext).Single.CheckIcon, { get: s, set: c, on: l, off: d, ...p } = fastDeepMerge(o, n);
245
+ return /* @__PURE__ */ jsx(IconButton, {
246
+ onClick: useCallback(() => c((n) => !n), [c]),
247
+ ...p,
248
+ children: s ? l : d
249
+ });
250
+ }, SingleFloat_default = (n) => {
251
+ let i = useContext(FastStartContext).Single.Float;
252
+ return /* @__PURE__ */ jsx(TextField, { ...useSplitSingleFloatProps(i, n) });
253
+ };
254
+ export { ObjCheckIcon_default as ObjCheckIcon, ObjCheckbox_default as ObjCheckbox, ObjFloat_default as ObjFloat, ObjInteger_default as ObjInteger, ObjText_default as ObjText, SingleCheckIcon_default as SingleCheckIcon, SingleCheckbox_default as SingleCheckbox, SingleFloat_default as SingleFloat, SingleInteger_default as SingleInteger, SingleText_default as SingleText };
@@ -0,0 +1,3 @@
1
+ import type { ObjCheckIconProps } from "../../../types";
2
+ declare const ObjCheckIcon: <T extends object>(customProps: ObjCheckIconProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default ObjCheckIcon;
@@ -0,0 +1,3 @@
1
+ import type { ObjCheckboxProps } from "../../../types";
2
+ declare const ObjCheckbox: <T extends object>(customProps: ObjCheckboxProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default ObjCheckbox;
@@ -0,0 +1,3 @@
1
+ import type { ObjNumberProps } from "../../../types";
2
+ declare const ObjFloat: <T extends object>(customProps: ObjNumberProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default ObjFloat;
@@ -0,0 +1,3 @@
1
+ import type { ObjNumberProps } from "../../../types";
2
+ declare const ObjInteger: <T extends object>(customProps: ObjNumberProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default ObjInteger;
@@ -0,0 +1,3 @@
1
+ import type { ObjTextProps } from "../../../types";
2
+ declare const ObjText: <T extends object>(customProps: ObjTextProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ export default ObjText;
@@ -0,0 +1,3 @@
1
+ import type { SingleCheckIconProps } from "../../../types";
2
+ declare const SingleCheckIcon: (customProps: SingleCheckIconProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SingleCheckIcon;
@@ -0,0 +1,3 @@
1
+ import type { SingleCheckboxProps } from "../../../types";
2
+ declare const SingleCheckbox: (customProps: SingleCheckboxProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SingleCheckbox;
@@ -0,0 +1,3 @@
1
+ import type { SingleNumberProps } from "../../../types";
2
+ declare const SingleFloat: (customProps: SingleNumberProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SingleFloat;
@@ -0,0 +1,3 @@
1
+ import type { SingleNumberProps } from "../../../types";
2
+ declare const SingleInteger: (customProps: SingleNumberProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SingleInteger;
@@ -0,0 +1,3 @@
1
+ import type { SingleTextProps } from "../../../types";
2
+ declare const SingleText: (customProps: SingleTextProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default SingleText;
@@ -0,0 +1,11 @@
1
+ export type { SingleNumberProps, SingleTextProps, SingleCheckboxProps, SingleCheckIconProps } from '../types';
2
+ export { default as ObjCheckbox } from './Obj/Checkbox/ObjCheckbox';
3
+ export { default as ObjCheckIcon } from './Obj/Checkbox/ObjCheckIcon';
4
+ export { default as ObjFloat } from './Obj/Textfield/ObjFloat';
5
+ export { default as ObjInteger } from './Obj/Textfield/ObjInteger';
6
+ export { default as ObjText } from './Obj/Textfield/ObjText';
7
+ export { default as SingleCheckbox } from './Single/Checkbox/SingleCheckbox';
8
+ export { default as SingleCheckIcon } from './Single/Checkbox/SingleCheckIcon';
9
+ export { default as SingleFloat } from './Single/TextField/SingleFloat';
10
+ export { default as SingleInteger } from './Single/TextField/SingleInteger';
11
+ export { default as SingleText } from './Single/TextField/SingleText';
@@ -0,0 +1,3 @@
1
+ export * from './splits/useSplitSingleNumberProps';
2
+ export * from './splits/useSplitSingleTextProps';
3
+ export * from './state/useObjToSingle';
@@ -0,0 +1,5 @@
1
+ import type { SingleNumberProps } from "../../types";
2
+ import type { TextFieldProps } from "@mui/material";
3
+ declare const useSplitSingleFloatProps: (defaultProps: SingleNumberProps, customProps: SingleNumberProps) => TextFieldProps;
4
+ declare const useSplitSingleIntegerProps: (defaultProps: SingleNumberProps, customProps: SingleNumberProps) => TextFieldProps;
5
+ export { useSplitSingleFloatProps, useSplitSingleIntegerProps };
@@ -0,0 +1,4 @@
1
+ import type { SingleTextProps } from "../../types";
2
+ import type { TextFieldProps } from "@mui/material";
3
+ declare const useSplitSingleTextProps: (defaultProps: SingleTextProps, customProps: SingleTextProps) => TextFieldProps;
4
+ export default useSplitSingleTextProps;
@@ -0,0 +1,4 @@
1
+ import type { KeysWithValue } from "../../types";
2
+ import type { Dispatch, SetStateAction } from "react";
3
+ declare const useObjToSingle: <Type extends object, Target>(name: KeysWithValue<Type, Target> | string, get: Type, set: Dispatch<SetStateAction<Type>>) => [Target, Dispatch<SetStateAction<Target>>];
4
+ export default useObjToSingle;
@@ -0,0 +1,20 @@
1
+ import type { FastStartProviderProps } from "../types";
2
+ import { type Theme } from "@mui/material";
3
+ export declare const FastStartContext: import("react").Context<import("../types").DeepPartial<{
4
+ Single: {
5
+ Float: import("../types").SingleNumberProps;
6
+ Integer: import("../types").SingleNumberProps;
7
+ Text: import("../types").SingleTextProps;
8
+ Checkbox: import("../types").SingleCheckboxProps;
9
+ CheckIcon: import("../types").SingleCheckIconProps;
10
+ };
11
+ Obj: {
12
+ Float: import("../types").ObjNumberProps<object>;
13
+ Integer: import("../types").ObjNumberProps<object>;
14
+ Text: import("../types").ObjTextProps<object>;
15
+ Checkbox: import("../types").ObjCheckboxProps<object>;
16
+ CheckIcon: import("../types").ObjCheckIconProps<object>;
17
+ };
18
+ }>>;
19
+ declare const FastStartProvider: <T = Theme>(props: FastStartProviderProps<T>) => import("react/jsx-runtime").JSX.Element;
20
+ export default FastStartProvider;
@@ -0,0 +1,3 @@
1
+ import type { FastStartDefaultProps } from "../types";
2
+ declare const createDefaultProps: (props?: FastStartDefaultProps | undefined) => FastStartDefaultProps;
3
+ export default createDefaultProps;
@@ -0,0 +1,3 @@
1
+ export * from './props';
2
+ export * from './types';
3
+ export * from './provider';
@@ -0,0 +1,38 @@
1
+ import type { SlotProps, TextFieldOwnerState } from "@mui/material";
2
+ import type { Dispatch, SetStateAction } from "react";
3
+ import * as React from "react";
4
+ import type { InputBaseProps } from "@mui/material/InputBase";
5
+ import type { InputLabelProps } from "@mui/material/InputLabel";
6
+ type HtmlInputType = SlotProps<React.ElementType<InputBaseProps['inputProps']>, {}, TextFieldOwnerState>;
7
+ type InputLabelType = SlotProps<React.ElementType<InputLabelProps>, {}, TextFieldOwnerState>;
8
+ type KeysWithValue<Type extends object, Target> = {
9
+ [K in keyof Type]: Type[K] extends Target ? K : never;
10
+ }[keyof Type];
11
+ interface BaseProps<Type, Error> {
12
+ get: Type;
13
+ set: Dispatch<SetStateAction<Type>>;
14
+ label?: React.ReactNode;
15
+ errorData?: Error;
16
+ }
17
+ type BasePropertyProps<TYPE> = BaseProps<TYPE, string>;
18
+ interface BaseObjectProps<Type extends object, Target> extends BaseProps<Type, Partial<Type> | object> {
19
+ name: KeysWithValue<Type, Target> | string;
20
+ }
21
+ interface BaseTextProps {
22
+ minLength?: number;
23
+ maxLength?: number;
24
+ startAdornment?: React.ReactNode;
25
+ endAdornment?: React.ReactNode;
26
+ }
27
+ interface BaseCheckIconProps {
28
+ on: React.ReactNode;
29
+ off: React.ReactNode;
30
+ }
31
+ interface BaseNumberProps extends BaseTextProps {
32
+ disappear?: boolean;
33
+ def?: number;
34
+ min?: number;
35
+ max?: number;
36
+ step?: number;
37
+ }
38
+ export type { KeysWithValue, HtmlInputType, InputLabelType, BasePropertyProps, BaseObjectProps, BaseTextProps, BaseCheckIconProps, BaseNumberProps, };
@@ -0,0 +1,31 @@
1
+ import type { CheckboxProps, IconButtonProps, TextFieldProps, ThemeProviderProps } from "@mui/material";
2
+ import type { BaseCheckIconProps, BaseNumberProps, BaseObjectProps, BasePropertyProps, BaseTextProps } from './props';
3
+ import type { DeepPartial } from './types';
4
+ export type SingleNumberProps = TextFieldProps & BaseNumberProps & BasePropertyProps<number>;
5
+ export type SingleTextProps = TextFieldProps & BaseTextProps & BasePropertyProps<string>;
6
+ export type SingleCheckboxProps = CheckboxProps & Omit<BasePropertyProps<boolean>, 'errorData'>;
7
+ export type SingleCheckIconProps = IconButtonProps & BaseCheckIconProps & Omit<BasePropertyProps<boolean>, 'errorData' | 'label'>;
8
+ export type ObjNumberProps<T extends object> = Omit<TextFieldProps, 'name'> & BaseNumberProps & BaseObjectProps<T, number>;
9
+ export type ObjTextProps<T extends object> = Omit<TextFieldProps, 'name'> & BaseTextProps & BaseObjectProps<T, string>;
10
+ export type ObjCheckboxProps<T extends object> = Omit<CheckboxProps, 'name'> & Omit<BaseObjectProps<T, boolean>, 'errorData'>;
11
+ export type ObjCheckIconProps<T extends object> = Omit<IconButtonProps, 'name'> & BaseCheckIconProps & Omit<BaseObjectProps<T, boolean>, 'errorData' | 'label'>;
12
+ type FastStartDefaultProps = DeepPartial<{
13
+ Single: {
14
+ Float: SingleNumberProps;
15
+ Integer: SingleNumberProps;
16
+ Text: SingleTextProps;
17
+ Checkbox: SingleCheckboxProps;
18
+ CheckIcon: SingleCheckIconProps;
19
+ };
20
+ Obj: {
21
+ Float: ObjNumberProps<object>;
22
+ Integer: ObjNumberProps<object>;
23
+ Text: ObjTextProps<object>;
24
+ Checkbox: ObjCheckboxProps<object>;
25
+ CheckIcon: ObjCheckIconProps<object>;
26
+ };
27
+ }>;
28
+ interface FastStartProviderProps<Theme> extends ThemeProviderProps<Theme> {
29
+ defaultProps: FastStartDefaultProps;
30
+ }
31
+ export type { FastStartDefaultProps, FastStartProviderProps, };
@@ -0,0 +1,4 @@
1
+ type DeepPartial<T> = {
2
+ [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K];
3
+ };
4
+ export type { DeepPartial };
@@ -0,0 +1,2 @@
1
+ export * from './number/calculate';
2
+ export * from './object/merge';
@@ -0,0 +1,5 @@
1
+ declare const floatCalculate: (value: string | null, min: number, max: number, def: number) => number;
2
+ declare const integerCalculate: (value: string | null, min: number, max: number, def: number) => number;
3
+ declare const processFloat: (text: string) => string;
4
+ declare const processInteger: (text: string) => string;
5
+ export { floatCalculate, integerCalculate, processFloat, processInteger };
@@ -0,0 +1,3 @@
1
+ import type { DeepPartial } from "../../types";
2
+ declare function fastDeepMerge<T extends object>(target: DeepPartial<T>, source: T): T;
3
+ export { fastDeepMerge };
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "mui-fast-start",
3
+ "version": "0.1.0",
4
+ "description": "Fast and easy-to-use MUI components for React",
5
+ "keywords": ["mui", "material-ui", "react", "components", "form"],
6
+ "author": "PersesTitan",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/VaneProject/mui-fast-start"
11
+ },
12
+ "type": "module",
13
+ "main": "dist/index.cjs.js",
14
+ "module": "dist/index.esm.js",
15
+ "types": "dist/types/components/index.d.ts",
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "sideEffects": false,
21
+ "scripts": {
22
+ "dev": "vite",
23
+ "build": "vite build && tsc -p tsconfig.lib.json",
24
+ "lint": "eslint .",
25
+ "preview": "vite preview",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/index.esm.js",
31
+ "require": "./dist/index.cjs.js",
32
+ "types": "./dist/types/components/index.d.ts"
33
+ }
34
+ },
35
+ "peerDependencies": {
36
+ "react": ">=18",
37
+ "react-dom": ">=18",
38
+ "@mui/material": ">=6",
39
+ "@emotion/react": ">=11",
40
+ "@emotion/styled": ">=11"
41
+ },
42
+ "devDependencies": {
43
+ "@emotion/react": "^11.14.0",
44
+ "@emotion/styled": "^11.14.1",
45
+ "@eslint/js": "^9.39.1",
46
+ "@mui/material": "^7.1.1",
47
+ "@types/node": "^24.10.1",
48
+ "@types/react": "^19.2.5",
49
+ "@types/react-dom": "^19.2.3",
50
+ "@vitejs/plugin-react": "^5.1.1",
51
+ "eslint": "^9.39.1",
52
+ "eslint-plugin-react-hooks": "^7.0.1",
53
+ "eslint-plugin-react-refresh": "^0.4.24",
54
+ "globals": "^16.5.0",
55
+ "react": "^19.2.0",
56
+ "react-dom": "^19.2.0",
57
+ "typescript": "~5.9.3",
58
+ "typescript-eslint": "^8.46.4",
59
+ "vite": "npm:rolldown-vite@7.2.5"
60
+ },
61
+ "overrides": {
62
+ "vite": "npm:rolldown-vite@7.2.5"
63
+ }
64
+ }