@beda.software/web-item-controls 0.1.25-group-new-design.2 → 0.1.25-group-new-design.4

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":"AAIA,OAAO,EAAE,cAAc,EAAsC,MAAM,SAAS,CAAC;AAI7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CAwD9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupTabs/index.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAsC,MAAM,SAAS,CAAC;AAI7E,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,2CA0D9C"}
@@ -1,32 +1,32 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { Flex as d, Tabs as f } from "antd";
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { Flex as f, Tabs as d } from "antd";
3
3
  import { useState as b, useMemo as h } from "react";
4
- import { useWatch as I } from "react-hook-form";
5
- import { getEnabledQuestions as x, QuestionItems as y } from "sdc-qrf";
4
+ import { useWatch as y } from "react-hook-form";
5
+ import { getEnabledQuestions as x, QuestionItems as I } from "sdc-qrf";
6
6
  import { GroupWizardBus as v } from "../GroupWizard/index.js";
7
7
  function B(p) {
8
8
  var c;
9
9
  const {
10
- parentPath: o,
11
- questionItem: t,
12
- context: i
10
+ parentPath: n,
11
+ questionItem: o,
12
+ context: a
13
13
  } = p;
14
- t.repeats && console.warn("GroupTabs does not support repeatable groups in the first level");
15
- const a = I(), [l, u] = b(), m = h(() => {
14
+ o.repeats && console.warn("GroupTabs does not support repeatable groups in the first level");
15
+ const m = y(), [l, u] = b(), r = h(() => {
16
16
  const {
17
- linkId: r
18
- } = t, s = i[0];
19
- return s ? x(t.item ?? [], o, a, s).filter((e) => !e.hidden).map((e) => ({
17
+ linkId: s
18
+ } = o, t = a[0];
19
+ return t ? x(o.item ?? [], n, m, t).filter((e) => !e.hidden).map((e) => ({
20
20
  key: e.linkId,
21
21
  label: e.text,
22
- children: /* @__PURE__ */ n(d, { gap: 16, vertical: !0, children: /* @__PURE__ */ n(y, { questionItems: e.item, parentPath: [...o, r, "items", e.linkId, "items"], context: s }) })
22
+ children: /* @__PURE__ */ i(f, { gap: 16, vertical: !0, children: /* @__PURE__ */ i(I, { questionItems: e.item, parentPath: [...n, s, "items", e.linkId, "items"], context: t }) })
23
23
  })) : [];
24
- }, [i, a, o, t]);
24
+ }, [a, m, n, o]);
25
25
  return v.useBus("scrollTo", ({
26
- groupLinkId: r
26
+ groupLinkId: s
27
27
  }) => {
28
- u(r);
29
- }, []), /* @__PURE__ */ n(f, { type: "card", items: m, activeKey: l ?? ((c = m[0]) == null ? void 0 : c.key), onChange: u, destroyInactiveTabPane: !0 });
28
+ r.some((t) => t.key === s) && u(s);
29
+ }, [r]), /* @__PURE__ */ i(d, { type: "card", items: r, activeKey: l ?? ((c = r[0]) == null ? void 0 : c.key), onChange: u, destroyInactiveTabPane: !0 });
30
30
  }
31
31
  export {
32
32
  B as GroupTabs
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/controls/GroupWizard/GroupWizardSidebar/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EACH,cAAc,EAKjB,MAAM,SAAS,CAAC;AA8BjB,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,kDAoPvD;AAED,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/controls/GroupWizard/GroupWizardSidebar/index.tsx"],"names":[],"mappings":"AAMA,OAAO,EACH,cAAc,EAKjB,MAAM,SAAS,CAAC;AA8BjB,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,kDAkRvD;AAED,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AACnD,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,128 +1,139 @@
1
- import { jsx as r, jsxs as S, Fragment as L } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as b, Fragment as L } from "react/jsx-runtime";
2
2
  import { Trans as Q } from "@lingui/react";
3
3
  import { i18n as V } from "@lingui/core";
4
4
  import { DeleteOutlined as _ } from "@ant-design/icons";
5
- import { Popconfirm as X, Button as H } from "antd";
5
+ import { Popconfirm as N, Button as X } from "antd";
6
6
  import j from "lodash";
7
- import { useState as P, useMemo as G, useEffect as N } from "react";
7
+ import { useState as P, useMemo as M, useEffect as H } from "react";
8
8
  import { useWatch as Z, useFormContext as $ } from "react-hook-form";
9
9
  import { useQuestionnaireResponseFormContext as J, QuestionnaireResponseFormProvider as U, QuestionItems as A, populateItemKey as Y } from "sdc-qrf";
10
10
  import { Text as ee } from "../../../components/Typography.js";
11
- import { GroupWizardBus as y } from "../index.js";
11
+ import { GroupWizardBus as f } from "../index.js";
12
12
  import { SidebarMenu as te } from "./SidebarMenu.js";
13
13
  import { S as p } from "./styles.js";
