@peak-ai/canvas 1.4.22 → 1.4.23

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 (209) hide show
  1. package/package.json +7 -45
  2. package/.babelrc +0 -14
  3. package/.eslintcache +0 -1
  4. package/.eslintignore +0 -5
  5. package/.eslintrc.js +0 -29
  6. package/dist/package.json +0 -62
  7. package/scripts/build.ts +0 -120
  8. package/src/GrapesjsCanvas.tsx +0 -494
  9. package/src/constants/index.ts +0 -25
  10. package/src/declaration.d.ts +0 -1
  11. package/src/helpers/compiled-table.css +0 -2429
  12. package/src/helpers/css.ts +0 -2667
  13. package/src/helpers/date-picker.ts +0 -807
  14. package/src/helpers/filter-placeholder.ts +0 -18
  15. package/src/helpers/index.ts +0 -13
  16. package/src/helpers/merge-json.ts +0 -106
  17. package/src/index.styles.ts +0 -58
  18. package/src/index.ts +0 -9
  19. package/src/plugins/grapejs-plugin.tsx +0 -196
  20. package/src/plugins/helpers/custom-modal.tsx +0 -123
  21. package/src/plugins/helpers/data-table.tsx +0 -300
  22. package/src/plugins/helpers/extra.tsx +0 -164
  23. package/src/plugins/helpers/query-cache-context.tsx +0 -154
  24. package/src/plugins/helpers/query-cache-singleton.ts +0 -176
  25. package/src/plugins/helpers/query-cache-utils.ts +0 -226
  26. package/src/plugins/helpers/query-details-modal.tsx +0 -400
  27. package/src/plugins/helpers/query-heading-formatter.ts +0 -24
  28. package/src/plugins/helpers/query-loading-modal.tsx +0 -94
  29. package/src/plugins/helpers/render-components.tsx +0 -1450
  30. package/src/plugins/helpers/styled-info-button.tsx +0 -504
  31. package/src/public/canvas.css +0 -42
  32. package/src/public/components-css/table/table-output.css +0 -2436
  33. package/src/public/components-css/table/table.css +0 -30
  34. package/src/public/output.css +0 -2465
  35. package/src/public/table.css +0 -135
  36. package/src/shadcn/components/icons/AiAvatarIcon.tsx +0 -47
  37. package/src/shadcn/components/icons/Co_driver Expanding button copy.svg +0 -21
  38. package/src/shadcn/components/icons/ai-avatar.svg +0 -7
  39. package/src/shadcn/components/icons/thinking.gif +0 -0
  40. package/src/shadcn/components/ui/button.tsx +0 -132
  41. package/src/shadcn/components/ui/card.tsx +0 -92
  42. package/src/shadcn/components/ui/chart.tsx +0 -324
  43. package/src/shadcn/components/ui/checkbox.tsx +0 -27
  44. package/src/shadcn/components/ui/component-wrapper.tsx +0 -61
  45. package/src/shadcn/components/ui/date-filter.tsx +0 -816
  46. package/src/shadcn/components/ui/error-container.tsx +0 -125
  47. package/src/shadcn/components/ui/error-wrapper.tsx +0 -99
  48. package/src/shadcn/components/ui/filter.tsx +0 -368
  49. package/src/shadcn/components/ui/hover-card.tsx +0 -36
  50. package/src/shadcn/components/ui/input.tsx +0 -20
  51. package/src/shadcn/components/ui/label.tsx +0 -24
  52. package/src/shadcn/components/ui/pagination.tsx +0 -213
  53. package/src/shadcn/components/ui/scroll-area.tsx +0 -59
  54. package/src/shadcn/components/ui/search.tsx +0 -150
  55. package/src/shadcn/components/ui/separator.tsx +0 -26
  56. package/src/shadcn/components/ui/skeleton.tsx +0 -69
  57. package/src/shadcn/components/ui/table.tsx +0 -196
  58. package/src/shadcn/components/ui/tabs.tsx +0 -55
  59. package/src/shadcn/components/ui/textarea.tsx +0 -18
  60. package/src/shadcn/components/ui/tooltip.tsx +0 -87
  61. package/src/shadcn/utils.ts +0 -6
  62. package/src/types/grapesjs-tailwind.d.ts +0 -61
  63. package/src/types/images.d.ts +0 -1
  64. package/tailwind.config.js +0 -5
  65. package/tooling/tailwind-compiler/index.js +0 -99
  66. package/tooling/tailwind-compiler/package.json +0 -11
  67. package/tooling/tailwind-compiler/yarn.lock +0 -123
  68. package/tsconfig.build.json +0 -15
  69. package/tsconfig.json +0 -8
  70. /package/{dist/GrapesjsCanvas.d.ts → GrapesjsCanvas.d.ts} +0 -0
  71. /package/{dist/GrapesjsCanvas.js → GrapesjsCanvas.js} +0 -0
  72. /package/{dist/GrapesjsCanvas.js.map → GrapesjsCanvas.js.map} +0 -0
  73. /package/{dist/constants → constants}/index.d.ts +0 -0
  74. /package/{dist/constants → constants}/index.js +0 -0
  75. /package/{dist/constants → constants}/index.js.map +0 -0
  76. /package/{dist/declaration.d.js → declaration.d.js} +0 -0
  77. /package/{dist/declaration.d.js.map → declaration.d.js.map} +0 -0
  78. /package/{dist/helpers → helpers}/compiled-table.css +0 -0
  79. /package/{dist/helpers → helpers}/css.d.ts +0 -0
  80. /package/{dist/helpers → helpers}/css.js +0 -0
  81. /package/{dist/helpers → helpers}/css.js.map +0 -0
  82. /package/{dist/helpers → helpers}/date-picker.d.ts +0 -0
  83. /package/{dist/helpers → helpers}/date-picker.js +0 -0
  84. /package/{dist/helpers → helpers}/date-picker.js.map +0 -0
  85. /package/{dist/helpers → helpers}/filter-placeholder.d.ts +0 -0
  86. /package/{dist/helpers → helpers}/filter-placeholder.js +0 -0
  87. /package/{dist/helpers → helpers}/filter-placeholder.js.map +0 -0
  88. /package/{dist/helpers → helpers}/index.d.ts +0 -0
  89. /package/{dist/helpers → helpers}/index.js +0 -0
  90. /package/{dist/helpers → helpers}/index.js.map +0 -0
  91. /package/{dist/helpers → helpers}/merge-json.d.ts +0 -0
  92. /package/{dist/helpers → helpers}/merge-json.js +0 -0
  93. /package/{dist/helpers → helpers}/merge-json.js.map +0 -0
  94. /package/{dist/index.d.ts → index.d.ts} +0 -0
  95. /package/{dist/index.js → index.js} +0 -0
  96. /package/{dist/index.js.map → index.js.map} +0 -0
  97. /package/{dist/index.styles.d.ts → index.styles.d.ts} +0 -0
  98. /package/{dist/index.styles.js → index.styles.js} +0 -0
  99. /package/{dist/index.styles.js.map → index.styles.js.map} +0 -0
  100. /package/{dist/plugins → plugins}/grapejs-plugin.d.ts +0 -0
  101. /package/{dist/plugins → plugins}/grapejs-plugin.js +0 -0
  102. /package/{dist/plugins → plugins}/grapejs-plugin.js.map +0 -0
  103. /package/{dist/plugins → plugins}/helpers/custom-modal.d.ts +0 -0
  104. /package/{dist/plugins → plugins}/helpers/custom-modal.js +0 -0
  105. /package/{dist/plugins → plugins}/helpers/custom-modal.js.map +0 -0
  106. /package/{dist/plugins → plugins}/helpers/data-table.d.ts +0 -0
  107. /package/{dist/plugins → plugins}/helpers/data-table.js +0 -0
  108. /package/{dist/plugins → plugins}/helpers/data-table.js.map +0 -0
  109. /package/{dist/plugins → plugins}/helpers/extra.d.ts +0 -0
  110. /package/{dist/plugins → plugins}/helpers/extra.js +0 -0
  111. /package/{dist/plugins → plugins}/helpers/extra.js.map +0 -0
  112. /package/{dist/plugins → plugins}/helpers/query-cache-context.d.ts +0 -0
  113. /package/{dist/plugins → plugins}/helpers/query-cache-context.js +0 -0
  114. /package/{dist/plugins → plugins}/helpers/query-cache-context.js.map +0 -0
  115. /package/{dist/plugins → plugins}/helpers/query-cache-singleton.d.ts +0 -0
  116. /package/{dist/plugins → plugins}/helpers/query-cache-singleton.js +0 -0
  117. /package/{dist/plugins → plugins}/helpers/query-cache-singleton.js.map +0 -0
  118. /package/{dist/plugins → plugins}/helpers/query-cache-utils.d.ts +0 -0
  119. /package/{dist/plugins → plugins}/helpers/query-cache-utils.js +0 -0
  120. /package/{dist/plugins → plugins}/helpers/query-cache-utils.js.map +0 -0
  121. /package/{dist/plugins → plugins}/helpers/query-details-modal.d.ts +0 -0
  122. /package/{dist/plugins → plugins}/helpers/query-details-modal.js +0 -0
  123. /package/{dist/plugins → plugins}/helpers/query-details-modal.js.map +0 -0
  124. /package/{dist/plugins → plugins}/helpers/query-heading-formatter.d.ts +0 -0
  125. /package/{dist/plugins → plugins}/helpers/query-heading-formatter.js +0 -0
  126. /package/{dist/plugins → plugins}/helpers/query-heading-formatter.js.map +0 -0
  127. /package/{dist/plugins → plugins}/helpers/query-loading-modal.d.ts +0 -0
  128. /package/{dist/plugins → plugins}/helpers/query-loading-modal.js +0 -0
  129. /package/{dist/plugins → plugins}/helpers/query-loading-modal.js.map +0 -0
  130. /package/{dist/plugins → plugins}/helpers/render-components.d.ts +0 -0
  131. /package/{dist/plugins → plugins}/helpers/render-components.js +0 -0
  132. /package/{dist/plugins → plugins}/helpers/render-components.js.map +0 -0
  133. /package/{dist/plugins → plugins}/helpers/styled-info-button.d.ts +0 -0
  134. /package/{dist/plugins → plugins}/helpers/styled-info-button.js +0 -0
  135. /package/{dist/plugins → plugins}/helpers/styled-info-button.js.map +0 -0
  136. /package/{dist/shadcn → shadcn}/components/icons/AiAvatarIcon.d.ts +0 -0
  137. /package/{dist/shadcn → shadcn}/components/icons/AiAvatarIcon.js +0 -0
  138. /package/{dist/shadcn → shadcn}/components/icons/AiAvatarIcon.js.map +0 -0
  139. /package/{dist/shadcn → shadcn}/components/icons/thinking.gif +0 -0
  140. /package/{dist/shadcn → shadcn}/components/ui/button.d.ts +0 -0
  141. /package/{dist/shadcn → shadcn}/components/ui/button.js +0 -0
  142. /package/{dist/shadcn → shadcn}/components/ui/button.js.map +0 -0
  143. /package/{dist/shadcn → shadcn}/components/ui/card.d.ts +0 -0
  144. /package/{dist/shadcn → shadcn}/components/ui/card.js +0 -0
  145. /package/{dist/shadcn → shadcn}/components/ui/card.js.map +0 -0
  146. /package/{dist/shadcn → shadcn}/components/ui/chart.d.ts +0 -0
  147. /package/{dist/shadcn → shadcn}/components/ui/chart.js +0 -0
  148. /package/{dist/shadcn → shadcn}/components/ui/chart.js.map +0 -0
  149. /package/{dist/shadcn → shadcn}/components/ui/checkbox.d.ts +0 -0
  150. /package/{dist/shadcn → shadcn}/components/ui/checkbox.js +0 -0
  151. /package/{dist/shadcn → shadcn}/components/ui/checkbox.js.map +0 -0
  152. /package/{dist/shadcn → shadcn}/components/ui/component-wrapper.d.ts +0 -0
  153. /package/{dist/shadcn → shadcn}/components/ui/component-wrapper.js +0 -0
  154. /package/{dist/shadcn → shadcn}/components/ui/component-wrapper.js.map +0 -0
  155. /package/{dist/shadcn → shadcn}/components/ui/date-filter.d.ts +0 -0
  156. /package/{dist/shadcn → shadcn}/components/ui/date-filter.js +0 -0
  157. /package/{dist/shadcn → shadcn}/components/ui/date-filter.js.map +0 -0
  158. /package/{dist/shadcn → shadcn}/components/ui/error-container.d.ts +0 -0
  159. /package/{dist/shadcn → shadcn}/components/ui/error-container.js +0 -0
  160. /package/{dist/shadcn → shadcn}/components/ui/error-container.js.map +0 -0
  161. /package/{dist/shadcn → shadcn}/components/ui/error-wrapper.d.ts +0 -0
  162. /package/{dist/shadcn → shadcn}/components/ui/error-wrapper.js +0 -0
  163. /package/{dist/shadcn → shadcn}/components/ui/error-wrapper.js.map +0 -0
  164. /package/{dist/shadcn → shadcn}/components/ui/filter.d.ts +0 -0
  165. /package/{dist/shadcn → shadcn}/components/ui/filter.js +0 -0
  166. /package/{dist/shadcn → shadcn}/components/ui/filter.js.map +0 -0
  167. /package/{dist/shadcn → shadcn}/components/ui/hover-card.d.ts +0 -0
  168. /package/{dist/shadcn → shadcn}/components/ui/hover-card.js +0 -0
  169. /package/{dist/shadcn → shadcn}/components/ui/hover-card.js.map +0 -0
  170. /package/{dist/shadcn → shadcn}/components/ui/input.d.ts +0 -0
  171. /package/{dist/shadcn → shadcn}/components/ui/input.js +0 -0
  172. /package/{dist/shadcn → shadcn}/components/ui/input.js.map +0 -0
  173. /package/{dist/shadcn → shadcn}/components/ui/label.d.ts +0 -0
  174. /package/{dist/shadcn → shadcn}/components/ui/label.js +0 -0
  175. /package/{dist/shadcn → shadcn}/components/ui/label.js.map +0 -0
  176. /package/{dist/shadcn → shadcn}/components/ui/pagination.d.ts +0 -0
  177. /package/{dist/shadcn → shadcn}/components/ui/pagination.js +0 -0
  178. /package/{dist/shadcn → shadcn}/components/ui/pagination.js.map +0 -0
  179. /package/{dist/shadcn → shadcn}/components/ui/scroll-area.d.ts +0 -0
  180. /package/{dist/shadcn → shadcn}/components/ui/scroll-area.js +0 -0
  181. /package/{dist/shadcn → shadcn}/components/ui/scroll-area.js.map +0 -0
  182. /package/{dist/shadcn → shadcn}/components/ui/search.d.ts +0 -0
  183. /package/{dist/shadcn → shadcn}/components/ui/search.js +0 -0
  184. /package/{dist/shadcn → shadcn}/components/ui/search.js.map +0 -0
  185. /package/{dist/shadcn → shadcn}/components/ui/separator.d.ts +0 -0
  186. /package/{dist/shadcn → shadcn}/components/ui/separator.js +0 -0
  187. /package/{dist/shadcn → shadcn}/components/ui/separator.js.map +0 -0
  188. /package/{dist/shadcn → shadcn}/components/ui/skeleton.d.ts +0 -0
  189. /package/{dist/shadcn → shadcn}/components/ui/skeleton.js +0 -0
  190. /package/{dist/shadcn → shadcn}/components/ui/skeleton.js.map +0 -0
  191. /package/{dist/shadcn → shadcn}/components/ui/table.d.ts +0 -0
  192. /package/{dist/shadcn → shadcn}/components/ui/table.js +0 -0
  193. /package/{dist/shadcn → shadcn}/components/ui/table.js.map +0 -0
  194. /package/{dist/shadcn → shadcn}/components/ui/tabs.d.ts +0 -0
  195. /package/{dist/shadcn → shadcn}/components/ui/tabs.js +0 -0
  196. /package/{dist/shadcn → shadcn}/components/ui/tabs.js.map +0 -0
  197. /package/{dist/shadcn → shadcn}/components/ui/textarea.d.ts +0 -0
  198. /package/{dist/shadcn → shadcn}/components/ui/textarea.js +0 -0
  199. /package/{dist/shadcn → shadcn}/components/ui/textarea.js.map +0 -0
  200. /package/{dist/shadcn → shadcn}/components/ui/tooltip.d.ts +0 -0
  201. /package/{dist/shadcn → shadcn}/components/ui/tooltip.js +0 -0
  202. /package/{dist/shadcn → shadcn}/components/ui/tooltip.js.map +0 -0
  203. /package/{dist/shadcn → shadcn}/utils.d.ts +0 -0
  204. /package/{dist/shadcn → shadcn}/utils.js +0 -0
  205. /package/{dist/shadcn → shadcn}/utils.js.map +0 -0
  206. /package/{dist/types → types}/grapesjs-tailwind.d.js +0 -0
  207. /package/{dist/types → types}/grapesjs-tailwind.d.js.map +0 -0
  208. /package/{dist/types → types}/images.d.js +0 -0
  209. /package/{dist/types → types}/images.d.js.map +0 -0
