geostyler 18.2.0 → 18.3.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,4 +1,4 @@
1
- import { jsx as s, jsxs as r } from "react/jsx-runtime";
1
+ import { jsx as s, jsxs as l } from "react/jsx-runtime";
2
2
  import { useRef as de, useState as p, useMemo as me, useEffect as C, useCallback as pe } from "react";
3
3
  import { useMonaco as fe, Editor as ue } from "@monaco-editor/react";
4
4
  import { saveAs as ge } from "file-saver";
@@ -12,34 +12,34 @@ import { SldStyleParser as J } from "geostyler-sld-parser";
12
12
  import { SLDUnitsSelect as ve } from "../Symbolizer/SLDUnitsSelect/SLDUnitsSelect.js";
13
13
  import { usePrevious as B } from "../../hook/UsePrevious.js";
14
14
  import { ParserFeedback as H } from "../ParserFeedback/ParserFeedback.js";
15
- import { QGISStyleParser as ke } from "geostyler-qgis-parser";
16
15
  import { MapboxStyleParser as I } from "geostyler-mapbox-parser";
17
- import { useGeoStylerLocale as Fe } from "../../context/GeoStylerContext/GeoStylerContext.js";
18
- const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
16
+ import { useGeoStylerLocale as ke } from "../../context/GeoStylerContext/GeoStylerContext.js";
17
+ import { QGISStyleParser as Fe } from "geostyler-qgis-parser";
18
+ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (r) => {
19
19
  let c = {
20
20
  extension: ".txt",
21
21
  language: "plaintext",
22
22
  mimeType: "text/plain"
23
23
  };
24
- return m instanceof J ? c = {
24
+ return r && r.title === J.title ? c = {
25
25
  extension: ".sld",
26
26
  language: "xml",
27
27
  mimeType: "text/xml"
28
- } : m instanceof ke ? c = {
28
+ } : r && r.title === Fe.title ? c = {
29
29
  extension: ".qml",
30
30
  language: "xml",
31
31
  mimeType: "text/xml"
32
- } : m instanceof I ? c = {
32
+ } : r && r.title === I.title ? c = {
33
33
  extension: ".json",
34
34
  language: "json",
35
35
  mimeType: "application/json"
36
- } : m === void 0 && (c = {
36
+ } : r === void 0 && (c = {
37
37
  extension: ".json",
38
38
  language: "json",
39
39
  mimeType: "application/json"
40
40
  }), c;
41
41
  }, Ve = ({
42
- defaultParser: m,
42
+ defaultParser: r,
43
43
  delay: c = 500,
44
44
  onStyleChange: v = () => {
45
45
  },
@@ -49,9 +49,9 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
49
49
  showUploadButton: W = !1,
50
50
  showCopyButton: q = !1,
51
51
  showSaveButton: _ = !1,
52
- style: l
52
+ style: d
53
53
  }) => {
54
- const d = Fe("CodeEditor"), F = de(void 0), [o, z] = p(m), [g, f] = p(""), [n, N] = p(), [a, h] = p(), [T, Q] = p(!1), [K, X] = p(!1), w = B(l), j = B(o), b = fe(), Y = me(() => u(o).extension, [o]);
54
+ const m = ke("CodeEditor"), F = de(void 0), [o, z] = p(r), [g, f] = p(""), [n, N] = p(), [i, h] = p(), [T, Q] = p(!1), [K, X] = p(!1), w = B(d), j = B(o), b = fe(), Y = me(() => u(o).extension, [o]);
55
55
  C(() => {
56
56
  if (n != null && n.output) {
57
57
  const t = u(o);
@@ -78,16 +78,16 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
78
78
  }
79
79
  }, [o]);
80
80
  if (C(() => {
81
- (!P(w, l) || !P(j, o)) && y(l);
82
- }, [o, l, y, w, j]), K)
81
+ (!P(w, d) || !P(j, o)) && y(d);
82
+ }, [o, d, y, w, j]), K)
83
83
  return /* @__PURE__ */ s("h1", { children: "An error occurred in the CodeEditor UI." });
84
84
  const E = async (t) => {
85
85
  f(t), h(void 0);
86
86
  try {
87
87
  let e;
88
88
  if (o) {
89
- let i;
90
- o instanceof I ? i = await o.readStyle(JSON.parse(t)) : i = await o.readStyle(t), h(i), v(i.output);
89
+ let a;
90
+ o instanceof I ? a = await o.readStyle(JSON.parse(t)) : a = await o.readStyle(t), h(a), v(a.output);
91
91
  } else
92
92
  e = JSON.parse(t), v(e);
93
93
  } catch (e) {
@@ -96,12 +96,12 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
96
96
  });
