UNPKG

drizzle-cube

Version:

Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.

287 lines (286 loc) 8.05 kB
import { jsx as m } from "react/jsx-runtime"; import { Suspense as C, lazy as g, useState as p, useEffect as y } from "react"; import "./charts-DzHumCCp.js"; const c = /* @__PURE__ */ new Map(), l = { bar: () => import("./charts-DzHumCCp.js").then((t) => t.aG), line: () => import("./charts-DzHumCCp.js").then((t) => t.aH), area: () => import("./charts-DzHumCCp.js").then((t) => t.aI), pie: () => import("./charts-DzHumCCp.js").then((t) => t.aJ), scatter: () => import("./charts-DzHumCCp.js").then((t) => t.aK), radar: () => import("./charts-DzHumCCp.js").then((t) => t.aL), radialBar: () => import("./charts-DzHumCCp.js").then((t) => t.aM), treemap: () => import("./charts-DzHumCCp.js").then((t) => t.aN), bubble: () => import("./charts-DzHumCCp.js").then((t) => t.aO), table: () => import("./charts-DzHumCCp.js").then((t) => t.aP), activityGrid: () => import("./charts-DzHumCCp.js").then((t) => t.aQ), kpiNumber: () => import("./charts-DzHumCCp.js").then((t) => t.aR), kpiDelta: () => import("./charts-DzHumCCp.js").then((t) => t.aS), kpiText: () => import("./charts-DzHumCCp.js").then((t) => t.aT), markdown: () => import("./charts-DzHumCCp.js").then((t) => t.aU), funnel: () => import("./charts-DzHumCCp.js").then((t) => t.aV), sankey: () => import("./charts-DzHumCCp.js").then((t) => t.aW), sunburst: () => import("./charts-DzHumCCp.js").then((t) => t.aX) }; function b(t) { if (!c.has(t)) { const e = l[t]; if (!e) throw new Error(`Unknown chart type: ${t}`); c.set(t, g(e)); } return c.get(t); } function O(t) { return t in l; } function w({ height: t }) { return /* @__PURE__ */ m( "div", { className: "flex items-center justify-center w-full", style: { height: typeof t == "number" ? `${t}px` : t || "200px" }, children: /* @__PURE__ */ m("div", { className: "animate-pulse bg-dc-surface-secondary rounded w-full h-full min-h-[100px]" }) } ); } function j({ chartType: t, fallback: e, height: a, ...r }) { const n = b(t); return /* @__PURE__ */ m(C, { fallback: e ?? /* @__PURE__ */ m(w, { height: a }), children: /* @__PURE__ */ m(n, { height: a, ...r }) }); } function x(t) { const e = l[t]; e && e(); } function A(t) { t.forEach(x); } function F() { return Object.keys(l); } const f = { dropZones: [ { key: "xAxis", label: "X-Axis (Categories)", description: "Dimensions and time dimensions for grouping", mandatory: !1, acceptTypes: ["dimension", "timeDimension"], emptyText: "Drop dimensions & time dimensions here" }, { key: "yAxis", label: "Y-Axis (Values)", description: "Measures for values or dimensions for series", mandatory: !1, acceptTypes: ["measure", "dimension"], emptyText: "Drop measures or dimensions here" }, { key: "series", label: "Series (Split into Multiple Series)", description: "Dimensions to create separate data series", mandatory: !1, acceptTypes: ["dimension"], emptyText: "Drop dimensions here to split data into series" } ], displayOptions: ["showLegend", "showGrid", "showTooltip"] }; function G(t, e) { return e[t] || f; } const d = { bar: () => import("./charts-DzHumCCp.js").then((t) => t.ao), line: () => import("./charts-DzHumCCp.js").then((t) => t.ap), area: () => import("./charts-DzHumCCp.js").then((t) => t.aq), pie: () => import("./charts-DzHumCCp.js").then((t) => t.ar), scatter: () => import("./charts-DzHumCCp.js").then((t) => t.as), radar: () => import("./charts-DzHumCCp.js").then((t) => t.au), radialBar: () => import("./charts-DzHumCCp.js").then((t) => t.av), treemap: () => import("./charts-DzHumCCp.js").then((t) => t.aw), bubble: () => import("./charts-DzHumCCp.js").then((t) => t.at), table: () => import("./charts-DzHumCCp.js").then((t) => t.ax), activityGrid: () => import("./charts-DzHumCCp.js").then((t) => t.ay), kpiNumber: () => import("./charts-DzHumCCp.js").then((t) => t.az), kpiDelta: () => import("./charts-DzHumCCp.js").then((t) => t.aA), kpiText: () => import("./charts-DzHumCCp.js").then((t) => t.aB), markdown: () => import("./charts-DzHumCCp.js").then((t) => t.aC), funnel: () => import("./charts-DzHumCCp.js").then((t) => t.aD), sankey: () => import("./charts-DzHumCCp.js").then((t) => t.aE), sunburst: () => import("./charts-DzHumCCp.js").then((t) => t.aF) }, k = { bar: "barChartConfig", line: "lineChartConfig", area: "areaChartConfig", pie: "pieChartConfig", scatter: "scatterChartConfig", radar: "radarChartConfig", radialBar: "radialBarChartConfig", treemap: "treemapChartConfig", bubble: "bubbleChartConfig", table: "dataTableConfig", activityGrid: "activityGridChartConfig", kpiNumber: "kpiNumberConfig", kpiDelta: "kpiDeltaConfig", kpiText: "kpiTextConfig", markdown: "markdownConfig", funnel: "funnelChartConfig", sankey: "sankeyChartConfig", sunburst: "sunburstChartConfig" }, i = /* @__PURE__ */ new Map(); async function h(t) { if (i.has(t)) return i.get(t); const e = d[t]; if (!e) return null; try { const a = await e(), r = k[t], n = a[r]; return n ? (i.set(t, n), n) : null; } catch (a) { return console.error(`Failed to load config for chart type: ${t}`, a), null; } } function v(t) { return i.get(t) || f; } function B(t) { return i.has(t); } function E(t) { const [e, a] = p( t ? v(t) : f ), [r, n] = p(!1), [u, o] = p(!1); return y(() => { if (!t) { a(f), o(!1); return; } if (i.has(t)) { a(i.get(t)), o(!0); return; } n(!0), h(t).then((s) => { s ? (a(s), o(!0)) : (a(f), o(!0)); }).finally(() => n(!1)); }, [t]), { config: e, loading: r, loaded: u }; } async function N(t) { i.has(t) || await h(t); } async function I(t) { await Promise.all(t.map(N)); } async function J() { const t = Object.keys(d); await Promise.all(t.map(h)); const e = {}; for (const a of t) { const r = i.get(a); r && (e[a] = r); } return e; } function P() { i.clear(); } function $(t) { const e = D(t); return { portlets: t, layouts: e }; } function D(t) { const e = t.map((a) => ({ i: a.id, x: a.x, y: a.y, w: a.w, h: a.h, minW: 3, minH: 3 })); return { lg: e, md: e.map((a) => ({ ...a, w: Math.min(a.w, 8) })), sm: e.map((a) => ({ ...a, w: Math.min(a.w, 6) })), xs: e.map((a) => ({ ...a, w: Math.min(a.w, 4) })), xxs: e.map((a) => ({ ...a, w: 2 })) }; } function q(t, e = {}) { const { formatNumbers: a = !0, precision: r = 2 } = e; return a ? t.map((n) => { const u = {}; for (const [o, s] of Object.entries(n)) typeof s == "number" ? u[o] = Number(s.toFixed(r)) : u[o] = s; return u; }) : t; } function z() { return `portlet-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; } function Q(t, e = 6, a = 4) { return t.length === 0 ? { x: 0, y: 0 } : { x: 0, y: Math.max(...t.map((n) => n.y + n.h)) }; } function R(t) { try { const e = JSON.parse(t); return typeof e != "object" || e === null ? { valid: !1, error: "Query must be a JSON object" } : !e.measures && !e.dimensions ? { valid: !1, error: "Query must have at least measures or dimensions" } : { valid: !0, query: e }; } catch { return { valid: !1, error: "Invalid JSON format" }; } } function T() { return { title: "Sample Chart", query: JSON.stringify({ measures: ["count"], dimensions: ["category"] }, null, 2), chartType: "bar", chartConfig: { x: "category", y: ["count"] }, displayConfig: { showLegend: !0, showGrid: !0, showTooltip: !0 }, w: 6, h: 4, x: 0, y: 0 }; } export { j as L, A as a, G as b, $ as c, D as d, z as e, q as f, F as g, Q as h, O as i, T as j, h as k, v as l, B as m, N as n, I as o, x as p, J as q, P as r, E as u, R as v }; //# sourceMappingURL=charts-DwU4Ekjc.js.map