@@ -1,504 +0,0 @@
1
- import React, { useState, useRef, useEffect } from 'react';
2
- import { QueryDetailsModal } from './query-details-modal';
3
- import { QueryLoadingModal } from './query-loading-modal';
4
- import { formatQueryHeading } from './query-heading-formatter';
5
- import { useQueryCache } from './query-cache-context';
6
- import { extractInteractionState } from './query-cache-utils';
7
-
8
- const POSITION_CLASSES = {
9
- 'top-right': 'absolute top-0 right-0',
10
- 'top-left': 'absolute top-2 left-2',
11
- 'bottom-left': 'absolute bottom-0 left-1/2 transform -translate-x-1/2',
12
- 'bottom-right': 'absolute bottom-0 right-0 ',
13
- 'card-overlay': 'absolute bottom-0 right-0'
14
- } as const;
15
-
16
- const ERROR_MESSAGES = {
17
- FETCH_FAILED: 'Failed to fetch query details from semantic layer',
18
- LOAD_FAILED: 'Failed to load query information',
19
- SQL_NOT_AVAILABLE: 'SQL not available'
20
- } as const;
21
-
22
-
23
- type ButtonStyle = {
24
- backgroundColor?: string;
25
- color?: string;
26
- border?: string;
27
- [key: string]: unknown;
28
- };
29
-
30
- type TableButtonExplanation = {
31
- action: string;
32
- explanation: string;
33
- operationName?: string;
34
- operationSummary?: string;
35
- operationDescription?: string;
36
- buttonClassName?: string;
37
- buttonStyle?: ButtonStyle;
38
- formFields?: Record<string, unknown>;
39
- jsonBody?: unknown;
40
- filesArg?: Record<string, unknown>;
41
- hasPayload?: boolean;
42
- };
43
-
44
- type TableAction = {
45
- id: string;
46
- text: string;
47
- className?: string;
48
- [key: string]: unknown;
49
- };
50
-
51
- type Position = 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' | 'card-overlay';
52
-
53
- type StyledInfoButtonProps = {
54
- buttonStyle?: ButtonStyle;
55
- onClick?: () => void;
56
- isVisible?: boolean;
57
- tableName?: string;
58
- position?: Position;
59
- componentId?: string;
60
- className?: string;
61
- onSqlFetch?: (sql: string | string[]) => void;
62
- performInteraction?: (payload: Record<string, unknown>) => Promise<Record<string, unknown>>;
63
- tableActions?: TableAction[];
64
- firstRowData?: Record<string, unknown>;
65
- componentProps?: Record<string, unknown>;
66
- }
67
-
68
-
69
- export function StyledInfoButton({
70
- position = 'bottom-right',
71
- componentId,
72
- className = '',
73
- isVisible = true,
74
- onSqlFetch,
75
- performInteraction = () => Promise.resolve({} as Record<string, unknown>),
76
- tableActions = [],
77
- firstRowData = {},
78
- componentProps = {}
79
- }: StyledInfoButtonProps) {
80
- const [isModalOpen, setIsModalOpen] = useState(false);
81
- const [isLoadingModalOpen, setIsLoadingModalOpen] = useState(false);
82
-
83
- const [sqlQuery, setSqlQuery] = useState<string | string[]>('');
84
- const [queryHeadings, setQueryHeadings] = useState<string[]>([]);
85
- const [tableButtonExplanations, setTableButtonExplanations] = useState<TableButtonExplanation[]>([]);
86
-
87
- const [isLoading, setIsLoading] = useState(false);
88
- const [error, setError] = useState<string>('');
89
-
90
- const modalOpen = useRef(false);
91
-
92
- const queryCache = useQueryCache();
93
-
94
- const currentInteractionState = extractInteractionState(componentProps);
95
-
96
- let interactionStateKey = '';
97
-
98
- try {
99
- interactionStateKey = JSON.stringify(currentInteractionState);
100
- } catch (err) {
101
- // eslint-disable-next-line no-console
102
- console.warn('Failed to serialize interaction state:', err);
103
- interactionStateKey = `fallback_${Date.now()}_${Math.random()}`;
104
- }
105
-
106
- const prevInteractionStateKeyRef = useRef<string | undefined>(undefined);
107
-
108
- const interactionState = currentInteractionState;
109
-
110
- useEffect(() => {
111
- const prevKey = prevInteractionStateKeyRef.current;
112
- const currentKey = interactionStateKey;
113
-
114
- if (prevKey !== currentKey && prevKey !== undefined) {
115
- if (componentId) {
116
- queryCache.invalidateComponent(componentId);
117
-
118
- setSqlQuery('');
119
- setQueryHeadings([]);
120
- setTableButtonExplanations([]);
121
- setError('');
122
- }
123
- }
124
-
125
- prevInteractionStateKeyRef.current = currentKey;
126
- }, [interactionStateKey, componentId, queryCache]);
127
-
128
- async function fetchTableButtonExplanations(): Promise<TableButtonExplanation[]> {
129
- try {
130
- if (!tableActions || tableActions.length === 0) {
131
- return [];
132
- }
133
-
134
-
135
- const buttonPromises = tableActions.map(async (action) => {
136
- try {
137
- const result = await performInteraction({
138
- id: action.id || componentId,
139
- interactionType: 'tableButton',
140
- payload: {
141
- row: firstRowData,
142
- params: { isInfoButtonInteraction: true }
143
- },
144
- affectedComponents: []
145
- });
146
-
147
- if (result && typeof result === 'object' && 'apiResponse' in result &&
148
- result.apiResponse && typeof result.apiResponse === 'object') {
149
- const response = result.apiResponse as Record<string, unknown>;
150
-
151
- if (response.request_url && typeof response.request_url === 'string') {
152
- const buttonStyle: ButtonStyle = {};
153
- const actionClassName = (action.className as string) || '';
154
-
155
- if (typeof actionClassName === 'string') {
156
- const bgMatch = actionClassName.match(/bg-\[(#[0-9A-Fa-f]{6})\]/);
157
-
158
- if (bgMatch) {
159
- buttonStyle.backgroundColor = bgMatch[1];
160
- }
161
-
162
- const textMatch = actionClassName.match(/text-\[(#[0-9A-Fa-f]{6})\]/);
163
-
164
- if (textMatch) {
165
- buttonStyle.color = textMatch[1];
166
- }
167
-
168
- const borderMatch = actionClassName.match(/border-\[(#[0-9A-Fa-f]{6})\]/);
169
-
170
- if (borderMatch) {
171
- buttonStyle.border = `1px solid ${borderMatch[1]}`;
172
- }
173
- }
174
-
175
- const formFields = response.form_fields as Record<string, unknown> || {};
176
- const jsonBody = response.json_body;
177
- const filesArg = response.files_arg as Record<string, unknown> || {};
178
-
179
- // Check if any payload fields have content
180
- const hasFormFields = Object.keys(formFields).length > 0;
181
- const hasJsonBody = jsonBody !== null && jsonBody !== undefined && jsonBody !== '';
182
- const hasFilesArg = Object.keys(filesArg).length > 0;
183
- const hasPayload = hasFormFields || hasJsonBody || hasFilesArg;
184
-
185
- return {
186
- action: action.text || action.id || 'Button Action',
187
- explanation: response.request_url,
188
- operationName: response.operation_name as string,
189
- operationSummary: response.operation_summary as string,
190
- operationDescription: response.operation_description as string,
191
- buttonClassName: actionClassName,
192
- buttonStyle,
193
- formFields,
194
- jsonBody,
195
- filesArg,
196
- hasPayload
197
- };
198
- }
199
- }
200
-
201
- return null;
202
- } catch (err) {
203
- return null;
204
- }
205
- });
206
-
207
- const results = await Promise.all(buttonPromises);
208
-
209
- return results.filter((result) => result !== null) as TableButtonExplanation[];
210
- } catch (err) {
211
- return [];
212
- }
213
- }
214
-
215
- async function fetchSemanticLayerQuery(): Promise<{sql: string | string[], headings: string[]}> {
216
- try {
217
- setIsLoading(true);
218
- setError('');
219
-
220
- const result = await performInteraction({
221
- id: componentId || 'styled-info-button',
222
- interactionType: 'semanticLayerQuery',
223
- affectedComponents: []
224
- });
225
-
226
- if (result && typeof result === 'object' && 'apiResponse' in result &&
227
- result.apiResponse && typeof result.apiResponse === 'object') {
228
- const apiResponse = result.apiResponse as Record<string, unknown>;
229
-
230
- if (!('sql' in apiResponse)) {
231
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
232
- }
233
-
234
- const sqlResponse = apiResponse.sql;
235
-
236
- if (!sqlResponse || (typeof sqlResponse !== 'object')) {
237
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
238
- }
239
-
240
- if ('success' in sqlResponse && Array.isArray(sqlResponse.success)) {
241
- const successArray = sqlResponse.success as Array<{
242
- error: boolean;
243
- sql?: string;
244
- errorMessage?: string;
245
- query_key?: string;
246
- }>;
247
-
248
- const hasAnyValidQuery = successArray.some(item =>
249
- item && typeof item === 'object' &&
250
- item.error === false &&
251
- 'sql' in item &&
252
- typeof item.sql === 'string' &&
253
- item.sql.trim()
254
- );
255
-
256
- if (!hasAnyValidQuery) {
257
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
258
- }
259
-
260
- const validQueries = successArray
261
- .filter(item =>
262
- item &&
263
- typeof item === 'object' &&
264
- item.error === false &&
265
- 'sql' in item &&
266
- typeof item.sql === 'string' &&
267
- item.sql.trim()
268
- )
269
- .map(item => ({
270
- sql: item.sql as string,
271
- queryKey: item.query_key || 'Query details'
272
- }));
273
-
274
- if (validQueries.length === 0) {
275
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
276
- }
277
-
278
- // Extract SQL and headings in the correct order
279
- const sqlQueries = validQueries.map(q => q.sql);
280
- const extractedHeadings = validQueries.map(q => formatQueryHeading(q.queryKey));
281
-
282
- return {
283
- sql: sqlQueries.length > 1 ? sqlQueries : sqlQueries[0],
284
- headings: extractedHeadings
285
- };
286
- }
287
-
288
- if ('error' in sqlResponse && typeof sqlResponse.error === 'string') {
289
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
290
- }
291
-
292
- if (Array.isArray(sqlResponse)) {
293
- const sqlObjects = sqlResponse as Array<{sql: string, error: boolean, query_key?: string}>;
294
-
295
- const validQueries = sqlObjects
296
- .filter(obj => obj && typeof obj === 'object' && 'sql' in obj && 'error' in obj && !obj.error && obj.sql && obj.sql.trim())
297
- .map(obj => ({
298
- sql: obj.sql,
299
- queryKey: obj.query_key || 'Query details'
300
- }));
301
-
302
- if (validQueries.length === 0) {
303
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
304
- }
305
-
306
- const sqlQueries = validQueries.map(q => q.sql);
307
- const extractedHeadings = validQueries.map(q => formatQueryHeading(q.queryKey));
308
-
309
- return {
310
- sql: sqlQueries.length > 1 ? sqlQueries : sqlQueries[0],
311
- headings: extractedHeadings
312
- };
313
- }
314
-
315
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
316
- }
317
-
318
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
319
-
320
- } catch (err) {
321
-
322
- return {sql: ERROR_MESSAGES.SQL_NOT_AVAILABLE, headings: []};
323
-
324
- } finally {
325
- setIsLoading(false);
326
- }
327
- }
328
-
329
- async function handleInfoClick(e: React.MouseEvent) {
330
- e.stopPropagation();
331
- e.preventDefault();
332
-
333
- modalOpen.current = true;
334
-
335
- try {
336
- const cachedSemanticQuery = componentId
337
- ? queryCache.getCachedQuery(componentId, 'semanticLayerQuery', interactionState)
338
- : null;
339
-
340
- const cachedTableButton = componentId && tableActions.length > 0
341
- ? queryCache.getCachedQuery(componentId, 'tableButton', interactionState)
342
- : null;
343
-
344
- if (cachedSemanticQuery && (tableActions.length === 0 || cachedTableButton)) {
345
- setSqlQuery(cachedSemanticQuery.sqlQuery);
346
- setQueryHeadings(cachedSemanticQuery.queryHeadings);
347
- setTableButtonExplanations(
348
- cachedTableButton?.tableButtonExplanations || cachedSemanticQuery.tableButtonExplanations
349
- );
350
- setError('');
351
-
352
- if (modalOpen.current) {
353
- setIsModalOpen(true);
354
- }
355
-
356
- if (onSqlFetch && cachedSemanticQuery.sqlQuery &&
357
- cachedSemanticQuery.sqlQuery !== ERROR_MESSAGES.SQL_NOT_AVAILABLE) {
358
- onSqlFetch(cachedSemanticQuery.sqlQuery);
359
- }
360
-
361
- return;
362
- }
363
-
364
- setIsLoadingModalOpen(true);
365
- setError('');
366
-
367
- const [sqlResult, buttonExplanations] = await Promise.all([
368
- fetchSemanticLayerQuery(),
369
- fetchTableButtonExplanations()
370
- ]);
371
-
372
- if (componentId) {
373
- const cacheEntry = {
374
- sqlQuery: sqlResult.sql || ERROR_MESSAGES.SQL_NOT_AVAILABLE,
375
- queryHeadings: sqlResult.headings || [],
376
- tableButtonExplanations: buttonExplanations,
377
- timestamp: Date.now(),
378
- };
379
-
380
- queryCache.setCachedQuery(componentId, 'semanticLayerQuery', interactionState, cacheEntry);
381
-
382
- if (tableActions.length > 0) {
383
- queryCache.setCachedQuery(componentId, 'tableButton', interactionState, {
384
- ...cacheEntry,
385
- tableButtonExplanations: buttonExplanations,
386
- });
387
- }
388
- }
389
-
390
- setSqlQuery(sqlResult.sql || ERROR_MESSAGES.SQL_NOT_AVAILABLE);
391
- setQueryHeadings(sqlResult.headings || []);
392
- setTableButtonExplanations(buttonExplanations);
393
-
394
- setIsLoadingModalOpen(false);
395
-
396
- if (modalOpen.current) {
397
- setIsModalOpen(true);
398
- }
399
-
400
- if (onSqlFetch && sqlResult.sql && sqlResult.sql !== ERROR_MESSAGES.SQL_NOT_AVAILABLE) {
401
- onSqlFetch(sqlResult.sql);
402
- }
403
- } catch (err) {
404
- setSqlQuery(ERROR_MESSAGES.SQL_NOT_AVAILABLE);
405
- setTableButtonExplanations([]);
406
- setIsLoadingModalOpen(false);
407
-
408
- if (modalOpen.current) {
409
- setIsModalOpen(true);
410
- }
411
- }
412
- }
413
-
414
- function resetState() {
415
- setIsModalOpen(false);
416
- setIsLoadingModalOpen(false);
417
- setSqlQuery('');
418
- setQueryHeadings([]);
419
- setTableButtonExplanations([]);
420
- setError('');
421
- setIsLoading(false);
422
- }
423
-
424
- function handleModalClose() {
425
- // User explicitly closed the modal
426
- modalOpen.current = false;
427
- resetState();
428
- }
429
-
430
- function handleRetry() {
431
- resetState();
432
- const mockEvent = {
433
- stopPropagation: () => void 0,
434
- preventDefault: () => void 0
435
- } as React.MouseEvent;
436
- handleInfoClick(mockEvent);
437
- }
438
-
439
-
440
- if (!isVisible) {
441
- return null;
442
- }
443
-
444
- return (
445
- <>
446
- <button
447
- className={`${POSITION_CLASSES[position]} ${className}`}
448
- onClick={handleInfoClick}
449
- title="View Query Details"
450
- type="button"
451
- style={{
452
- width: '60px',
453
- height: '60px',
454
- transform: 'rotate(0deg)',
455
- opacity: 1,
456
- border: 'none',
457
- background: 'transparent',
458
- padding: 0,
459
- }}
460
- >
461
- <svg
462
- width="50"
463
- height="50"
464
- viewBox="0 0 67 66"
465
- fill="none"
466
- xmlns="http://www.w3.org/2000/svg"
467
- >
468
- <g filter="url(#filter0_d_4766_2811)">
469
- <rect x="16.1667" y="15.5" width="35" height="35" rx="7.5" stroke="#A601FF" strokeWidth="1" shapeRendering="crispEdges"/>
470
- <path d="M33.0756 28.0171C33.3312 27.5498 34.0023 27.5498 34.2578 28.0171L35.7159 30.683C35.7777 30.7961 35.8706 30.889 35.9837 30.9508L38.6496 32.4089C39.1169 32.6644 39.1169 33.3355 38.6496 33.5911L35.9837 35.0491C35.8706 35.111 35.7777 35.2039 35.7159 35.317L34.2578 37.9829C34.0023 38.4501 33.3312 38.4501 33.0756 37.9829L31.6176 35.317C31.5557 35.2039 31.4628 35.111 31.3497 35.0491L28.6838 33.5911C28.2166 33.3355 28.2166 32.6644 28.6838 32.4089L31.3497 30.9508C31.4628 30.889 31.5557 30.7961 31.6176 30.683L33.0756 28.0171Z" fill="#A601FF"/>
471
- <path d="M29.0634 27.1601C29.1801 26.9466 29.4866 26.9466 29.6033 27.1601L29.9973 27.8804C30.0255 27.932 30.068 27.9745 30.1196 28.0027L30.84 28.3967C31.0534 28.5134 31.0534 28.8199 30.84 28.9367L30.1196 29.3306C30.068 29.3589 30.0255 29.4013 29.9973 29.4529L29.6033 30.1733C29.4866 30.3867 29.1801 30.3867 29.0634 30.1733L28.6694 29.4529C28.6412 29.4013 28.5987 29.3589 28.5471 29.3306L27.8268 28.9367C27.6133 28.8199 27.6133 28.5134 27.8268 28.3967L28.5471 28.0027C28.5987 27.9745 28.6412 27.932 28.6694 27.8804L29.0634 27.1601Z" fill="#A601FF"/>
472
- <path d="M38.0346 36.5104C38.1638 36.2743 38.5029 36.2743 38.6321 36.5105L38.8874 36.9773C38.9186 37.0344 38.9656 37.0814 39.0227 37.1126L39.4896 37.368C39.7257 37.4971 39.7257 37.8363 39.4896 37.9654L39.0227 38.2207C38.9656 38.252 38.9186 38.2989 38.8874 38.3561L38.6321 38.8229C38.5029 39.059 38.1638 39.059 38.0346 38.8229L37.7793 38.3561C37.748 38.2989 37.7011 38.252 37.6439 38.2207L37.1771 37.9654C36.941 37.8363 36.941 37.4971 37.1771 37.368L37.6439 37.1126C37.7011 37.0814 37.748 37.0344 37.7793 36.9773L38.0346 36.5104Z" fill="#A601FF"/>
473
- </g>
474
- <defs>
475
- <filter id="filter0_d_4766_2811" x="0.666687" y="0" width="66" height="66" filterUnits="userSpaceOnUse" colorInterpolationFilters="sRGB">
476
- <feFlood floodOpacity="0" result="BackgroundImageFix"/>
477
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
478
- <feMorphology radius="5" operator="dilate" in="SourceAlpha" result="effect1_dropShadow_4766_2811"/>
479
- <feOffset/>
480
- <feGaussianBlur stdDeviation="5"/>
481
- <feComposite in2="hardAlpha" operator="out"/>
482
- <feColorMatrix type="matrix" values="0 0 0 0 0.0317231 0 0 0 0 0.0834676 0 0 0 0 0.370052 0 0 0 0.05 0"/>
483
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_4766_2811"/>
484
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_4766_2811" result="shape"/>
485
- </filter>
486
- </defs>
487
- </svg>
488
- </button>
489
-
490
- <QueryLoadingModal isOpen={isLoadingModalOpen} onClose={handleModalClose} />
491
-
492
- <QueryDetailsModal
493
- isOpen={isModalOpen}
494
- onClose={handleModalClose}
495
- isLoading={isLoading}
496
- error={error}
497
- sqlQuery={sqlQuery}
498
- queryHeadings={queryHeadings}
499
- tableButtonExplanations={tableButtonExplanations}
500
- onRetry={handleRetry}
501
- />
502
- </>
503
- );
504
- }
@@ -1,42 +0,0 @@
1
- @import "tailwindcss";
2
- @config "../../tailwind.config.js";
3
-
4
-
5
- @theme inline {
6
- --color-background: oklch(1 0 0);
7
- --color-foreground: oklch(0.145 0 0);
8
- --color-card: oklch(1 0 0);
9
- --color-card-foreground: oklch(0.145 0 0);
10
- --color-popover: oklch(1 0 0);
11
- --color-popover-foreground: oklch(0.145 0 0);
12
- --color-primary: oklch(0.205 0 0);
13
- --color-primary-foreground: oklch(0.985 0 0);
14
- --color-secondary: oklch(0.97 0 0);
15
- --color-secondary-foreground: oklch(0.205 0 0);
16
- --color-muted: oklch(0.97 0 0);
17
- --color-muted-foreground: oklch(0.556 0 0);
18
- --color-accent: oklch(0.97 0 0);
19
- --color-accent-foreground: oklch(0.205 0 0);
20
- --color-destructive: oklch(0.577 0.245 27.325);
21
- --color-destructive-foreground: oklch(0.577 0.245 27.325);
22
- --color-border: oklch(0.922 0 0);
23
- --color-input: oklch(0.922 0 0);
24
- --color-ring: oklch(0.708 0 0);
25
- --color-chart-1: oklch(0.646 0.222 41.116);
26
- --color-chart-2: oklch(0.6 0.118 184.704);
27
- --color-chart-3: oklch(0.398 0.07 227.392);
28
- --color-chart-4: oklch(0.828 0.189 84.429);
29
- --color-chart-5: oklch(0.769 0.188 70.08);
30
- --radius-sm: calc(0.625rem - 4px);
31
- --radius-md: calc(0.625rem - 2px);
32
- --radius-lg: 0.625rem;
33
- --radius-xl: calc(0.625rem + 4px);
34
- --color-sidebar: oklch(0.985 0 0);
35
- --color-sidebar-foreground: oklch(0.145 0 0);
36
- --color-sidebar-primary: oklch(0.205 0 0);
37
- --color-sidebar-primary-foreground: oklch(0.985 0 0);
38
- --color-sidebar-accent: oklch(0.97 0 0);
39
- --color-sidebar-accent-foreground: oklch(0.205 0 0);
40
- --color-sidebar-border: oklch(0.922 0 0);
41
- --color-sidebar-ring: oklch(0.708 0 0);
42
- }