geostyler
Version:
Framework for styling geodata
54 lines (53 loc) • 1.34 kB
JavaScript
import { jsx as l, jsxs as S } from "react/jsx-runtime";
import { useState as h } from "react";
import { Select as a } from "antd";
import { UploadButton as v } from "../../UploadButton/UploadButton.js";
import w from "../../../Util/FileUtil.js";
import { useGeoStylerLocale as g } from "../../../context/GeoStylerContext/GeoStylerContext.js";
const x = a.Option, q = ({
parsers: n,
onStyleRead: m = () => {
}
}) => {
const f = g("StyleLoader"), [e, d] = h(), u = async (t) => {
if (!e)
return;
const o = t.file;
let r;
try {
r = await w.readFile(o);
} catch (c) {
return t.onError(c), c;
}
const {
output: s,
errors: i
} = await e.readStyle(r);
m(s), (i == null ? void 0 : i.length) > 0 ? i.forEach(t.onError) : t.onSuccess(s);
}, p = n.map(
(t) => /* @__PURE__ */ l(x, { value: t.title, children: t.title }, t.title)
), y = (t) => {
const o = n.find((r) => r.title === t);
o && d(o);
};
return /* @__PURE__ */ S("div", { className: e ? "gs-dataloader-right" : "", children: [
f.label,
/* @__PURE__ */ l(
a,
{
style: { width: 300 },
onSelect: y,
children: p
}
),
e ? /* @__PURE__ */ l(
v,
{
customRequest: u
}
) : null
] });
};
export {
q as StyleLoader
};