UNPKG

@arcgis/coding-components

Version:
176 lines (164 loc) • 4.86 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */ import { html as a, unsafeCSS as v, css as m } from "lit"; import { nothing as y, safeClassMap as l } from "@arcgis/lumina"; import { classes as i } from "@arcgis/toolkit/dom"; import { uncapitalize as f, quoteString as c } from "@arcgis/toolkit/string"; import { f as g, a as b, b as $ } from "./arcade-executor.js"; import { t as o } from "./monaco-theme.js"; const s = { lines: !0, selectionMode: "none", scale: "s", oncalciteTreeSelect: (e) => e.currentTarget.selectedItems.forEach((t) => t.selected = !1) }, u = "tree-item-metadata", p = ({ name: e, isMetadata: t = !1 }) => a`<bdi class=${l(i("dictionary-property", t && u))}>${e}</bdi><bdi class=${l(i(t && u))}>:&nbsp;</bdi>`, z = ({ obj: e, subtree: t }) => a`<calcite-tree slot=${"children"} .lines=${s.lines} .selectionMode=${s.selectionMode} .scale=${s.scale} @calciteTreeSelect=${s.oncalciteTreeSelect}><calcite-tree-item class="string-value">${JSON.stringify(e, void 0, 2)}</calcite-tree-item></calcite-tree>`, N = ({ value: e, subtree: t = !1 }) => a`<calcite-tree slot=${(t ? "children" : void 0) ?? y} .lines=${s.lines} .selectionMode=${s.selectionMode} .scale=${s.scale} @calciteTreeSelect=${s.oncalciteTreeSelect}><calcite-tree-item><div class="tree-item-label">${p({ name: "type" })}<bdi>${f(e.type)}</bdi></div></calcite-tree-item><calcite-tree-item><div class="tree-item-label">${p({ name: "value" })}<span class="string-value">${JSON.stringify(e, void 0, 2)}</span></div></calcite-tree-item></calcite-tree>`, C = ({ type: e, value: t }) => { switch (e) { case "unknown": case "Unknown": return a`<span class="constant-value">${e}</span>`; case "null": case "Null": return a`<span class="constant-value">null</span>`; case "text": case "String": case "Text": return a`<span class="string-value">${c(t)}</span>`; case "number": case "Number": return a`<span class="number-value">${t}</span>`; case "boolean": case "Boolean": return a`<span class="constant-value">${t}</span>`; case "date": case "Date": return a`<span class="date-value">${t}</span>`; case "dateOnly": case "DateOnly": return a`<span class="string-value">${c(t)}</span>`; case "time": case "Time": return a`<span class="string-value">${c(t)}</span>`; case "": return a`<span class="string-value">null</span>`; default: return null; } }, h = [ "boolean", "date", "dateOnly", "null", "number", "text", "time", "unknown", "Boolean", "Date", "DateOnly", "Null", "Number", "Text", // TODO only use string "Time", "Unknown", "String", "" ], M = (e) => h.includes(e.type); function V(e) { switch (e.type) { case "null": case "unknown": return { type: e.type, value: e.type }; case "number": return { type: e.type, value: String(e.value) }; case "boolean": return { type: e.type, value: String(e.value) }; case "text": return { type: e.type, value: e.value }; case "date": return { type: e.type, value: $(e) }; case "dateOnly": return { type: e.type, value: b(e) }; case "time": return { type: e.type, value: g(e) }; } } const S = "calcite-mode-dark"; function A() { let e = `:host { `; const t = o["light-theme"]; Object.entries(t).forEach(([n, r]) => { e += ` --arcgis-editor-${n}: ${r}; `; }), e += `} `, e += `:host(:state(${S})), `, e += `:host([calcite-mode-dark]) { `; const d = o["dark-theme"]; return Object.entries(d).forEach(([n, r]) => { e += ` --arcgis-editor-${n}: ${r};`; }), e += ` } `, m` ${v(e)} `; } const E = m` .xs { font-size: var(--calcite-font-size-xs); color: var(--calcite-color-text-2); } .breakpoint-code { font-size: var(--calcite-font-size--2); } [class*="result-value-"] { font-size: var(--calcite-font-size--2); background-color: var(--calcite-color-foreground-1); } .tree-item-label, .number-value, .string-value, .boolean-value { font-family: var(--calcite-code-family); } .tree-item-label, .value-type { color: var(--calcite-color-text-2); font-weight: var(--calcite-font-weight-normal); } .tree-item-metadata { opacity: 0.7; } .dictionary-property { color: var(--arcgis-editor-identifier); } .uninitialized-value { color: var(--arcgis-editor-identifier); } .number-value { color: var(--arcgis-editor-number); } .string-value { color: var(--arcgis-editor-string); white-space: pre-wrap; } .constant-value { color: var(--arcgis-editor-constant); } .date-value { color: var(--arcgis-editor-date); } `; export { p as D, N as G, C as S, V as a, z as b, S as c, E as d, A as g, M as i, s as t };