geostyler
Version:
Framework for styling geodata
68 lines (67 loc) • 1.48 kB
JavaScript
import { jsx as n } from "react/jsx-runtime";
/* empty css */
import "ol/ol.css";
import { Tabs as u } from "antd";
import { Editor as b } from "../Editor/Editor.js";
import y from "../../../Util/SymbolizerUtil.js";
const K = ({
editorProps: l,
symbolizers: o,
onSymbolizersChange: i,
iconLibraries: c,
...a
}) => {
const m = () => {
const e = o.length > 0 ? o[0].kind : void 0, t = y.generateSymbolizer(e);
i && i([...o, t]);
}, d = (e) => {
const t = [...o];
t.splice(e, 1), i && i(t);
}, s = (e, t) => {
const r = [...o];
r[t] = e, i && i(r);
}, f = (e, t) => {
if (t === "add")
m();
else
try {
if (o.length === 1)
return;
const r = parseInt(e.toString(), 10);
d(r);
} catch {
console.log("Could not remove symbolizer. Invalid key.");
}
}, p = o.map((e, t) => ({
className: "gs-symbolizer-multi-editor-tab",
key: t.toString(),
closable: !0,
label: `${e.kind} (${t})`,
children: /* @__PURE__ */ n(
b,
{
symbolizer: e,
onSymbolizerChange: (r) => {
s(r, t);
},
iconLibraries: c,
...l
}
)
}));
return /* @__PURE__ */ n(
u,
{
className: "gs-symbolizer-multi-editor",
type: "editable-card",
defaultActiveKey: "0",
items: p,
animated: !1,
onEdit: f,
...a
}
);
};
export {
K as MultiEditor
};