UNPKG

drizzle-cube

Version:

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

278 lines (277 loc) 7.55 kB
import { jsx as u } from "react/jsx-runtime"; import { Suspense as C, lazy as g, useState as c, useEffect as y } from "react"; import "./charts-BvLb1eub.js"; const p = /* @__PURE__ */ new Map(), l = { bar: () => import("./charts-BvLb1eub.js").then((t) => t.al), line: () => import("./charts-BvLb1eub.js").then((t) => t.am), area: () => import("./charts-BvLb1eub.js").then((t) => t.an), pie: () => import("./charts-BvLb1eub.js").then((t) => t.ao), scatter: () => import("./charts-BvLb1eub.js").then((t) => t.ap), radar: () => import("./charts-BvLb1eub.js").then((t) => t.aq), radialBar: () => import("./charts-BvLb1eub.js").then((t) => t.ar), treemap: () => import("./charts-BvLb1eub.js").then((t) => t.as), bubble: () => import("./charts-BvLb1eub.js").then((t) => t.at), table: () => import("./charts-BvLb1eub.js").then((t) => t.au), activityGrid: () => import("./charts-BvLb1eub.js").then((t) => t.av), kpiNumber: () => import("./charts-BvLb1eub.js").then((t) => t.aw), kpiDelta: () => import("./charts-BvLb1eub.js").then((t) => t.ax), kpiText: () => import("./charts-BvLb1eub.js").then((t) => t.ay), markdown: () => import("./charts-BvLb1eub.js").then((t) => t.az) }; function b(t) { if (!p.has(t)) { const e = l[t]; if (!e) throw new Error(`Unknown chart type: ${t}`); p.set(t, g(e)); } return p.get(t); } function j(t) { return t in l; } function w({ height: t }) { return /* @__PURE__ */ u( "div", { className: "flex items-center justify-center w-full", style: { height: typeof t == "number" ? `${t}px` : t || "200px" }, children: /* @__PURE__ */ u("div", { className: "animate-pulse bg-dc-surface-secondary rounded w-full h-full min-h-[100px]" }) } ); } function O({ chartType: t, fallback: e, height: a, ...n }) { const r = b(t); return /* @__PURE__ */ u(C, { fallback: e ?? /* @__PURE__ */ u(w, { height: a }), children: /* @__PURE__ */ u(r, { height: a, ...n }) }); } 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-BvLb1eub.js").then((t) => t.a6), line: () => import("./charts-BvLb1eub.js").then((t) => t.a7), area: () => import("./charts-BvLb1eub.js").then((t) => t.a8), pie: () => import("./charts-BvLb1eub.js").then((t) => t.a9), scatter: () => import("./charts-BvLb1eub.js").then((t) => t.aa), radar: () => import("./charts-BvLb1eub.js").then((t) => t.ac), radialBar: () => import("./charts-BvLb1eub.js").then((t) => t.ad), treemap: () => import("./charts-BvLb1eub.js").then((t) => t.ae), bubble: () => import("./charts-BvLb1eub.js").then((t) => t.ab), table: () => import("./charts-BvLb1eub.js").then((t) => t.af), activityGrid: () => import("./charts-BvLb1eub.js").then((t) => t.ag), kpiNumber: () => import("./charts-BvLb1eub.js").then((t) => t.ah), kpiDelta: () => import("./charts-BvLb1eub.js").then((t) => t.ai), kpiText: () => import("./charts-BvLb1eub.js").then((t) => t.aj), markdown: () => import("./charts-BvLb1eub.js").then((t) => t.ak) }, 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" }, 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(), n = k[t], r = a[n]; return r ? (i.set(t, r), r) : 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 $(t) { return i.has(t); } function q(t) { const [e, a] = c( t ? v(t) : f ), [n, r] = c(!1), [m, o] = c(!1); return y(() => { if (!t) { a(f), o(!1); return; } if (i.has(t)) { a(i.get(t)), o(!0); return; } r(!0), h(t).then((s) => { s ? (a(s), o(!0)) : (a(f), o(!0)); }).finally(() => r(!1)); }, [t]), { config: e, loading: n, loaded: m }; } async function N(t) { i.has(t) || await h(t); } async function z(t) { await Promise.all(t.map(N)); } async function B() { const t = Object.keys(d); await Promise.all(t.map(h)); const e = {}; for (const a of t) { const n = i.get(a); n && (e[a] = n); } return e; } function E() { i.clear(); } function I(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 J(t, e = {}) { const { formatNumbers: a = !0, precision: n = 2 } = e; return a ? t.map((r) => { const m = {}; for (const [o, s] of Object.entries(r)) typeof s == "number" ? m[o] = Number(s.toFixed(n)) : m[o] = s; return m; }) : t; } function P() { 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((r) => r.y + r.h)) }; } function Y(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 R() { 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 { O as L, A as a, G as b, I as c, D as d, P as e, J as f, F as g, Q as h, j as i, R as j, h as k, v as l, $ as m, N as n, z as o, x as p, B as q, E as r, q as u, Y as v }; //# sourceMappingURL=charts-BsXrHSCm.js.map