@devgateway/dvz-ui-react 1.7.15 → 1.8.0

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,65 +1,65 @@
1
- import { jsx as e, jsxs as b } from "react/jsx-runtime";
2
- import F, { useState as p, useRef as ne, useEffect as T } from "react";
3
- import { Container as S, Accordion as E, Icon as oe, Menu as z, Grid as _, Label as G, Button as ie } from "semantic-ui-react";
4
- import { PostProvider as re, PostConsumer as q, MediaProvider as V, MediaConsumer as U, PostIcon as Y, PostLabel as J } from "@devgateway/wp-react-lib";
5
- import { injectIntl as ae } from "react-intl";
6
- import { connect as le } from "react-redux";
7
- import K from "../connected-templates/PostIntro.js";
8
- import { useWindowDimensionsAndDevice as ce } from "../../lib/hooks/window-dimensions.js";
9
- const se = ({ posts: t, activeItem: s, setActive: i, showLabels: n }) => t ? t.map((r) => /* @__PURE__ */ e(
10
- z.Item,
1
+ import { jsx as e, jsxs as g } from "react/jsx-runtime";
2
+ import y, { useState as v, useRef as G, useEffect as I } from "react";
3
+ import { Container as f, Accordion as p, Icon as V, Menu as T, Grid as w, Label as M, Button as W } from "semantic-ui-react";
4
+ import { PostProvider as q, PostConsumer as N, MediaProvider as P, MediaConsumer as k, PostIcon as L, PostLabel as S } from "@devgateway/wp-react-lib";
5
+ import { injectIntl as E } from "react-intl";
6
+ import { connect as z } from "react-redux";
7
+ import A from "../connected-templates/PostIntro.js";
8
+ import { useWindowDimensionsAndDevice as O } from "../../lib/hooks/window-dimensions.js";
9
+ const U = ({ posts: t, activeItem: a, setActive: i, showLabels: n }) => t ? t.map((l) => /* @__PURE__ */ e(
10
+ T.Item,
11
11
  {
12
- onClick: () => i(r.slug),
13
- className: r.slug === s ? "active" : "",
14
- children: n ? /* @__PURE__ */ e(J, { post: r }) : /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: r.title.rendered } }) })
12
+ onClick: () => i(l.slug),
13
+ className: l.slug === a ? "active" : "",
14
+ children: n ? /* @__PURE__ */ e(S, { post: l }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: l.title.rendered } }) })
15
15
  },
