@beda.software/web-item-controls 0.1.28 → 0.1.29-tab-validation.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupTabs/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupTabs/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAsC,MAAM,SAAS,CAAC;AAM7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAgF9C"}
|
|
@@ -1,33 +1,47 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as s, jsxs as k } from "react/jsx-runtime";
|
|
2
|
+
import { theme as y, Tabs as x, Flex as p, Badge as T } from "antd";
|
|
3
|
+
import v from "lodash";
|
|
4
|
+
import { useState as E } from "react";
|
|
5
|
+
import { useWatch as P, useFormState as B } from "react-hook-form";
|
|
6
|
+
import { getEnabledQuestions as C, QuestionItems as G } from "sdc-qrf";
|
|
7
|
+
import { GroupWizardBus as K } from "../GroupWizard/index.js";
|
|
8
|
+
import { countValidationErrors as j } from "./utils.js";
|
|
9
|
+
function _(d) {
|
|
10
|
+
var m;
|
|
9
11
|
const {
|
|
10
|
-
parentPath:
|
|
11
|
-
questionItem:
|
|
12
|
-
context:
|
|
13
|
-
} =
|
|
14
|
-
|
|
15
|
-
const
|
|
12
|
+
parentPath: i,
|
|
13
|
+
questionItem: n,
|
|
14
|
+
context: f
|
|
15
|
+
} = d;
|
|
16
|
+
n.repeats && console.warn("GroupTabs does not support repeatable groups in the first level");
|
|
17
|
+
const h = P(), {
|
|
18
|
+
errors: b
|
|
19
|
+
} = B(), {
|
|
20
|
+
token: g
|
|
21
|
+
} = y.useToken(), [I, c] = E(), o = (() => {
|
|
16
22
|
const {
|
|
17
|
-
linkId:
|
|
18
|
-
} =
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
linkId: r
|
|
24
|
+
} = n, e = f[0];
|
|
25
|
+
return e ? C(n.item ?? [], i, h, e).filter((t) => !t.hidden).map((t) => {
|
|
26
|
+
const u = [...i, r, "items", t.linkId, "items"], l = j(v.get(b, u)), a = l > 0;
|
|
27
|
+
return {
|
|
28
|
+
key: t.linkId,
|
|
29
|
+
label: /* @__PURE__ */ k(p, { align: "center", gap: 8, "data-testid": `group-tab-${t.linkId}`, "data-has-errors": a, style: a ? {
|
|
30
|
+
color: g.colorError
|
|
31
|
+
} : void 0, children: [
|
|
32
|
+
t.text,
|
|
33
|
+
a ? /* @__PURE__ */ s(T, { count: l, size: "small", "data-testid": `group-tab-errors-count-${t.linkId}` }) : null
|
|
34
|
+
] }),
|
|
35
|
+
children: /* @__PURE__ */ s(p, { gap: 16, vertical: !0, children: /* @__PURE__ */ s(G, { questionItems: t.item, parentPath: u, context: e }) })
|
|
36
|
+
};
|
|
37
|
+
}) : [];
|
|
38
|
+
})();
|
|
39
|
+
return K.useBus("scrollTo", ({
|
|
40
|
+
groupLinkId: r
|
|
27
41
|
}) => {
|
|
28
|
-
|
|
29
|
-
}, [
|
|
42
|
+
o.some((e) => e.key === r) && c(r);
|
|
43
|
+
}, [o]), /* @__PURE__ */ s(x, { type: "card", items: o, activeKey: I ?? ((m = o[0]) == null ? void 0 : m.key), onChange: c, destroyInactiveTabPane: !0 });
|
|
30
44
|
}
|
|
31
45
|
export {
|
|
32
|
-
|
|
46
|
+
_ as GroupTabs
|
|
33
47
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively counts leaf validation errors in a (nested) react-hook-form errors object.
|
|
3
|
+
*
|
|
4
|
+
* @param errors - A react-hook-form errors subtree (object, array or a single field error)
|
|
5
|
+
* @returns Number of field errors found in the subtree
|
|
6
|
+
*/
|
|
7
|
+
export declare function countValidationErrors(errors: unknown): number;
|
|
8
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupTabs/utils.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAU7D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import i from "lodash";
|
|
2
|
+
function n(t) {
|
|
3
|
+
return i.isPlainObject(t) && typeof t.type == "string";
|
|
4
|
+
}
|
|
5
|
+
function o(t) {
|
|
6
|
+
return n(t) ? 1 : i.isObjectLike(t) ? Object.values(t).reduce((r, e) => r + o(e), 0) : 0;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
o as countValidationErrors
|
|
10
|
+
};
|