@quillsql/react 2.11.9 → 2.11.12

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.
Files changed (147) hide show
  1. package/dist/cjs/BarList.d.ts +2 -1
  2. package/dist/cjs/BarList.d.ts.map +1 -1
  3. package/dist/cjs/BarList.js +9 -3
  4. package/dist/cjs/Chart.d.ts +11 -5
  5. package/dist/cjs/Chart.d.ts.map +1 -1
  6. package/dist/cjs/Chart.js +57 -20
  7. package/dist/cjs/ChartBuilder.d.ts +16 -1
  8. package/dist/cjs/ChartBuilder.d.ts.map +1 -1
  9. package/dist/cjs/ChartBuilder.js +423 -281
  10. package/dist/cjs/ChartEditor.d.ts.map +1 -1
  11. package/dist/cjs/ChartEditor.js +1 -0
  12. package/dist/cjs/Dashboard.d.ts +2 -1
  13. package/dist/cjs/Dashboard.d.ts.map +1 -1
  14. package/dist/cjs/Dashboard.js +5 -19
  15. package/dist/cjs/PieChart.d.ts.map +1 -1
  16. package/dist/cjs/PieChart.js +2 -1
  17. package/dist/cjs/QuillProvider.d.ts.map +1 -1
  18. package/dist/cjs/QuillProvider.js +15 -1
  19. package/dist/cjs/ReportBuilder.d.ts +4 -3
  20. package/dist/cjs/ReportBuilder.d.ts.map +1 -1
  21. package/dist/cjs/ReportBuilder.js +76 -45
  22. package/dist/cjs/SQLEditor.d.ts +2 -1
  23. package/dist/cjs/SQLEditor.d.ts.map +1 -1
  24. package/dist/cjs/SQLEditor.js +60 -90
  25. package/dist/cjs/components/Chart/BarChart.d.ts +2 -1
  26. package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
  27. package/dist/cjs/components/Chart/BarChart.js +10 -3
  28. package/dist/cjs/components/Chart/LineChart.d.ts +3 -4
  29. package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
  30. package/dist/cjs/components/Chart/LineChart.js +32 -15
  31. package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
  32. package/dist/cjs/components/Dashboard/ChartComponent.js +0 -3
  33. package/dist/cjs/components/Dashboard/DashboardSection.js +4 -4
  34. package/dist/cjs/components/Dashboard/DashboardSectionContainer.js +1 -1
  35. package/dist/cjs/components/Dashboard/DataLoader.d.ts +8 -1
  36. package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
  37. package/dist/cjs/components/Dashboard/DataLoader.js +12 -3
  38. package/dist/cjs/components/Dashboard/MetricComponent.d.ts +12 -1
  39. package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
  40. package/dist/cjs/components/Dashboard/MetricComponent.js +105 -9
  41. package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
  42. package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
  43. package/dist/cjs/components/Dashboard/TableComponent.js +78 -3
  44. package/dist/cjs/components/QuillTable.d.ts.map +1 -1
  45. package/dist/cjs/components/QuillTable.js +3 -1
  46. package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
  47. package/dist/cjs/components/ReportBuilder/AddSortPopover.js +5 -4
  48. package/dist/cjs/components/ReportBuilder/ast.d.ts +4 -0
  49. package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -1
  50. package/dist/cjs/components/ReportBuilder/ast.js +10 -1
  51. package/dist/cjs/components/ReportBuilder/convert.d.ts +4 -1
  52. package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
  53. package/dist/cjs/components/ReportBuilder/convert.js +45 -13
  54. package/dist/cjs/components/ReportBuilder/pivot.d.ts +3 -0
  55. package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -1
  56. package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
  57. package/dist/cjs/components/ReportBuilder/ui.js +3 -2
  58. package/dist/cjs/components/ReportBuilder/util.d.ts +1 -0
  59. package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
  60. package/dist/cjs/components/ReportBuilder/util.js +48 -1
  61. package/dist/cjs/components/UiComponents.d.ts +3 -1
  62. package/dist/cjs/components/UiComponents.d.ts.map +1 -1
  63. package/dist/cjs/components/UiComponents.js +4 -4
  64. package/dist/cjs/hooks/useQuill.js +1 -1
  65. package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
  66. package/dist/cjs/internals/ReportBuilder/PivotModal.js +65 -62
  67. package/dist/cjs/utils/axisFormatter.js +74 -30
  68. package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
  69. package/dist/cjs/utils/dataFetcher.js +10 -0
  70. package/dist/cjs/utils/getDomain.d.ts.map +1 -1
  71. package/dist/cjs/utils/getDomain.js +22 -4
  72. package/dist/cjs/utils/valueFormatter.d.ts +2 -1
  73. package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
  74. package/dist/esm/BarList.d.ts +2 -1
  75. package/dist/esm/BarList.d.ts.map +1 -1
  76. package/dist/esm/BarList.js +9 -3
  77. package/dist/esm/Chart.d.ts +11 -5
  78. package/dist/esm/Chart.d.ts.map +1 -1
  79. package/dist/esm/Chart.js +57 -20
  80. package/dist/esm/ChartBuilder.d.ts +16 -1
  81. package/dist/esm/ChartBuilder.d.ts.map +1 -1
  82. package/dist/esm/ChartBuilder.js +421 -280
  83. package/dist/esm/ChartEditor.d.ts.map +1 -1
  84. package/dist/esm/ChartEditor.js +1 -0
  85. package/dist/esm/Dashboard.d.ts +2 -1
  86. package/dist/esm/Dashboard.d.ts.map +1 -1
  87. package/dist/esm/Dashboard.js +5 -19
  88. package/dist/esm/PieChart.d.ts.map +1 -1
  89. package/dist/esm/PieChart.js +2 -1
  90. package/dist/esm/QuillProvider.d.ts.map +1 -1
  91. package/dist/esm/QuillProvider.js +16 -2
  92. package/dist/esm/ReportBuilder.d.ts +4 -3
  93. package/dist/esm/ReportBuilder.d.ts.map +1 -1
  94. package/dist/esm/ReportBuilder.js +80 -49
  95. package/dist/esm/SQLEditor.d.ts +2 -1
  96. package/dist/esm/SQLEditor.d.ts.map +1 -1
  97. package/dist/esm/SQLEditor.js +61 -91
  98. package/dist/esm/components/Chart/BarChart.d.ts +2 -1
  99. package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
  100. package/dist/esm/components/Chart/BarChart.js +10 -3
  101. package/dist/esm/components/Chart/LineChart.d.ts +3 -4
  102. package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
  103. package/dist/esm/components/Chart/LineChart.js +32 -15
  104. package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
  105. package/dist/esm/components/Dashboard/ChartComponent.js +0 -3
  106. package/dist/esm/components/Dashboard/DashboardSection.js +4 -4
  107. package/dist/esm/components/Dashboard/DashboardSectionContainer.js +1 -1
  108. package/dist/esm/components/Dashboard/DataLoader.d.ts +8 -1
  109. package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
  110. package/dist/esm/components/Dashboard/DataLoader.js +13 -4
  111. package/dist/esm/components/Dashboard/MetricComponent.d.ts +12 -1
  112. package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
  113. package/dist/esm/components/Dashboard/MetricComponent.js +101 -8
  114. package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
  115. package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
  116. package/dist/esm/components/Dashboard/TableComponent.js +74 -2
  117. package/dist/esm/components/QuillTable.d.ts.map +1 -1
  118. package/dist/esm/components/QuillTable.js +3 -1
  119. package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
  120. package/dist/esm/components/ReportBuilder/AddSortPopover.js +6 -5
  121. package/dist/esm/components/ReportBuilder/ast.d.ts +4 -0
  122. package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -1
  123. package/dist/esm/components/ReportBuilder/ast.js +8 -0
  124. package/dist/esm/components/ReportBuilder/convert.d.ts +4 -1
  125. package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
  126. package/dist/esm/components/ReportBuilder/convert.js +45 -13
  127. package/dist/esm/components/ReportBuilder/pivot.d.ts +3 -0
  128. package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -1
  129. package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
  130. package/dist/esm/components/ReportBuilder/ui.js +3 -2
  131. package/dist/esm/components/ReportBuilder/util.d.ts +1 -0
  132. package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
  133. package/dist/esm/components/ReportBuilder/util.js +46 -0
  134. package/dist/esm/components/UiComponents.d.ts +3 -1
  135. package/dist/esm/components/UiComponents.d.ts.map +1 -1
  136. package/dist/esm/components/UiComponents.js +4 -4
  137. package/dist/esm/hooks/useQuill.js +1 -1
  138. package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
  139. package/dist/esm/internals/ReportBuilder/PivotModal.js +65 -62
  140. package/dist/esm/utils/axisFormatter.js +74 -30
  141. package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
  142. package/dist/esm/utils/dataFetcher.js +10 -0
  143. package/dist/esm/utils/getDomain.d.ts.map +1 -1
  144. package/dist/esm/utils/getDomain.js +22 -4
  145. package/dist/esm/utils/valueFormatter.d.ts +2 -1
  146. package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
  147. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SQLEditor.d.ts","sourceRoot":"","sources":["../../src/SQLEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAQxE,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,2BAA2B,CAAC;AAGnC,wBAAgB,qBAAqB,CAAC,MAAM,KAAA;;;;;EAwE3C;AA2BD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACtB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC;IAEpC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;IAC/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AAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAuCD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,cAAoC,EACpC,eAAgC,EAChC,wBAAkD,EAClD,kBAAmC,EACnC,cAA2B,EAC3B,eAAuB,EACvB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,eAAe,EACf,cAAc,EACd,UAAkB,EAClB,mBAA2B,EAC3B,sBAA8B,EAC9B,oBAA4B,EAC5B,wBAAgC,EAChC,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,yBAA8C,EAC9C,aAAyB,EACzB,gBAA4B,EAC5B,0BAAkC,GACnC,EAAE,cAAc,2CA8WhB;AA6JD,eAAO,MAAM,mBAAmB;;;;;;;6CAuG/B,CAAC"}