16
- r.id
17
- )) : null, de = ({
16
+ l.id
17
+ )) : null, Y = ({
18
18
  posts: t,
19
- activeItem: s,
19
+ activeItem: a,
20
20
  setActive: i,
21
21
  showIcons: n,
22
- showLabels: r
22
+ showLabels: l
23
23
  }) => {
24
- const l = t.length;
25
- return t ? t.map((c) => {
26
- var h, w;
27
- return (h = c._embedded) != null && h["wp:featuredmedia"] && c._embedded["wp:featuredmedia"][0].source_url, /* @__PURE__ */ e(
28
- _.Column,
24
+ const o = t.length;
25
+ return t ? t.map((r) => {
26
+ var d, m;
27
+ return (d = r._embedded) != null && d["wp:featuredmedia"] && r._embedded["wp:featuredmedia"][0].source_url, /* @__PURE__ */ e(
28
+ w.Column,
29
29
  {
30
- className: (c.slug === s ? "active" : "") + (n ? " has-icon" : ""),
31
- children: /* @__PURE__ */ b(
32
- ie,
30
+ className: (r.slug === a ? "active" : "") + (n ? " has-icon" : ""),
31
+ children: /* @__PURE__ */ g(
32
+ W,
33
33
  {
34
- onClick: () => i(c.slug),
35
- className: `nav ${l === 1 ? "one" : ""}`,
34
+ onClick: () => i(r.slug),
35
+ className: `nav ${o === 1 ? "one" : ""}`,
36
36
  children: [
37
37
  n && /* @__PURE__ */ e(
38
- V,
38
+ P,
39
39
  {
40
- id: (w = c.meta_fields) != null && w.icon ? c.meta_fields.icon[0] : null,
41
- children: /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e(Y, { className: "icon" }) })
40
+ id: (m = r.meta_fields) != null && m.icon ? r.meta_fields.icon[0] : null,
41
+ children: /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(L, { className: "icon" }) })
42
42
  }
43
43
  ),
44
- r ? /* @__PURE__ */ e(J, { post: c }) : /* @__PURE__ */ e(G, { children: /* @__PURE__ */ e(
44
+ l ? /* @__PURE__ */ e(S, { post: r }) : /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
45
45
  "span",
46
46
  {
47
- dangerouslySetInnerHTML: { __html: c.title.rendered }
47
+ dangerouslySetInnerHTML: { __html: r.title.rendered }
48
48
  }
49
49
  ) })
50
50
  ]
51
51
  }
52
52
  )
53
53
  },
54
- c.id
54
+ r.id
55
55
  );
56
56
  }) : null;
57
- }, Q = ({ posts: t, activeItem: s }) => (T(() => {
57
+ }, $ = ({ posts: t, activeItem: a }) => (I(() => {
58
58
  const i = document.querySelector(".ui.container.content-tab");
59
59
  i && (i.scrollTop = 0);
60
- }, [s]), t ? t.map((i) => {
60
+ }, [a]), t ? t.map((i) => {
61
61
  let n = {};
62
- return i.slug !== s ? n = {
62
+ return i.slug !== a ? n = {
63
63
  position: "absolute",
64
64
  left: "-3000px",
65
65
  width: "auto",
@@ -70,91 +70,35 @@ const se = ({ posts: t, activeItem: s, setActive: i, showLabels: n }) => t ? t.m
70
70
  visibility: "visible",
71
71
  position: "relative",
72
72
  width: "auto"
73
- }, /* @__PURE__ */ e(K, { as: S, fluid: !0, post: i, style: n }, i.slug);
74
- }) : null), ue = ({ posts: t, activeItem: s, setActive: i }) => {
75
- const [n, r] = p(
76
- t.findIndex((o) => o.slug === s)
77
- ), [l, c] = p(null), h = ne(null), [w, A] = p(window.innerWidth <= 1250);
78
- T(() => {
79
- if (l) {
80
- const o = l.getBoundingClientRect().top + window.scrollY;
73
+ }, /* @__PURE__ */ e(A, { as: f, fluid: !0, post: i, style: n }, i.slug);
74
+ }) : null), J = ({ posts: t, activeItem: a, setActive: i }) => {
75
+ const [n, l] = v(
76
+ t.findIndex((s) => s.slug === a)
77
+ ), [o, r] = v(null), d = G(null);
78
+ I(() => {
79
+ if (o) {
80
+ const s = o.getBoundingClientRect().top + window.scrollY;
81
81
  window.scrollTo({
82
- top: o,
82
+ top: s,
83
83
  behavior: "smooth"
84
84
  });
85
85
  }
86
- }, [l]);
87
- const v = () => {
88
- var o;
89
- return ((o = window.screen.orientation) == null ? void 0 : o.type) || (window.innerWidth > window.innerHeight ? "landscape-primary" : "portrait-primary");
90
- }, [m, L] = p(v()), g = () => {
91
- setTimeout(() => {
92
- L(v()), A(window.innerWidth <= 1250);
93
- }, 100);
94
- }, P = (o) => {
95
- setTimeout(() => {
96
- var d;
97
- const u = o.querySelectorAll(
98
- ".accordion .legends.container.has-standard-12-font-size.bottom, .legends.container.items-section"
99
- );
100
- if (u.length !== 0)
101
- for (const a of u) {
102
- const x = a.closest(".ui.fluid.container.content"), f = x ? x.querySelector(".data-source") : null;
103
- if (!f || a.offsetParent === null || f.offsetParent === null || a.offsetHeight === 0 || f.offsetHeight === 0)
104
- continue;
105
- const I = f.getBoundingClientRect(), D = a.getBoundingClientRect(), X = window.getComputedStyle(f), H = window.getComputedStyle(a), Z = Number.parseFloat(X.marginTop) || 0, ee = Number.parseFloat(H.marginBottom) || 0, M = D.bottom + ee, W = I.top - Z;
106
- if (M > W) {
107
- const C = M - W;
108
- f.style.marginTop = `${C + 20}px`;
109
- }
110
- const N = (d = a.closest(
111
- ".wp-block-column.is-layout-flow.wp-block-column-is-layout-flow"
112
- )) == null ? void 0 : d.nextElementSibling;
113
- if (N) {
114
- const C = N.getBoundingClientRect(), k = window.getComputedStyle(N), $ = Number.parseFloat(k.marginTop) || 0, y = C.top - $;
115
- if (M > y) {
116
- const j = M - y;
117
- N.style.marginTop = `${j + 20}px`;
118
- }
119
- }
120
- const R = a.closest(".chart.container");
121
- if (R) {
122
- const C = R.getBoundingClientRect(), k = window.getComputedStyle(R), $ = Number.parseFloat(k.marginBottom) || 0, y = C.bottom + $, j = Number.parseFloat(H.marginTop) || 0, O = D.top - j;
123
- if (O < y) {
124
- const te = y - O;
125
- a.style.marginTop = `${te + 20}px`;
126
- }
127
- }
128
- }
129
- }, 10);
130
- };
131
- T(() => (window.screen.orientation && window.screen.orientation.addEventListener(
132
- "change",
133
- g
134
- ), window.addEventListener("resize", g), () => window.removeEventListener("resize", g)), []), T(() => {
135
- let o;
136
- const u = [];
137
- return n !== -1 && (o = setTimeout(() => {
138
- document.querySelectorAll(".accordion").forEach((a) => P(a));
139
- }, 0)), () => {
140
- clearTimeout(o), u.forEach((d) => d.disconnect());
141
- };
142
- }, [n, w, m]);
143
- const B = (o, u) => {
144
- const { index: d } = u, a = n === d ? -1 : d;
145
- r(a), i(t[d].slug), a !== -1 && c(o.currentTarget);
86
+ }, [o]);
87
+ const m = (s, u) => {
88
+ const { index: c } = u, h = n === c ? -1 : c;
89
+ l(h), i(t[c].slug), h !== -1 && r(s.currentTarget);
146
90
  };
147
- return /* @__PURE__ */ e(E, { fluid: !0, styled: !0, children: t.map((o, u) => {
148
- var a;
149
- const d = (a = o.meta_fields) != null && a.icon ? o.meta_fields.icon[0] : null;
150
- return /* @__PURE__ */ b(F.Fragment, { children: [
91
+ return /* @__PURE__ */ e(p, { fluid: !0, styled: !0, children: t.map((s, u) => {
92
+ var h;
93
+ const c = (h = s.meta_fields) != null && h.icon ? s.meta_fields.icon[0] : null;
94
+ return /* @__PURE__ */ g(y.Fragment, { children: [
151
95
  /* @__PURE__ */ e(
152
- E.Title,
96
+ p.Title,
153
97
  {
154
98
  active: n === u,
155
99
  index: u,
156
- onClick: B,
157
- children: /* @__PURE__ */ b(
100
+ onClick: m,
101
+ children: /* @__PURE__ */ g(
158
102
  "div",
159
103
  {
160
104
  style: {
@@ -164,100 +108,100 @@ const se = ({ posts: t, activeItem: s, setActive: i, showLabels: n }) => t ? t.m
164
108
  width: "100%"
165
109
  },
166
110
  children: [
167
- /* @__PURE__ */ b("div", { style: { display: "flex", alignItems: "center" }, children: [
168
- d && /* @__PURE__ */ e(V, { id: d, children: /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e(Y, { className: "icon" }) }) }),
111
+ /* @__PURE__ */ g("div", { style: { display: "flex", alignItems: "center" }, children: [
112
+ c && /* @__PURE__ */ e(P, { id: c, children: /* @__PURE__ */ e(k, { children: /* @__PURE__ */ e(L, { className: "icon" }) }) }),
169
113
  /* @__PURE__ */ e(
170
114
  "span",
171
115
  {
172
- dangerouslySetInnerHTML: { __html: o.title.rendered },
173
- style: { marginLeft: d ? "10px" : "0" }
116
+ dangerouslySetInnerHTML: { __html: s.title.rendered },
117
+ style: { marginLeft: c ? "10px" : "0" }
174
118
  }
175
119
  )
176
120
  ] }),
177
- /* @__PURE__ */ e(oe, { name: "chevron down" })
121
+ /* @__PURE__ */ e(V, { name: "chevron down" })
178
122
  ]
179
123
  }
180
124
  )
181
125
  }
182
126
  ),
183
127
  /* @__PURE__ */ e(
184
- E.Content,
128
+ p.Content,
185
129
  {
186
130
  className: "accordion-post-content",
187
131
  active: n === u,
188
- children: /* @__PURE__ */ e("div", { ref: h, children: /* @__PURE__ */ e(K, { post: o, as: S, fluid: !0 }) })
132
+ children: /* @__PURE__ */ e("div", { ref: d, children: /* @__PURE__ */ e(A, { post: s, as: f, fluid: !0 }) })
189
133
  }
190
134
  )
191
- ] }, o.id);
135
+ ] }, s.id);
192
136
  }) });
193
- }, me = ({ posts: t, showLabels: s, height: i }) => {
194
- const [n, r] = p(t ? t[0].slug : null);
195
- return T(() => {
137
+ }, K = ({ posts: t, showLabels: a, height: i }) => {
138
+ const [n, l] = v(t ? t[0].slug : null);
139
+ return I(() => {
196
140
  setTimeout(() => {
197
141
  if (window.location.hash) {
198
- const l = window.location.hash.substr(1), c = document.getElementById(l);
199
- c && t.map((h) => h.slug).indexOf(l) > -1 && (r(l), c.scrollIntoView({ behavior: "auto", block: "start" }));
142
+ const o = window.location.hash.substr(1), r = document.getElementById(o);
143
+ r && t.map((d) => d.slug).indexOf(o) > -1 && (l(o), r.scrollIntoView({ behavior: "auto", block: "start" }));
200
144
  }
201
145
  }, 0);
202
- }, [t]), /* @__PURE__ */ b(F.Fragment, { children: [
203
- t.map((l) => /* @__PURE__ */ e("anchor", { id: l.slug }, l.slug)),
204
- /* @__PURE__ */ e(z, { className: "tabbed posts", text: !0, children: /* @__PURE__ */ e(se, { showLabels: s, posts: t, setActive: r, activeItem: n }) }),
205
- /* @__PURE__ */ e(S, { className: "content-tab", style: { height: `${i}px` }, children: /* @__PURE__ */ e(Q, { posts: t, activeItem: n }) })
146
+ }, [t]), /* @__PURE__ */ g(y.Fragment, { children: [
147
+ t.map((o) => /* @__PURE__ */ e("anchor", { id: o.slug }, o.slug)),
148
+ /* @__PURE__ */ e(T, { className: "tabbed posts", text: !0, children: /* @__PURE__ */ e(U, { showLabels: a, posts: t, setActive: l, activeItem: n }) }),
149
+ /* @__PURE__ */ e(f, { className: "content-tab", style: { height: `${i}px` }, children: /* @__PURE__ */ e($, { posts: t, activeItem: n }) })
206
150
  ] });
207
- }, he = ({ posts: t, showLabels: s, showIcons: i, height: n }) => {
208
- const [r, l] = p(t ? t[0].slug : null);
209
- return /* @__PURE__ */ e(F.Fragment, { children: /* @__PURE__ */ b(_, { stackable: !0, className: "tabbed posts", columns: t.length, style: { height: n + "px" }, children: [
210
- /* @__PURE__ */ e(de, { showIcons: i, showLabels: s, posts: t, activeItem: r, setActive: l }),
211
- /* @__PURE__ */ e(_.Row, { style: { height: `${n}px` }, children: /* @__PURE__ */ e(_.Column, { width: 16, className: "content", children: /* @__PURE__ */ e(S, { className: "content-tab", style: { height: `${n}px` }, children: /* @__PURE__ */ e(Q, { className: "content-tab", posts: t, activeItem: r }) }) }) })
151
+ }, Q = ({ posts: t, showLabels: a, showIcons: i, height: n }) => {
152
+ const [l, o] = v(t ? t[0].slug : null);
153
+ return /* @__PURE__ */ e(y.Fragment, { children: /* @__PURE__ */ g(w, { stackable: !0, className: "tabbed posts", columns: t.length, style: { height: n + "px" }, children: [
154
+ /* @__PURE__ */ e(Y, { showIcons: i, showLabels: a, posts: t, activeItem: l, setActive: o }),
155
+ /* @__PURE__ */ e(w.Row, { style: { height: `${n}px` }, children: /* @__PURE__ */ e(w.Column, { width: 16, className: "content", children: /* @__PURE__ */ e(f, { className: "content-tab", style: { height: `${n}px` }, children: /* @__PURE__ */ e($, { className: "content-tab", posts: t, activeItem: l }) }) }) })
212
156
  ] }) });
213
- }, ge = (t) => {
214
- var I;
157
+ }, X = (t) => {
158
+ var _;
215
159
  let {
216
- "data-type": s,
160
+ "data-type": a,
217
161
  "data-taxonomy": i,
218
162
  "data-categories": n,
219
- "data-items": r,
220
- "data-theme": l = "light",
221
- "data-show-icons": c,
222
- "data-use-scrolls": h,
223
- "data-show-labels": w,
224
- "data-height": A,
225
- "data-preview-mode": v = "Desktop",
226
- pageModuleProps: m,
227
- parent: L,
228
- editing: g,
229
- unique: P
163
+ "data-items": l,
164
+ "data-theme": o = "light",
165
+ "data-show-icons": r,
166
+ "data-use-scrolls": d,
167
+ "data-show-labels": m,
168
+ "data-height": s,
169
+ "data-preview-mode": u = "Desktop",
170
+ pageModuleProps: c,
171
+ parent: h,
172
+ editing: b,
173
+ unique: D
230
174
  } = t;
231
- m != null && m.previewMode && (m != null && m.editing) && (v = m.previewMode, g = m.editing);
232
- const B = t.intl.locale, o = h === "true", u = o ? A : void 0, { width: d } = ce(), a = d <= 1024, x = v !== "Desktop" && g, f = a && !g;
233
- return /* @__PURE__ */ e(S, { className: `viz tabbed posts ${g ? "editing" : ""} ${o ? "scrollable" : ""}`, fluid: !0, children: /* @__PURE__ */ e(
234
- re,
175
+ c != null && c.previewMode && (c != null && c.editing) && (u = c.previewMode, b = c.editing);
176
+ const R = t.intl.locale, x = d === "true", C = x ? s : void 0, { width: j } = O(), H = j <= 1024, B = u !== "Desktop" && b, F = H && !b;
177
+ return /* @__PURE__ */ e(f, { className: `viz tabbed posts ${b ? "editing" : ""} ${x ? "scrollable" : ""}`, fluid: !0, children: /* @__PURE__ */ e(
178
+ q,
235
179
  {
236
- locale: B,
237
- type: s,
180
+ locale: R,
181
+ type: a,
238
182
  taxonomy: i,
239
183
  categories: n,
240
- store: `tabbedposts_${L}_${P}`,
184
+ store: `tabbedposts_${h}_${D}`,
241
185
  page: 1,
242
- perPage: r,
243
- children: /* @__PURE__ */ e(q, { children: /* @__PURE__ */ e(q, { children: f || x ? /* @__PURE__ */ e(ue, { posts: r, activeItem: (I = r[0]) == null ? void 0 : I.slug, setActive: () => {
244
- } }) : l === "light" ? /* @__PURE__ */ e(me, { height: u, showLabels: w === "true" }) : /* @__PURE__ */ e(
245
- he,
186
+ perPage: l,
187
+ children: /* @__PURE__ */ e(N, { children: /* @__PURE__ */ e(N, { children: F || B ? /* @__PURE__ */ e(J, { posts: l, activeItem: (_ = l[0]) == null ? void 0 : _.slug, setActive: () => {
188
+ } }) : o === "light" ? /* @__PURE__ */ e(K, { height: C, showLabels: m === "true" }) : /* @__PURE__ */ e(
189
+ Q,
246
190
  {
247
- height: u,
248
- showLabels: w === "true",
249
- showIcons: c === "true"
191
+ height: C,
192
+ showLabels: m === "true",
193
+ showIcons: r === "true"
250
194
  }
251
195
  ) }) })
252
196
  }
253
197
  ) });
254
- }, fe = (t, s) => {
198
+ }, Z = (t, a) => {
255
199
  const i = t.getIn([
256
200
  "data",
257
201
  "pageModuleProps"
258
202
  ]), n = {};
259
203
  return i && (n.pageModuleProps = i), n;
260
- }, we = {}, Ie = le(fe, we)(ae(ge));
204
+ }, ee = {}, se = z(Z, ee)(E(X));
261
205
  export {
262
- Ie as default
206
+ se as default
263
207
  };