@hybridcore/ui 1.4.15 → 1.4.16

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.
@@ -2,8 +2,8 @@ import { jsxs as l, Fragment as p, jsx as o } from "react/jsx-runtime";
2
2
  import { Button as a, Box as f } from "@mui/material";
3
3
  import u from "../map/index.js";
4
4
  import C from "../parser/index.js";
5
- import { g as y, c as g } from "../../../ol-CHaVTXvL.js";
6
- import { useState as h } from "react";
5
+ import { g as y, c as h } from "../../../ol-CHaVTXvL.js";
6
+ import { useState as g } from "react";
7
7
  import { Add as P } from "@mui/icons-material";
8
8
  import { parse as v, convert as x } from "../../map/helpers/wkt.js";
9
9
  import T from "lodash";
@@ -14,7 +14,7 @@ function M({
14
14
  onCancel: m,
15
15
  onSubmit: s
16
16
  }) {
17
- const [t, n] = h(
17
+ const [t, n] = g(
18
18
  r ? y(r) : c
19
19
  );
20
20
  return /* @__PURE__ */ l(p, { children: [
@@ -27,7 +27,7 @@ function M({
27
27
  disableContextMenu: !0,
28
28
  defaultExtent: r,
29
29
  onDrawEnd: (e) => {
30
- const i = g({ features: e });
30
+ const i = h({ features: e });
31
31
  n(i);
32
32
  }
33
33
  }
@@ -54,7 +54,7 @@ function M({
54
54
  }
55
55
  ]
56
56
  };
57
- else if (e.type === "Point")
57
+ else if ((e == null ? void 0 : e.type) === "Point")
58
58
  e = {
59
59
  type: "GeometryCollection",
60
60
  geometries: [
@@ -65,7 +65,7 @@ function M({
65
65
  }
66
66
  ]
67
67
  };
68
- else if (e.type === "GeometryCollection")
68
+ else if ((e == null ? void 0 : e.type) === "GeometryCollection")
69
69
  e.geometries.push({
70
70
  type: "Point",
71
71
  coordinates: [0, 0]
@@ -75,7 +75,7 @@ function M({
75
75
  return;
76
76
  }
77
77
  const i = x(e);
78
- n(i);
78
+ n(i ?? "");
79
79
  },
80
80
  children: "Add Coordinate"
81
81
  }
@@ -1,4 +1,4 @@
1
- import { jsxs as a, jsx as e, Fragment as x } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as r, Fragment as x } from "react/jsx-runtime";
2
2
  import E, { useState as F, useEffect as T } from "react";
3
3
  import { Dialog as w, DialogContent as K, DialogActions as j, Button as c, Box as O } from "@mui/material";
4
4
  import g from "../map/index.js";
@@ -16,53 +16,53 @@ function z({
16
16
  onSubmit: u,
17
17
  onChange: d
18
18
  }) {
19
- const r = E.useRef(null), [t, k] = F(y), m = () => {
20
- u && u(t);
21
- }, p = (n) => {
22
- const o = P({ features: n });
19
+ const t = E.useRef(null), [n, k] = F(y), m = () => {
20
+ u && u(n);
21
+ }, p = (e) => {
22
+ const o = P({ features: e });
23
23
  k(o), d && d(o);
24
24
  }, h = () => {
25
25
  var o, v, C;
26
- const n = S(t);
27
- if (!_.isArray(n))
28
- if (n.type === "Point") {
29
- const i = B(n.coordinates, "EPSG:4326", "EPSG:3857");
30
- (o = r.current) == null || o.setCenter(i), (v = r.current) == null || v.setZoomLevel(10);
26
+ const e = S(n);
27
+ if (!_.isArray(e))
28
+ if ((e == null ? void 0 : e.type) === "Point") {
29
+ const i = B(e.coordinates, "EPSG:4326", "EPSG:3857");
30
+ (o = t.current) == null || o.setCenter(i), (v = t.current) == null || v.setZoomLevel(10);
31
31
  } else {
32
- const i = R(t);
33
- i && ((C = r.current) == null || C.centerToFeature(i[0], [100, 100, 100, 100]));
32
+ const i = R(n);
33
+ i && ((C = t.current) == null || C.centerToFeature(i[0], [100, 100, 100, 100]));
34
34
  }
35
35
  };
36
36
  return T(() => (h(), () => {
37
37
  }), [h]), W === "dialog" ? /* @__PURE__ */ a(w, { open: !0, maxWidth: "sm", fullWidth: !0, onClose: l, children: [
38
- /* @__PURE__ */ e(K, { children: /* @__PURE__ */ e(
38
+ /* @__PURE__ */ r(K, { children: /* @__PURE__ */ r(
39
39
  g,
40
40
  {
41
41
  id: f,
42
- ref: r,
43
- drawingWKTData: t,
42
+ ref: t,
43
+ drawingWKTData: n,
44
44
  mapboxAccessToken: s,
45
45
  onDrawEnd: p
46
46
  }
47
47
  ) }),
48
48
  /* @__PURE__ */ a(j, { children: [
49
- /* @__PURE__ */ e(c, { color: "inherit", variant: "contained", onClick: l, children: "Cancel" }),
50
- /* @__PURE__ */ e(c, { variant: "contained", onClick: m, children: "Ok" })
49
+ /* @__PURE__ */ r(c, { color: "inherit", variant: "contained", onClick: l, children: "Cancel" }),
50
+ /* @__PURE__ */ r(c, { variant: "contained", onClick: m, children: "Ok" })
51
51
  ] })
52
52
  ] }) : /* @__PURE__ */ a(x, { children: [
53
- /* @__PURE__ */ e(
53
+ /* @__PURE__ */ r(
54
54
  g,
55
55
  {
56
56
  id: f,
57
- ref: r,
58
- drawingWKTData: t,
57
+ ref: t,
58
+ drawingWKTData: n,
59
59
  mapboxAccessToken: s,
60
60
  onDrawEnd: p
61
61
  }
62
62
  ),
63
63
  !D && /* @__PURE__ */ a(O, { display: "flex", justifyContent: "space-between", mt: 3, children: [
64
- /* @__PURE__ */ e(c, { color: "primary", onClick: l, children: "Cancel" }),
65
- /* @__PURE__ */ e(c, { color: "primary", variant: "contained", onClick: m, children: "Ok" })
64
+ /* @__PURE__ */ r(c, { color: "primary", onClick: l, children: "Cancel" }),
65
+ /* @__PURE__ */ r(c, { color: "primary", variant: "contained", onClick: m, children: "Ok" })
66
66
  ] })
67
67
  ] });
68
68
  }
@@ -1,17 +1,18 @@
1
- import { jsx as e, Fragment as y, jsxs as o } from "react/jsx-runtime";
1
+ import { jsx as e, Fragment as w, jsxs as o } from "react/jsx-runtime";
2
2
  import { AccordionSummary as c, Box as a, Typography as s, Tooltip as d, IconButton as h, AccordionDetails as p } from "@mui/material";
3
3
  import m from "./coordinate-input/index.js";
4
- import w from "./logic.js";
4
+ import P from "./logic.js";
5
5
  import { GridExpandMoreIcon as f } from "@mui/x-data-grid";
6
6
  import { Accordion as u } from "./styled.js";
7
7
  import { Close as g } from "@mui/icons-material";
8
- import { ConditionalWrapper as P } from "../../conditional-wrapper/index.js";
9
- function M(C) {
10
- const { state: I, action: t } = w(C);
11
- return /* @__PURE__ */ e(y, { children: I.parsed.map((r, n) => {
8
+ import { ConditionalWrapper as z } from "../../conditional-wrapper/index.js";
9
+ function R(C) {
10
+ var I;
11
+ const { state: y, action: t } = P(C);
12
+ return /* @__PURE__ */ e(w, { children: (I = y.parsed) == null ? void 0 : I.map((r, n) => {
12
13
  if (r.type === "Point")
13
14
  return /* @__PURE__ */ e(
14
- P,
15
+ z,
15
16
  {
16
17
  condition: !C.disableGrouping,
17
18
  wrapper: (i) => /* @__PURE__ */ o(u, { defaultExpanded: !0, children: [
@@ -175,5 +176,5 @@ function M(C) {
175
176
  }) });
176
177
  }
177
178
  export {
178
- M as default
179
+ R as default
179
180
  };
@@ -1,80 +1,80 @@
1
1
  import u from "react";
2
2
  import { parse as a, convert as l } from "../../map/helpers/wkt.js";
3
3
  import m from "lodash";
4
- function M({ value: p, onChange: i }) {
5
- const r = u.useMemo(() => {
4
+ function M({ value: p, onChange: s }) {
5
+ const n = u.useMemo(() => {
6
6
  let o = a(p);
7
- return m.isArray(o) || (o = [o]), o;
7
+ return o && !m.isArray(o) && (o = [o]), o;
8
8
  }, [p]);
9
9
  return {
10
10
  state: {
11
- parsed: r
11
+ parsed: n
12
12
  },
13
13
  action: {
14
- onCoordinateInputChange: (o) => (s) => {
15
- if (i) {
14
+ onCoordinateInputChange: (o) => (c) => {
15
+ if (s) {
16
16
  let e;
17
- const t = [...r];
17
+ const t = [...n || []];
18
18
  t[o] = {
19
19
  type: "Point",
20
- coordinates: [s.longitude, s.latitude]
20
+ coordinates: [c.longitude, c.latitude]
21
21
  }, t.length > 1 ? e = l({
22
22
  type: "GeometryCollection",
23
23
  geometries: t
24
- }) : e = l(t[0]), i(e);
24
+ }) : e = l(t[0]), s(e ?? "");
25
25
  }
26
26
  },
27
- onPolygonInputChange: (o, s, e) => (t) => {
28
- if (i) {
29
- const n = [...r], c = [...o[0]];
30
- c[e] = [t.longitude, t.latitude], n[s] = {
27
+ onPolygonInputChange: (o, c, e) => (t) => {
28
+ if (s) {
29
+ const i = [...n || []], r = [...o[0]];
30
+ r[e] = [t.longitude, t.latitude], i[c] = {
31
31
  type: "Polygon",
32
- coordinates: [c]
32
+ coordinates: [r]
33
33
  };
34
34
  const g = l({
35
35
  type: "GeometryCollection",
36
- geometries: n
36
+ geometries: i
37
37
  });
38
- i(g);
38
+ s(g ?? "");
39
39
  }
40
40
  },
41
- onMultiPointInputChange: (o, s, e) => (t) => {
42
- if (i) {
43
- const n = [...r], c = [...o];
44
- c[e] = [t.longitude, t.latitude], n[s] = {
41
+ onMultiPointInputChange: (o, c, e) => (t) => {
42
+ if (s) {
43
+ const i = [...n || []], r = [...o];
44
+ r[e] = [t.longitude, t.latitude], i[c] = {
45
45
  type: "MultiPoint",
46
- coordinates: c
46
+ coordinates: r
47
47
  };
48
48
  const g = l({
49
49
  type: "GeometryCollection",
50
- geometries: n
50
+ geometries: i
51
51
  });
52
- i(g);
52
+ s(g ?? "");
53
53
  }
54
54
  },
55
- onLineStringInputChange: (o, s, e) => (t) => {
56
- if (i) {
57
- const n = [...r], c = [...o];
58
- c[e] = [t.longitude, t.latitude], n[s] = {
55
+ onLineStringInputChange: (o, c, e) => (t) => {
56
+ if (s) {
57
+ const i = [...n || []], r = [...o];
58
+ r[e] = [t.longitude, t.latitude], i[c] = {
59
59
  type: "LineString",
60
- coordinates: c
60
+ coordinates: r
61
61
  };
62
62
  const g = l({
63
63
  type: "GeometryCollection",
64
- geometries: n
64
+ geometries: i
65
65
  });
66
- i(g);
66
+ s(g ?? "");
67
67
  }
68
68
  },
69
- onRemoveItem: (o) => (s) => {
70
- if (s.stopPropagation(), i) {
71
- const e = [...r];
69
+ onRemoveItem: (o) => (c) => {
70
+ if (c.stopPropagation(), s) {
71
+ const e = [...n || []];
72
72
  e.splice(o, 1);
73
- const n = l({
73
+ const i = l({
74
74
  type: "GeometryCollection",
75
75
  geometries: e
76
76
  });
77
- i(n);
77
+ s(i ?? "");
78
78
  }
79
79
  }
80
80
  }
@@ -1,24 +1,32 @@
1
1
  import i from "terraformer-wkt-parser";
2
2
  import * as o from "@turf/turf";
3
3
  const l = (e) => {
4
- if (e.includes("GEOMETRYCOLLECTION")) {
5
- let t = e.replace("GEOMETRYCOLLECTION(", "");
6
- t = t.slice(0, -1);
7
- let n = t.split("),");
8
- return n = n.filter((r) => r !== "").map((r, s) => (s < n.length - 1 && (r += ")"), r)), n.map((r) => i.parse(r));
4
+ try {
5
+ if (e.includes("GEOMETRYCOLLECTION")) {
6
+ let t = e.replace("GEOMETRYCOLLECTION(", "");
7
+ t = t.slice(0, -1);
8
+ let r = t.split("),");
9
+ return r = r.filter((n) => n !== "").map((n, c) => (c < r.length - 1 && (n += ")"), n)), r.map((n) => i.parse(n));
10
+ }
11
+ return i.parse(e);
12
+ } catch {
9
13
  }
10
- return i.parse(e);
11
- }, p = (e) => i.convert(e), u = (e) => {
14
+ }, p = (e) => {
15
+ try {
16
+ return i.convert(e);
17
+ } catch {
18
+ }
19
+ }, u = (e) => {
12
20
  let t = [0, 0];
13
21
  if (e.type === "Point")
14
22
  return t = e.coordinates, t;
15
23
  if (e.type === "Polygon") {
16
- const n = o.polygon(e.coordinates);
17
- return t = o.centerOfMass(n).geometry.coordinates, t;
24
+ const r = o.polygon(e.coordinates);
25
+ return t = o.centerOfMass(r).geometry.coordinates, t;
18
26
  }
19
27
  if (e.type === "LineString") {
20
- const n = o.lineString(e.coordinates);
21
- return t = o.centerOfMass(n).geometry.coordinates, t;
28
+ const r = o.lineString(e.coordinates);
29
+ return t = o.centerOfMass(r).geometry.coordinates, t;
22
30
  }
23
31
  return e.type === "MultiPoint" ? (t = o.multiPoint(e.coordinates).geometry.coordinates[0], t) : (console.log("Undefined geometry type!", e.type), t);
24
32
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.4.15",
4
+ "version": "1.4.16",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",