@ogc-maps/storybook-components 0.9.0 → 0.10.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.
Files changed (61) hide show
  1. package/dist/{CollapsibleControl-CGRNPpCw.js → CollapsibleControl-qo9daiD8.js} +5 -5
  2. package/dist/ExportButton-BsNrOvRE.js +25 -0
  3. package/dist/Legend-BLWBzD7Y.js +275 -0
  4. package/dist/SearchPanel-4Y12jfuP.js +401 -0
  5. package/dist/components/CollapsibleControl/index.js +1 -1
  6. package/dist/components/ExportButton/ExportButton.d.ts +2 -8
  7. package/dist/components/ExportButton/ExportButton.d.ts.map +1 -1
  8. package/dist/components/ExportButton/index.d.ts +1 -1
  9. package/dist/components/ExportButton/index.d.ts.map +1 -1
  10. package/dist/components/ExportButton/index.js +1 -1
  11. package/dist/components/ExportModal/ExportModal.d.ts +29 -0
  12. package/dist/components/ExportModal/ExportModal.d.ts.map +1 -0
  13. package/dist/components/ExportModal/index.d.ts +3 -0
  14. package/dist/components/ExportModal/index.d.ts.map +1 -0
  15. package/dist/components/LayerEditor/LayerEditor.d.ts.map +1 -1
  16. package/dist/components/Legend/Legend.d.ts.map +1 -1
  17. package/dist/components/Legend/index.js +1 -1
  18. package/dist/components/MeasurePanel/MeasurePanel.d.ts +13 -0
  19. package/dist/components/MeasurePanel/MeasurePanel.d.ts.map +1 -0
  20. package/dist/components/MeasurePanel/index.d.ts +3 -0
  21. package/dist/components/MeasurePanel/index.d.ts.map +1 -0
  22. package/dist/components/SearchFieldEditor/SearchFieldEditor.d.ts.map +1 -1
  23. package/dist/components/SearchPanel/NumberInput.d.ts.map +1 -1
  24. package/dist/components/SearchPanel/SearchPanel.d.ts +2 -1
  25. package/dist/components/SearchPanel/SearchPanel.d.ts.map +1 -1
  26. package/dist/components/SearchPanel/index.js +1 -1
  27. package/dist/components/StyleEditor/DataDrivenColorEditor.d.ts.map +1 -1
  28. package/dist/components/UIConfigEditor/UIConfigEditor.d.ts.map +1 -1
  29. package/dist/components/index.d.ts +5 -1
  30. package/dist/components/index.d.ts.map +1 -1
  31. package/dist/geo-CIJBPCVe.js +1038 -0
  32. package/dist/hooks/index.d.ts +5 -0
  33. package/dist/hooks/index.d.ts.map +1 -1
  34. package/dist/hooks/index.js +40 -35
  35. package/dist/hooks/useExport.d.ts +22 -0
  36. package/dist/hooks/useExport.d.ts.map +1 -0
  37. package/dist/hooks/useMeasure.d.ts +15 -0
  38. package/dist/hooks/useMeasure.d.ts.map +1 -0
  39. package/dist/{index-UmK2u6Yd.js → index-DA_GGs_P.js} +296 -291
  40. package/dist/main.js +1370 -1031
  41. package/dist/schemas/config.d.ts +131 -0
  42. package/dist/schemas/config.d.ts.map +1 -1
  43. package/dist/schemas/index.js +1 -1
  44. package/dist/style.css +1 -1
  45. package/dist/types/index.js +1 -1
  46. package/dist/utils/cql2.d.ts.map +1 -1
  47. package/dist/utils/csvExport.d.ts.map +1 -1
  48. package/dist/utils/download.d.ts +2 -0
  49. package/dist/utils/download.d.ts.map +1 -0
  50. package/dist/utils/expressionColors.d.ts.map +1 -1
  51. package/dist/utils/geo.d.ts +3 -0
  52. package/dist/utils/geo.d.ts.map +1 -0
  53. package/dist/utils/index.d.ts +1 -0
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/measure.d.ts +49 -0
  56. package/dist/utils/measure.d.ts.map +1 -0
  57. package/package.json +6 -3
  58. package/dist/ExportButton-CLsWoW4m.js +0 -77
  59. package/dist/Legend-CwaZA84A.js +0 -273
  60. package/dist/SearchPanel-DtLXMoVs.js +0 -363
  61. package/dist/cql2-DOJnQwcv.js +0 -440