@@ -1,13 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // @ts-nocheck
3
3
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4
- import { useState, useContext, useEffect } from 'react';
4
+ import { useState, useContext, useEffect, } from 'react';
5
5
  import MonacoEditor from '@monaco-editor/react';
6
6
  // import './nightOwlLight.css';
7
7
  import { ClientContext, SchemaContext, ThemeContext } from './Context';
8
8
  import QuillTable from './components/QuillTable';
9
9
  import { getData, getDataFromCloud } from './utils/dataFetcher';
10
10
  import { ChartBuilderWithModal } from './ChartBuilder';
11
+ import { MemoizedButton, MemoizedSecondaryButton, } from './components/UiComponents';
12
+ import { QuillTextInput } from './components/ReportBuilder/ui';
11
13
  export function convertPostgresColumn(column) {
12
14
  let format;
13
15
  let fieldType;
@@ -122,29 +124,8 @@ const QuillButton = ({ onClick, label, theme, secondary, }) => (_jsx("button", {
122
124
  fontFamily: theme?.fontFamily,
123
125
  height: 38,
124
126
  }, onClick: onClick, children: label }));
125
- const QuillTextInput = ({ onChange, value, id, placeholder, theme, style = {}, }) => {
126
- return (_jsx("input", { style: {
127
- display: 'flex',
128
- flexDirection: 'row',
129
- alignItems: 'center',
130
- paddingLeft: '12px',
131
- paddingRight: '12px',
132
- fontWeight: 'medium',
133
- height: 38,
134
- boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
135
- width: '445px',
136
- backgroundColor: theme?.backgroundColor || 'white',
137
- color: theme?.primaryTextColor,
138
- borderWidth: '1px',
139
- borderColor: theme?.borderColor || '#E7E7E7',
140
- borderStyle: 'solid',
141
- borderRadius: '6px',
142
- ...style
143
- }, id: id, onChange: onChange, value: value, placeholder: placeholder }));
144
- };
145
- export default function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, SecondaryButtonComponent, TextInputComponent, TableComponent = QuillTable, newQueryEnabled = false, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode = false, chartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', dashboardItem = undefined, organizationName = undefined, chartBuilderHorizontalView = false, }) {
127
+ export default function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, TextInputComponent = QuillTextInput, TableComponent = QuillTable, newQueryEnabled = false, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode = false, chartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', dashboardItem = undefined, organizationName = undefined, chartBuilderHorizontalView = false, }) {
146
128
  const [sqlPrompt, setSqlPrompt] = useState('');
