@goodie-forms/react 1.1.6-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.
@@ -1,28 +1,28 @@
1
- import { Field, FormField, NonnullFormField } from '../../../core/src';
1
+ import { FieldPath, FormField, NonnullFormField } from '../../../core/src';
2
2
  import { ChangeEvent, FocusEvent, ReactNode, Ref } from 'react';
3
3
  import { UseForm } from '../hooks/useForm';
4
- export interface RenderParams<TShape extends object, TPath extends Field.Paths<TShape>> {
4
+ export interface RenderParams<TOutput extends object, TValue> {
5
5
  ref: Ref<any | null>;
6
- value: Field.GetValue<TShape, TPath> | undefined;
6
+ value: TValue | undefined;
7
7
  handlers: {
8
8
  onChange: (event: ChangeEvent<EventTarget>) => void;
9
9
  onFocus: (event: FocusEvent) => void;
10
10
  onBlur: (event: FocusEvent) => void;
11
11
  };
12
- field: undefined extends Field.GetValue<TShape, TPath> ? FormField<TShape, TPath> : NonnullFormField<TShape, TPath>;
12
+ field: undefined extends TValue ? FormField<TOutput, TValue> : NonnullFormField<TOutput, TValue>;
13
13
  }
14
14
  type DefaultValueProps<TValue> = undefined extends TValue ? {
15
15
  defaultValue?: TValue | (() => TValue);
16
16
  } : {
17
17
  defaultValue: TValue | (() => TValue);
18
18
  };
19
- export type FieldRendererProps<TShape extends object, TPath extends Field.Paths<TShape>> = {
20
- form: UseForm<TShape>;
19
+ export type FieldRendererProps<TOutput extends object, TPath extends FieldPath.Segments> = {
20
+ form: UseForm<TOutput>;
21
21
  path: TPath;
22
22
  overrideInitialValue?: boolean;
23
23
  unbindOnUnmount?: boolean;
24
- render: (params: RenderParams<TShape, TPath>) => ReactNode;
25
- } & DefaultValueProps<Field.GetValue<TShape, TPath>>;
26
- export declare function FieldRenderer<TShape extends object, TPath extends Field.Paths<TShape>>(props: FieldRendererProps<TShape, TPath>): import("react/jsx-runtime").JSX.Element;
24
+ render: (params: RenderParams<TOutput, FieldPath.Resolve<TOutput, NoInfer<TPath>>>) => ReactNode;
25
+ } & DefaultValueProps<FieldPath.Resolve<TOutput, NoInfer<TPath>>>;
26
+ export declare function FieldRenderer<TOutput extends object, const TPath extends FieldPath.Segments>(props: FieldRendererProps<TOutput, TPath>): import("react/jsx-runtime").JSX.Element;
27
27
  export {};
28
28
  //# sourceMappingURL=FieldRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FieldRenderer.d.ts","sourceRoot":"","sources":["../../src/components/FieldRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,GAAG,EAGJ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,MAAM,WAAW,YAAY,CAC3B,MAAM,SAAS,MAAM,EACrB,KAAK,SAAS,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;IAEjC,GAAG,EAAE,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC;IAErB,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC;IAEjD,QAAQ,EAAE;QACR,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;QACpD,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;QACrC,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;KACrC,CAAC;IAEF,KAAK,EAAE,SAAS,SAAS,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,GAClD,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,GACxB,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACrC;AAED,KAAK,iBAAiB,CAAC,MAAM,IAAI,SAAS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EAAE,KAAK,CAAC,2CA4E1C"}
@@ -1,18 +1,19 @@
1
- import { FormController, Form } from '../../../core/src';
2
- export declare function useForm<TShape extends object>(formConfigs: Form.FormConfigs<TShape>, hookConfigs?: {
1
+ import { FieldPathBuilder, FormController } from '../../../core/src';
2
+ export declare function useForm<TOutput extends object>(formConfigs: FormController.Configs<TOutput>, hookConfigs?: {
3
3
  validateMode?: "onChange" | "onBlur" | "onSubmit";
4
4
  revalidateMode?: "onChange" | "onBlur" | "onSubmit";
5
5
  watchIssues?: boolean;
6
6
  watchValues?: boolean;
7
- }): UseForm<TShape>;
8
- export type UseForm<TShape extends object> = {
9
- formConfigs: Form.FormConfigs<TShape>;
10
- hookConfigs?: {
7
+ }): {
8
+ formConfigs: FormController.Configs<TOutput>;
9
+ paths: FieldPathBuilder<TOutput>;
10
+ hookConfigs: {
11
11
  validateMode?: "onChange" | "onBlur" | "onSubmit";
12
12
  revalidateMode?: "onChange" | "onBlur" | "onSubmit";
13
13
  watchIssues?: boolean;
14
14
  watchValues?: boolean;
15
- };
16
- controller: FormController<TShape>;
15
+ } | undefined;
16
+ controller: FormController<TOutput>;
17
17
  };
18
+ export type UseForm<TOutput extends object> = ReturnType<typeof useForm<TOutput>>;
18
19
  //# sourceMappingURL=useForm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../src/hooks/useForm.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAK/D,wBAAgB,OAAO,CAAC,MAAM,SAAS,MAAM,EAC3C,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EACrC,WAAW,CAAC,EAAE;IACZ,YAAY,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;IAClD,cAAc,CAAC,EAAE,UAAU,GAAG,QAAQ,GAAG,UAAU,CAAC;IACpD,WAAW,CAAC,EAAE,OAAO,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+ import { FieldPath } from '../../../core/src';
2
2
  import { UseForm } from './useForm';
3
- export declare function useFormErrorObserver<TShape extends object, TInclude extends Field.Paths<TShape>[] | undefined>(form: UseForm<TShape>, options?: {
3
+ export declare function useFormErrorObserver<TOutput extends object, TInclude extends FieldPath.Segments[] | undefined = undefined>(form: UseForm<TOutput>, options?: {
4
4
  include?: TInclude;
5
5
  }): Record<string, import("@standard-schema/spec").StandardSchemaV1.Issue[]>;
6
6
  //# sourceMappingURL=useFormErrorObserver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFormErrorObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormErrorObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,oBAAoB,CAClC,MAAM,SAAS,MAAM,EACrB,QAAQ,SAAS,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,EAElD,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EACrB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB,4EA2BF"}
1
+ {"version":3,"file":"useFormErrorObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormErrorObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,oBAAoB,CAClC,OAAO,SAAS,MAAM,EACtB,QAAQ,SAAS,SAAS,CAAC,QAAQ,EAAE,GAAG,SAAS,GAAG,SAAS,EAE7D,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EACtB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB,4EA6BF"}
@@ -1,4 +1,4 @@
1
- import { Field } from '../../../core/src';
1
+ import { FieldPath } from '../../../core/src';
2
2
  import { UseForm } from '../hooks/useForm';
3
- export declare function useFormField<TShape extends object, TPath extends Field.Paths<TShape>>(form: UseForm<TShape>, path: TPath, bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1]): import('../../../core/src').FormField<TShape, TPath> | undefined;
3
+ export declare function useFormField<TOutput extends object, TPath extends FieldPath.Segments>(form: UseForm<TOutput>, path: TPath, bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1]): import('../../../core/src').FormField<TOutput, FieldPath.Resolve<TOutput, TPath>> | undefined;
4
4
  //# sourceMappingURL=useFormField.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,wBAAgB,YAAY,CAC1B,MAAM,SAAS,MAAM,EACrB,KAAK,SAAS,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAEjC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EACrB,IAAI,EAAE,KAAK,EACX,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,qEA0CvE"}
1
+ {"version":3,"file":"useFormField.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormField.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,EACtB,KAAK,SAAS,SAAS,CAAC,QAAQ,EAEhC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EACtB,IAAI,EAAE,KAAK,EACX,aAAa,CAAC,EAAE,UAAU,CAAC,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,kGAkDvE"}
@@ -1,6 +1,6 @@
1
- import { Field } from '../../../core/src';
1
+ import { FieldPath } from '../../../core/src';
2
2
  import { UseForm } from './useForm';
3
- export declare function useFormValuesObserver<TShape extends object, TPaths extends Field.Paths<TShape>[] | undefined = undefined>(form: UseForm<TShape>, options?: {
3
+ export declare function useFormValuesObserver<TOutput extends object, TPaths extends FieldPath.Segments[] | undefined = undefined>(form: UseForm<TOutput>, options?: {
4
4
  include?: TPaths;
5
- }): import('../../../core/src').DeepPartial<TShape>;
5
+ }): import('../../../core/src').DeepPartial<TOutput>;
6
6
  //# sourceMappingURL=useFormValuesObserver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFormValuesObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormValuesObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAG3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,MAAM,EACrB,MAAM,SAAS,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,SAAS,GAAG,SAAS,EAE5D,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,EACrB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,oDA+BF"}
1
+ {"version":3,"file":"useFormValuesObserver.d.ts","sourceRoot":"","sources":["../../src/hooks/useFormValuesObserver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,MAAM,EACtB,MAAM,SAAS,SAAS,CAAC,QAAQ,EAAE,GAAG,SAAS,GAAG,SAAS,EAE3D,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EACtB,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,qDAmCF"}
package/dist/index.js CHANGED
@@ -1,130 +1,136 @@
1
- import { FormController as m, Field as c } from "@goodie-forms/core";
2
- import { useState as v, useRef as f, startTransition as h, useEffect as i } from "react";
3
- import { jsx as F, Fragment as C } from "react/jsx-runtime";
4
- function s(...e) {
5
- return () => {
6
- for (const n of e)
7
- n();
8
- };
9
- }
10
- function a() {
11
- const [, e] = v(0), n = f(0), r = f(!1);
1
+ import { FormController as m, FieldPathBuilder as h, FieldPath as o } from "@goodie-forms/core";
2
+ import { useState as a, useRef as v, startTransition as F, useEffect as i } from "react";
3
+ import { jsx as g, Fragment as C } from "react/jsx-runtime";
4
+ function f() {
5
+ const [, e] = a(0), n = v(0), r = v(!1);
12
6
  n.current++;
13
- const l = () => {
7
+ const u = () => {
14
8
  r.current || (r.current = !0, queueMicrotask(() => {
15
- h(() => {
16
- e((o) => o + 1);
9
+ F(() => {
10
+ e((t) => t + 1);
17
11
  }), r.current = !1;
18
12
  }));
19
13
  };
20
14
  return {
21
15
  renderCount: n.current,
22
- forceRerender: l
16
+ forceRerender: u
17
+ };
18
+ }
19
+ function s(...e) {
20
+ return () => {
21
+ for (const n of e)
22
+ n();
23
23
  };
24
24
  }
25
25
  function U(e, n) {
26
- const [r] = v(() => new m(e)), l = a();
26
+ const [r] = a(() => new m(e)), [u] = a(() => new h()), t = f();
27
27
  return i(() => {
28
- const o = () => {
28
+ const l = () => {
29
29
  };
30
30
  return s(
31
31
  r.events.on("submissionStatusChange", () => {
32
- l.forceRerender();
32
+ t.forceRerender();
33
33
  }),
34
34
  n?.watchIssues ? r.events.on(
35
35
  "fieldIssuesUpdated",
36
- () => l.forceRerender()
37
- ) : o,
36
+ () => t.forceRerender()
37
+ ) : l,
38
38
  n?.watchValues ? r.events.on(
39
39
  "valueChanged",
40
- () => l.forceRerender()
41
- ) : o
40
+ () => t.forceRerender()
41
+ ) : l
42
42
  );
43
43
  }, [r]), {
44
44
  formConfigs: e,
45
+ paths: u,
45
46
  hookConfigs: n,
46
47
  controller: r
47
48
  };
48
49
  }
49
- function g(e, n, r) {
50
- const l = a(), [o, t] = v(() => {
51
- let u = e.controller.getField(n);
52
- return u == null && r != null && (u = e.controller.bindField(n, r)), u;
50
+ function R(e, n, r) {
51
+ const u = f(), [t, l] = a(() => {
52
+ let d = e.controller.getField(n);
53
+ return d == null && r != null && (d = e.controller.bindField(n, r)), d;
53
54
  });
54
55
  return i(() => {
55
- const { events: u } = e.controller;
56
- return t(e.controller.getField(n)), s(
57
- u.on("fieldBound", (d) => {
58
- d === n && t(e.controller.getField(n));
56
+ const { events: d } = e.controller;
57
+ return l(e.controller.getField(n)), s(
58
+ d.on("fieldBound", (c) => {
59
+ o.equals(c, n) && l(e.controller.getField(n));
59
60
  }),
60
- u.on("fieldUnbound", (d) => {
61
- d === n && t(void 0);
61
+ d.on("fieldUnbound", (c) => {
62
+ o.equals(c, n) && l(void 0);
62
63
  }),
63
- u.on("valueChanged", (d) => {
64
- (d === n || c.isDescendant(d, n)) && l.forceRerender();
64
+ d.on("valueChanged", (c) => {
65
+ (o.equals(c, n) || o.isDescendant(c, n)) && u.forceRerender();
65
66
  }),
66
- u.on("fieldTouchUpdated", (d) => {
67
- d === n && l.forceRerender();
67
+ d.on("fieldTouchUpdated", (c) => {
68
+ o.equals(c, n) && u.forceRerender();
68
69
  }),
69
- u.on("fieldDirtyUpdated", (d) => {
70
- d === n && l.forceRerender();
70
+ d.on("fieldDirtyUpdated", (c) => {
71
+ o.equals(c, n) && u.forceRerender();
71
72
  }),
72
- u.on("fieldIssuesUpdated", (d) => {
73
- d === n && l.forceRerender();
73
+ d.on("fieldIssuesUpdated", (c) => {
74
+ o.equals(c, n) && u.forceRerender();
74
75
  })
75
76
  );
76
- }, []), o;
77
+ }, []), t;
77
78
  }
78
79
  function w(e, n) {
79
- const r = a(), l = n?.include == null ? e.controller._data : n.include.reduce((o, t) => {
80
- const u = c.getValue(e.controller._data, t);
81
- return c.setValue(o, t, u), o;
80
+ const r = f(), u = n?.include == null ? e.controller._data : n.include.reduce((t, l) => {
81
+ const d = o.getValue(
82
+ e.controller._data,
83
+ l
84
+ );
85
+ return o.setValue(t, l, d), t;
82
86
  }, {});
83
87
  return i(() => {
84
- const { events: o } = e.controller;
88
+ const { events: t } = e.controller;
85
89
  return s(
86
- o.on("valueChanged", (t) => {
90
+ t.on("valueChanged", (l) => {
87
91
  (n?.include == null || n.include.some(
88
- (d) => d === t || c.isDescendant(d, t)
92
+ (c) => o.equals(c, l) || o.isDescendant(c, l)
89
93
  )) && r.forceRerender();
90
94
  })
91
95
  );
92
- }, []), l;
96
+ }, []), u;
93
97
  }
94
- function R(e, n) {
98
+ function V(e, n) {
95
99
  const r = {};
96
- for (const l of e) {
97
- const o = n(l);
98
- (r[o] ??= []).push(l);
100
+ for (const u of e) {
101
+ const t = n(u);
102
+ (r[t] ??= []).push(u);
99
103
  }
100
104
  return r;
101
105
  }
102
106
  function y(e, n) {
103
- const r = a(), l = e.controller._issues.filter((t) => {
107
+ const r = f(), u = e.controller._issues.filter((t) => {
104
108
  if (n?.include == null) return !0;
105
- const u = c.parsePath(t.path);
106
- return n.include.includes(u);
107
- }), o = R(
108
- l,
109
- (t) => c.parsePath(t.path)
110
- );
109
+ const l = o.normalize(t.path);
110
+ return n.include.some(
111
+ (d) => o.equals(d, l)
112
+ );
113
+ });
111
114
  return i(() => {
112
115
  const { events: t } = e.controller;
113
116
  return s(
114
- t.on("fieldIssuesUpdated", (u) => {
115
- (n?.include?.includes?.(u) ?? !0) && r.forceRerender();
117
+ t.on("fieldIssuesUpdated", (l) => {
118
+ (n?.include?.includes?.(l) ?? !0) && r.forceRerender();
116
119
  })
117
120
  );
118
- }, []), o;
121
+ }, []), V(
122
+ u,
123
+ (t) => t.path == null ? "$" : o.toStringPath(o.normalize(t.path))
124
+ );
119
125
  }
120
- function D(e) {
121
- const n = f(null), r = g(e.form, e.path, {
126
+ function B(e) {
127
+ const n = v(null), r = R(e.form, e.path, {
122
128
  overrideInitialValue: e.overrideInitialValue ?? !0,
123
129
  defaultValue: typeof e.defaultValue == "function" ? e.defaultValue() : e.defaultValue
124
- }), l = {
125
- onChange(o) {
126
- const { target: t } = o;
127
- t === r.boundElement && "value" in t && typeof t.value == "string" && r.setValue(t.value, {
130
+ }), u = {
131
+ onChange(t) {
132
+ const { target: l } = t;
133
+ l === r.boundElement && "value" in l && typeof l.value == "string" && r.setValue(l.value, {
128
134
  shouldTouch: !0,
129
135
  shouldMarkDirty: !0
130
136
  });
@@ -137,27 +143,27 @@ function D(e) {
137
143
  }
138
144
  };
139
145
  return i(() => {
140
- const { events: o } = e.form.controller;
146
+ const { events: t } = e.form.controller;
141
147
  return s(
142
- o.on("valueChanged", (t) => {
143
- t !== e.path && !c.isDescendant(t, e.path) || e.form.hookConfigs?.validateMode === "onChange" && e.form.controller.validateField(e.path);
148
+ t.on("valueChanged", (l) => {
149
+ !o.equals(l, e.path) && !o.isDescendant(l, e.path) || e.form.hookConfigs?.validateMode === "onChange" && e.form.controller.validateField(e.path);
144
150
  })
145
151
  );
146
152
  }, []), i(() => (r.bindElement(n.current), () => {
147
153
  e.unbindOnUnmount && e.form.controller.unbindField(e.path);
148
- }), []), /* @__PURE__ */ F(C, { children: e.render({
154
+ }), []), /* @__PURE__ */ g(C, { children: e.render({
149
155
  ref: n,
150
156
  value: r.value,
151
- handlers: l,
157
+ handlers: u,
152
158
  field: r
153
159
  }) });
154
160
  }
155
161
  export {
156
- D as FieldRenderer,
162
+ B as FieldRenderer,
157
163
  U as useForm,
158
164
  y as useFormErrorObserver,
159
- g as useFormField,
165
+ R as useFormField,
160
166
  w as useFormValuesObserver,
161
- a as useRenderControl
167
+ f as useRenderControl
162
168
  };
163
169
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils/composeFns.ts","../src/hooks/useRenderControl.tsx","../src/hooks/useForm.tsx","../src/hooks/useFormField.tsx","../src/hooks/useFormValuesObserver.ts","../src/utils/groupBy.ts","../src/hooks/useFormErrorObserver.ts","../src/components/FieldRenderer.tsx"],"sourcesContent":["export function composeFns<TFns extends (() => void)[]>(...fns: TFns) {\n return () => {\n for (const fn of fns) {\n fn();\n }\n };\n}\n","import { startTransition, useRef, useState } from \"react\";\n\nexport function useRenderControl() {\n const [, rerender] = useState(0);\n const renderCount = useRef(0);\n const renderScheduled = useRef(false);\n renderCount.current++;\n\n const scheduleRerender = () => {\n if (renderScheduled.current) return;\n renderScheduled.current = true;\n\n queueMicrotask(() => {\n startTransition(() => {\n rerender((i) => i + 1);\n });\n\n renderScheduled.current = false;\n });\n };\n\n return {\n renderCount: renderCount.current,\n forceRerender: scheduleRerender,\n };\n}\n","import { FormController, type Form } from \"@goodie-forms/core\";\nimport { useEffect, useState } from \"react\";\nimport { composeFns } from \"../utils/composeFns\";\nimport { useRenderControl } from \"../hooks/useRenderControl\";\n\nexport function useForm<TShape extends object>(\n formConfigs: Form.FormConfigs<TShape>,\n hookConfigs?: {\n validateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\n revalidateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\n watchIssues?: boolean;\n watchValues?: boolean;\n }\n) {\n const [controller] = useState(() => new FormController(formConfigs));\n\n const renderControl = useRenderControl();\n\n useEffect(() => {\n const noop = () => {};\n\n return composeFns(\n controller.events.on(\"submissionStatusChange\", () => {\n renderControl.forceRerender();\n }),\n hookConfigs?.watchIssues\n ? controller.events.on(\"fieldIssuesUpdated\", () =>\n renderControl.forceRerender()\n )\n : noop,\n hookConfigs?.watchValues\n ? controller.events.on(\"valueChanged\", () =>\n renderControl.forceRerender()\n )\n : noop\n );\n }, [controller]);\n\n return {\n formConfigs,\n hookConfigs,\n controller,\n } as UseForm<TShape>;\n}\n\nexport type UseForm<TShape extends object> = {\n formConfigs: Form.FormConfigs<TShape>;\n hookConfigs?: {\n validateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\n revalidateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\n watchIssues?: boolean;\n watchValues?: boolean;\n };\n controller: FormController<TShape>;\n};\n","import { Field } from \"@goodie-forms/core\";\nimport { useEffect, useState } from \"react\";\nimport { UseForm } from \"../hooks/useForm\";\nimport { useRenderControl } from \"../hooks/useRenderControl\";\nimport { composeFns } from \"../utils/composeFns\";\n\nexport function useFormField<\n TShape extends object,\n TPath extends Field.Paths<TShape>\n>(\n form: UseForm<TShape>,\n path: TPath,\n bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1]\n) {\n const renderControl = useRenderControl();\n\n const [field, setField] = useState(() => {\n let field = form.controller.getField(path);\n if (field == null && bindingConfig != null) {\n field = form.controller.bindField(path, bindingConfig);\n }\n return field;\n });\n\n useEffect(() => {\n const { events } = form.controller;\n\n setField(form.controller.getField(path));\n\n return composeFns(\n events.on(\"fieldBound\", (_path) => {\n if (_path === path) setField(form.controller.getField(path));\n }),\n events.on(\"fieldUnbound\", (_path) => {\n if (_path === path) setField(undefined);\n }),\n events.on(\"valueChanged\", (changedPath) => {\n if (changedPath === path || Field.isDescendant(changedPath, path)) {\n renderControl.forceRerender();\n }\n }),\n events.on(\"fieldTouchUpdated\", (_path) => {\n if (_path === path) renderControl.forceRerender();\n }),\n events.on(\"fieldDirtyUpdated\", (_path) => {\n if (_path === path) renderControl.forceRerender();\n }),\n events.on(\"fieldIssuesUpdated\", (_path) => {\n if (_path === path) renderControl.forceRerender();\n })\n );\n }, []);\n\n return field;\n}\n","import { Field } from \"@goodie-forms/core\";\nimport { useEffect } from \"react\";\nimport { composeFns } from \"../utils/composeFns\";\nimport type { UseForm } from \"./useForm\";\nimport { useRenderControl } from \"./useRenderControl\";\n\nexport function useFormValuesObserver<\n TShape extends object,\n TPaths extends Field.Paths<TShape>[] | undefined = undefined\n>(\n form: UseForm<TShape>,\n options?: {\n include?: TPaths;\n }\n) {\n const renderControl = useRenderControl();\n\n const observedValues =\n options?.include == null\n ? form.controller._data\n : options.include.reduce((data, path) => {\n const value = Field.getValue(form.controller._data as TShape, path)!;\n Field.setValue(data, path, value);\n return data;\n }, {} as TShape);\n\n useEffect(() => {\n const { events } = form.controller;\n\n return composeFns(\n events.on(\"valueChanged\", (changedPath) => {\n const watchingChange =\n options?.include == null\n ? true\n : options.include.some(\n (path) =>\n path === changedPath || Field.isDescendant(path, changedPath)\n );\n if (watchingChange) renderControl.forceRerender();\n })\n );\n }, []);\n\n return observedValues;\n}\n","export function groupBy<T, K extends PropertyKey>(\n items: readonly T[],\n key: (item: T) => K,\n): Record<K, T[]> {\n const result = {} as Record<K, T[]>;\n\n for (const item of items) {\n const k = key(item);\n (result[k] ??= []).push(item);\n }\n\n return result;\n}\n","import { Field } from \"@goodie-forms/core\";\nimport { useEffect } from \"react\";\nimport { composeFns } from \"../utils/composeFns\";\nimport { groupBy } from \"../utils/groupBy\";\nimport type { UseForm } from \"./useForm\";\nimport { useRenderControl } from \"./useRenderControl\";\n\nexport function useFormErrorObserver<\n TShape extends object,\n TInclude extends Field.Paths<TShape>[] | undefined\n>(\n form: UseForm<TShape>,\n options?: {\n include?: TInclude;\n }\n) {\n const renderControl = useRenderControl();\n\n const filteredIssues = form.controller._issues.filter((issue) => {\n if (options?.include == null) return true;\n const path = Field.parsePath(issue.path!) as Field.Paths<TShape>;\n return options.include.includes(path);\n });\n\n const observedIssues = groupBy(filteredIssues, (issue) =>\n Field.parsePath(issue.path!)\n );\n\n useEffect(() => {\n const { events } = form.controller;\n\n return composeFns(\n events.on(\"fieldIssuesUpdated\", (path) => {\n if (options?.include?.includes?.(path) ?? true) {\n renderControl.forceRerender();\n }\n })\n );\n }, []);\n\n return observedIssues;\n}\n","import { Field, FormField, NonnullFormField } from \"@goodie-forms/core\";\nimport {\n ChangeEvent,\n FocusEvent,\n ReactNode,\n Ref,\n useEffect,\n useRef,\n} from \"react\";\nimport { UseForm } from \"../hooks/useForm\";\nimport { useFormField } from \"../hooks/useFormField\";\nimport { composeFns } from \"../utils/composeFns\";\n\nexport interface RenderParams<\n TShape extends object,\n TPath extends Field.Paths<TShape>\n> {\n ref: Ref<any | null>;\n\n value: Field.GetValue<TShape, TPath> | undefined;\n\n handlers: {\n onChange: (event: ChangeEvent<EventTarget>) => void;\n onFocus: (event: FocusEvent) => void;\n onBlur: (event: FocusEvent) => void;\n };\n\n field: undefined extends Field.GetValue<TShape, TPath>\n ? FormField<TShape, TPath>\n : NonnullFormField<TShape, TPath>;\n}\n\ntype DefaultValueProps<TValue> = undefined extends TValue\n ? { defaultValue?: TValue | (() => TValue) }\n : { defaultValue: TValue | (() => TValue) };\n\nexport type FieldRendererProps<\n TShape extends object,\n TPath extends Field.Paths<TShape>\n> = {\n form: UseForm<TShape>;\n path: TPath;\n overrideInitialValue?: boolean;\n unbindOnUnmount?: boolean;\n render: (params: RenderParams<TShape, TPath>) => ReactNode;\n} & DefaultValueProps<Field.GetValue<TShape, TPath>>;\n\nexport function FieldRenderer<\n TShape extends object,\n TPath extends Field.Paths<TShape>\n>(props: FieldRendererProps<TShape, TPath>) {\n const elementRef = useRef<HTMLElement>(null);\n\n const field = useFormField(props.form, props.path, {\n overrideInitialValue: props.overrideInitialValue ?? true,\n defaultValue:\n typeof props.defaultValue === \"function\"\n ? (props.defaultValue as any)()\n : props.defaultValue,\n })!;\n\n const handlers: RenderParams<TShape, TPath>[\"handlers\"] = {\n onChange(event) {\n const { target } = event;\n if (target !== field.boundElement) return;\n if (!(\"value\" in target)) return;\n if (typeof target.value !== \"string\") return;\n field.setValue(target.value as Field.GetValue<TShape, TPath>, {\n shouldTouch: true,\n shouldMarkDirty: true,\n });\n },\n onFocus() {\n field.touch();\n },\n onBlur() {\n if (\n props.form.hookConfigs?.validateMode === \"onBlur\" ||\n props.form.hookConfigs?.validateMode === \"onChange\"\n ) {\n props.form.controller.validateField(props.path);\n }\n },\n };\n\n useEffect(() => {\n const { events } = props.form.controller;\n\n return composeFns(\n events.on(\"valueChanged\", (path) => {\n if (path !== props.path && !Field.isDescendant(path, props.path))\n return;\n if (props.form.hookConfigs?.validateMode === \"onChange\") {\n props.form.controller.validateField(props.path);\n }\n })\n );\n }, []);\n\n useEffect(() => {\n field.bindElement(elementRef.current!);\n\n return () => {\n if (props.unbindOnUnmount) {\n props.form.controller.unbindField(props.path);\n }\n };\n }, []);\n\n return (\n <>\n {props.render({\n ref: elementRef,\n value: field.value,\n handlers: handlers,\n field: field as any,\n })}\n </>\n );\n}\n"],"names":["composeFns","fns","fn","useRenderControl","rerender","useState","renderCount","useRef","renderScheduled","scheduleRerender","startTransition","i","useForm","formConfigs","hookConfigs","controller","FormController","renderControl","useEffect","noop","useFormField","form","path","bindingConfig","field","setField","events","_path","changedPath","Field","useFormValuesObserver","options","observedValues","data","value","groupBy","items","key","result","item","k","useFormErrorObserver","filteredIssues","issue","observedIssues","FieldRenderer","props","elementRef","handlers","event","target","jsx","Fragment"],"mappings":";;;AAAO,SAASA,KAA2CC,GAAW;AACpE,SAAO,MAAM;AACX,eAAWC,KAAMD;AACf,MAAAC,EAAA;AAAA,EAEJ;AACF;ACJO,SAASC,IAAmB;AACjC,QAAM,GAAGC,CAAQ,IAAIC,EAAS,CAAC,GACzBC,IAAcC,EAAO,CAAC,GACtBC,IAAkBD,EAAO,EAAK;AACpC,EAAAD,EAAY;AAEZ,QAAMG,IAAmB,MAAM;AAC7B,IAAID,EAAgB,YACpBA,EAAgB,UAAU,IAE1B,eAAe,MAAM;AACnB,MAAAE,EAAgB,MAAM;AACpB,QAAAN,EAAS,CAACO,MAAMA,IAAI,CAAC;AAAA,MACvB,CAAC,GAEDH,EAAgB,UAAU;AAAA,IAC5B,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,aAAaF,EAAY;AAAA,IACzB,eAAeG;AAAA,EAAA;AAEnB;ACpBO,SAASG,EACd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AAAA,IACA,SAAS;AACP,OACEsB,EAAM,KAAK,aAAa,iBAAiB,YACzCA,EAAM,KAAK,aAAa,iBAAiB,eAEzCA,EAAM,KAAK,WAAW,cAAcA,EAAM,IAAI;AAAA,IAElD;AAAA,EAAA;AAGF,SAAA5B,EAAU,MAAM;AACd,UAAM,EAAE,QAAAQ,EAAA,IAAWoB,EAAM,KAAK;AAE9B,WAAO9C;AAAA,MACL0B,EAAO,GAAG,gBAAgB,CAACJ,MAAS;AAClC,QAAIA,MAASwB,EAAM,QAAQ,CAACjB,EAAM,aAAaP,GAAMwB,EAAM,IAAI,KAE3DA,EAAM,KAAK,aAAa,iBAAiB,cAC3CA,EAAM,KAAK,WAAW,cAAcA,EAAM,IAAI;AAAA,MAElD,CAAC;AAAA,IAAA;AAAA,EAEL,GAAG,CAAA,CAAE,GAEL5B,EAAU,OACRM,EAAM,YAAYuB,EAAW,OAAQ,GAE9B,MAAM;AACX,IAAID,EAAM,mBACRA,EAAM,KAAK,WAAW,YAAYA,EAAM,IAAI;AAAA,EAEhD,IACC,CAAA,CAAE,GAGH,gBAAAK,EAAAC,GAAA,EACG,YAAM,OAAO;AAAA,IACZ,KAAKL;AAAA,IACL,OAAOvB,EAAM;AAAA,IACb,UAAAwB;AAAA,IACA,OAAAxB;AAAA,EAAA,CACD,GACH;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../src/hooks/useRenderControl.tsx","../src/utils/composeFns.ts","../src/hooks/useForm.tsx","../src/hooks/useFormField.tsx","../src/hooks/useFormValuesObserver.ts","../src/utils/groupBy.ts","../src/hooks/useFormErrorObserver.ts","../src/components/FieldRenderer.tsx"],"sourcesContent":["import { startTransition, useRef, useState } from \"react\";\r\n\r\nexport function useRenderControl() {\r\n const [, rerender] = useState(0);\r\n const renderCount = useRef(0);\r\n const renderScheduled = useRef(false);\r\n renderCount.current++;\r\n\r\n const scheduleRerender = () => {\r\n if (renderScheduled.current) return;\r\n renderScheduled.current = true;\r\n\r\n queueMicrotask(() => {\r\n startTransition(() => {\r\n rerender((i) => i + 1);\r\n });\r\n\r\n renderScheduled.current = false;\r\n });\r\n };\r\n\r\n return {\r\n renderCount: renderCount.current,\r\n forceRerender: scheduleRerender,\r\n };\r\n}\r\n","export function composeFns<TFns extends (() => void)[]>(...fns: TFns) {\r\n return () => {\r\n for (const fn of fns) {\r\n fn();\r\n }\r\n };\r\n}\r\n","import { FieldPathBuilder, FormController } from \"@goodie-forms/core\";\r\nimport { useEffect, useState } from \"react\";\r\nimport { useRenderControl } from \"../hooks/useRenderControl\";\r\nimport { composeFns } from \"../utils/composeFns\";\r\n\r\nexport function useForm<TOutput extends object>(\r\n formConfigs: FormController.Configs<TOutput>,\r\n hookConfigs?: {\r\n validateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\r\n revalidateMode?: \"onChange\" | \"onBlur\" | \"onSubmit\";\r\n watchIssues?: boolean;\r\n watchValues?: boolean;\r\n },\r\n) {\r\n const [controller] = useState(() => new FormController(formConfigs));\r\n const [paths] = useState(() => new FieldPathBuilder<TOutput>());\r\n\r\n const renderControl = useRenderControl();\r\n\r\n useEffect(() => {\r\n const noop = () => {};\r\n\r\n return composeFns(\r\n controller.events.on(\"submissionStatusChange\", () => {\r\n renderControl.forceRerender();\r\n }),\r\n hookConfigs?.watchIssues\r\n ? controller.events.on(\"fieldIssuesUpdated\", () =>\r\n renderControl.forceRerender(),\r\n )\r\n : noop,\r\n hookConfigs?.watchValues\r\n ? controller.events.on(\"valueChanged\", () =>\r\n renderControl.forceRerender(),\r\n )\r\n : noop,\r\n );\r\n }, [controller]);\r\n\r\n return {\r\n formConfigs,\r\n paths,\r\n hookConfigs,\r\n controller,\r\n };\r\n}\r\n\r\nexport type UseForm<TOutput extends object> = ReturnType<\r\n typeof useForm<TOutput>\r\n>;\r\n","import { FieldPath } from \"@goodie-forms/core\";\r\nimport { useEffect, useState } from \"react\";\r\nimport { UseForm } from \"../hooks/useForm\";\r\nimport { useRenderControl } from \"../hooks/useRenderControl\";\r\nimport { composeFns } from \"../utils/composeFns\";\r\n\r\nexport function useFormField<\r\n TOutput extends object,\r\n TPath extends FieldPath.Segments,\r\n>(\r\n form: UseForm<TOutput>,\r\n path: TPath,\r\n bindingConfig?: Parameters<typeof form.controller.bindField<TPath>>[1],\r\n) {\r\n const renderControl = useRenderControl();\r\n\r\n const [field, setField] = useState(() => {\r\n let field = form.controller.getField(path);\r\n if (field == null && bindingConfig != null) {\r\n field = form.controller.bindField(path, bindingConfig);\r\n }\r\n return field;\r\n });\r\n\r\n useEffect(() => {\r\n const { events } = form.controller;\r\n\r\n setField(form.controller.getField(path));\r\n\r\n return composeFns(\r\n events.on(\"fieldBound\", (_path) => {\r\n if (!FieldPath.equals(_path, path)) return;\r\n setField(form.controller.getField(path));\r\n }),\r\n events.on(\"fieldUnbound\", (_path) => {\r\n if (!FieldPath.equals(_path, path)) return;\r\n setField(undefined);\r\n }),\r\n events.on(\"valueChanged\", (changedPath) => {\r\n if (\r\n FieldPath.equals(changedPath, path) ||\r\n FieldPath.isDescendant(changedPath, path)\r\n ) {\r\n renderControl.forceRerender();\r\n }\r\n }),\r\n events.on(\"fieldTouchUpdated\", (_path) => {\r\n if (!FieldPath.equals(_path, path)) return;\r\n renderControl.forceRerender();\r\n }),\r\n events.on(\"fieldDirtyUpdated\", (_path) => {\r\n if (!FieldPath.equals(_path, path)) return;\r\n renderControl.forceRerender();\r\n }),\r\n events.on(\"fieldIssuesUpdated\", (_path) => {\r\n if (!FieldPath.equals(_path, path)) return;\r\n renderControl.forceRerender();\r\n }),\r\n );\r\n }, []);\r\n\r\n return field;\r\n}\r\n","import { FieldPath } from \"@goodie-forms/core\";\r\nimport { useEffect } from \"react\";\r\nimport { composeFns } from \"../utils/composeFns\";\r\nimport type { UseForm } from \"./useForm\";\r\nimport { useRenderControl } from \"./useRenderControl\";\r\n\r\nexport function useFormValuesObserver<\r\n TOutput extends object,\r\n TPaths extends FieldPath.Segments[] | undefined = undefined,\r\n>(\r\n form: UseForm<TOutput>,\r\n options?: {\r\n include?: TPaths;\r\n },\r\n) {\r\n const renderControl = useRenderControl();\r\n\r\n const observedValues =\r\n options?.include == null\r\n ? form.controller._data\r\n : options.include.reduce((data, path) => {\r\n const value = FieldPath.getValue(\r\n form.controller._data as TOutput,\r\n path,\r\n )!;\r\n FieldPath.setValue(data, path, value);\r\n return data;\r\n }, {} as TOutput);\r\n\r\n useEffect(() => {\r\n const { events } = form.controller;\r\n\r\n return composeFns(\r\n events.on(\"valueChanged\", (changedPath) => {\r\n const watchingChange =\r\n options?.include == null\r\n ? true\r\n : options.include.some(\r\n (path) =>\r\n FieldPath.equals(path, changedPath) ||\r\n FieldPath.isDescendant(path, changedPath),\r\n );\r\n if (watchingChange) renderControl.forceRerender();\r\n }),\r\n );\r\n }, []);\r\n\r\n return observedValues;\r\n}\r\n","export function groupBy<T, K extends PropertyKey>(\r\n items: readonly T[],\r\n key: (item: T) => K,\r\n): Record<K, T[]> {\r\n const result = {} as Record<K, T[]>;\r\n\r\n for (const item of items) {\r\n const k = key(item);\r\n (result[k] ??= []).push(item);\r\n }\r\n\r\n return result;\r\n}\r\n","import { FieldPath } from \"@goodie-forms/core\";\r\nimport { groupBy } from \"../utils/groupBy\";\r\nimport { useEffect } from \"react\";\r\nimport { composeFns } from \"../utils/composeFns\";\r\nimport type { UseForm } from \"./useForm\";\r\nimport { useRenderControl } from \"./useRenderControl\";\r\n\r\nexport function useFormErrorObserver<\r\n TOutput extends object,\r\n TInclude extends FieldPath.Segments[] | undefined = undefined,\r\n>(\r\n form: UseForm<TOutput>,\r\n options?: {\r\n include?: TInclude;\r\n },\r\n) {\r\n const renderControl = useRenderControl();\r\n\r\n const observedIssues = form.controller._issues.filter((issue) => {\r\n if (options?.include == null) return true;\r\n const normalizedIssuePath = FieldPath.normalize(issue.path);\r\n return options.include.some((path) =>\r\n FieldPath.equals(path, normalizedIssuePath),\r\n );\r\n });\r\n\r\n useEffect(() => {\r\n const { events } = form.controller;\r\n\r\n return composeFns(\r\n events.on(\"fieldIssuesUpdated\", (path) => {\r\n if (options?.include?.includes?.(path) ?? true) {\r\n renderControl.forceRerender();\r\n }\r\n }),\r\n );\r\n }, []);\r\n\r\n return groupBy(observedIssues, (issue) =>\r\n issue.path == null\r\n ? \"$\"\r\n : FieldPath.toStringPath(FieldPath.normalize(issue.path)),\r\n );\r\n}\r\n","import { FieldPath, FormField, NonnullFormField } from \"@goodie-forms/core\";\r\nimport {\r\n ChangeEvent,\r\n FocusEvent,\r\n ReactNode,\r\n Ref,\r\n useEffect,\r\n useRef,\r\n} from \"react\";\r\nimport { useForm, UseForm } from \"../hooks/useForm\";\r\nimport { useFormField } from \"../hooks/useFormField\";\r\nimport { composeFns } from \"../utils/composeFns\";\r\n\r\nexport interface RenderParams<TOutput extends object, TValue> {\r\n ref: Ref<any | null>;\r\n\r\n value: TValue | undefined;\r\n\r\n handlers: {\r\n onChange: (event: ChangeEvent<EventTarget>) => void;\r\n onFocus: (event: FocusEvent) => void;\r\n onBlur: (event: FocusEvent) => void;\r\n };\r\n\r\n field: undefined extends TValue\r\n ? FormField<TOutput, TValue>\r\n : NonnullFormField<TOutput, TValue>;\r\n}\r\n\r\ntype DefaultValueProps<TValue> = undefined extends TValue\r\n ? { defaultValue?: TValue | (() => TValue) }\r\n : { defaultValue: TValue | (() => TValue) };\r\n\r\nexport type FieldRendererProps<\r\n TOutput extends object,\r\n TPath extends FieldPath.Segments,\r\n> = {\r\n form: UseForm<TOutput>;\r\n path: TPath;\r\n overrideInitialValue?: boolean;\r\n unbindOnUnmount?: boolean;\r\n render: (\r\n params: RenderParams<TOutput, FieldPath.Resolve<TOutput, NoInfer<TPath>>>,\r\n ) => ReactNode;\r\n} & DefaultValueProps<FieldPath.Resolve<TOutput, NoInfer<TPath>>>;\r\n\r\nexport function FieldRenderer<\r\n TOutput extends object,\r\n const TPath extends FieldPath.Segments,\r\n>(props: FieldRendererProps<TOutput, TPath>) {\r\n type TValue = FieldPath.Resolve<TOutput, TPath>;\r\n\r\n const elementRef = useRef<HTMLElement>(null);\r\n\r\n const field = useFormField(props.form, props.path, {\r\n overrideInitialValue: props.overrideInitialValue ?? true,\r\n defaultValue:\r\n typeof props.defaultValue === \"function\"\r\n ? (props.defaultValue as any)()\r\n : props.defaultValue,\r\n })!;\r\n\r\n const handlers: RenderParams<TOutput, TValue>[\"handlers\"] = {\r\n onChange(event) {\r\n const { target } = event;\r\n if (target !== field.boundElement) return;\r\n if (!(\"value\" in target)) return;\r\n if (typeof target.value !== \"string\") return;\r\n field.setValue(target.value as TValue, {\r\n shouldTouch: true,\r\n shouldMarkDirty: true,\r\n });\r\n },\r\n onFocus() {\r\n field.touch();\r\n },\r\n onBlur() {\r\n if (\r\n props.form.hookConfigs?.validateMode === \"onBlur\" ||\r\n props.form.hookConfigs?.validateMode === \"onChange\"\r\n ) {\r\n props.form.controller.validateField(props.path);\r\n }\r\n },\r\n };\r\n\r\n useEffect(() => {\r\n const { events } = props.form.controller;\r\n\r\n return composeFns(\r\n events.on(\"valueChanged\", (_path) => {\r\n if (\r\n !FieldPath.equals(_path, props.path) &&\r\n !FieldPath.isDescendant(_path, props.path)\r\n ) {\r\n return;\r\n }\r\n\r\n if (props.form.hookConfigs?.validateMode === \"onChange\") {\r\n props.form.controller.validateField(props.path);\r\n }\r\n }),\r\n );\r\n }, []);\r\n\r\n useEffect(() => {\r\n field.bindElement(elementRef.current!);\r\n\r\n return () => {\r\n if (props.unbindOnUnmount) {\r\n props.form.controller.unbindField(props.path);\r\n }\r\n };\r\n }, []);\r\n\r\n return (\r\n <>\r\n {props.render({\r\n ref: elementRef,\r\n value: field.value,\r\n handlers: handlers,\r\n field: field as any,\r\n })}\r\n </>\r\n );\r\n}\r\n\r\n/* ---- TESTS ---------------- */\r\n\r\n// function TestComp() {\r\n// const form = useForm<{ a?: { b: 99 } }>({});\r\n\r\n// const jsx = (\r\n// <>\r\n// <FieldRenderer\r\n// form={form}\r\n// path={form.paths.fromProxy((data) => data.a.b)}\r\n// defaultValue={() => 99 as const}\r\n// render={({ ref, value, handlers, field }) => {\r\n// // ^?\r\n// return <></>;\r\n// }}\r\n// />\r\n\r\n// {/* defaultField olmayabilir, çünkü \"a\" nullable */}\r\n// <FieldRenderer\r\n// form={form}\r\n// path={form.paths.fromProxy((data) => data.a)}\r\n// render={({ ref, value, handlers, field }) => {\r\n// // ^?\r\n// return <></>;\r\n// }}\r\n// />\r\n\r\n// <FieldRenderer\r\n// form={form}\r\n// path={form.paths.fromStringPath(\"a.b\")}\r\n// defaultValue={() => 99 as const}\r\n// render={({ ref, value, handlers, field }) => {\r\n// // ^?\r\n// return <></>;\r\n// }}\r\n// />\r\n// </>\r\n// );\r\n// }\r\n"],"names":["useRenderControl","rerender","useState","renderCount","useRef","renderScheduled","scheduleRerender","startTransition","i","composeFns","fns","fn","useForm","formConfigs","hookConfigs","controller","FormController","paths","FieldPathBuilder","renderControl","useEffect","noop","useFormField","form","path","bindingConfig","field","setField","events","_path","FieldPath","changedPath","useFormValuesObserver","options","observedValues","data","value","groupBy","items","key","result","item","k","useFormErrorObserver","observedIssues","issue","normalizedIssuePath","FieldRenderer","props","elementRef","handlers","event","target","jsx","Fragment"],"mappings":";;;AAEO,SAASA,IAAmB;AACjC,QAAM,GAAGC,CAAQ,IAAIC,EAAS,CAAC,GACzBC,IAAcC,EAAO,CAAC,GACtBC,IAAkBD,EAAO,EAAK;AACpC,EAAAD,EAAY;AAEZ,QAAMG,IAAmB,MAAM;AAC7B,IAAID,EAAgB,YACpBA,EAAgB,UAAU,IAE1B,eAAe,MAAM;AACnB,MAAAE,EAAgB,MAAM;AACpB,QAAAN,EAAS,CAACO,MAAMA,IAAI,CAAC;AAAA,MACvB,CAAC,GAEDH,EAAgB,UAAU;AAAA,IAC5B,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,aAAaF,EAAY;AAAA,IACzB,eAAeG;AAAA,EAAA;AAEnB;ACzBO,SAASG,KAA2CC,GAAW;AACpE,SAAO,MAAM;AACX,eAAWC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ED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodie-forms/react",
3
- "version": "1.1.6-alpha",
3
+ "version": "1.2.0-alpha",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "react-dom": "^18 || ^19"
19
19
  },
20
20
  "dependencies": {
21
- "@goodie-forms/core": "1.1.6-alpha"
21
+ "@goodie-forms/core": "1.2.0-alpha"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/react": "^19.2.9",