@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,273 +0,0 @@
1
- import { jsxs as l, jsx as e, Fragment as v } from "react/jsx-runtime";
2
- import { useState as b } from "react";
3
- import { BsArrowsAngleContract as C, BsArrowsAngleExpand as A } from "react-icons/bs";
4
- import { MdOutlineKeyboardArrowDown as k, MdOutlineKeyboardArrowRight as $ } from "react-icons/md";
5
- const E = {
6
- fill: "fill-opacity",
7
- line: "line-opacity",
8
- circle: "circle-opacity",
9
- symbol: "icon-opacity"
10
- };
11
- function I(m) {
12
- var r, s;
13
- const a = (r = m.styles) == null ? void 0 : r[0];
14
- if (!a) return 1;
15
- const i = E[a.type];
16
- if (!i) return 1;
17
- const n = (s = a.paint) == null ? void 0 : s[i];
18
- return typeof n == "number" ? n : 1;
19
- }
20
- function w({ color: m, shape: a }) {
21
- const i = a ?? "square";
22
- let n;
23
- return i === "circle" ? n = /* @__PURE__ */ e(
24
- "span",
25
- {
26
- className: "mapui:inline-block mapui:h-3 mapui:w-3 mapui:rounded-full",
27
- style: { backgroundColor: m }
28
- }
29
- ) : i === "line" ? n = /* @__PURE__ */ e(
30
- "span",
31
- {
32
- className: "mapui:inline-block mapui:h-0.5 mapui:w-4 mapui:rounded-full",
33
- style: { backgroundColor: m }
34
- }
35
- ) : n = /* @__PURE__ */ e(
36
- "span",
37
- {
38
- className: "mapui:inline-block mapui:h-3 mapui:w-3 mapui:rounded-sm",
39
- style: { backgroundColor: m }
40
- }
41
- ), /* @__PURE__ */ e("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: n });
42
- }
43
- function j(m) {
44
- return `linear-gradient(to right, ${m.map((a, i) => `${a.color} ${i / m.length * 100}% ${(i + 1) / m.length * 100}%`).join(", ")})`;
45
- }
46
- function y(m) {
47
- return `linear-gradient(to right, ${m.map((a) => a.color).join(", ")})`;
48
- }
49
- function N(m) {
50
- const a = m.trim();
51
- let i, n, r;
52
- if (/^#[0-9a-f]{3}$/i.test(a))
53
- i = parseInt(a[1] + a[1], 16), n = parseInt(a[2] + a[2], 16), r = parseInt(a[3] + a[3], 16);
54
- else if (/^#[0-9a-f]{6}$/i.test(a))
55
- i = parseInt(a.slice(1, 3), 16), n = parseInt(a.slice(3, 5), 16), r = parseInt(a.slice(5, 7), 16);
56
- else
57
- return null;
58
- const s = i / 255, u = n / 255, p = r / 255, g = Math.max(s, u, p), f = Math.min(s, u, p), d = g - f;
59
- if (d === 0) return 0;
60
- let h = 0;
61
- return g === s ? h = ((u - p) / d + 6) % 6 : g === u ? h = (p - s) / d + 2 : h = (s - u) / d + 4, h * 60;
62
- }
63
- function L(m) {
64
- return [...m].sort((a, i) => {
65
- const n = N(a.color), r = N(i.color);
66
- return n === null && r === null ? 0 : n === null ? 1 : r === null ? -1 : n - r;
67
- });
68
- }
69
- function S({ legend: m, label: a, hasArrowColumn: i }) {
70
- const { entries: n } = m, r = i ? /* @__PURE__ */ e("span", { className: "mapui:w-5 mapui:shrink-0" }) : null;
71
- return n.length === 1 ? /* @__PURE__ */ l("div", { className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0", children: [
72
- r,
73
- /* @__PURE__ */ e(w, { color: n[0].color, shape: n[0].shape }),
74
- /* @__PURE__ */ e("span", { className: "mapui:text-gray-700 mapui:truncate", children: n[0].label || a })
75
- ] }) : /* @__PURE__ */ l("div", { children: [
76
- /* @__PURE__ */ e("div", { className: "mapui:mb-1 mapui:text-xs mapui:font-medium mapui:text-gray-600", children: a }),
77
- /* @__PURE__ */ e("ul", { className: "mapui:m-0 mapui:list-none mapui:space-y-1 mapui:p-0 mapui:pl-1", children: n.map((s, u) => /* @__PURE__ */ l(
78
- "li",
79
- {
80
- className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0",
81
- children: [
82
- r,
83
- /* @__PURE__ */ e(w, { color: s.color, shape: s.shape }),
84
- /* @__PURE__ */ e("span", { className: "mapui:text-gray-700 mapui:truncate", children: s.label })
85
- ]
86
- },
87
- `${s.label}-${u}`
88
- )) })
89
- ] });
90
- }
91
- function M({
92
- legend: m,
93
- label: a,
94
- expanded: i,
95
- onToggle: n,
96
- hasArrowColumn: r
97
- }) {
98
- const { entries: s } = m, u = m.showColorBar !== !1, p = m.showDisclosureArrow !== !1, g = s.filter((t, o, c) => c.findIndex((x) => x.color === t.color) === o), f = L(g), d = /* @__PURE__ */ e("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: /* @__PURE__ */ e("span", { className: "mapui:text-gray-400", children: i ? /* @__PURE__ */ e(k, {}) : /* @__PURE__ */ e($, {}) }) }), h = /* @__PURE__ */ l(v, { children: [
99
- r && (p ? d : /* @__PURE__ */ e("span", { className: "mapui:w-5 mapui:shrink-0" })),
100
- u ? /* @__PURE__ */ e(
101
- "div",
102
- {
103
- className: "mapui:h-3 mapui:w-5 mapui:rounded-sm mapui:shrink-0",
104
- style: { background: j(f) }
105
- }
106
- ) : !r && p ? d : /* @__PURE__ */ e("span", { className: "mapui:w-5 mapui:shrink-0" }),
107
- /* @__PURE__ */ e("span", { className: "mapui:truncate", children: a })
108
- ] });
109
- return /* @__PURE__ */ l("div", { children: [
110
- p ? /* @__PURE__ */ e(
111
- "button",
112
- {
113
- type: "button",
114
- className: "mapui:flex mapui:items-center mapui:gap-2 mapui:bg-transparent mapui:border-none mapui:p-0 mapui:cursor-pointer mapui:text-left mapui:text-gray-700 mapui:text-sm mapui:font-medium mapui:min-w-0",
115
- onClick: n,
116
- "aria-expanded": i,
117
- children: h
118
- }
119
- ) : /* @__PURE__ */ e("div", { className: "mapui:flex mapui:items-center mapui:gap-2 mapui:text-gray-700 mapui:text-sm mapui:font-medium mapui:min-w-0", children: h }),
120
- i && /* @__PURE__ */ e("ul", { className: `mapui:m-0 mapui:mt-1 mapui:list-none mapui:space-y-1 mapui:p-0 mapui:max-h-48 mapui:overflow-y-auto${p ? " mapui:ml-7" : ""}`, children: s.map((t, o) => /* @__PURE__ */ l(
121
- "li",
122
- {
123
- className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0",
124
- children: [
125
- /* @__PURE__ */ e(w, { color: t.color, shape: t.shape }),
126
- /* @__PURE__ */ e("span", { className: "mapui:text-gray-700 mapui:truncate mapui:text-xs", children: t.label })
127
- ]
128
- },
129
- `${t.label}-${o}`
130
- )) })
131
- ] });
132
- }
133
- function B({
134
- legend: m,
135
- label: a,
136
- expanded: i,
137
- onToggle: n,
138
- hasArrowColumn: r
139
- }) {
140
- const { entries: s, gradientProperty: u } = m, p = m.showDisclosureArrow !== !1, f = /* @__PURE__ */ l(v, { children: [
141
- r && (p ? /* @__PURE__ */ e("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: /* @__PURE__ */ e("span", { className: "mapui:text-gray-400", children: i ? /* @__PURE__ */ e(k, {}) : /* @__PURE__ */ e($, {}) }) }) : /* @__PURE__ */ e("span", { className: "mapui:w-5 mapui:shrink-0" })),
142
- /* @__PURE__ */ e(
143
- "div",
144
- {
145
- className: "mapui:h-3 mapui:w-5 mapui:rounded-sm mapui:shrink-0",
146
- style: { background: y(s) }
147
- }
148
- ),
149
- /* @__PURE__ */ e("span", { className: "mapui:truncate", children: a })
150
- ] });
151
- return /* @__PURE__ */ l("div", { children: [
152
- p ? /* @__PURE__ */ e(
153
- "button",
154
- {
155
- type: "button",
156
- className: "mapui:flex mapui:items-center mapui:gap-2 mapui:bg-transparent mapui:border-none mapui:p-0 mapui:cursor-pointer mapui:text-left mapui:text-gray-700 mapui:text-sm mapui:font-medium",
157
- onClick: n,
158
- "aria-expanded": i,
159
- children: f
160
- }
161
- ) : /* @__PURE__ */ e("div", { className: "mapui:flex mapui:items-center mapui:gap-2 mapui:text-gray-700 mapui:text-sm mapui:font-medium", children: f }),
162
- /* @__PURE__ */ e("div", { className: p ? "mapui:mt-1 mapui:ml-7" : "mapui:mt-1", children: /* @__PURE__ */ e(
163
- "div",
164
- {
165
- className: "mapui:h-3 mapui:min-w-12 mapui:max-w-32 mapui:rounded-sm",
166
- style: { background: y(s) }
167
- }
168
- ) }),
169
- i && /* @__PURE__ */ l("div", { className: `mapui:mt-1 mapui:text-xs mapui:text-gray-600${p ? " mapui:ml-7" : ""}`, children: [
170
- u && /* @__PURE__ */ e("div", { className: "mapui:font-medium mapui:mb-1", children: u }),
171
- s.length >= 2 && /* @__PURE__ */ l("div", { className: "mapui:flex mapui:justify-between mapui:max-w-32", children: [
172
- /* @__PURE__ */ e("span", { children: s[0].label }),
173
- /* @__PURE__ */ e("span", { children: s[s.length - 1].label })
174
- ] })
175
- ] })
176
- ] });
177
- }
178
- function D({
179
- layerId: m,
180
- opacity: a,
181
- onChange: i
182
- }) {
183
- return /* @__PURE__ */ l("div", { className: "mapui:flex mapui:items-center mapui:gap-1.5 mapui:mt-0.5 mapui:ml-1", children: [
184
- /* @__PURE__ */ e(
185
- "input",
186
- {
187
- type: "range",
188
- min: 0,
189
- max: 1,
190
- step: 0.01,
191
- value: a,
192
- onChange: (n) => i(m, parseFloat(n.target.value)),
193
- className: "range-sm mapui:w-14"
194
- }
195
- ),
196
- /* @__PURE__ */ l("span", { className: "mapui:text-[9px] mapui:text-gray-400 mapui:w-6 mapui:text-right mapui:tabular-nums", children: [
197
- Math.round(a * 100),
198
- "%"
199
- ] })
200
- ] });
201
- }
202
- function q({ layers: m, visibleLayerIds: a, onOpacityChange: i, className: n }) {
203
- const [r, s] = b(/* @__PURE__ */ new Set()), [u, p] = b(!1), g = m.filter((t) => a.includes(t.id));
204
- function f(t) {
205
- s((o) => {
206
- const c = new Set(o);
207
- return c.has(t) ? c.delete(t) : c.add(t), c;
208
- });
209
- }
210
- const d = g.filter((t) => t.legend !== void 0);
211
- if (d.length === 0)
212
- return null;
213
- const h = d.some((t) => {
214
- const o = t.legend, c = o.displayMode ?? "simple", x = o.showDisclosureArrow !== !1;
215
- return c === "gradient" ? x : c === "categorical" ? x && o.showColorBar !== !1 : !1;
216
- });
217
- return /* @__PURE__ */ l(
218
- "div",
219
- {
220
- className: `mapui:rounded-lg mapui:bg-white mapui:p-3 mapui:shadow-md mapui:text-sm${n ? ` ${n}` : ""}`,
221
- children: [
222
- /* @__PURE__ */ l("div", { className: "mapui:flex mapui:items-center mapui:justify-between mapui:mb-2", children: [
223
- /* @__PURE__ */ e("h3", { className: "mapui:m-0 mapui:text-xs mapui:font-semibold mapui:uppercase mapui:tracking-wide mapui:text-gray-500", children: "Legend" }),
224
- i && /* @__PURE__ */ e(
225
- "button",
226
- {
227
- type: "button",
228
- 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",
229
- onClick: () => p((t) => !t),
230
- "aria-label": u ? "Collapse legend" : "Expand legend",
231
- children: u ? /* @__PURE__ */ e(C, {}) : /* @__PURE__ */ e(A, {})
232
- }
233
- )
234
- ] }),
235
- /* @__PURE__ */ e("ul", { className: `mapui:m-0 mapui:list-none mapui:p-0 ${u ? "mapui:space-y-1.5" : "mapui:space-y-2"}`, children: d.map((t) => {
236
- const o = t.legend, c = o.displayMode ?? "simple", x = u || r.has(t.id);
237
- return /* @__PURE__ */ l("li", { children: [
238
- c === "categorical" ? /* @__PURE__ */ e(
239
- M,
240
- {
241
- legend: o,
242
- label: t.label,
243
- expanded: x,
244
- onToggle: () => f(t.id),
245
- hasArrowColumn: h
246
- }
247
- ) : c === "gradient" ? /* @__PURE__ */ e(
248
- B,
249
- {
250
- legend: o,
251
- label: t.label,
252
- expanded: x,
253
- onToggle: () => f(t.id),
254
- hasArrowColumn: h
255
- }
256
- ) : /* @__PURE__ */ e(S, { legend: o, label: t.label, hasArrowColumn: h }),
257
- u && i && /* @__PURE__ */ e(
258
- D,
259
- {
260
- layerId: t.id,
261
- opacity: I(t),
262
- onChange: i
263
- }
264
- )
265
- ] }, t.id);
266
- }) })
267
- ]
268
- }
269
- );
270
- }
271
- export {
272
- q as L
273
- };
@@ -1,363 +0,0 @@
1
- import { jsxs as h, jsx as m } from "react/jsx-runtime";
2
- import { useState as j, useRef as L, useId as D, useMemo as S, useCallback as A, useEffect as I } from "react";
3
- function V({
4
- value: e,
5
- onChange: t,
6
- suggestions: u,
7
- onQueryChange: d,
8
- placeholder: N = "",
9
- className: l = "",
10
- id: y
11
- }) {
12
- const [f, c] = j(!1), [p, o] = j(-1), g = L(null), i = D(), r = p >= 0 ? `${i}-option-${p}` : void 0, v = S(
13
- () => u.filter((n) => n.toLowerCase().includes(e.toLowerCase())),
14
- [u, e]
15
- ), b = f && v.length > 0, a = A(
16
- (n) => {
17
- t(n), d == null || d(n), c(!1), o(-1);
18
- },
19
- [t, d]
20
- ), x = (n) => {
21
- const s = n.target.value;
22
- t(s), d == null || d(s), c(!0), o(-1);
23
- }, w = (n) => {
24
- b && (n.key === "ArrowDown" ? (n.preventDefault(), o((s) => Math.min(s + 1, v.length - 1))) : n.key === "ArrowUp" ? (n.preventDefault(), o((s) => Math.max(s - 1, 0))) : n.key === "Enter" && p >= 0 ? (n.preventDefault(), a(v[p])) : n.key === "Escape" && (c(!1), o(-1)));
25
- };
26
- return I(() => {
27
- const n = (s) => {
28
- g.current && !g.current.contains(s.target) && (c(!1), o(-1));
29
- };
30
- return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
31
- }, []), /* @__PURE__ */ h("div", { ref: g, className: `mapui:relative ${l}`.trim(), children: [
32
- /* @__PURE__ */ m(
33
- "input",
34
- {
35
- id: y,
36
- type: "text",
37
- value: e,
38
- placeholder: N,
39
- role: "combobox",
40
- "aria-expanded": b,
41
- "aria-autocomplete": "list",
42
- "aria-controls": i,
43
- "aria-activedescendant": r,
44
- onChange: x,
45
- onFocus: () => c(!0),
46
- onKeyDown: w,
47
- className: "mapui:w-full mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500"
48
- }
49
- ),
50
- b && /* @__PURE__ */ m(
51
- "ul",
52
- {
53
- id: i,
54
- role: "listbox",
55
- className: "mapui:absolute mapui:z-10 mapui:mt-1 mapui:w-full mapui:rounded mapui:border mapui:border-gray-200 mapui:bg-white mapui:shadow-lg mapui:max-h-48 mapui:overflow-y-auto mapui:p-0 mapui:m-0 mapui:list-none",
56
- children: v.map((n, s) => /* @__PURE__ */ m(
57
- "li",
58
- {
59
- id: `${i}-option-${s}`,
60
- role: "option",
61
- "aria-selected": s === p,
62
- onMouseDown: (E) => {
63
- E.preventDefault(), a(n);
64
- },
65
- className: `mapui:cursor-pointer mapui:px-2 mapui:py-1 mapui:text-sm ${s === p ? "mapui:bg-blue-100" : "hover:mapui:bg-gray-50"}`,
66
- children: n
67
- },
68
- `${s}-${n}`
69
- ))
70
- }
71
- )
72
- ] });
73
- }
74
- function R({
75
- startValue: e,
76
- endValue: t,
77
- onStartChange: u,
78
- onEndChange: d,
79
- className: N = "",
80
- id: l
81
- }) {
82
- const y = D(), f = l ?? y, c = `${f}-start`, p = `${f}-end`, o = "mapui:flex-1 mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500";
83
- return /* @__PURE__ */ h("div", { className: `mapui:flex mapui:flex-col mapui:gap-1.5 ${N}`.trim(), children: [
84
- /* @__PURE__ */ h("div", { className: "mapui:flex mapui:items-center mapui:gap-2", children: [
85
- /* @__PURE__ */ m("label", { htmlFor: c, className: "mapui:text-xs mapui:text-gray-400 mapui:w-8", children: "From" }),
86
- /* @__PURE__ */ m(
87
- "input",
88
- {
89
- id: c,
90
- type: "datetime-local",
91
- value: e,
92
- onChange: (g) => u(g.target.value),
93
- "aria-label": "Start date",
94
- className: o
95
- }
96
- )
97
- ] }),
98
- /* @__PURE__ */ h("div", { className: "mapui:flex mapui:items-center mapui:gap-2", children: [
99
- /* @__PURE__ */ m("label", { htmlFor: p, className: "mapui:text-xs mapui:text-gray-400 mapui:w-8", children: "To" }),
100
- /* @__PURE__ */ m(
101
- "input",
102
- {
103
- id: p,
104
- type: "datetime-local",
105
- value: t,
106
- onChange: (g) => d(g.target.value),
107
- "aria-label": "End date",
108
- className: o
109
- }
110
- )
111
- ] })
112
- ] });
113
- }
114
- const k = {
115
- eq: "=",
116
- gt: ">",
117
- lt: "<",
118
- gte: ">=",
119
- lte: "<=",
120
- between: "between"
121
- }, M = ["eq", "gt", "lt", "gte", "lte", "between"];
122
- function O(e, t) {
123
- if (e && typeof e == "object") {
124
- if ("operator" in e) return e.operator;
125
- if ("min" in e) return "between";
126
- }
127
- return t;
128
- }
129
- const $ = "mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500", K = "mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500 mapui:bg-white";
130
- function P({ field: e, value: t, onChange: u, className: d = "", id: N }) {
131
- const [l, y] = j(
132
- () => O(t, e.operator)
133
- );
134
- I(() => {
135
- y(O(t, e.operator));
136
- }, [t, e.operator]);
137
- const f = l === "between", c = e.inputMode === "slider" ? M.filter((a) => a !== "between") : M, p = (a) => {
138
- if (y(a), a === "between")
139
- u(void 0);
140
- else if (f)
141
- u(void 0);
142
- else if (t && typeof t == "object" && "value" in t) {
143
- const x = t.value;
144
- u({ value: x, operator: a });
145
- }
146
- }, o = (a) => {
147
- u(a === "" ? void 0 : { value: Number(a), operator: l });
148
- }, g = (a) => {
149
- const x = t && typeof t == "object" && "max" in t ? t.max : void 0;
150
- u(a === "" ? x === void 0 ? void 0 : { min: e.min ?? 0, max: x } : { min: Number(a), max: x ?? e.max ?? 0 });
151
- }, i = (a) => {
152
- const x = t && typeof t == "object" && "min" in t ? t.min : void 0;
153
- u(a === "" ? x === void 0 ? void 0 : { min: x, max: e.max ?? 0 } : { min: x ?? e.min ?? 0, max: Number(a) });
154
- }, r = t && typeof t == "object" && "value" in t ? String(t.value) : "", v = t && typeof t == "object" && "min" in t ? String(t.min) : "", b = t && typeof t == "object" && "max" in t ? String(t.max) : "";
155
- return /* @__PURE__ */ h("div", { className: `mapui:flex mapui:flex-col mapui:gap-1.5 ${d}`.trim(), children: [
156
- /* @__PURE__ */ m(
157
- "select",
158
- {
159
- value: l,
160
- onChange: (a) => p(a.target.value),
161
- "aria-label": `${e.label} operator`,
162
- className: K,
163
- children: c.map((a) => /* @__PURE__ */ m("option", { value: a, children: k[a] }, a))
164
- }
165
- ),
166
- f ? (
167
- /* Between: min + max inputs */
168
- /* @__PURE__ */ h("div", { className: "mapui:flex mapui:gap-2", children: [
169
- /* @__PURE__ */ m(
170
- "input",
171
- {
172
- type: "number",
173
- value: v,
174
- placeholder: e.min !== void 0 ? String(e.min) : "Min",
175
- min: e.min,
176
- max: e.max,
177
- step: e.step,
178
- onChange: (a) => g(a.target.value),
179
- "aria-label": `${e.label} minimum`,
180
- className: `${$} mapui:w-1/2`
181
- }
182
- ),
183
- /* @__PURE__ */ m(
184
- "input",
185
- {
186
- type: "number",
187
- value: b,
188
- placeholder: e.max !== void 0 ? String(e.max) : "Max",
189
- min: e.min,
190
- max: e.max,
191
- step: e.step,
192
- onChange: (a) => i(a.target.value),
193
- "aria-label": `${e.label} maximum`,
194
- className: `${$} mapui:w-1/2`
195
- }
196
- )
197
- ] })
198
- ) : e.inputMode === "slider" ? (
199
- /* Slider */
200
- /* @__PURE__ */ h("div", { className: "mapui:flex mapui:items-center mapui:gap-2", children: [
201
- /* @__PURE__ */ m(
202
- "input",
203
- {
204
- type: "range",
205
- value: r !== "" ? r : e.min ?? 0,
206
- min: e.min ?? 0,
207
- max: e.max ?? 100,
208
- step: e.step ?? 1,
209
- onChange: (a) => o(a.target.value),
210
- "aria-label": e.label,
211
- className: "mapui:flex-1"
212
- }
213
- ),
214
- /* @__PURE__ */ m("span", { className: "mapui:text-xs mapui:text-gray-600 mapui:min-w-12 mapui:whitespace-nowrap mapui:text-right", children: r !== "" ? r : e.min ?? 0 })
215
- ] })
216
- ) : (
217
- /* Number input */
218
- /* @__PURE__ */ m(
219
- "input",
220
- {
221
- id: N,
222
- type: "number",
223
- value: r,
224
- placeholder: e.placeholder ?? "",
225
- min: e.min,
226
- max: e.max,
227
- step: e.step,
228
- onChange: (a) => o(a.target.value),
229
- className: $
230
- }
231
- )
232
- )
233
- ] });
234
- }
235
- function q(e) {
236
- return e === void 0 || e === "" || e === null ? !1 : typeof e == "object" && "start" in e && "end" in e ? e.start !== "" || e.end !== "" : !0;
237
- }
238
- function _({
239
- layers: e,
240
- activeFilters: t,
241
- onFilterChange: u,
242
- onClearFilters: d,
243
- autocompleteSuggestions: N = {},
244
- onFetchSuggestions: l,
245
- className: y = "",
246
- hideTitle: f
247
- }) {
248
- const c = S(
249
- () => e.filter((p) => {
250
- var o;
251
- return (o = p.search) == null ? void 0 : o.fields.length;
252
- }),
253
- [e]
254
- );
255
- return I(() => {
256
- if (l)
257
- for (const p of c)
258
- for (const o of p.search.fields)
259
- o.type === "select" && o.prefetch && l(p.id, o.property, "", { prefetch: !0 });
260
- }, [c, l]), c.length === 0 ? /* @__PURE__ */ h("div", { className: `mapui:flex mapui:flex-col mapui:gap-1 ${y}`.trim(), children: [
261
- !f && /* @__PURE__ */ m("h3", { className: "mapui:m-0 mapui:mb-2 mapui:text-sm mapui:font-semibold mapui:text-gray-700", children: "Search & Filter" }),
262
- /* @__PURE__ */ m("p", { className: "mapui:m-0 mapui:text-xs mapui:text-gray-500", children: "No searchable layers configured." })
263
- ] }) : /* @__PURE__ */ h("div", { className: `mapui:flex mapui:flex-col mapui:gap-3 ${y}`.trim(), children: [
264
- !f && /* @__PURE__ */ m("h3", { className: "mapui:m-0 mapui:mb-2 mapui:text-sm mapui:font-semibold mapui:text-gray-700", children: "Search & Filter" }),
265
- c.map((p) => {
266
- const o = t[p.id] ?? {}, g = Object.values(o).some(q);
267
- return /* @__PURE__ */ h("div", { className: "mapui:flex mapui:flex-col mapui:gap-3 mapui:border-b mapui:border-gray-100 mapui:pb-3 last:mapui:border-0", children: [
268
- /* @__PURE__ */ h("div", { className: "mapui:flex mapui:items-center mapui:justify-between", children: [
269
- /* @__PURE__ */ m("span", { className: "mapui:text-sm mapui:font-medium mapui:text-gray-600", children: p.label }),
270
- g && /* @__PURE__ */ m(
271
- "button",
272
- {
273
- type: "button",
274
- onClick: () => d(p.id),
275
- className: "mapui:cursor-pointer mapui:border-none mapui:bg-transparent mapui:p-0 mapui:text-xs mapui:text-blue-600 hover:mapui:text-blue-800",
276
- children: "Clear"
277
- }
278
- )
279
- ] }),
280
- p.search.fields.map((i) => {
281
- const r = o[i.property], v = `${p.id}:${i.property}`, b = `search-${p.id}-${i.property}`;
282
- return /* @__PURE__ */ h("div", { className: "mapui:flex mapui:flex-col mapui:gap-1", children: [
283
- /* @__PURE__ */ m("label", { htmlFor: b, className: "mapui:text-xs mapui:text-gray-500", children: i.label }),
284
- i.type === "text" && i.autocomplete ? /* @__PURE__ */ m(
285
- V,
286
- {
287
- id: b,
288
- value: r ?? "",
289
- onChange: (a) => u(p.id, i.property, a || void 0),
290
- suggestions: [.../* @__PURE__ */ new Set([
291
- ...N[v] ?? [],
292
- ...i.options ?? []
293
- ])],
294
- onQueryChange: (a) => l == null ? void 0 : l(p.id, i.property, a, { prefetch: i.prefetch }),
295
- placeholder: i.placeholder ?? ""
296
- }
297
- ) : i.type === "text" ? /* @__PURE__ */ m(
298
- "input",
299
- {
300
- id: b,
301
- type: "text",
302
- value: r ?? "",
303
- placeholder: i.placeholder ?? "",
304
- onChange: (a) => u(p.id, i.property, a.target.value || void 0),
305
- className: "mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500"
306
- }
307
- ) : i.type === "datetime" && i.range ? /* @__PURE__ */ m(
308
- R,
309
- {
310
- id: b,
311
- startValue: r && typeof r == "object" && "start" in r ? r.start : "",
312
- endValue: r && typeof r == "object" && "end" in r ? r.end : "",
313
- onStartChange: (a) => u(p.id, i.property, {
314
- start: a,
315
- end: r && typeof r == "object" && "end" in r ? r.end : ""
316
- }),
317
- onEndChange: (a) => u(p.id, i.property, {
318
- start: r && typeof r == "object" && "start" in r ? r.start : "",
319
- end: a
320
- })
321
- }
322
- ) : i.type === "datetime" ? /* @__PURE__ */ m(
323
- "input",
324
- {
325
- id: b,
326
- type: "datetime-local",
327
- value: r ?? "",
328
- onChange: (a) => u(p.id, i.property, a.target.value || void 0),
329
- className: "mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500"
330
- }
331
- ) : i.type === "number" ? /* @__PURE__ */ m(
332
- P,
333
- {
334
- id: b,
335
- field: i,
336
- value: r,
337
- onChange: (a) => u(p.id, i.property, a)
338
- }
339
- ) : i.type === "select" ? (() => {
340
- const a = i, x = N[v] ?? [], w = a.options ?? [], n = [.../* @__PURE__ */ new Set([...x, ...w])];
341
- return /* @__PURE__ */ h(
342
- "select",
343
- {
344
- id: b,
345
- value: r ?? "",
346
- onChange: (s) => u(p.id, i.property, s.target.value || void 0),
347
- className: "mapui:rounded mapui:border mapui:border-gray-300 mapui:px-2 mapui:py-1 mapui:text-sm mapui:outline-none focus:mapui:border-blue-500 focus:mapui:ring-1 focus:mapui:ring-blue-500",
348
- children: [
349
- /* @__PURE__ */ m("option", { value: "", children: i.placeholder ?? "Select..." }),
350
- n.map((s) => /* @__PURE__ */ m("option", { value: s, children: s }, s))
351
- ]
352
- }
353
- );
354
- })() : null
355
- ] }, i.property);
356
- })
357
- ] }, p.id);
358
- })
359
- ] });
360
- }
361
- export {
362
- _ as S
363
- };