@hybridcore/ui 1.6.19 → 1.6.20

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,119 +1,133 @@
1
- import { jsx as e, jsxs as i, Fragment as f } from "react/jsx-runtime";
2
- import { EditOutlined as C, DeleteOutline as A, AddLocationOutlined as G, DrawOutlined as b, LayersOutlined as p } from "@mui/icons-material";
3
- import { Coordinate as D } from "./coordinate/index.js";
4
- import { Edit as P } from "./edit/index.js";
5
- import { Geometry as S } from "./geometry/index.js";
6
- import { Kml as O } from "./kml/index.js";
7
- import { Wkt as I } from "./wkt/index.js";
8
- import { useGeometryPickerLogic as E } from "./logic.js";
9
- import { GeometryPickerEndAdornment as M, GeometryPickerEndAdornmentButton as y, GeometryPickerRoot as x, GeometryPickerTopLabel as T, GeometryPickerContainer as g, GeometryPickerActions as L, GeometryPickerActionButton as c, GeometryPickerFormControl as W, GeometryPickerInputLabel as K, GeometryPickerInputStandard as v, GeometryPickerInputOutlined as w, GeometryPickerInputFilled as z, GeometryPickerDialog as B, GeometryPickerDialogTitle as R, GeometryPickerDialogContent as F } from "./styled.js";
10
- const X = (s) => {
11
- const { label: r, mapboxAccessToken: d, value: n = "", defaultExtent: u } = s, { refs: h, state: t, actions: o } = E(s), { ownerState: k, variant: l, labelPosition: a } = t, m = /* @__PURE__ */ e(M, { position: "end", children: n !== "" && /* @__PURE__ */ i(f, { children: [
12
- /* @__PURE__ */ e(y, { size: "small", onClick: o.onEdit, children: /* @__PURE__ */ e(C, { fontSize: "small" }) }),
13
- /* @__PURE__ */ e(y, { size: "small", onClick: o.onDelete, children: /* @__PURE__ */ e(A, { fontSize: "small" }) })
14
- ] }) });
15
- return /* @__PURE__ */ i(x, { ref: h.rootRef, sx: t.sx, children: [
16
- a === "top" && r !== void 0 && /* @__PURE__ */ e(T, { children: r }),
17
- /* @__PURE__ */ i(g, { children: [
18
- /* @__PURE__ */ i(L, { ownerState: k, children: [
19
- k.disableAddCoordinate === !1 && /* @__PURE__ */ e(
20
- c,
21
- {
22
- color: "inherit",
23
- startIcon: /* @__PURE__ */ e(G, {}),
24
- onClick: o.onAddCoordinate,
25
- children: "Add Coordinate"
26
- }
27
- ),
28
- /* @__PURE__ */ e(
29
- c,
30
- {
31
- color: "inherit",
32
- startIcon: /* @__PURE__ */ e(b, {}),
33
- onClick: o.onDraw,
34
- children: "Draw"
35
- }
36
- ),
37
- /* @__PURE__ */ e(
38
- c,
39
- {
40
- color: "inherit",
41
- startIcon: /* @__PURE__ */ e(p, {}),
42
- onClick: o.onAddKml,
43
- children: "Add KML"
44
- }
45
- ),
46
- /* @__PURE__ */ e(
47
- c,
48
- {
49
- color: "inherit",
50
- startIcon: /* @__PURE__ */ e(p, {}),
51
- onClick: o.onAddWkt,
52
- children: "Add WKT"
53
- }
54
- )
55
- ] }),
56
- /* @__PURE__ */ i(
57
- W,
1
+ import { jsx as e, jsxs as n, Fragment as G } from "react/jsx-runtime";
2
+ import { ContentCopyOutlined as b, EditOutlined as A, DeleteOutline as P, AddLocationOutlined as D, DrawOutlined as O, LayersOutlined as h } from "@mui/icons-material";
3
+ import { Tooltip as p } from "@mui/material";
4
+ import { Coordinate as S } from "./coordinate/index.js";
5
+ import { Edit as E } from "./edit/index.js";
6
+ import { Geometry as I } from "./geometry/index.js";
7
+ import { Kml as T } from "./kml/index.js";
8
+ import { Wkt as M } from "./wkt/index.js";
9
+ import { useGeometryPickerLogic as x } from "./logic.js";
10
+ import { GeometryPickerEndAdornment as g, GeometryPickerEndAdornmentButton as u, GeometryPickerActions as L, GeometryPickerActionButton as d, GeometryPickerRoot as W, GeometryPickerHeader as z, GeometryPickerTopLabel as K, GeometryPickerContainer as v, GeometryPickerFormControl as R, GeometryPickerInputLabel as w, GeometryPickerInputStandard as B, GeometryPickerInputOutlined as F, GeometryPickerInputFilled as j, GeometryPickerDialog as N, GeometryPickerDialogTitle as H, GeometryPickerDialogContent as Y } from "./styled.js";
11
+ const oe = (y) => {
12
+ const { label: r, mapboxAccessToken: a, value: i = "", defaultExtent: k } = y, { refs: f, state: t, actions: o } = x(y), { ownerState: m, variant: l, labelPosition: c } = t, s = /* @__PURE__ */ e(g, { position: "end", children: i !== "" && /* @__PURE__ */ n(G, { children: [
13
+ /* @__PURE__ */ e(
14
+ p,
15
+ {
16
+ title: t.copied ? "Copied to clipboard" : "Copy",
17
+ open: t.copyTooltipOpen,
18
+ onOpen: o.openCopyTooltip,
19
+ onClose: o.closeCopyTooltip,
20
+ children: /* @__PURE__ */ e(u, { size: "small", onClick: o.onCopy, children: /* @__PURE__ */ e(b, { fontSize: "small" }) })
21
+ }
22
+ ),
23
+ /* @__PURE__ */ e(p, { title: "Edit", children: /* @__PURE__ */ e(u, { size: "small", onClick: o.onEdit, children: /* @__PURE__ */ e(A, { fontSize: "small" }) }) }),
24
+ /* @__PURE__ */ e(p, { title: "Remove", children: /* @__PURE__ */ e(u, { size: "small", onClick: o.onDelete, children: /* @__PURE__ */ e(P, { fontSize: "small" }) }) })
25
+ ] }) }), C = /* @__PURE__ */ n(L, { ownerState: m, children: [
26
+ m.disableAddCoordinate === !1 && /* @__PURE__ */ e(
27
+ d,
28
+ {
29
+ color: "inherit",
30
+ startIcon: /* @__PURE__ */ e(D, {}),
31
+ onClick: o.onAddCoordinate,
32
+ children: "Add Coordinate"
33
+ }
34
+ ),
35
+ /* @__PURE__ */ e(
36
+ d,
37
+ {
38
+ color: "inherit",
39
+ startIcon: /* @__PURE__ */ e(O, {}),
40
+ onClick: o.onDraw,
41
+ children: "Draw"
42
+ }
43
+ ),
44
+ /* @__PURE__ */ e(
45
+ d,
46
+ {
47
+ color: "inherit",
48
+ startIcon: /* @__PURE__ */ e(h, {}),
49
+ onClick: o.onAddKml,
50
+ children: "Add KML"
51
+ }
52
+ ),
53
+ /* @__PURE__ */ e(
54
+ d,
55
+ {
56
+ color: "inherit",
57
+ startIcon: /* @__PURE__ */ e(h, {}),
58
+ onClick: o.onAddWkt,
59
+ children: "Add WKT"
60
+ }
61
+ )
62
+ ] });
63
+ return /* @__PURE__ */ n(W, { ref: f.rootRef, sx: t.sx, children: [
64
+ c === "top" && /* @__PURE__ */ n(z, { children: [
65
+ r !== void 0 && /* @__PURE__ */ e(K, { children: r }),
66
+ C
67
+ ] }),
68
+ /* @__PURE__ */ n(v, { ownerState: m, children: [
69
+ c !== "top" && C,
70
+ /* @__PURE__ */ n(
71
+ R,
58
72
  {
59
73
  fullWidth: !0,
60
74
  variant: l,
61
75
  contentEditable: !1,
62
76
  onClick: o.onClick,
63
77
  children: [
64
- a === "default" && /* @__PURE__ */ e(K, { shrink: !!n, children: r }),
65
- l === "standard" && /* @__PURE__ */ e(v, { value: n, readOnly: !0, endAdornment: m }),
78
+ c === "default" && /* @__PURE__ */ e(w, { shrink: !!i, children: r }),
79
+ l === "standard" && /* @__PURE__ */ e(B, { value: i, readOnly: !0, endAdornment: s }),
66
80
  l === "outlined" && /* @__PURE__ */ e(
67
- w,
81
+ F,
68
82
  {
69
- label: a === "default" ? r : void 0,
70
- value: n,
83
+ label: c === "default" ? r : void 0,
84
+ value: i,
71
85
  readOnly: !0,
72
- endAdornment: m
86
+ endAdornment: s
73
87
  }
74
88
  ),
75
- l === "filled" && /* @__PURE__ */ e(z, { value: n, readOnly: !0, endAdornment: m })
89
+ l === "filled" && /* @__PURE__ */ e(j, { value: i, readOnly: !0, endAdornment: s })
76
90
  ]
77
91
  }
78
92
  )
79
93
  ] }),
80
- /* @__PURE__ */ i(
81
- B,
94
+ /* @__PURE__ */ n(
95
+ N,
82
96
  {
83
97
  open: t.modal.isOpen,
84
98
  onClose: o.closeModal,
85
99
  fullWidth: !0,
86
100
  maxWidth: "md",
87
101
  children: [
88
- /* @__PURE__ */ e(R, { children: t.content.title }),
89
- /* @__PURE__ */ i(F, { children: [
102
+ /* @__PURE__ */ e(H, { children: t.content.title }),
103
+ /* @__PURE__ */ n(Y, { children: [
90
104
  t.content.action === "ADD" && t.content.type === "COORDINATE" && /* @__PURE__ */ e(
91
- D,
105
+ S,
92
106
  {
93
- mapboxAccessToken: d,
94
- defaultExtent: u,
107
+ mapboxAccessToken: a,
108
+ defaultExtent: k,
95
109
  onCancel: o.closeModal,
96
110
  onSubmit: o.onSubmit
97
111
  }
98
112
  ),
99
113
  t.content.action === "ADD" && t.content.type === "GEOMETRY" && /* @__PURE__ */ e(
100
- S,
114
+ I,
101
115
  {
102
116
  mapId: "map-geo-picker-001",
103
- mapboxAccessToken: d,
104
- defaultExtent: u,
117
+ mapboxAccessToken: a,
118
+ defaultExtent: k,
105
119
  onCancel: o.closeModal,
106
120
  onSubmit: o.onSubmit
107
121
  }
108
122
  ),
109
- t.content.action === "ADD" && t.content.type === "KML" && /* @__PURE__ */ e(O, { onCancel: o.closeModal, onSubmit: o.onSubmit }),
110
- t.content.action === "ADD" && t.content.type === "WKT" && /* @__PURE__ */ e(I, { onCancel: o.closeModal, onSubmit: o.onSubmit }),
111
- t.content.action === "EDIT" && !!n && /* @__PURE__ */ e(
112
- P,
123
+ t.content.action === "ADD" && t.content.type === "KML" && /* @__PURE__ */ e(T, { onCancel: o.closeModal, onSubmit: o.onSubmit }),
124
+ t.content.action === "ADD" && t.content.type === "WKT" && /* @__PURE__ */ e(M, { onCancel: o.closeModal, onSubmit: o.onSubmit }),
125
+ t.content.action === "EDIT" && !!i && /* @__PURE__ */ e(
126
+ E,
113
127
  {
114
128
  mapId: "map-geo-edit-001",
115
- value: n,
116
- mapboxAccessToken: d,
129
+ value: i,
130
+ mapboxAccessToken: a,
117
131
  onCancel: o.closeModal,
118
132
  onSubmit: o.onSubmit
119
133
  }
@@ -125,5 +139,5 @@ const X = (s) => {
125
139
  ] });
126
140
  };
127
141
  export {
128
- X as GeometryPicker
142
+ oe as GeometryPicker
129
143
  };
@@ -1,62 +1,79 @@
1
- import { useThemeProps as C } from "@mui/material";
2
- import { useRef as P, useState as K } from "react";
3
- import E from "../../hooks/useToggle.js";
4
- const k = (f) => {
5
- const c = C({ props: f, name: "HCGeometryPicker" }), {
6
- value: a = "",
7
- disableAddCoordinate: p = !1,
8
- variant: r = "outlined",
9
- labelPosition: l = "top",
10
- onChange: e
11
- } = c, m = P(null), t = E(!1), [i, n] = K({
1
+ import { useThemeProps as x } from "@mui/material";
2
+ import { useRef as C, useState as p, useEffect as G } from "react";
3
+ import L from "../../hooks/useToggle.js";
4
+ const H = (g) => {
5
+ const l = x({ props: g, name: "HCGeometryPicker" }), {
6
+ value: e = "",
7
+ disableAddCoordinate: f = !1,
8
+ variant: d = "outlined",
9
+ labelPosition: u = "top",
10
+ onChange: s
11
+ } = l, P = C(null), t = L(!1), [m, D] = p(!1), [E, a] = p(!1), i = C(), [c, n] = p({
12
12
  title: "",
13
13
  type: "COORDINATE",
14
14
  action: "ADD"
15
- }), d = () => {
15
+ }), T = () => {
16
16
  n({ title: "Add Coordinate", type: "COORDINATE", action: "ADD" }), t.action.open();
17
- }, A = () => {
17
+ }, K = () => {
18
18
  n({ title: "Add KML", type: "KML", action: "ADD" }), t.action.open();
19
- }, u = () => {
19
+ }, O = () => {
20
20
  n({ title: "Add WKT", type: "WKT", action: "ADD" }), t.action.open();
21
- }, s = (o) => {
21
+ }, r = (o) => {
22
22
  o != null && o.stopPropagation && o.stopPropagation(), n({ title: "Edit", type: "WKT", action: "EDIT" }), t.action.open();
23
- }, D = (o) => {
24
- o != null && o.stopPropagation && o.stopPropagation(), n({ title: "Draw Geometry", type: "GEOMETRY", action: "ADD" }), t.action.open();
25
23
  }, y = (o) => {
26
- t.action.close(), e && e(o), i.action === "ADD" && (i.type === "KML" || i.type === "WKT") && s();
27
- }, T = () => {
28
- a !== void 0 && a !== "" ? s() : p === !1 ? d() : D();
29
- }, g = (o) => {
30
- o.stopPropagation(), e && e("");
24
+ o != null && o.stopPropagation && o.stopPropagation(), n({ title: "Draw Geometry", type: "GEOMETRY", action: "ADD" }), t.action.open();
25
+ }, R = (o) => {
26
+ t.action.close(), s && s(o), c.action === "ADD" && (c.type === "KML" || c.type === "WKT") && r();
27
+ }, w = () => {
28
+ e !== void 0 && e !== "" ? r() : f === !1 ? T() : y();
29
+ }, M = (o) => {
30
+ o.stopPropagation(), s && s("");
31
+ }, W = (o) => {
32
+ var A;
33
+ o != null && o.stopPropagation && o.stopPropagation(), e && ((A = navigator.clipboard) == null || A.writeText(e), D(!0), a(!0), i.current && clearTimeout(i.current), i.current = setTimeout(() => {
34
+ D(!1), a(!1);
35
+ }, 2e3));
36
+ }, b = () => a(!0), k = () => {
37
+ m || a(!1);
31
38
  };
32
- return {
33
- refs: { rootRef: m },
39
+ return G(
40
+ () => () => {
41
+ i.current && clearTimeout(i.current);
42
+ },
43
+ []
44
+ ), {
45
+ refs: { rootRef: P },
34
46
  state: {
35
47
  ownerState: {
36
- variant: r,
37
- labelPosition: l,
38
- hasValue: a !== "",
39
- disableAddCoordinate: p
48
+ variant: d,
49
+ labelPosition: u,
50
+ hasValue: e !== "",
51
+ disableAddCoordinate: f
40
52
  },
41
- content: i,
53
+ content: c,
42
54
  modal: t.state,
43
- variant: r,
44
- labelPosition: l,
45
- sx: c.sx
55
+ variant: d,
56
+ labelPosition: u,
57
+ copied: m,
58
+ copyTooltipOpen: E,
59
+ sx: l.sx
46
60
  },
47
61
  actions: {
48
- onAddCoordinate: d,
49
- onAddKml: A,
50
- onAddWkt: u,
51
- onSubmit: y,
52
- onClick: T,
53
- onDelete: g,
54
- onEdit: s,
55
- onDraw: D,
62
+ onAddCoordinate: T,
63
+ onAddKml: K,
64
+ onAddWkt: O,
65
+ onSubmit: R,
66
+ onClick: w,
67
+ onCopy: W,
68
+ openCopyTooltip: b,
69
+ closeCopyTooltip: k,
70
+ onDelete: M,
71
+ onEdit: r,
72
+ onDraw: y,
56
73
  closeModal: t.action.close
57
74
  }
58
75
  };
59
76
  };
60
77
  export {
61
- k as useGeometryPickerLogic
78
+ H as useGeometryPickerLogic
62
79
  };