@sidekickdb/components 0.0.0 → 2.0.0

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 (144) hide show
  1. package/.turbo/turbo-build.log +20 -0
  2. package/LICENSE.md +202 -0
  3. package/NOTICE +27 -0
  4. package/README.md +92 -2
  5. package/app/App.css +38 -0
  6. package/app/App.tsx +63 -0
  7. package/app/index.css +18 -0
  8. package/app/main.tsx +10 -0
  9. package/dist/components/DialogContentPrimitive.d.ts +1 -0
  10. package/dist/components/DialogContentPrimitive.d.ts.map +1 -0
  11. package/dist/components/StyleMe.d.ts +15 -0
  12. package/dist/components/StyleMe.d.ts.map +1 -0
  13. package/dist/components/error-boundary.d.ts +17 -0
  14. package/dist/components/error-boundary.d.ts.map +1 -0
  15. package/dist/components/explorer/__tests__/edit-row-dialog.test.d.ts +2 -0
  16. package/dist/components/explorer/__tests__/edit-row-dialog.test.d.ts.map +1 -0
  17. package/dist/components/explorer/__tests__/format-value.test.d.ts +2 -0
  18. package/dist/components/explorer/__tests__/format-value.test.d.ts.map +1 -0
  19. package/dist/components/explorer/edit-namespace-dialog.d.ts +17 -0
  20. package/dist/components/explorer/edit-namespace-dialog.d.ts.map +1 -0
  21. package/dist/components/explorer/edit-row-dialog.d.ts +15 -0
  22. package/dist/components/explorer/edit-row-dialog.d.ts.map +1 -0
  23. package/dist/components/explorer/expandable-deleted-attr.d.ts +15 -0
  24. package/dist/components/explorer/expandable-deleted-attr.d.ts.map +1 -0
  25. package/dist/components/explorer/explorer-layout.d.ts +9 -0
  26. package/dist/components/explorer/explorer-layout.d.ts.map +1 -0
  27. package/dist/components/explorer/format-value.d.ts +2 -0
  28. package/dist/components/explorer/format-value.d.ts.map +1 -0
  29. package/dist/components/explorer/index.d.ts +128 -0
  30. package/dist/components/explorer/index.d.ts.map +1 -0
  31. package/dist/components/explorer/inner-explorer.d.ts +17 -0
  32. package/dist/components/explorer/inner-explorer.d.ts.map +1 -0
  33. package/dist/components/explorer/new-namespace-dialog.d.ts +10 -0
  34. package/dist/components/explorer/new-namespace-dialog.d.ts.map +1 -0
  35. package/dist/components/explorer/query-inspector.d.ts +11 -0
  36. package/dist/components/explorer/query-inspector.d.ts.map +1 -0
  37. package/dist/components/explorer/recently-deleted.d.ts +36 -0
  38. package/dist/components/explorer/recently-deleted.d.ts.map +1 -0
  39. package/dist/components/explorer/search-input.d.ts +9 -0
  40. package/dist/components/explorer/search-input.d.ts.map +1 -0
  41. package/dist/components/explorer/table-components.d.ts +16 -0
  42. package/dist/components/explorer/table-components.d.ts.map +1 -0
  43. package/dist/components/explorer/view-settings.d.ts +10 -0
  44. package/dist/components/explorer/view-settings.d.ts.map +1 -0
  45. package/dist/components/rosePineDawnTheme.d.ts +13 -0
  46. package/dist/components/rosePineDawnTheme.d.ts.map +1 -0
  47. package/dist/components/select.d.ts +16 -0
  48. package/dist/components/select.d.ts.map +1 -0
  49. package/dist/components/toast.d.ts +4 -0
  50. package/dist/components/toast.d.ts.map +1 -0
  51. package/dist/components/ui.d.ts +349 -0
  52. package/dist/components/ui.d.ts.map +1 -0
  53. package/dist/config.d.ts +11 -0
  54. package/dist/config.d.ts.map +1 -0
  55. package/dist/hooks/__tests__/explorer.test.d.ts +2 -0
  56. package/dist/hooks/__tests__/explorer.test.d.ts.map +1 -0
  57. package/dist/hooks/explorer.d.ts +33 -0
  58. package/dist/hooks/explorer.d.ts.map +1 -0
  59. package/dist/hooks/useAttrNotes.d.ts +10 -0
  60. package/dist/hooks/useAttrNotes.d.ts.map +1 -0
  61. package/dist/hooks/useClickOutside.d.ts +3 -0
  62. package/dist/hooks/useClickOutside.d.ts.map +1 -0
  63. package/dist/hooks/useColumnVisibility.d.ts +12 -0
  64. package/dist/hooks/useColumnVisibility.d.ts.map +1 -0
  65. package/dist/hooks/useEditBlobConstraints.d.ts +32 -0
  66. package/dist/hooks/useEditBlobConstraints.d.ts.map +1 -0
  67. package/dist/hooks/useExplorerHistory.d.ts +1 -0
  68. package/dist/hooks/useExplorerHistory.d.ts.map +1 -0
  69. package/dist/hooks/useIsOverflow.d.ts +6 -0
  70. package/dist/hooks/useIsOverflow.d.ts.map +1 -0
  71. package/dist/hooks/useLocalStorage.d.ts +2 -0
  72. package/dist/hooks/useLocalStorage.d.ts.map +1 -0
  73. package/dist/hooks/useMonacoJSONSchema.d.ts +3 -0
  74. package/dist/hooks/useMonacoJSONSchema.d.ts.map +1 -0
  75. package/dist/hooks/useStableDB.d.ts +7 -0
  76. package/dist/hooks/useStableDB.d.ts.map +1 -0
  77. package/dist/index.cjs +15 -0
  78. package/dist/index.d.ts +7 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +9751 -0
  81. package/dist/schema.d.ts +5 -0
  82. package/dist/schema.d.ts.map +1 -0
  83. package/dist/style.css +1 -0
  84. package/dist/types.d.ts +241 -0
  85. package/dist/types.d.ts.map +1 -0
  86. package/dist/utils/format.d.ts +2 -0
  87. package/dist/utils/format.d.ts.map +1 -0
  88. package/dist/utils/indexingJobs.d.ts +24 -0
  89. package/dist/utils/indexingJobs.d.ts.map +1 -0
  90. package/dist/utils/parsePermsJSON.d.ts +11 -0
  91. package/dist/utils/parsePermsJSON.d.ts.map +1 -0
  92. package/dist/utils/renames.d.ts +3 -0
  93. package/dist/utils/renames.d.ts.map +1 -0
  94. package/dist/utils/tableWidthSize.d.ts +9 -0
  95. package/dist/utils/tableWidthSize.d.ts.map +1 -0
  96. package/index.html +13 -0
  97. package/package.json +106 -3
  98. package/src/components/DialogContentPrimitive.tsx +0 -0
  99. package/src/components/StyleMe.tsx +97 -0
  100. package/src/components/error-boundary.tsx +76 -0
  101. package/src/components/explorer/__tests__/edit-row-dialog.test.ts +31 -0
  102. package/src/components/explorer/__tests__/format-value.test.ts +9 -0
  103. package/src/components/explorer/edit-namespace-dialog.tsx +1890 -0
  104. package/src/components/explorer/edit-row-dialog.tsx +1367 -0
  105. package/src/components/explorer/expandable-deleted-attr.tsx +170 -0
  106. package/src/components/explorer/explorer-layout.tsx +196 -0
  107. package/src/components/explorer/format-value.ts +9 -0
  108. package/src/components/explorer/index.tsx +280 -0
  109. package/src/components/explorer/inner-explorer.tsx +1524 -0
  110. package/src/components/explorer/new-namespace-dialog.tsx +55 -0
  111. package/src/components/explorer/query-inspector.tsx +395 -0
  112. package/src/components/explorer/recently-deleted.tsx +349 -0
  113. package/src/components/explorer/search-input.tsx +358 -0
  114. package/src/components/explorer/table-components.tsx +416 -0
  115. package/src/components/explorer/view-settings.tsx +76 -0
  116. package/src/components/rosePineDawnTheme.ts +45 -0
  117. package/src/components/select.tsx +198 -0
  118. package/src/components/toast.tsx +18 -0
  119. package/src/components/ui.tsx +1740 -0
  120. package/src/config.ts +57 -0
  121. package/src/hooks/__tests__/explorer.test.ts +109 -0
  122. package/src/hooks/explorer.tsx +137 -0
  123. package/src/hooks/useAttrNotes.ts +27 -0
  124. package/src/hooks/useClickOutside.ts +23 -0
  125. package/src/hooks/useColumnVisibility.ts +39 -0
  126. package/src/hooks/useEditBlobConstraints.ts +185 -0
  127. package/src/hooks/useExplorerHistory.ts +0 -0
  128. package/src/hooks/useIsOverflow.ts +24 -0
  129. package/src/hooks/useLocalStorage.ts +51 -0
  130. package/src/hooks/useMonacoJSONSchema.ts +41 -0
  131. package/src/hooks/useStableDB.ts +31 -0
  132. package/src/index.tsx +12 -0
  133. package/src/schema.ts +286 -0
  134. package/src/style.css +84 -0
  135. package/src/types.ts +359 -0
  136. package/src/utils/format.ts +13 -0
  137. package/src/utils/indexingJobs.ts +126 -0
  138. package/src/utils/parsePermsJSON.ts +35 -0
  139. package/src/utils/renames.ts +42 -0
  140. package/src/utils/tableWidthSize.ts +62 -0
  141. package/tailwind.config.cjs +48 -0
  142. package/tsconfig.json +22 -0
  143. package/vite-env.d.ts +1 -0
  144. package/vite.config.ts +50 -0
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { id, InstantReactWebDatabase } from '@sidekickdb/react';
3
+ import { useState } from 'react';
4
+ import { DBAttr } from '@lib/types';
5
+ import { ActionButton, ActionForm, TextInput } from '../ui';
6
+
7
+ export function NewNamespaceDialog({
8
+ db,
9
+ onClose,
10
+ }: {
11
+ db: InstantReactWebDatabase<any>;
12
+ onClose: (p?: { id: string; name: string }) => void;
13
+ }) {
14
+ const [name, setName] = useState('');
15
+
16
+ async function onSubmit() {
17
+ const idAttr: DBAttr = {
18
+ id: id(),
19
+ 'forward-identity': [id(), name, 'id'],
20
+ 'value-type': 'blob',
21
+ cardinality: 'one',
22
+ 'unique?': true,
23
+ 'index?': false,
24
+ };
25
+
26
+ const ops = [['add-attr', idAttr]];
27
+ await db.core._reactor.pushOps(ops);
28
+ onClose({ id: idAttr.id, name });
29
+ }
30
+
31
+ return (
32
+ <ActionForm className="flex flex-col gap-4">
33
+ <h5 className="flex items-center text-lg font-bold">
34
+ Create a new namespace
35
+ </h5>
36
+
37
+ <TextInput
38
+ value={name}
39
+ placeholder="Name your namespace"
40
+ onChange={(n) => setName(n)}
41
+ autoFocus
42
+ ignorePasswordManager
43
+ />
44
+
45
+ <ActionButton
46
+ type="submit"
47
+ label="Create"
48
+ submitLabel="Creating..."
49
+ errorMessage="Failed to create namespace"
50
+ disabled={!name}
51
+ onClick={onSubmit}
52
+ />
53
+ </ActionForm>
54
+ );
55
+ }
@@ -0,0 +1,395 @@
1
+ import React from 'react';
2
+ import JsonParser from 'json5';
3
+ import { useEffect, useMemo, useState } from 'react';
4
+ import * as Tooltip from '@radix-ui/react-tooltip';
5
+ import { StarIcon, TrashIcon } from '@heroicons/react/24/outline';
6
+ import { ArrowRightIcon } from '@heroicons/react/24/solid';
7
+
8
+ import { Button, CodeEditor, cn } from '@lib/components/ui';
9
+ import { errorToast } from '@lib/components/toast';
10
+ import { init, InstantReactWebDatabase } from '@sidekickdb/react';
11
+ import { DBAttr, SchemaNamespace } from '@lib/types';
12
+ import { attrsToSchema } from '@lib/schema';
13
+ import { apiSchemaToInstantSchemaDef } from '@sidekickdb/platform';
14
+ import { useExplorerProps } from '.';
15
+
16
+ const SAVED_QUERIES_CACHE_KEY = '__instant:explorer-saved-queries';
17
+ const QUERY_HISTORY_CACHE_KEY = '__instant:explorer-query-history';
18
+
19
+ type CachedQueryItem = {
20
+ ts: number;
21
+ query: string;
22
+ };
23
+
24
+ class QueryInspectorCache {
25
+ savedQueriesCacheKey: string;
26
+ queryHistoryCacheKey: string;
27
+
28
+ constructor(appId: string) {
29
+ this.savedQueriesCacheKey = `${SAVED_QUERIES_CACHE_KEY}:${appId}`;
30
+ this.queryHistoryCacheKey = `${QUERY_HISTORY_CACHE_KEY}:${appId}`;
31
+ }
32
+
33
+ get(key: string) {
34
+ try {
35
+ const raw = localStorage.getItem(key);
36
+
37
+ return raw ? JSON.parse(raw) : null;
38
+ } catch (e) {
39
+ return null;
40
+ }
41
+ }
42
+ set(key: string, value: any) {
43
+ localStorage.setItem(key, JSON.stringify(value));
44
+
45
+ return value;
46
+ }
47
+ getQueryHistory() {
48
+ return this.get(this.queryHistoryCacheKey) || [];
49
+ }
50
+ setQueryHistory(history: CachedQueryItem[]) {
51
+ return this.set(this.queryHistoryCacheKey, history);
52
+ }
53
+ getSavedQueries() {
54
+ return this.get(this.savedQueriesCacheKey) || [];
55
+ }
56
+ setSavedQueries(queries: CachedQueryItem[]) {
57
+ return this.set(this.savedQueriesCacheKey, queries);
58
+ }
59
+ }
60
+
61
+ function dbForAttrs(
62
+ baseDb: InstantReactWebDatabase<any>,
63
+ attrs: Record<string, DBAttr> | null,
64
+ ): InstantReactWebDatabase<any> {
65
+ if (!attrs) {
66
+ return baseDb;
67
+ }
68
+ const schema = apiSchemaToInstantSchemaDef(
69
+ attrsToSchema(Object.values(attrs)),
70
+ );
71
+ return init({
72
+ ...baseDb.core._reactor.config,
73
+ disableValidation: true,
74
+ schema,
75
+ devtool: false,
76
+ });
77
+ }
78
+
79
+ export function QueryInspector({
80
+ className,
81
+ appId,
82
+ db: baseDb,
83
+ namespaces,
84
+ attrs,
85
+ }: {
86
+ className?: string;
87
+ appId: string;
88
+ db: InstantReactWebDatabase<any>;
89
+ namespaces: SchemaNamespace[] | null;
90
+ attrs: Record<string, DBAttr> | null;
91
+ }) {
92
+ const db = useMemo(() => dbForAttrs(baseDb, attrs), [baseDb, attrs]);
93
+ const cache = new QueryInspectorCache(appId);
94
+ const [query, setQuery] = useState<Record<string, any>>({});
95
+ const [draft, setQueryDraft] = useState('{}');
96
+ const [history, setQueryHistory] = useState<CachedQueryItem[]>([]);
97
+ const [saved, setSavedQueries] = useState<CachedQueryItem[]>([]);
98
+
99
+ const explorerProps = useExplorerProps();
100
+
101
+ const { data, isLoading, error } = (
102
+ db as InstantReactWebDatabase<any>
103
+ ).useQuery(query);
104
+
105
+ useEffect(() => {
106
+ const saved = cache.getSavedQueries();
107
+ const history = cache.getQueryHistory();
108
+ const previousQueryItem = history[0] || saved[0];
109
+
110
+ if (previousQueryItem) {
111
+ const { query: stringified } = previousQueryItem;
112
+
113
+ setQuery(JSON.parse(stringified));
114
+ setQueryDraft(stringified);
115
+ } else {
116
+ setQuery({});
117
+ setQueryDraft('{}');
118
+ }
119
+
120
+ setSavedQueries(saved);
121
+ setQueryHistory(history);
122
+ }, [appId]);
123
+
124
+ useEffect(() => {
125
+ if (!namespaces) {
126
+ return;
127
+ }
128
+
129
+ const isQueryEmpty = Object.keys(query).length === 0;
130
+
131
+ if (isQueryEmpty && namespaces.length > 0) {
132
+ const [first] = namespaces;
133
+ const defaultQuery = {
134
+ [first.name]: { $: { limit: 5 } },
135
+ };
136
+
137
+ setQuery(defaultQuery);
138
+ setQueryDraft(JSON.stringify(defaultQuery, null, 2));
139
+ }
140
+ }, [namespaces]);
141
+
142
+ const handleClearQuery = () => {
143
+ setQuery({});
144
+ setQueryDraft('{}');
145
+ };
146
+
147
+ const run = (val: string) => {
148
+ try {
149
+ const parsed = JsonParser.parse(val);
150
+ const stringified = JSON.stringify(parsed, null, 2);
151
+ setQuery(parsed);
152
+ setQueryDraft(stringified);
153
+ setQueryHistory((prev) => {
154
+ const [latest] = prev;
155
+
156
+ if (latest && latest.query === stringified) {
157
+ return prev;
158
+ }
159
+
160
+ const item = { ts: Date.now(), query: stringified };
161
+ const history = [item, ...prev];
162
+ cache.setQueryHistory(history);
163
+
164
+ return history;
165
+ });
166
+ } catch (e) {
167
+ errorToast('Unable to run query: Invalid JSON');
168
+ }
169
+ };
170
+
171
+ const handleRunQuery = () => run(draft);
172
+
173
+ const handleSaveQuery = () => {
174
+ try {
175
+ const parsed = JsonParser.parse(draft);
176
+ const stringified = JSON.stringify(parsed, null, 2);
177
+ setSavedQueries((prev) => {
178
+ const item = { ts: Date.now(), query: stringified };
179
+ // If query was already saved, move it to the top
180
+ if (prev.some((i) => i.query === stringified)) {
181
+ const saved = [item, ...prev.filter((i) => i.query !== stringified)];
182
+ cache.setSavedQueries(saved);
183
+ return saved;
184
+ } else {
185
+ const saved = [item, ...prev];
186
+ cache.setSavedQueries(saved);
187
+ return saved;
188
+ }
189
+ });
190
+ } catch (e) {
191
+ errorToast('Unable to save query: Invalid JSON');
192
+ }
193
+ };
194
+
195
+ const handleRemoveFromSaved = (ts: number) => {
196
+ setSavedQueries((prev) => {
197
+ const saved = prev.filter((i) => i.ts !== ts);
198
+ cache.setSavedQueries(saved);
199
+
200
+ return saved;
201
+ });
202
+ };
203
+
204
+ const handleRemoveFromHistory = (ts: number) => {
205
+ setQueryHistory((prev) => {
206
+ const history = prev.filter((i) => i.ts !== ts);
207
+ cache.setQueryHistory(history);
208
+
209
+ return history;
210
+ });
211
+ };
212
+
213
+ return (
214
+ <div className={cn('flex flex-1', className)}>
215
+ <div className="flex max-w-lg flex-1 flex-col dark:bg-neutral-800">
216
+ <h2 className="mt-4 mb-1 px-3 text-sm font-semibold">InstaQL query</h2>
217
+
218
+ <div className="relative h-64 overflow-hidden rounded-sm border-y dark:border-y-neutral-800">
219
+ <CodeEditor
220
+ darkMode={explorerProps.darkMode}
221
+ language="json"
222
+ value={draft}
223
+ onChange={(code) => setQueryDraft(code)}
224
+ onMount={(editor, monaco) => {
225
+ // cmd+S/cmd+Enter bindings to run query
226
+ editor.addCommand(
227
+ monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS,
228
+ () => run(editor.getValue()),
229
+ );
230
+ editor.addCommand(
231
+ monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter,
232
+ () => run(editor.getValue()),
233
+ );
234
+ }}
235
+ />
236
+ <div className="absolute bottom-0 flex w-full items-center justify-between gap-4 px-3 py-2">
237
+ <Button
238
+ className="group"
239
+ variant="secondary"
240
+ size="mini"
241
+ onClick={handleSaveQuery}
242
+ >
243
+ <StarIcon className="mr-0.5 h-4 w-4 transition-colors group-hover:text-amber-500" />
244
+ Save
245
+ </Button>
246
+ <div className="flex items-center gap-2">
247
+ <Button
248
+ variant="secondary"
249
+ size="mini"
250
+ onClick={handleClearQuery}
251
+ >
252
+ Clear
253
+ </Button>
254
+ <Button variant="primary" size="mini" onClick={handleRunQuery}>
255
+ Run
256
+ </Button>
257
+ </div>
258
+ </div>
259
+ </div>
260
+
261
+ <div className="">
262
+ <h2 className="mt-4 mb-1 px-3 text-sm font-semibold">
263
+ Saved queries
264
+ </h2>
265
+
266
+ <div className="px-3 text-sm">
267
+ {saved.length > 0 ? (
268
+ saved.map((item) => {
269
+ return (
270
+ <div
271
+ key={item.ts}
272
+ className="group mb-1 flex items-center justify-between gap-2 text-gray-700 dark:text-neutral-200"
273
+ >
274
+ <Tooltip.Provider>
275
+ <Tooltip.Root delayDuration={200}>
276
+ <Tooltip.Trigger asChild>
277
+ <div className="truncate font-mono text-xs">
278
+ {item.query}
279
+ </div>
280
+ </Tooltip.Trigger>
281
+ <Tooltip.Portal>
282
+ <Tooltip.Content
283
+ className="animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md border bg-white px-3 py-1 text-sm text-gray-900 shadow-md dark:border-neutral-800"
284
+ side="top"
285
+ align="start"
286
+ sideOffset={8}
287
+ >
288
+ <pre>
289
+ <code className="text-xs">{item.query}</code>
290
+ </pre>
291
+ </Tooltip.Content>
292
+ </Tooltip.Portal>
293
+ </Tooltip.Root>
294
+ </Tooltip.Provider>
295
+ <div className="flex items-center gap-1">
296
+ <Button
297
+ className="px-1 opacity-0 transition-opacity group-hover:opacity-100"
298
+ variant="destructive"
299
+ size="mini"
300
+ onClick={() => handleRemoveFromSaved(item.ts)}
301
+ >
302
+ <TrashIcon className="h-4 w-4" />
303
+ </Button>
304
+ <Button
305
+ className="px-1 opacity-0 transition-opacity group-hover:opacity-100"
306
+ variant="primary"
307
+ size="mini"
308
+ onClick={() => run(item.query)}
309
+ >
310
+ <ArrowRightIcon className="h-4 w-4 -rotate-45" />
311
+ </Button>
312
+ </div>
313
+ </div>
314
+ );
315
+ })
316
+ ) : (
317
+ <div className="py-1 text-gray-400">Nothing here yet!</div>
318
+ )}
319
+ </div>
320
+ </div>
321
+
322
+ <div className="mt-4 border-t py-4 dark:border-t-neutral-700">
323
+ <h2 className="mb-1 px-3 text-sm font-semibold">Query history</h2>
324
+
325
+ <div className="px-3 text-sm">
326
+ {history.length > 0 ? (
327
+ history.slice(0, 20).map((item) => {
328
+ return (
329
+ <div
330
+ key={item.ts}
331
+ className="group mb-1 flex items-center justify-between gap-2 text-gray-700 dark:text-neutral-300"
332
+ >
333
+ <Tooltip.Provider>
334
+ <Tooltip.Root delayDuration={200}>
335
+ <Tooltip.Trigger asChild>
336
+ <div className="truncate font-mono text-xs">
337
+ {item.query}
338
+ </div>
339
+ </Tooltip.Trigger>
340
+ <Tooltip.Portal>
341
+ <Tooltip.Content
342
+ className="animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md border bg-white px-3 py-1 text-sm text-gray-900 shadow-md"
343
+ side="top"
344
+ align="start"
345
+ sideOffset={8}
346
+ >
347
+ <pre>
348
+ <code className="text-xs">{item.query}</code>
349
+ </pre>
350
+ </Tooltip.Content>
351
+ </Tooltip.Portal>
352
+ </Tooltip.Root>
353
+ </Tooltip.Provider>
354
+ <div className="flex items-center gap-1">
355
+ <Button
356
+ className="px-1 opacity-0 transition-opacity group-hover:opacity-100"
357
+ variant="destructive"
358
+ size="mini"
359
+ onClick={() => handleRemoveFromHistory(item.ts)}
360
+ >
361
+ <TrashIcon className="h-4 w-4" />
362
+ </Button>
363
+ <Button
364
+ className="px-1 opacity-0 transition-opacity group-hover:opacity-100"
365
+ variant="primary"
366
+ size="mini"
367
+ onClick={() => run(item.query)}
368
+ >
369
+ <ArrowRightIcon className="h-4 w-4 -rotate-45" />
370
+ </Button>
371
+ </div>
372
+ </div>
373
+ );
374
+ })
375
+ ) : (
376
+ <div className="py-1 text-gray-400">Nothing here yet!</div>
377
+ )}
378
+ </div>
379
+ </div>
380
+ </div>
381
+ <div className="flex max-h-full flex-1 flex-col overflow-scroll border-l dark:border-l-neutral-700 dark:bg-neutral-800">
382
+ <h2 className="mt-4 mb-1 px-3 text-sm font-semibold">Query results</h2>
383
+ <div className="flex-1 overflow-hidden rounded-sm border-y dark:border-y-neutral-700">
384
+ <CodeEditor
385
+ darkMode={explorerProps.darkMode}
386
+ loading={isLoading}
387
+ language={'json'}
388
+ value={JSON.stringify(data || error || {}, null, 2)}
389
+ onChange={() => {}}
390
+ />
391
+ </div>
392
+ </div>
393
+ </div>
394
+ );
395
+ }