drizzle-cube 0.1.21 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/{compiler-CPsEzFP2.js → compiler-CSr2Ti96.js} +553 -505
- package/dist/adapters/express/index.js +1 -1
- package/dist/adapters/fastify/index.js +1 -1
- package/dist/adapters/hono/index.js +1 -1
- package/dist/adapters/nextjs/index.js +50 -50
- package/dist/client/charts/chartConfigs.d.ts +31 -1
- package/dist/client/charts.d.ts +1 -0
- package/dist/client/charts.js +1 -1
- package/dist/client/chunks/charts-Dx3asDBi.js +2269 -0
- package/dist/client/chunks/charts-Dx3asDBi.js.map +1 -0
- package/dist/client/chunks/{icons-B5RVM-7b.js → icons-BMGOKdZb.js} +279 -239
- package/dist/client/chunks/icons-BMGOKdZb.js.map +1 -0
- package/dist/client/chunks/{providers-DI5zeeEU.js → providers-B7MVnAAt.js} +50 -50
- package/dist/client/chunks/providers-B7MVnAAt.js.map +1 -0
- package/dist/client/components/ChartConfigPanel.d.ts +3 -2
- package/dist/client/components/ColorPaletteSelector.d.ts +11 -0
- package/dist/client/components/DashboardGrid.d.ts +3 -1
- package/dist/client/components/DataHistogram.d.ts +23 -0
- package/dist/client/components/PortletEditModal.d.ts +3 -2
- package/dist/client/components/charts/ActivityGridChart.config.d.ts +5 -0
- package/dist/client/components/charts/ActivityGridChart.d.ts +2 -0
- package/dist/client/components/charts/AreaChart.d.ts +1 -1
- package/dist/client/components/charts/BarChart.d.ts +1 -1
- package/dist/client/components/charts/BubbleChart.d.ts +1 -1
- package/dist/client/components/charts/KpiNumber.config.d.ts +5 -0
- package/dist/client/components/charts/KpiNumber.d.ts +2 -0
- package/dist/client/components/charts/KpiText.config.d.ts +5 -0
- package/dist/client/components/charts/KpiText.d.ts +2 -0
- package/dist/client/components/charts/LineChart.d.ts +1 -1
- package/dist/client/components/charts/PieChart.d.ts +1 -1
- package/dist/client/components/charts/RadarChart.d.ts +1 -1
- package/dist/client/components/charts/RadialBarChart.d.ts +1 -1
- package/dist/client/components/charts/ScatterChart.d.ts +1 -1
- package/dist/client/components/charts/TreeMapChart.d.ts +1 -1
- package/dist/client/components/charts/index.d.ts +3 -0
- package/dist/client/components.js +5134 -2607
- package/dist/client/components.js.map +1 -1
- package/dist/client/hooks/useCubeMeta.d.ts +1 -0
- package/dist/client/hooks.js +62 -60
- package/dist/client/hooks.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.js +2 -2
- package/dist/client/providers.js +1 -1
- package/dist/client/types.d.ts +17 -5
- package/dist/client/utils/colorPalettes.d.ts +35 -0
- package/dist/client-bundle-stats.html +1 -1
- package/dist/server/index.d.ts +3 -8
- package/dist/server/index.js +748 -700
- package/package.json +22 -1
- package/dist/client/chunks/charts-BadAUMmd.js +0 -2285
- package/dist/client/chunks/charts-BadAUMmd.js.map +0 -1
- package/dist/client/chunks/icons-B5RVM-7b.js.map +0 -1
- package/dist/client/chunks/providers-DI5zeeEU.js.map +0 -1
package/dist/client/hooks.js
CHANGED
|
@@ -1,77 +1,79 @@
|
|
|
1
|
-
import { useState as h, useRef as
|
|
2
|
-
import { u as
|
|
3
|
-
import { a as v } from "./chunks/providers-
|
|
4
|
-
function
|
|
5
|
-
const { cubeApi:
|
|
1
|
+
import { useState as h, useRef as b, useEffect as C, useCallback as V } from "react";
|
|
2
|
+
import { u as I } from "./chunks/providers-B7MVnAAt.js";
|
|
3
|
+
import { a as v } from "./chunks/providers-B7MVnAAt.js";
|
|
4
|
+
function L(r, t = {}) {
|
|
5
|
+
const { cubeApi: i } = I(), [o, c] = h({
|
|
6
6
|
resultSet: null,
|
|
7
7
|
isLoading: !1,
|
|
8
8
|
error: null,
|
|
9
9
|
queryId: null
|
|
10
|
-
}),
|
|
11
|
-
return
|
|
12
|
-
if (!r ||
|
|
10
|
+
}), a = b("");
|
|
11
|
+
return C(() => {
|
|
12
|
+
if (!r || t.skip)
|
|
13
13
|
return;
|
|
14
|
-
const
|
|
15
|
-
if (
|
|
14
|
+
const f = JSON.stringify(r);
|
|
15
|
+
if (f === a.current && !t.resetResultSetOnChange)
|
|
16
16
|
return;
|
|
17
|
-
|
|
17
|
+
a.current = f;
|
|
18
18
|
const u = `${Date.now()}_${Math.random().toString(36).substring(7)}`;
|
|
19
|
-
|
|
20
|
-
resultSet:
|
|
19
|
+
c((n) => ({
|
|
20
|
+
resultSet: t.resetResultSetOnChange ? null : n.resultSet,
|
|
21
21
|
isLoading: !0,
|
|
22
22
|
error: null,
|
|
23
23
|
queryId: u
|
|
24
|
-
})),
|
|
25
|
-
|
|
26
|
-
resultSet:
|
|
24
|
+
})), i.load(r).then((n) => {
|
|
25
|
+
c((s) => s.queryId === u ? {
|
|
26
|
+
resultSet: n,
|
|
27
27
|
isLoading: !1,
|
|
28
28
|
error: null,
|
|
29
29
|
queryId: u
|
|
30
30
|
} : s);
|
|
31
|
-
}).catch((
|
|
32
|
-
|
|
31
|
+
}).catch((n) => {
|
|
32
|
+
c((s) => s.queryId === u ? {
|
|
33
33
|
resultSet: null,
|
|
34
34
|
isLoading: !1,
|
|
35
|
-
error:
|
|
35
|
+
error: n instanceof Error ? n : new Error(String(n)),
|
|
36
36
|
queryId: u
|
|
37
37
|
} : s);
|
|
38
38
|
});
|
|
39
|
-
}, [r,
|
|
39
|
+
}, [r, i, t.skip, t.resetResultSetOnChange]), o;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const [
|
|
43
|
-
resultSet:
|
|
41
|
+
function m(r, t = !0) {
|
|
42
|
+
const [i, o] = h([]), [c, a] = h(null), f = b(null), u = b(""), {
|
|
43
|
+
resultSet: n,
|
|
44
44
|
isLoading: s,
|
|
45
|
-
error:
|
|
46
|
-
queryId:
|
|
47
|
-
} =
|
|
48
|
-
skip: !
|
|
45
|
+
error: g,
|
|
46
|
+
queryId: y
|
|
47
|
+
} = L(c, {
|
|
48
|
+
skip: !c || !t,
|
|
49
49
|
resetResultSetOnChange: !0
|
|
50
50
|
// Clear old results when query changes
|
|
51
|
-
}), q =
|
|
51
|
+
}), q = V((e) => {
|
|
52
52
|
if (!e || !r)
|
|
53
53
|
return [];
|
|
54
54
|
try {
|
|
55
|
-
const
|
|
56
|
-
return
|
|
57
|
-
const
|
|
58
|
-
|
|
55
|
+
const S = e.tablePivot(), l = /* @__PURE__ */ new Set();
|
|
56
|
+
return S.forEach((x) => {
|
|
57
|
+
const d = x[r];
|
|
58
|
+
d != null && d !== "" && l.add(d);
|
|
59
59
|
}), Array.from(l);
|
|
60
|
-
} catch (
|
|
61
|
-
return console.error("Error extracting values from result set:",
|
|
60
|
+
} catch (S) {
|
|
61
|
+
return console.error("Error extracting values from result set:", S), [];
|
|
62
62
|
}
|
|
63
63
|
}, [r]);
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
else if (
|
|
69
|
-
const e = q(
|
|
70
|
-
|
|
64
|
+
C(() => {
|
|
65
|
+
if (y && y !== f.current && !s)
|
|
66
|
+
if (f.current = y, g)
|
|
67
|
+
o([]);
|
|
68
|
+
else if (n) {
|
|
69
|
+
const e = q(n);
|
|
70
|
+
o(e);
|
|
71
71
|
} else
|
|
72
|
-
|
|
73
|
-
}, [
|
|
74
|
-
|
|
72
|
+
o([]);
|
|
73
|
+
}, [n, s, g, y, q]), C(() => {
|
|
74
|
+
(!r || !t) && (o([]), a(null), f.current = null, u.current = "");
|
|
75
|
+
}, [r, t]);
|
|
76
|
+
const E = V(() => {
|
|
75
77
|
if (r) {
|
|
76
78
|
u.current = "";
|
|
77
79
|
try {
|
|
@@ -80,13 +82,13 @@ function k(r, n = !0) {
|
|
|
80
82
|
limit: 25,
|
|
81
83
|
order: { [r]: "asc" }
|
|
82
84
|
};
|
|
83
|
-
|
|
85
|
+
a(e);
|
|
84
86
|
} catch (e) {
|
|
85
87
|
console.error("Error creating query:", e);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
}, [r]), R =
|
|
89
|
-
if (r && !(!
|
|
90
|
+
}, [r]), R = V((e, S = !1) => {
|
|
91
|
+
if (r && !(!S && e === u.current)) {
|
|
90
92
|
u.current = e;
|
|
91
93
|
try {
|
|
92
94
|
const l = {
|
|
@@ -98,35 +100,35 @@ function k(r, n = !0) {
|
|
|
98
100
|
member: r,
|
|
99
101
|
operator: "contains",
|
|
100
102
|
values: [e.trim()]
|
|
101
|
-
}]),
|
|
103
|
+
}]), a(l);
|
|
102
104
|
} catch (l) {
|
|
103
105
|
console.error("Error creating search query:", l);
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
}, [r]);
|
|
107
109
|
return {
|
|
108
|
-
values:
|
|
110
|
+
values: i,
|
|
109
111
|
loading: s,
|
|
110
|
-
error:
|
|
112
|
+
error: g ? g instanceof Error ? g.message : String(g) : null,
|
|
111
113
|
refetch: E,
|
|
112
114
|
searchValues: R
|
|
113
115
|
};
|
|
114
116
|
}
|
|
115
|
-
function p(r,
|
|
116
|
-
const [
|
|
117
|
-
return
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
},
|
|
117
|
+
function p(r, t) {
|
|
118
|
+
const [i, o] = h(r);
|
|
119
|
+
return C(() => {
|
|
120
|
+
const c = setTimeout(() => {
|
|
121
|
+
o(r);
|
|
122
|
+
}, t);
|
|
121
123
|
return () => {
|
|
122
|
-
clearTimeout(
|
|
124
|
+
clearTimeout(c);
|
|
123
125
|
};
|
|
124
|
-
}, [r,
|
|
126
|
+
}, [r, t]), i;
|
|
125
127
|
}
|
|
126
128
|
export {
|
|
127
129
|
v as useCubeMeta,
|
|
128
|
-
|
|
130
|
+
L as useCubeQuery,
|
|
129
131
|
p as useDebounce,
|
|
130
|
-
|
|
132
|
+
m as useFilterValues
|
|
131
133
|
};
|
|
132
134
|
//# sourceMappingURL=hooks.js.map
|
package/dist/client/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sources":["../../src/client/hooks/useCubeQuery.ts","../../src/client/hooks/useFilterValues.ts","../../src/client/hooks/useDebounce.ts"],"sourcesContent":["/**\n * React hook for executing Cube queries\n * Replaces @cubejs-client/react useCubeQuery\n */\n\nimport { useState, useEffect, useRef } from 'react'\nimport { useCubeContext } from '../providers/CubeProvider'\nimport type { CubeQuery, CubeQueryOptions, CubeResultSet } from '../types'\n\ninterface UseCubeQueryResult {\n resultSet: CubeResultSet | null\n isLoading: boolean\n error: Error | null\n queryId: string | null\n}\n\nexport function useCubeQuery(\n query: CubeQuery | null, \n options: CubeQueryOptions = {}\n): UseCubeQueryResult {\n const { cubeApi } = useCubeContext()\n \n // Use a single state object to ensure atomic updates\n const [state, setState] = useState<UseCubeQueryResult>({\n resultSet: null,\n isLoading: false,\n error: null,\n queryId: null\n })\n \n // Track the last query to avoid unnecessary re-fetches\n const lastQueryRef = useRef<string>('')\n \n useEffect(() => {\n // Skip if query is null or skip option is true\n if (!query || options.skip) {\n return\n }\n\n // Create a stable query string for comparison\n const queryString = JSON.stringify(query)\n \n // Skip if query hasn't changed (unless resetResultSetOnChange is true)\n if (queryString === lastQueryRef.current && !options.resetResultSetOnChange) {\n return\n }\n\n lastQueryRef.current = queryString\n \n // Create a unique ID for this query execution\n const queryId = `${Date.now()}_${Math.random().toString(36).substring(7)}`\n\n // Update state atomically with new query ID and loading state\n setState(prevState => ({\n resultSet: options.resetResultSetOnChange ? null : prevState.resultSet,\n isLoading: true,\n error: null,\n queryId\n }))\n\n cubeApi.load(query)\n .then((result) => {\n setState(prevState => {\n // Only update if this is still the current query\n if (prevState.queryId === queryId) {\n return {\n resultSet: result,\n isLoading: false,\n error: null,\n queryId\n }\n }\n return prevState\n })\n })\n .catch((err) => {\n setState(prevState => {\n // Only update if this is still the current query\n if (prevState.queryId === queryId) {\n return {\n resultSet: null,\n isLoading: false,\n error: err instanceof Error ? err : new Error(String(err)),\n queryId\n }\n }\n return prevState\n })\n })\n }, [query, cubeApi, options.skip, options.resetResultSetOnChange])\n\n return state\n}","/**\n * Hook for fetching distinct field values for filter dropdowns\n * Uses the /load API to get actual data values\n */\n\nimport { useState, useEffect, useCallback, useRef } from 'react'\nimport { useCubeQuery } from '../hooks/useCubeQuery'\nimport type { CubeQuery } from '../types'\n\ninterface UseFilterValuesResult {\n values: any[]\n loading: boolean\n error: string | null\n refetch: () => void\n searchValues: (searchTerm: string, force?: boolean) => void\n}\n\n/**\n * Custom hook to fetch distinct values for a field\n */\nexport function useFilterValues(\n fieldName: string | null, \n enabled: boolean = true\n): UseFilterValuesResult {\n const [values, setValues] = useState<any[]>([])\n const [currentQuery, setCurrentQuery] = useState<CubeQuery | null>(null)\n const lastProcessedQueryId = useRef<string | null>(null)\n const lastSearchTerm = useRef<string>('')\n \n // Use cube query hook for actual data fetching\n const { \n resultSet, \n isLoading,\n error: queryError,\n queryId\n } = useCubeQuery(currentQuery, {\n skip: !currentQuery || !enabled,\n resetResultSetOnChange: true // Clear old results when query changes\n })\n \n // Extract unique values from result set\n const extractValuesFromResultSet = useCallback((rs: any): any[] => {\n if (!rs || !fieldName) {\n return []\n }\n \n try {\n const data = rs.tablePivot()\n \n const uniqueValues = new Set<any>()\n \n data.forEach((row: any) => {\n const value = row[fieldName]\n if (value !== null && value !== undefined && value !== '') {\n uniqueValues.add(value)\n }\n })\n \n // Convert to array - already sorted by query\n const sortedValues = Array.from(uniqueValues)\n \n return sortedValues\n } catch (err) {\n console.error('Error extracting values from result set:', err)\n return []\n }\n }, [fieldName])\n \n // Process results only when we have a new matching query result\n useEffect(() => {\n // Skip if no query ID\n if (!queryId) {\n return\n }\n \n // Skip if we've already processed this query\n if (queryId === lastProcessedQueryId.current) {\n return\n }\n \n // Skip if still loading\n if (isLoading) {\n return\n }\n \n // Mark as processed\n lastProcessedQueryId.current = queryId\n \n if (queryError) {\n setValues([])\n } else if (resultSet) {\n const extractedValues = extractValuesFromResultSet(resultSet)\n setValues(extractedValues)\n } else {\n setValues([])\n }\n }, [resultSet, isLoading, queryError, queryId, extractValuesFromResultSet])\n \n // Refetch function\n const refetch = useCallback(() => {\n if (!fieldName) return\n \n lastSearchTerm.current = ''\n \n try {\n const query: CubeQuery = {\n dimensions: [fieldName], \n limit: 25,\n order: { [fieldName]: 'asc' }\n }\n setCurrentQuery(query)\n } catch (err) {\n console.error('Error creating query:', err)\n }\n }, [fieldName])\n\n // Search function for server-side filtering\n const searchValues = useCallback((searchTerm: string, force: boolean = false) => {\n if (!fieldName) {\n return\n }\n \n // Don't create a new query if the search term hasn't changed (unless forced)\n if (!force && searchTerm === lastSearchTerm.current) {\n return\n }\n \n lastSearchTerm.current = searchTerm\n \n try {\n // Create query inline to avoid dependency issues\n const query: CubeQuery = {\n dimensions: [fieldName], \n limit: 25,\n order: { [fieldName]: 'asc' }\n }\n \n if (searchTerm && searchTerm.trim()) {\n query.filters = [{\n member: fieldName,\n operator: 'contains',\n values: [searchTerm.trim()]\n }]\n }\n \n setCurrentQuery(query)\n } catch (err) {\n console.error('Error creating search query:', err)\n }\n }, [fieldName])\n \n return {\n values,\n loading: isLoading,\n error: queryError ? (queryError instanceof Error ? queryError.message : String(queryError)) : null,\n refetch,\n searchValues\n }\n}","/**\n * Custom hook for debouncing values\n * Delays updating the value until after the specified delay has passed\n * since the last change\n */\n\nimport { useState, useEffect } from 'react'\n\n/**\n * Debounces a value by the specified delay\n * @param value The value to debounce\n * @param delay The delay in milliseconds\n * @returns The debounced value\n */\nexport function useDebounce<T>(value: T, delay: number): T {\n const [debouncedValue, setDebouncedValue] = useState(value)\n\n useEffect(() => {\n // Set up a timer to update the debounced value after the delay\n const handler = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n // Clean up the timer if the value changes before the delay\n return () => {\n clearTimeout(handler)\n }\n }, [value, delay])\n\n return debouncedValue\n}"],"names":["useCubeQuery","query","options","cubeApi","useCubeContext","state","setState","useState","lastQueryRef","useRef","useEffect","queryString","queryId","prevState","result","err","useFilterValues","fieldName","enabled","values","setValues","currentQuery","setCurrentQuery","lastProcessedQueryId","lastSearchTerm","resultSet","isLoading","queryError","extractValuesFromResultSet","useCallback","rs","data","uniqueValues","row","value","extractedValues","refetch","searchValues","searchTerm","force","useDebounce","delay","debouncedValue","setDebouncedValue","handler"],"mappings":";;;AAgBO,SAASA,EACdC,GACAC,IAA4B,IACR;AACpB,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA,GAGd,CAACC,GAAOC,CAAQ,IAAIC,EAA6B;AAAA,IACrD,WAAW;AAAA,IACX,WAAW;AAAA,IACX,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,CACV,GAGKC,IAAeC,EAAe,EAAE;AAEtC,SAAAC,EAAU,MAAM;AAEd,QAAI,CAACT,KAASC,EAAQ;AACpB;AAIF,UAAMS,IAAc,KAAK,UAAUV,CAAK;AAGxC,QAAIU,MAAgBH,EAAa,WAAW,CAACN,EAAQ;AACnD;AAGF,IAAAM,EAAa,UAAUG;AAGvB,UAAMC,IAAU,GAAG,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAGxE,IAAAN,EAAS,CAAAO,OAAc;AAAA,MACrB,WAAWX,EAAQ,yBAAyB,OAAOW,EAAU;AAAA,MAC7D,WAAW;AAAA,MACX,OAAO;AAAA,MACP,SAAAD;AAAA,IAAA,EACA,GAEFT,EAAQ,KAAKF,CAAK,EACf,KAAK,CAACa,MAAW;AAChB,MAAAR,EAAS,CAAAO,MAEHA,EAAU,YAAYD,IACjB;AAAA,QACL,WAAWE;AAAA,QACX,WAAW;AAAA,QACX,OAAO;AAAA,QACP,SAAAF;AAAA,MAAA,IAGGC,CACR;AAAA,IACH,CAAC,EACA,MAAM,CAACE,MAAQ;AACd,MAAAT,EAAS,CAAAO,MAEHA,EAAU,YAAYD,IACjB;AAAA,QACL,WAAW;AAAA,QACX,WAAW;AAAA,QACX,OAAOG,aAAe,QAAQA,IAAM,IAAI,MAAM,OAAOA,CAAG,CAAC;AAAA,QACzD,SAAAH;AAAA,MAAA,IAGGC,C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IAAIpC,EAAS2B,CAAK;AAE1D,SAAAxB,EAAU,MAAM;AAEd,UAAMkC,IAAU,WAAW,MAAM;AAC/B,MAAAD,EAAkBT,CAAK;AAAA,IACzB,GAAGO,CAAK;AAGR,WAAO,MAAM;AACX,mBAAaG,CAAO;AAAA,IACtB;AAAA,EACF,GAAG,CAACV,GAAOO,CAAK,CAAC,GAEVC;AACT;"}
|
|
1
|
+
{"version":3,"file":"hooks.js","sources":["../../src/client/hooks/useCubeQuery.ts","../../src/client/hooks/useFilterValues.ts","../../src/client/hooks/useDebounce.ts"],"sourcesContent":["/**\n * React hook for executing Cube queries\n * Replaces @cubejs-client/react useCubeQuery\n */\n\nimport { useState, useEffect, useRef } from 'react'\nimport { useCubeContext } from '../providers/CubeProvider'\nimport type { CubeQuery, CubeQueryOptions, CubeResultSet } from '../types'\n\ninterface UseCubeQueryResult {\n resultSet: CubeResultSet | null\n isLoading: boolean\n error: Error | null\n queryId: string | null\n}\n\nexport function useCubeQuery(\n query: CubeQuery | null, \n options: CubeQueryOptions = {}\n): UseCubeQueryResult {\n const { cubeApi } = useCubeContext()\n \n // Use a single state object to ensure atomic updates\n const [state, setState] = useState<UseCubeQueryResult>({\n resultSet: null,\n isLoading: false,\n error: null,\n queryId: null\n })\n \n // Track the last query to avoid unnecessary re-fetches\n const lastQueryRef = useRef<string>('')\n \n useEffect(() => {\n // Skip if query is null or skip option is true\n if (!query || options.skip) {\n return\n }\n\n // Create a stable query string for comparison\n const queryString = JSON.stringify(query)\n \n // Skip if query hasn't changed (unless resetResultSetOnChange is true)\n if (queryString === lastQueryRef.current && !options.resetResultSetOnChange) {\n return\n }\n\n lastQueryRef.current = queryString\n \n // Create a unique ID for this query execution\n const queryId = `${Date.now()}_${Math.random().toString(36).substring(7)}`\n\n // Update state atomically with new query ID and loading state\n setState(prevState => ({\n resultSet: options.resetResultSetOnChange ? null : prevState.resultSet,\n isLoading: true,\n error: null,\n queryId\n }))\n\n cubeApi.load(query)\n .then((result) => {\n setState(prevState => {\n // Only update if this is still the current query\n if (prevState.queryId === queryId) {\n return {\n resultSet: result,\n isLoading: false,\n error: null,\n queryId\n }\n }\n return prevState\n })\n })\n .catch((err) => {\n setState(prevState => {\n // Only update if this is still the current query\n if (prevState.queryId === queryId) {\n return {\n resultSet: null,\n isLoading: false,\n error: err instanceof Error ? err : new Error(String(err)),\n queryId\n }\n }\n return prevState\n })\n })\n }, [query, cubeApi, options.skip, options.resetResultSetOnChange])\n\n return state\n}","/**\n * Hook for fetching distinct field values for filter dropdowns\n * Uses the /load API to get actual data values\n */\n\nimport { useState, useEffect, useCallback, useRef } from 'react'\nimport { useCubeQuery } from '../hooks/useCubeQuery'\nimport type { CubeQuery } from '../types'\n\ninterface UseFilterValuesResult {\n values: any[]\n loading: boolean\n error: string | null\n refetch: () => void\n searchValues: (searchTerm: string, force?: boolean) => void\n}\n\n/**\n * Custom hook to fetch distinct values for a field\n */\nexport function useFilterValues(\n fieldName: string | null, \n enabled: boolean = true\n): UseFilterValuesResult {\n const [values, setValues] = useState<any[]>([])\n const [currentQuery, setCurrentQuery] = useState<CubeQuery | null>(null)\n const lastProcessedQueryId = useRef<string | null>(null)\n const lastSearchTerm = useRef<string>('')\n \n // Use cube query hook for actual data fetching\n const { \n resultSet, \n isLoading,\n error: queryError,\n queryId\n } = useCubeQuery(currentQuery, {\n skip: !currentQuery || !enabled,\n resetResultSetOnChange: true // Clear old results when query changes\n })\n \n // Extract unique values from result set\n const extractValuesFromResultSet = useCallback((rs: any): any[] => {\n if (!rs || !fieldName) {\n return []\n }\n \n try {\n const data = rs.tablePivot()\n \n const uniqueValues = new Set<any>()\n \n data.forEach((row: any) => {\n const value = row[fieldName]\n if (value !== null && value !== undefined && value !== '') {\n uniqueValues.add(value)\n }\n })\n \n // Convert to array - already sorted by query\n const sortedValues = Array.from(uniqueValues)\n \n return sortedValues\n } catch (err) {\n console.error('Error extracting values from result set:', err)\n return []\n }\n }, [fieldName])\n \n // Process results only when we have a new matching query result\n useEffect(() => {\n // Skip if no query ID\n if (!queryId) {\n return\n }\n \n // Skip if we've already processed this query\n if (queryId === lastProcessedQueryId.current) {\n return\n }\n \n // Skip if still loading\n if (isLoading) {\n return\n }\n \n // Mark as processed\n lastProcessedQueryId.current = queryId\n \n if (queryError) {\n setValues([])\n } else if (resultSet) {\n const extractedValues = extractValuesFromResultSet(resultSet)\n setValues(extractedValues)\n } else {\n setValues([])\n }\n }, [resultSet, isLoading, queryError, queryId, extractValuesFromResultSet])\n \n // Reset values when fieldName becomes null or enabled changes\n useEffect(() => {\n if (!fieldName || !enabled) {\n setValues([])\n setCurrentQuery(null)\n lastProcessedQueryId.current = null\n lastSearchTerm.current = ''\n }\n }, [fieldName, enabled])\n \n // Refetch function\n const refetch = useCallback(() => {\n if (!fieldName) return\n \n lastSearchTerm.current = ''\n \n try {\n const query: CubeQuery = {\n dimensions: [fieldName], \n limit: 25,\n order: { [fieldName]: 'asc' }\n }\n setCurrentQuery(query)\n } catch (err) {\n console.error('Error creating query:', err)\n }\n }, [fieldName])\n\n // Search function for server-side filtering\n const searchValues = useCallback((searchTerm: string, force: boolean = false) => {\n if (!fieldName) {\n return\n }\n \n // Don't create a new query if the search term hasn't changed (unless forced)\n if (!force && searchTerm === lastSearchTerm.current) {\n return\n }\n \n lastSearchTerm.current = searchTerm\n \n try {\n // Create query inline to avoid dependency issues\n const query: CubeQuery = {\n dimensions: [fieldName], \n limit: 25,\n order: { [fieldName]: 'asc' }\n }\n \n if (searchTerm && searchTerm.trim()) {\n query.filters = [{\n member: fieldName,\n operator: 'contains',\n values: [searchTerm.trim()]\n }]\n }\n \n setCurrentQuery(query)\n } catch (err) {\n console.error('Error creating search query:', err)\n }\n }, [fieldName])\n \n return {\n values,\n loading: isLoading,\n error: queryError ? (queryError instanceof Error ? queryError.message : String(queryError)) : null,\n refetch,\n searchValues\n }\n}","/**\n * Custom hook for debouncing values\n * Delays updating the value until after the specified delay has passed\n * since the last change\n */\n\nimport { useState, useEffect } from 'react'\n\n/**\n * Debounces a value by the specified delay\n * @param value The value to debounce\n * @param delay The delay in milliseconds\n * @returns The debounced value\n */\nexport function useDebounce<T>(value: T, delay: number): T {\n const [debouncedValue, setDebouncedValue] = useState(value)\n\n useEffect(() => {\n // Set up a timer to update the debounced value after the delay\n const handler = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n // Clean up the timer if the value changes before the delay\n return () => {\n clearTimeout(handler)\n }\n }, [value, delay])\n\n return debouncedValue\n}"],"names":["useCubeQuery","query","options","cubeApi","useCubeContext","state","setState","useState","lastQueryRef","useRef","useEffect","queryString","queryId","prevState","result","err","useFilterValues","fieldName","enabled","values","setValues","currentQuery","setCurrentQuery","lastProcessedQueryId","lastSearchTerm","resultSet","isLoading","queryError","extractValuesFromResultSet","useCallback","rs","data","uniqueValues","row","value","extractedValues","refetch","searchValues","searchTerm","force","useDebounce","delay","debouncedValue","setDebouncedValue","handler"],"mappings":";;;AAgBO,SAASA,EACdC,GACAC,IAA4B,IACR;AACpB,QAAM,EAAE,SAAAC,EAAA,IAAYC,EAAA,GAGd,CAACC,GAAOC,CAAQ,IAAIC,EAA6B;AAAA,IACrD,WAAW;AAAA,IACX,WAAW;AAAA,IACX,OAAO;AAAA,IACP,SAAS;AAAA,EAAA,CACV,GAGKC,IAAeC,EAAe,EAAE;AAEtC,SAAAC,EAAU,MAAM;AAEd,QAAI,CAACT,KAASC,EAAQ;AACpB;AAIF,UAAMS,IAAc,KAAK,UAAUV,CAAK;AAGxC,QAAIU,MAAgBH,EAAa,WAAW,CAACN,EAAQ;AACnD;AAGF,IAAAM,EAAa,UAAUG;AAGvB,UAAMC,IAAU,GAAG,KAAK,IAAA,CAAK,IAAI,KAAK,OAAA,EAAS,SAAS,EAAE,EAAE,UAAU,CAAC,CAAC;AAGxE,IAAAN,EAAS,CAAAO,OAAc;AAAA,MACrB,WAAWX,EAAQ,yBAAyB,OAAOW,EAAU;AAAA,MAC7D,WAAW;AAAA,MACX,OAAO;AAAA,MACP,SAAA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YAAY,CAACgB,CAAS;AAAA,UACtB,OAAO;AAAA,UACP,OAAO,EAAE,CAACA,CAAS,GAAG,MAAA;AAAA,QAAM;AAG9B,QAAIqB,KAAcA,EAAW,WAC3BrC,EAAM,UAAU,CAAC;AAAA,UACf,QAAQgB;AAAA,UACR,UAAU;AAAA,UACV,QAAQ,CAACqB,EAAW,KAAA,CAAM;AAAA,QAAA,CAC3B,IAGHhB,EAAgBrB,CAAK;AAAA,MACvB,SAASc,GAAK;AACZ,gBAAQ,MAAM,gCAAgCA,CAAG;AAAA,MACnD;AAAA;AAAA,EACF,GAAG,CAACE,CAAS,CAAC;AAEd,SAAO;AAAA,IACL,QAAAE;AAAA,IACA,SAASO;AAAA,IACT,OAAOC,IAAcA,aAAsB,QAAQA,EAAW,UAAU,OAAOA,CAAU,IAAK;AAAA,IAC9F,SAAAS;AAAA,IACA,cAAAC;AAAA,EAAA;AAEJ;AC1JO,SAASG,EAAeN,GAAUO,GAAkB;AACzD,QAAM,CAACC,GAAgBC,CAAiB,IAAIpC,EAAS2B,CAAK;AAE1D,SAAAxB,EAAU,MAAM;AAEd,UAAMkC,IAAU,WAAW,MAAM;AAC/B,MAAAD,EAAkBT,CAAK;AAAA,IACzB,GAAGO,CAAK;AAGR,WAAO,MAAM;AACX,mBAAaG,CAAO;AAAA,IACtB;AAAA,EACF,GAAG,CAACV,GAAOO,CAAK,CAAC,GAEVC;AACT;"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export { CubeProvider, useCubeContext } from './providers/CubeProvider';
|
|
|
11
11
|
export { useCubeQuery } from './hooks/useCubeQuery';
|
|
12
12
|
export { createCubeClient } from './client/CubeClient';
|
|
13
13
|
export type { PortletConfig, ChartType, ChartAxisConfig, ChartDisplayConfig, CubeQuery, CubeQueryOptions, CubeApiOptions, DashboardConfig } from './types';
|
|
14
|
+
export type { ChartTypeConfig, DisplayOptionConfig, AxisDropZoneConfig } from './charts/chartConfigs';
|
|
14
15
|
export { createDashboardLayout, formatChartData } from './utils/index';
|
package/dist/client/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnalyticsDashboard as t, AnalyticsPortlet as e, DashboardEditModal as s, DashboardGrid as o, Modal as h, PortletContainer as C, PortletEditModal as c, QueryBuilder as d } from "./components.js";
|
|
2
|
-
import { C as l, c as u, u as R } from "./chunks/providers-
|
|
2
|
+
import { C as l, c as u, u as R } from "./chunks/providers-B7MVnAAt.js";
|
|
3
3
|
import { useCubeQuery as n } from "./hooks.js";
|
|
4
|
-
import { D as f, A as P, B as m, L as p, P as x, R as y, a as A, S as B, T as M, c as L, f as T } from "./chunks/charts-
|
|
4
|
+
import { D as f, A as P, B as m, L as p, P as x, R as y, a as A, S as B, T as M, c as L, f as T } from "./chunks/charts-Dx3asDBi.js";
|
|
5
5
|
export {
|
|
6
6
|
t as AnalyticsDashboard,
|
|
7
7
|
e as AnalyticsPortlet,
|
package/dist/client/providers.js
CHANGED
package/dist/client/types.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
* Type definitions for drizzle-cube client components
|
|
3
|
-
*/
|
|
1
|
+
import { ColorPalette } from './utils/colorPalettes';
|
|
4
2
|
export type { CubeMeta, CubeMetaCube, CubeMetaField, FieldLabelMap } from './hooks/useCubeMeta';
|
|
5
|
-
export type
|
|
3
|
+
export type { ColorPalette } from './utils/colorPalettes';
|
|
4
|
+
export type ChartType = 'line' | 'bar' | 'pie' | 'table' | 'area' | 'scatter' | 'radar' | 'radialBar' | 'treemap' | 'bubble' | 'activityGrid' | 'kpiNumber' | 'kpiText';
|
|
6
5
|
export interface ChartAxisConfig {
|
|
7
6
|
xAxis?: string[];
|
|
8
7
|
yAxis?: string[];
|
|
9
8
|
series?: string[];
|
|
10
9
|
sizeField?: string;
|
|
11
10
|
colorField?: string;
|
|
11
|
+
dateField?: string[];
|
|
12
|
+
valueField?: string[];
|
|
12
13
|
x?: string;
|
|
13
14
|
y?: string[];
|
|
14
15
|
}
|
|
@@ -22,6 +23,14 @@ export interface ChartDisplayConfig {
|
|
|
22
23
|
minBubbleSize?: number;
|
|
23
24
|
maxBubbleSize?: number;
|
|
24
25
|
bubbleOpacity?: number;
|
|
26
|
+
showLabels?: boolean;
|
|
27
|
+
colorIntensity?: 'low' | 'medium' | 'high';
|
|
28
|
+
template?: string;
|
|
29
|
+
prefix?: string;
|
|
30
|
+
suffix?: string;
|
|
31
|
+
decimals?: number;
|
|
32
|
+
valueColor?: string;
|
|
33
|
+
valueColorIndex?: number;
|
|
25
34
|
}
|
|
26
35
|
export interface PortletConfig {
|
|
27
36
|
id: string;
|
|
@@ -40,8 +49,9 @@ export interface DashboardConfig {
|
|
|
40
49
|
layouts?: {
|
|
41
50
|
[key: string]: any;
|
|
42
51
|
};
|
|
52
|
+
colorPalette?: string;
|
|
43
53
|
}
|
|
44
|
-
export type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'gt' | 'gte' | 'lt' | 'lte' | 'set' | 'notSet' | 'inDateRange' | 'beforeDate' | 'afterDate';
|
|
54
|
+
export type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'notStartsWith' | 'endsWith' | 'notEndsWith' | 'like' | 'notLike' | 'ilike' | 'gt' | 'gte' | 'lt' | 'lte' | 'between' | 'notBetween' | 'in' | 'notIn' | 'set' | 'notSet' | 'isEmpty' | 'isNotEmpty' | 'inDateRange' | 'beforeDate' | 'afterDate' | 'regex' | 'notRegex';
|
|
45
55
|
export interface SimpleFilter {
|
|
46
56
|
member: string;
|
|
47
57
|
operator: FilterOperator;
|
|
@@ -92,6 +102,7 @@ export interface AnalyticsPortletProps {
|
|
|
92
102
|
displayConfig?: ChartDisplayConfig;
|
|
93
103
|
height?: string | number;
|
|
94
104
|
title?: string;
|
|
105
|
+
colorPalette?: ColorPalette;
|
|
95
106
|
onDebugDataReady?: (debugData: {
|
|
96
107
|
chartConfig: ChartAxisConfig;
|
|
97
108
|
displayConfig: ChartDisplayConfig;
|
|
@@ -113,6 +124,7 @@ export interface ChartProps {
|
|
|
113
124
|
displayConfig?: ChartDisplayConfig;
|
|
114
125
|
queryObject?: CubeQuery;
|
|
115
126
|
height?: string | number;
|
|
127
|
+
colorPalette?: ColorPalette;
|
|
116
128
|
}
|
|
117
129
|
export interface FeaturesConfig {
|
|
118
130
|
enableAI?: boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Color Palette System
|
|
3
|
+
* Each palette contains coordinated series and gradient colors that work well together
|
|
4
|
+
*/
|
|
5
|
+
export interface ColorPalette {
|
|
6
|
+
name: string;
|
|
7
|
+
label: string;
|
|
8
|
+
colors: string[];
|
|
9
|
+
gradient: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare const COLOR_PALETTES: ColorPalette[];
|
|
12
|
+
/**
|
|
13
|
+
* Get a color palette by name, with fallback to default
|
|
14
|
+
*/
|
|
15
|
+
export declare function getColorPalette(paletteName?: string): ColorPalette;
|
|
16
|
+
/**
|
|
17
|
+
* Get just the series colors for a palette
|
|
18
|
+
*/
|
|
19
|
+
export declare function getSeriesColors(paletteName?: string): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Get just the gradient colors for a palette
|
|
22
|
+
*/
|
|
23
|
+
export declare function getGradientColors(paletteName?: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Chart types that use series colors (discrete categories)
|
|
26
|
+
*/
|
|
27
|
+
export declare const SERIES_CHART_TYPES: readonly ["bar", "line", "area", "pie", "scatter", "radar", "radialBar", "treeMap"];
|
|
28
|
+
/**
|
|
29
|
+
* Chart types that use gradient colors (continuous values)
|
|
30
|
+
*/
|
|
31
|
+
export declare const GRADIENT_CHART_TYPES: readonly ["bubble", "activityGrid"];
|
|
32
|
+
/**
|
|
33
|
+
* Determine if a chart type uses gradient colors
|
|
34
|
+
*/
|
|
35
|
+
export declare function usesGradientColors(chartType: string): boolean;
|