geostyler
Version:
Framework for styling geodata
160 lines (159 loc) • 4.44 kB
JavaScript
import { jsxs as G, jsx as l } from "react/jsx-runtime";
import { useState as R } from "react";
import { Select as x, Form as T, Tabs as k } from "antd";
import { isGrayChannel as s, isRgbChannel as g } from "geostyler-style";
import { ChannelField as C } from "../Field/ChannelField/ChannelField.js";
import O from "lodash-es/get.js";
import { useGeoStylerComposition as q, useGeoStylerLocale as z } from "../../../context/GeoStylerContext/GeoStylerContext.js";
import { getFormItemConfig as A } from "../../../Util/FormItemUtil.js";
const E = x.Option, W = (I) => {
const $ = q("RasterChannelEditor"), j = { ...I, ...$ }, {
channelSelection: e,
channelSelectionField: a,
contrastEnhancementTypes: o,
onChange: y,
sourceChannelNames: i
} = j, r = z("RasterChannelEditor"), w = e ? s(e) ? "gray" : "rgb" : (a == null ? void 0 : a.default) || "rgb", [b, B] = R(w), K = e && s(e) ? "gray" : "red", [N, F] = R(K), _ = (n) => {
B(n);
}, c = (n) => O(r, `${n}BandLabel`) ? O(r, `${n}BandLabel`) : n, h = (n, d) => {
let t;
const v = `${n}Channel`;
!e || s(e) && n !== "gray" || g(e) && n === "gray" ? (t = {}, t[v] = d) : (t = structuredClone(e), t[v] = d), y && y(t);
}, m = (n) => {
F(n);
};
let u;
e && g(e) && e.redChannel && (u = e.redChannel);
let f;
e && g(e) && e.greenChannel && (f = e.greenChannel);
let p;
e && g(e) && e.blueChannel && (p = e.blueChannel);
let S;
e && s(e) && e.grayChannel && (S = e.grayChannel);
const L = A();
return /* @__PURE__ */ G("div", { children: [
/* @__PURE__ */ l(
T.Item,
{
...L,
children: /* @__PURE__ */ l("span", { children: r.titleLabel })
}
),
(a == null ? void 0 : a.visibility) === !1 ? null : /* @__PURE__ */ l(
T.Item,
{
...L,
label: r.channelSelectionLabel,
children: /* @__PURE__ */ G(
x,
{
className: "editor-field rgb-or-gray-field",
allowClear: !0,
value: b,
onChange: _,
children: [
/* @__PURE__ */ l(
E,
{
value: "rgb",
children: r.channelSelectionRgbLabel
},
"rgb"
),
/* @__PURE__ */ l(
E,
{
value: "gray",
children: r.channelSelectionGrayLabel
},
"gray"
)
]
}
)
}
),
b ? b === "rgb" ? /* @__PURE__ */ l(
k,
{
onChange: m,
type: "card",
activeKey: N,
items: [
{
key: "red",
label: c("red"),
children: /* @__PURE__ */ l(
C,
{
channel: u,
contrastEnhancementTypes: o,
onChange: (n) => {
h("red", n);
},
sourceChannelNames: i
}
)
},
{
key: "green",
label: c("green"),
children: /* @__PURE__ */ l(
C,
{
channel: f,
contrastEnhancementTypes: o,
onChange: (n) => {
h("green", n);
},
sourceChannelNames: i
}
)
},
{
key: "blue",
label: c("blue"),
children: /* @__PURE__ */ l(
C,
{
channel: p,
contrastEnhancementTypes: o,
onChange: (n) => {
h("blue", n);
},
sourceChannelNames: i
}
)
}
]
}
) : /* @__PURE__ */ l(
k,
{
onChange: m,
type: "card",
activeKey: "gray",
items: [
{
key: "gray",
label: c("gray"),
children: /* @__PURE__ */ l(
C,
{
channel: S,
contrastEnhancementTypes: o,
onChange: (n) => {
h("gray", n);
},
sourceChannelNames: i
}
)
}
]
}
) : null
] });
};
export {
W as RasterChannelEditor
};