@arcgis/map-components
Version:
ArcGIS Map Components
91 lines (90 loc) • 2.79 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { substitute as o, formatNumber as l } from "@arcgis/core/intl.js";
import { stripHTML as s } from "@arcgis/core/applications/Components/stringUtils.js";
function d(r, t) {
return t;
}
function u(r, t, i) {
if (!t)
return;
if (typeof t == "number")
return t;
if (typeof t == "string")
return s(t);
if ("value" in t || "unit" in t)
return o(r.dotValue ?? "", t);
if ("colorName" in t && "bandName" in t) {
const n = r[t.colorName], a = r[t.bandName] || t.bandName;
return `${n}: ${a}`;
}
if ("showCount" in t)
return t.showCount ? r.clusterCountTitle : void 0;
let e = null;
return d(t, i) ? e = t.ratioPercentTotal ? "showRatioPercentTotal" : t.ratioPercent ? "showRatioPercent" : t.ratio ? "showRatio" : t.normField ? "showNormField" : t.field ? "showField" : null : c(t, i) && (e = t.normField ? "showNormField" : t.normByPct ? "showNormPct" : t.field ? "showField" : null), e ? o(e === "showField" ? "{field}" : r[e] ?? "", {
field: t.field,
normField: t.normField
}) : void 0;
}
function c(r, t) {
return !t;
}
function h(r, t) {
if (!r.title || typeof r.title == "string")
return r.title;
const i = r.type === "color-ramp" || r.type === "opacity-ramp", e = r.title, n = u(t, e, i);
return c(e, i) && e.title ? `${e.title} (${n})` : n;
}
const m = /^-?(\d+(\.\d+)?)\s*((px)|(pt))?$/iu;
function y(r, t, i) {
switch (t) {
case "heatmap-ramp":
return (i[r.label] || r.label) ?? null;
case "stretch-ramp":
const e = "value" in r ? r.value : void 0, n = r.label ? i[r.label] : "";
return n ? `${n}: ${typeof e == "string" ? e : l(e ?? 0, {
style: "decimal",
notation: e?.toString().toLowerCase().includes("e") ? "scientific" : "standard"
})}` : "";
default:
return r.label ?? null;
}
}
function w(r, t) {
return !!(t && t === "Stretched" && "version" in r && typeof r.version == "number" && r.version >= 10.3 && r.declaredClass === "esri.layers.ImageryLayer");
}
function N(r) {
return r ? r / 72 * 96 : 0;
}
function b(r) {
return r ? r * 72 / 96 : 0;
}
function v(r) {
if (typeof r == "string") {
const t = r.match(m);
if (t) {
const i = Number(t[1]), e = t[3]?.toLowerCase(), n = r.startsWith("-"), a = e === "px" ? b(i) : i;
return n ? -a : a;
}
return null;
}
return r;
}
function L(r, t) {
const i = u(r, t, !1), e = i ? r.previewTemplateAriaLabel : r.previewAriaLabel;
return o(e ?? "", { label: i });
}
function F(r, t) {
if (!t || !r)
return;
(r.querySelector("svg") ?? r.querySelector("canvas") ?? r).setAttribute("aria-label", t);
}
export {
y as a,
h as b,
u as c,
L as g,
w as i,
N as p,
F as s,
v as t
};