@ogc-maps/storybook-components 0.8.0 → 0.9.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/dist/Legend-CwaZA84A.js +273 -0
- package/dist/components/Legend/Legend.d.ts.map +1 -1
- package/dist/components/Legend/index.js +1 -1
- package/dist/components/LegendEditor/LegendEditor.d.ts.map +1 -1
- package/dist/{index-RzZtWlUz.js → index-UmK2u6Yd.js} +187 -185
- package/dist/main.js +194 -168
- package/dist/schemas/config.d.ts +36 -0
- 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.js +1 -1
- package/package.json +1 -1
- package/dist/Legend-BiRyrZL1.js +0 -239
|
@@ -0,0 +1,273 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../../src/components/Legend/Legend.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../../src/components/Legend/Legend.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAA6B,MAAM,aAAa,CAAC;AAE1E,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA8TD,wBAAgB,MAAM,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,WAAW,kDA2F1F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendEditor/LegendEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAW1E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,KAAK,IAAI,CAAC;IACrD,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAeD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"LegendEditor.d.ts","sourceRoot":"","sources":["../../../src/components/LegendEditor/LegendEditor.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAW1E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,KAAK,IAAI,CAAC;IACrD,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAeD,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,iBAAiB,2CAyQ1E"}
|