geostyler 18.4.2 → 18.5.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,100 +1,102 @@
1
1
  import { jsx as r, jsxs as g } from "react/jsx-runtime";
2
- import { useState as p, useRef as _, useEffect as Re } from "react";
3
- import { CqlParser as De } from "geostyler-cql-parser";
4
- import Ee from "lodash-es/get.js";
5
- import Ie from "lodash-es/set.js";
6
- import ze from "lodash-es/cloneDeep.js";
7
- import { Tooltip as k, Table as ve, Button as N, Popover as j, Input as F, Space as Te } from "antd";
2
+ import { useState as y, useRef as j, useEffect as Ie } from "react";
3
+ import { CqlParser as ve } from "geostyler-cql-parser";
4
+ import M from "lodash-es/get.js";
5
+ import ze from "lodash-es/set.js";
6
+ import Te from "lodash-es/cloneDeep.js";
7
+ import { Tooltip as S, Table as ke, Button as O, Popover as P, Input as F, Space as Ne } from "antd";
8
8
  /* empty css */
9
- import { FilterEditorWindow as ke } from "../Filter/FilterEditorWindow/FilterEditorWindow.js";
10
- import { SymbolizerEditorWindow as Ne } from "../Symbolizer/SymbolizerEditorWindow/SymbolizerEditorWindow.js";
11
- import Oe from "../../Util/FilterUtil.js";
12
- import M from "../../Util/DataUtil.js";
13
- import { BgColorsOutlined as Ve, BlockOutlined as qe, EditOutlined as P, CopyOutlined as Ke, CloseOutlined as Ue } from "@ant-design/icons";
14
- import { Renderer as Le } from "../Renderer/Renderer/Renderer.js";
15
- import { useGeoStylerData as Be, useGeoStylerComposition as H, useGeoStylerLocale as We } from "../../context/GeoStylerContext/GeoStylerContext.js";
16
- import { DndContext as Ge, closestCenter as _e } from "@dnd-kit/core";
17
- import { useDragDropSensors as je } from "../../hook/UseDragDropSensors.js";
18
- import { SortableContext as Fe, verticalListSortingStrategy as Me, arrayMove as O } from "@dnd-kit/sortable";
19
- import { DraggableRow as Pe } from "../DraggableTableRow/DraggableTablerow.js";
20
- import { InputScaleDenominator as He } from "../ScaleDenominator/InputScaleDenominator.js";
21
- import { SelectScaleDenominator as Je } from "../ScaleDenominator/SelectScaleDenominator.js";
22
- const yt = (J) => {
23
- var L, B;
24
- const s = Be(), V = s == null ? void 0 : s.scaleDenominators, Q = H("Rule"), X = H("Style"), Y = { ...J, ...Q }, {
25
- amountField: S,
9
+ import { FilterEditorWindow as Oe } from "../Filter/FilterEditorWindow/FilterEditorWindow.js";
10
+ import { SymbolizerEditorWindow as Ve } from "../Symbolizer/SymbolizerEditorWindow/SymbolizerEditorWindow.js";
11
+ import qe from "../../Util/FilterUtil.js";
12
+ import H from "../../Util/DataUtil.js";
13
+ import { BgColorsOutlined as Ke, BlockOutlined as Ue, EditOutlined as J, CopyOutlined as Le, CloseOutlined as Be } from "@ant-design/icons";
14
+ import { Renderer as We } from "../Renderer/Renderer/Renderer.js";
15
+ import { useGeoStylerData as Ge, useGeoStylerComposition as Q, useGeoStylerLocale as _e } from "../../context/GeoStylerContext/GeoStylerContext.js";
16
+ import { DndContext as je, closestCenter as Me } from "@dnd-kit/core";
17
+ import { useDragDropSensors as Pe } from "../../hook/UseDragDropSensors.js";
18
+ import { SortableContext as Fe, verticalListSortingStrategy as He, arrayMove as V } from "@dnd-kit/sortable";
19
+ import { DraggableRow as Je } from "../DraggableTableRow/DraggableTablerow.js";
20
+ import { InputScaleDenominator as Qe } from "../ScaleDenominator/InputScaleDenominator.js";
21
+ import { SelectScaleDenominator as Xe } from "../ScaleDenominator/SelectScaleDenominator.js";
22
+ import { ElseRuleField as Ye } from "../Symbolizer/Field/ElseRuleField/ElseRuleField.js";
23
+ const gt = (X) => {
24
+ var B, W;
25
+ const c = Ge(), q = c == null ? void 0 : c.scaleDenominators, Y = Q("Rule"), Z = Q("Style"), $ = { ...X, ...Y }, {
26
+ amountField: R,
26
27
  duplicateField: x,
27
28
  filterField: w,
28
- scalesField: R,
29
- nameField: D,
29
+ scalesField: D,
30
+ nameField: E,
30
31
  /** show actions column by default if disableMultiEdit is true */
31
- actionsField: y = {
32
- visibility: X.disableMultiEdit === !0
32
+ actionsField: h = {
33
+ visibility: Z.disableMultiEdit === !0
33
34
  },
34
- onRulesChange: E,
35
- rendererType: Z = "OpenLayers",
36
- rules: i,
37
- onCloneRule: I,
38
- onRemoveRule: z,
35
+ elseRuleField: I,
36
+ onRulesChange: v,
37
+ rendererType: A = "OpenLayers",
38
+ rules: l,
39
+ onCloneRule: z,
40
+ onRemoveRule: T,
39
41
  // The composableProps include the antd table props
40
42
  ...a
41
- } = Y, c = We("RuleTable"), [b, q] = p(), [$, v] = p(), [A, T] = p(), [ee, te] = p(), [re, ne] = p(), [oe, ie] = p(), K = () => i.map(() => crypto.randomUUID()), m = _(K()), le = je(), { current: se } = _(new De());
42
- Re(() => {
43
+ } = $, s = _e("RuleTable"), [b, K] = y(), [ee, k] = y(), [te, N] = y(), [re, ne] = y(), [oe, le] = y(), [ie, se] = y(), U = () => l.map(() => crypto.randomUUID()), m = j(U()), ce = Pe(), { current: ae } = j(new ve());
44
+ Ie(() => {
43
45
  let e = {};
44
46
  try {
45
- s && M.isVector(s) ? e = Oe.calculateCountAndDuplicates(i, s) : e = {};
47
+ c && H.isVector(c) ? e = qe.calculateCountAndDuplicates(l, c) : e = {};
46
48
  } catch {
47
- te(!0);
49
+ ne(!0);
48
50
  }
49
- ne(e == null ? void 0 : e.counts), ie(e == null ? void 0 : e.duplicates);
50
- }, [i, s]), m.current.length < i.length && (m.current = K());
51
- const C = i == null ? void 0 : i.map((e, n) => ({
51
+ le(e == null ? void 0 : e.counts), se(e == null ? void 0 : e.duplicates);
52
+ }, [l, c]), m.current.length < l.length && (m.current = U());
53
+ const C = l == null ? void 0 : l.map((e, n) => ({
52
54
  ...e,
53
55
  key: m.current[n]
54
- })), ce = (e) => {
55
- q(e), v(!0), T(!1);
56
- }, ae = (e, n, o) => {
56
+ })), me = (e) => {
57
+ K(e), k(!0), N(!1);
58
+ }, ue = (e, n, o) => {
57
59
  const t = () => {
58
- ce(o);
60
+ me(o);
59
61
  };
60
62
  return /* @__PURE__ */ g("div", { className: "gs-symbolizer-wrapper", children: [
61
63
  /* @__PURE__ */ r(
62
- Le,
64
+ We,
63
65
  {
64
- rendererType: Z,
66
+ rendererType: A,
65
67
  symbolizers: n.symbolizers
66
68
  }
67
69
  ),
68
70
  /* @__PURE__ */ r(
69
- N,
71
+ O,
70
72
  {
71
73
  className: "square-button",
72
74
  type: "primary",
73
- icon: /* @__PURE__ */ r(P, {}),
75
+ icon: /* @__PURE__ */ r(J, {}),
74
76
  onClick: t
75
77
  }
76
78
  )
77
79
  ] });
78
- }, me = (e, n, o) => /* @__PURE__ */ r(
79
- j,
80
+ }, de = (e, n, o) => /* @__PURE__ */ r(
81
+ P,
80
82
  {
81
83
  content: n.name,
82
- title: c.nameColumnTitle,
84
+ title: s.nameColumnTitle,
83
85
  children: /* @__PURE__ */ r(
84
86
  F,
85
87
  {
86
88
  value: n.name,
87
89
  name: "name-renderer",
88
90
  onChange: (t) => {
89
- const l = t.target;
90
- h(o, "name", l.value);
91
+ const i = t.target;
92
+ p(o, "name", i.value);
91
93
  }
92
94
  }
93
95
  )
94
96
  }
95
- ), ue = (e, n, o) => {
96
- const t = se.write(n.filter);
97
- let l;
97
+ ), fe = (e, n, o) => {
98
+ const t = ae.write(n.filter);
99
+ let i;
98
100
  const d = /* @__PURE__ */ r(
99
101
  F.Search,
100
102
  {
@@ -103,148 +105,167 @@ const yt = (J) => {
103
105
  value: t,
104
106
  onChange: () => {
105
107
  },
106
- enterButton: /* @__PURE__ */ r(P, {}),
108
+ enterButton: /* @__PURE__ */ r(J, {}),
107
109
  onSearch: () => {
108
- de(o);
110
+ pe(o);
109
111
  }
110
112
  }
111
113
  );
112
- return t && t.length > 0 ? l = /* @__PURE__ */ r(
113
- j,
114
+ return t && t.length > 0 ? i = /* @__PURE__ */ r(
115
+ P,
114
116
  {
115
117
  content: t,
116
- title: c.filterColumnTitle,
118
+ title: s.filterColumnTitle,
117
119
  children: d
118
120
  }
119
- ) : l = d, l;
120
- }, de = (e) => {
121
- q(e), v(!1), T(!0);
122
- }, fe = (e, n, o) => {
123
- const t = Ee(n, "scaleDenominator");
124
- return V ? /* @__PURE__ */ r(
125
- Je,
121
+ ) : i = d, i;
122
+ }, pe = (e) => {
123
+ K(e), k(!1), N(!0);
124
+ }, ye = (e, n, o) => {
125
+ const t = M(n, "scaleDenominator");
126
+ return q ? /* @__PURE__ */ r(
127
+ Xe,
126
128
  {
127
- scaleDenominators: V,
129
+ scaleDenominators: q,
128
130
  scaleDenominator: t,
129
- onChange: (l) => {
130
- h(o, "scaleDenominator", l);
131
+ onChange: (i) => {
132
+ p(o, "scaleDenominator", i);
131
133
  }
132
134
  }
133
- ) : /* @__PURE__ */ r(He, { scaleDenominator: t, onChange: (l) => {
134
- h(o, "scaleDenominator", l);
135
+ ) : /* @__PURE__ */ r(Qe, { scaleDenominator: t, onChange: (i) => {
136
+ p(o, "scaleDenominator", i);
135
137
  } });
136
- }, pe = (e, n, o) => {
138
+ }, he = (e, n, o) => {
139
+ const t = M(n, "elseRule");
140
+ return /* @__PURE__ */ r(
141
+ "div",
142
+ {
143
+ className: "gs-rule-table-else-rule-renderer",
144
+ children: /* @__PURE__ */ r(
145
+ Ye,
146
+ {
147
+ value: t === void 0 ? !1 : t,
148
+ onChange: (i) => {
149
+ p(o, "elseRule", i);
150
+ }
151
+ }
152
+ )
153
+ }
154
+ );
155
+ }, be = (e, n, o) => {
137
156
  let t = "-";
138
- const l = n.filter;
139
- if (s && l)
157
+ if (c && H.isVector(c))
140
158
  try {
141
- t = re[o] || 0;
159
+ t = oe[o] || 0;
142
160
  } catch {
143
161
  t = "-";
144
162
  }
145
- else s && M.isVector(s) && (t = s.exampleFeatures.features.length);
146
163
  return /* @__PURE__ */ r("div", { className: "ant-input gs-rule-table-numeric-cell amount-renderer", children: t });
147
- }, ye = (e, n, o) => {
164
+ }, Ce = (e, n, o) => {
148
165
  let t = "-";
149
- if (s && i)
166
+ if (c && l)
150
167
  try {
151
- t = oe[o];
168
+ t = ie[o];
152
169
  } catch {
153
170
  t = "-";
154
171
  }
155
172
  return /* @__PURE__ */ r("div", { className: "ant-input gs-rule-table-numeric-cell duplicates-renderer", children: t });
156
- }, he = (e, n, o) => /* @__PURE__ */ g(Te.Compact, { block: !0, children: [
157
- y.clone !== !1 && /* @__PURE__ */ r(
158
- N,
173
+ }, ge = (e, n, o) => /* @__PURE__ */ g(Ne.Compact, { block: !0, children: [
174
+ h.clone !== !1 && /* @__PURE__ */ r(
175
+ O,
159
176
  {
160
177
  className: "gs-rule-table-action-buttons",
161
- icon: /* @__PURE__ */ r(Ke, {}),
162
- title: c.actionCloneLabel,
178
+ icon: /* @__PURE__ */ r(Le, {}),
179
+ title: s.actionCloneLabel,
163
180
  color: "default",
164
181
  variant: "text",
165
- onClick: () => I == null ? void 0 : I(o)
182
+ onClick: () => z == null ? void 0 : z(o)
166
183
  }
167
184
  ),
168
- y.remove !== !1 && /* @__PURE__ */ r(
169
- N,
185
+ h.remove !== !1 && /* @__PURE__ */ r(
186
+ O,
170
187
  {
171
188
  className: "gs-rule-table-action-buttons",
172
- icon: /* @__PURE__ */ r(Ue, {}),
189
+ icon: /* @__PURE__ */ r(Be, {}),
173
190
  color: "default",
174
191
  variant: "text",
175
- title: c.actionRemoveLabel,
176
- onClick: () => z == null ? void 0 : z(o),
177
- disabled: i.length <= 1
192
+ title: s.actionRemoveLabel,
193
+ onClick: () => T == null ? void 0 : T(o),
194
+ disabled: l.length <= 1
178
195
  }
179
196
  )
180
- ] }), be = (e) => {
181
- h(b, "symbolizers", e);
182
- }, Ce = (e) => {
183
- h(b, "filter", e);
184
- }, h = (e, n, o) => {
185
- const t = ze(i);
186
- Ie(t[e], n, o), E && E(t);
187
- }, ge = () => {
188
- v(!1);
189
- }, Se = () => {
190
- T(!1);
197
+ ] }), Se = (e) => {
198
+ p(b, "symbolizers", e);
199
+ }, Re = (e) => {
200
+ p(b, "filter", e);
201
+ }, p = (e, n, o) => {
202
+ const t = Te(l);
203
+ ze(t[e], n, o), v && v(t);
204
+ }, xe = () => {
205
+ k(!1);
206
+ }, we = () => {
207
+ N(!1);
191
208
  }, u = [
192
209
  {
193
- title: /* @__PURE__ */ r(k, { title: c.symbolizersColumnTitle, children: /* @__PURE__ */ r(Ve, {}) }),
210
+ title: /* @__PURE__ */ r(S, { title: s.symbolizersColumnTitle, children: /* @__PURE__ */ r(Ke, {}) }),
194
211
  dataIndex: "symbolizers",
195
- render: ae
212
+ render: ue
196
213
  }
197
214
  ];
198
- (D == null ? void 0 : D.visibility) !== !1 && u.push({
199
- title: c.nameColumnTitle,
215
+ (E == null ? void 0 : E.visibility) !== !1 && u.push({
216
+ title: s.nameColumnTitle,
200
217
  dataIndex: "name",
201
- render: me
218
+ render: de
202
219
  }), (w == null ? void 0 : w.visibility) !== !1 && u.push({
203
- title: c.filterColumnTitle,
220
+ title: s.filterColumnTitle,
204
221
  dataIndex: "filter",
205
- render: ue
206
- }), (R == null ? void 0 : R.visibility) !== !1 && u.push({
207
- title: c.scalesColumnTitle,
208
- dataIndex: "scaleDenominator",
209
222
  render: fe
210
- }), (S == null ? void 0 : S.visibility) !== !1 && u.push({
211
- title: /* @__PURE__ */ r(k, { title: c.amountColumnTitle, children: "Σ" }),
223
+ }), (D == null ? void 0 : D.visibility) !== !1 && u.push({
224
+ title: s.scalesColumnTitle,
225
+ dataIndex: "scaleDenominator",
226
+ render: ye
227
+ }), (I == null ? void 0 : I.visibility) !== !1 && u.push({
228
+ title: /* @__PURE__ */ r(S, { title: s.elseRuleColumnTitle, children: "≠" }),
229
+ dataIndex: "elseRule",
230
+ render: he
231
+ }), (R == null ? void 0 : R.visibility) !== !1 && u.push({
232
+ title: /* @__PURE__ */ r(S, { title: s.amountColumnTitle, children: "Σ" }),
212
233
  dataIndex: "amount",
213
- render: pe
234
+ render: be
214
235
  }), (x == null ? void 0 : x.visibility) !== !1 && u.push({
215
- title: /* @__PURE__ */ r(k, { title: c.duplicatesColumnTitle, children: /* @__PURE__ */ r(qe, {}) }),
236
+ title: /* @__PURE__ */ r(S, { title: s.duplicatesColumnTitle, children: /* @__PURE__ */ r(Ue, {}) }),
216
237
  dataIndex: "duplicates",
217
- render: ye
218
- }), (y == null ? void 0 : y.visibility) !== !1 && u.push({
219
- title: c.actionsColumnTitle,
220
- render: he
238
+ render: Ce
239
+ }), (h == null ? void 0 : h.visibility) !== !1 && u.push({
240
+ title: s.actionsColumnTitle,
241
+ render: ge
221
242
  });
222
- const U = (e, n, o) => {
223
- var t, l;
224
- return (l = (t = a.rowSelection) == null ? void 0 : t.onChange) == null ? void 0 : l.call(t, e.map((d) => m.current.indexOf(d)), n, o);
225
- }, xe = ({ active: e, over: n }) => {
226
- var d, W, G;
243
+ const L = (e, n, o) => {
244
+ var t, i;
245
+ return (i = (t = a.rowSelection) == null ? void 0 : t.onChange) == null ? void 0 : i.call(t, e.map((d) => m.current.indexOf(d)), n, o);
246
+ }, De = ({ active: e, over: n }) => {
247
+ var d, G, _;
227
248
  if (e.id === (n == null ? void 0 : n.id))
228
249
  return;
229
- const o = C.findIndex((f) => f.key === e.id), t = C.findIndex((f) => f.key === (n == null ? void 0 : n.id)), l = (W = (d = a == null ? void 0 : a.rowSelection) == null ? void 0 : d.selectedRowKeys) == null ? void 0 : W.map(
250
+ const o = C.findIndex((f) => f.key === e.id), t = C.findIndex((f) => f.key === (n == null ? void 0 : n.id)), i = (G = (d = a == null ? void 0 : a.rowSelection) == null ? void 0 : d.selectedRowKeys) == null ? void 0 : G.map(
230
251
  (f) => m.current[f]
231
252
  );
232
- m.current = O(m.current, o, t), E(O(i, o, t)), !(!a.rowSelection || ((G = a.rowSelection.selectedRowKeys) == null ? void 0 : G.length) === 0) && U(
233
- l,
234
- O(C, o, t).filter((f) => l.includes(f.key)),
253
+ m.current = V(m.current, o, t), v(V(l, o, t)), !(!a.rowSelection || ((_ = a.rowSelection.selectedRowKeys) == null ? void 0 : _.length) === 0) && L(
254
+ i,
255
+ V(C, o, t).filter((f) => i.includes(f.key)),
235
256
  null
236
257
  );
237
258
  };
238
- if (ee)
259
+ if (re)
239
260
  return /* @__PURE__ */ r("h1", { children: "An error occurred in the RuleTable UI." });
240
- const we = a.rowSelection ? {
261
+ const Ee = a.rowSelection ? {
241
262
  ...a.rowSelection,
242
263
  selectedRowKeys: a.rowSelection.selectedRowKeys.map((e) => m.current[e]),
243
- onChange: U
264
+ onChange: L
244
265
  } : void 0;
245
266
  return /* @__PURE__ */ g("div", { className: "gs-rule-table", children: [
246
- /* @__PURE__ */ r(Ge, { sensors: le, collisionDetection: _e, onDragEnd: xe, children: /* @__PURE__ */ r(Fe, { items: m.current, strategy: Me, children: /* @__PURE__ */ r(
247
- ve,
267
+ /* @__PURE__ */ r(je, { sensors: ce, collisionDetection: Me, onDragEnd: De, children: /* @__PURE__ */ r(Fe, { items: m.current, strategy: He, children: /* @__PURE__ */ r(
268
+ ke,
248
269
  {
249
270
  columns: u,
250
271
  dataSource: C,
@@ -258,33 +279,33 @@ const yt = (J) => {
258
279
  ] })
259
280
  },
260
281
  body: {
261
- row: Pe
282
+ row: Je
262
283
  }
263
284
  },
264
285
  ...a,
265
- rowSelection: we
286
+ rowSelection: Ee
266
287
  }
267
288
  ) }) }),
268
289
  /* @__PURE__ */ r(
269
- Ne,
290
+ Ve,
270
291
  {
271
- open: $,
272
- onClose: ge,
273
- symbolizers: (L = i == null ? void 0 : i[b]) == null ? void 0 : L.symbolizers,
274
- onSymbolizersChange: be
292
+ open: ee,
293
+ onClose: xe,
294
+ symbolizers: (B = l == null ? void 0 : l[b]) == null ? void 0 : B.symbolizers,
295
+ onSymbolizersChange: Se
275
296
  }
276
297
  ),
277
298
  /* @__PURE__ */ r(
278
- ke,
299
+ Oe,
279
300
  {
280
- open: A,
281
- onClose: Se,
282
- filter: (B = i == null ? void 0 : i[b]) == null ? void 0 : B.filter,
283
- onFilterChange: Ce
301
+ open: te,
302
+ onClose: we,
303
+ filter: (W = l == null ? void 0 : l[b]) == null ? void 0 : W.filter,
304
+ onFilterChange: Re
284
305
  }
285
306
  )
286
307
  ] });
287
308
  };
288
309
  export {
289
- yt as RuleTable
310
+ gt as RuleTable
290
311
  };