@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
@@ -5,14 +5,14 @@ function x({
5
5
  icon: t,
6
6
  label: i,
7
7
  defaultCollapsed: l = !0,
8
- collapsed: u,
9
- onToggle: p,
8
+ collapsed: p,
9
+ onToggle: u,
10
10
  children: o,
11
11
  className: n = ""
12
12
  }) {
13
- const [c, d] = h(l), m = u !== void 0 ? u : c, s = () => {
13
+ const [c, d] = h(l), m = p !== void 0 ? p : c, s = () => {
14
14
  const r = !m;
15
- p ? p(r) : d(r);
15
+ u ? u(r) : d(r);
16
16
  };
17
17
  return /* @__PURE__ */ e("div", { className: `mapui:relative mapui:w-10 mapui:h-10 ${n}`, children: [
18
18
  /* @__PURE__ */ a(
@@ -44,7 +44,7 @@ function x({
44
44
  }
45
45
  )
46
46
  ] }),
47
- /* @__PURE__ */ a("div", { children: o })
47
+ /* @__PURE__ */ a("div", { className: "mapui:p-2", children: o })
48
48
  ] })
49
49
  ] });
50
50
  }
@@ -0,0 +1,25 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ function m({
3
+ onExport: r,
4
+ loading: a = !1,
5
+ disabled: o = !1,
6
+ className: t = ""
7
+ }) {
8
+ const i = o || a, p = [
9
+ "mapui:inline-flex mapui:items-center mapui:gap-1.5 mapui:rounded mapui:border mapui:border-gray-300",
10
+ "mapui:bg-white mapui:px-3 mapui:py-1.5 mapui:text-sm mapui:text-gray-700 mapui:transition-colors",
11
+ i ? "mapui:cursor-not-allowed mapui:opacity-50" : "mapui:cursor-pointer hover:mapui:bg-gray-50 hover:mapui:border-gray-400"
12
+ ].join(" ");
13
+ return /* @__PURE__ */ e(
14
+ "button",
15
+ {
16
+ className: `${p} ${t}`.trim(),
17
+ disabled: i,
18
+ onClick: () => !i && r(),
19
+ children: a ? "Exporting..." : "Export"
20
+ }
21
+ );
22
+ }
23
+ export {
24
+ m as E
25
+ };
@@ -0,0 +1,275 @@
1
+ import { jsxs as o, jsx as a, Fragment as b } from "react/jsx-runtime";
2
+ import { useState as N } from "react";
3
+ import { BsArrowsAngleContract as C, BsArrowsAngleExpand as A } from "react-icons/bs";
4
+ import { MdOutlineKeyboardArrowDown as k, MdOutlineKeyboardArrowRight as v } 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(i) {
12
+ var s, p;
13
+ const e = (s = i.styles) == null ? void 0 : s[0];
14
+ if (!e) return 1;
15
+ const n = E[e.type];
16
+ if (!n) return 1;
17
+ const t = (p = e.paint) == null ? void 0 : p[n];
18
+ return typeof t == "number" ? t : 1;
19
+ }
20
+ function w({ color: i, shape: e }) {
21
+ const n = e ?? "square";
22
+ let t;
23
+ return n === "circle" ? t = /* @__PURE__ */ a(
24
+ "span",
25
+ {
26
+ className: "mapui:inline-block mapui:h-3 mapui:w-3 mapui:rounded-full",
27
+ style: { backgroundColor: i }
28
+ }
29
+ ) : n === "line" ? t = /* @__PURE__ */ a(
30
+ "span",
31
+ {
32
+ className: "mapui:inline-block mapui:h-0.5 mapui:w-4 mapui:rounded-full",
33
+ style: { backgroundColor: i }
34
+ }
35
+ ) : t = /* @__PURE__ */ a(
36
+ "span",
37
+ {
38
+ className: "mapui:inline-block mapui:h-3 mapui:w-3 mapui:rounded-sm",
39
+ style: { backgroundColor: i }
40
+ }
41
+ ), /* @__PURE__ */ a("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: t });
42
+ }
43
+ function L(i) {
44
+ return `linear-gradient(to right, ${i.map((e, n) => `${e.color} ${n / i.length * 100}% ${(n + 1) / i.length * 100}%`).join(", ")})`;
45
+ }
46
+ function B(i) {
47
+ return `linear-gradient(to right, ${i.map((e) => e.color).join(", ")})`;
48
+ }
49
+ function y(i) {
50
+ const e = i.trim();
51
+ let n, t, s;
52
+ if (/^#[0-9a-f]{3}$/i.test(e))
53
+ n = parseInt(e[1] + e[1], 16), t = parseInt(e[2] + e[2], 16), s = parseInt(e[3] + e[3], 16);
54
+ else if (/^#[0-9a-f]{6}$/i.test(e))
55
+ n = parseInt(e.slice(1, 3), 16), t = parseInt(e.slice(3, 5), 16), s = parseInt(e.slice(5, 7), 16);
56
+ else
57
+ return null;
58
+ const p = n / 255, r = t / 255, d = s / 255, h = Math.max(p, r, d), g = Math.min(p, r, d), f = h - g;
59
+ if (f === 0) return 0;
60
+ let l = 0;
61
+ return h === p ? l = ((r - d) / f + 6) % 6 : h === r ? l = (d - p) / f + 2 : l = (p - r) / f + 4, l * 60;
62
+ }
63
+ function j(i) {
64
+ return [...i].sort((e, n) => {
65
+ const t = y(e.color), s = y(n.color);
66
+ return t === null && s === null ? 0 : t === null ? 1 : s === null ? -1 : t - s;
67
+ });
68
+ }
69
+ function S({ legend: i, label: e, hasArrowColumn: n }) {
70
+ const { entries: t } = i, s = n ? /* @__PURE__ */ a("span", { className: "mapui:w-5 mapui:shrink-0" }) : null;
71
+ return t.length === 1 ? /* @__PURE__ */ o("div", { className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0", children: [
72
+ s,
73
+ /* @__PURE__ */ a(w, { color: t[0].color, shape: t[0].shape }),
74
+ /* @__PURE__ */ a("span", { className: "mapui:text-gray-700 mapui:truncate", children: t[0].label || e })
75
+ ] }) : /* @__PURE__ */ o("div", { children: [
76
+ /* @__PURE__ */ a("div", { className: "mapui:mb-1 mapui:text-xs mapui:font-medium mapui:text-gray-600", children: e }),
77
+ /* @__PURE__ */ a("ul", { className: "mapui:m-0 mapui:list-none mapui:space-y-1 mapui:p-0 mapui:pl-1", children: t.map((p, r) => /* @__PURE__ */ o(
78
+ "li",
79
+ {
80
+ className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0",
81
+ children: [
82
+ s,
83
+ /* @__PURE__ */ a(w, { color: p.color, shape: p.shape }),
84
+ /* @__PURE__ */ a("span", { className: "mapui:text-gray-700 mapui:truncate", children: p.label })
85
+ ]
86
+ },
87
+ `${p.label}-${r}`
88
+ )) })
89
+ ] });
90
+ }
91
+ function M({
92
+ legend: i,
93
+ label: e,
94
+ expanded: n,
95
+ onToggle: t,
96
+ hasArrowColumn: s
97
+ }) {
98
+ const { entries: p } = i, r = i.showColorBar !== !1, d = i.showDisclosureArrow !== !1, h = i.showLabelsCollapsed ?? !1, g = p.filter((u, c, x) => x.findIndex(($) => $.color === u.color) === c), f = j(g), l = /* @__PURE__ */ a("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: /* @__PURE__ */ a("span", { className: "mapui:text-gray-400", children: n ? /* @__PURE__ */ a(k, {}) : /* @__PURE__ */ a(v, {}) }) }), m = /* @__PURE__ */ o(b, { children: [
99
+ s && (d ? l : /* @__PURE__ */ a("span", { className: "mapui:w-5 mapui:shrink-0" })),
100
+ r ? /* @__PURE__ */ a(
101
+ "div",
102
+ {
103
+ className: "mapui:h-3 mapui:w-5 mapui:rounded-sm mapui:shrink-0",
104
+ style: { background: L(f) }
105
+ }
106
+ ) : !s && d ? l : /* @__PURE__ */ a("span", { className: "mapui:w-5 mapui:shrink-0" }),
107
+ /* @__PURE__ */ a("span", { className: "mapui:truncate", children: e })
108
+ ] });
109
+ return /* @__PURE__ */ o("div", { children: [
110
+ d ? /* @__PURE__ */ a(
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: t,
116
+ "aria-expanded": n,
117
+ children: m
118
+ }
119
+ ) : /* @__PURE__ */ a("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: m }),
120
+ (n || h) && /* @__PURE__ */ a("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${d ? " mapui:ml-7" : ""}`, children: p.map((u, c) => /* @__PURE__ */ o(
121
+ "li",
122
+ {
123
+ className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0",
124
+ children: [
125
+ /* @__PURE__ */ a(w, { color: u.color, shape: u.shape }),
126
+ /* @__PURE__ */ a("span", { className: "mapui:text-gray-700 mapui:truncate mapui:text-xs", children: u.label })
127
+ ]
128
+ },
129
+ `${u.label}-${c}`
130
+ )) })
131
+ ] });
132
+ }
133
+ function D({
134
+ legend: i,
135
+ label: e,
136
+ expanded: n,
137
+ onToggle: t,
138
+ hasArrowColumn: s
139
+ }) {
140
+ const { entries: p, gradientProperty: r } = i, d = i.showColorBar !== !1, h = i.showDisclosureArrow !== !1, g = /* @__PURE__ */ a("span", { className: "mapui:inline-flex mapui:items-center mapui:justify-center mapui:w-5 mapui:shrink-0", children: /* @__PURE__ */ a("span", { className: "mapui:text-gray-400", children: n ? /* @__PURE__ */ a(k, {}) : /* @__PURE__ */ a(v, {}) }) }), f = /* @__PURE__ */ o(b, { children: [
141
+ s && (h ? g : /* @__PURE__ */ a("span", { className: "mapui:w-5 mapui:shrink-0" })),
142
+ d ? /* @__PURE__ */ a(
143
+ "div",
144
+ {
145
+ className: "mapui:h-3 mapui:w-5 mapui:rounded-sm mapui:shrink-0",
146
+ style: { background: B(p) }
147
+ }
148
+ ) : !s && h ? g : /* @__PURE__ */ a("span", { className: "mapui:w-5 mapui:shrink-0" }),
149
+ /* @__PURE__ */ a("span", { className: "mapui:truncate", children: e })
150
+ ] });
151
+ return /* @__PURE__ */ o("div", { children: [
152
+ h ? /* @__PURE__ */ a(
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: t,
158
+ "aria-expanded": n,
159
+ children: f
160
+ }
161
+ ) : /* @__PURE__ */ a("div", { className: "mapui:flex mapui:items-center mapui:gap-2 mapui:text-gray-700 mapui:text-sm mapui:font-medium", children: f }),
162
+ n && /* @__PURE__ */ o(b, { children: [
163
+ r && /* @__PURE__ */ a("div", { className: `mapui:mt-1 mapui:text-xs mapui:font-medium mapui:text-gray-600${h ? " mapui:ml-7" : ""}`, children: r }),
164
+ /* @__PURE__ */ a("ul", { className: `mapui:m-0 mapui:mt-1 mapui:list-none mapui:space-y-1 mapui:p-0${h ? " mapui:ml-7" : ""}`, children: p.map((l, m) => /* @__PURE__ */ o(
165
+ "li",
166
+ {
167
+ className: "mapui:flex mapui:items-center mapui:gap-2 mapui:min-w-0",
168
+ children: [
169
+ /* @__PURE__ */ a(w, { color: l.color, shape: l.shape }),
170
+ /* @__PURE__ */ a("span", { className: "mapui:text-gray-700 mapui:truncate mapui:text-xs", children: l.label })
171
+ ]
172
+ },
173
+ `${l.label}-${m}`
174
+ )) })
175
+ ] })
176
+ ] });
177
+ }
178
+ function T({
179
+ layerId: i,
180
+ opacity: e,
181
+ onChange: n,
182
+ hasArrowColumn: t
183
+ }) {
184
+ return /* @__PURE__ */ o("div", { className: `mapui:flex mapui:items-center mapui:gap-1.5 mapui:mt-0.5 ${t ? "mapui:ml-14" : "mapui:ml-7"}`, children: [
185
+ /* @__PURE__ */ a(
186
+ "input",
187
+ {
188
+ type: "range",
189
+ min: 0,
190
+ max: 1,
191
+ step: 0.01,
192
+ value: e,
193
+ onChange: (s) => n(i, parseFloat(s.target.value)),
194
+ className: "range-sm mapui:w-14"
195
+ }
196
+ ),
197
+ /* @__PURE__ */ o("span", { className: "mapui:text-[9px] mapui:text-gray-400 mapui:w-6 mapui:text-right mapui:tabular-nums", children: [
198
+ Math.round(e * 100),
199
+ "%"
200
+ ] })
201
+ ] });
202
+ }
203
+ function F({ layers: i, visibleLayerIds: e, onOpacityChange: n, className: t }) {
204
+ const [s, p] = N(/* @__PURE__ */ new Set()), [r, d] = N(!1), h = i.filter((m) => e.includes(m.id));
205
+ function g(m) {
206
+ p((u) => {
207
+ const c = new Set(u);
208
+ return c.has(m) ? c.delete(m) : c.add(m), c;
209
+ });
210
+ }
211
+ const f = h.filter((m) => m.legend !== void 0);
212
+ if (f.length === 0)
213
+ return null;
214
+ const l = f.some((m) => {
215
+ const u = m.legend, c = u.displayMode ?? "simple", x = u.showDisclosureArrow !== !1;
216
+ return c === "gradient" || c === "categorical" ? x && u.showColorBar !== !1 : !1;
217
+ });
218
+ return /* @__PURE__ */ o(
219
+ "div",
220
+ {
221
+ className: `mapui:rounded-lg mapui:bg-white mapui:p-3 mapui:shadow-md mapui:text-sm${t ? ` ${t}` : ""}`,
222
+ children: [
223
+ /* @__PURE__ */ o("div", { className: "mapui:flex mapui:items-center mapui:justify-between mapui:mb-2", children: [
224
+ /* @__PURE__ */ a("h3", { className: "mapui:m-0 mapui:text-xs mapui:font-semibold mapui:uppercase mapui:tracking-wide mapui:text-gray-500", children: "Legend" }),
225
+ n && /* @__PURE__ */ a(
226
+ "button",
227
+ {
228
+ type: "button",
229
+ 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",
230
+ onClick: () => d((m) => !m),
231
+ "aria-label": r ? "Collapse legend" : "Expand legend",
232
+ children: r ? /* @__PURE__ */ a(C, {}) : /* @__PURE__ */ a(A, {})
233
+ }
234
+ )
235
+ ] }),
236
+ /* @__PURE__ */ a("ul", { className: `mapui:m-0 mapui:list-none mapui:p-0 ${r ? "mapui:space-y-1.5" : "mapui:space-y-2"}`, children: f.map((m) => {
237
+ const u = m.legend, c = u.displayMode ?? "simple", x = r || s.has(m.id);
238
+ return /* @__PURE__ */ o("li", { children: [
239
+ c === "categorical" ? /* @__PURE__ */ a(
240
+ M,
241
+ {
242
+ legend: u,
243
+ label: m.label,
244
+ expanded: x,
245
+ onToggle: () => g(m.id),
246
+ hasArrowColumn: l
247
+ }
248
+ ) : c === "gradient" ? /* @__PURE__ */ a(
249
+ D,
250
+ {
251
+ legend: u,
252
+ label: m.label,
253
+ expanded: x,
254
+ onToggle: () => g(m.id),
255
+ hasArrowColumn: l
256
+ }
257
+ ) : /* @__PURE__ */ a(S, { legend: u, label: m.label, hasArrowColumn: l }),
258
+ r && n && /* @__PURE__ */ a(
259
+ T,
260
+ {
261
+ layerId: m.id,
262
+ opacity: I(m),
263
+ onChange: n,
264
+ hasArrowColumn: l
265
+ }
266
+ )
267
+ ] }, m.id);
268
+ }) })
269
+ ]
270
+ }
271
+ );
272
+ }
273
+ export {
274
+ F as L
275
+ };