@goodie-forms/react 1.1.5-alpha → 1.2.0-alpha
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/LICENSE +426 -426
- package/dist/components/FieldRenderer.d.ts +9 -9
- package/dist/components/FieldRenderer.d.ts.map +1 -1
- package/dist/hooks/useForm.d.ts +6 -9
- package/dist/hooks/useForm.d.ts.map +1 -1
- package/dist/hooks/useFormErrorObserver.d.ts +4 -6
- package/dist/hooks/useFormErrorObserver.d.ts.map +1 -1
- package/dist/hooks/useFormField.d.ts +2 -2
- package/dist/hooks/useFormField.d.ts.map +1 -1
- package/dist/hooks/useFormValuesObserver.d.ts +3 -3
- package/dist/hooks/useFormValuesObserver.d.ts.map +1 -1
- package/dist/index.js +82 -76
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/FieldRenderer.tsx +166 -120
- package/src/hooks/useForm.tsx +50 -46
- package/src/hooks/useFormErrorObserver.ts +44 -40
- package/src/hooks/useFormField.tsx +63 -55
- package/src/hooks/useFormValuesObserver.ts +49 -45
- package/src/hooks/useRenderControl.tsx +26 -26
- package/src/index.ts +7 -7
- package/src/utils/composeFns.ts +7 -7
- package/src/utils/groupBy.ts +13 -13
- package/tsconfig.json +8 -8
- package/vite.config.ts +23 -23
package/src/hooks/useForm.tsx
CHANGED
|
@@ -1,46 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export function useForm<
|
|
7
|
-
formConfigs:
|
|
8
|
-
hookConfigs?: {
|
|
9
|
-
validateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
10
|
-
revalidateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
11
|
-
watchIssues?: boolean;
|
|
12
|
-
watchValues?: boolean;
|
|
13
|
-
},
|
|
14
|
-
) {
|
|
15
|
-
const [controller] = useState(() => new FormController(formConfigs));
|
|
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
|
-
|
|
1
|
+
import { FieldPathBuilder, FormController } from "@goodie-forms/core";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useRenderControl } from "../hooks/useRenderControl";
|
|
4
|
+
import { composeFns } from "../utils/composeFns";
|
|
5
|
+
|
|
6
|
+
export function useForm<TOutput extends object>(
|
|
7
|
+
formConfigs: FormController.Configs<TOutput>,
|
|
8
|
+
hookConfigs?: {
|
|
9
|
+
validateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
10
|
+
revalidateMode?: "onChange" | "onBlur" | "onSubmit";
|
|
11
|
+
watchIssues?: boolean;
|
|
12
|
+
watchValues?: boolean;
|
|
13
|
+
},
|
|
14
|
+
) {
|
|
15
|
+
const [controller] = useState(() => new FormController(formConfigs));
|
|
16
|
+
const [paths] = useState(() => new FieldPathBuilder<TOutput>());
|
|
17
|
+
|
|
18
|
+
const renderControl = useRenderControl();
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const noop = () => {};
|
|
22
|
+
|
|
23
|
+
return composeFns(
|
|
24
|
+
controller.events.on("submissionStatusChange", () => {
|
|
25
|
+
renderControl.forceRerender();
|
|
26
|
+
}),
|
|
27
|
+
hookConfigs?.watchIssues
|
|
28
|
+
? controller.events.on("fieldIssuesUpdated", () =>
|
|
29
|
+
renderControl.forceRerender(),
|
|
30
|
+
)
|
|
31
|
+
: noop,
|
|
32
|
+
hookConfigs?.watchValues
|
|
33
|
+
? controller.events.on("valueChanged", () =>
|
|
34
|
+
renderControl.forceRerender(),
|
|
35
|
+
)
|
|
36
|
+
: noop,
|
|
37
|
+
);
|
|
38
|
+
}, [controller]);
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
formConfigs,
|
|
42
|
+
paths,
|
|
43
|
+
hookConfigs,
|
|
44
|
+
controller,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type UseForm<TOutput extends object> = ReturnType<
|
|
49
|
+
typeof useForm<TOutput>
|
|
50
|
+
>;
|
|
@@ -1,40 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import type { UseForm } from "./useForm";
|
|
6
|
-
import { useRenderControl } from "./useRenderControl";
|
|
7
|
-
|
|
8
|
-
export function useFormErrorObserver<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const { events } = form.controller;
|
|
29
|
-
|
|
30
|
-
return composeFns(
|
|
31
|
-
events.on("fieldIssuesUpdated", (path) => {
|
|
32
|
-
if (options?.include?.includes?.(path) ?? true) {
|
|
33
|
-
renderControl.forceRerender();
|
|
34
|
-
}
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
return observedIssues
|
|
40
|
-
|
|
1
|
+
import { FieldPath } from "@goodie-forms/core";
|
|
2
|
+
import { groupBy } from "../utils/groupBy";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { composeFns } from "../utils/composeFns";
|
|
5
|
+
import type { UseForm } from "./useForm";
|
|
6
|
+
import { useRenderControl } from "./useRenderControl";
|
|
7
|
+
|
|
8
|
+
export function useFormErrorObserver<
|
|
9
|
+
TOutput extends object,
|
|
10
|
+
TInclude extends FieldPath.Segments[] | undefined = undefined,
|
|
11
|
+
>(
|
|
12
|
+
form: UseForm<TOutput>,
|
|
13
|
+
options?: {
|
|
14
|
+
include?: TInclude;
|
|
15
|
+
},
|
|
16
|
+
) {
|
|
17
|
+
const renderControl = useRenderControl();
|
|
18
|
+
|
|
19
|
+
const observedIssues = form.controller._issues.filter((issue) => {
|
|
20
|
+
if (options?.include == null) return true;
|
|
21
|
+
const normalizedIssuePath = FieldPath.normalize(issue.path);
|
|
22
|
+
return options.include.some((path) =>
|
|
23
|
+
FieldPath.equals(path, normalizedIssuePath),
|
|
24
|
+
);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const { events } = form.controller;
|
|
29
|
+
|
|
30
|
+
return composeFns(
|
|
31
|
+
events.on("fieldIssuesUpdated", (path) => {
|
|
32
|
+
if (options?.include?.includes?.(path) ?? true) {
|
|
33
|
+
renderControl.forceRerender();
|
|
34
|
+
}
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
39
|
+
return groupBy(observedIssues, (issue) =>
|
|
40
|
+
issue.path == null
|
|
41
|
+
? "$"
|
|
42
|
+
: FieldPath.toStringPath(FieldPath.normalize(issue.path)),
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -1,55 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { UseForm } from "../hooks/useForm";
|
|
4
|
-
import { useRenderControl } from "../hooks/useRenderControl";
|
|
5
|
-
import { composeFns } from "../utils/composeFns";
|
|
6
|
-
|
|
7
|
-
export function useFormField<
|
|
8
|
-
|
|
9
|
-
TPath extends
|
|
10
|
-
>(
|
|
11
|
-
form: UseForm<
|
|
12
|
-
path: TPath,
|
|
13
|
-
bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1]
|
|
14
|
-
) {
|
|
15
|
-
const renderControl = useRenderControl();
|
|
16
|
-
|
|
17
|
-
const [field, setField] = useState(() => {
|
|
18
|
-
let field = form.controller.getField(path);
|
|
19
|
-
if (field == null && bindingConfig != null) {
|
|
20
|
-
field = form.controller.bindField(path, bindingConfig);
|
|
21
|
-
}
|
|
22
|
-
return field;
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const { events } = form.controller;
|
|
27
|
-
|
|
28
|
-
setField(form.controller.getField(path));
|
|
29
|
-
|
|
30
|
-
return composeFns(
|
|
31
|
-
events.on("fieldBound", (_path) => {
|
|
32
|
-
if (_path
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import { FieldPath } from "@goodie-forms/core";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { UseForm } from "../hooks/useForm";
|
|
4
|
+
import { useRenderControl } from "../hooks/useRenderControl";
|
|
5
|
+
import { composeFns } from "../utils/composeFns";
|
|
6
|
+
|
|
7
|
+
export function useFormField<
|
|
8
|
+
TOutput extends object,
|
|
9
|
+
TPath extends FieldPath.Segments,
|
|
10
|
+
>(
|
|
11
|
+
form: UseForm<TOutput>,
|
|
12
|
+
path: TPath,
|
|
13
|
+
bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1],
|
|
14
|
+
) {
|
|
15
|
+
const renderControl = useRenderControl();
|
|
16
|
+
|
|
17
|
+
const [field, setField] = useState(() => {
|
|
18
|
+
let field = form.controller.getField(path);
|
|
19
|
+
if (field == null && bindingConfig != null) {
|
|
20
|
+
field = form.controller.bindField(path, bindingConfig);
|
|
21
|
+
}
|
|
22
|
+
return field;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const { events } = form.controller;
|
|
27
|
+
|
|
28
|
+
setField(form.controller.getField(path));
|
|
29
|
+
|
|
30
|
+
return composeFns(
|
|
31
|
+
events.on("fieldBound", (_path) => {
|
|
32
|
+
if (!FieldPath.equals(_path, path)) return;
|
|
33
|
+
setField(form.controller.getField(path));
|
|
34
|
+
}),
|
|
35
|
+
events.on("fieldUnbound", (_path) => {
|
|
36
|
+
if (!FieldPath.equals(_path, path)) return;
|
|
37
|
+
setField(undefined);
|
|
38
|
+
}),
|
|
39
|
+
events.on("valueChanged", (changedPath) => {
|
|
40
|
+
if (
|
|
41
|
+
FieldPath.equals(changedPath, path) ||
|
|
42
|
+
FieldPath.isDescendant(changedPath, path)
|
|
43
|
+
) {
|
|
44
|
+
renderControl.forceRerender();
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
events.on("fieldTouchUpdated", (_path) => {
|
|
48
|
+
if (!FieldPath.equals(_path, path)) return;
|
|
49
|
+
renderControl.forceRerender();
|
|
50
|
+
}),
|
|
51
|
+
events.on("fieldDirtyUpdated", (_path) => {
|
|
52
|
+
if (!FieldPath.equals(_path, path)) return;
|
|
53
|
+
renderControl.forceRerender();
|
|
54
|
+
}),
|
|
55
|
+
events.on("fieldIssuesUpdated", (_path) => {
|
|
56
|
+
if (!FieldPath.equals(_path, path)) return;
|
|
57
|
+
renderControl.forceRerender();
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
}, []);
|
|
61
|
+
|
|
62
|
+
return field;
|
|
63
|
+
}
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { composeFns } from "../utils/composeFns";
|
|
4
|
-
import type { UseForm } from "./useForm";
|
|
5
|
-
import { useRenderControl } from "./useRenderControl";
|
|
6
|
-
|
|
7
|
-
export function useFormValuesObserver<
|
|
8
|
-
|
|
9
|
-
TPaths extends
|
|
10
|
-
>(
|
|
11
|
-
form: UseForm<
|
|
12
|
-
options?: {
|
|
13
|
-
include?: TPaths;
|
|
14
|
-
}
|
|
15
|
-
) {
|
|
16
|
-
const renderControl = useRenderControl();
|
|
17
|
-
|
|
18
|
-
const observedValues =
|
|
19
|
-
options?.include == null
|
|
20
|
-
? form.controller._data
|
|
21
|
-
: options.include.reduce((data, path) => {
|
|
22
|
-
const value =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import { FieldPath } from "@goodie-forms/core";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { composeFns } from "../utils/composeFns";
|
|
4
|
+
import type { UseForm } from "./useForm";
|
|
5
|
+
import { useRenderControl } from "./useRenderControl";
|
|
6
|
+
|
|
7
|
+
export function useFormValuesObserver<
|
|
8
|
+
TOutput extends object,
|
|
9
|
+
TPaths extends FieldPath.Segments[] | undefined = undefined,
|
|
10
|
+
>(
|
|
11
|
+
form: UseForm<TOutput>,
|
|
12
|
+
options?: {
|
|
13
|
+
include?: TPaths;
|
|
14
|
+
},
|
|
15
|
+
) {
|
|
16
|
+
const renderControl = useRenderControl();
|
|
17
|
+
|
|
18
|
+
const observedValues =
|
|
19
|
+
options?.include == null
|
|
20
|
+
? form.controller._data
|
|
21
|
+
: options.include.reduce((data, path) => {
|
|
22
|
+
const value = FieldPath.getValue(
|
|
23
|
+
form.controller._data as TOutput,
|
|
24
|
+
path,
|
|
25
|
+
)!;
|
|
26
|
+
FieldPath.setValue(data, path, value);
|
|
27
|
+
return data;
|
|
28
|
+
}, {} as TOutput);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const { events } = form.controller;
|
|
32
|
+
|
|
33
|
+
return composeFns(
|
|
34
|
+
events.on("valueChanged", (changedPath) => {
|
|
35
|
+
const watchingChange =
|
|
36
|
+
options?.include == null
|
|
37
|
+
? true
|
|
38
|
+
: options.include.some(
|
|
39
|
+
(path) =>
|
|
40
|
+
FieldPath.equals(path, changedPath) ||
|
|
41
|
+
FieldPath.isDescendant(path, changedPath),
|
|
42
|
+
);
|
|
43
|
+
if (watchingChange) renderControl.forceRerender();
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
return observedValues;
|
|
49
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { startTransition, useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export function useRenderControl() {
|
|
4
|
-
const [, rerender] = useState(0);
|
|
5
|
-
const renderCount = useRef(0);
|
|
6
|
-
const renderScheduled = useRef(false);
|
|
7
|
-
renderCount.current++;
|
|
8
|
-
|
|
9
|
-
const scheduleRerender = () => {
|
|
10
|
-
if (renderScheduled.current) return;
|
|
11
|
-
renderScheduled.current = true;
|
|
12
|
-
|
|
13
|
-
queueMicrotask(() => {
|
|
14
|
-
startTransition(() => {
|
|
15
|
-
rerender((i) => i + 1);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
renderScheduled.current = false;
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
renderCount: renderCount.current,
|
|
24
|
-
forceRerender: scheduleRerender,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
1
|
+
import { startTransition, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export function useRenderControl() {
|
|
4
|
+
const [, rerender] = useState(0);
|
|
5
|
+
const renderCount = useRef(0);
|
|
6
|
+
const renderScheduled = useRef(false);
|
|
7
|
+
renderCount.current++;
|
|
8
|
+
|
|
9
|
+
const scheduleRerender = () => {
|
|
10
|
+
if (renderScheduled.current) return;
|
|
11
|
+
renderScheduled.current = true;
|
|
12
|
+
|
|
13
|
+
queueMicrotask(() => {
|
|
14
|
+
startTransition(() => {
|
|
15
|
+
rerender((i) => i + 1);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
renderScheduled.current = false;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
renderCount: renderCount.current,
|
|
24
|
+
forceRerender: scheduleRerender,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./hooks/useForm";
|
|
2
|
-
export * from "./hooks/useFormField";
|
|
3
|
-
export * from "./hooks/useFormValuesObserver";
|
|
4
|
-
export * from "./hooks/useFormErrorObserver";
|
|
5
|
-
export * from "./hooks/useRenderControl";
|
|
6
|
-
|
|
7
|
-
export * from "./components/FieldRenderer";
|
|
1
|
+
export * from "./hooks/useForm";
|
|
2
|
+
export * from "./hooks/useFormField";
|
|
3
|
+
export * from "./hooks/useFormValuesObserver";
|
|
4
|
+
export * from "./hooks/useFormErrorObserver";
|
|
5
|
+
export * from "./hooks/useRenderControl";
|
|
6
|
+
|
|
7
|
+
export * from "./components/FieldRenderer";
|
package/src/utils/composeFns.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function composeFns<TFns extends (() => void)[]>(...fns: TFns) {
|
|
2
|
-
return () => {
|
|
3
|
-
for (const fn of fns) {
|
|
4
|
-
fn();
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
}
|
|
1
|
+
export function composeFns<TFns extends (() => void)[]>(...fns: TFns) {
|
|
2
|
+
return () => {
|
|
3
|
+
for (const fn of fns) {
|
|
4
|
+
fn();
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
}
|
package/src/utils/groupBy.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function groupBy<T, K extends PropertyKey>(
|
|
2
|
-
items: readonly T[],
|
|
3
|
-
key: (item: T) => K,
|
|
4
|
-
): Record<K, T[]> {
|
|
5
|
-
const result = {} as Record<K, T[]>;
|
|
6
|
-
|
|
7
|
-
for (const item of items) {
|
|
8
|
-
const k = key(item);
|
|
9
|
-
(result[k] ??= []).push(item);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
1
|
+
export function groupBy<T, K extends PropertyKey>(
|
|
2
|
+
items: readonly T[],
|
|
3
|
+
key: (item: T) => K,
|
|
4
|
+
): Record<K, T[]> {
|
|
5
|
+
const result = {} as Record<K, T[]>;
|
|
6
|
+
|
|
7
|
+
for (const item of items) {
|
|
8
|
+
const k = key(item);
|
|
9
|
+
(result[k] ??= []).push(item);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return result;
|
|
13
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"jsx": "react-jsx"
|
|
6
|
-
},
|
|
7
|
-
"include": ["src"]
|
|
8
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"jsx": "react-jsx"
|
|
6
|
+
},
|
|
7
|
+
"include": ["src"]
|
|
8
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { defineConfig } from "vite";
|
|
2
|
-
import react from "@vitejs/plugin-react";
|
|
3
|
-
import dts from "vite-plugin-dts";
|
|
4
|
-
|
|
5
|
-
export default defineConfig({
|
|
6
|
-
plugins: [react(), dts({ entryRoot: "src" })],
|
|
7
|
-
build: {
|
|
8
|
-
lib: {
|
|
9
|
-
entry: "src/index.ts",
|
|
10
|
-
formats: ["es"],
|
|
11
|
-
fileName: "index",
|
|
12
|
-
},
|
|
13
|
-
rollupOptions: {
|
|
14
|
-
external: [
|
|
15
|
-
"react",
|
|
16
|
-
"react-dom",
|
|
17
|
-
"react/jsx-runtime",
|
|
18
|
-
"@goodie-forms/core",
|
|
19
|
-
],
|
|
20
|
-
},
|
|
21
|
-
sourcemap: true,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import dts from "vite-plugin-dts";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
plugins: [react(), dts({ entryRoot: "src" })],
|
|
7
|
+
build: {
|
|
8
|
+
lib: {
|
|
9
|
+
entry: "src/index.ts",
|
|
10
|
+
formats: ["es"],
|
|
11
|
+
fileName: "index",
|
|
12
|
+
},
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
external: [
|
|
15
|
+
"react",
|
|
16
|
+
"react-dom",
|
|
17
|
+
"react/jsx-runtime",
|
|
18
|
+
"@goodie-forms/core",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
sourcemap: true,
|
|
22
|
+
},
|
|
23
|
+
});
|