@arcgis/coding-components
Version:
ArcGIS Coding Components
84 lines (83 loc) • 4.36 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
import { html as a } from "lit";
import "@arcgis/lumina";
import { B as y, v as p, M as $ } from "./arcade-executor.js";
import { uncapitalize as m, setValuesInString as v } from "@arcgis/toolkit/string";
import { s as g } from "./fields.js";
import "@arcgis/toolkit/function";
import { i as S, a as f, S as h, D as o, b as k, G as x } from "./debugger-value-styles.js";
const i = {
lines: !0,
selectionMode: "none",
scale: "s",
oncalciteTreeSelect: (e) => e.currentTarget.selectedItems.forEach((t) => t.selected = !1)
}, d = {
onClick: (e) => {
const t = e.currentTarget;
t.expanded = !t.expanded;
}
}, A = ({ arcadeResult: e, t9nStrings: t }) => {
const r = e.value ?? [], c = Math.max(r.length - $, 0);
return a`<bdi>${`${m(e.type)}(${r.length ?? 0})`}</bdi>${c > 0 ? a`<span> ${v(t.showingfirstitemsformat, {
count: $.toString()
})}</span>` : null}`;
}, C = ({ value: e, subtree: t, t9nStrings: r }) => {
const c = e.geometry?.();
return a`<calcite-tree slot=${"children"} .lines=${i.lines} .selectionMode=${i.selectionMode} .scale=${i.scale} @calciteTreeSelect=${i.oncalciteTreeSelect}>${e.keys().map((l) => {
const s = p(e.field(l));
return e.arcadeDeclaredClass === "esri.arcade.Feature" && s.type === "geometry" ? null : u({ arcadeResult: s, name: l, t9nStrings: r });
})}${c ? u({ arcadeResult: { type: "geometry", value: c }, name: "geometry", t9nStrings: r }) : null}</calcite-tree>`;
}, B = ({ arcadeResult: e, t9nStrings: t }) => a`<div class="value-type"><bdi>${m(e.type)}:</bdi>${e.features.length >= y ? a`<span> ${v(t.showingfirstitemsformat, {
count: y.toString()
})}</span>` : null}</div>`, D = ({ items: e, subtree: t, arrayLength: r = e.length, t9nStrings: c }) => a`<calcite-tree slot=${"children"} .lines=${i.lines} .selectionMode=${i.selectionMode} .scale=${i.scale} @calciteTreeSelect=${i.oncalciteTreeSelect}>${e.map((l, s) => {
const n = p(l);
return u({ arcadeResult: n, name: s, expanded: !t, t9nStrings: c });
})}${u({ arcadeResult: { type: "number", value: r }, name: "length", isMetadata: !0, t9nStrings: c })}</calcite-tree>`, u = ({ arcadeResult: e, name: t, isMetadata: r = !1, expanded: c, t9nStrings: l }) => {
switch (e.type) {
case "null":
case "unknown":
case "text":
case "number":
case "date":
case "dateOnly":
case "time":
case "boolean":
const { type: s, value: n } = f(e);
return a`<calcite-tree-item><div class="tree-item-label">${o({ name: t, isMetadata: r })}${h({ type: s, value: n })}</div></calcite-tree-item>`;
case "array": {
const b = e.value ?? [], T = b.slice(0, $);
return a`<calcite-tree-item .expanded=${c} @click=${d.onClick}><div class="tree-item-label">${o({ name: t, isMetadata: r })}${A({ arcadeResult: e, t9nStrings: l })}</div>${D({ items: T, arrayLength: b.length, subtree: !0, t9nStrings: l })}</calcite-tree-item>`;
}
case "geometry":
return a`<calcite-tree-item .expanded=${c} @click=${d.onClick}><div class="tree-item-label">${o({ name: t, isMetadata: r })}<bdi>${m(e.type)}</bdi></div>${x({ value: e.value, subtree: !0 })}</calcite-tree-item>`;
case "attachment":
return a`<calcite-tree-item .expanded=${c} @click=${d.onClick}><div class="tree-item-label">${o({ name: t, isMetadata: r })}<bdi>${m(e.type)}</bdi></div>${k({ obj: e.value.castAsJson(), subtree: !0 })}</calcite-tree-item>`;
case "feature":
case "dictionary":
case "portal":
return a`<calcite-tree-item .expanded=${c} @click=${d.onClick}><div class="tree-item-label">${o({ name: t, isMetadata: r })}<bdi>${m(e.type)}</bdi></div>${C({ value: e.value, subtree: !0, t9nStrings: l })}</calcite-tree-item>`;
default:
return null;
}
}, G = ({ arcadeResult: e }) => {
const t = g(e.value.fields);
return a`<div class="table-scroll"><table><thead><tr>${t.map((r) => a`<th>${r.name}</th>`)}</tr></thead><tbody>${e.features.map((r) => a`<tr>${t.map((c) => {
const l = p(r.field(c.name));
if (!S(l))
return a`<td></td>`;
try {
const { type: s, value: n } = f(l);
return a`<td>${h({ type: s, value: n })}</td>`;
} catch {
return a`<td></td>`;
}
})}</tr>`)}</tbody></table></div>`;
};
export {
A,
C as D,
B as F,
G as a,
D as b,
i as t
};