@ogc-maps/storybook-components 0.6.1 → 0.7.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.
- package/README.md +2 -0
- package/dist/{Legend-B6uIqOSw.js → Legend-DNjVLgsd.js} +20 -20
- package/dist/components/LayerEditor/LayerEditor.d.ts.map +1 -1
- package/dist/components/Legend/index.js +1 -1
- package/dist/cql2-DOJnQwcv.js +440 -0
- package/dist/hooks/index.js +1 -1
- package/dist/{index-B4i0zJXf.js → index-RzZtWlUz.js} +259 -238
- package/dist/main.js +795 -723
- package/dist/schemas/__tests__/config.test.d.ts +2 -0
- package/dist/schemas/__tests__/config.test.d.ts.map +1 -0
- package/dist/schemas/config.d.ts +398 -313
- package/dist/schemas/config.d.ts.map +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +19 -18
- package/dist/utils/__tests__/queryableHelpers.test.d.ts +2 -0
- package/dist/utils/__tests__/queryableHelpers.test.d.ts.map +1 -0
- package/dist/utils/__tests__/wkt.test.d.ts +2 -0
- package/dist/utils/__tests__/wkt.test.d.ts.map +1 -0
- package/dist/utils/csvExport.d.ts.map +1 -1
- package/dist/utils/queryableHelpers.d.ts +16 -2
- package/dist/utils/queryableHelpers.d.ts.map +1 -1
- package/dist/utils/wkt.d.ts +2 -0
- package/dist/utils/wkt.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/cql2-onoyCbps.js +0 -413
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
|
|
|
@@ -8,12 +8,12 @@ const w = {
|
|
|
8
8
|
symbol: "icon-opacity"
|
|
9
9
|
};
|
|
10
10
|
function v(i) {
|
|
11
|
-
var n;
|
|
12
|
-
const m = i.
|
|
11
|
+
var n, l;
|
|
12
|
+
const m = (n = i.styles) == null ? void 0 : n[0];
|
|
13
13
|
if (!m) return 1;
|
|
14
14
|
const e = w[m.type];
|
|
15
15
|
if (!e) return 1;
|
|
16
|
-
const u = (
|
|
16
|
+
const u = (l = m.paint) == null ? void 0 : l[e];
|
|
17
17
|
return typeof u == "number" ? u : 1;
|
|
18
18
|
}
|
|
19
19
|
function g({ color: i, shape: m }) {
|
|
@@ -70,8 +70,8 @@ function L({
|
|
|
70
70
|
expanded: e,
|
|
71
71
|
onToggle: u
|
|
72
72
|
}) {
|
|
73
|
-
var
|
|
74
|
-
const { entries: n, showLabelsCollapsed:
|
|
73
|
+
var s, d;
|
|
74
|
+
const { entries: n, showLabelsCollapsed: l } = i;
|
|
75
75
|
return /* @__PURE__ */ p("div", { children: [
|
|
76
76
|
/* @__PURE__ */ p(
|
|
77
77
|
"button",
|
|
@@ -94,8 +94,8 @@ function L({
|
|
|
94
94
|
style: { background: k(n) }
|
|
95
95
|
}
|
|
96
96
|
),
|
|
97
|
-
|
|
98
|
-
/* @__PURE__ */ a("span", { className: "mapui:truncate", children: (
|
|
97
|
+
l && !e && /* @__PURE__ */ p("div", { className: "mapui:mt-1 mapui:flex mapui:justify-between mapui:text-[10px] mapui:text-gray-500 mapui:max-w-32", children: [
|
|
98
|
+
/* @__PURE__ */ a("span", { className: "mapui:truncate", children: (s = n[0]) == null ? void 0 : s.label }),
|
|
99
99
|
n.length > 1 && /* @__PURE__ */ a("span", { className: "mapui:truncate", children: (d = n[n.length - 1]) == null ? void 0 : d.label })
|
|
100
100
|
] })
|
|
101
101
|
] }),
|
|
@@ -118,7 +118,7 @@ function E({
|
|
|
118
118
|
expanded: e,
|
|
119
119
|
onToggle: u
|
|
120
120
|
}) {
|
|
121
|
-
const { entries: n, gradientProperty:
|
|
121
|
+
const { entries: n, gradientProperty: l } = i;
|
|
122
122
|
return /* @__PURE__ */ p("div", { children: [
|
|
123
123
|
/* @__PURE__ */ p(
|
|
124
124
|
"button",
|
|
@@ -141,7 +141,7 @@ function E({
|
|
|
141
141
|
}
|
|
142
142
|
) }),
|
|
143
143
|
e && /* @__PURE__ */ p("div", { className: "mapui:mt-1 mapui:ml-4 mapui:text-xs mapui:text-gray-600", children: [
|
|
144
|
-
|
|
144
|
+
l && /* @__PURE__ */ a("div", { className: "mapui:font-medium mapui:mb-1", children: l }),
|
|
145
145
|
n.length >= 2 && /* @__PURE__ */ p("div", { className: "mapui:flex mapui:justify-between mapui:max-w-32", children: [
|
|
146
146
|
/* @__PURE__ */ a("span", { children: n[0].label }),
|
|
147
147
|
/* @__PURE__ */ a("span", { children: n[n.length - 1].label })
|
|
@@ -174,11 +174,11 @@ function j({
|
|
|
174
174
|
] });
|
|
175
175
|
}
|
|
176
176
|
function G({ layers: i, visibleLayerIds: m, onOpacityChange: e, className: u }) {
|
|
177
|
-
const [n,
|
|
177
|
+
const [n, l] = f(/* @__PURE__ */ new Set()), [s, d] = f(!1), c = i.filter((t) => m.includes(t.id));
|
|
178
178
|
function h(t) {
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
return
|
|
179
|
+
l((o) => {
|
|
180
|
+
const r = new Set(o);
|
|
181
|
+
return r.has(t) ? r.delete(t) : r.add(t), r;
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
184
|
const x = c.filter((t) => t.legend !== void 0);
|
|
@@ -195,15 +195,15 @@ function G({ layers: i, visibleLayerIds: m, onOpacityChange: e, className: u })
|
|
|
195
195
|
type: "button",
|
|
196
196
|
className: "mapui:bg-transparent mapui:border-none mapui:p-0 mapui:cursor-pointer mapui:text-gray-400 hover:mapui:text-gray-600 mapui:text-sm",
|
|
197
197
|
onClick: () => d((t) => !t),
|
|
198
|
-
"aria-label":
|
|
199
|
-
children:
|
|
198
|
+
"aria-label": s ? "Collapse legend" : "Expand legend",
|
|
199
|
+
children: s ? /* @__PURE__ */ a(N, {}) : /* @__PURE__ */ a(y, {})
|
|
200
200
|
}
|
|
201
201
|
)
|
|
202
202
|
] }),
|
|
203
|
-
/* @__PURE__ */ a("ul", { className: `mapui:m-0 mapui:list-none mapui:p-0 ${
|
|
204
|
-
const o = t.legend,
|
|
203
|
+
/* @__PURE__ */ a("ul", { className: `mapui:m-0 mapui:list-none mapui:p-0 ${s ? "mapui:space-y-1.5" : "mapui:space-y-2"}`, children: x.map((t) => {
|
|
204
|
+
const o = t.legend, r = o.displayMode ?? "simple", b = s || n.has(t.id);
|
|
205
205
|
return /* @__PURE__ */ p("li", { children: [
|
|
206
|
-
|
|
206
|
+
r === "categorical" ? /* @__PURE__ */ a(
|
|
207
207
|
L,
|
|
208
208
|
{
|
|
209
209
|
legend: o,
|
|
@@ -211,7 +211,7 @@ function G({ layers: i, visibleLayerIds: m, onOpacityChange: e, className: u })
|
|
|
211
211
|
expanded: b,
|
|
212
212
|
onToggle: () => h(t.id)
|
|
213
213
|
}
|
|
214
|
-
) :
|
|
214
|
+
) : r === "gradient" ? /* @__PURE__ */ a(
|
|
215
215
|
E,
|
|
216
216
|
{
|
|
217
217
|
legend: o,
|
|
@@ -220,7 +220,7 @@ function G({ layers: i, visibleLayerIds: m, onOpacityChange: e, className: u })
|
|
|
220
220
|
onToggle: () => h(t.id)
|
|
221
221
|
}
|
|
222
222
|
) : /* @__PURE__ */ a(C, { legend: o, label: t.label }),
|
|
223
|
-
|
|
223
|
+
s && e && /* @__PURE__ */ a(
|
|
224
224
|
j,
|
|
225
225
|
{
|
|
226
226
|
layerId: t.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LayerEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LayerEditor/LayerEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"LayerEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LayerEditor/LayerEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAkC,MAAM,aAAa,CAAC;AA2B7F,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,gBAAgB,EAAE,YAAY,EAAE,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAKD,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,gBAAgB,2CAuQlG"}
|
|
@@ -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
|
+
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -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-
|
|
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,
|