97
97
  }
98
98
  }, Z = (t) => {
99
- const e = k.find((i) => i.title === t);
99
+ const e = k.find((a) => a.title === t);
100
100
  V(e), z(e);
101
101
  }, R = (t) => {
102
102
  if (o) {
103
103
  const e = o;
104
- e.symbolizerUnits = t, y(l);
104
+ e.symbolizerUnits = t, y(d);
105
105
  }
106
106
  }, ee = (t) => {
107
107
  clearTimeout(F.current), F.current = window.setTimeout(
@@ -122,30 +122,30 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
122
122
  const te = (t) => {
123
123
  const e = new FileReader();
124
124
  e.onload = () => {
125
- const i = e.result;
126
- E(i);
125
+ const a = e.result;
126
+ E(a);
127
127
  }, e.readAsText(t.fileList[0].originFileObj);
128
128
  }, ne = () => {
129
- if (l) {
129
+ if (d) {
130
130
  const t = u(o);
131
- let e = l.name;
131
+ let e = d.name;
132
132
  e += t.extension;
133
- const i = `${t.mimeType};charset=utf-8`, le = new Blob([g], { type: i });
134
- ge(le, e);
133
+ const a = `${t.mimeType};charset=utf-8`, ce = new Blob([g], { type: a });
134
+ ge(ce, e);
135
135
  }
136
136
  }, se = (t) => {
137
137
  const e = document.createElement("textarea");
138
138
  e.value = t, e.setAttribute("readonly", ""), e.style.position = "absolute", e.style.left = "-9999px", document.body.appendChild(e);
139
- const i = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : !1;
140
- e.select(), document.execCommand("copy"), document.body.removeChild(e), Ce.info(d.styleCopied), i && (document.getSelection().removeAllRanges(), document.getSelection().addRange(i));
141
- }, ae = () => {
139
+ const a = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : !1;
140
+ e.select(), document.execCommand("copy"), document.body.removeChild(e), Ce.info(m.styleCopied), a && (document.getSelection().removeAllRanges(), document.getSelection().addRange(a));
141
+ }, ie = () => {
142
142
  se(g);
143
143
  }, O = () => {
144
144
  Q(!T);
145
- }, ie = o && o instanceof J && o.sldVersion !== "1.0.0", A = (n == null ? void 0 : n.errors) || (n == null ? void 0 : n.warnings) || (n == null ? void 0 : n.unsupportedProperties), L = (a == null ? void 0 : a.errors) || (a == null ? void 0 : a.warnings) || (a == null ? void 0 : a.unsupportedProperties), U = (n == null ? void 0 : n.errors) || (a == null ? void 0 : a.errors), re = L || A && !U, ce = T ? "feedback-visible" : "feedback-hidden";
146
- return /* @__PURE__ */ r("div", { className: "gs-code-editor", children: [
147
- /* @__PURE__ */ r("div", { className: "gs-code-editor-toolbar", children: [
148
- d.formatSelectLabel,
145
+ }, ae = o && o instanceof J && o.sldVersion !== "1.0.0", A = (n == null ? void 0 : n.errors) || (n == null ? void 0 : n.warnings) || (n == null ? void 0 : n.unsupportedProperties), L = (i == null ? void 0 : i.errors) || (i == null ? void 0 : i.warnings) || (i == null ? void 0 : i.unsupportedProperties), U = (n == null ? void 0 : n.errors) || (i == null ? void 0 : i.errors), re = L || A && !U, le = T ? "feedback-visible" : "feedback-hidden";
146
+ return /* @__PURE__ */ l("div", { className: "gs-code-editor", children: [
147
+ /* @__PURE__ */ l("div", { className: "gs-code-editor-toolbar", children: [
148
+ m.formatSelectLabel,
149
149
  ": ",
150
150
  /* @__PURE__ */ s(
151
151
  M,
@@ -156,7 +156,7 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
156
156
  children: x
157
157
  }
158
158
  ),
159
- ie && /* @__PURE__ */ s(ve, { changeHandler: R }),
159
+ ae && /* @__PURE__ */ s(ve, { changeHandler: R }),
160
160
  W && /* @__PURE__ */ s(
161
161
  xe,
162
162
  {
@@ -170,7 +170,7 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
170
170
  className: "gs-code-editor-upload-button",
171
171
  icon: /* @__PURE__ */ s(he, {}),
172
172
  type: "primary",
173
- children: d.uploadButtonLabel
173
+ children: m.uploadButtonLabel
174
174
  }
175
175
  )
176
176
  }
@@ -186,29 +186,29 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
186
186
  onChange: ee
187
187
  }
188
188
  ),
189
- /* @__PURE__ */ r("div", { className: `gs-code-editor-feedback ${ce}`, children: [
190
- A && /* @__PURE__ */ r("div", { className: "write-feedback", children: [
191
- /* @__PURE__ */ s("span", { children: `${d.writeFeedback} ${o == null ? void 0 : o.title}` }),
189
+ /* @__PURE__ */ l("div", { className: `gs-code-editor-feedback ${le}`, children: [
190
+ A && /* @__PURE__ */ l("div", { className: "write-feedback", children: [
191
+ /* @__PURE__ */ s("span", { children: `${m.writeFeedback} ${o == null ? void 0 : o.title}` }),
192
192
  /* @__PURE__ */ s(H, { feedback: n })
193
193
  ] }),
194
- L && /* @__PURE__ */ r("div", { className: "read-feedback", children: [
195
- /* @__PURE__ */ s("span", { children: `${d.readFeedback} ${o == null ? void 0 : o.title}` }),
196
- /* @__PURE__ */ s(H, { feedback: a })
194
+ L && /* @__PURE__ */ l("div", { className: "read-feedback", children: [
195
+ /* @__PURE__ */ s("span", { children: `${m.readFeedback} ${o == null ? void 0 : o.title}` }),
196
+ /* @__PURE__ */ s(H, { feedback: i })
197
197
  ] })
198
198
  ] }),
199
- /* @__PURE__ */ r("div", { className: "gs-code-editor-bottombar", children: [
200
- /* @__PURE__ */ r("div", { className: "left-items", children: [
199
+ /* @__PURE__ */ l("div", { className: "gs-code-editor-bottombar", children: [
200
+ /* @__PURE__ */ l("div", { className: "left-items", children: [
201
201
  U && /* @__PURE__ */ s(be, { twoToneColor: "#ff4d4f", onClick: O }),
202
202
  re && /* @__PURE__ */ s(ye, { twoToneColor: "#faad14", onClick: O })
203
203
  ] }),
204
- /* @__PURE__ */ r("div", { className: "center-items", children: [
204
+ /* @__PURE__ */ l("div", { className: "center-items", children: [
205
205
  q && /* @__PURE__ */ s(
206
206
  S,
207
207
  {
208
208
  className: "gs-code-editor-copy-button",
209
209
  type: "primary",
210
- onClick: ae,
211
- children: d.copyButtonLabel
210
+ onClick: ie,
211
+ children: m.copyButtonLabel
212
212
  }
213
213
  ),
214
214
  _ && /* @__PURE__ */ s(
@@ -217,7 +217,7 @@ const $ = M.Option, G = "geostyler.json", Ne = D.$id, u = (m) => {
217
217
  className: "gs-code-editor-download-button",
218
218
  type: "primary",
219
219
  onClick: ne,
220
- children: d.downloadButtonLabel
220
+ children: m.downloadButtonLabel
221
221
  }
222
222
  )
223
223
  ] }),
@@ -1,61 +1,65 @@
1
- import { jsx as t, jsxs as p, Fragment as S } from "react/jsx-runtime";
2
- import { useState as j } from "react";
1
+ import { jsx as t, jsxs as e, Fragment as I } from "react/jsx-runtime";
2
+ import { useState as S, useEffect as j } from "react";
3
3
  import { Slider as k, InputNumber as b, Button as N } from "antd";
4
4
  import { FunctionUI as w } from "../../FunctionUI/FunctionUI.js";
5
- import { isGeoStylerFunction as x } from "geostyler-style";
6
- import { FunctionOutlined as e } from "@ant-design/icons";
5
+ import { isGeoStylerFunction as l } from "geostyler-style";
6
+ import { FunctionOutlined as x } from "@ant-design/icons";
7
7
  /* empty css */
8
- const q = ({
9
- slider: y = !1,
10
- sliderProps: l = {},
8
+ const z = ({
9
+ slider: V = !1,
10
+ sliderProps: f = {},
11
11
  /* more safety */
12
12
  onChange: r,
13
- onCancel: u,
14
- value: m,
13
+ onCancel: p,
14
+ value: i,
15
15
  className: d,
16
- inputProps: F = {},
16
+ inputProps: y = {},
17
17
  /* more safety */
18
- functionUiProps: I
18
+ functionUiProps: F
19
19
  }) => {
20
- let s = "number-expression-input";
21
- d && (s += ` ${d}`);
22
- const [f, c] = j(() => x(m) ? void 0 : m);
23
- return x(m) ? /* @__PURE__ */ t("span", { className: s, children: /* @__PURE__ */ t(
20
+ let u = "number-expression-input";
21
+ d && (u += ` ${d}`);
22
+ const [o, c] = S(() => l(i) ? void 0 : i);
23
+ return j(() => {
24
+ l(i) || c(i);
25
+ }, [i]), l(i) ? /* @__PURE__ */ t("span", { className: u, children: /* @__PURE__ */ t(
24
26
  w,
25
27
  {
26
28
  type: "number",
27
- value: m,
28
- ...I,
29
+ value: i,
30
+ ...F,
29
31
  onChange: r,
30
- onCancel: () => u == null ? void 0 : u("number")
32
+ onCancel: () => p == null ? void 0 : p("number")
31
33
  }
32
- ) }) : /* @__PURE__ */ t("span", { className: s, children: y ? /* @__PURE__ */ p("div", { className: "slider-wrapper", children: [
34
+ ) }) : /* @__PURE__ */ t("span", { className: u, children: V ? /* @__PURE__ */ e("div", { className: "slider-wrapper", children: [
33
35
  /* @__PURE__ */ t(
34
36
  k,
35
37
  {
36
- ...l,
37
- value: f,
38
+ ...f,
39
+ value: o,
38
40
  range: !1,
39
- onChange: (i) => {
40
- i === null && (r == null || r(void 0)), r == null || r(i), c(i === null ? void 0 : i);
41
+ onChange: (s) => {
42
+ const m = s === null ? void 0 : Number(s);
43
+ r == null || r(m), c(m);
41
44
  }
42
45
  }
43
46
  ),
44
- /* @__PURE__ */ p("div", { className: "number-wrapper", children: [
47
+ /* @__PURE__ */ e("div", { className: "number-wrapper", children: [
45
48
  /* @__PURE__ */ t(
46
49
  b,
47
50
  {
48
- ...l,
49
- value: f,
50
- onChange: (i) => {
51
- i === null && (r == null || r(void 0)), r == null || r(Number(i)), c(i === null ? void 0 : Number(i));
51
+ ...f,
52
+ value: o,
53
+ onChange: (s) => {
54
+ const m = s === null ? void 0 : Number(s);
55
+ r == null || r(m), c(m);
52
56
  }
53
57
  }
54
58
  ),
55
59
  /* @__PURE__ */ t(
56
60
  N,
57
61
  {
58
- icon: /* @__PURE__ */ t(e, {}),
62
+ icon: /* @__PURE__ */ t(x, {}),
59
63
  onClick: () => {
60
64
  r == null || r({
61
65
  name: "property",
@@ -65,21 +69,22 @@ const q = ({
65
69
  }
66
70
  )
67
71
  ] })
68
- ] }) : /* @__PURE__ */ p(S, { children: [
72
+ ] }) : /* @__PURE__ */ e(I, { children: [
69
73
  /* @__PURE__ */ t(
70
74
  b,
71
75
  {
72
- value: m,
73
- onChange: (i) => {
74
- i === null && (r == null || r(void 0)), r == null || r(i);
76
+ value: i,
77
+ onChange: (s) => {
78
+ const m = s === null ? void 0 : Number(s);
79
+ r == null || r(m);
75
80
  },
76
- ...F
81
+ ...y
77
82
  }
78
83
  ),
79
84
  /* @__PURE__ */ t(
80
85
  N,
81
86
  {
82
- icon: /* @__PURE__ */ t(e, {}),
87
+ icon: /* @__PURE__ */ t(x, {}),
83
88
  onClick: () => {
84
89
  r == null || r({
85
90
  name: "property",
@@ -91,6 +96,6 @@ const q = ({
91
96
  ] }) });
92
97
  };
93
98
  export {
94
- q as NumberExpressionInput,
95
- q as default
99
+ z as NumberExpressionInput,
100
+ z as default
96
101
  };
@@ -0,0 +1,14 @@
1
+ import { default as React } from 'react';
2
+ import { Expression, PlacementType, TextSymbolizer } from 'geostyler-style';
3
+ import { StringExpressionSelectProps } from '../../../ExpressionInput/StringExpressionSelect/StringExpressionSelect';
4
+ export interface PlacementFieldProps {
5
+ placementOptions?: PlacementType[];
6
+ onChange?: (placement: TextSymbolizer['placement'] | Expression<string>) => void;
7
+ value?: TextSymbolizer['placement'] | Expression<string>;
8
+ }
9
+ type SelectProps = StringExpressionSelectProps['selectProps'];
10
+ /**
11
+ * PlacementField to select between different placement options
12
+ */
13
+ export declare const PlacementField: React.FC<PlacementFieldProps & SelectProps>;
14
+ export {};
@@ -0,0 +1,33 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { StringExpressionSelect as a } from "../../../ExpressionInput/StringExpressionSelect/StringExpressionSelect.js";
3
+ import { useGeoStylerLocale as m } from "../../../../context/GeoStylerContext/GeoStylerContext.js";
4
+ const u = ({
5
+ onChange: o,
6
+ value: l,
7
+ placementOptions: t = ["point", "line", "line-center"],
8
+ ...n
9
+ }) => {
10
+ const i = m("PlacementField"), r = t.map((e) => ({
11
+ label: i.placementOptions[e],
12
+ value: e
13
+ }));
14
+ function c() {
15
+ o(void 0);
16
+ }
17
+ return /* @__PURE__ */ s(
18
+ a,
19
+ {
20
+ className: "editor-field placement-field",
21
+ value: l,
22
+ onChange: (e) => o(e),
23
+ onCancel: c,
24
+ selectProps: {
25
+ ...n,
26
+ options: r
27
+ }
28
+ }
29
+ );
30
+ };
31
+ export {
32
+ u as PlacementField
33
+ };
@@ -0,0 +1,13 @@
1
+ import { default as React } from 'react';
2
+ import { NumberExpressionInputProps } from '../../../ExpressionInput/NumberExpressionInput/NumberExpressionInput';
3
+ import { Expression } from 'geostyler-style';
4
+ type InputProps = NumberExpressionInputProps['inputProps'];
5
+ export interface RepeatFieldProps extends InputProps {
6
+ value?: Expression<number>;
7
+ onChange?: (newValue: Expression<number> | undefined) => void;
8
+ }
9
+ /**
10
+ * RepeatField
11
+ */
12
+ export declare const RepeatField: React.FC<RepeatFieldProps>;
13
+ export {};
@@ -0,0 +1,27 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { NumberExpressionInput as r } from "../../../ExpressionInput/NumberExpressionInput/NumberExpressionInput.js";
3
+ const f = ({
4
+ onChange: t,
5
+ value: i,
6
+ ...e
7
+ }) => {
8
+ function l() {
9
+ t(e.defaultValue ? Number(e.defaultValue) : void 0);
10
+ }
11
+ return /* @__PURE__ */ o(
12
+ r,
13
+ {
14
+ className: "editor-field repeat-field",
15
+ value: i,
16
+ onChange: t,
17
+ onCancel: l,
18
+ inputProps: {
19
+ ...e,
20
+ min: 0
21
+ }
22
+ }
23
+ );
24
+ };
25
+ export {
26
+ f as RepeatField
27
+ };
@@ -9,6 +9,8 @@ import { RotateFieldProps } from '../Field/RotateField/RotateField';
9
9
  import { SizeFieldProps } from '../Field/SizeField/SizeField';
10
10
  import { InputConfig } from '../../../context/GeoStylerContext/GeoStylerContext';
11
11
  import { VisibilityFieldProps } from '../Field/VisibilityField/VisibilityField';
12
+ import { RepeatFieldProps } from '../Field/RepeatField/RepeatField';
13
+ import { PlacementFieldProps } from '../Field/PlacementField/PlacementField';
12
14
  export interface TextEditorComposableProps {
13
15
  templateField?: InputConfig<string>;
14
16
  colorField?: InputConfig<ColorFieldProps['value']>;
@@ -23,6 +25,8 @@ export interface TextEditorComposableProps {
23
25
  haloColorField?: InputConfig<ColorFieldProps['value']>;
24
26
  haloWidthField?: InputConfig<WidthFieldProps['value']>;
25
27
  visibilityField?: InputConfig<VisibilityFieldProps['value']>;
28
+ placementField?: InputConfig<PlacementFieldProps['value']>;
29
+ repeatField?: InputConfig<RepeatFieldProps['value']>;
26
30
  }
27
31
  export interface TextEditorInternalProps {
28
32
  symbolizer: TextSymbolizer;