147
- const [isOpen, setIsOpen] = useState(false);
148
129
  const [client] = useContext(ClientContext);
149
130
  const [theme] = useContext(ThemeContext);
150
131
  const [query, setQuery] = useState(defaultQuery);
@@ -236,15 +217,6 @@ export default function QueryEditor({ containerStyle = { height: '100vh' }, Butt
236
217
  if (resp.rows.length === 0) {
237
218
  setErrorMessage('No data found');
238
219
  }
239
- // stringify all rows that are either jsonb or json
240
- resp.rows = resp.rows.map((row) => {
241
- for (const key in row) {
242
- if (typeof row[key] === 'object') {
243
- row[key] = JSON.stringify(row[key]);
244
- }
245
- }
246
- return row;
247
- });
248
220
  setRows(resp.rows && resp.rows.length ? resp.rows : []);
249
221
  if (onChangeData) {
250
222
  onChangeData(resp.rows && resp.rows.length ? resp.rows : []);
@@ -263,13 +235,39 @@ export default function QueryEditor({ containerStyle = { height: '100vh' }, Butt
263
235
  return;
264
236
  }
265
237
  };
266
- /* all your useState and useContext calls and your useEffect hooks */
238
+ const handleFixWithAI = async () => {
239
+ try {
240
+ setDisplayTable(false);
241
+ setSqlResponseLoading(true);
242
+ const resp = await getDataFromCloud(client, 'plsfix', {
243
+ initialQuestion: sqlPrompt,
244
+ brokenQuery: query,
245
+ errorMessage: errorMessage,
246
+ });
247
+ setErrorMessage('');
248
+ setQuery(resp.message);
249
+ setSqlResponseLoading(false);
250
+ }
251
+ catch (e) {
252
+ setErrorMessage('Failed to fix query');
253
+ setSqlResponseLoading(false);
254
+ console.log('ERROR: ', e);
255
+ }
256
+ };
257
+ const handleClickSchemaItem = async (event) => {
258
+ const name = event.target.textContent;
259
+ if (query.length > 0) {
260
+ await navigator.clipboard.writeText(name);
261
+ }
262
+ else {
263
+ setQuery(`SELECT * FROM ${name};`);
264
+ }
265
+ };
267
266
  useEffect(() => {
268
267
  if (onChangeQuery) {
269
268
  onChangeQuery(query);
270
269
  }
271
270
  }, [query]);
272
- /* rest of your methods */
273
271
  return (_jsxs("div", { style: containerStyle, children: [(!chartBuilderHorizontalView ||
274
272
  (chartBuilderHorizontalView && !isChartBuilderOpen)) && (_jsx("div", { style: {
275
273
  height: '100%',
@@ -282,22 +280,23 @@ export default function QueryEditor({ containerStyle = { height: '100vh' }, Butt
282
280
  height: '100%',
283
281
  flexDirection: 'row',
284
282
  gap: 20,
285
- }, children: [_jsx(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), _jsxs("div", { style: {
283
+ }, children: [_jsx(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading, onClick: handleClickSchemaItem }), _jsxs("div", { style: {
286
284
  display: 'flex',
287
285
  // gap: 12,
288
286
  flexDirection: 'column',
289
287
  width: 'calc(100% - 290px)',
290
288
  height: '100%',
291
289
  overflowX: 'hidden',
292
- }, children: [_jsxs("div", { style: {
293
- // TODO: change color
294
- background: 'white',
290
+ }, children: [_jsxs("form", { onSubmit: (e) => {
291
+ e.preventDefault();
292
+ handleRunSqlPrompt();
293
+ }, style: {
295
294
  display: 'flex',
296
295
  flexDirection: 'row',
297
- alignItems: 'center',
298
- gap: '10px',
299
- height: 80,
300
- }, children: [_jsx("div", { style: { minWidth: 440, flexGrow: 1 }, children: (TextInputComponent && (_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, style: { width: '100%' }, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }))) || (_jsx(QuillTextInput, { id: "ai-search", value: sqlPrompt, style: { width: '100%' }, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question...", theme: theme })) }), (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || (_jsx(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] }), _jsx("div", { style: { height: 'calc(50% - 40px)' }, children: _jsx(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, newQueryEnabled: newQueryEnabled, handleClearQuery: handleClearQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), _jsxs("div", { style: {
296
+ gap: 12,
297
+ paddingTop: 16,
298
+ paddingBottom: 16,
299
+ }, children: [_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, style: { width: '100%', fontSize: 14 }, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }), (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || (_jsx(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] }), _jsx("div", { style: { height: 'calc(50% - 40px)' }, children: _jsx(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, handleFixWithAI: handleFixWithAI, newQueryEnabled: newQueryEnabled, handleClearQuery: handleClearQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), _jsxs("div", { style: {
301
300
  display: 'flex',
302
301
  flexDirection: 'column',
303
302
  height: 'calc(50% - 108px)',
@@ -310,16 +309,19 @@ export default function QueryEditor({ containerStyle = { height: '100vh' }, Butt
310
309
  color: theme?.primaryTextColor,
311
310
  fontSize: 15,
312
311
  fontWeight: '400',
313
- }, children: _jsx("div", { style: {
314
- padding: 30,
315
- // TODO: change color
316
- background: 'rgba(0,0,0,0.02)',
317
- display: 'inline-block',
318
- flex: 0,
319
- borderRadius: 6,
312
+ width: '100%',
313
+ }, children: _jsxs("div", { style: {
314
+ display: 'flex',
315
+ flexDirection: 'row',
316
+ justifyContent: 'space-between',
317
+ gap: 12,
318
+ background: 'rgba(0,0,0,0.02)', // TODO: change color
320
319
  color: theme?.primaryTextColor,
321
320
  fontFamily: theme?.fontFamily,
322
- }, children: errorMessage }) })), errorMessage || !displayTable ? null : (_jsx(TableComponent, { rows: rows, columns: columns, containerStyle: { height: 'calc(100%)' }, LoadingComponent: LoadingComponent, loading: sqlQueryLoading }))] }), chartBuilderEnabled && rows.length > 0 && (_jsx("div", { style: {
321
+ borderRadius: 6,
322
+ padding: 20,
323
+ width: '100%',
324
+ }, children: [errorMessage, (SecondaryButtonComponent && (_jsx(SecondaryButtonComponent, { onClick: handleFixWithAI, label: "Fix with AI" }))) || (_jsx(QuillButton, { secondary: true, onClick: handleFixWithAI, label: "Fix with AI", theme: theme }))] }) })), errorMessage || !displayTable ? null : (_jsx(TableComponent, { rows: rows, columns: columns, containerStyle: { height: 'calc(100%)' }, LoadingComponent: LoadingComponent, loading: sqlQueryLoading }))] }), chartBuilderEnabled && rows.length > 0 && (_jsx("div", { style: {
323
325
  display: 'flex',
324
326
  flexDirection: 'row',
325
327
  alignItems: 'center',
@@ -328,7 +330,7 @@ export default function QueryEditor({ containerStyle = { height: '100vh' }, Butt
328
330
  height: '70px',
329
331
  }, children: (ButtonComponent && (_jsx(ButtonComponent, { onClick: () => setIsChartBuilderOpen(true), label: addToDashboardButtonLabel }))) || (_jsx(QuillButton, { onClick: () => setIsChartBuilderOpen(true), label: addToDashboardButtonLabel, theme: theme })) }))] })] }) }) })), _jsx(ChartBuilderWithModal, { rows: rows, columns: columns, fields: fields, query: query, horizontalView: chartBuilderHorizontalView, isEditMode: isEditMode, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onAddToDashboardComplete, showTableFormatOptions: showTableFormatOptions, showDateFieldOptions: showDateFieldOptions, showAccessControlOptions: showAccessControlOptions, destinationDashboard: destinationDashboard, title: chartBuilderTitle, button: chartBuilderButtonLabel, buttonLabel: addToDashboardButtonLabel, dashboardItem: dashboardItem, organizationName: organizationName, Modal: ModalComponent, Button: ButtonComponent })] }));
330
332
  }
331
- const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleClearQuery, defineEditorTheme, setEditorTheme, ButtonComponent, SecondaryButtonComponent, newQueryEnabled, theme, loading, LoadingComponent, }) => {
333
+ const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleFixWithAI, handleClearQuery, defineEditorTheme, setEditorTheme, ButtonComponent, SecondaryButtonComponent, newQueryEnabled, theme, loading, LoadingComponent, }) => {
332
334
  return (_jsxs("div", { style: {
333
335
  background: theme.backgroundColor,
334
336
  // maxHeight: 700,
@@ -363,41 +365,9 @@ const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleClearQuery,
363
365
  flexDirection: 'row',
364
366
  alignItems: 'center',
365
367
  height: 70,
366
- }, children: _jsxs("div", { style: { display: 'flex' }, children: [(ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || (_jsx(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })), newQueryEnabled && (_jsx("div", { children: (SecondaryButtonComponent && (_jsx(SecondaryButtonComponent, { onClick: handleClearQuery, label: "Clear query" }))) || (_jsx(QuillButton, { secondary: true, onClick: handleClearQuery, label: "Clear query", theme: theme })) }))] }) })] }));
368
+ }, children: _jsxs("div", { style: { display: 'flex', gap: 12 }, children: [(ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || (_jsx(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })), newQueryEnabled && (_jsx("div", { children: (SecondaryButtonComponent && (_jsx(SecondaryButtonComponent, { onClick: handleClearQuery, label: "Clear query" }))) || (_jsx(QuillButton, { secondary: true, onClick: handleClearQuery, label: "Clear query", theme: theme })) }))] }) })] }));
367
369
  };