@@ -1,440 +0,0 @@
1
- import { useState as f, useEffect as w, useCallback as I } from "react";
2
- function d(t) {
3
- return t.endsWith("/") ? t.slice(0, -1) : t;
4
- }
5
- async function y(t) {
6
- const e = await fetch(t);
7
- if (!e.ok)
8
- throw new Error(`OGC API request failed: ${e.status} ${e.statusText} (${t})`);
9
- return e.json();
10
- }
11
- async function N(t) {
12
- const e = `${d(t)}/collections?f=json`;
13
- return (await y(e)).collections;
14
- }
15
- async function C(t, e, n = {}) {
16
- var c;
17
- const s = d(t), r = new URLSearchParams({ f: "geojson" });
18
- if (n.limit != null && r.set("limit", String(n.limit)), n.offset != null && r.set("offset", String(n.offset)), n.bbox && r.set("bbox", n.bbox.join(",")), (c = n.properties) != null && c.length && r.set("properties", n.properties.join(",")), n.datetime && r.set("datetime", n.datetime), n.cql2Filter)
19
- r.set("filter-lang", "cql2-json"), r.set("filter", JSON.stringify(n.cql2Filter));
20
- else if (n.filter)
21
- for (const [i, a] of Object.entries(n.filter))
22
- r.set(i, String(a));
23
- const o = `${s}/collections/${encodeURIComponent(e)}/items?${r}`;
24
- return y(o);
25
- }
26
- async function T(t, e) {
27
- const s = `${d(t)}/collections/${encodeURIComponent(e)}/queryables?f=schemajson`;
28
- return y(s);
29
- }
30
- async function x(t, e) {
31
- const s = `${d(t)}/collections/${encodeURIComponent(e)}?f=json`;
32
- return y(s);
33
- }
34
- async function _(t) {
35
- const e = `${d(t)}/conformance?f=json`;
36
- return y(e);
37
- }
38
- async function H(t, e, n = "WebMercatorQuad") {
39
- const s = P(t, e, n);
40
- return y(s);
41
- }
42
- async function X(t, e, n = {}) {
43
- return (await C(t, e, {
44
- ...n,
45
- limit: 0
46
- })).numberMatched ?? null;
47
- }
48
- function P(t, e, n = "WebMercatorQuad") {
49
- return `${d(t)}/collections/${encodeURIComponent(e)}/tiles/${encodeURIComponent(n)}/tilejson.json`;
50
- }
51
- function Z(t, e, n = "WebMercatorQuad") {
52
- return `${d(t)}/collections/${encodeURIComponent(e)}/tiles/${encodeURIComponent(n)}/{z}/{x}/{y}`;
53
- }
54
- function tt(t, e, n, s = "WebMercatorQuad") {
55
- const o = `${d(t)}/collections/${encodeURIComponent(e)}/tiles/${encodeURIComponent(s)}/{z}/{x}/{y}`;
56
- if (!n || Object.keys(n).length === 0) return o;
57
- const c = new URLSearchParams();
58
- for (const [i, a] of Object.entries(n))
59
- c.set(i, String(a));
60
- return `${o}?${c}`;
61
- }
62
- async function et(t, e, n, s) {
63
- var i;
64
- const r = s != null && s.query ? { op: "like", args: [{ property: n }, `%${s.query}%`] } : void 0, o = await C(t, e, {
65
- properties: [n],
66
- limit: (s == null ? void 0 : s.limit) ?? 50,
67
- cql2Filter: r
68
- }), c = /* @__PURE__ */ new Set();
69
- for (const a of o.features) {
70
- const u = (i = a.properties) == null ? void 0 : i[n];
71
- u != null && typeof u == "string" && c.add(u);
72
- }
73
- return Array.from(c).sort();
74
- }
75
- function nt(t, e, n, s = "WebMercatorQuad") {
76
- const o = `${d(t)}/collections/${encodeURIComponent(e)}/tiles/${encodeURIComponent(s)}/{z}/{x}/{y}`;
77
- if (!n) return o;
78
- const c = new URLSearchParams({
79
- "filter-lang": "cql2-json",
80
- filter: JSON.stringify(n)
81
- });
82
- return `${o}?${c}`;
83
- }
84
- function rt(t) {
85
- const [e, n] = f([]), [s, r] = f(!1), [o, c] = f(null);
86
- return w(() => {
87
- if (!t) return;
88
- let i = !1;
89
- return r(!0), c(null), N(t).then((a) => {
90
- i || n(a);
91
- }).catch((a) => {
92
- i || c(a instanceof Error ? a : new Error(String(a)));
93
- }).finally(() => {
94
- i || r(!1);
95
- }), () => {
96
- i = !0;
97
- };
98
- }, [t]), { collections: e, loading: s, error: o };
99
- }
100
- function st(t, e) {
101
- const [n, s] = f(null), [r, o] = f(!1), [c, i] = f(null);
102
- return w(() => {
103
- if (!t || !e) return;
104
- let a = !1;
105
- return o(!0), i(null), T(t, e).then((u) => {
106
- a || s(u);
107
- }).catch((u) => {
108
- a || i(u instanceof Error ? u : new Error(String(u)));
109
- }).finally(() => {
110
- a || o(!1);
111
- }), () => {
112
- a = !0;
113
- };
114
- }, [t, e]), { queryables: n, loading: r, error: c };
115
- }
116
- function ot(t, e, n = {}) {
117
- const [s, r] = f([]), [o, c] = f(!1), [i, a] = f(null), [u, m] = f(!1), g = JSON.stringify(n);
118
- return w(() => {
119
- if (!t || !e) return;
120
- let p = !1;
121
- c(!0), a(null);
122
- const h = JSON.parse(g);
123
- return C(t, e, h).then((l) => {
124
- if (!p) {
125
- r(l.features);
126
- const O = h.limit ?? 10, j = h.offset ?? 0;
127
- l.numberMatched != null ? m(j + l.features.length < l.numberMatched) : m(l.features.length >= O);
128
- }
129
- }).catch((l) => {
130
- p || (a(l instanceof Error ? l : new Error(String(l))), r([]), m(!1));
131
- }).finally(() => {
132
- p || c(!1);
133
- }), () => {
134
- p = !0;
135
- };
136
- }, [t, e, g]), { features: s, loading: o, error: i, hasMore: u };
137
- }
138
- function L(t) {
139
- return `${t[0]} ${t[1]}`;
140
- }
141
- function S(t) {
142
- return t.map(L).join(", ");
143
- }
144
- function k(t) {
145
- if (!t || !t.type) return "";
146
- switch (t.type) {
147
- case "Point":
148
- return `POINT (${L(t.coordinates)})`;
149
- case "MultiPoint":
150
- return `MULTIPOINT (${t.coordinates.map((e) => `(${L(e)})`).join(", ")})`;
151
- case "LineString":
152
- return `LINESTRING (${S(t.coordinates)})`;
153
- case "MultiLineString":
154
- return `MULTILINESTRING (${t.coordinates.map((e) => `(${S(e)})`).join(", ")})`;
155
- case "Polygon":
156
- return `POLYGON (${t.coordinates.map((e) => `(${S(e)})`).join(", ")})`;
157
- case "MultiPolygon":
158
- return `MULTIPOLYGON (${t.coordinates.map((e) => `(${e.map((n) => `(${S(n)})`).join(", ")})`).join(", ")})`;
159
- case "GeometryCollection":
160
- return `GEOMETRYCOLLECTION (${t.geometries.map(k).join(", ")})`;
161
- default:
162
- return "";
163
- }
164
- }
165
- function E(t, e) {
166
- return t.includes('"') || t.includes(e) || t.includes(`
167
- `) ? `"${t.replace(/"/g, '""')}"` : t;
168
- }
169
- function U(t, e) {
170
- const n = (t.properties ?? {})[e];
171
- return n == null ? "" : typeof n == "object" ? JSON.stringify(n) : String(n);
172
- }
173
- function q(t, e = {}) {
174
- const { fields: n, includeGeometry: s = !0, delimiter: r = "," } = e;
175
- if (t.length === 0) return "";
176
- const o = n ?? [...new Set(t.flatMap((a) => Object.keys(a.properties ?? {})))], c = s ? [...o, "geometry"] : o, i = t.map((a) => {
177
- const u = o.map(
178
- (m) => E(U(a, m), r)
179
- );
180
- return s && u.push(E(k(a.geometry), r)), u.join(r);
181
- });
182
- return [c.map((a) => E(a, r)).join(r), ...i].join(`
183
- `);
184
- }
185
- function F(t, e) {
186
- const n = new Blob([t], { type: "text/csv;charset=utf-8;" }), s = URL.createObjectURL(n), r = document.createElement("a");
187
- r.href = s, r.download = e, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(s);
188
- }
189
- function it({
190
- baseUrl: t,
191
- limit: e = 1e3,
192
- csvOptions: n
193
- }) {
194
- const [s, r] = f(!1), [o, c] = f(null);
195
- return { exportCsv: I(
196
- async (a, u = `${a}.csv`, m) => {
197
- r(!0), c(null);
198
- const g = [], p = Math.min(e, 1e3);
199
- let h = 0;
200
- try {
201
- for (; g.length < e; ) {
202
- const O = e - g.length, j = Math.min(p, O), b = await C(t, a, {
203
- limit: j,
204
- offset: h,
205
- cql2Filter: m
206
- });
207
- if (g.push(...b.features), h += b.features.length, b.features.length < j || b.numberMatched != null && h >= b.numberMatched) break;
208
- }
209
- const l = q(g, n);
210
- F(l, u);
211
- } catch (l) {
212
- c(l instanceof Error ? l : new Error(String(l)));
213
- } finally {
214
- r(!1);
215
- }
216
- },
217
- [t, e, n]
218
- ), loading: s, error: o };
219
- }
220
- function at(t, e) {
221
- const [n, s] = f(null), [r, o] = f(!1), [c, i] = f(null);
222
- return w(() => {
223
- if (!t || !e) return;
224
- let a = !1;
225
- return o(!0), i(null), x(t, e).then((u) => {
226
- a || s(u);
227
- }).catch((u) => {
228
- a || i(u instanceof Error ? u : new Error(String(u)));
229
- }).finally(() => {
230
- a || o(!1);
231
- }), () => {
232
- a = !0;
233
- };
234
- }, [t, e]), { collection: n, loading: r, error: c };
235
- }
236
- function ct(t) {
237
- if (!t) return;
238
- const e = [], n = {};
239
- for (const [s, r] of Object.entries(t))
240
- r.visible !== !1 && (e.push(s), r.label && (n[s] = r.label));
241
- return { fields: e, labels: n };
242
- }
243
- async function ut(t) {
244
- try {
245
- const e = await fetch(t);
246
- if (!e.ok) return null;
247
- const n = await e.json();
248
- return n.sprite ? typeof n.sprite == "string" ? n.sprite : Array.isArray(n.sprite) && n.sprite.length > 0 ? n.sprite[0].url : null : null;
249
- } catch {
250
- return null;
251
- }
252
- }
253
- async function v(t) {
254
- try {
255
- const e = await fetch(`${t}.json`);
256
- if (!e.ok) return [];
257
- const n = await e.json();
258
- return Object.keys(n).sort();
259
- } catch {
260
- return [];
261
- }
262
- }
263
- async function lt(t, e) {
264
- const n = await fetch(t);
265
- if (!n.ok) throw new Error(`Failed to fetch style: ${n.status}`);
266
- const s = await n.json();
267
- if (!e.length) return s;
268
- const r = Array.isArray(s.sprite) ? s.sprite : s.sprite ? [{ id: "default", url: s.sprite }] : [], o = new Set(e.map((i) => i.id)), c = [
269
- ...r.filter((i) => !o.has(i.id)),
270
- ...e.map((i) => ({ id: i.id, url: i.url }))
271
- ];
272
- return { ...s, sprite: c };
273
- }
274
- async function A(t) {
275
- try {
276
- const e = await fetch(t);
277
- if (!e.ok) return [];
278
- const n = await e.json();
279
- return n.sprite ? typeof n.sprite == "string" ? [{ id: "default", url: n.sprite }] : Array.isArray(n.sprite) ? n.sprite : [] : [];
280
- } catch {
281
- return [];
282
- }
283
- }
284
- async function M(t) {
285
- const e = await v(t.url);
286
- return t.id === "default" ? e : e.map((n) => `${t.id}:${n}`);
287
- }
288
- async function ft(t, e = []) {
289
- const n = [];
290
- t && n.push(
291
- A(t).then(
292
- (r) => Promise.all(r.map(M)).then((o) => o.flat())
293
- )
294
- );
295
- for (const r of e)
296
- n.push(M(r));
297
- const s = await Promise.all(n);
298
- return [...new Set(s.flat())].sort();
299
- }
300
- function $(t, e) {
301
- return { op: "=", args: [{ property: t }, e] };
302
- }
303
- function dt(t, e) {
304
- return { op: "<>", args: [{ property: t }, e] };
305
- }
306
- function G(t, e) {
307
- return { op: ">", args: [{ property: t }, e] };
308
- }
309
- function J(t, e) {
310
- return { op: ">=", args: [{ property: t }, e] };
311
- }
312
- function W(t, e) {
313
- return { op: "<", args: [{ property: t }, e] };
314
- }
315
- function Q(t, e) {
316
- return { op: "<=", args: [{ property: t }, e] };
317
- }
318
- function z(t, e, n) {
319
- return { op: "between", args: [{ property: t }, e, n] };
320
- }
321
- function mt(t, e) {
322
- return { op: "like", args: [{ property: t }, e] };
323
- }
324
- function gt(t, e) {
325
- return { op: "in", args: [{ property: t }, e] };
326
- }
327
- function ht(t) {
328
- return { op: "isNull", args: [{ property: t }] };
329
- }
330
- function R(...t) {
331
- const e = t.filter((n) => n != null);
332
- return e.length === 0 ? null : e.length === 1 ? e[0] : { op: "and", args: e };
333
- }
334
- function pt(...t) {
335
- const e = t.filter((n) => n != null);
336
- return e.length === 0 ? null : e.length === 1 ? e[0] : { op: "or", args: e };
337
- }
338
- function yt(t) {
339
- return { op: "not", args: [t] };
340
- }
341
- function D(t, e) {
342
- return { op: "t_after", args: [{ property: t }, e] };
343
- }
344
- function V(t, e) {
345
- return { op: "t_before", args: [{ property: t }, e] };
346
- }
347
- function B(t, e, n) {
348
- const s = "date" in e ? e.date : e.timestamp, r = "date" in n ? n.date : n.timestamp;
349
- return { op: "t_during", args: [{ property: t }, { interval: [s, r] }] };
350
- }
351
- function bt(t) {
352
- const e = Object.entries(t).filter(([, n]) => n !== void 0 && n !== "").map(([n, s]) => $(n, s));
353
- return R(...e);
354
- }
355
- function $t(t, e) {
356
- const n = new Map(e.map((r) => [r.property, r])), s = Object.entries(t).map(([r, o]) => {
357
- if (o === void 0) return null;
358
- const c = n.get(r);
359
- if (typeof o == "string")
360
- return o === "" ? null : (c == null ? void 0 : c.type) === "datetime" ? $(r, { timestamp: o }) : $(r, o);
361
- if (typeof o == "number")
362
- return $(r, o);
363
- if (typeof o == "object") {
364
- if ("start" in o || "end" in o) {
365
- const { start: i, end: a } = o;
366
- return i && a ? B(r, { timestamp: i }, { timestamp: a }) : i ? D(r, { timestamp: i }) : a ? V(r, { timestamp: a }) : null;
367
- }
368
- if ("value" in o && "operator" in o) {
369
- const { value: i, operator: a } = o;
370
- if (i == null || String(i) === "") return null;
371
- switch (a) {
372
- case "gt":
373
- return G(r, i);
374
- case "lt":
375
- return W(r, i);
376
- case "gte":
377
- return J(r, i);
378
- case "lte":
379
- return Q(r, i);
380
- default:
381
- return $(r, i);
382
- }
383
- }
384
- if ("min" in o && "max" in o) {
385
- const { min: i, max: a } = o;
386
- return i === void 0 || a === void 0 ? null : z(r, i, a);
387
- }
388
- }
389
- return null;
390
- });
391
- return R(...s);
392
- }
393
- function jt(t) {
394
- return JSON.stringify(t);
395
- }
396
- export {
397
- pt as A,
398
- ct as B,
399
- lt as C,
400
- jt as D,
401
- D as E,
402
- V as F,
403
- B as G,
404
- it as H,
405
- at as I,
406
- rt as J,
407
- ot as K,
408
- st as L,
409
- F as M,
410
- q as N,
411
- v as O,
412
- ut as P,
413
- ft as Q,
414
- R as a,
415
- z as b,
416
- N as c,
417
- _ as d,
418
- $ as e,
419
- x as f,
420
- et as g,
421
- X as h,
422
- C as i,
423
- T as j,
424
- H as k,
425
- bt as l,
426
- $t as m,
427
- nt as n,
428
- tt as o,
429
- P as p,
430
- Z as q,
431
- G as r,
432
- J as s,
433
- gt as t,
434
- ht as u,
435
- mt as v,
436
- W as w,
437
- Q as x,
438
- dt as y,
439
- yt as z
440
- };