14
14
  import { buildRootSection as ne, shouldApplySidebarDesign as oe } from "./utils.js";
15
- function M(f, c, d) {
16
- f.nodes.forEach((u) => {
17
- d.nodesByKey.set(u.key, u), d.ancestorsByKey.set(u.key, c), u.sections.forEach((s) => M(s, [...c, u.key], d));
15
+ function q(h, u, l) {
16
+ h.nodes.forEach((m) => {
17
+ l.nodesByKey.set(m.key, m), l.ancestorsByKey.set(m.key, u), m.sections.forEach((o) => q(o, [...u, m.key], l));
18
18
  });
19
19
  }
20
- function re(f) {
21
- const c = {
20
+ function re(h) {
21
+ const u = {
22
22
  nodesByKey: /* @__PURE__ */ new Map(),
23
23
  ancestorsByKey: /* @__PURE__ */ new Map()
24
24
  };
25
- return M(f, [], c), c;
25
+ return q(h, [], u), u;
26
26
  }
27
- function Ie(f) {
27
+ function Ie(h) {
28
28
  const {
29
- parentPath: c,
30
- questionItem: d,
31
- context: u
32
- } = f, {
33
- linkId: s,
34
- hidden: q,
35
- readOnly: K
36
- } = d, x = u[0], b = Z(), {
37
- getValues: v,
29
+ parentPath: u,
30
+ questionItem: l,
31
+ context: m
32
+ } = h, {
33
+ linkId: o,
34
+ hidden: D,
35
+ readOnly: x
36
+ } = l, g = m[0], v = Z(), {
37
+ getValues: K,
38
38
  setValue: B
39
- } = $(), D = J(), [C, h] = P(null), [F, w] = P(/* @__PURE__ */ new Set()), [m, g] = P(null), n = G(() => ne(d, c, b, x), [d, c, b, x]), {
40
- nodesByKey: I,
41
- ancestorsByKey: T
42
- } = G(() => re(n), [n]), l = m ? I.get(m) : void 0, E = (m ? T.get(m) ?? [] : []).map((e) => I.get(e)).filter((e) => !!e && e.contentItems.length > 0);
43
- N(() => {
44
- if (!l && n.nodes.length > 0) {
39
+ } = $(), F = J(), [C, y] = P(null), [O, T] = P(/* @__PURE__ */ new Set()), [c, I] = P(null), n = M(() => ne(l, u, v, g), [l, u, v, g]), {
40
+ nodesByKey: k,
41
+ ancestorsByKey: w
42
+ } = M(() => re(n), [n]), d = c ? k.get(c) : void 0, R = (c ? w.get(c) ?? [] : []).map((e) => k.get(e)).filter((e) => !!e && e.contentItems.length > 0);
43
+ H(() => {
44
+ if (!d && n.nodes.length > 0) {
45
45
  const e = n.nodes[0];
46
- g(e.key), h(e.key);
46
+ I(e.key), y(e.key);
47
47
  }
48
- }, [l, n]);
49
- const k = (e) => {
50
- g(e);
51
- const t = T.get(e) ?? [], [o, ...i] = t;
52
- h(o ?? e), i.length > 0 && w((a) => /* @__PURE__ */ new Set([...a, ...i]));
53
- }, O = (e) => {
48
+ }, [d, n]);
49
+ const S = (e) => {
50
+ I(e);
51
+ const t = w.get(e) ?? [], [r, ...s] = t;
52
+ y(r ?? e), s.length > 0 && T((a) => /* @__PURE__ */ new Set([...a, ...s]));
53
+ }, W = (e) => {
54
54
  const t = n.nodes.map((a) => a.key);
55
55
  if (t.length < 2)
56
56
  return;
57
57
  if (C !== e.key) {
58
- h(e.key);
58
+ y(e.key);
59
59
  return;
60
60
  }
61
- const i = (t.indexOf(e.key) + 1) % t.length;
62
- h(t[i]);
63
- }, R = (e) => {
64
- const t = j.get(v(), e.fieldPath), o = (t == null ? void 0 : t.items) ?? [], i = [...o, {}].map(Y), a = [...e.fieldPath, "items", o.length.toString()].join(".");
61
+ const s = (t.indexOf(e.key) + 1) % t.length;
62
+ y(t[s]);
63
+ }, E = (e) => {
64
+ const t = j.get(K(), e.fieldPath), r = (t == null ? void 0 : t.items) ?? [], s = [...r, {}].map(Y), a = [...e.fieldPath, "items", r.length.toString()].join(".");
65
65
  B(e.fieldPath.join("."), {
66
66
  ...t,
67
- items: i
67
+ items: s
68
68
  }, {
69
69
  shouldDirty: !0
70
- }), g(a), e === n && h(a);
71
- }, W = (e) => {
70
+ }), I(a), e === n && y(a);
71
+ }, G = (e) => {
72
72
  if (e.repeatIndex === void 0 || !e.fieldPath)
73
73
  return;
74
- const t = j.get(v(), e.fieldPath), i = ((t == null ? void 0 : t.items) ?? []).filter((a, z) => z !== e.repeatIndex);
74
+ const t = j.get(K(), e.fieldPath), s = ((t == null ? void 0 : t.items) ?? []).filter((a, z) => z !== e.repeatIndex);
75
75
  B(e.fieldPath.join("."), {
76
76
  ...t,
77
- items: i
77
+ items: s
78
78
  }, {
79
79
  shouldDirty: !0
80
- }), g(null);
80
+ }), I(null);
81
81
  };
82
- return y.useBus("sidebarSelect", (e) => {
83
- e.type !== "sidebarSelect" || e.groupLinkId !== s || !I.has(e.key) || k(e.key);
84
- }, [s, I]), y.useBus("sidebarGoToIndex", (e) => {
85
- if (e.type !== "sidebarGoToIndex" || e.groupLinkId !== s)
82
+ return f.useBus("sidebarSelect", (e) => {
83
+ e.type !== "sidebarSelect" || e.groupLinkId !== o || !k.has(e.key) || S(e.key);
84
+ }, [o, k]), f.useBus("sidebarGoToIndex", (e) => {
85
+ if (e.type !== "sidebarGoToIndex" || e.groupLinkId !== o)
86
86
  return;
87
87
  const t = n.nodes[e.index];
88
- t && k(t.key);
89
- }, [s, n]), y.useBus("sidebarGoToPrevious", ({
88
+ t && S(t.key);
89
+ }, [o, n]), f.useBus("sidebarGoToPrevious", ({
90
90
  groupLinkId: e
91
91
  }) => {
92
- if (e !== s)
92
+ if (e !== o)
93
93
  return;
94
- const t = n.nodes.findIndex((a) => a.key === m), o = Math.max(0, (t === -1 ? n.nodes.length : t) - 1), i = n.nodes[o];
95
- i && k(i.key);
96
- }, [s, n, m]), y.useBus("sidebarAddElement", ({
94
+ const t = n.nodes.findIndex((a) => a.key === c), r = Math.max(0, (t === -1 ? n.nodes.length : t) - 1), s = n.nodes[r];
95
+ s && S(s.key);
96
+ }, [o, n, c]), f.useBus("sidebarGoToNext", ({
97
+ groupLinkId: e
98
+ }) => {
99
+ if (e !== o)
100
+ return;
101
+ const t = n.nodes.findIndex((a) => a.key === c), r = Math.min(n.nodes.length - 1, t + 1), s = n.nodes[r];
102
+ s && S(s.key);
103
+ }, [o, n, c]), f.useBus("sidebarAddElement", ({
104
+ groupLinkId: e
105
+ }) => {
106
+ e === o && E(n);
107
+ }, [o, n]), f.useBus("sidebarRemove", ({
97
108
  groupLinkId: e
98
109
  }) => {
99
- e === s && R(n);
100
- }, [s, n]), q || !d.item ? null : oe(d) ? /* @__PURE__ */ S(p.Container, { children: [
101
- /* @__PURE__ */ r(p.Sider, { children: /* @__PURE__ */ r(te, { section: n, expandedRootKey: C, expandedKeys: F, selectedKey: m, onToggleRoot: O, onToggleExpand: (e) => w((t) => {
102
- const o = new Set(t);
103
- return o.has(e) ? o.delete(e) : o.add(e), o;
104
- }), onSelect: (e) => y.dispatch({
110
+ e !== o || x || !d || G(d);
111
+ }, [o, x, d]), D || !l.item ? null : oe(l) ? /* @__PURE__ */ b(p.Container, { children: [
112
+ /* @__PURE__ */ i(p.Sider, { children: /* @__PURE__ */ i(te, { section: n, expandedRootKey: C, expandedKeys: O, selectedKey: c, onToggleRoot: W, onToggleExpand: (e) => T((t) => {
113
+ const r = new Set(t);
114
+ return r.has(e) ? r.delete(e) : r.add(e), r;
115
+ }), onSelect: (e) => f.dispatch({
105
116
  type: "sidebarSelect",
106
- groupLinkId: s,
117
+ groupLinkId: o,
107
118
  key: e.key
108
- }), onAdd: K ? void 0 : R }) }),
109
- /* @__PURE__ */ r(p.Content, { children: l ? /* @__PURE__ */ S(L, { children: [
110
- E.length > 0 ? /* @__PURE__ */ r(U, { ...D, readOnly: !0, children: E.map((e) => /* @__PURE__ */ S(p.ParentPreview, { children: [
111
- /* @__PURE__ */ r(p.ParentPreviewTitle, { level: 5, children: e.text }),
112
- /* @__PURE__ */ r(A, { questionItems: e.contentItems, parentPath: e.path, context: x })
119
+ }), onAdd: x ? void 0 : E }) }),
120
+ /* @__PURE__ */ i(p.Content, { children: d ? /* @__PURE__ */ b(L, { children: [
121
+ R.length > 0 ? /* @__PURE__ */ i(U, { ...F, readOnly: !0, children: R.map((e) => /* @__PURE__ */ b(p.ParentPreview, { children: [
122
+ /* @__PURE__ */ i(p.ParentPreviewTitle, { level: 5, children: e.text }),
123
+ /* @__PURE__ */ i(A, { questionItems: e.contentItems, parentPath: e.path, context: g })
113
124
  ] }, e.key)) }) : null,
114
- /* @__PURE__ */ S(p.ContentHeader, { children: [
115
- /* @__PURE__ */ r(p.ContentTitle, { level: 4, children: l.text }),
116
- !K && l.repeatIndex !== void 0 ? /* @__PURE__ */ r(X, { title: V._(
125
+ /* @__PURE__ */ b(p.ContentHeader, { children: [
126
+ /* @__PURE__ */ i(p.ContentTitle, { level: 4, children: d.text }),
127
+ !x && d.repeatIndex !== void 0 ? /* @__PURE__ */ i(N, { title: V._(
117
128
  /*i18n*/
118
129
  {
119
130
  id: "XtpCjZ"
120
131
  }
121
- ), onConfirm: () => W(l), children: /* @__PURE__ */ r(H, { danger: !0, icon: /* @__PURE__ */ r(_, {}), "data-testid": `sidebar-menu-remove-${l.key}` }) }) : null
132
+ ), onConfirm: () => G(d), children: /* @__PURE__ */ i(X, { danger: !0, icon: /* @__PURE__ */ i(_, {}), "data-testid": `sidebar-menu-remove-${d.key}` }) }) : null
122
133
  ] }),
123
- /* @__PURE__ */ r(A, { questionItems: l.contentItems, parentPath: l.path, context: x })
134
+ /* @__PURE__ */ i(A, { questionItems: d.contentItems, parentPath: d.path, context: g })
124
135
  ] }) : null })
125
- ] }) : (console.error("GroupWizardSidebar was used for a group that does not match the sidebar design criteria"), /* @__PURE__ */ r(ee, { children: /* @__PURE__ */ r(Q, { id: "vya+nX" }) }));
136
+ ] }) : (console.error("GroupWizardSidebar was used for a group that does not match the sidebar design criteria"), /* @__PURE__ */ i(ee, { children: /* @__PURE__ */ i(Q, { id: "vya+nX" }) }));
126
137
  }
127
138
  export {
128
139
  Ie as GroupWizardSidebar,
@@ -4,7 +4,7 @@ export interface GroupWizardProps extends GroupItemProps {
4
4
  wizard?: Partial<WizardProps>;
5
5
  }
6
6
  export declare const GroupWizardBus: {
7
- useBus: (type: "scrollTo" | "sidebarAddElement" | "sidebarGoToIndex" | "sidebarGoToPrevious" | "sidebarSelect", callback: (e: {
7
+ useBus: (type: "scrollTo" | "sidebarAddElement" | "sidebarGoToIndex" | "sidebarGoToPrevious" | "sidebarGoToNext" | "sidebarRemove" | "sidebarSelect", callback: (e: {
8
8
  type: "scrollTo";
9
9
  groupLinkId: string;
10
10
  } | {
@@ -17,6 +17,12 @@ export declare const GroupWizardBus: {
17
17
  } | {
18
18
  type: "sidebarGoToPrevious";
19
19
  groupLinkId: string;
20
+ } | {
21
+ type: "sidebarGoToNext";
22
+ groupLinkId: string;
23
+ } | {
24
+ type: "sidebarRemove";
25
+ groupLinkId: string;
20
26
  } | {
21
27
  type: "sidebarSelect";
22
28
  groupLinkId: string;
@@ -34,6 +40,12 @@ export declare const GroupWizardBus: {
34
40
  } | {
35
41
  type: "sidebarGoToPrevious";
36
42
  groupLinkId: string;
43
+ } | {
44
+ type: "sidebarGoToNext";
45
+ groupLinkId: string;
46
+ } | {
47
+ type: "sidebarRemove";
48
+ groupLinkId: string;
37
49
  } | {
38
50
  type: "sidebarSelect";
39
51
  groupLinkId: string;
@@ -52,6 +64,12 @@ export declare const GroupWizardBus: {
52
64
  } | {
53
65
  type: "sidebarGoToPrevious";
54
66
  groupLinkId: string;
67
+ } | {
68
+ type: "sidebarGoToNext";
69
+ groupLinkId: string;
70
+ } | {
71
+ type: "sidebarRemove";
72
+ groupLinkId: string;
55
73
  } | {
56
74
  type: "sidebarSelect";
57
75
  groupLinkId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupWizard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACH,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,WAAW,EAGd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAAsB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKxE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,cAAc;;cAEX,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;cAnBL,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;;cAnBL,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;CAElB,CAAC;AAEJ,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,2CAU1D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,2CAS9D;AAED,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,yBAAyB,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAkJlD;AAED,eAAO,MAAM,aAAa,GACtB,WAAW,oBAAoB,EAC/B,YAAY,MAAM,EAAE,EACpB,YAAY,SAAS,EACrB,SAAS,WAAW,KACrB,UAeF,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/controls/GroupWizard/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EACH,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,WAAW,EAGd,MAAM,SAAS,CAAC;AAOjB,OAAO,EAAsB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKxE,MAAM,WAAW,gBAAiB,SAAQ,cAAc;IACpD,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,cAAc;;cAEX,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,iBAAiB;qBACV,MAAM;;cAGb,eAAe;qBACR,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;cA3BL,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,iBAAiB;qBACV,MAAM;;cAGb,eAAe;qBACR,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;;cA3BL,UAAU;qBACH,MAAM;;cAGb,mBAAmB;qBACZ,MAAM;;cAGb,kBAAkB;qBACX,MAAM;eACZ,MAAM;;cAGP,qBAAqB;qBACd,MAAM;;cAGb,iBAAiB;qBACV,MAAM;;cAGb,eAAe;qBACR,MAAM;;cAGb,eAAe;qBACR,MAAM;aACd,MAAM;;CAElB,CAAC;AAEJ,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,2CAU1D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,gBAAgB,2CAS9D;AAED,MAAM,WAAW,UAAU;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,yBAAyB,EAAE,MAAM,CAAC;CACrC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAkJlD;AAED,eAAO,MAAM,aAAa,GACtB,WAAW,oBAAoB,EAC/B,YAAY,MAAM,EAAE,EACpB,YAAY,SAAS,EACrB,SAAS,WAAW,KACrB,UAeF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/readonly-controls/GroupWizardSidebar/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AA6BxD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,kDAuLvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/readonly-controls/GroupWizardSidebar/index.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AA6BxD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,cAAc,kDAyMvD"}
@@ -1,90 +1,97 @@
1
- import { jsx as o, jsxs as S, Fragment as W } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as k, Fragment as W } from "react/jsx-runtime";
2
2
  import { Trans as q } from "@lingui/react";
3
- import { useState as k, useMemo as w, useEffect as z } from "react";
3
+ import { useState as S, useMemo as w, useEffect as z } from "react";
4
4
  import { useWatch as A } from "react-hook-form";
5
5
  import { QuestionItems as P } from "sdc-qrf";
6
6
  import { Text as L } from "../../components/Typography.js";
7
- import { GroupWizardBus as g } from "../../controls/GroupWizard/index.js";
7
+ import { GroupWizardBus as m } from "../../controls/GroupWizard/index.js";
8
8
  import { SidebarMenu as j } from "../../controls/GroupWizard/GroupWizardSidebar/SidebarMenu.js";
9
- import { S as u } from "../../controls/GroupWizard/GroupWizardSidebar/styles.js";
10
- import { buildRootSection as D, shouldApplySidebarDesign as F } from "../../controls/GroupWizard/GroupWizardSidebar/utils.js";
11
- function E(f, d, r) {
12
- f.nodes.forEach((c) => {
13
- r.nodesByKey.set(c.key, c), r.ancestorsByKey.set(c.key, d), c.sections.forEach((s) => E(s, [...d, c.key], r));
9
+ import { S as p } from "../../controls/GroupWizard/GroupWizardSidebar/styles.js";
10
+ import { buildRootSection as N, shouldApplySidebarDesign as D } from "../../controls/GroupWizard/GroupWizardSidebar/utils.js";
11
+ function E(y, a, d) {
12
+ y.nodes.forEach((u) => {
13
+ d.nodesByKey.set(u.key, u), d.ancestorsByKey.set(u.key, a), u.sections.forEach((o) => E(o, [...a, u.key], d));
14
14
  });
15
15
  }
16
- function H(f) {
17
- const d = {
16
+ function F(y) {
17
+ const a = {
18
18
  nodesByKey: /* @__PURE__ */ new Map(),
19
19
  ancestorsByKey: /* @__PURE__ */ new Map()
20
20
  };
21
- return E(f, [], d), d;
21
+ return E(y, [], a), a;
22
22
  }
23
- function $(f) {
23
+ function $(y) {
24
24
  const {
25
- parentPath: d,
26
- questionItem: r,
27
- context: c
28
- } = f, {
29
- linkId: s,
25
+ parentPath: a,
26
+ questionItem: d,
27
+ context: u
28
+ } = y, {
29
+ linkId: o,
30
30
  hidden: G
31
- } = r, m = c[0], K = A(), [b, h] = k(null), [R, B] = k(/* @__PURE__ */ new Set()), [a, T] = k(null), n = w(() => D(r, d, K, m), [r, d, K, m]), {
32
- nodesByKey: x,
31
+ } = d, h = u[0], b = A(), [K, x] = S(null), [M, B] = S(/* @__PURE__ */ new Set()), [c, T] = S(null), t = w(() => N(d, a, b, h), [d, a, b, h]), {
32
+ nodesByKey: g,
33
33
  ancestorsByKey: v
34
- } = w(() => H(n), [n]), p = a ? x.get(a) : void 0, C = (a ? v.get(a) ?? [] : []).map((e) => x.get(e)).filter((e) => !!e && e.contentItems.length > 0);
34
+ } = w(() => F(t), [t]), f = c ? g.get(c) : void 0, R = (c ? v.get(c) ?? [] : []).map((e) => g.get(e)).filter((e) => !!e && e.contentItems.length > 0);
35
35
  z(() => {
36
- if (!p && n.nodes.length > 0) {
37
- const e = n.nodes[0];
38
- T(e.key), h(e.key);
36
+ if (!f && t.nodes.length > 0) {
37
+ const e = t.nodes[0];
38
+ T(e.key), x(e.key);
39
39
  }
40
- }, [p, n]);
40
+ }, [f, t]);
41
41
  const I = (e) => {
42
42
  T(e);
43
- const t = v.get(e) ?? [], [i, ...l] = t;
44
- h(i ?? e), l.length > 0 && B((y) => /* @__PURE__ */ new Set([...y, ...l]));
45
- }, M = (e) => {
46
- const t = n.nodes.map((y) => y.key);
47
- if (t.length < 2)
43
+ const n = v.get(e) ?? [], [s, ...r] = n;
44
+ x(s ?? e), r.length > 0 && B((l) => /* @__PURE__ */ new Set([...l, ...r]));
45
+ }, C = (e) => {
46
+ const n = t.nodes.map((l) => l.key);
47
+ if (n.length < 2)
48
48
  return;
49
- if (b !== e.key) {
50
- h(e.key);
49
+ if (K !== e.key) {
50
+ x(e.key);
51
51
  return;
52
52
  }
53
- const l = (t.indexOf(e.key) + 1) % t.length;
54
- h(t[l]);
53
+ const r = (n.indexOf(e.key) + 1) % n.length;
54
+ x(n[r]);
55
55
  };
56
- return g.useBus("sidebarSelect", (e) => {
57
- e.type !== "sidebarSelect" || e.groupLinkId !== s || !x.has(e.key) || I(e.key);
58
- }, [s, x]), g.useBus("sidebarGoToIndex", (e) => {
59
- if (e.type !== "sidebarGoToIndex" || e.groupLinkId !== s)
56
+ return m.useBus("sidebarSelect", (e) => {
57
+ e.type !== "sidebarSelect" || e.groupLinkId !== o || !g.has(e.key) || I(e.key);
58
+ }, [o, g]), m.useBus("sidebarGoToIndex", (e) => {
59
+ if (e.type !== "sidebarGoToIndex" || e.groupLinkId !== o)
60
60
  return;
61
- const t = n.nodes[e.index];
62
- t && I(t.key);
63
- }, [s, n]), g.useBus("sidebarGoToPrevious", ({
61
+ const n = t.nodes[e.index];
62
+ n && I(n.key);
63
+ }, [o, t]), m.useBus("sidebarGoToPrevious", ({
64
64
  groupLinkId: e
65
65
  }) => {
66
- if (e !== s)
66
+ if (e !== o)
67
67
  return;
68
- const t = n.nodes.findIndex((y) => y.key === a), i = Math.max(0, (t === -1 ? n.nodes.length : t) - 1), l = n.nodes[i];
69
- l && I(l.key);
70
- }, [s, n, a]), G || !r.item ? null : F(r) ? /* @__PURE__ */ S(u.Container, { children: [
71
- /* @__PURE__ */ o(u.Sider, { children: /* @__PURE__ */ o(j, { section: n, expandedRootKey: b, expandedKeys: R, selectedKey: a, onToggleRoot: M, onToggleExpand: (e) => B((t) => {
72
- const i = new Set(t);
73
- return i.has(e) ? i.delete(e) : i.add(e), i;
74
- }), onSelect: (e) => g.dispatch({
68
+ const n = t.nodes.findIndex((l) => l.key === c), s = Math.max(0, (n === -1 ? t.nodes.length : n) - 1), r = t.nodes[s];
69
+ r && I(r.key);
70
+ }, [o, t, c]), m.useBus("sidebarGoToNext", ({
71
+ groupLinkId: e
72
+ }) => {
73
+ if (e !== o)
74
+ return;
75
+ const n = t.nodes.findIndex((l) => l.key === c), s = Math.min(t.nodes.length - 1, n + 1), r = t.nodes[s];
76
+ r && I(r.key);
77
+ }, [o, t, c]), G || !d.item ? null : D(d) ? /* @__PURE__ */ k(p.Container, { children: [
78
+ /* @__PURE__ */ i(p.Sider, { children: /* @__PURE__ */ i(j, { section: t, expandedRootKey: K, expandedKeys: M, selectedKey: c, onToggleRoot: C, onToggleExpand: (e) => B((n) => {
79
+ const s = new Set(n);
80
+ return s.has(e) ? s.delete(e) : s.add(e), s;
81
+ }), onSelect: (e) => m.dispatch({
75
82
  type: "sidebarSelect",
76
- groupLinkId: s,
83
+ groupLinkId: o,
77
84
  key: e.key
78
85
  }) }) }),
79
- /* @__PURE__ */ o(u.Content, { children: p ? /* @__PURE__ */ S(W, { children: [
80
- C.map((e) => /* @__PURE__ */ S(u.ParentPreview, { children: [
81
- /* @__PURE__ */ o(u.ParentPreviewTitle, { level: 5, children: e.text }),
82
- /* @__PURE__ */ o(P, { questionItems: e.contentItems, parentPath: e.path, context: m })
86
+ /* @__PURE__ */ i(p.Content, { children: f ? /* @__PURE__ */ k(W, { children: [
87
+ R.map((e) => /* @__PURE__ */ k(p.ParentPreview, { children: [
88
+ /* @__PURE__ */ i(p.ParentPreviewTitle, { level: 5, children: e.text }),
89
+ /* @__PURE__ */ i(P, { questionItems: e.contentItems, parentPath: e.path, context: h })
83
90
  ] }, e.key)),
84
- /* @__PURE__ */ o(u.ContentHeader, { children: /* @__PURE__ */ o(u.ContentTitle, { level: 4, children: p.text }) }),
85
- /* @__PURE__ */ o(P, { questionItems: p.contentItems, parentPath: p.path, context: m })
91
+ /* @__PURE__ */ i(p.ContentHeader, { children: /* @__PURE__ */ i(p.ContentTitle, { level: 4, children: f.text }) }),
92
+ /* @__PURE__ */ i(P, { questionItems: f.contentItems, parentPath: f.path, context: h })
86
93
  ] }) : null })
87
- ] }) : (console.error("GroupWizardSidebar was used for a group that does not match the sidebar design criteria"), /* @__PURE__ */ o(L, { children: /* @__PURE__ */ o(q, { id: "vya+nX" }) }));
94
+ ] }) : (console.error("GroupWizardSidebar was used for a group that does not match the sidebar design criteria"), /* @__PURE__ */ i(L, { children: /* @__PURE__ */ i(q, { id: "vya+nX" }) }));
88
95
  }
89
96
  export {
90
97
  $ as GroupWizardSidebar
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- ._row_dy31e_1{display:flex}._inputWrapper_dy31e_5{flex:auto}._splitterWrapper_dy31e_9{display:flex;flex-direction:column;justify-content:flex-end}._splitter_dy31e_9{position:relative;bottom:22px;margin:0 8px;font-weight:400;font-size:20px;line-height:22px}._group_1ndd9_1{display:flex;flex-direction:column;gap:16px;width:100%}._groupTitle_1ndd9_8{font-weight:700;font-size:16px;line-height:24px}._row_1ndd9_14{display:flex;flex-direction:row;justify-content:space-between;gap:16px;width:100%}._col_1ndd9_22{display:flex;flex-direction:column;gap:16px}._form_1v4sy_1 .ant-form-item-label{font-weight:700}._form_1v4sy_1 .ant-form-item-row{flex:1;flex-direction:column;justify-content:space-between;gap:12px}._form_1v4sy_1 .ant-form-item-label{text-align:start;white-space:normal}._form_1v4sy_1 .ant-form-item-label label{display:flex;height:auto}._form_1v4sy_1 .ant-form-item-label label:after{display:none}._form_1v4sy_1 .ant-form-item-control{flex-grow:0}._content_1v4sy_25{display:flex;flex-direction:column;gap:24px}._field_1v4sy_31{width:100%;margin-bottom:0;display:flex}._field_1v4sy_31.__hidden_1v4sy_36{display:none}._inputContainer_gs0vq_1{display:flex;flex-direction:column}._inputHeader_gs0vq_6{display:flex;margin-bottom:12px;align-items:center;justify-content:space-between}._label_gs0vq_13{font-weight:700;font-size:14px;line-height:22px}.ant-dropdown .ant-table-filter-dropdown{border:0;background:none;box-shadow:none;position:relative;overflow:visible}._column_14bfg_1{display:flex;flex-direction:column}._row_14bfg_6{display:flex;flex-direction:row;justify-content:space-between;align-items:center}._questionText_14bfg_13{font-weight:700;margin:0}._answer_14bfg_18{display:block;min-width:40%;max-width:40%}
1
+ ._column_14bfg_1{display:flex;flex-direction:column}._row_14bfg_6{display:flex;flex-direction:row;justify-content:space-between;align-items:center}._questionText_14bfg_13{font-weight:700;margin:0}._answer_14bfg_18{display:block;min-width:40%;max-width:40%}.ant-dropdown .ant-table-filter-dropdown{border:0;background:none;box-shadow:none;position:relative;overflow:visible}._row_dy31e_1{display:flex}._inputWrapper_dy31e_5{flex:auto}._splitterWrapper_dy31e_9{display:flex;flex-direction:column;justify-content:flex-end}._splitter_dy31e_9{position:relative;bottom:22px;margin:0 8px;font-weight:400;font-size:20px;line-height:22px}._form_1v4sy_1 .ant-form-item-label{font-weight:700}._form_1v4sy_1 .ant-form-item-row{flex:1;flex-direction:column;justify-content:space-between;gap:12px}._form_1v4sy_1 .ant-form-item-label{text-align:start;white-space:normal}._form_1v4sy_1 .ant-form-item-label label{display:flex;height:auto}._form_1v4sy_1 .ant-form-item-label label:after{display:none}._form_1v4sy_1 .ant-form-item-control{flex-grow:0}._content_1v4sy_25{display:flex;flex-direction:column;gap:24px}._field_1v4sy_31{width:100%;margin-bottom:0;display:flex}._field_1v4sy_31.__hidden_1v4sy_36{display:none}._group_1ndd9_1{display:flex;flex-direction:column;gap:16px;width:100%}._groupTitle_1ndd9_8{font-weight:700;font-size:16px;line-height:24px}._row_1ndd9_14{display:flex;flex-direction:row;justify-content:space-between;gap:16px;width:100%}._col_1ndd9_22{display:flex;flex-direction:column;gap:16px}._inputContainer_gs0vq_1{display:flex;flex-direction:column}._inputHeader_gs0vq_6{display:flex;margin-bottom:12px;align-items:center;justify-content:space-between}._label_gs0vq_13{font-weight:700;font-size:14px;line-height:22px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beda.software/web-item-controls",
3
- "version": "0.1.25-group-new-design.2",
3
+ "version": "0.1.25-group-new-design.4",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -344,7 +344,7 @@ msgstr ""
344
344
  #~ msgstr ""
345
345
 
346
346
  #: src/controls/GroupTable/hooks.tsx:615
347
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:266
347
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:296
348
348
  msgid "Are you sure you want to delete this item?"
349
349
  msgstr ""
350
350
 
@@ -1643,8 +1643,8 @@ msgstr ""
1643
1643
  #~ msgid "The questionnaire is saved"
1644
1644
  #~ msgstr ""
1645
1645
 
1646
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:212
1647
- #: src/readonly-controls/GroupWizardSidebar/index.tsx:158
1646
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:242
1647
+ #: src/readonly-controls/GroupWizardSidebar/index.tsx:176
1648
1648
  msgid "The sidebar item control requires at least 2 subgroups"
1649
1649
  msgstr ""
1650
1650
 
@@ -361,7 +361,7 @@ msgstr ""
361
361
  #~ msgstr ""
362
362
 
363
363
  #: src/controls/GroupTable/hooks.tsx:615
364
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:266
364
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:296
365
365
  msgid "Are you sure you want to delete this item?"
366
366
  msgstr ""
367
367
 
@@ -1868,8 +1868,8 @@ msgstr ""
1868
1868
  #~ msgid "The questionnaire is saved"
1869
1869
  #~ msgstr ""
1870
1870
 
1871
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:212
1872
- #: src/readonly-controls/GroupWizardSidebar/index.tsx:158
1871
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:242
1872
+ #: src/readonly-controls/GroupWizardSidebar/index.tsx:176
1873
1873
  msgid "The sidebar item control requires at least 2 subgroups"
1874
1874
  msgstr ""
1875
1875
 
@@ -361,7 +361,7 @@ msgstr ""
361
361
  #~ msgstr "¿Estás seguro de que quieres eliminar el documento?"
362
362
 
363
363
  #: src/controls/GroupTable/hooks.tsx:615
364
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:266
364
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:296
365
365
  msgid "Are you sure you want to delete this item?"
366
366
  msgstr "¿Estás seguro que deseas eliminar este ítem?"
367
367
 
@@ -1852,8 +1852,8 @@ msgstr ""
1852
1852
  #~ msgid "The questionnaire is saved"
1853
1853
  #~ msgstr "El cuestionario fue guardado"
1854
1854
 
1855
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:212
1856
- #: src/readonly-controls/GroupWizardSidebar/index.tsx:158
1855
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:242
1856
+ #: src/readonly-controls/GroupWizardSidebar/index.tsx:176
1857
1857
  msgid "The sidebar item control requires at least 2 subgroups"
1858
1858
  msgstr ""
1859
1859
 
@@ -361,7 +361,7 @@ msgstr ""
361
361
  #~ msgstr ""
362
362
 
363
363
  #: src/controls/GroupTable/hooks.tsx:615
364
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:266
364
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:296
365
365
  msgid "Are you sure you want to delete this item?"
366
366
  msgstr ""
367
367
 
@@ -1868,8 +1868,8 @@ msgstr ""
1868
1868
  #~ msgid "The questionnaire is saved"
1869
1869
  #~ msgstr ""
1870
1870
 
1871
- #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:212
1872
- #: src/readonly-controls/GroupWizardSidebar/index.tsx:158
1871
+ #: src/controls/GroupWizard/GroupWizardSidebar/index.tsx:242
1872
+ #: src/readonly-controls/GroupWizardSidebar/index.tsx:176
1873
1873
  msgid "The sidebar item control requires at least 2 subgroups"
1874
1874
  msgstr ""
1875
1875