368
- const styles = {
369
- columnHeader: {
370
- boxSizing: 'border-box',
371
- flex: '150 0 auto',
372
- minWidth: '50px',
373
- width: '150px',
374
- position: 'relative',
375
- cursor: 'pointer',
376
- background: 'rgb(249, 250, 251)',
377
- borderRight: '1px solid rgb(229, 231, 235)',
378
- whiteSpace: 'nowrap',
379
- display: 'flex',
380
- alignItems: 'center',
381
- overflowX: 'visible',
382
- margin: '0px',
383
- textOverflow: 'ellipsis',
384
- minHeight: '36px',
385
- // 2.25rem * 16px = 36px
386
- },
387
- columnHeaderLabel: {
388
- fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
389
- WebkitTapHighlightColor: 'transparent',
390
- color: 'rgb(55, 65, 81)',
391
- textDecoration: 'none',
392
- fontWeight: 500,
393
- fontSize: '14px', // 0.875rem * 16px = 14px
394
- lineHeight: '20px', // 1.25rem * 16px = 20px
395
- textOverflow: 'ellipsis',
396
- whiteSpace: 'nowrap',
397
- overflow: 'hidden',
398
- },
399
- };
400
- export const SchemaListComponent = ({ schema, theme, loading, LoadingComponent, width, }) => {
370
+ export const SchemaListComponent = ({ schema, theme, loading, LoadingComponent, width, onClick = () => { }, }) => {
401
371
  if (loading) {
402
372
  return (_jsxs("div", { style: {
403
373
  background: theme.backgroundColor,
@@ -425,9 +395,9 @@ export const SchemaListComponent = ({ schema, theme, loading, LoadingComponent,
425
395
  // maxHeight: "100%",
426
396
  paddingLeft: 20,
427
397
  paddingRight: 30,
428
- }, children: schema.map((elem, index) => (_jsx(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index))) }));
398
+ }, children: schema.map((elem, index) => (_jsx(SchemaItem, { elem: elem, theme: theme, index: index, onClick: onClick }, elem.displayName + index))) }));
429
399
  };
