react-form-manage 1.0.6-beta.0 → 1.0.6-beta.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/CHANGELOG.md +44 -0
- package/dist/components/Form/FormCleanUp.js +46 -0
- package/dist/components/Form/FormItem.js +46 -0
- package/dist/components/Form/FormList.js +11 -0
- package/dist/components/Form/InputWrapper.js +7 -0
- package/dist/components/Input.d.ts +4 -5
- package/dist/components/Input.js +8 -0
- package/dist/constants/validation.js +33 -0
- package/dist/contexts/FormContext.js +2 -0
- package/dist/hooks/useFormItemControl.js +390 -0
- package/dist/hooks/useFormListControl.js +280 -0
- package/dist/index.d.ts +8 -185
- package/dist/index.js +9 -0
- package/dist/providers/Form.js +322 -0
- package/dist/stores/formStore.js +304 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/public.d.ts +51 -0
- package/dist/utils/obj.util.js +24 -0
- package/package.json +30 -45
- package/src/App.css +49 -0
- package/src/App.tsx +36 -0
- package/src/assets/react.svg +1 -0
- package/src/components/Form/FormCleanUp.tsx +57 -0
- package/src/components/Form/FormItem.tsx +60 -0
- package/src/components/Form/FormList.tsx +13 -0
- package/src/components/Form/InputWrapper.tsx +17 -0
- package/src/components/Input.jsx +13 -0
- package/src/components/Input.tsx +21 -0
- package/src/constants/validation.ts +63 -0
- package/src/contexts/FormContext.ts +3 -0
- package/src/hooks/useFormItemControl.ts +558 -0
- package/src/hooks/useFormListControl.ts +378 -0
- package/src/index.css +68 -0
- package/src/index.ts +30 -0
- package/src/main.tsx +10 -0
- package/src/providers/Form.tsx +429 -0
- package/src/stores/formStore.ts +477 -0
- package/src/types/index.ts +1 -0
- package/src/types/public.ts +50 -0
- package/src/utils/obj.util.ts +42 -0
- package/dist/App.d.ts +0 -2
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.d.ts +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.esm.d.ts +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/src/types/components.d.ts +0 -135
- /package/dist/{main.d.ts → types/public.js} +0 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
import { cloneDeep, get, isNil } from "lodash";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { v4 } from "uuid";
|
|
4
|
+
import { useShallow } from "zustand/react/shallow";
|
|
5
|
+
import { useFormContext } from "../providers/Form";
|
|
6
|
+
import { useFormCleanUp, useFormStore } from "../stores/formStore";
|
|
7
|
+
|
|
8
|
+
import type { FormInstance } from "../stores/formStore";
|
|
9
|
+
|
|
10
|
+
type ListField = { name: string; key: string };
|
|
11
|
+
|
|
12
|
+
interface UseFormListControlProps {
|
|
13
|
+
name?: string;
|
|
14
|
+
form?: FormInstance;
|
|
15
|
+
initialValues?: any[];
|
|
16
|
+
formName?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface UseFormListControlReturn {
|
|
20
|
+
listFields: ListField[];
|
|
21
|
+
move: (opts: { from?: number; fromKey?: string; to: number }) => void;
|
|
22
|
+
add: (index: number) => void;
|
|
23
|
+
remove: (opts: { index?: number; key?: string }) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function useFormListControl<T = any>({
|
|
27
|
+
name,
|
|
28
|
+
form,
|
|
29
|
+
initialValues,
|
|
30
|
+
formName,
|
|
31
|
+
}: UseFormListControlProps): UseFormListControlReturn {
|
|
32
|
+
const contextForm = useFormContext();
|
|
33
|
+
const getFormValues = useFormStore((state) => state.getFormValues);
|
|
34
|
+
const [listFormInitValues, setListFormInitValues] = useState<any[] | undefined>(undefined);
|
|
35
|
+
const { clearCacheData, setCacheData } = useFormStore(
|
|
36
|
+
useShallow((state) => ({
|
|
37
|
+
cacheData: state.cacheData,
|
|
38
|
+
clearCacheData: state.clearCacheData,
|
|
39
|
+
setCacheData: state.setCacheData,
|
|
40
|
+
})),
|
|
41
|
+
);
|
|
42
|
+
const { setCleanUpStack } = useFormCleanUp(
|
|
43
|
+
useShallow((state) => ({
|
|
44
|
+
setCleanUpStack: state.setCleanUpStack,
|
|
45
|
+
})),
|
|
46
|
+
);
|
|
47
|
+
const { initValue: internalInitValue, formState } = useFormStore(
|
|
48
|
+
useShallow((state) => {
|
|
49
|
+
// console.log(
|
|
50
|
+
// "Shallow get initValue: ",
|
|
51
|
+
// formName || form?.formName || contextForm?.formName,
|
|
52
|
+
// name,
|
|
53
|
+
// get(
|
|
54
|
+
// state.initialValues,
|
|
55
|
+
// `${formName || form?.formName || contextForm?.formName}.${name}`
|
|
56
|
+
// )
|
|
57
|
+
// );
|
|
58
|
+
return {
|
|
59
|
+
initValue: get(
|
|
60
|
+
state.initialValues,
|
|
61
|
+
`${formName || form?.formName || contextForm?.formName}.${name}`,
|
|
62
|
+
),
|
|
63
|
+
formState: get(
|
|
64
|
+
state.formStates,
|
|
65
|
+
formName || form?.formName || contextForm?.formName,
|
|
66
|
+
),
|
|
67
|
+
setInitData: state.setInitData,
|
|
68
|
+
getFormState: state.getFormState,
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const [listFields, setListFields] = useState<ListField[]>([]);
|
|
74
|
+
|
|
75
|
+
const handleCacheListField = (prev: ListField[], cur: ListField[]) => {
|
|
76
|
+
const currentFormValues = cloneDeep(
|
|
77
|
+
getFormValues(formName || form?.formName || contextForm?.formName),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const formDataBeforeChange = get(currentFormValues, name);
|
|
81
|
+
|
|
82
|
+
const mapPrevWithKey = formDataBeforeChange
|
|
83
|
+
.map((d, index) => {
|
|
84
|
+
const findPrev = prev.find((p, pIndex) => pIndex === index);
|
|
85
|
+
|
|
86
|
+
if (!findPrev) return undefined;
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
key: findPrev.key,
|
|
90
|
+
value: d,
|
|
91
|
+
};
|
|
92
|
+
})
|
|
93
|
+
.filter(Boolean);
|
|
94
|
+
|
|
95
|
+
const mapCurWithKey = cur.map(
|
|
96
|
+
(c) => mapPrevWithKey.find((m) => m.key === c.key) || c,
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const getNewValueCache = mapCurWithKey.filter(Boolean).map((c) => c.value);
|
|
100
|
+
|
|
101
|
+
const startRemoveIndex =
|
|
102
|
+
formDataBeforeChange.length - getNewValueCache.length;
|
|
103
|
+
// console.log("Before list fields: ", prev);
|
|
104
|
+
// console.log("After list fields: ", cur);
|
|
105
|
+
// console.log("Before change arr value: ", formDataBeforeChange);
|
|
106
|
+
// console.log("Mapping prev value with prev fields: ", mapPrevWithKey);
|
|
107
|
+
// console.log("Mapping Cur value with prev fields: ", mapCurWithKey);
|
|
108
|
+
// console.log("After change arr value: ", getNewValueCache);
|
|
109
|
+
|
|
110
|
+
// Nếu số phần tử trước khi thay đổi mảng lớn hơn thì đẩy 2 phần tử còn lại vào clean up stack để clear
|
|
111
|
+
if (startRemoveIndex > 0) {
|
|
112
|
+
Array.from(Array(startRemoveIndex))
|
|
113
|
+
.map((_, index) => {
|
|
114
|
+
return getNewValueCache.length + index;
|
|
115
|
+
})
|
|
116
|
+
.forEach((index) => {
|
|
117
|
+
// console.log("Data for cleanup arr element: ", {
|
|
118
|
+
// formName: formName || form?.formName || contextForm?.formName,
|
|
119
|
+
// name: `${name}.${index}`,
|
|
120
|
+
// type: "array",
|
|
121
|
+
// });
|
|
122
|
+
setCleanUpStack({
|
|
123
|
+
formName: formName || form?.formName || contextForm?.formName,
|
|
124
|
+
name: `${name}.${index}`,
|
|
125
|
+
type: "array",
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// console.log({ getNewValueCache });
|
|
131
|
+
setCacheData(
|
|
132
|
+
formName || form?.formName || contextForm?.formName,
|
|
133
|
+
name,
|
|
134
|
+
getNewValueCache,
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const add = (index: number) => {
|
|
139
|
+
setListFields((prev) => {
|
|
140
|
+
if (index > prev.length) return prev;
|
|
141
|
+
|
|
142
|
+
if (index < 0) return prev;
|
|
143
|
+
|
|
144
|
+
if (index === prev.length) {
|
|
145
|
+
const newName = `${name}.${prev.length}`;
|
|
146
|
+
const newKey = v4();
|
|
147
|
+
const result = [
|
|
148
|
+
...prev,
|
|
149
|
+
{
|
|
150
|
+
name: newName,
|
|
151
|
+
key: newKey,
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const clonePrev = [...prev];
|
|
159
|
+
|
|
160
|
+
const result = clonePrev
|
|
161
|
+
.reduce((prev, cur, curIndex) => {
|
|
162
|
+
const newKey = v4();
|
|
163
|
+
if (curIndex === index)
|
|
164
|
+
return [
|
|
165
|
+
...prev,
|
|
166
|
+
{
|
|
167
|
+
key: newKey,
|
|
168
|
+
},
|
|
169
|
+
cur,
|
|
170
|
+
];
|
|
171
|
+
|
|
172
|
+
return [...prev, cur];
|
|
173
|
+
}, [])
|
|
174
|
+
.map((r, index) => ({
|
|
175
|
+
name: `${name}.${index}`,
|
|
176
|
+
key: r.key,
|
|
177
|
+
}));
|
|
178
|
+
handleCacheListField(prev, result);
|
|
179
|
+
return result;
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const remove = ({ index, key }: { index?: number; key?: string }) => {
|
|
184
|
+
setListFields((prev) => {
|
|
185
|
+
if (!isNil(key)) {
|
|
186
|
+
const clonePrev = [...prev];
|
|
187
|
+
|
|
188
|
+
const removedItem = clonePrev.filter((d) => d.key !== key);
|
|
189
|
+
|
|
190
|
+
console.log("Remove data: ", removedItem);
|
|
191
|
+
|
|
192
|
+
const result = removedItem.map((r, index) => ({
|
|
193
|
+
name: `${name}.${index}`,
|
|
194
|
+
key: r.key,
|
|
195
|
+
}));
|
|
196
|
+
handleCacheListField(prev, result);
|
|
197
|
+
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
if (!isNil(index)) {
|
|
201
|
+
if (index > prev.length - 1 || index < 0) return prev;
|
|
202
|
+
|
|
203
|
+
const clonePrev = [...prev];
|
|
204
|
+
|
|
205
|
+
clonePrev.splice(index, 1);
|
|
206
|
+
|
|
207
|
+
const result = clonePrev.map((r, index) => ({
|
|
208
|
+
name: `${name}.${index}`,
|
|
209
|
+
key: r.key,
|
|
210
|
+
}));
|
|
211
|
+
handleCacheListField(prev, result);
|
|
212
|
+
|
|
213
|
+
return result;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return prev;
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const move = ({ from, fromKey, to }: { from?: number; fromKey?: string; to: number }) => {
|
|
221
|
+
setListFields((prev) => {
|
|
222
|
+
console.log("move list item: ", { from, to });
|
|
223
|
+
if (
|
|
224
|
+
from >= listFields.length ||
|
|
225
|
+
from < 0 ||
|
|
226
|
+
to >= listFields.length ||
|
|
227
|
+
to < 0 ||
|
|
228
|
+
from === to
|
|
229
|
+
)
|
|
230
|
+
return prev;
|
|
231
|
+
console.log("Trigger move item: ");
|
|
232
|
+
|
|
233
|
+
if (!isNil(fromKey)) {
|
|
234
|
+
const findItemIndex = prev.findIndex((p) => p.key === fromKey);
|
|
235
|
+
if (findItemIndex < 0) return prev;
|
|
236
|
+
const moveItem = cloneDeep(listFields[findItemIndex]);
|
|
237
|
+
|
|
238
|
+
const result = prev
|
|
239
|
+
.reduce((prev, cur, curIndex) => {
|
|
240
|
+
if (findItemIndex === curIndex) return [...prev];
|
|
241
|
+
if (to === curIndex) {
|
|
242
|
+
if (findItemIndex > to) return [...prev, moveItem, cur];
|
|
243
|
+
else return [...prev, cur, moveItem];
|
|
244
|
+
} else {
|
|
245
|
+
return [...prev, cur];
|
|
246
|
+
}
|
|
247
|
+
}, [])
|
|
248
|
+
.map((i, index) => ({
|
|
249
|
+
key: i.key,
|
|
250
|
+
name: `${name}.${index}`,
|
|
251
|
+
}));
|
|
252
|
+
|
|
253
|
+
handleCacheListField(prev, result);
|
|
254
|
+
|
|
255
|
+
return result;
|
|
256
|
+
} else if (!isNil(from)) {
|
|
257
|
+
console.log("Trigger from index: ");
|
|
258
|
+
const moveItem = cloneDeep(listFields[from]);
|
|
259
|
+
|
|
260
|
+
const result = prev
|
|
261
|
+
.reduce((prev, cur, curIndex) => {
|
|
262
|
+
if (from === curIndex) return [...prev];
|
|
263
|
+
if (to === curIndex) {
|
|
264
|
+
if (from > to) return [...prev, moveItem, cur];
|
|
265
|
+
else return [...prev, cur, moveItem];
|
|
266
|
+
} else {
|
|
267
|
+
return [...prev, cur];
|
|
268
|
+
}
|
|
269
|
+
}, [])
|
|
270
|
+
.map((i, index) => ({
|
|
271
|
+
key: i.key,
|
|
272
|
+
name: `${name}.${index}`,
|
|
273
|
+
}));
|
|
274
|
+
|
|
275
|
+
console.log({ result });
|
|
276
|
+
|
|
277
|
+
handleCacheListField(prev, result);
|
|
278
|
+
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return prev;
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
useEffect(() => {
|
|
287
|
+
console.log("Trigger init", formState?.isInitied, internalInitValue);
|
|
288
|
+
if (formState?.isInitied) {
|
|
289
|
+
if (Array.isArray(listFormInitValues)) {
|
|
290
|
+
const result = listFormInitValues?.map((_, i) => {
|
|
291
|
+
const itemName = `${name}.${i}`;
|
|
292
|
+
const key = v4();
|
|
293
|
+
return {
|
|
294
|
+
key,
|
|
295
|
+
name: itemName,
|
|
296
|
+
};
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
console.log("Get local init values: ", listFormInitValues, result);
|
|
300
|
+
|
|
301
|
+
setListFields(result);
|
|
302
|
+
setCacheData(
|
|
303
|
+
formName || form?.formName || contextForm?.formName,
|
|
304
|
+
name,
|
|
305
|
+
listFormInitValues,
|
|
306
|
+
);
|
|
307
|
+
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
if (Array.isArray(internalInitValue)) {
|
|
312
|
+
const result = internalInitValue.map((_, i) => {
|
|
313
|
+
const itemName = `${name}.${i}`;
|
|
314
|
+
const key = v4();
|
|
315
|
+
return {
|
|
316
|
+
key,
|
|
317
|
+
name: itemName,
|
|
318
|
+
};
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
// console.log("Get form init values: ", internalInitValue, result);
|
|
322
|
+
|
|
323
|
+
setListFields(result);
|
|
324
|
+
setListFormInitValues(internalInitValue as any);
|
|
325
|
+
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// console.log({ initialValues });
|
|
330
|
+
|
|
331
|
+
// console.log("After init: ", { result: cloneDeep(result) });
|
|
332
|
+
|
|
333
|
+
if (Array.isArray(initialValues)) {
|
|
334
|
+
const result = initialValues.map((_, i) => {
|
|
335
|
+
const itemName = `${name}.${i}`;
|
|
336
|
+
const key = v4();
|
|
337
|
+
return {
|
|
338
|
+
key,
|
|
339
|
+
name: itemName,
|
|
340
|
+
};
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
if (initialValues) {
|
|
344
|
+
setCacheData(
|
|
345
|
+
formName || form?.formName || contextForm?.formName,
|
|
346
|
+
name,
|
|
347
|
+
initialValues,
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
setListFields(result);
|
|
352
|
+
setListFormInitValues(initialValues as any);
|
|
353
|
+
|
|
354
|
+
// console.log("Get form init values: ", internalInitValue, result);
|
|
355
|
+
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}, [formState?.isInitied]);
|
|
360
|
+
|
|
361
|
+
// useEffect(() => {
|
|
362
|
+
// console.log("Show form list init values: ", { internalInitValue });
|
|
363
|
+
// }, [internalInitValue]);
|
|
364
|
+
|
|
365
|
+
// useEffect(() => {
|
|
366
|
+
// console.log("List fields update: ", listFields);
|
|
367
|
+
// }, [listFields]);
|
|
368
|
+
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
// console.log({ listFields });
|
|
371
|
+
return () => {
|
|
372
|
+
// console.log("Cleanup listfield change");
|
|
373
|
+
clearCacheData();
|
|
374
|
+
};
|
|
375
|
+
}, [listFields]);
|
|
376
|
+
|
|
377
|
+
return { listFields, move, add, remove };
|
|
378
|
+
}
|
package/src/index.css
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
font-family: system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
3
|
+
line-height: 1.5;
|
|
4
|
+
font-weight: 400;
|
|
5
|
+
|
|
6
|
+
color-scheme: light dark;
|
|
7
|
+
color: rgba(255, 255, 255, 0.87);
|
|
8
|
+
background-color: #242424;
|
|
9
|
+
|
|
10
|
+
font-synthesis: none;
|
|
11
|
+
text-rendering: optimizeLegibility;
|
|
12
|
+
-webkit-font-smoothing: antialiased;
|
|
13
|
+
-moz-osx-font-smoothing: grayscale;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
a {
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #646cff;
|
|
19
|
+
text-decoration: inherit;
|
|
20
|
+
}
|
|
21
|
+
a:hover {
|
|
22
|
+
color: #535bf2;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
body {
|
|
26
|
+
margin: 0;
|
|
27
|
+
display: flex;
|
|
28
|
+
place-items: center;
|
|
29
|
+
min-width: 320px;
|
|
30
|
+
min-height: 100vh;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h1 {
|
|
34
|
+
font-size: 3.2em;
|
|
35
|
+
line-height: 1.1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
button {
|
|
39
|
+
border-radius: 8px;
|
|
40
|
+
border: 1px solid transparent;
|
|
41
|
+
padding: 0.6em 1.2em;
|
|
42
|
+
font-size: 1em;
|
|
43
|
+
font-weight: 500;
|
|
44
|
+
font-family: inherit;
|
|
45
|
+
background-color: #1a1a1a;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
transition: border-color 0.25s;
|
|
48
|
+
}
|
|
49
|
+
button:hover {
|
|
50
|
+
border-color: #646cff;
|
|
51
|
+
}
|
|
52
|
+
button:focus,
|
|
53
|
+
button:focus-visible {
|
|
54
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-color-scheme: light) {
|
|
58
|
+
:root {
|
|
59
|
+
color: #213547;
|
|
60
|
+
background-color: #ffffff;
|
|
61
|
+
}
|
|
62
|
+
a:hover {
|
|
63
|
+
color: #747bff;
|
|
64
|
+
}
|
|
65
|
+
button {
|
|
66
|
+
background-color: #f9f9f9;
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Form, {
|
|
2
|
+
useForm,
|
|
3
|
+
useWatch,
|
|
4
|
+
useSubmitDataWatch,
|
|
5
|
+
useFormStateWatch,
|
|
6
|
+
} from "./providers/Form";
|
|
7
|
+
|
|
8
|
+
import FormItem from "./components/Form/FormItem";
|
|
9
|
+
import FormList from "./components/Form/FormList";
|
|
10
|
+
import Input from "./components/Input";
|
|
11
|
+
import InputWrapper from "./components/Form/InputWrapper";
|
|
12
|
+
|
|
13
|
+
import useFormItemControl from "./hooks/useFormItemControl";
|
|
14
|
+
import useFormListControl from "./hooks/useFormListControl";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Form,
|
|
18
|
+
FormItem,
|
|
19
|
+
FormList,
|
|
20
|
+
Input,
|
|
21
|
+
InputWrapper,
|
|
22
|
+
useFormItemControl,
|
|
23
|
+
useFormListControl,
|
|
24
|
+
useForm,
|
|
25
|
+
useWatch,
|
|
26
|
+
useSubmitDataWatch,
|
|
27
|
+
useFormStateWatch,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default Form;
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createRoot } from "react-dom/client";
|
|
2
|
+
import App from "./App";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
|
|
5
|
+
const container = document.getElementById("root");
|
|
6
|
+
if (!container) {
|
|
7
|
+
throw new Error("Root container missing");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
createRoot(container).render(<App />);
|