@companix/formkit 0.0.27 → 0.0.28
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/dist/bundle.es.js +126 -112
- package/dist/manager/manager.d.ts +2 -0
- package/dist/useForm.d.ts +4 -0
- package/package.json +1 -1
package/dist/bundle.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as h, Fragment as
|
|
2
|
-
import { createContext as M, useState as
|
|
1
|
+
import { jsx as h, Fragment as w, jsxs as B } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as M, useState as R, useContext as T, useMemo as S, useEffect as $, useCallback as D, useRef as P } from "react";
|
|
3
3
|
import L from "fast-deep-equal";
|
|
4
|
-
const
|
|
5
|
-
const [, r] =
|
|
4
|
+
const j = M({}), q = (o) => {
|
|
5
|
+
const [, r] = R([]), e = T(j);
|
|
6
6
|
if (!e)
|
|
7
7
|
throw new Error("useValue cannot be used outside Form context");
|
|
8
|
-
const s =
|
|
8
|
+
const s = S(() => {
|
|
9
9
|
const t = e.getForm(o);
|
|
10
10
|
if (!t)
|
|
11
11
|
throw new Error(`form with name "${o}" doesnt exist in form`);
|
|
@@ -19,18 +19,18 @@ const D = M({}), q = (o) => {
|
|
|
19
19
|
t();
|
|
20
20
|
};
|
|
21
21
|
}, []), s.value;
|
|
22
|
-
},
|
|
22
|
+
}, K = () => (o) => q(o), O = ({ canActivate: o, name: r, children: e }) => {
|
|
23
23
|
const s = q(r);
|
|
24
|
-
return o(s) ? /* @__PURE__ */ h(
|
|
24
|
+
return o(s) ? /* @__PURE__ */ h(w, { children: e }) : null;
|
|
25
25
|
}, U = ({ item: { Form: o }, name: r }) => {
|
|
26
|
-
const [, e] =
|
|
26
|
+
const [, e] = R([]), s = T(j), { unregistry: t } = S(() => s.registry(r, () => {
|
|
27
27
|
e([]);
|
|
28
|
-
}), []), l =
|
|
29
|
-
(
|
|
30
|
-
if (
|
|
28
|
+
}), []), l = D(
|
|
29
|
+
(b) => {
|
|
30
|
+
if (b && b.focus) {
|
|
31
31
|
const v = s.getForm(r);
|
|
32
32
|
v.focus = () => {
|
|
33
|
-
|
|
33
|
+
b.focus();
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -39,107 +39,107 @@ const D = M({}), q = (o) => {
|
|
|
39
39
|
$(() => () => {
|
|
40
40
|
t();
|
|
41
41
|
}, []);
|
|
42
|
-
const { value: g, error:
|
|
42
|
+
const { value: g, error: x } = s.getForm(r);
|
|
43
43
|
return /* @__PURE__ */ h(
|
|
44
44
|
o,
|
|
45
45
|
{
|
|
46
46
|
field: {
|
|
47
47
|
value: g,
|
|
48
|
-
onChange: (
|
|
49
|
-
s.onChange(r,
|
|
48
|
+
onChange: (b) => {
|
|
49
|
+
s.onChange(r, b);
|
|
50
50
|
},
|
|
51
51
|
onBlur: () => {
|
|
52
52
|
},
|
|
53
53
|
ref: l
|
|
54
54
|
},
|
|
55
55
|
isDirty: !1,
|
|
56
|
-
error:
|
|
56
|
+
error: x,
|
|
57
57
|
disabled: s.disabled
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
|
-
},
|
|
61
|
-
const { getController: e, items: s } = o, t =
|
|
62
|
-
const
|
|
63
|
-
return s.forEach(({ name:
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
}, []), g =
|
|
67
|
-
const
|
|
68
|
-
return s.forEach(({ name:
|
|
69
|
-
t.getForm([...r,
|
|
70
|
-
}),
|
|
71
|
-
}, []),
|
|
60
|
+
}, _ = ({ item: o, path: r }) => {
|
|
61
|
+
const { getController: e, items: s } = o, t = T(j), l = S(() => {
|
|
62
|
+
const y = {};
|
|
63
|
+
return s.forEach(({ name: d, getForm: V }) => {
|
|
64
|
+
y[d] = V(d, () => a(d));
|
|
65
|
+
}), y;
|
|
66
|
+
}, []), g = D(() => {
|
|
67
|
+
const y = [];
|
|
68
|
+
return s.forEach(({ name: d }) => {
|
|
69
|
+
t.getForm([...r, d].join(".")).value !== void 0 && y.push(d);
|
|
70
|
+
}), y;
|
|
71
|
+
}, []), x = S(() => g(), []), [b, v] = R(x);
|
|
72
72
|
$(() => {
|
|
73
|
-
const { unregistry:
|
|
74
|
-
s.map(({ name:
|
|
73
|
+
const { unregistry: y } = t.registryExtraForm(
|
|
74
|
+
s.map(({ name: d }) => [...r, d].join(".")),
|
|
75
75
|
() => {
|
|
76
76
|
v(g());
|
|
77
77
|
}
|
|
78
78
|
);
|
|
79
79
|
return () => {
|
|
80
|
-
|
|
80
|
+
y();
|
|
81
81
|
};
|
|
82
82
|
}, []);
|
|
83
|
-
const
|
|
84
|
-
(
|
|
85
|
-
l[
|
|
83
|
+
const f = D(
|
|
84
|
+
(y) => {
|
|
85
|
+
l[y] && !b.includes(y) && v((d) => [...d, y]);
|
|
86
86
|
},
|
|
87
|
-
[
|
|
88
|
-
), a =
|
|
89
|
-
v((
|
|
87
|
+
[b]
|
|
88
|
+
), a = D((y) => {
|
|
89
|
+
v((d) => d.filter((V) => V !== y));
|
|
90
90
|
}, []);
|
|
91
|
-
return /* @__PURE__ */ B(
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
return /* @__PURE__ */ h(
|
|
91
|
+
return /* @__PURE__ */ B(w, { children: [
|
|
92
|
+
b.map((y) => {
|
|
93
|
+
const d = l[y];
|
|
94
|
+
return /* @__PURE__ */ h(p, { path: r, scheme: [d] }, `param-form--${y}`);
|
|
95
95
|
}),
|
|
96
|
-
e(
|
|
96
|
+
e(f, b)
|
|
97
97
|
] });
|
|
98
|
-
},
|
|
99
|
-
|
|
98
|
+
}, p = ({ scheme: o, path: r }) => /* @__PURE__ */ h(w, { children: o.map((e, s) => e.type === "layout" ? /* @__PURE__ */ h(e.Layout, { children: /* @__PURE__ */ h(p, { path: r, scheme: e.childs }) }, `layout-form--${s}-${r.length}`) : e.type === "context" ? /* @__PURE__ */ h(
|
|
99
|
+
p,
|
|
100
100
|
{
|
|
101
101
|
path: [...r, e.context],
|
|
102
102
|
scheme: e.childs
|
|
103
103
|
},
|
|
104
104
|
`context-form--${s}-${e.context}-${r.length}`
|
|
105
105
|
) : e.type === "condition" ? /* @__PURE__ */ h(
|
|
106
|
-
|
|
106
|
+
O,
|
|
107
107
|
{
|
|
108
108
|
name: e.depended,
|
|
109
109
|
canActivate: e.canActivate,
|
|
110
|
-
children: /* @__PURE__ */ h(
|
|
110
|
+
children: /* @__PURE__ */ h(p, { path: r, scheme: e.childs })
|
|
111
111
|
},
|
|
112
112
|
`condition--${s}-${e.depended}-${r.length}`
|
|
113
|
-
) : e.type === "extra" ? /* @__PURE__ */ h(
|
|
113
|
+
) : e.type === "extra" ? /* @__PURE__ */ h(_, { path: r, item: e }, `partial-item--${s}-${r.length}`) : e.type === "visability" ? e.hidden ? null : /* @__PURE__ */ h(p, { path: r, scheme: e.childs }, `visability--${s}-${r.length}`) : /* @__PURE__ */ h(
|
|
114
114
|
U,
|
|
115
115
|
{
|
|
116
116
|
name: [...r, e.name].join("."),
|
|
117
117
|
item: e
|
|
118
118
|
},
|
|
119
119
|
`form-item--${s}-${e.name}-${r.length}`
|
|
120
|
-
)) }),
|
|
120
|
+
)) }), C = (o, r, e, s) => {
|
|
121
121
|
o.forEach((t) => {
|
|
122
122
|
if (t.type === "form" && s(t, [...r, t.name].join("."), e[t.name]), t.type === "context") {
|
|
123
|
-
|
|
123
|
+
C(t.childs, [...r, t.context], e[t.context] ?? {}, s);
|
|
124
124
|
return;
|
|
125
125
|
}
|
|
126
126
|
if (t.type === "layout" || t.type === "condition" || t.type === "visability") {
|
|
127
|
-
|
|
127
|
+
C(t.childs, r, e, s);
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
t.type === "extra" && t.items.forEach(({ getForm: l, name: g }) => {
|
|
131
|
-
|
|
131
|
+
C([l(g, () => {
|
|
132
132
|
})], r, e, s);
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
|
-
},
|
|
135
|
+
}, E = ({ scheme: o, values: r, path: e, forms: s }) => {
|
|
136
136
|
o.forEach((t) => {
|
|
137
137
|
if (t.type === "form") {
|
|
138
138
|
const l = [...e, t.name].join(".");
|
|
139
139
|
s[l].value !== void 0 && (r[t.name] = s[l].value);
|
|
140
140
|
}
|
|
141
141
|
if (t.type === "context") {
|
|
142
|
-
r[t.context] = {},
|
|
142
|
+
r[t.context] = {}, E({
|
|
143
143
|
scheme: t.childs,
|
|
144
144
|
path: [...e, t.context],
|
|
145
145
|
values: r[t.context],
|
|
@@ -148,38 +148,38 @@ const D = M({}), q = (o) => {
|
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
if (t.type === "layout") {
|
|
151
|
-
|
|
151
|
+
E({ scheme: t.childs, path: e, values: r, forms: s });
|
|
152
152
|
return;
|
|
153
153
|
}
|
|
154
154
|
if (t.type === "visability") {
|
|
155
|
-
|
|
155
|
+
E({ scheme: t.childs, path: e, values: r, forms: s });
|
|
156
156
|
return;
|
|
157
157
|
}
|
|
158
158
|
if (t.type === "condition") {
|
|
159
159
|
const l = s[t.depended]?.value;
|
|
160
160
|
if (t.canActivate(l)) {
|
|
161
|
-
|
|
161
|
+
E({ scheme: t.childs, path: e, values: r, forms: s });
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
t.type === "extra" && t.items.forEach(({ getForm: l, name: g }) => {
|
|
166
|
-
|
|
166
|
+
E({ scheme: [l(g, () => {
|
|
167
167
|
})], path: e, values: r, forms: s });
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
|
-
},
|
|
170
|
+
}, N = (o, r) => {
|
|
171
171
|
const e = {};
|
|
172
|
-
return
|
|
173
|
-
},
|
|
174
|
-
const { onSubmit: e, onEqual: s, disabled: t, onDirty: l, onFormDirty: g, onChangeEvent:
|
|
172
|
+
return E({ scheme: o, path: [], values: e, forms: r }), e;
|
|
173
|
+
}, z = (o, r) => {
|
|
174
|
+
const { onSubmit: e, onEqual: s, disabled: t, onDirty: l, onFormDirty: g, onChangeEvent: x, defaultValues: b } = r, v = { onSubmit: e }, f = {
|
|
175
175
|
isActive: !1,
|
|
176
176
|
isSubmitted: !1,
|
|
177
177
|
dirtyCount: 0
|
|
178
|
-
}, a = {},
|
|
178
|
+
}, a = {}, y = /* @__PURE__ */ new Set(), d = {
|
|
179
179
|
subscribers: [],
|
|
180
180
|
names: {}
|
|
181
181
|
};
|
|
182
|
-
|
|
182
|
+
C(o, [], b ?? {}, (n, u, i) => {
|
|
183
183
|
a[u] = {
|
|
184
184
|
error: null,
|
|
185
185
|
isDirty: !1,
|
|
@@ -195,18 +195,18 @@ const D = M({}), q = (o) => {
|
|
|
195
195
|
validate: n.validate
|
|
196
196
|
};
|
|
197
197
|
});
|
|
198
|
-
const
|
|
199
|
-
l?.({ name: n, isDirty: u }), u &&
|
|
198
|
+
const V = (n, u) => {
|
|
199
|
+
l?.({ name: n, isDirty: u }), u && f.dirtyCount === 0 && g?.(!0), !u && f.dirtyCount === 1 && g?.(!1), f.dirtyCount += u ? 1 : -1;
|
|
200
200
|
};
|
|
201
201
|
return {
|
|
202
202
|
submitRef: v,
|
|
203
203
|
scheme: o,
|
|
204
204
|
disabled: t,
|
|
205
205
|
activate() {
|
|
206
|
-
|
|
206
|
+
f.isActive = !0;
|
|
207
207
|
},
|
|
208
208
|
disactivate() {
|
|
209
|
-
|
|
209
|
+
f.isActive = !1;
|
|
210
210
|
},
|
|
211
211
|
setError(n, u) {
|
|
212
212
|
const i = this.getForm(n);
|
|
@@ -224,12 +224,12 @@ const D = M({}), q = (o) => {
|
|
|
224
224
|
i && i.value !== u && this.onChange(n, u);
|
|
225
225
|
},
|
|
226
226
|
getValues() {
|
|
227
|
-
return
|
|
227
|
+
return N(o, a);
|
|
228
228
|
},
|
|
229
229
|
async handleSubmit() {
|
|
230
230
|
if (t)
|
|
231
231
|
return;
|
|
232
|
-
|
|
232
|
+
f.isSubmitted = !0;
|
|
233
233
|
let n = !1, u = !1;
|
|
234
234
|
for (const i in a) {
|
|
235
235
|
const c = a[i];
|
|
@@ -239,18 +239,18 @@ const D = M({}), q = (o) => {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
if (!u) {
|
|
242
|
-
if (
|
|
242
|
+
if (f.dirtyCount === 0 && s) {
|
|
243
243
|
s();
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
|
-
const i =
|
|
246
|
+
const i = N(o, a);
|
|
247
247
|
await v.onSubmit(i, {
|
|
248
248
|
setError: (c, F) => {
|
|
249
|
-
const
|
|
250
|
-
|
|
249
|
+
const m = this.getForm(c);
|
|
250
|
+
m.error = {
|
|
251
251
|
error: !0,
|
|
252
252
|
messages: [F.message]
|
|
253
|
-
},
|
|
253
|
+
}, m.rerender();
|
|
254
254
|
}
|
|
255
255
|
}).catch((c) => {
|
|
256
256
|
console.log("[formkit] submit exception:", c);
|
|
@@ -258,32 +258,32 @@ const D = M({}), q = (o) => {
|
|
|
258
258
|
}
|
|
259
259
|
},
|
|
260
260
|
reset(n, { asDirty: u }) {
|
|
261
|
-
|
|
261
|
+
C(o, [], n, (i, c, F) => {
|
|
262
262
|
if (F === void 0 && a[c].value === void 0)
|
|
263
263
|
return;
|
|
264
|
-
if (
|
|
264
|
+
if (d.names[c] && F === void 0) {
|
|
265
265
|
a[c].value = void 0;
|
|
266
266
|
return;
|
|
267
267
|
}
|
|
268
|
-
const
|
|
269
|
-
u || (a[c].startValue =
|
|
270
|
-
}), u || (
|
|
268
|
+
const m = F ?? i.defaultValue;
|
|
269
|
+
u || (a[c].startValue = m, a[c].isDirty = !1), a[c].value !== m && this.onChange(c, m);
|
|
270
|
+
}), u || (f.dirtyCount = 0, f.isSubmitted = !1), d.subscribers.forEach(({ visualizeEvalueatedForms: i }) => {
|
|
271
271
|
i();
|
|
272
272
|
});
|
|
273
273
|
},
|
|
274
274
|
setAsDefault() {
|
|
275
|
-
|
|
276
|
-
a[
|
|
277
|
-
}),
|
|
275
|
+
C(o, [], {}, (n, u) => {
|
|
276
|
+
a[u].startValue = a[u].value, a[u].isDirty = !1;
|
|
277
|
+
}), f.dirtyCount = 0, f.isSubmitted = !1;
|
|
278
278
|
},
|
|
279
279
|
registry(n, u) {
|
|
280
280
|
return a[n].rerender = u, a[n].value === void 0 && (a[n].value = a[n].defaultValue), {
|
|
281
281
|
unregistry() {
|
|
282
282
|
if (a[n].rerender = () => {
|
|
283
|
-
}, a[n].focus = void 0,
|
|
283
|
+
}, a[n].focus = void 0, f.isActive) {
|
|
284
284
|
a[n].value = void 0;
|
|
285
285
|
const i = !L(a[n].startValue, a[n].defaultValue);
|
|
286
|
-
a[n].isDirty !== i &&
|
|
286
|
+
a[n].isDirty !== i && V(n, i), a[n].isDirty = i;
|
|
287
287
|
}
|
|
288
288
|
}
|
|
289
289
|
};
|
|
@@ -297,28 +297,38 @@ const D = M({}), q = (o) => {
|
|
|
297
297
|
c.subscribers = c.subscribers.filter((F) => F !== i);
|
|
298
298
|
};
|
|
299
299
|
},
|
|
300
|
+
subscribeToAny(n) {
|
|
301
|
+
return y.add(n), () => {
|
|
302
|
+
y.delete(n);
|
|
303
|
+
};
|
|
304
|
+
},
|
|
305
|
+
getNames() {
|
|
306
|
+
return Object.keys(a);
|
|
307
|
+
},
|
|
300
308
|
registryExtraForm(n, u) {
|
|
301
309
|
const i = { visualizeEvalueatedForms: u };
|
|
302
310
|
return n.forEach((c) => {
|
|
303
|
-
|
|
304
|
-
}),
|
|
311
|
+
d.names[c] = !0;
|
|
312
|
+
}), d.subscribers.push(i), {
|
|
305
313
|
unregistry() {
|
|
306
|
-
|
|
314
|
+
d.subscribers = d.subscribers.filter((c) => c !== i);
|
|
307
315
|
}
|
|
308
316
|
};
|
|
309
317
|
},
|
|
310
318
|
onChange(n, u) {
|
|
311
319
|
const i = this.getForm(n), c = !L(u, i.startValue);
|
|
312
|
-
i.isDirty !== c &&
|
|
320
|
+
i.isDirty !== c && V(n, c), i.isDirty = c, x?.({ name: n, value: u }), (i.error || f.isSubmitted) && (i.error = i.validate(u) || null);
|
|
313
321
|
const F = i.value;
|
|
314
|
-
i.value = u, i.rerender(), i.subscribers.forEach(({ callback:
|
|
315
|
-
|
|
322
|
+
i.value = u, i.rerender(), i.subscribers.forEach(({ callback: m }) => {
|
|
323
|
+
m(u, F);
|
|
324
|
+
}), y.forEach((m) => {
|
|
325
|
+
m();
|
|
316
326
|
});
|
|
317
327
|
}
|
|
318
328
|
};
|
|
319
329
|
}, Q = (o, r) => {
|
|
320
330
|
const e = P(null);
|
|
321
|
-
e.current === null && (e.current =
|
|
331
|
+
e.current === null && (e.current = z(o, r));
|
|
322
332
|
const s = e.current;
|
|
323
333
|
return $(() => {
|
|
324
334
|
e.current && (e.current.submitRef.onSubmit = r.onSubmit);
|
|
@@ -346,13 +356,17 @@ const D = M({}), q = (o) => {
|
|
|
346
356
|
await s.handleSubmit();
|
|
347
357
|
},
|
|
348
358
|
// prettier-ignore
|
|
349
|
-
subscribe: (t, l) => s.subscribeToForm(t, l)
|
|
359
|
+
subscribe: (t, l) => s.subscribeToForm(t, l),
|
|
360
|
+
// подписка на любое изменение значений формы (для гейтов поверх всех полей)
|
|
361
|
+
subscribeAny: (t) => s.subscribeToAny(t),
|
|
362
|
+
// плоский список имён всех полей (dotted-пути; вложенные context раскрыты)
|
|
363
|
+
getNames: () => s.getNames()
|
|
350
364
|
};
|
|
351
|
-
}, W = ({ manager: o }) => (
|
|
365
|
+
}, W = ({ manager: o }) => (S(() => {
|
|
352
366
|
o.activate();
|
|
353
367
|
}, []), $(() => () => {
|
|
354
368
|
o.disactivate();
|
|
355
|
-
}, []), /* @__PURE__ */ h(
|
|
369
|
+
}, []), /* @__PURE__ */ h(j.Provider, { value: o, children: /* @__PURE__ */ h(p, { scheme: o.scheme, path: [] }) })), A = (o) => {
|
|
356
370
|
try {
|
|
357
371
|
o();
|
|
358
372
|
} catch (r) {
|
|
@@ -367,28 +381,28 @@ const D = M({}), q = (o) => {
|
|
|
367
381
|
};
|
|
368
382
|
}
|
|
369
383
|
}, X = (o) => (r, e) => {
|
|
370
|
-
const s = o.getRequireCheck(e), { $rules: t = {}, ...l } = e, { validate: g, required:
|
|
384
|
+
const s = o.getRequireCheck(e), { $rules: t = {}, ...l } = e, { validate: g, required: x } = t;
|
|
371
385
|
return {
|
|
372
386
|
type: "form",
|
|
373
387
|
name: r,
|
|
374
388
|
defaultValue: o.defaultValue,
|
|
375
389
|
Form: o.getForm(l),
|
|
376
|
-
validate: (
|
|
377
|
-
if (
|
|
378
|
-
const v =
|
|
390
|
+
validate: (b) => {
|
|
391
|
+
if (x) {
|
|
392
|
+
const v = A(() => s(b));
|
|
379
393
|
if (v)
|
|
380
394
|
return v;
|
|
381
395
|
if (g) {
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
return
|
|
396
|
+
const f = A(() => g(b));
|
|
397
|
+
if (f)
|
|
398
|
+
return f;
|
|
385
399
|
}
|
|
386
400
|
return;
|
|
387
401
|
}
|
|
388
|
-
if (g && !
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
return
|
|
402
|
+
if (g && !A(() => s(b))) {
|
|
403
|
+
const f = A(() => g(b));
|
|
404
|
+
if (f)
|
|
405
|
+
return f;
|
|
392
406
|
}
|
|
393
407
|
}
|
|
394
408
|
};
|
|
@@ -403,29 +417,29 @@ const D = M({}), q = (o) => {
|
|
|
403
417
|
type: "extra",
|
|
404
418
|
items: o((e) => (s) => ({ type: "registry", name: e, getForm: s })),
|
|
405
419
|
getController: r
|
|
406
|
-
}),
|
|
420
|
+
}), k = (o) => (...r) => ({
|
|
407
421
|
type: "context",
|
|
408
422
|
context: o,
|
|
409
423
|
childs: r
|
|
410
|
-
}),
|
|
424
|
+
}), I = (o, r) => (...e) => ({
|
|
411
425
|
type: "condition",
|
|
412
426
|
depended: o,
|
|
413
427
|
canActivate: r.canActivate,
|
|
414
428
|
childs: e
|
|
415
|
-
}),
|
|
429
|
+
}), rr = ({ hidden: o }) => (...r) => ({
|
|
416
430
|
type: "visability",
|
|
417
431
|
hidden: o ?? !1,
|
|
418
432
|
childs: r
|
|
419
433
|
});
|
|
420
434
|
export {
|
|
421
|
-
|
|
422
|
-
|
|
435
|
+
I as Condition,
|
|
436
|
+
k as Context,
|
|
423
437
|
W as FormLayout,
|
|
424
|
-
|
|
438
|
+
rr as Visablility,
|
|
425
439
|
Z as createExtraForm,
|
|
426
440
|
X as createForm,
|
|
427
441
|
Y as createLayout,
|
|
428
|
-
|
|
442
|
+
K as createUseValue,
|
|
429
443
|
Q as useForm,
|
|
430
444
|
q as useValue
|
|
431
445
|
};
|
|
@@ -33,6 +33,8 @@ export interface FormManager<Values, FlattenValues, ClonedValues> {
|
|
|
33
33
|
unregistry: () => void;
|
|
34
34
|
};
|
|
35
35
|
subscribeToForm: <K extends keyof FlattenValues>(name: K & string, callback: (value: FlattenValues[K], prevValue: FlattenValues[K]) => void) => () => void;
|
|
36
|
+
subscribeToAny: (callback: () => void) => () => void;
|
|
37
|
+
getNames: () => string[];
|
|
36
38
|
registryExtraForm: (names: string[], callback: () => void) => {
|
|
37
39
|
unregistry: () => void;
|
|
38
40
|
};
|
package/dist/useForm.d.ts
CHANGED
|
@@ -51,6 +51,8 @@ declare const useDynamicForm: (scheme: SchemeItems.All[], opts: MainOptions<Fiel
|
|
|
51
51
|
};
|
|
52
52
|
handleSubmit: () => Promise<void>;
|
|
53
53
|
subscribe: <K extends string>(name: K, callback: (value: any, prevValue: any) => void) => () => void;
|
|
54
|
+
subscribeAny: (callback: () => void) => () => void;
|
|
55
|
+
getNames: () => string[];
|
|
54
56
|
};
|
|
55
57
|
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>) => {
|
|
56
58
|
manager: FormManager<Values, FlattenValues, Cloned>;
|
|
@@ -66,6 +68,8 @@ declare const useForm: <Items extends SchemeItems.All[], Values extends ExtractV
|
|
|
66
68
|
getValues: () => DeepPartial<Cloned>;
|
|
67
69
|
handleSubmit: () => Promise<void>;
|
|
68
70
|
subscribe: <K extends keyof FlattenValues>(name: K & string, callback: (value: FlattenValues[K], prevValue: FlattenValues[K]) => void) => () => void;
|
|
71
|
+
subscribeAny: (callback: () => void) => () => void;
|
|
72
|
+
getNames: () => string[];
|
|
69
73
|
};
|
|
70
74
|
interface Props {
|
|
71
75
|
manager: FormManager<any, any, any>;
|