@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,31 +1,31 @@
1
1
  import { jsx as e, jsxs as u } from "react/jsx-runtime";
2
- import { Menu as d, Container as b, Flag as P, Image as U } from "semantic-ui-react";
3
- import L, { useEffect as _, useState as p, useRef as y } from "react";
4
- import { utils as j, MenuProvider as H, MediaProvider as A, MediaConsumer as V, MenuConsumer as E } from "@devgateway/wp-react-lib";
5
- import { injectIntl as R } from "react-intl";
6
- import { useParams as $ } from "react-router";
7
- import B from "./SearchControl.js";
8
- import K from "./LangSwitcher.js";
9
- const W = (r, s) => {
2
+ import { Menu as d, Container as N, Flag as U, Image as j } from "semantic-ui-react";
3
+ import E, { useEffect as p, useState as g, useRef as W } from "react";
4
+ import { utils as H, MenuProvider as A, MediaProvider as V, MediaConsumer as B, MenuConsumer as b } from "@devgateway/wp-react-lib";
5
+ import { injectIntl as T } from "react-intl";
6
+ import { useParams as y } from "react-router";
7
+ import K from "./SearchControl.js";
8
+ import q from "./LangSwitcher.js";
9
+ const F = (r, l) => {
10
10
  const t = [];
11
11
  return r.items.forEach((i) => {
12
12
  i.child_items ? i.child_items.forEach((a) => {
13
- a.slug == s.slug && (t.push(i), t.push(a));
14
- }) : i.slug == s.slug && i.url != "/" && t.push(i);
13
+ a.slug == l.slug && (t.push(i), t.push(a));
14
+ }) : i.slug == l.slug && i.url != "/" && t.push(i);
15
15
  }), t;