430
- function SchemaItem({ elem, theme, index }) {
400
+ function SchemaItem({ elem, theme, index, onClick }) {
431
401
  const [isOpen, setIsOpen] = useState(index === 0);
432
402
  const schemaContainerStyle = {
433
403
  display: 'flex',
@@ -445,12 +415,11 @@ function SchemaItem({ elem, theme, index }) {
445
415
  alignItems: 'center',
446
416
  width: '100%',
447
417
  justifyContent: 'space-between',
448
- cursor: 'pointer',
449
418
  };
450
419
  const schemaRowHoverStyle = {
451
420
  background: theme.selectUnderlayColor,
452
421
  };
453
- return (_jsxs("div", { style: schemaContainerStyle, children: [_jsxs("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, onClick: () => setIsOpen(!isOpen), children: [_jsx("p", { style: {
422
+ return (_jsxs("div", { style: schemaContainerStyle, children: [_jsxs("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, children: [_jsx("p", { style: {
454
423
  marginLeft: theme.padding,
455
424
  fontSize: 13,
456
425
  color: '#384151',
@@ -460,9 +429,10 @@ function SchemaItem({ elem, theme, index }) {
460
429
  margin: 0,
461
430
  textOverflow: 'ellipsis',
462
431
  overflow: 'hidden',
432
+ cursor: 'pointer',
463
433
  userSelect: 'none',
464
434
  fontFamily: theme?.fontFamily,
465
- }, title: elem.displayName, children: elem.displayName }), _jsx("div", { style: {
435
+ }, title: elem.displayName, onClick: onClick, children: elem.displayName }), _jsx("div", { style: {
466
436
  display: 'flex',
467
437
  alignItems: 'center',
468
438
  justifyContent: 'center',
@@ -472,7 +442,7 @@ function SchemaItem({ elem, theme, index }) {
472
442
  paddingLeft: 0,
473
443
  cursor: 'pointer',
474
444
  userSelect: 'none',
475
- }, children: isOpen ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: _jsx("path", { fillRule: "evenodd", d: "M12.53 16.28a.75.75 0 01-1.06 0l-7.5-7.5a.75.75 0 011.06-1.06L12 14.69l6.97-6.97a.75.75 0 111.06 1.06l-7.5 7.5z", clipRule: "evenodd" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: _jsx("path", { fillRule: "evenodd", d: "M16.28 11.47a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 011.06-1.06l7.5 7.5z", clipRule: "evenodd" }) })) })] }), isOpen ? (_jsx("div", { style: {
445
+ }, onClick: () => setIsOpen(!isOpen), children: isOpen ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: _jsx("path", { fillRule: "evenodd", d: "M12.53 16.28a.75.75 0 01-1.06 0l-7.5-7.5a.75.75 0 011.06-1.06L12 14.69l6.97-6.97a.75.75 0 111.06 1.06l-7.5 7.5z", clipRule: "evenodd" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: _jsx("path", { fillRule: "evenodd", d: "M16.28 11.47a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 011.06-1.06l7.5 7.5z", clipRule: "evenodd" }) })) })] }), isOpen ? (_jsx("div", { style: {
476
446
  paddingBottom: theme.padding,
477
447
  display: 'flex',
478
448
  flexDirection: 'column',
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import { type ColorMapType } from '../../Chart';
2
3
  export default function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isStacked, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, }: {
3
4
  colors?: string[];
4
- colorMap?: any;
5
+ colorMap?: ColorMapType;
5
6
  yAxisFields: any[];
6
7
  data: any[];
7
8
  containerStyle?: React.CSSProperties;
@@ -1 +1 @@
1
- {"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,GAC1B,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,GA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B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,2CAgLA"}
@@ -23,6 +23,13 @@ export default function BarChart({ colors, colorMap, yAxisFields, data, containe
23
23
  });
24
24
  setFormattedData(curData);
25
25
  }, [data]);
26
+ const getCustomColor = (field) => {
27
+ const key = field.startsWith('comparison_') ? 'comparison' : 'primary';
28
+ field = field.replace('comparison_', '');
29
+ if (colorMap && colorMap[field])
30
+ return colorMap[field][key];
31
+ return undefined;
32
+ };
26
33
  if (!data || data.length === 0) {
27
34
  return (_jsx("div", { style: {
28
35
  display: 'flex',
@@ -39,12 +46,12 @@ export default function BarChart({ colors, colorMap, yAxisFields, data, containe
39
46
  return (_jsx("div", { style: {
40
47
  boxSizing: 'content-box',
41
48
  ...containerStyle,
42
- }, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsBarChart, { data: formattedData, layout: 'horizontal', children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), _jsx(YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: getDomain(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, style: {
49
+ }, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsBarChart, { data: formattedData, layout: 'horizontal', children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), _jsx(YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: getDomain(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, tickCount: 5, style: {
43
50
  fontSize: '12px',
44
51
  fontFamily: theme.chartLabelFontFamily,
45
52
  }, tickFormatter: (tick) => axisFormatter({
46
53
  value: tick,
47
- field: yAxisFields[0].field || 'what',
54
+ field: yAxisFields[0]?.field,
48
55
  fields: yAxisFields,
49
56
  }) }), _jsx(XAxis, { hide: hideXAxis, dataKey: xAxisField, tick: { transform: 'translate(0, 6)' }, style: {
50
57
  fontSize: '12px',
@@ -73,7 +80,7 @@ export default function BarChart({ colors, colorMap, yAxisFields, data, containe
73
80
  }, position: { y: 0 } }), yAxisFields.map((elem) => {
74
81
  return (_jsx(Bar, { name: elem.label, dataKey: elem.field, stackId: isStacked &&
75
82
  (elem.field?.replace('comparison_', '') ??
76
- 'unknown'), type: "linear", fill: (colorMap && colorMap[elem.field]) ??
83
+ 'unknown'), type: "linear", fill: getCustomColor(elem.field) ??
77
84
  selectColor(elem, colors, yAxisFields.findIndex((field) => field.field === elem.field?.replace('comparison_', ''))), isAnimationActive: isAnimationActive }, elem.field));
78
85
  })] }) }) }));
79
86
  }
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
- export default function LineChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dashedComparison, customPrimaryColor, customComparisonColor, singlePointStyle, }: {
2
+ import { type ColorMapType } from '../../Chart';
3
+ export default function LineChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dashedComparison, singlePointStyle, }: {
3
4
  colors?: string[];
4
- colorMap?: any;
5
+ colorMap?: ColorMapType;
5
6
  yAxisFields: any[];
6
7
  data: any[];
7
8
  containerStyle?: React.CSSProperties;
@@ -15,8 +16,6 @@ export default function LineChart({ colors, colorMap, yAxisFields, data, contain
15
16
  hideYAxis: boolean;
16
17
  hideCartesianGrid: boolean;
17
18
  dashedComparison: boolean;
18
- customPrimaryColor: string | undefined;
19
- customComparisonColor: string | undefined;
20
19
  singlePointStyle: 'dot' | 'line';
21
20
  }): import("react/jsx-runtime").JSX.Element | null;
22
21
  //# sourceMappingURL=LineChart.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAiBA,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,gBAAwB,EACxB,kBAA8B,EAC9B,qBAAiC,EACjC,gBAAwB,GACzB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC,kDAkOA"}
1
+ {"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,gBAAwB,EACxB,gBAAwB,GACzB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC,kDA6OA"}
@@ -7,7 +7,8 @@ import { selectColor } from '../../utils/color';
7
7
  import ChartTooltip from '../../components/Chart/ChartTooltip';
8
8
  import getDomain from '../../utils/getDomain';
9
9
  import { useEffect, useState } from 'react';
10
- export default function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, dashedComparison = false, customPrimaryColor = undefined, customComparisonColor = undefined, singlePointStyle = 'dot', }) {
10
+ import { hashCode } from '../../utils/crypto';
11
+ export default function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, dashedComparison = false, singlePointStyle = 'dot', }) {
11
12
  const [formattedData, setFormattedData] = useState([]);
12
13
  if (!yAxisFields || !yAxisFields.length) {
13
14
  return null;
@@ -44,19 +45,21 @@ export default function LineChart({ colors, colorMap = {}, yAxisFields, data, co
44
45
  fontSize: 13,
45
46
  color: theme.secondaryTextColor,
46
47
  ...containerStyle,
47
- }, children: "No results found for specified time period." }));
48
+ }, children: "No results" }));
48
49
  }
49
50
  // Allows the users to override the color scheme on a per-chart basis.
50
- const getCustomColor = (index, field) => {
51
- if (index === 0 && customPrimaryColor) {
52
- return customPrimaryColor;
53
- }
54
- if (index === 1 && comparison && customComparisonColor) {
55
- return customComparisonColor;
56
- }
51
+ const getCustomColor = (index, field, gradient) => {
52
+ let key = index === 0 ? 'primary' : 'comparison';
57
53
  if (colorMap && colorMap[field]) {
58
- // console.log(field, '->', colorMap[field]);
59
- return colorMap[field];
54
+ if (index === 0 && gradient === 'start')
55
+ key = 'primaryGradientStart';
56
+ if (index === 0 && gradient === 'stop')
57
+ key = 'primaryGradientStop';
58
+ if (index === 1 && gradient === 'start')
59
+ key = 'comparisonGradientStart';
60
+ if (index === 1 && gradient === 'stop')
61
+ key = 'comparisonGradientStop';
62
+ return colorMap[field][key];
60
63
  }
61
64
  return undefined; // use the default colors from the theme
62
65
  };
@@ -72,7 +75,7 @@ export default function LineChart({ colors, colorMap = {}, yAxisFields, data, co
72
75
  field: xAxisField,
73
76
  fields: [{ field: xAxisField, format: xAxisFormat }],
74
77
  });
75
- } }), _jsx(YAxis, { hide: hideYAxis, width: 44, axisLine: false, tickLine: false, type: "number", domain: getDomain(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, style: {
78
+ } }), _jsx(YAxis, { hide: hideYAxis, width: 44, axisLine: false, tickLine: false, type: "number", domain: getDomain(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, tickCount: 5, style: {
76
79
  fontSize: '12px',
77
80
  fontFamily: theme?.chartLabelFontFamily ||
78
81
  theme?.fontFamily ||
@@ -104,7 +107,21 @@ export default function LineChart({ colors, colorMap = {}, yAxisFields, data, co
104
107
  { field: xAxisField, format: xAxisFormat },
105
108
  ],
106
109
  }), xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, theme: theme }));
107
- }, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${elem.field}${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: getCustomColor(index, elem.field) ??
108
- selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index, elem.field) ??
109
- selectColor(elem, colors, index), fill: `url(#gradient${elem.field}${index})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && dashedComparison && index > 0 ? '5 5' : undefined, isAnimationActive: isAnimationActive }, elem.field)))] }) }) }));
110
+ }, position: { y: 0 } }), yAxisFields.map((elem, index) => {
111
+ // hash the color stops so they're stable, valid html ids
112
+ const gradientStart = getCustomColor(index, elem.field, 'start') ??
113
+ selectColor(elem, colors, index);
114
+ const gradientStop = getCustomColor(index, elem.field, 'stop') ?? '#00000000';
115
+ const uniqueId = `gradient_${hashCode(gradientStart)}_${hashCode(gradientStop)}`;
116
+ return (_jsx("defs", { children: _jsxs("linearGradient", { id: uniqueId, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: gradientStart, stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: gradientStop, stopOpacity: 0 })] }) }, `defs_${uniqueId}_${index}`));
117
+ }), yAxisFields.map((elem, index) => {
118
+ const gradientStart = hashCode(getCustomColor(index, elem.field, 'start') ??
119
+ selectColor(elem, colors, index));
120
+ const gradientStop = hashCode(getCustomColor(index, elem.field, 'stop') ?? '#00000000');
121
+ const uniqueId = `gradient_${gradientStart}_${gradientStop}`;
122
+ return (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index, elem.field) ??
123
+ selectColor(elem, colors, index), fill: `url(#${uniqueId})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && dashedComparison && index > 0
124
+ ? '5 5'
125
+ : undefined, isAnimationActive: isAnimationActive }, elem.field));
126
+ })] }) }) }));
110
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChartComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/ChartComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAqGnB"}
1
+ {"version":3,"file":"ChartComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/ChartComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAkGnB"}
@@ -3,13 +3,10 @@ export default function DashboardItem({ dashboardItem, onClickDashboardItem, the
3
3
  return (_jsx("div", { onClick: onClickDashboardItem
4
4
  ? () => onClickDashboardItem(dashboardItem)
5
5
  : () => { }, style: {
6
- // height: '100%',
7
6
  cursor: 'pointer',
8
7
  boxSizing: 'content-box',
9
- paddingRight: 25,
10
8
  minHeight: 400,
11
9
  borderRadius: 8,
12
- paddingTop: 20,
13
10
  ...style,
14
11
  }, children: _jsx("div", { style: {
15
12
  width: '100%',
@@ -4,8 +4,8 @@ export default function DashboardSection({ section, children, }) {
4
4
  if (section === 'tables')
5
5
  return (_jsx("div", { style: {
6
6
  boxSizing: 'content-box',
7
- width: `100%`,
8
- gap: 20,
7
+ width: '100%',
8
+ gap: 40,
9
9
  display: 'flex',
10
10
  flexDirection: 'column',
11
11
  }, children: children }));
@@ -15,8 +15,8 @@ export default function DashboardSection({ section, children, }) {
15
15
  width: '100%',
16
16
  listStyleType: 'none',
17
17
  display: 'grid',
18
- gap: 20,
19
- gridTemplateColumns: `repeat(auto-fill,minmax(400px, 1fr))`,
18
+ gap: 40,
19
+ gridTemplateColumns: 'repeat(auto-fill,minmax(400px, 1fr))',
20
20
  gridTemplateRows: `repeat(${170}px)`,
21
21
  }, children: children }));
22
22
  }
@@ -4,7 +4,7 @@ export default function DashboardSectionContainer({ style, children, ...props })
4
4
  width: '100%',
5
5
  display: 'flex',
6
6
  flexDirection: 'column',
7
- gap: 20,
7
+ gap: 40,
8
8
  ...style,
9
9
  }, ...props, children: children }));
10
10
  }
