@devgateway/dvz-ui-react 1.1.1 → 1.2.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.
Files changed (34) hide show
  1. package/dist/cjs/embeddable/big-number/index.js +1 -1
  2. package/dist/cjs/embeddable/chart/Bar.js +1 -1
  3. package/dist/cjs/embeddable/chart/index.js +1 -1
  4. package/dist/cjs/embeddable/d3Map/BaseLayer.js +1 -1
  5. package/dist/cjs/embeddable/d3Map/DataLayer.js +1 -1
  6. package/dist/cjs/embeddable/d3Map/FlowLayer.js +1 -1
  7. package/dist/cjs/embeddable/d3Map/ZoomControl.js +1 -1
  8. package/dist/cjs/embeddable/d3Map/index.js +1 -1
  9. package/dist/cjs/embeddable/posts-with-filters/DropDownFilter.js +1 -0
  10. package/dist/cjs/embeddable/posts-with-filters/Post.js +1 -1
  11. package/dist/cjs/embeddable/posts-with-filters/index.js +1 -1
  12. package/dist/cjs/embeddable/reducers/data-api.js +1 -1
  13. package/dist/cjs/layout/containers/SlugPostContainer.js +1 -1
  14. package/dist/cjs/styles.css +1 -1
  15. package/dist/esm/embeddable/big-number/index.js +92 -85
  16. package/dist/esm/embeddable/chart/Bar.js +128 -123
  17. package/dist/esm/embeddable/chart/index.js +229 -225
  18. package/dist/esm/embeddable/d3Map/BaseLayer.js +40 -27
  19. package/dist/esm/embeddable/d3Map/DataLayer.js +196 -204
  20. package/dist/esm/embeddable/d3Map/FlowLayer.js +104 -101
  21. package/dist/esm/embeddable/d3Map/ZoomControl.js +64 -54
  22. package/dist/esm/embeddable/d3Map/index.js +110 -99
  23. package/dist/esm/embeddable/posts-with-filters/DropDownFilter.js +25 -0
  24. package/dist/esm/embeddable/posts-with-filters/Post.js +49 -24
  25. package/dist/esm/embeddable/posts-with-filters/index.js +120 -119
  26. package/dist/esm/embeddable/reducers/data-api.js +13 -11
  27. package/dist/esm/layout/containers/SlugPostContainer.js +3 -3
  28. package/dist/esm/styles.css +1 -1
  29. package/dist/types/embeddable/chart/Bar.d.ts +2 -0
  30. package/dist/types/embeddable/d3Map/BaseLayer.d.ts +1 -0
  31. package/dist/types/embeddable/d3Map/ZoomControl.d.ts +2 -1
  32. package/dist/types/embeddable/posts-with-filters/DropDownFilter.d.ts +4 -0
  33. package/dist/types/embeddable/posts-with-filters/Post.d.ts +4 -2
  34. package/package.json +4 -2
@@ -1,9 +1,9 @@
1
- import { jsx as F } from "react/jsx-runtime";
1
+ import { jsx as L } from "react/jsx-runtime";
2
2
  import "react";
3
3
  import q from "./BaseLayer.js";
4
4
  import G from "../data/DataProvider.js";
5
5
  import H from "../data/DataConsumer.js";
6
- import * as O from "d3";
6
+ import * as P from "d3";
7
7
  import { injectIntl as X } from "react-intl";
8
8
  import K from "papaparse";
9
9
  import Q from "./BreaksStyles.js";
