@ogc-maps/storybook-components 0.6.0 → 0.6.2

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