@@ -1,3 +1,10 @@
1
1
  /// <reference types="react" />
2
- export default function DataLoader({ id, children }: any): JSX.Element;
2
+ export type DataLoaderChildProps = {
3
+ isLoading: boolean;
4
+ error: string | null;
5
+ };
6
+ export default function DataLoader({ id, children, }: {
7
+ id: string;
8
+ children: ({ isLoading, error }: DataLoaderChildProps) => JSX.Element;
9
+ }): JSX.Element;
3
10
  //# sourceMappingURL=DataLoader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAWA,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAuErE"}
1
+ {"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAUA,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,EAAE,EACF,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;CACvE,GAAG,GAAG,CAAC,OAAO,CA+Ed"}
@@ -1,16 +1,20 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { useContext, useEffect } from 'react';
2
+ import { useContext, useEffect, useState } from 'react';
3
3
  import { didFiltersChange } from '../../Chart';
4
4
  import { ClientContext, DashboardContext, DashboardFiltersContext, } from '../../Context';
5
5
  import { getData } from '../../utils/dataFetcher';
6
6
  import { mergeComparisonRange } from '../../utils/merge';
7
- export default function DataLoader({ id, children }) {
7
+ export default function DataLoader({ id, children, }) {
8
8
  const [client, _] = useContext(ClientContext);
9
9
  const { dispatch, dashboard } = useContext(DashboardContext);
10
10
  const { dashboardFilters } = useContext(DashboardFiltersContext);
11
+ const [isLoading, setIsLoading] = useState(true);
12
+ const [error, setError] = useState(null);
11
13
  useEffect(() => {
12
14
  async function getChartOptions() {
15
+ setIsLoading(true);
13
16
  if (!didFiltersChange(dashboard[id], dashboardFilters)) {
17
+ setIsLoading(false);
14
18
  return;
15
19
  }
16
20
  try {
@@ -41,7 +45,7 @@ export default function DataLoader({ id, children }) {
41
45
  filters: minimalFilters,
42
46
  };
43
47
  const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
44
- if (resp && resp.name !== 'error') {
48
+ if (resp && resp.name !== 'error' && !resp.errorMessage) {
45
49
  if (resp.compareRows) {
46
50
  mergeComparisonRange(resp);
47
51
  }
@@ -55,12 +59,17 @@ export default function DataLoader({ id, children }) {
55
59
  },
56
60
  });
57
61
  }
62
+ else {
63
+ setError(resp?.errorMessage);
64
+ }
65
+ setIsLoading(false);
58
66
  }
59
67
  catch (e) {
60
68
  console.log('Error fetching chart: ', e);
69
+ setError(e.message);
61
70
  }
62
71
  }
63
72
  getChartOptions();
64
73
  }, [dashboardFilters, client, id]);
65
- return _jsx(_Fragment, { children: children });
74
+ return _jsx(_Fragment, { children: children({ isLoading, error }) });
66
75
  }
@@ -1,3 +1,14 @@
1
1
  /// <reference types="react" />
2
- export default function DashboardItem({ dashboardItem, onClickDashboardItem, theme, style, children, }: any): JSX.Element;
2
+ import { DashboardItem } from '../../Dashboard';
3
+ interface DashboardItemProps {
4
+ dashboardItem: DashboardItem;
5
+ onClickDashboardItem?: any;
6
+ error?: string | null;
7
+ isLoading?: boolean;
8
+ children?: any;
9
+ theme?: any;
10
+ style?: any;
11
+ }
12
+ export default function QuillMetricComponent({ dashboardItem, onClickDashboardItem, error, isLoading, theme, style, }: DashboardItemProps): JSX.Element;
13
+ export {};
3
14
  //# sourceMappingURL=MetricComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAsGnB"}
1
+ {"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,UAAU,kBAAkB;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,oBAAoB,CAAC,EAAE,GAAG,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,KAAK,EACL,KAAK,GACN,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAkPlC"}