16
- }, x = (r, s) => {
16
+ }, S = (r, l) => {
17
17
  if (r) {
18
18
  const t = r.indexOf("/wp");
19
19
  if (t !== -1) {
20
20
  const i = r.substr(t + 3);
21
- return i.startsWith("/" + s) ? i : "/" + s + i;
21
+ return i.startsWith("/" + l) ? i : "/" + l + i;
22
22
  } else
23
- return r.startsWith("/" + s) ? r : "/" + s + r;
23
+ return r.startsWith("/" + l) ? r : "/" + l + r;
24
24
  }
25
25
  return "";
26
- }, q = R(({ menu: r, intl: s }) => {
27
- const t = $(), i = W(r, t);
28
- return /* @__PURE__ */ e(L.Fragment, { children: i.filter((a) => a.url != "#wpm-languages").map(
26
+ }, G = T(({ menu: r, intl: l }) => {
27
+ const t = y(), i = F(r, t);
28
+ return /* @__PURE__ */ e(E.Fragment, { children: i.filter((a) => a.url != "#wpm-languages").map(
29
29
  (a) => a.child_items ? /* @__PURE__ */ u("span", { children: [
30
30
  a.post_title,
31
31
  " "
@@ -33,7 +33,7 @@ const W = (r, s) => {
33
33
  "a",
34
34
  {
35
35
  className: a.slug == t.slug ? "active" : "",
36
- href: j.replaceLink(a.url, s.locale),
36
+ href: H.replaceLink(a.url, l.locale),
37
37
  children: [
38
38
  " ",
39
39
  a.post_title
@@ -41,53 +41,53 @@ const W = (r, s) => {
41
41
  }
42
42
  )
43
43
  ) });
44
- }), C = R(
44
+ }), O = T(
45
45
  ({
46
46
  settings: r,
47
- withIcons: s,
47
+ withIcons: l,
48
48
  active: t,
49
49
  menu: i,
50
50
  onSetSelected: a,
51
51
  selected: o,
52
- intl: { locale: g },
53
- isSmallScreen: D
52
+ intl: { locale: f },
53
+ isSmallScreen: L
54
54
  }) => {
55
- const z = $();
56
- _(
55
+ const z = y();
56
+ p(
57
57
  (n) => {
58
- const l = W(i, z).filter((f) => f.menu_item_parent == 0);
59
- l && l.length > 0 ? a(l[0]) : a(null);
58
+ const s = F(i, z).filter((_) => _.menu_item_parent == 0);
59
+ s && s.length > 0 ? a(s[0]) : a(null);
60
60
  },
61
61
  [i, a, z.slug]
62
62
  );
63
- const [v, I] = p(null);
64
- _(() => {
65
- I(i);
66
- }, [i]), _(() => {
63
+ const [v, w] = g(null);
64
+ p(() => {
65
+ w(i);
66
+ }, [i]), p(() => {
67
67
  if (r && r.menu_settings && v) {
68
- const n = [], h = i.items.map((l) => (r.menu_settings && r.menu_settings["nav_menu_item[" + l.ID + "]"] === !1 && n.push(l.ID), r.menu_settings && r.menu_settings["nav_menu_item[" + l.ID + "]"] ? (r.menu_settings["nav_menu_item[" + l.ID + "]"], {
69
- ...l,
70
- ...r.menu_settings["nav_menu_item[" + l.ID + "]"]
71
- }) : l));
72
- Object.keys(r.menu_settings).map((l) => {
73
- const f = r.menu_settings[l];
74
- if (f.type == "nav_menu_item") {
75
- const S = /(-)?[0-9]+/g.exec(l), k = parseInt(S[0]);
76
- h.find((c) => c.ID == k) || h.push(f.value);
68
+ const n = [], m = i.items.map((s) => (r.menu_settings && r.menu_settings["nav_menu_item[" + s.ID + "]"] === !1 && n.push(s.ID), r.menu_settings && r.menu_settings["nav_menu_item[" + s.ID + "]"] ? (r.menu_settings["nav_menu_item[" + s.ID + "]"], {
69
+ ...s,
70
+ ...r.menu_settings["nav_menu_item[" + s.ID + "]"]
71
+ }) : s));
72
+ Object.keys(r.menu_settings).map((s) => {
73
+ const _ = r.menu_settings[s];
74
+ if (_.type == "nav_menu_item") {
75
+ const D = /(-)?[0-9]+/g.exec(s), C = parseInt(D[0]);
76
+ m.find(($) => $.ID == C) || m.push(_.value);
77
77
  }
78
- }), I({
78
+ }), w({
79
79
  ...i,
80
- items: h.filter((l) => n.indexOf(l.ID) === -1)
80
+ items: m.filter((s) => n.indexOf(s.ID) === -1)
81
81
  });
82
82
  }
83
83
  }, [r]);
84
- const [w, M] = p(!1);
85
- return _(() => {
84
+ const [k, I] = g(!1);
85
+ return p(() => {
86
86
  const n = () => {
87
- M(window.innerWidth <= 1200);
87
+ I(window.innerWidth <= 1200);
88
88
  };
89
89
  return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
90
- }, []), v && /* @__PURE__ */ e(L.Fragment, { children: v.items.filter((n) => n.url !== "#wpm-languages").map((n, h) => /* @__PURE__ */ u(L.Fragment, { children: [
90
+ }, []), v && /* @__PURE__ */ e(E.Fragment, { children: v.items.filter((n) => n.url !== "#wpm-languages").map((n, m) => /* @__PURE__ */ u(E.Fragment, { children: [
91
91
  /* @__PURE__ */ u(
92
92
  d.Item,
93
93
  {
@@ -95,84 +95,84 @@ const W = (r, s) => {
95
95
  ${o && o.ID === n.ID ? "selected" : ""}
96
96
  ${t === n.slug ? "active" : ""}`,
97
97
  children: [
98
- s && /* @__PURE__ */ e("a", { href: x(n.url, g), children: /* @__PURE__ */ e("div", { className: "mark", children: /* @__PURE__ */ e("span", { className: "sr-only", children: n.title }) }) }),
99
- D ? n.child_items ? /* @__PURE__ */ e(
98
+ l && /* @__PURE__ */ e("a", { href: S(n.url, f), children: /* @__PURE__ */ e("div", { className: "mark", children: /* @__PURE__ */ e("span", { className: "sr-only", children: n.title }) }) }),
99
+ L ? n.child_items ? /* @__PURE__ */ e(
100
100
  "span",
101
101
  {
102
102
  onClick: () => a(o === n ? null : n),
103
103
  children: n.title
104
104
  }
105
- ) : /* @__PURE__ */ e("a", { href: x(n.url, g), children: n.title }) : n.child_items ? /* @__PURE__ */ e(
105
+ ) : /* @__PURE__ */ e("a", { href: S(n.url, f), children: n.title }) : n.child_items ? /* @__PURE__ */ e(
106
106
  "span",
107
107
  {
108
- onMouseOver: (l) => a(n),
108
+ onMouseOver: (s) => a(n),
109
109
  onClick: () => a(o === n ? null : n),
110
110
  children: n.title
111
111
  }
112
112
  ) : /* @__PURE__ */ e(
113
113
  "a",
114
114
  {
115
- onMouseOut: (l) => a(null),
116
- onMouseOver: (l) => a(n),
117
- href: x(n.url, g),
115
+ onMouseOut: (s) => a(null),
116
+ onMouseOver: (s) => a(n),
117
+ href: S(n.url, f),
118
118
  children: n.title
119
119
  }
120
120
  )
121
121
  ]
122
122
  }
123
123
  ),
124
- w && o && o.ID === n.ID && o.child_items && /* @__PURE__ */ e(L.Fragment, { children: o.child_items.map((l) => /* @__PURE__ */ u(
124
+ k && o && o.ID === n.ID && o.child_items && /* @__PURE__ */ e(E.Fragment, { children: o.child_items.map((s) => /* @__PURE__ */ u(
125
125
  d.Item,
126
126
  {
127
- className: `divided child-item ${t === l.slug ? "active" : ""}`,
127
+ className: `divided child-item ${t === s.slug ? "active" : ""}`,
128
128
  children: [
129
129
  /* @__PURE__ */ e("div", { className: "mark" }),
130
- /* @__PURE__ */ e("a", { href: x(l.url, g), children: l.title })
130
+ /* @__PURE__ */ e("a", { href: S(s.url, f), children: s.title })
131
131
  ]
132
132
  },
133
- l.ID
133
+ s.ID
134
134
  )) })
135
135
  ] }, n.ID)) });
136
136
  }
137
- ), G = ({ intl: r, settings: s }) => {
138
- const [t, i] = p(), [a, o] = p(!1), [g, D] = p(!1), [z, v] = p(!1), [I, w] = p(!1), { slug: M } = $(), n = y(null), h = y(null), l = () => {
139
- w(!I), o(!a);
137
+ ), J = ({ intl: r, settings: l, logoSmallSrc: t = "/logo_small.png" }) => {
138
+ const [i, a] = g(), [o, f] = g(!1), [L, z] = g(!1), [v, w] = g(!1), [k, I] = g(!1), { slug: n } = y(), m = W(null), s = W(null), _ = () => {
139
+ I(!k), f(!o);
140
140
  };
141
- _(() => {
142
- const c = (m) => {
143
- (n.current && !n.current.contains(m.target) && !h.current.contains(m.target) || m.target.closest(".desktop") || m.target.closest(".breadcrumbs")) && (o(!1), w(!1));
144
- }, N = (m) => {
145
- m.key === "Escape" && (o(!1), w(!1));
141
+ p(() => {
142
+ const c = (h) => {
143
+ (m.current && !m.current.contains(h.target) && !s.current.contains(h.target) || h.target.closest(".desktop") || h.target.closest(".breadcrumbs")) && (f(!1), I(!1));
144
+ }, M = (h) => {
145
+ h.key === "Escape" && (f(!1), I(!1));
146
146
  };
147
- return document.addEventListener("mousedown", c), document.addEventListener("keydown", N), () => {
148
- document.removeEventListener("mousedown", c), document.removeEventListener("keydown", N);
147
+ return document.addEventListener("mousedown", c), document.addEventListener("keydown", M), () => {
148
+ document.removeEventListener("mousedown", c), document.removeEventListener("keydown", M);
149
149
  };
150
- }, []), _(() => {
150
+ }, []), p(() => {
151
151
  let c;
152
- const N = () => {
153
- const F = window.innerWidth <= 1200;
154
- D(F), v(!1);
155
- }, m = () => {
156
- v(!0), clearTimeout(c), c = setTimeout(N, 300);
152
+ const M = () => {
153
+ const P = window.innerWidth <= 1200;
154
+ z(P), w(!1);
155
+ }, h = () => {
156
+ w(!0), clearTimeout(c), c = setTimeout(M, 300);
157
157
  };
158
- return N(), window.addEventListener("resize", m), () => {
159
- clearTimeout(c), window.removeEventListener("resize", m);
158
+ return M(), window.addEventListener("resize", h), () => {
159
+ clearTimeout(c), window.removeEventListener("resize", h);
160
160
  };
161
161
  }, []);
162
- const [f, T] = p(!1);
163
- _(() => {
162
+ const [x, D] = g(!1);
163
+ p(() => {
164
164
  const c = () => {
165
- T(window.innerWidth <= 1364);
165
+ D(window.innerWidth <= 1364);
166
166
  };
167
167
  return c(), window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
168
168
  }, []);
169
- const S = ({ media: c }) => c ? /* @__PURE__ */ e(U, { src: c.guid.rendered }) : /* @__PURE__ */ e("img", { className: "brand logo", size: "large", src: "/logo_full.png" }), k = (s == null ? void 0 : s.landing_page_url) && s.landing_page_url !== !1 && s.landing_page_url !== void 0 && s.landing_page_url !== "", O = k ? s.landing_page_url : `/${r.locale}`;
170
- return /* @__PURE__ */ e(L.Fragment, { children: /* @__PURE__ */ u(H, { slug: "main", locale: r.locale, children: [
171
- /* @__PURE__ */ u(b, { fluid: !0, className: "header", children: [
172
- /* @__PURE__ */ e(b, { fluid: !0, className: "background", ref: n, children: /* @__PURE__ */ u(d, { className: "branding", text: !0, children: [
173
- /* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ u("a", { href: `${O}`, target: k ? "_blank" : "_self", rel: "noopener noreferrer", id: "site_url", children: [
174
- s.site_logo !== 0 && !f && /* @__PURE__ */ e(A, { id: s.site_logo, children: /* @__PURE__ */ e(V, { children: /* @__PURE__ */ e(S, {}, "logo") }) }),
175
- s.site_logo === 0 && !f && /* @__PURE__ */ e(
169
+ const C = ({ media: c }) => c ? /* @__PURE__ */ e(j, { src: c.guid.rendered }) : /* @__PURE__ */ e("img", { className: "brand logo", size: "large", src: "/logo_full.png" }), R = (l == null ? void 0 : l.landing_page_url) && l.landing_page_url !== !1 && l.landing_page_url !== void 0 && l.landing_page_url !== "", $ = R ? l.landing_page_url : `/${r.locale}`;
170
+ return /* @__PURE__ */ e(E.Fragment, { children: /* @__PURE__ */ u(A, { slug: "main", locale: r.locale, children: [
171
+ /* @__PURE__ */ u(N, { fluid: !0, className: "header", children: [
172
+ /* @__PURE__ */ e(N, { fluid: !0, className: "background", ref: m, children: /* @__PURE__ */ u(d, { className: "branding", text: !0, children: [
173
+ /* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ u("a", { href: `${$}`, target: R ? "_blank" : "_self", rel: "noopener noreferrer", id: "site_url", children: [
174
+ l.site_logo !== 0 && !x && /* @__PURE__ */ e(V, { id: l.site_logo, children: /* @__PURE__ */ e(B, { children: /* @__PURE__ */ e(C, {}, "logo") }) }),
175
+ l.site_logo === 0 && !x && /* @__PURE__ */ e(
176
176
  "img",
177
177
  {
178
178
  className: "brand logo",
@@ -180,60 +180,60 @@ const W = (r, s) => {
180
180
  src: "/logo_full.png"
181
181
  }
182
182
  ),
183
- f && /* @__PURE__ */ e(
183
+ x && /* @__PURE__ */ e(
184
184
  "img",
185
185
  {
186
186
  className: "brand logo small",
187
187
  size: "small",
188
- src: "/wp-media/TCDI-Icon-small_02.png"
188
+ src: t
189
189
  }
190
190
  )
191
191
  ] }) }),
192
192
  /* @__PURE__ */ e(d.Item, { className: "divider", children: /* @__PURE__ */ e("div", {}) }),
193
193
  /* @__PURE__ */ u(d.Item, { fitted: !0, href: "/", children: [
194
- /* @__PURE__ */ e(P, { name: "za" }),
195
- /* @__PURE__ */ e("div", { className: "site name", children: s.name })
194
+ /* @__PURE__ */ e(U, { name: "za" }),
195
+ /* @__PURE__ */ e("div", { className: "site name", children: l.name })
196
196
  ] }),
197
- !z && (g ? /* @__PURE__ */ e(d, { className: `pages ${a ? "show" : ""}`, children: /* @__PURE__ */ e(b, { fluid: !0, children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
198
- C,
197
+ !v && (L ? /* @__PURE__ */ e(d, { className: `pages ${o ? "show" : ""}`, children: /* @__PURE__ */ e(N, { fluid: !0, children: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(
198
+ O,
199
199
  {
200
- settings: s,
201
- active: M,
202
- selected: t,
203
- onSetSelected: i,
204
- isSmallScreen: g
200
+ settings: l,
201
+ active: n,
202
+ selected: i,
203
+ onSetSelected: a,
204
+ isSmallScreen: L
205
205
  },
206
206
  "items"
207
- ) }) }) }) : /* @__PURE__ */ e(d.Menu, { className: "pages", children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
208
- C,
207
+ ) }) }) }) : /* @__PURE__ */ e(d.Menu, { className: "pages", children: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(
208
+ O,
209
209
  {
210
- settings: s,
211
- active: M,
212
- selected: t,
213
- onSetSelected: i
210
+ settings: l,
211
+ active: n,
212
+ selected: i,
213
+ onSetSelected: a
214
214
  },
215
215
  "items"
216
216
  ) }) })),
217
- /* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
218
- K,
217
+ /* @__PURE__ */ e(d.Item, { children: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(
218
+ q,
219
219
  {
220
220
  locale: r.locale
221
221
  },
222
222
  "lang"
223
223
  ) }) }),
224
- /* @__PURE__ */ e(d.Item, { fitted: !0, children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(
225
- B,
224
+ /* @__PURE__ */ e(d.Item, { fitted: !0, children: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(
225
+ K,
226
226
  {
227
- onSetSelected: i,
228
- settings: s
227
+ onSetSelected: a,
228
+ settings: l
229
229
  }
230
230
  ) }) }),
231
231
  /* @__PURE__ */ u(
232
232
  "div",
233
233
  {
234
- ref: h,
235
- className: `hamburger-menu ${I ? "animate" : ""} ${a ? "open" : "close"}`,
236
- onClick: l,
234
+ ref: s,
235
+ className: `hamburger-menu ${k ? "animate" : ""} ${o ? "open" : "close"}`,
236
+ onClick: _,
237
237
  children: [
238
238
  /* @__PURE__ */ e("div", {}),
239
239
  /* @__PURE__ */ e("div", { className: "middle-line" }),
@@ -242,20 +242,20 @@ const W = (r, s) => {
242
242
  }
243
243
  )
244
244
  ] }) }),
245
- /* @__PURE__ */ e(b, { fluid: !0, className: "child", children: t && t.child_items && /* @__PURE__ */ e(d, { fluid: !0, text: !0, children: /* @__PURE__ */ e(
246
- C,
245
+ /* @__PURE__ */ e(N, { fluid: !0, className: "child", children: i && i.child_items && /* @__PURE__ */ e(d, { fluid: !0, text: !0, children: /* @__PURE__ */ e(
246
+ O,
247
247
  {
248
- active: M,
248
+ active: n,
249
249
  locale: r.locale,
250
250
  withIcons: !0,
251
251
  onSetSelected: (c) => null,
252
- menu: { items: t.child_items }
252
+ menu: { items: i.child_items }
253
253
  }
254
254
  ) }) })
255
255
  ] }, "header-container"),
256
- /* @__PURE__ */ e(b, { className: "url breadcrumbs", children: /* @__PURE__ */ e(E, { children: /* @__PURE__ */ e(q, {}) }) })
256
+ /* @__PURE__ */ e(N, { className: "url breadcrumbs", children: /* @__PURE__ */ e(b, { children: /* @__PURE__ */ e(G, {}) }) })
257
257
  ] }) });
258
- }, se = R(G);
258
+ }, le = T(J);
259
259
  export {
260
- se as default
260
+ le as default
261
261
  };
@@ -2,10 +2,12 @@ import { default as React } from 'react';
2
2
  declare const _default: React.FC<import('react-intl').WithIntlProps<{
3
3
  intl: any;
4
4
  settings: any;
5
+ logoSmallSrc?: string | undefined;
5
6
  }>> & {
6
7
  WrappedComponent: React.ComponentType<{
7
8
  intl: any;
8
9
  settings: any;
10
+ logoSmallSrc?: string | undefined;
9
11
  }>;
10
12
  };
11
13
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devgateway/dvz-ui-react",
3
- "version": "1.7.15",
3
+ "version": "1.8.0",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -20,8 +20,11 @@
20
20
  "react-ui-library",
21
21
  "react-ui-components"
22
22
  ],
23
- "author": "Timothy Mugo",
24
- "license": "MIT",
23
+ "author": "Sebastian Dimunzio <sdimunzio@gmail.com>",
24
+ "contributors": [
25
+ "Timothy Gachengo (https://github.com/timothygachengo)"
26
+ ],
27
+ "license": "Apache-2.0",
25
28
  "description": "A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.",
26
29
  "repository": {
27
30
  "type": "git",