@companix/formkit 0.0.5 → 0.0.7
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/README.md +21 -11
- package/dist/bundle.es.js +142 -141
- package/dist/index.d.ts +1 -0
- package/dist/manager/manager.d.ts +1 -0
- package/dist/useForm.d.ts +4 -13
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
## Create form primitives
|
|
2
2
|
|
|
3
3
|
```tsx
|
|
4
|
-
const SelectForm = (name: string
|
|
5
|
-
|
|
4
|
+
const SelectForm = (name: string) => {
|
|
5
|
+
// select form code
|
|
6
|
+
}
|
|
7
|
+
const InputForm = (name: string) => {
|
|
8
|
+
// input form code
|
|
9
|
+
}
|
|
6
10
|
```
|
|
7
11
|
|
|
8
12
|
## Create layouts
|
|
9
13
|
|
|
10
14
|
```tsx
|
|
11
|
-
const Label = (
|
|
12
|
-
return ({ children }) =>
|
|
13
|
-
}
|
|
15
|
+
export const Label = createLayout((label: React.ReactNode) => {
|
|
16
|
+
return ({ children }) => {
|
|
17
|
+
return <FormGroup label={label}>{children}</FormGroup>
|
|
18
|
+
}
|
|
19
|
+
})
|
|
14
20
|
|
|
15
|
-
const Double = () => {
|
|
16
|
-
return () => {
|
|
17
|
-
return
|
|
21
|
+
export const Double = createLayout(() => {
|
|
22
|
+
return ({ children }) => {
|
|
23
|
+
return <div className="form-double-primitive">{children}</div>
|
|
18
24
|
}
|
|
19
|
-
}
|
|
25
|
+
})
|
|
20
26
|
|
|
21
|
-
const Splitter = () => {
|
|
27
|
+
export const Splitter = createLayout(() => {
|
|
28
|
+
return () => {
|
|
29
|
+
return <div className="form-splitter" />
|
|
30
|
+
}
|
|
31
|
+
})
|
|
22
32
|
```
|
|
23
33
|
|
|
24
|
-
##
|
|
34
|
+
## Create a scheme
|
|
25
35
|
|
|
26
36
|
```ts
|
|
27
37
|
const scheme = [
|
package/dist/bundle.es.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
1
|
+
import { jsx as b, Fragment as B, jsxs as P } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as T, useState as q, useContext as L, useEffect as D, useMemo as A, useCallback as S, useRef as N } from "react";
|
|
3
3
|
import R from "fast-deep-equal";
|
|
4
|
-
const j =
|
|
5
|
-
const [, r] = q([]), o = L(j),
|
|
4
|
+
const j = T({}), M = (s) => {
|
|
5
|
+
const [, r] = q([]), o = L(j), e = o.getForm(s);
|
|
6
6
|
return D(() => {
|
|
7
|
-
const { unsubscribe:
|
|
7
|
+
const { unsubscribe: t } = o.subscribeToForm(s, () => {
|
|
8
8
|
r([]);
|
|
9
9
|
});
|
|
10
10
|
return () => {
|
|
11
|
-
|
|
11
|
+
t();
|
|
12
12
|
};
|
|
13
|
-
}, []),
|
|
13
|
+
}, []), e?.value;
|
|
14
14
|
}, _ = ({ canActivate: s, name: r, children: o }) => {
|
|
15
|
-
const
|
|
16
|
-
return s(
|
|
15
|
+
const e = M(r);
|
|
16
|
+
return s(e) ? /* @__PURE__ */ b(B, { children: o }) : null;
|
|
17
17
|
}, z = ({ item: { Form: s }, name: r }) => {
|
|
18
|
-
const [, o] = q([]),
|
|
18
|
+
const [, o] = q([]), e = L(j), { unregistry: t } = A(() => e.registry(r, () => {
|
|
19
19
|
o([]);
|
|
20
20
|
}), []), l = S(
|
|
21
21
|
(d) => {
|
|
22
22
|
if (d && d.focus) {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const g = e.getForm(r);
|
|
24
|
+
g.focus = () => {
|
|
25
25
|
d.focus();
|
|
26
26
|
};
|
|
27
27
|
}
|
|
@@ -29,143 +29,143 @@ const j = N({}), M = (s) => {
|
|
|
29
29
|
[r]
|
|
30
30
|
);
|
|
31
31
|
D(() => () => {
|
|
32
|
-
|
|
32
|
+
t();
|
|
33
33
|
}, []);
|
|
34
|
-
const { value:
|
|
35
|
-
return /* @__PURE__ */
|
|
34
|
+
const { value: y, error: F } = e.getForm(r);
|
|
35
|
+
return /* @__PURE__ */ b(
|
|
36
36
|
s,
|
|
37
37
|
{
|
|
38
38
|
field: {
|
|
39
|
-
value:
|
|
39
|
+
value: y,
|
|
40
40
|
onChange: (d) => {
|
|
41
|
-
|
|
41
|
+
e.onChange(r, d);
|
|
42
42
|
},
|
|
43
43
|
onBlur: () => {
|
|
44
44
|
},
|
|
45
45
|
ref: l
|
|
46
46
|
},
|
|
47
47
|
isDirty: !1,
|
|
48
|
-
error:
|
|
49
|
-
disabled:
|
|
48
|
+
error: F,
|
|
49
|
+
disabled: e.disabled
|
|
50
50
|
}
|
|
51
51
|
);
|
|
52
52
|
}, G = ({ item: s, path: r }) => {
|
|
53
|
-
const { getController: o, items:
|
|
53
|
+
const { getController: o, items: e } = s, t = L(j), l = A(() => {
|
|
54
54
|
const i = {};
|
|
55
|
-
return
|
|
56
|
-
i[f] =
|
|
55
|
+
return e.forEach(({ name: f, getForm: x }) => {
|
|
56
|
+
i[f] = x(f, () => p(f));
|
|
57
57
|
}), i;
|
|
58
|
-
}, []),
|
|
58
|
+
}, []), y = S(() => {
|
|
59
59
|
const i = [];
|
|
60
|
-
return
|
|
61
|
-
|
|
60
|
+
return e.forEach(({ name: f }) => {
|
|
61
|
+
t.getForm([...r, f].join(".")).value !== void 0 && i.push(f);
|
|
62
62
|
}), i;
|
|
63
|
-
}, []),
|
|
63
|
+
}, []), F = A(() => y(), []), [d, g] = q(F);
|
|
64
64
|
D(() => {
|
|
65
|
-
const { unregistry: i } =
|
|
66
|
-
|
|
65
|
+
const { unregistry: i } = t.registryExtraForm(
|
|
66
|
+
e.map(({ name: f }) => [...r, f].join(".")),
|
|
67
67
|
() => {
|
|
68
|
-
|
|
68
|
+
g(y());
|
|
69
69
|
}
|
|
70
70
|
);
|
|
71
71
|
return () => {
|
|
72
72
|
i();
|
|
73
73
|
};
|
|
74
74
|
}, []);
|
|
75
|
-
const
|
|
75
|
+
const v = S(
|
|
76
76
|
(i) => {
|
|
77
|
-
l[i] && !d.includes(i) &&
|
|
77
|
+
l[i] && !d.includes(i) && g((f) => [...f, i]);
|
|
78
78
|
},
|
|
79
79
|
[d]
|
|
80
|
-
),
|
|
81
|
-
|
|
80
|
+
), p = S((i) => {
|
|
81
|
+
g((f) => f.filter((x) => x !== i));
|
|
82
82
|
}, []);
|
|
83
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ P(B, { children: [
|
|
84
84
|
d.map((i) => {
|
|
85
85
|
const f = l[i];
|
|
86
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ b(V, { path: r, scheme: [f] }, `param-form--${i}`);
|
|
87
87
|
}),
|
|
88
|
-
o(
|
|
88
|
+
o(v, d)
|
|
89
89
|
] });
|
|
90
|
-
},
|
|
91
|
-
|
|
90
|
+
}, V = ({ scheme: s, path: r, className: o }) => /* @__PURE__ */ b("div", { className: o, children: s.map((e, t) => e.type === "layout" ? /* @__PURE__ */ b(e.Layout, { children: /* @__PURE__ */ b(V, { path: r, scheme: e.childs }) }, `layout-form--${t}-${r.length}`) : e.type === "context" ? /* @__PURE__ */ b(
|
|
91
|
+
V,
|
|
92
92
|
{
|
|
93
|
-
path: [...r,
|
|
94
|
-
scheme:
|
|
93
|
+
path: [...r, e.context],
|
|
94
|
+
scheme: e.childs
|
|
95
95
|
},
|
|
96
|
-
`context-form--${
|
|
97
|
-
) :
|
|
96
|
+
`context-form--${t}-${e.context}-${r.length}`
|
|
97
|
+
) : e.type === "condition" ? /* @__PURE__ */ b(
|
|
98
98
|
_,
|
|
99
99
|
{
|
|
100
|
-
name:
|
|
101
|
-
canActivate:
|
|
102
|
-
children: /* @__PURE__ */
|
|
100
|
+
name: e.depended,
|
|
101
|
+
canActivate: e.canActivate,
|
|
102
|
+
children: /* @__PURE__ */ b(V, { path: r, scheme: e.childs })
|
|
103
103
|
},
|
|
104
|
-
`condition--${
|
|
105
|
-
) :
|
|
104
|
+
`condition--${t}-${e.depended}-${r.length}`
|
|
105
|
+
) : e.type === "extra" ? /* @__PURE__ */ b(G, { path: r, item: e }, `partial-item--${t}-${r.length}`) : /* @__PURE__ */ b(
|
|
106
106
|
z,
|
|
107
107
|
{
|
|
108
|
-
name: [...r,
|
|
109
|
-
item:
|
|
108
|
+
name: [...r, e.name].join("."),
|
|
109
|
+
item: e
|
|
110
110
|
},
|
|
111
|
-
`form-item--${
|
|
112
|
-
)) }),
|
|
113
|
-
s.forEach((
|
|
114
|
-
if (
|
|
115
|
-
|
|
111
|
+
`form-item--${t}-${e.name}-${r.length}`
|
|
112
|
+
)) }), C = (s, r, o, e) => {
|
|
113
|
+
s.forEach((t) => {
|
|
114
|
+
if (t.type === "form" && e(t, [...r, t.name].join("."), o[t.name]), t.type === "context") {
|
|
115
|
+
C(t.childs, [...r, t.context], o[t.context] ?? {}, e);
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
|
-
if (
|
|
119
|
-
|
|
118
|
+
if (t.type === "layout" || t.type === "condition") {
|
|
119
|
+
C(t.childs, r, o, e);
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
})], r, o,
|
|
122
|
+
t.type === "extra" && t.items.forEach(({ getForm: l, name: y }) => {
|
|
123
|
+
C([l(y, () => {
|
|
124
|
+
})], r, o, e);
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
|
-
},
|
|
128
|
-
s.forEach((
|
|
129
|
-
if (
|
|
130
|
-
const l = [...o,
|
|
131
|
-
|
|
127
|
+
}, E = ({ scheme: s, values: r, path: o, forms: e }) => {
|
|
128
|
+
s.forEach((t) => {
|
|
129
|
+
if (t.type === "form") {
|
|
130
|
+
const l = [...o, t.name].join(".");
|
|
131
|
+
e[l].value !== void 0 && (r[t.name] = e[l].value);
|
|
132
132
|
}
|
|
133
|
-
if (
|
|
134
|
-
r[
|
|
135
|
-
scheme:
|
|
136
|
-
path: [...o,
|
|
137
|
-
values: r[
|
|
138
|
-
forms:
|
|
133
|
+
if (t.type === "context") {
|
|
134
|
+
r[t.context] = {}, E({
|
|
135
|
+
scheme: t.childs,
|
|
136
|
+
path: [...o, t.context],
|
|
137
|
+
values: r[t.context],
|
|
138
|
+
forms: e
|
|
139
139
|
});
|
|
140
140
|
return;
|
|
141
141
|
}
|
|
142
|
-
if (
|
|
143
|
-
|
|
142
|
+
if (t.type === "layout") {
|
|
143
|
+
E({ scheme: t.childs, path: o, values: r, forms: e });
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
-
if (
|
|
147
|
-
const l = t
|
|
148
|
-
if (
|
|
149
|
-
|
|
146
|
+
if (t.type === "condition") {
|
|
147
|
+
const l = e[t.depended]?.value;
|
|
148
|
+
if (t.canActivate(l)) {
|
|
149
|
+
E({ scheme: t.childs, path: o, values: r, forms: e });
|
|
150
150
|
return;
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
})], path: o, values: r, forms:
|
|
153
|
+
t.type === "extra" && t.items.forEach(({ getForm: l, name: y }) => {
|
|
154
|
+
E({ scheme: [l(y, () => {
|
|
155
|
+
})], path: o, values: r, forms: e });
|
|
156
156
|
});
|
|
157
157
|
});
|
|
158
158
|
}, w = (s, r) => {
|
|
159
159
|
const o = {};
|
|
160
|
-
return
|
|
160
|
+
return E({ scheme: s, path: [], values: o, forms: r }), o;
|
|
161
161
|
}, H = (s, r) => {
|
|
162
|
-
const { onSubmit: o, onEqual:
|
|
163
|
-
let
|
|
162
|
+
const { onSubmit: o, onEqual: e, disabled: t, onDirty: l, onFormDirty: y, onChangeEvent: F, defaultValues: d } = r;
|
|
163
|
+
let g = !1, v = !1, p = 0;
|
|
164
164
|
const i = {}, f = {
|
|
165
165
|
subscribers: [],
|
|
166
166
|
names: {}
|
|
167
167
|
};
|
|
168
|
-
|
|
168
|
+
C(s, [], d ?? {}, (n, c, u) => {
|
|
169
169
|
i[c] = {
|
|
170
170
|
error: null,
|
|
171
171
|
isDirty: !1,
|
|
@@ -178,16 +178,17 @@ const j = N({}), M = (s) => {
|
|
|
178
178
|
validate: n.validate
|
|
179
179
|
};
|
|
180
180
|
});
|
|
181
|
-
const
|
|
182
|
-
l?.({ name: n, isDirty: c }), c &&
|
|
181
|
+
const x = (n, c) => {
|
|
182
|
+
l?.({ name: n, isDirty: c }), c && p === 0 && y?.(!0), !c && p === 1 && y?.(!1), p += c ? 1 : -1;
|
|
183
183
|
};
|
|
184
184
|
return {
|
|
185
|
-
|
|
185
|
+
scheme: s,
|
|
186
|
+
disabled: t,
|
|
186
187
|
activate() {
|
|
187
|
-
|
|
188
|
+
g = !0;
|
|
188
189
|
},
|
|
189
190
|
disactivate() {
|
|
190
|
-
|
|
191
|
+
g = !1;
|
|
191
192
|
},
|
|
192
193
|
setError(n, c) {
|
|
193
194
|
const u = this.getForm(n);
|
|
@@ -208,29 +209,29 @@ const j = N({}), M = (s) => {
|
|
|
208
209
|
return w(s, i);
|
|
209
210
|
},
|
|
210
211
|
async handleSubmit() {
|
|
211
|
-
if (
|
|
212
|
+
if (t)
|
|
212
213
|
return;
|
|
213
|
-
|
|
214
|
+
v = !0;
|
|
214
215
|
let n = !1, c = !1;
|
|
215
216
|
for (const u in i) {
|
|
216
217
|
const a = i[u];
|
|
217
218
|
if (a.value !== void 0) {
|
|
218
|
-
const
|
|
219
|
-
|
|
219
|
+
const h = a.validate(a.value);
|
|
220
|
+
h && (c = !0, a.error = h, a.rerender(), !n && a.focus && (a.focus(), n = !0));
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
if (!c) {
|
|
223
|
-
if (
|
|
224
|
-
|
|
224
|
+
if (p === 0) {
|
|
225
|
+
e?.();
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
227
228
|
const u = w(s, i);
|
|
228
229
|
await o(u, {
|
|
229
|
-
setError: (a,
|
|
230
|
+
setError: (a, h) => {
|
|
230
231
|
const m = this.getForm(a);
|
|
231
232
|
m.error = {
|
|
232
233
|
error: !0,
|
|
233
|
-
messages: [
|
|
234
|
+
messages: [h.message]
|
|
234
235
|
}, m.rerender();
|
|
235
236
|
}
|
|
236
237
|
});
|
|
@@ -238,14 +239,14 @@ const j = N({}), M = (s) => {
|
|
|
238
239
|
},
|
|
239
240
|
reset(n) {
|
|
240
241
|
const c = [];
|
|
241
|
-
|
|
242
|
-
if (
|
|
242
|
+
C(s, [], n, (u, a, h) => {
|
|
243
|
+
if (h === void 0 && i[a].value === void 0)
|
|
243
244
|
return;
|
|
244
|
-
if (f.names[a] &&
|
|
245
|
-
c.push(a), i[a].value =
|
|
245
|
+
if (f.names[a] && h === void 0) {
|
|
246
|
+
c.push(a), i[a].value = h;
|
|
246
247
|
return;
|
|
247
248
|
}
|
|
248
|
-
const m =
|
|
249
|
+
const m = h ?? u.defaultValue;
|
|
249
250
|
i[a].value !== m && (c.push(a), this.onChange(a, m));
|
|
250
251
|
}), c.some((u) => f.names[u]) && f.subscribers.forEach(({ callback: u }) => {
|
|
251
252
|
u();
|
|
@@ -255,10 +256,10 @@ const j = N({}), M = (s) => {
|
|
|
255
256
|
return i[n].rerender = c, i[n].value === void 0 && (i[n].value = i[n].defaultValue), {
|
|
256
257
|
unregistry() {
|
|
257
258
|
if (i[n].rerender = () => {
|
|
258
|
-
}, i[n].focus = void 0,
|
|
259
|
+
}, i[n].focus = void 0, g) {
|
|
259
260
|
i[n].value = void 0;
|
|
260
261
|
const u = !R(i[n].defaultValue, i[n].initValue);
|
|
261
|
-
i[n].isDirty !== u &&
|
|
262
|
+
i[n].isDirty !== u && x(n, u), i[n].isDirty = u;
|
|
262
263
|
}
|
|
263
264
|
}
|
|
264
265
|
};
|
|
@@ -270,7 +271,7 @@ const j = N({}), M = (s) => {
|
|
|
270
271
|
const u = { callback: c }, a = this.getForm(n);
|
|
271
272
|
return a.subscribers.push(u), {
|
|
272
273
|
unsubscribe: () => {
|
|
273
|
-
a.subscribers = a.subscribers.filter((
|
|
274
|
+
a.subscribers = a.subscribers.filter((h) => h !== u);
|
|
274
275
|
}
|
|
275
276
|
};
|
|
276
277
|
},
|
|
@@ -286,40 +287,40 @@ const j = N({}), M = (s) => {
|
|
|
286
287
|
},
|
|
287
288
|
onChange(n, c) {
|
|
288
289
|
const u = this.getForm(n), a = !R(c, u.initValue);
|
|
289
|
-
u.isDirty !== a &&
|
|
290
|
-
|
|
290
|
+
u.isDirty !== a && x(n, a), u.isDirty = a, F?.({ name: n, value: c }), (u.error || v) && (u.error = u.validate(c) || null), u.value = c, u.rerender(), u.subscribers.forEach(({ callback: h }) => {
|
|
291
|
+
h();
|
|
291
292
|
});
|
|
292
293
|
}
|
|
293
294
|
};
|
|
294
295
|
}, Q = (s, r) => {
|
|
295
|
-
const o =
|
|
296
|
+
const o = N(null);
|
|
296
297
|
o.current === null && (o.current = H(s, r));
|
|
297
|
-
const
|
|
298
|
+
const e = o.current;
|
|
298
299
|
return {
|
|
299
|
-
useValue: (
|
|
300
|
-
reset: (
|
|
301
|
-
|
|
300
|
+
useValue: (t) => M(t),
|
|
301
|
+
reset: (t) => {
|
|
302
|
+
e.reset(t);
|
|
302
303
|
},
|
|
303
|
-
setFocus: (
|
|
304
|
-
|
|
304
|
+
setFocus: (t) => {
|
|
305
|
+
e.setFocus(t);
|
|
305
306
|
},
|
|
306
|
-
setError: (
|
|
307
|
-
|
|
307
|
+
setError: (t, l) => {
|
|
308
|
+
e.setError(t, l);
|
|
308
309
|
},
|
|
309
|
-
setValue: (
|
|
310
|
-
|
|
310
|
+
setValue: (t, l) => {
|
|
311
|
+
e.setValue(t, l);
|
|
311
312
|
},
|
|
312
|
-
getValues: () =>
|
|
313
|
+
getValues: () => e.getValues(),
|
|
313
314
|
handleSubmit: async () => {
|
|
314
|
-
await
|
|
315
|
+
await e.handleSubmit();
|
|
315
316
|
},
|
|
316
|
-
|
|
317
|
+
manager: e
|
|
317
318
|
};
|
|
318
|
-
}, U = ({
|
|
319
|
-
s.
|
|
319
|
+
}, U = ({ manager: s, className: r }) => (A(() => {
|
|
320
|
+
s.activate();
|
|
320
321
|
}, []), D(() => () => {
|
|
321
|
-
s.
|
|
322
|
-
}, []), /* @__PURE__ */
|
|
322
|
+
s.disactivate();
|
|
323
|
+
}, []), /* @__PURE__ */ b(j.Provider, { value: s, children: /* @__PURE__ */ b(V, { className: r, scheme: s.scheme, path: [] }) })), $ = (s) => {
|
|
323
324
|
try {
|
|
324
325
|
s();
|
|
325
326
|
} catch (r) {
|
|
@@ -334,28 +335,28 @@ const j = N({}), M = (s) => {
|
|
|
334
335
|
};
|
|
335
336
|
}
|
|
336
337
|
}, W = (s) => (r, o) => {
|
|
337
|
-
const
|
|
338
|
+
const e = s.getRequireCheck(o), { $rules: t = {}, ...l } = o, { validate: y, required: F } = t;
|
|
338
339
|
return {
|
|
339
340
|
type: "form",
|
|
340
341
|
name: r,
|
|
341
342
|
defaultValue: s.defaultValue,
|
|
342
|
-
Form: s.getForm(
|
|
343
|
-
validate: (
|
|
344
|
-
if (
|
|
345
|
-
const
|
|
346
|
-
if (
|
|
347
|
-
return
|
|
348
|
-
if (
|
|
349
|
-
const
|
|
350
|
-
if (
|
|
351
|
-
return
|
|
343
|
+
Form: s.getForm(l),
|
|
344
|
+
validate: (d) => {
|
|
345
|
+
if (F) {
|
|
346
|
+
const g = $(() => e(d));
|
|
347
|
+
if (g)
|
|
348
|
+
return g;
|
|
349
|
+
if (y) {
|
|
350
|
+
const v = $(() => y(d));
|
|
351
|
+
if (v)
|
|
352
|
+
return v;
|
|
352
353
|
}
|
|
353
354
|
return;
|
|
354
355
|
}
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
if (
|
|
358
|
-
return
|
|
356
|
+
if (y && !$(() => e(d))) {
|
|
357
|
+
const v = $(() => y(d));
|
|
358
|
+
if (v)
|
|
359
|
+
return v;
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
362
|
};
|
|
@@ -368,10 +369,10 @@ const j = N({}), M = (s) => {
|
|
|
368
369
|
getController: r
|
|
369
370
|
}) => ({
|
|
370
371
|
type: "extra",
|
|
371
|
-
items: s((o) => (
|
|
372
|
+
items: s((o) => (e) => ({
|
|
372
373
|
type: "registry",
|
|
373
374
|
name: o,
|
|
374
|
-
getForm:
|
|
375
|
+
getForm: e
|
|
375
376
|
})),
|
|
376
377
|
getController: r
|
|
377
378
|
}), Z = (s) => (...r) => ({
|
package/dist/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { createLayout } from './core/builders/create-layout';
|
|
|
4
4
|
export { createExtraForm } from './core/builders/create-extra-form';
|
|
5
5
|
export { Condition, Context } from './core/builders/syntax';
|
|
6
6
|
export type { FieldError } from './core/types';
|
|
7
|
+
export type { FormManager } from './manager/manager';
|
package/dist/useForm.d.ts
CHANGED
|
@@ -45,10 +45,7 @@ declare const useDynamicForm: (scheme: SchemeItems.All[], opts: MainOptions<Fiel
|
|
|
45
45
|
[x: string]: any;
|
|
46
46
|
};
|
|
47
47
|
handleSubmit: () => Promise<void>;
|
|
48
|
-
|
|
49
|
-
manager: FormManager<FieldValues, FieldValues>;
|
|
50
|
-
scheme: [];
|
|
51
|
-
};
|
|
48
|
+
manager: FormManager<FieldValues, FieldValues>;
|
|
52
49
|
};
|
|
53
50
|
declare const useForm: <Items extends SchemeItems.All[], Values extends ExtractValues<Items[number]>, FlattenValues extends ExtractFlatValues<Items[number]>, Cloned extends Copy<Values>>(scheme: Items, opts: MainOptions<Values, FlattenValues, Cloned>) => {
|
|
54
51
|
useValue: <K extends keyof FlattenValues>(name: K) => FlattenValues[K];
|
|
@@ -60,17 +57,11 @@ declare const useForm: <Items extends SchemeItems.All[], Values extends ExtractV
|
|
|
60
57
|
setValue: <K extends keyof FlattenValues>(name: K, value: FlattenValues[K]) => void;
|
|
61
58
|
getValues: () => DeepPartial<Cloned>;
|
|
62
59
|
handleSubmit: () => Promise<void>;
|
|
63
|
-
|
|
64
|
-
manager: FormManager<FlattenValues, Cloned>;
|
|
65
|
-
scheme: Items;
|
|
66
|
-
};
|
|
60
|
+
manager: FormManager<FlattenValues, Cloned>;
|
|
67
61
|
};
|
|
68
62
|
interface Props {
|
|
69
63
|
className?: string;
|
|
70
|
-
|
|
71
|
-
manager: FormManager<any, any>;
|
|
72
|
-
scheme: SchemeItems.All[];
|
|
73
|
-
};
|
|
64
|
+
manager: FormManager<any, any>;
|
|
74
65
|
}
|
|
75
|
-
export declare const FormLayout: ({
|
|
66
|
+
export declare const FormLayout: ({ manager, className }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
76
67
|
export { useForm, useDynamicForm };
|
package/package.json
CHANGED