@ogc-maps/storybook-components 0.6.1 → 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.
package/README.md CHANGED
@@ -9,6 +9,8 @@ A reusable, config-driven map component library built on OGC API standards. Desi
9
9
  - **OGC Standards**: Native support for OGC API Features and Tiles (e.g., via `tipg`).
10
10
  - **Controlled Components**: Fully controlled UI components for seamless state management.
11
11
  - **TypeScript**: Comprehensive type definitions inferred from Zod schemas.
12
+ - **Data-Driven Styling**: Visual editors for categorical and gradient color expressions.
13
+ - **Geometry Export**: CSV export with WKT geometry support.
12
14
 
13
15
  ## Installation
14
16
 
@@ -0,0 +1,440 @@
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
+ };
@@ -1,4 +1,4 @@
1
- import { a, b as t, e as l, f as r, c as i, d as o, g as c, h as n, i as u, j as f, k as g, l as h, m as C, n as F, o as p, p as m, q as y, r as D, s as d, t as q, u as T, v as b, w as v, x as O, y as S, z as U, A as V, B as x, C as J, D as k, E as w, F as z, G as A, H as B, I as E, J as L, K as Q, L as j } from "../cql2-onoyCbps.js";
1
+ import { a, b as t, e as l, f as r, c as i, d as o, g as c, h as n, i as u, j as f, k as g, l as h, m as C, n as F, o as p, p as m, q as y, r as D, s as d, t as q, u as T, v as b, w as v, x as O, y as S, z as U, A as V, B as x, C as J, D as k, E as w, F as z, G as A, H as B, I as E, J as L, K as Q, L as j } from "../cql2-DOJnQwcv.js";
2
2
  export {
3
3
  a as and,
4
4
  t as between,
package/dist/main.js CHANGED
@@ -10,8 +10,8 @@ import { S as ft } from "./SearchPanel-DCY01Wa-.js";
10
10
  import { jsxs as l, jsx as a, Fragment as B } from "react/jsx-runtime";
11
11
  import { useId as Ee, useState as L, useRef as ue, useMemo as Pe, useCallback as ze, useEffect as X } from "react";
12
12
  import { LuInfo as Ve } from "react-icons/lu";
13
- import { J as Fe, j as Me, i as se, L as _e, g as Ye } from "./cql2-onoyCbps.js";
14
- import { a as wt, b as vt, M as Nt, e as kt, N as Ct, f as St, c as Dt, d as Tt, h as Lt, O as It, P as At, k as Et, l as Pt, m as Ft, n as Mt, o as Ot, p as jt, q as $t, r as Rt, s as Bt, t as qt, u as Ut, v as Wt, w as Gt, x as zt, y as Vt, z as _t, A as Yt, Q as Xt, B as Ht, C as Jt, D as Kt, E as Qt, F as Zt, G as ei, H as ai, I as ti, K as ii } from "./cql2-onoyCbps.js";
13
+ import { J as Fe, j as Me, i as se, L as _e, g as Ye } from "./cql2-DOJnQwcv.js";
14
+ import { a as wt, b as vt, M as Nt, e as kt, N as Ct, f as St, c as Dt, d as Tt, h as Lt, O as It, P as At, k as Et, l as Pt, m as Ft, n as Mt, o as Ot, p as jt, q as $t, r as Rt, s as Bt, t as qt, u as Ut, v as Wt, w as Gt, x as zt, y as Vt, z as _t, A as Yt, Q as Xt, B as Ht, C as Jt, D as Kt, E as Qt, F as Zt, G as ei, H as ai, I as ti, K as ii } from "./cql2-DOJnQwcv.js";
15
15
  import { s as Xe } from "./index-B4i0zJXf.js";
16
16
  import { B as li, C as ni, a as pi, b as oi, D as ui, F as mi, c as si, d as ci, e as di, L as hi, f as gi, g as bi, h as yi, i as fi, j as xi, M as wi, N as vi, O as Ni, P as ki, k as Ci, S as Si, l as Di, m as Ti, n as Li, o as Ii, p as Ai, q as Ei, r as Pi, T as Fi, U as Mi, V as Oi, v as ji } from "./index-B4i0zJXf.js";
17
17
  import './style.css';function He({ text: e, id: t }) {
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=wkt.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkt.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/wkt.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"csvExport.d.ts","sourceRoot":"","sources":["../../src/utils/csvExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAqBR;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAW/D"}
1
+ {"version":3,"file":"csvExport.d.ts","sourceRoot":"","sources":["../../src/utils/csvExport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,cAAc,EAAE,EAC1B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CAqBR;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAW/D"}
@@ -0,0 +1,2 @@
1
+ export declare function geojsonGeometryToWkt(geometry: any): string;
2
+ //# sourceMappingURL=wkt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wkt.d.ts","sourceRoot":"","sources":["../../src/utils/wkt.ts"],"names":[],"mappings":"AAYA,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CA4B1D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogc-maps/storybook-components",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "main": "./dist/main.js",
6
6
  "publishConfig": {
@@ -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
- };