@@ -11,64 +11,64 @@ class Z extends q {
11
11
  constructor() {
12
12
  super(), this.createDataLayer = this.createDataLayer.bind(this);
13
13
  }
14
- createDataLayer(i) {
14
+ createDataLayer(r) {
15
15
  const {
16
16
  format: s,
17
17
  path: a,
18
- tooltip: v,
19
- markFillColor: y,
20
- markBorderColor: k,
21
- markSizeScale: L,
18
+ tooltip: k,
19
+ markFillColor: n,
20
+ markBorderColor: g,
21
+ markSizeScale: F,
22
22
  //circle size
23
- featureJoinAttribute: m,
23
+ featureJoinAttribute: d,
24
24
  apiJoinAttribute: A,
25
- projection: w,
25
+ projection: b,
26
26
  breaks: C,
27
- markSizeScale2: x,
27
+ markSizeScale2: w,
28
28
  //arrow size
29
29
  measures: u,
30
- zoom: g,
31
- offsetPixels: n = 10,
32
- waitForFilters: V
33
- } = this.props, E = u[0], D = new Q({
30
+ zoom: v,
31
+ offsetPixels: l = 10,
32
+ waitForFilters: N
33
+ } = this.props, E = u[0], x = new Q({
34
34
  breaks: C,
35
- defaultFillColor: y,
36
- defaultBorderColor: k,
37
- defaultSize: x
35
+ defaultFillColor: n,
36
+ defaultBorderColor: g,
37
+ defaultSize: w
38
38
  });
39
39
  s.style === "compacted" || s.style, s.style, s.currency, parseInt(s.minimumFractionDigits), parseInt(s.maximumFractionDigits);
40
- const P = i.features.filter((t) => t.properties._value != null);
41
- this.g = O.select(this.gRef.current), this.g.attr("class", "base-layer"), this.props.transform && this.g.attr("transform", this.props.transform), this.g.selectAll(".flow-line").remove(), this.g.selectAll(".start-point").remove(), this.g.selectAll(".end-point").remove(), this.g.select("defs").selectAll("*").remove();
42
- const I = this.props.transform ? this.props.transform.k : 1, b = [];
43
- P.forEach((t) => {
44
- b.push(t), t.properties.destinations.sort((l, e) => l[E] - e[E]).forEach((l) => {
45
- const e = l[E];
46
- i.features.filter((r) => r.properties[m] == l.value).forEach((r) => {
47
- r.properties.meta = l;
48
- const p = t.properties[m], o = t.properties[m] + "--" + r.properties[m], d = a.centroid(t), f = a.centroid(r), _ = f[0] - d[0], T = f[1] - d[1], B = Math.sqrt(_ * _ + T * T), M = _ / B, N = T / B, R = [
49
- f[0] - M * n,
50
- f[1] - N * n
51
- ], U = w.invert(R), W = {
40
+ const _ = r.features.filter((t) => t.properties._value != null);
41
+ this.g = P.select(this.gRef.current), this.g.attr("class", "base-layer zoomable"), this.props.transform && this.g.attr("transform", this.props.transform), this.g.selectAll(".flow-line").remove(), this.g.selectAll(".start-point").remove(), this.g.selectAll(".end-point").remove(), this.g.select("defs").selectAll("*").remove();
42
+ const J = this.props.transform ? this.props.transform.k : 1, S = [];
43
+ _.forEach((t) => {
44
+ S.push(t), t.properties.destinations.sort((p, e) => p[E] - e[E]).forEach((p) => {
45
+ const e = p[E];
46
+ r.features.filter((o) => o.properties[d] == p.value).forEach((o) => {
47
+ o.properties.meta = p;
48
+ const c = t.properties[d], i = t.properties[d] + "--" + o.properties[d], f = a.centroid(t), h = a.centroid(o), O = h[0] - f[0], T = h[1] - f[1], I = Math.sqrt(O * O + T * T), V = O / I, M = T / I, R = [
49
+ h[0] - V * l,
50
+ h[1] - M * l
51
+ ], U = b.invert(R), W = {
52
52
  type: "LineString",
53
53
  coordinates: [
54
- w.invert(d),
54
+ b.invert(f),
55
55
  // Start in geo coords
56
56
  U
57
57
  // New endpoint before d2
58
58
  ]
59
- }, c = this.g.append("g");
60
- this.g.select("defs").append("marker").attr("id", "arrow" + o).attr("markerUnits", "strokeWidth").attr("markerWidth", "6").attr("markerHeight", "6").attr("viewBox", "0 0 24 24").attr("refX", "6").attr("refY", "6").attr("orient", "auto").append("path").attr("d", "M2,2 L10,6 L2,10 L6,6 L2,2").attr("d", "M2,2 L10,6 L2,10 L6,6 L2,2").attr("style", (S) => "fill: " + D.getColor(e) + ";"), c.append("path").attr("d", a(W)).attr("id", o).attr("class", "flow-line").style("fill", "none").style("cursor", "pointer").style("stroke-dasharray", "0").style("stroke", (S) => D.getColor(e)).style("stroke-width", (S) => D.getSize(e)).attr("marker-end", "url(#arrow" + o + ")").on("mouseenter", (S, tt) => {
61
- if (c.selectAll("marker").transition().duration("200").style("opacity", 0), c.selectAll(".start-point").transition().duration("200").style("opacity", 0), c.selectAll(".flow-line").transition().duration("200").style("opacity", 0), O.select(S.target).transition().duration("200").style("opacity", 1), c.selectAll("#arrow" + o).transition().duration("200").style("opacity", 1), c.selectAll(".start-point.circle_" + p).transition().duration("200").style("opacity", 1), e) {
62
- const J = {}, j = {};
63
- Object.keys(t.properties).forEach((h) => {
64
- J["origin_" + h] = t.properties[h];
65
- }), Object.keys(r.properties).forEach((h) => {
66
- j["target_" + h] = r.properties[h];
67
- }), Object.keys(r.properties.meta).forEach((h) => {
68
- j["target_" + h] = r.properties.meta[h];
59
+ }, m = this.g.append("g");
60
+ this.g.select("defs").append("marker").attr("id", "arrow" + i).attr("markerUnits", "strokeWidth").attr("markerWidth", "6").attr("markerHeight", "6").attr("viewBox", "0 0 24 24").attr("refX", "6").attr("refY", "6").attr("orient", "auto").append("path").attr("d", "M2,2 L10,6 L2,10 L6,6 L2,2").attr("d", "M2,2 L10,6 L2,10 L6,6 L2,2").attr("style", (D) => "fill: " + x.getColor(e) + ";"), m.append("path").attr("d", a(W)).attr("id", i).attr("class", "flow-line").style("fill", "none").style("cursor", "pointer").style("stroke-dasharray", "0").style("stroke", (D) => x.getColor(e)).style("stroke-width", (D) => x.getSize(e)).attr("marker-end", "url(#arrow" + i + ")").on("mouseenter", (D, tt) => {
61
+ if (m.selectAll("marker").transition().duration("200").style("opacity", 0), m.selectAll(".start-point").transition().duration("200").style("opacity", 0), m.selectAll(".flow-line").transition().duration("200").style("opacity", 0), P.select(D.target).transition().duration("200").style("opacity", 1), m.selectAll("#arrow" + i).transition().duration("200").style("opacity", 1), m.selectAll(".start-point.circle_" + c).transition().duration("200").style("opacity", 1), e) {
62
+ const B = {}, j = {};
63
+ Object.keys(t.properties).forEach((y) => {
64
+ B["origin_" + y] = t.properties[y];
65
+ }), Object.keys(o.properties).forEach((y) => {
66
+ j["target_" + y] = o.properties[y];
67
+ }), Object.keys(o.properties.meta).forEach((y) => {
68
+ j["target_" + y] = o.properties.meta[y];
69
69
  });
70
70
  const Y = {
71
- ...J,
71
+ ...B,
72
72
  ...j,
73
73
  meta: {
74
74
  [A]: t.properties.meta ? t.properties.meta.value : "",
@@ -76,106 +76,109 @@ class Z extends q {
76
76
  value: e
77
77
  }
78
78
  };
79
- this.showToolTip(v, Y, D.getColor(r.properties._value));
79
+ this.showToolTip(k, Y, x.getColor(o.properties._value));
80
80
  }
81
- }).on("mouseout", (S) => {
82
- this.hiddenToolTip(), O.selectAll(".flow-line").transition().duration("100").style("opacity", 1), c.selectAll(".start-point").transition().duration("100").style("opacity", 1), c.selectAll("marker").transition().duration("100").style("opacity", 1);
83
- }), c.append("text").append("textPath").attr("xlink:href", o).style("text-anchor", "middle").attr("startOffset", "50%").attr("fill", "#fff").text("Yay, my text is on a wavy path");
81
+ }).on("mouseout", (D) => {
82
+ this.hiddenToolTip(), P.selectAll(".flow-line").transition().duration("100").style("opacity", 1), m.selectAll(".start-point").transition().duration("100").style("opacity", 1), m.selectAll("marker").transition().duration("100").style("opacity", 1);
83
+ }), m.append("text").append("textPath").attr("xlink:href", i).style("text-anchor", "middle").attr("startOffset", "50%").attr("fill", "#fff").text("Yay, my text is on a wavy path");
84
84
  });
85
85
  });
86
- }), b.forEach((t) => {
87
- this.g.append("circle").attr("fill", y).attr("stroke", k).attr("class", "start-point circle_" + t.properties[m]).attr("stroke-width", 2).style("vector-effect", "non-scaling-stroke").attr("cx", a.centroid(t)[0]).attr("cy", a.centroid(t)[1]).attr("r", () => L * 1 / I).on("mouseenter", (l) => {
86
+ }), S.forEach((t) => {
87
+ this.g.append("circle").attr("fill", n).attr("stroke", g).attr("class", "start-point circle_" + t.properties[d]).attr("stroke-width", 2).style("vector-effect", "non-scaling-stroke").attr("cx", a.centroid(t)[0]).attr("cy", a.centroid(t)[1]).attr("r", () => F * 1 / J).on("mouseenter", (p) => {
88
88
  this.showToolTip("{name_en}", t.properties, "");
89
- }).on("mouseout", (l) => {
89
+ }).on("mouseout", (p) => {
90
90
  this.hiddenToolTip();
91
91
  });
92
92
  });
93
93
  }
94
94
  create() {
95
95
  const {
96
- app: i,
96
+ app: r,
97
97
  name: s,
98
98
  file: a,
99
- path: v,
100
- csv: y,
101
- zoom: k,
102
- labelFilter: L = [],
103
- labelField: m,
99
+ path: k,
100
+ csv: n,
101
+ zoom: g,
102
+ labelFilter: F = [],
103
+ labelField: d,
104
104
  labelFontSize: A,
105
- labelColor: w,
105
+ labelColor: b,
106
106
  fillColor: C,
107
- borderColor: x,
107
+ borderColor: w,
108
108
  featureJoinAttribute: u,
109
- editing: g,
110
- data: n,
111
- breaks: V,
109
+ editing: v,
110
+ data: l,
111
+ breaks: N,
112
112
  markFillColor: E,
113
- markSizeScale: D,
114
- measures: P,
115
- flowValuesFrom: I
113
+ markSizeScale: x,
114
+ measures: _,
115
+ flowValuesFrom: J
116
116
  } = this.props;
117
- a != "none" && this.loadJSON(a).then((b) => {
118
- const t = b.features.map((e) => {
119
- const r = e.properties[u];
120
- if (i != "csv" && n && n.children) {
121
- const p = n.children.filter((o) => o.value.indexOf(r) > -1);
122
- if (p.length > 0) {
123
- const o = p[0][P[0]];
124
- e.properties.meta = p[0], e.properties._value = o, e.properties.destinations = p[0].children;
117
+ a != "none" && this.loadJSON(a).then((S) => {
118
+ const t = S.features.map((e) => {
119
+ const o = e.properties[u];
120
+ if (r != "csv" && l && l.children) {
121
+ const c = l.children.filter((i) => i.value.indexOf(o) > -1);
122
+ if (c.length > 0) {
123
+ const i = c[0][_[0]];
124
+ e.properties.meta = c[0], e.properties._value = i, e.properties.destinations = c[0].children;
125
125
  }
126
- } else if (i == "csv") {
127
- const p = K.parse(y, { header: !0, dynamicTyping: !0 }), o = e.properties[u];
128
- p.data.filter((f) => f.origin == o);
129
- const d = p.data.filter((f) => f.origin == o)[0];
130
- d != null && (alert("CSV Not implemented Yet, please do it if you have time"), e.properties.meta = d, e.properties._value = d.value, e.properties.destinations = d.destination);
126
+ } else if (r == "csv") {
127
+ const c = K.parse(n, { header: !0, dynamicTyping: !0 }), i = e.properties[u];
128
+ c.data.filter((h) => h.origin == i);
129
+ const f = c.data.filter((h) => h.origin == i)[0];
130
+ f != null && (alert("CSV Not implemented Yet, please do it if you have time"), e.properties.meta = f, e.properties._value = f.value, e.properties.destinations = f.destination);
131
131
  }
132
132
  return e;
133
- }), l = { ...b, features: t };
134
- this.createDataLayer(l);
133
+ }), p = { ...S, features: t };
134
+ this.createDataLayer(p);
135
135
  });
136
136
  }
137
- componentDidUpdate(i, s, a) {
138
- const { projection: v } = this.props;
139
- this.create();
137
+ componentDidUpdate(r, s, a) {
138
+ const { projection: k, editing: n, data: g } = this.props;
139
+ if ((n || JSON.stringify(r.data) !== JSON.stringify(g)) && this.create(), r.visible != this.props.visible) {
140
+ debugger;
141
+ this.g.style("display", this.props.visible ? "" : "none");
142
+ }
140
143
  }
141
144
  componentDidMount() {
142
145
  this.create(), this.props.zoom.current.fullView();
143
146
  }
144
147
  render() {
145
- const { id: i } = this.props;
146
- return /* @__PURE__ */ F("g", { id: "data-" + i, className: "data " + i, ref: this.gRef, children: /* @__PURE__ */ F("defs", {}) });
148
+ const { id: r } = this.props;
149
+ return /* @__PURE__ */ L("g", { id: "data-" + r, className: "data " + r, ref: this.gRef, children: /* @__PURE__ */ L("defs", {}) });
147
150
  }
148
151
  }
149
152
  const $ = (z) => {
150
153
  const {
151
- id: i,
154
+ id: r,
152
155
  unique: s,
153
156
  filters: a,
154
- csv: v,
155
- app: y,
156
- group: k = "default",
157
- flowOrigin: L,
158
- editing: m,
157
+ csv: k,
158
+ app: n,
159
+ group: g = "default",
160
+ flowOrigin: F,
161
+ editing: d,
159
162
  flowDestination: A,
160
- dvzProxyDatasetId: w,
163
+ dvzProxyDatasetId: b,
161
164
  waitForFilters: C
162
- } = z, x = { dvzProxyDatasetId: w }, u = a || {};
163
- return u && u.forEach && u.forEach((g) => {
164
- g.value != null && g.value.filter((n) => n != null && n.toString().trim() != "").length > 0 && (x[g.param] = g.value);
165
- }), /* @__PURE__ */ F(
165
+ } = z, w = { dvzProxyDatasetId: b }, u = a || {};
166
+ return u && u.forEach && u.forEach((v) => {
167
+ v.value != null && v.value.filter((l) => l != null && l.toString().trim() != "").length > 0 && (w[v.param] = v.value);
168
+ }), /* @__PURE__ */ L(
166
169
  G,
167
170
  {
168
- editing: m,
169
- params: x,
171
+ editing: d,
172
+ params: w,
170
173
  waitForFilters: C,
171
- app: y,
172
- csv: decodeURIComponent(v),
173
- group: k,
174
+ app: n,
175
+ csv: decodeURIComponent(k),
176
+ group: g,
174
177
  ignoreErrors: !0,
175
178
  isSvg: !0,
176
- store: [y, s, i],
177
- source: L + "/" + A,
178
- children: /* @__PURE__ */ F(H, { children: /* @__PURE__ */ F(Z, { ...z }) })
179
+ store: [n, s, r],
180
+ source: F + "/" + A,
181
+ children: /* @__PURE__ */ L(H, { children: /* @__PURE__ */ L(Z, { ...z }) })
179
182
  }
180
183
  );
181
184
  }, pt = X($);
@@ -1,50 +1,61 @@
1
- import { jsx as l, jsxs as x } from "react/jsx-runtime";
1
+ import { jsx as n, jsxs as I } from "react/jsx-runtime";
2
2
  import y from "react";
3
- import * as m from "d3";
4
- import { Icon as b, Popup as I } from "semantic-ui-react";
5
- import { FormattedMessage as k } from "react-intl";
6
- class O extends y.Component {
3
+ import * as f from "d3";
4
+ import { Icon as b, Popup as k } from "semantic-ui-react";
5
+ import { FormattedMessage as N } from "react-intl";
6
+ class T extends y.Component {
7
7
  constructor(t) {
8
- super(t), this.zoomRef = y.createRef(), this.lastInternalZoom = null, this.lastUserTransform = null, this.zoomed = this.zoomed.bind(this), this.zoomEnd = this.zoomEnd.bind(this), this.zoomIn = this.zoomIn.bind(this), this.zoomOut = this.zoomOut.bind(this), this.reset = this.reset.bind(this), this.fullView = this.fullView.bind(this), this.transition2fullView = this.transition2fullView.bind(this), this._fullView = this._fullView.bind(this), this.zoom = m.zoom().scaleExtent([0.1, 300]).on("zoom", this.zoomed).on("end", this.zoomEnd);
8
+ super(t), this.zoomRef = y.createRef(), this.lastInternalZoom = null, this.lastUserTransform = null, this.zoomed = this.zoomed.bind(this), this.zoomEnd = this.zoomEnd.bind(this), this.zoomIn = this.zoomIn.bind(this), this.zoomOut = this.zoomOut.bind(this), this.reset = this.reset.bind(this), this.fullView = this.fullView.bind(this), this.transition2fullView = this.transition2fullView.bind(this), this._fullView = this._fullView.bind(this), this.initialized = !1, this.zoom = f.zoom().scaleExtent([0.1, 300]).on("zoom", this.zoomed).on("end", this.zoomEnd);
9
9
  }
10
10
  componentDidMount() {
11
- const { zoomEnabled: t = !0 } = this.props, o = this.getSelection();
12
- o && (this.fullView(), t && (this.props.editing || (o.on("dblclick.zoom", null), o.on("dblclick", (i) => {
13
- i.preventDefault(), console.log("double click event"), o.transition().duration(250).call(this.zoom.scaleBy, 1.5);
14
- }), o.on("wheel.zoom", null), o.on("wheel", (i) => {
15
- console.log("wheel event", i.deltaY, i.deltaX, i.deltaZ), i.preventDefault();
16
- const s = i.deltaY > 0 ? 1 / 1.5 : 1.5;
17
- o.transition().duration(250).call(this.zoom.scaleBy, s);
18
- }), o.call(this.zoom))));
11
+ const { zoomEnabled: t = !0 } = this.props, i = this.getSelection();
12
+ this._fullView(!1), t && (this.props.editing || (i.on("dblclick.zoom", null), i.on("dblclick", (o) => {
13
+ o.preventDefault(), i.transition().duration(250).call(this.zoom.scaleBy, 1.5);
14
+ }), i.on("wheel.zoom", null), i.on("wheel", (o) => {
15
+ o.preventDefault();
16
+ const s = o.deltaY > 0 ? 1 / 1.5 : 1.5;
17
+ i.transition().duration(250).call(this.zoom.scaleBy, s);
18
+ }), i.call(this.zoom))), this.fullView();
19
19
  }
20
20
  componentDidUpdate(t) {
21
- const o = this.getSelection(), { zoomEnabled: i, initialPosition: s, readyState: c, height: d, width: a, selectedPoint: n, projection: h } = this.props, r = JSON.stringify(t.initialPosition) !== JSON.stringify(s);
22
- if (t.zoomEnabled !== i || r)
23
- if (i && o) {
21
+ const i = this.getSelection(), {
22
+ zoomEnabled: o,
23
+ initialPosition: s,
24
+ readyState: c,
25
+ height: d,
26
+ width: h,
27
+ selectedPoint: e,
28
+ projection: m,
29
+ editing: a
30
+ } = this.props;
31
+ !this.initialized && this.props.readyToZoom && (this.fullView(), this.initialized = !0);
32
+ const l = JSON.stringify(t.initialPosition) !== JSON.stringify(s);
33
+ if (t.zoomEnabled !== o || l)
34
+ if (o && i || a) {
24
35
  if (s && this.lastInternalZoom) {
25
- const e = (V, S = 3) => Number(V.toFixed(S)), { x: f, y: p, k: u } = s, { x: z, y: g, k: w } = this.lastInternalZoom;
26
- if (Math.abs(e(f) - e(z)) < 1 && Math.abs(e(p) - e(g)) < 1 && Math.abs(e(u) - e(w)) < 1e-3) {
36
+ const r = (S, x = 3) => Number(S.toFixed(x)), { x: p, y: u, k: z } = s, { x: g, y: w, k: V } = this.lastInternalZoom;
37
+ if (Math.abs(r(p) - r(g)) < 1 && Math.abs(r(u) - r(w)) < 1 && Math.abs(r(z) - r(V)) < 1e-3) {
27
38
  this.lastInternalZoom = null;
28
39
  return;
29
40
  }
30
41
  }
31
- o.call(this.zoom).on(".zoom", this.zoom), this.transition2fullView();
32
- } else o && o.on(".zoom", null);
33
- !t.readyState && c && this.fullView(), (t.height !== d || t.width !== a) && this.fullView(), n != t.selectedPoint && n && this.zoomTo(h([n.y, n.x]));
42
+ i.call(this.zoom).on(".zoom", this.zoom), this.transition2fullView();
43
+ } else i && i.on(".zoom", null);
44
+ !t.readyState && c && this.fullView(), (t.height !== d || t.width !== h) && this.fullView(), e != t.selectedPoint && e && this.zoomTo(m([e.y, e.x]));
34
45
  }
35
46
  zoomed(t) {
36
- var i, s;
37
- const o = this.getSelection();
38
- o && (o.selectAll("g.zoomable").attr("transform", t.transform), (s = (i = this.props).onZoomed) == null || s.call(i, t.transform), this.props.editing && t.sourceEvent && (this.lastUserTransform = t.transform));
47
+ var o, s;
48
+ const i = this.getSelection();
49
+ i && (i.selectAll("g.zoomable").attr("transform", t.transform), (s = (o = this.props).onZoomed) == null || s.call(o, t.transform), this.props.editing && t.sourceEvent && (this.lastUserTransform = t.transform));
39
50
  }
40
51
  zoomEnd(t) {
41
- var n, h;
42
- const { identifier: o, editing: i, width: s, height: c, postMessageOrigin: d = "*" } = this.props, a = this.lastUserTransform || t.transform;
43
- if (this.lastUserTransform = null, (h = (n = this.props).onZoomed) == null || h.call(n, a), i) {
44
- const r = (g, w = 3) => Number(g.toFixed(w)), { x: e, y: f, k: p } = a, u = { x: r(e), y: r(f), k: r(p) };
52
+ var e, m;
53
+ const { identifier: i, editing: o, width: s, height: c, postMessageOrigin: d = "*" } = this.props, h = this.lastUserTransform || t.transform;
54
+ if (this.lastUserTransform = null, (m = (e = this.props).onZoomed) == null || m.call(e, h), o) {
55
+ const a = (g, w = 3) => Number(g.toFixed(w)), { x: l, y: r, k: p } = h, u = { x: a(l), y: a(r), k: a(p) };
45
56
  this.lastInternalZoom = u;
46
57
  const z = {
47
- type: `d3_map_${o}`,
58
+ type: `d3_map_${i}`,
48
59
  value: {
49
60
  ...u,
50
61
  width: s,
@@ -57,36 +68,35 @@ class O extends y.Component {
57
68
  zoomIn() {
58
69
  const t = this.getSelection();
59
70
  if (t) {
60
- const o = this.props.editing ? 0 : this.props.transitionDuration || 500;
61
- t.transition().duration(o).call(this.zoom.scaleBy, 2);
71
+ const i = this.props.editing ? 0 : this.props.transitionDuration || 500;
72
+ t.transition().duration(i).call(this.zoom.scaleBy, 2);
62
73
  }
63
74
  }
64
75
  zoomTo(t) {
65
- const o = m.zoomIdentity.translate(this.props.width / 2, this.props.height / 2).scale(200).translate(-t[0], -t[1]), i = this.getSelection();
66
- this.props.editing || this.props.transitionDuration, i.transition().duration(750).call(this.zoom.transform, o);
76
+ const i = f.zoomIdentity.translate(this.props.width / 2, this.props.height / 2).scale(200).translate(-t[0], -t[1]), o = this.getSelection();
77
+ this.props.editing || this.props.transitionDuration, o.transition().duration(750).call(this.zoom.transform, i);
67
78
  }
68
79
  zoomOut() {
69
80
  const t = this.getSelection();
70
81
  if (t) {
71
- const o = this.props.editing ? 0 : this.props.transitionDuration || 500;
72
- t.transition().duration(o).call(this.zoom.scaleBy, 0.5);
82
+ const i = this.props.editing ? 0 : this.props.transitionDuration || 500;
83
+ t.transition().duration(i).call(this.zoom.scaleBy, 0.5);
73
84
  }
74
85
  }
75
86
  reset() {
76
87
  const t = this.getSelection();
77
- t && (this.props.editing ? t.call(this.zoom.transform, m.zoomIdentity.translate(0, 0).scale(1)) : this.transition2fullView());
88
+ t && (this.props.editing ? t.call(this.zoom.transform, f.zoomIdentity.translate(0, 0).scale(1)) : this.transition2fullView());
78
89
  }
79
90
  getSelection() {
80
- var t;
81
- return (t = this.props.svgRef) != null && t.current ? m.select(this.props.svgRef.current) : this.zoomRef.current ? m.select(this.zoomRef.current.parentNode.querySelector("svg")) : null;
91
+ return f.select(this.zoomRef.current.parentNode.querySelector("svg"));
82
92
  }
83
93
  _fullView(t = !0) {
84
- const { initialPosition: o, width: i, height: s, transform: c } = this.props;
85
- if (!o) return;
86
- const { x: d = 100, y: a = 23, k: n = 1, width: h, height: r } = o;
87
- if (!h || !r || !n) return;
88
- const e = this.getSelection();
89
- e && e.transition().duration(t ? 750 : 0).attr("transform", c).call(this.zoom.transform, m.zoomIdentity.translate(d, a).scale(n));
94
+ const { initialPosition: i, width: o, height: s, transform: c } = this.props;
95
+ if (!i) return;
96
+ const { x: d = 100, y: h = 23, k: e = 1, width: m, height: a } = i;
97
+ if (!m || !a || !e) return;
98
+ const l = this.getSelection();
99
+ l && (console.log("SVG parent client sizes:", l.node().parentNode.clientWidth, l.node().parentNode.clientHeight), l.transition().duration(t ? 750 : 0).attr("transform", c).call(this.zoom.transform, f.zoomIdentity.translate(d, h).scale(e)));
90
100
  }
91
101
  transition2fullView() {
92
102
  this._fullView(!0);
@@ -95,20 +105,20 @@ class O extends y.Component {
95
105
  this._fullView(!1);
96
106
  }
97
107
  render() {
98
- const { editing: t, zoomEnabled: o = !0 } = this.props;
99
- return /* @__PURE__ */ l("div", { ref: this.zoomRef, className: `zoom ${o ? "" : "disabled"}`, children: (t || o) && /* @__PURE__ */ x("div", { children: [
100
- /* @__PURE__ */ l("div", { className: "button plus", onClick: this.zoomIn, children: /* @__PURE__ */ l(b, { name: "plus", size: "small" }) }),
101
- /* @__PURE__ */ l("div", { className: "button minus", onClick: this.zoomOut, children: /* @__PURE__ */ l(b, { name: "minus", size: "small" }) }),
102
- /* @__PURE__ */ l(
103
- I,
108
+ const { editing: t, zoomEnabled: i = !0 } = this.props;
109
+ return /* @__PURE__ */ n("div", { ref: this.zoomRef, className: `zoom ${i ? "" : "disabled"}`, children: (t || i) && /* @__PURE__ */ I("div", { children: [
110
+ /* @__PURE__ */ n("div", { className: "button plus", onClick: this.zoomIn, children: /* @__PURE__ */ n(b, { name: "plus", size: "small" }) }),
111
+ /* @__PURE__ */ n("div", { className: "button minus", onClick: this.zoomOut, children: /* @__PURE__ */ n(b, { name: "minus", size: "small" }) }),
112
+ /* @__PURE__ */ n(
113
+ k,
104
114
  {
105
- content: /* @__PURE__ */ l(k, { id: "map.reset.tooltip", defaultMessage: "Reset zoom" }),
106
- trigger: /* @__PURE__ */ l("div", { className: "button reset", onClick: this.reset, children: /* @__PURE__ */ l(b, { name: "repeat", size: "small" }) })
115
+ content: /* @__PURE__ */ n(N, { id: "map.reset.tooltip", defaultMessage: "Reset zoom" }),
116
+ trigger: /* @__PURE__ */ n("div", { className: "button reset", onClick: this.reset, children: /* @__PURE__ */ n(b, { name: "repeat", size: "small" }) })
107
117
  }
108
118
  )
109
119
  ] }) });
110
120
  }
111
121
  }
112
122
  export {
113
- O as default
123
+ T as default
114
124
  };