@sqlrooms/sql-editor 0.29.0-rc.6 → 0.29.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/dist/SqlCodeMirrorEditor.d.ts +2 -0
- package/dist/SqlCodeMirrorEditor.d.ts.map +1 -1
- package/dist/SqlCodeMirrorEditor.js +3 -3
- package/dist/SqlCodeMirrorEditor.js.map +1 -1
- package/dist/SqlEditor.d.ts.map +1 -1
- package/dist/SqlEditor.js +1 -1
- package/dist/SqlEditor.js.map +1 -1
- package/dist/SqlEditorModal.d.ts.map +1 -1
- package/dist/SqlEditorModal.js +1 -1
- package/dist/SqlEditorModal.js.map +1 -1
- package/dist/SqlEditorSlice.d.ts +41 -0
- package/dist/SqlEditorSlice.d.ts.map +1 -1
- package/dist/SqlEditorSlice.js +142 -50
- package/dist/SqlEditorSlice.js.map +1 -1
- package/dist/SqlQuery.d.ts +34 -0
- package/dist/SqlQuery.d.ts.map +1 -0
- package/dist/SqlQuery.js +51 -0
- package/dist/SqlQuery.js.map +1 -0
- package/dist/SqlQueryBlock.d.ts +20 -0
- package/dist/SqlQueryBlock.d.ts.map +1 -0
- package/dist/SqlQueryBlock.js +148 -0
- package/dist/SqlQueryBlock.js.map +1 -0
- package/dist/codemirror/extensions/completion.d.ts +5 -2
- package/dist/codemirror/extensions/completion.d.ts.map +1 -1
- package/dist/codemirror/extensions/completion.js +82 -22
- package/dist/codemirror/extensions/completion.js.map +1 -1
- package/dist/codemirror/extensions/duck-db/duck-db.d.ts.map +1 -1
- package/dist/codemirror/extensions/duck-db/duck-db.js +3 -3
- package/dist/codemirror/extensions/duck-db/duck-db.js.map +1 -1
- package/dist/codemirror/extensions/duck-db/duckdb-sql.d.ts +2 -0
- package/dist/codemirror/extensions/duck-db/duckdb-sql.d.ts.map +1 -1
- package/dist/codemirror/extensions/duck-db/duckdb-sql.js +33 -2
- package/dist/codemirror/extensions/duck-db/duckdb-sql.js.map +1 -1
- package/dist/codemirror/extensions/sql-keymap.d.ts.map +1 -1
- package/dist/codemirror/extensions/sql-keymap.js +7 -8
- package/dist/codemirror/extensions/sql-keymap.js.map +1 -1
- package/dist/codemirror/utils/schema-converter.d.ts.map +1 -1
- package/dist/codemirror/utils/schema-converter.js +56 -1
- package/dist/codemirror/utils/schema-converter.js.map +1 -1
- package/dist/components/QueryEditorPanel.d.ts +6 -0
- package/dist/components/QueryEditorPanel.d.ts.map +1 -1
- package/dist/components/QueryEditorPanel.js +6 -0
- package/dist/components/QueryEditorPanel.js.map +1 -1
- package/dist/components/QueryEditorPanelActions.d.ts +6 -0
- package/dist/components/QueryEditorPanelActions.d.ts.map +1 -1
- package/dist/components/QueryEditorPanelActions.js +17 -5
- package/dist/components/QueryEditorPanelActions.js.map +1 -1
- package/dist/components/QueryEditorPanelEditor.d.ts +8 -0
- package/dist/components/QueryEditorPanelEditor.d.ts.map +1 -1
- package/dist/components/QueryEditorPanelEditor.js +29 -9
- package/dist/components/QueryEditorPanelEditor.js.map +1 -1
- package/dist/components/QueryResultLimitSelect.d.ts.map +1 -1
- package/dist/components/QueryResultLimitSelect.js +3 -2
- package/dist/components/QueryResultLimitSelect.js.map +1 -1
- package/dist/components/QueryResultPanel.d.ts +8 -0
- package/dist/components/QueryResultPanel.d.ts.map +1 -1
- package/dist/components/QueryResultPanel.js +28 -13
- package/dist/components/QueryResultPanel.js.map +1 -1
- package/dist/components/SqlEditorHeader.d.ts +2 -0
- package/dist/components/SqlEditorHeader.d.ts.map +1 -1
- package/dist/components/SqlEditorHeader.js +3 -2
- package/dist/components/SqlEditorHeader.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
|
@@ -2,20 +2,32 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { RunButton, Tooltip, TooltipContent, TooltipTrigger } from '@sqlrooms/ui';
|
|
3
3
|
import { isMacOS } from '@sqlrooms/utils';
|
|
4
4
|
import { useStoreWithSqlEditor } from '../SqlEditorSlice';
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Prefer `SqlQuery.Actions` for newly composed single-query
|
|
7
|
+
* surfaces. This component remains for compatibility with the legacy tabbed
|
|
8
|
+
* query panel.
|
|
9
|
+
*/
|
|
10
|
+
export const QueryEditorPanelActions = ({ className, queryId }) => {
|
|
6
11
|
const runCurrentQuery = useStoreWithSqlEditor((s) => s.sqlEditor.parseAndRunCurrentQuery);
|
|
7
12
|
const abortCurrentQuery = useStoreWithSqlEditor((s) => s.sqlEditor.abortCurrentQuery);
|
|
13
|
+
const runQueryById = useStoreWithSqlEditor((s) => s.sqlEditor.runQueryById);
|
|
14
|
+
const abortQueryById = useStoreWithSqlEditor((s) => s.sqlEditor.abortQueryById);
|
|
15
|
+
const selectedQueryId = useStoreWithSqlEditor((s) => s.sqlEditor.config.selectedQueryId);
|
|
8
16
|
const selectedQueryResult = useStoreWithSqlEditor((s) => {
|
|
9
|
-
const
|
|
10
|
-
return s.sqlEditor.queryResultsById[
|
|
17
|
+
const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;
|
|
18
|
+
return s.sqlEditor.queryResultsById[resolvedQueryId];
|
|
11
19
|
});
|
|
12
20
|
const isMac = isMacOS();
|
|
13
21
|
const isLoading = selectedQueryResult?.status === 'loading';
|
|
14
22
|
const isAborted = selectedQueryResult?.status === 'loading' &&
|
|
15
23
|
selectedQueryResult.isBeingAborted;
|
|
16
24
|
const state = isAborted ? 'cancelling' : isLoading ? 'running' : 'idle';
|
|
17
|
-
return (_jsxs(Tooltip, { delayDuration: 100, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("div", { children: _jsx(RunButton, { state: state, onRun:
|
|
25
|
+
return (_jsxs(Tooltip, { delayDuration: 100, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("div", { children: _jsx(RunButton, { state: state, onRun: queryId
|
|
26
|
+
? () => runQueryById(queryId)
|
|
27
|
+
: () => runCurrentQuery(), onCancel: queryId
|
|
28
|
+
? () => abortQueryById(queryId)
|
|
29
|
+
: () => abortCurrentQuery(), variant: "default", cancelVariant: "default", className: className }) }) }), _jsx(TooltipContent, { align: "end", children: isLoading
|
|
18
30
|
? 'Cancel the running query'
|
|
19
|
-
: `Run query (${isMac ? 'Cmd' : 'Ctrl'}+Enter)` })] }));
|
|
31
|
+
: `Run ${queryId && queryId !== selectedQueryId ? 'this ' : ''}query (${isMac ? 'Cmd' : 'Ctrl'}+Enter)` })] }));
|
|
20
32
|
};
|
|
21
33
|
//# sourceMappingURL=QueryEditorPanelActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryEditorPanelActions.js","sourceRoot":"","sources":["../../src/components/QueryEditorPanelActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"QueryEditorPanelActions.js","sourceRoot":"","sources":["../../src/components/QueryEditorPanelActions.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAChF,OAAO,EAAC,OAAO,EAAC,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAExD;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAG/B,CAAC,EAAC,SAAS,EAAE,OAAO,EAAC,EAAE,EAAE;IAC5B,MAAM,eAAe,GAAG,qBAAqB,CAC3C,CAAC,CAAC,EAAE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H,OAAO;4BACL,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC;4BAC7B,CAAC,CAAC,GAAG,EAAE,CAAC,eAAe,EAAE,EAE7B,QAAQ,EACN,OAAO;4BACL,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC;4BAC/B,CAAC,CAAC,GAAG,EAAE,CAAC,iBAAiB,EAAE,EAE/B,OAAO,EAAC,SAAS,EACjB,aAAa,EAAC,SAAS,EACvB,SAAS,EAAE,SAAS,GACpB,GACE,GACS,EACjB,KAAC,cAAc,IAAC,KAAK,EAAC,KAAK,YACxB,SAAS;oBACR,CAAC,CAAC,0BAA0B;oBAC5B,CAAC,CAAC,OACE,OAAO,IAAI,OAAO,KAAK,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACrD,UAAU,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,SAAS,GAC9B,IACT,CACX,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {RunButton, Tooltip, TooltipContent, TooltipTrigger} from '@sqlrooms/ui';\nimport {isMacOS} from '@sqlrooms/utils';\nimport React from 'react';\nimport {useStoreWithSqlEditor} from '../SqlEditorSlice';\n\n/**\n * @deprecated Prefer `SqlQuery.Actions` for newly composed single-query\n * surfaces. This component remains for compatibility with the legacy tabbed\n * query panel.\n */\nexport const QueryEditorPanelActions: React.FC<{\n className?: string;\n queryId?: string;\n}> = ({className, queryId}) => {\n const runCurrentQuery = useStoreWithSqlEditor(\n (s) => s.sqlEditor.parseAndRunCurrentQuery,\n );\n const abortCurrentQuery = useStoreWithSqlEditor(\n (s) => s.sqlEditor.abortCurrentQuery,\n );\n const runQueryById = useStoreWithSqlEditor((s) => s.sqlEditor.runQueryById);\n const abortQueryById = useStoreWithSqlEditor(\n (s) => s.sqlEditor.abortQueryById,\n );\n const selectedQueryId = useStoreWithSqlEditor(\n (s) => s.sqlEditor.config.selectedQueryId,\n );\n const selectedQueryResult = useStoreWithSqlEditor((s) => {\n const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;\n return s.sqlEditor.queryResultsById[resolvedQueryId];\n });\n const isMac = isMacOS();\n\n const isLoading = selectedQueryResult?.status === 'loading';\n const isAborted =\n selectedQueryResult?.status === 'loading' &&\n selectedQueryResult.isBeingAborted;\n\n const state = isAborted ? 'cancelling' : isLoading ? 'running' : 'idle';\n\n return (\n <Tooltip delayDuration={100}>\n <TooltipTrigger asChild>\n <div>\n <RunButton\n state={state}\n onRun={\n queryId\n ? () => runQueryById(queryId)\n : () => runCurrentQuery()\n }\n onCancel={\n queryId\n ? () => abortQueryById(queryId)\n : () => abortCurrentQuery()\n }\n variant=\"default\"\n cancelVariant=\"default\"\n className={className}\n />\n </div>\n </TooltipTrigger>\n <TooltipContent align=\"end\">\n {isLoading\n ? 'Cancel the running query'\n : `Run ${\n queryId && queryId !== selectedQueryId ? 'this ' : ''\n }query (${isMac ? 'Cmd' : 'Ctrl'}+Enter)`}\n </TooltipContent>\n </Tooltip>\n );\n};\n"]}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Prefer `SqlQuery.Editor` for newly composed single-query
|
|
3
|
+
* surfaces. This component remains for compatibility with the legacy tabbed
|
|
4
|
+
* query panel.
|
|
5
|
+
*/
|
|
1
6
|
export declare const QueryEditorPanelEditor: React.FC<{
|
|
2
7
|
className?: string;
|
|
3
8
|
queryId: string;
|
|
9
|
+
readOnly?: boolean;
|
|
10
|
+
autoHeight?: boolean;
|
|
11
|
+
compact?: boolean;
|
|
4
12
|
}>;
|
|
5
13
|
//# sourceMappingURL=QueryEditorPanelEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryEditorPanelEditor.d.ts","sourceRoot":"","sources":["../../src/components/QueryEditorPanelEditor.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"QueryEditorPanelEditor.d.ts","sourceRoot":"","sources":["../../src/components/QueryEditorPanelEditor.tsx"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAkEA,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from '@sqlrooms/ui';
|
|
3
|
-
import { useCallback } from 'react';
|
|
3
|
+
import { useCallback, useMemo } from 'react';
|
|
4
4
|
import { useStoreWithSqlEditor } from '../SqlEditorSlice';
|
|
5
5
|
import { SqlCodeMirrorEditor } from '../SqlCodeMirrorEditor';
|
|
6
6
|
const CODEMIRROR_OPTIONS = {
|
|
@@ -8,22 +8,42 @@ const CODEMIRROR_OPTIONS = {
|
|
|
8
8
|
autocompletion: true,
|
|
9
9
|
highlightActiveLine: true,
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `SqlQuery.Editor` for newly composed single-query
|
|
13
|
+
* surfaces. This component remains for compatibility with the legacy tabbed
|
|
14
|
+
* query panel.
|
|
15
|
+
*/
|
|
16
|
+
export const QueryEditorPanelEditor = ({ className, queryId, readOnly, autoHeight, compact }) => {
|
|
12
17
|
const tableSchemas = useStoreWithSqlEditor((s) => s.db.tables);
|
|
13
|
-
const
|
|
18
|
+
const runQueryById = useStoreWithSqlEditor((s) => s.sqlEditor.runQueryById);
|
|
14
19
|
const connector = useStoreWithSqlEditor((s) => s.db.connector);
|
|
15
20
|
const queryText = useStoreWithSqlEditor((s) => s.sqlEditor.config.queries.find((q) => q.id === queryId)?.query);
|
|
16
21
|
const updateQueryText = useStoreWithSqlEditor((s) => s.sqlEditor.updateQueryText);
|
|
17
22
|
// Handle query text update
|
|
18
23
|
const handleUpdateQuery = useCallback((value) => {
|
|
19
|
-
|
|
20
|
-
return;
|
|
21
|
-
updateQueryText(queryId, value);
|
|
24
|
+
updateQueryText(queryId, value ?? '');
|
|
22
25
|
}, [queryId, updateQueryText]);
|
|
23
26
|
// Handle query execution via keyboard shortcut
|
|
24
27
|
const handleRunQuery = useCallback((query) => {
|
|
25
|
-
|
|
26
|
-
}, [
|
|
27
|
-
|
|
28
|
+
runQueryById(queryId, query);
|
|
29
|
+
}, [queryId, runQueryById]);
|
|
30
|
+
const editorOptions = useMemo(() => ({
|
|
31
|
+
...CODEMIRROR_OPTIONS,
|
|
32
|
+
...(compact
|
|
33
|
+
? {
|
|
34
|
+
lineNumbers: false,
|
|
35
|
+
foldGutter: false,
|
|
36
|
+
highlightActiveLine: false,
|
|
37
|
+
}
|
|
38
|
+
: {}),
|
|
39
|
+
}), [compact]);
|
|
40
|
+
return (_jsx(SqlCodeMirrorEditor, { connector: connector, value: queryText ?? '', onChange: handleUpdateQuery, className: cn(autoHeight
|
|
41
|
+
? [
|
|
42
|
+
'h-auto min-h-0 w-full grow',
|
|
43
|
+
'[&_.cm-content]:min-h-12',
|
|
44
|
+
'[&_.cm-editor]:h-auto [&_.cm-editor]:min-h-12',
|
|
45
|
+
'[&_.cm-scroller]:overflow-visible',
|
|
46
|
+
]
|
|
47
|
+
: 'h-full w-full grow', className), options: editorOptions, onRunQuery: handleRunQuery, tableSchemas: tableSchemas, readOnly: readOnly, hideGutter: compact }, queryId));
|
|
28
48
|
};
|
|
29
49
|
//# sourceMappingURL=QueryEditorPanelEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryEditorPanelEditor.js","sourceRoot":"","sources":["../../src/components/QueryEditorPanelEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"QueryEditorPanelEditor.js","sourceRoot":"","sources":["../../src/components/QueryEditorPanelEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,cAAc,CAAC;AAChC,OAAO,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAE3D,MAAM,kBAAkB,GAAG;IACzB,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,IAAI;CAC1B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAM9B,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAC,EAAE,EAAE;IAC3D,MAAM,YAAY,GAAG,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;IAC5E,MAAM,SAAS,GAAG,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;IAE/D,MAAM,SAAS,GAAG,qBAAqB,CACrC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAA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O,IAnBd,OAAO,CAoBZ,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {cn} from '@sqlrooms/ui';\nimport {useCallback, useMemo} from 'react';\nimport {useStoreWithSqlEditor} from '../SqlEditorSlice';\nimport {SqlCodeMirrorEditor} from '../SqlCodeMirrorEditor';\n\nconst CODEMIRROR_OPTIONS = {\n lineWrapping: true,\n autocompletion: true,\n highlightActiveLine: true,\n};\n\n/**\n * @deprecated Prefer `SqlQuery.Editor` for newly composed single-query\n * surfaces. This component remains for compatibility with the legacy tabbed\n * query panel.\n */\nexport const QueryEditorPanelEditor: React.FC<{\n className?: string;\n queryId: string;\n readOnly?: boolean;\n autoHeight?: boolean;\n compact?: boolean;\n}> = ({className, queryId, readOnly, autoHeight, compact}) => {\n const tableSchemas = useStoreWithSqlEditor((s) => s.db.tables);\n const runQueryById = useStoreWithSqlEditor((s) => s.sqlEditor.runQueryById);\n const connector = useStoreWithSqlEditor((s) => s.db.connector);\n\n const queryText = useStoreWithSqlEditor(\n (s) => s.sqlEditor.config.queries.find((q) => q.id === queryId)?.query,\n );\n const updateQueryText = useStoreWithSqlEditor(\n (s) => s.sqlEditor.updateQueryText,\n );\n\n // Handle query text update\n const handleUpdateQuery = useCallback(\n (value: string | undefined) => {\n updateQueryText(queryId, value ?? '');\n },\n [queryId, updateQueryText],\n );\n\n // Handle query execution via keyboard shortcut\n const handleRunQuery = useCallback(\n (query: string) => {\n runQueryById(queryId, query);\n },\n [queryId, runQueryById],\n );\n\n const editorOptions = useMemo(\n () => ({\n ...CODEMIRROR_OPTIONS,\n ...(compact\n ? {\n lineNumbers: false,\n foldGutter: false,\n highlightActiveLine: false,\n }\n : {}),\n }),\n [compact],\n );\n\n return (\n <SqlCodeMirrorEditor\n key={queryId}\n connector={connector}\n value={queryText ?? ''}\n onChange={handleUpdateQuery}\n className={cn(\n autoHeight\n ? [\n 'h-auto min-h-0 w-full grow',\n '[&_.cm-content]:min-h-12',\n '[&_.cm-editor]:h-auto [&_.cm-editor]:min-h-12',\n '[&_.cm-scroller]:overflow-visible',\n ]\n : 'h-full w-full grow',\n className,\n )}\n options={editorOptions}\n onRunQuery={handleRunQuery}\n tableSchemas={tableSchemas}\n readOnly={readOnly}\n hideGutter={compact}\n />\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResultLimitSelect.d.ts","sourceRoot":"","sources":["../../src/components/QueryResultLimitSelect.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryResultLimitSelect.d.ts","sourceRoot":"","sources":["../../src/components/QueryResultLimitSelect.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAgB,MAAM,OAAO,CAAC;AAErC,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA4CxE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cn,
|
|
2
|
+
import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from '@sqlrooms/ui';
|
|
3
3
|
import { formatCount } from '@sqlrooms/utils';
|
|
4
|
+
import { ChevronDown } from 'lucide-react';
|
|
4
5
|
import { useMemo } from 'react';
|
|
5
6
|
/**
|
|
6
7
|
* Reusable dropdown for selecting query result limits.
|
|
@@ -14,6 +15,6 @@ export const QueryResultLimitSelect = ({ value, onChange, options = [100, 500, 1
|
|
|
14
15
|
}
|
|
15
16
|
return options;
|
|
16
17
|
}, [options, value]);
|
|
17
|
-
return (_jsxs(
|
|
18
|
+
return (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { type: "button", className: cn('border-input bg-background flex h-6 w-fit items-center justify-between gap-1 rounded-md border px-2 py-1 shadow-sm outline-hidden focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50', className), children: [_jsx("span", { className: "text-xs text-gray-500", children: `Limit results to ${formatCount(value)} rows` }), _jsx(ChevronDown, { className: "h-3 w-3 opacity-50" })] }) }), _jsx(DropdownMenuContent, { align: "end", children: _jsx(DropdownMenuRadioGroup, { value: value.toString(), onValueChange: (v) => onChange(parseInt(v, 10)), children: limitOptions.map((limit) => (_jsx(DropdownMenuRadioItem, { value: limit.toString(), children: `${formatCount(limit)} rows` }, limit))) }) })] }));
|
|
18
19
|
};
|
|
19
20
|
//# sourceMappingURL=QueryResultLimitSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResultLimitSelect.js","sourceRoot":"","sources":["../../src/components/QueryResultLimitSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,EAAE,EACF,
|
|
1
|
+
{"version":3,"file":"QueryResultLimitSelect.js","sourceRoot":"","sources":["../../src/components/QueryResultLimitSelect.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,EAAE,EACF,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AACzC,OAAc,EAAC,OAAO,EAAC,MAAM,OAAO,CAAC;AAsBrC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAA0C,CAAC,EAC5E,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI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MenuContent,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuTrigger,\n} from '@sqlrooms/ui';\nimport {formatCount} from '@sqlrooms/utils';\nimport {ChevronDown} from 'lucide-react';\nimport React, {useMemo} from 'react';\n\nexport interface QueryResultLimitSelectProps {\n /**\n * Current limit value\n */\n value: number;\n /**\n * Callback when limit changes\n */\n onChange: (limit: number) => void;\n /**\n * Available limit options\n * @default [100, 500, 1000, 5000, 10000]\n */\n options?: number[];\n /**\n * Custom class name\n */\n className?: string;\n}\n\n/**\n * Reusable dropdown for selecting query result limits.\n * Used in QueryResultPanel and SqlQueryPreview.\n */\nexport const QueryResultLimitSelect: React.FC<QueryResultLimitSelectProps> = ({\n value,\n onChange,\n options = [100, 500, 1000, 5000, 10000],\n className,\n}) => {\n // Ensure current value is in options list\n const limitOptions = useMemo(() => {\n if (!options.includes(value)) {\n return [value, ...options].sort((a, b) => a - b);\n }\n return options;\n }, [options, value]);\n\n return (\n <DropdownMenu modal={false}>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n className={cn(\n 'border-input bg-background flex h-6 w-fit items-center justify-between gap-1 rounded-md border px-2 py-1 shadow-sm outline-hidden focus:ring-1 disabled:cursor-not-allowed disabled:opacity-50',\n className,\n )}\n >\n <span className=\"text-xs text-gray-500\">\n {`Limit results to ${formatCount(value)} rows`}\n </span>\n <ChevronDown className=\"h-3 w-3 opacity-50\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuRadioGroup\n value={value.toString()}\n onValueChange={(v) => onChange(parseInt(v, 10))}\n >\n {limitOptions.map((limit) => (\n <DropdownMenuRadioItem key={limit} value={limit.toString()}>\n {`${formatCount(limit)} rows`}\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n );\n};\n"]}
|
|
@@ -4,6 +4,8 @@ import React from 'react';
|
|
|
4
4
|
export interface QueryResultPanelProps {
|
|
5
5
|
/** Custom class name for styling */
|
|
6
6
|
className?: string;
|
|
7
|
+
/** Query id to render results for. Defaults to the selected query tab. */
|
|
8
|
+
queryId?: string;
|
|
7
9
|
/** Custom actions to render in the query result panel */
|
|
8
10
|
renderActions?: (query: string) => React.ReactNode;
|
|
9
11
|
/** Custom font size for the table e.g. text-xs, text-sm, text-md, text-lg, text-base */
|
|
@@ -44,8 +46,14 @@ export interface QueryResultPanelProps {
|
|
|
44
46
|
onRowSelectionChange?: (rowSelection: RowSelectionState) => void;
|
|
45
47
|
/** Custom value formatter for arrow data */
|
|
46
48
|
formatValue?: ArrowDataTableValueFormatter;
|
|
49
|
+
/** Additional content rendered in the result footer next to the row count. */
|
|
50
|
+
footerDetails?: React.ReactNode;
|
|
51
|
+
/** Custom class name for the inner paginated data table. */
|
|
52
|
+
dataTableClassName?: string;
|
|
47
53
|
}
|
|
48
54
|
export interface QueryResultPanelAskAiProps {
|
|
55
|
+
/** Query id to read the error/query from. Defaults to the selected query tab. */
|
|
56
|
+
queryId?: string;
|
|
49
57
|
/** Called when clicked with the current query and error message */
|
|
50
58
|
onClick?: (query: string, error: string) => void;
|
|
51
59
|
/** Custom icon (defaults to MessageCircleQuestion) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResultPanel.d.ts","sourceRoot":"","sources":["../../src/components/QueryResultPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAG7B,MAAM,sBAAsB,CAAC;AAW9B,OAAO,KAAK,EAAC,GAAG,EAAE,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AAElE,OAAO,KAAK,MAAM,OAAO,CAAC;AA+B1B,MAAM,WAAW,qBAAqB;IACpC,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IACnD,wFAAwF;IACxF,QAAQ,CAAC,E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,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAqDD,eAAO,MAAM,gBAAgB;;CAE3B,CAAC"}
|
|
@@ -32,12 +32,23 @@ function arrowTableToExplainText(result) {
|
|
|
32
32
|
}
|
|
33
33
|
return lines.join('\n');
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Result table for a SQL editor query.
|
|
37
|
+
*
|
|
38
|
+
* Prefer `SqlQuery.Results` when composing a complete single-query surface. Use
|
|
39
|
+
* this component directly when only the result panel is needed.
|
|
40
|
+
*/
|
|
41
|
+
const QueryResultPanelRoot = ({ className, queryId, renderActions, fontSize = 'text-xs', onRowClick, onRowDoubleClick, children, onAskAiAboutError, enableRowSelection, rowSelection, onRowSelectionChange, formatValue, footerDetails, dataTableClassName, }) => {
|
|
36
42
|
const queryResult = useStoreWithSqlEditor((s) => {
|
|
37
|
-
const
|
|
38
|
-
return s.sqlEditor.queryResultsById[
|
|
43
|
+
const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;
|
|
44
|
+
return s.sqlEditor.queryResultsById[resolvedQueryId];
|
|
45
|
+
});
|
|
46
|
+
const currentQuery = useStoreWithSqlEditor((s) => {
|
|
47
|
+
if (!queryId)
|
|
48
|
+
return s.sqlEditor.getCurrentQuery();
|
|
49
|
+
return (s.sqlEditor.config.queries.find((query) => query.id === queryId)?.query ??
|
|
50
|
+
'');
|
|
39
51
|
});
|
|
40
|
-
const getCurrentQuery = useStoreWithSqlEditor((s) => s.sqlEditor.getCurrentQuery);
|
|
41
52
|
const setQueryResultLimit = useStoreWithSqlEditor((s) => s.sqlEditor.setQueryResultLimit);
|
|
42
53
|
const queryResultLimit = useStoreWithSqlEditor((s) => s.sqlEditor.queryResultLimit);
|
|
43
54
|
const queryResultLimitOptions = useStoreWithSqlEditor((s) => s.sqlEditor.queryResultLimitOptions);
|
|
@@ -53,11 +64,10 @@ const QueryResultPanelRoot = ({ className, renderActions, fontSize = 'text-xs',
|
|
|
53
64
|
}, [queryResult]);
|
|
54
65
|
const handleAskAiAboutError = React.useCallback(() => {
|
|
55
66
|
if (queryResult?.status === 'error' && onAskAiAboutError) {
|
|
56
|
-
const currentQuery = getCurrentQuery();
|
|
57
67
|
const errorText = queryResult.error;
|
|
58
68
|
onAskAiAboutError?.(currentQuery, errorText);
|
|
59
69
|
}
|
|
60
|
-
}, [queryResult,
|
|
70
|
+
}, [queryResult, currentQuery, onAskAiAboutError]);
|
|
61
71
|
if (!queryResult) {
|
|
62
72
|
return null;
|
|
63
73
|
}
|
|
@@ -77,13 +87,13 @@ const QueryResultPanelRoot = ({ className, renderActions, fontSize = 'text-xs',
|
|
|
77
87
|
const contentWrapperClassName = cn('relative flex h-full w-full grow flex-col overflow-hidden', className);
|
|
78
88
|
// Result shows the EXPLAIN schema
|
|
79
89
|
if (queryResult.type === 'explain') {
|
|
80
|
-
return (_jsx("div", { className: contentWrapperClassName, children: _jsxs("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [_jsx("pre", { className: "flex-1 overflow-auto p-4 font-mono text-xs leading-tight wrap-break-word whitespace-pre-wrap", children: explainText }), _jsxs("div", { className: "bg-background flex w-full items-center gap-2 px-4 py-1", children: [_jsx("div", { className: "font-mono text-xs", children: "EXPLAIN" }), _jsx("div", { className: "flex-1" }), renderActions
|
|
90
|
+
return (_jsx("div", { className: contentWrapperClassName, children: _jsxs("div", { className: "flex h-full w-full flex-col overflow-hidden", children: [_jsx("pre", { className: "flex-1 overflow-auto p-4 font-mono text-xs leading-tight wrap-break-word whitespace-pre-wrap", children: explainText }), _jsxs("div", { className: "bg-background flex w-full items-center gap-2 border-t px-4 py-1", children: [_jsx("div", { className: "font-mono text-xs", children: "EXPLAIN" }), _jsx("div", { className: "flex-1" }), renderActions
|
|
81
91
|
? renderActions(queryResult.lastQueryStatement)
|
|
82
92
|
: undefined] })] }) }));
|
|
83
93
|
}
|
|
84
94
|
// Result shows the SELECT/PRAGMA table
|
|
85
95
|
if (isQueryWithResult(queryResult)) {
|
|
86
|
-
return (_jsx("div", { className: contentWrapperClassName, children: _jsxs("div", { className: "flex h-full w-full flex-col", children: [_jsx(DataTablePaginated, { data: arrowTableData?.data, columns: arrowTableData?.columns, className:
|
|
96
|
+
return (_jsx("div", { className: contentWrapperClassName, children: _jsxs("div", { className: "flex h-full w-full flex-col", children: [_jsx(DataTablePaginated, { data: arrowTableData?.data, columns: arrowTableData?.columns, className: cn('grow overflow-hidden', dataTableClassName), fontSize: fontSize, isFetching: false, onRowClick: onRowClick, onRowDoubleClick: onRowDoubleClick, enableRowSelection: enableRowSelection, rowSelection: rowSelection, onRowSelectionChange: onRowSelectionChange }), _jsxs("div", { className: "bg-background flex w-full items-center gap-2 border-t px-4 py-1", children: [queryResult.result ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "font-mono text-xs", children: `${formatCount(queryResult.result.numRows ?? 0)} rows` }), queryResult.type === 'select' ? (_jsx(QueryResultLimitSelect, { value: queryResultLimit, onChange: setQueryResultLimit, options: queryResultLimitOptions })) : null] })) : null, _jsx("div", { className: "flex-1" }), footerDetails, renderActions
|
|
87
97
|
? renderActions(queryResult.lastQueryStatement)
|
|
88
98
|
: undefined] })] }) }));
|
|
89
99
|
}
|
|
@@ -92,17 +102,22 @@ const QueryResultPanelRoot = ({ className, renderActions, fontSize = 'text-xs',
|
|
|
92
102
|
}
|
|
93
103
|
return null;
|
|
94
104
|
};
|
|
95
|
-
const QueryResultPanelAskAi = React.forwardRef(({ onClick, icon, className, tooltipContent = 'Ask AI for help' }, ref) => {
|
|
105
|
+
const QueryResultPanelAskAi = React.forwardRef(({ queryId, onClick, icon, className, tooltipContent = 'Ask AI for help' }, ref) => {
|
|
96
106
|
const queryResult = useStoreWithSqlEditor((s) => {
|
|
97
|
-
const
|
|
98
|
-
return s.sqlEditor.queryResultsById[
|
|
107
|
+
const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;
|
|
108
|
+
return s.sqlEditor.queryResultsById[resolvedQueryId];
|
|
109
|
+
});
|
|
110
|
+
const currentQuery = useStoreWithSqlEditor((s) => {
|
|
111
|
+
if (!queryId)
|
|
112
|
+
return s.sqlEditor.getCurrentQuery();
|
|
113
|
+
return (s.sqlEditor.config.queries.find((query) => query.id === queryId)?.query ??
|
|
114
|
+
'');
|
|
99
115
|
});
|
|
100
|
-
const getCurrentQuery = useStoreWithSqlEditor((s) => s.sqlEditor.getCurrentQuery);
|
|
101
116
|
// Only render in error state
|
|
102
117
|
if (queryResult?.status !== 'error')
|
|
103
118
|
return null;
|
|
104
119
|
const handleClick = () => {
|
|
105
|
-
onClick?.(
|
|
120
|
+
onClick?.(currentQuery, queryResult.error);
|
|
106
121
|
};
|
|
107
122
|
return (_jsx(TooltipProvider, { delayDuration: 200, children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { ref: ref, variant: "ghost", size: "icon", className: cn('h-8 w-8', className), onClick: handleClick, children: icon ?? _jsx(MessageCircleQuestion, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { children: _jsx("p", { className: "text-xs", children: tooltipContent }) })] }) }));
|
|
108
123
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryResultPanel.js","sourceRoot":"","sources":["../../src/components/QueryResultPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EAEL,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,MAAM,EACN,EAAE,EACF,WAAW,EACX,OAAO,EACP,cAAc,EACd,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAC,qBAAqB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,MAAM,OAAO,C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CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CACnC,CAAC;IAEF,6BAA6B;IAC7B,IAAI,WAAW,EAAE,MAAM,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAEjD,MAAM,WAAW,GAAG,GAAG,EAAE;QACvB,OAAO,EAAE,CAAC,eAAe,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC,CAAC;IAEF,OAAO,CACL,KAAC,eAAe,IAAC,aAAa,EAAE,GAAG,YACjC,MAAC,OAAO,eACN,KAAC,cAAc,IAAC,OAAO,kBACrB,KAAC,MAAM,IACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EACnC,OAAO,EAAE,WAAW,YAEnB,IAAI,IAAI,KAAC,qBAAqB,IAAC,SAAS,EAAC,SAAS,GAAG,GAC/C,GACM,EACjB,KAAC,cAAc,cACb,YAAG,SAAS,EAAC,SAAS,YAAE,cAAc,GAAK,GAC5B,IACT,GACM,CACnB,CAAC;AACJ,CAAC,CAAC,CAAC;AACH,qBAAqB,CAAC,WAAW,GAAG,wBAAwB,CAAC;AAE7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE;IAClE,KAAK,EAAE,qBAAqB;CAC7B,CAAC,CAAC","sourcesContent":["import {\n ArrowDataTableValueFormatter,\n DataTablePaginated,\n useArrowDataTable,\n} from '@sqlrooms/data-table';\nimport {\n Button,\n cn,\n SpinnerPane,\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@sqlrooms/ui';\nimport {formatCount} from '@sqlrooms/utils';\nimport type {Row, RowSelectionState} from '@tanstack/react-table';\nimport {MessageCircleQuestion} from 'lucide-react';\nimport React from 'react';\nimport {isQueryWithResult, useStoreWithSqlEditor} from '../SqlEditorSlice';\nimport {QueryResultLimitSelect} from './QueryResultLimitSelect';\n\n/**\n * Turns DuckDB's EXPLAIN result table into a readable plan string.\n * Prefer the `explain_value` column (DuckDB default); otherwise fall back\n * to the first column and join all rows with newlines.\n */\nfunction arrowTableToExplainText(result: any): string {\n if (!result) return '';\n\n const numRows: number = result.numRows ?? 0;\n const fields: {name: string}[] = result.schema?.fields ?? [];\n const fieldNames = fields.map((f) => f.name);\n\n const hasExplainValueColumn = fieldNames.includes('explain_value');\n const columnName = hasExplainValueColumn ? 'explain_value' : fieldNames[0];\n if (!columnName) return '';\n\n const col = result.getChild?.(columnName);\n if (!col) return '';\n\n const lines: string[] = [];\n for (let i = 0; i < numRows; i++) {\n const v = col.get(i);\n if (v != null && String(v).length > 0) lines.push(String(v));\n }\n return lines.join('\\n');\n}\n\nexport interface QueryResultPanelProps {\n /** Custom class name for styling */\n className?: string;\n /** Custom actions to render in the query result panel */\n renderActions?: (query: string) => React.ReactNode;\n /** Custom font size for the table e.g. text-xs, text-sm, text-md, text-lg, text-base */\n fontSize?: string;\n /**\n * Called when a row in the results table is clicked.\n */\n onRowClick?: (args: {\n row: Row<any>;\n event: React.MouseEvent<HTMLTableRowElement>;\n }) => void;\n /**\n * Called when a row in the results table is double-clicked.\n */\n onRowDoubleClick?: (args: {\n row: Row<any>;\n event: React.MouseEvent<HTMLTableRowElement>;\n }) => void;\n /** Custom content to render in the error state (e.g., QueryResultPanel.AskAi) */\n children?: React.ReactNode;\n /**\n * @deprecated Use children with QueryResultPanel.AskAi instead\n * Called when the \"Ask AI\" button is clicked on an error message.\n * Receives the current query and error text.\n */\n onAskAiAboutError?: (query: string, error: string) => void;\n /**\n * Enables row selection with checkboxes.\n */\n enableRowSelection?: boolean;\n /**\n * Controlled row selection state. Keys are row indices, values are selection status.\n */\n rowSelection?: RowSelectionState;\n /**\n * Called when row selection changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n /** Custom value formatter for arrow data */\n formatValue?: ArrowDataTableValueFormatter;\n}\n\nconst QueryResultPanelRoot: React.FC<QueryResultPanelProps> = ({\n className,\n renderActions,\n fontSize = 'text-xs',\n onRowClick,\n onRowDoubleClick,\n children,\n onAskAiAboutError,\n enableRowSelection,\n rowSelection,\n onRowSelectionChange,\n formatValue,\n}) => {\n const queryResult = useStoreWithSqlEditor((s) => {\n const selectedId = s.sqlEditor.config.selectedQueryId;\n return s.sqlEditor.queryResultsById[selectedId];\n });\n const getCurrentQuery = useStoreWithSqlEditor(\n (s) => s.sqlEditor.getCurrentQuery,\n );\n const setQueryResultLimit = useStoreWithSqlEditor(\n (s) => s.sqlEditor.setQueryResultLimit,\n );\n const queryResultLimit = useStoreWithSqlEditor(\n (s) => s.sqlEditor.queryResultLimit,\n );\n const queryResultLimitOptions = useStoreWithSqlEditor(\n (s) => s.sqlEditor.queryResultLimitOptions,\n );\n\n const tableForDataTable =\n isQueryWithResult(queryResult) && queryResult.type !== 'explain'\n ? queryResult.result\n : undefined;\n\n const arrowTableData = useArrowDataTable(tableForDataTable, {formatValue});\n\n const explainText = React.useMemo(() => {\n if (queryResult?.status !== 'success' || queryResult.type !== 'explain') {\n return undefined;\n }\n return arrowTableToExplainText(queryResult.result);\n }, [queryResult]);\n\n const handleAskAiAboutError = React.useCallback(() => {\n if (queryResult?.status === 'error' && onAskAiAboutError) {\n const currentQuery = getCurrentQuery();\n const errorText = queryResult.error;\n onAskAiAboutError?.(currentQuery, errorText);\n }\n }, [queryResult, getCurrentQuery, onAskAiAboutError]);\n\n if (!queryResult) {\n return null;\n }\n\n if (queryResult?.status === 'loading') {\n return <SpinnerPane h=\"100%\" />;\n }\n\n if (queryResult?.status === 'aborted') {\n return (\n <div className=\"p-5 font-mono text-xs leading-tight text-red-500\">\n Query was aborted\n </div>\n );\n }\n if (queryResult?.status === 'error') {\n // Backward compat: if no children but onAskAiAboutError is provided, render default button\n const errorActions =\n children ??\n (onAskAiAboutError && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-8 w-8\"\n onClick={handleAskAiAboutError}\n title=\"Ask AI for help\"\n >\n <MessageCircleQuestion className=\"h-4 w-4\" />\n </Button>\n ));\n\n return (\n <div className=\"relative h-full w-full overflow-auto p-5\">\n {errorActions && (\n <div className=\"absolute top-2 right-2\">{errorActions}</div>\n )}\n <pre\n className={cn(\n 'text-xs leading-tight whitespace-pre-wrap text-red-500',\n errorActions && 'pr-12',\n )}\n >\n {queryResult.error}\n </pre>\n </div>\n );\n }\n\n if (queryResult?.status === 'success') {\n const contentWrapperClassName = cn(\n 'relative flex h-full w-full grow flex-col overflow-hidden',\n className,\n );\n\n // Result shows the EXPLAIN schema\n if (queryResult.type === 'explain') {\n return (\n <div className={contentWrapperClassName}>\n <div className=\"flex h-full w-full flex-col overflow-hidden\">\n <pre className=\"flex-1 overflow-auto p-4 font-mono text-xs leading-tight wrap-break-word whitespace-pre-wrap\">\n {explainText}\n </pre>\n <div className=\"bg-background flex w-full items-center gap-2 px-4 py-1\">\n <div className=\"font-mono text-xs\">EXPLAIN</div>\n <div className=\"flex-1\" />\n {renderActions\n ? renderActions(queryResult.lastQueryStatement)\n : undefined}\n </div>\n </div>\n </div>\n );\n }\n\n // Result shows the SELECT/PRAGMA table\n if (isQueryWithResult(queryResult)) {\n return (\n <div className={contentWrapperClassName}>\n <div className=\"flex h-full w-full flex-col\">\n <DataTablePaginated\n data={arrowTableData?.data}\n columns={arrowTableData?.columns}\n className=\"grow overflow-hidden\"\n fontSize={fontSize}\n isFetching={false}\n onRowClick={onRowClick}\n onRowDoubleClick={onRowDoubleClick}\n enableRowSelection={enableRowSelection}\n rowSelection={rowSelection}\n onRowSelectionChange={onRowSelectionChange}\n />\n <div className=\"bg-background flex w-full items-center gap-2 px-4 py-1\">\n {queryResult.result ? (\n <>\n <div className=\"font-mono text-xs\">\n {`${formatCount(queryResult.result.numRows ?? 0)} rows`}\n </div>\n\n {queryResult.type === 'select' ? (\n <QueryResultLimitSelect\n value={queryResultLimit}\n onChange={setQueryResultLimit}\n options={queryResultLimitOptions}\n />\n ) : null}\n </>\n ) : null}\n <div className=\"flex-1\" />\n {renderActions\n ? renderActions(queryResult.lastQueryStatement)\n : undefined}\n </div>\n </div>\n </div>\n );\n }\n\n // Fallback message to show when the query result is not a SELECT/PRAGMA or EXPLAIN\n return (\n <div className={contentWrapperClassName}>\n <pre className=\"p-4 text-xs leading-tight text-green-500\">\n Successfully executed query\n </pre>\n </div>\n );\n }\n\n return null;\n};\n\nexport interface QueryResultPanelAskAiProps {\n /** Called when clicked with the current query and error message */\n onClick?: (query: string, error: string) => void;\n /** Custom icon (defaults to MessageCircleQuestion) */\n icon?: React.ReactNode;\n /** Custom className */\n className?: string;\n /** Tooltip text to display on hover */\n tooltipContent?: string;\n}\n\nconst QueryResultPanelAskAi = React.forwardRef<\n HTMLButtonElement,\n QueryResultPanelAskAiProps\n>(({onClick, icon, className, tooltipContent = 'Ask AI for help'}, ref) => {\n const queryResult = useStoreWithSqlEditor((s) => {\n const selectedId = s.sqlEditor.config.selectedQueryId;\n return s.sqlEditor.queryResultsById[selectedId];\n });\n const getCurrentQuery = useStoreWithSqlEditor(\n (s) => s.sqlEditor.getCurrentQuery,\n );\n\n // Only render in error state\n if (queryResult?.status !== 'error') return null;\n\n const handleClick = () => {\n onClick?.(getCurrentQuery(), queryResult.error);\n };\n\n return (\n <TooltipProvider delayDuration={200}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n ref={ref}\n variant=\"ghost\"\n size=\"icon\"\n className={cn('h-8 w-8', className)}\n onClick={handleClick}\n >\n {icon ?? <MessageCircleQuestion className=\"h-4 w-4\" />}\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p className=\"text-xs\">{tooltipContent}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n});\nQueryResultPanelAskAi.displayName = 'QueryResultPanel.AskAi';\n\nexport const QueryResultPanel = Object.assign(QueryResultPanelRoot, {\n AskAi: QueryResultPanelAskAi,\n});\n"]}
|
|
1
|
+
{"version":3,"file":"QueryResultPanel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,MAAC,OAAO,eACN,KAAC,cAAc,IAAC,OAAO,kBACrB,KAAC,MAAM,IACL,GAAG,EAAE,GAAG,EACR,OAAO,EAAC,OAAO,EACf,IAAI,EAAC,MAAM,EACX,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,EACnC,OAAO,EAAE,WAAW,YAEnB,IAAI,IAAI,KAAC,qBAAqB,IAAC,SAAS,EAAC,SAAS,GAAG,GAC/C,GACM,EACjB,KAAC,cAAc,cACb,YAAG,SAAS,EAAC,SAAS,YAAE,cAAc,GAAK,GAC5B,IACT,GACM,CACnB,CAAC;AACF,CAAC,CACF,CAAC;AACF,qBAAqB,CAAC,WAAW,GAAG,wBAAwB,CAAC;AAE7D,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE;IAClE,KAAK,EAAE,qBAAqB;CAC7B,CAAC,CAAC","sourcesContent":["import {\n ArrowDataTableValueFormatter,\n DataTablePaginated,\n useArrowDataTable,\n} from '@sqlrooms/data-table';\nimport {\n Button,\n cn,\n SpinnerPane,\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@sqlrooms/ui';\nimport {formatCount} from '@sqlrooms/utils';\nimport type {Row, RowSelectionState} from '@tanstack/react-table';\nimport {MessageCircleQuestion} from 'lucide-react';\nimport React from 'react';\nimport {isQueryWithResult, useStoreWithSqlEditor} from '../SqlEditorSlice';\nimport {QueryResultLimitSelect} from './QueryResultLimitSelect';\n\n/**\n * Turns DuckDB's EXPLAIN result table into a readable plan string.\n * Prefer the `explain_value` column (DuckDB default); otherwise fall back\n * to the first column and join all rows with newlines.\n */\nfunction arrowTableToExplainText(result: any): string {\n if (!result) return '';\n\n const numRows: number = result.numRows ?? 0;\n const fields: {name: string}[] = result.schema?.fields ?? [];\n const fieldNames = fields.map((f) => f.name);\n\n const hasExplainValueColumn = fieldNames.includes('explain_value');\n const columnName = hasExplainValueColumn ? 'explain_value' : fieldNames[0];\n if (!columnName) return '';\n\n const col = result.getChild?.(columnName);\n if (!col) return '';\n\n const lines: string[] = [];\n for (let i = 0; i < numRows; i++) {\n const v = col.get(i);\n if (v != null && String(v).length > 0) lines.push(String(v));\n }\n return lines.join('\\n');\n}\n\nexport interface QueryResultPanelProps {\n /** Custom class name for styling */\n className?: string;\n /** Query id to render results for. Defaults to the selected query tab. */\n queryId?: string;\n /** Custom actions to render in the query result panel */\n renderActions?: (query: string) => React.ReactNode;\n /** Custom font size for the table e.g. text-xs, text-sm, text-md, text-lg, text-base */\n fontSize?: string;\n /**\n * Called when a row in the results table is clicked.\n */\n onRowClick?: (args: {\n row: Row<any>;\n event: React.MouseEvent<HTMLTableRowElement>;\n }) => void;\n /**\n * Called when a row in the results table is double-clicked.\n */\n onRowDoubleClick?: (args: {\n row: Row<any>;\n event: React.MouseEvent<HTMLTableRowElement>;\n }) => void;\n /** Custom content to render in the error state (e.g., QueryResultPanel.AskAi) */\n children?: React.ReactNode;\n /**\n * @deprecated Use children with QueryResultPanel.AskAi instead\n * Called when the \"Ask AI\" button is clicked on an error message.\n * Receives the current query and error text.\n */\n onAskAiAboutError?: (query: string, error: string) => void;\n /**\n * Enables row selection with checkboxes.\n */\n enableRowSelection?: boolean;\n /**\n * Controlled row selection state. Keys are row indices, values are selection status.\n */\n rowSelection?: RowSelectionState;\n /**\n * Called when row selection changes.\n */\n onRowSelectionChange?: (rowSelection: RowSelectionState) => void;\n /** Custom value formatter for arrow data */\n formatValue?: ArrowDataTableValueFormatter;\n /** Additional content rendered in the result footer next to the row count. */\n footerDetails?: React.ReactNode;\n /** Custom class name for the inner paginated data table. */\n dataTableClassName?: string;\n}\n\n/**\n * Result table for a SQL editor query.\n *\n * Prefer `SqlQuery.Results` when composing a complete single-query surface. Use\n * this component directly when only the result panel is needed.\n */\nconst QueryResultPanelRoot: React.FC<QueryResultPanelProps> = ({\n className,\n queryId,\n renderActions,\n fontSize = 'text-xs',\n onRowClick,\n onRowDoubleClick,\n children,\n onAskAiAboutError,\n enableRowSelection,\n rowSelection,\n onRowSelectionChange,\n formatValue,\n footerDetails,\n dataTableClassName,\n}) => {\n const queryResult = useStoreWithSqlEditor((s) => {\n const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;\n return s.sqlEditor.queryResultsById[resolvedQueryId];\n });\n const currentQuery = useStoreWithSqlEditor((s) => {\n if (!queryId) return s.sqlEditor.getCurrentQuery();\n return (\n s.sqlEditor.config.queries.find((query) => query.id === queryId)?.query ??\n ''\n );\n });\n const setQueryResultLimit = useStoreWithSqlEditor(\n (s) => s.sqlEditor.setQueryResultLimit,\n );\n const queryResultLimit = useStoreWithSqlEditor(\n (s) => s.sqlEditor.queryResultLimit,\n );\n const queryResultLimitOptions = useStoreWithSqlEditor(\n (s) => s.sqlEditor.queryResultLimitOptions,\n );\n\n const tableForDataTable =\n isQueryWithResult(queryResult) && queryResult.type !== 'explain'\n ? queryResult.result\n : undefined;\n\n const arrowTableData = useArrowDataTable(tableForDataTable, {formatValue});\n\n const explainText = React.useMemo(() => {\n if (queryResult?.status !== 'success' || queryResult.type !== 'explain') {\n return undefined;\n }\n return arrowTableToExplainText(queryResult.result);\n }, [queryResult]);\n\n const handleAskAiAboutError = React.useCallback(() => {\n if (queryResult?.status === 'error' && onAskAiAboutError) {\n const errorText = queryResult.error;\n onAskAiAboutError?.(currentQuery, errorText);\n }\n }, [queryResult, currentQuery, onAskAiAboutError]);\n\n if (!queryResult) {\n return null;\n }\n\n if (queryResult?.status === 'loading') {\n return <SpinnerPane h=\"100%\" />;\n }\n\n if (queryResult?.status === 'aborted') {\n return (\n <div className=\"p-5 font-mono text-xs leading-tight text-red-500\">\n Query was aborted\n </div>\n );\n }\n if (queryResult?.status === 'error') {\n // Backward compat: if no children but onAskAiAboutError is provided, render default button\n const errorActions =\n children ??\n (onAskAiAboutError && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n className=\"h-8 w-8\"\n onClick={handleAskAiAboutError}\n title=\"Ask AI for help\"\n >\n <MessageCircleQuestion className=\"h-4 w-4\" />\n </Button>\n ));\n\n return (\n <div className=\"relative h-full w-full overflow-auto p-5\">\n {errorActions && (\n <div className=\"absolute top-2 right-2\">{errorActions}</div>\n )}\n <pre\n className={cn(\n 'text-xs leading-tight whitespace-pre-wrap text-red-500',\n errorActions && 'pr-12',\n )}\n >\n {queryResult.error}\n </pre>\n </div>\n );\n }\n\n if (queryResult?.status === 'success') {\n const contentWrapperClassName = cn(\n 'relative flex h-full w-full grow flex-col overflow-hidden',\n className,\n );\n\n // Result shows the EXPLAIN schema\n if (queryResult.type === 'explain') {\n return (\n <div className={contentWrapperClassName}>\n <div className=\"flex h-full w-full flex-col overflow-hidden\">\n <pre className=\"flex-1 overflow-auto p-4 font-mono text-xs leading-tight wrap-break-word whitespace-pre-wrap\">\n {explainText}\n </pre>\n <div className=\"bg-background flex w-full items-center gap-2 border-t px-4 py-1\">\n <div className=\"font-mono text-xs\">EXPLAIN</div>\n <div className=\"flex-1\" />\n {renderActions\n ? renderActions(queryResult.lastQueryStatement)\n : undefined}\n </div>\n </div>\n </div>\n );\n }\n\n // Result shows the SELECT/PRAGMA table\n if (isQueryWithResult(queryResult)) {\n return (\n <div className={contentWrapperClassName}>\n <div className=\"flex h-full w-full flex-col\">\n <DataTablePaginated\n data={arrowTableData?.data}\n columns={arrowTableData?.columns}\n className={cn('grow overflow-hidden', dataTableClassName)}\n fontSize={fontSize}\n isFetching={false}\n onRowClick={onRowClick}\n onRowDoubleClick={onRowDoubleClick}\n enableRowSelection={enableRowSelection}\n rowSelection={rowSelection}\n onRowSelectionChange={onRowSelectionChange}\n />\n <div className=\"bg-background flex w-full items-center gap-2 border-t px-4 py-1\">\n {queryResult.result ? (\n <>\n <div className=\"font-mono text-xs\">\n {`${formatCount(queryResult.result.numRows ?? 0)} rows`}\n </div>\n\n {queryResult.type === 'select' ? (\n <QueryResultLimitSelect\n value={queryResultLimit}\n onChange={setQueryResultLimit}\n options={queryResultLimitOptions}\n />\n ) : null}\n </>\n ) : null}\n <div className=\"flex-1\" />\n {footerDetails}\n {renderActions\n ? renderActions(queryResult.lastQueryStatement)\n : undefined}\n </div>\n </div>\n </div>\n );\n }\n\n // Fallback message to show when the query result is not a SELECT/PRAGMA or EXPLAIN\n return (\n <div className={contentWrapperClassName}>\n <pre className=\"p-4 text-xs leading-tight text-green-500\">\n Successfully executed query\n </pre>\n </div>\n );\n }\n\n return null;\n};\n\nexport interface QueryResultPanelAskAiProps {\n /** Query id to read the error/query from. Defaults to the selected query tab. */\n queryId?: string;\n /** Called when clicked with the current query and error message */\n onClick?: (query: string, error: string) => void;\n /** Custom icon (defaults to MessageCircleQuestion) */\n icon?: React.ReactNode;\n /** Custom className */\n className?: string;\n /** Tooltip text to display on hover */\n tooltipContent?: string;\n}\n\nconst QueryResultPanelAskAi = React.forwardRef<\n HTMLButtonElement,\n QueryResultPanelAskAiProps\n>(\n (\n {queryId, onClick, icon, className, tooltipContent = 'Ask AI for help'},\n ref,\n ) => {\n const queryResult = useStoreWithSqlEditor((s) => {\n const resolvedQueryId = queryId ?? s.sqlEditor.config.selectedQueryId;\n return s.sqlEditor.queryResultsById[resolvedQueryId];\n });\n const currentQuery = useStoreWithSqlEditor((s) => {\n if (!queryId) return s.sqlEditor.getCurrentQuery();\n return (\n s.sqlEditor.config.queries.find((query) => query.id === queryId)?.query ??\n ''\n );\n });\n\n // Only render in error state\n if (queryResult?.status !== 'error') return null;\n\n const handleClick = () => {\n onClick?.(currentQuery, queryResult.error);\n };\n\n return (\n <TooltipProvider delayDuration={200}>\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n ref={ref}\n variant=\"ghost\"\n size=\"icon\"\n className={cn('h-8 w-8', className)}\n onClick={handleClick}\n >\n {icon ?? <MessageCircleQuestion className=\"h-4 w-4\" />}\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n <p className=\"text-xs\">{tooltipContent}</p>\n </TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n },\n);\nQueryResultPanelAskAi.displayName = 'QueryResultPanel.AskAi';\n\nexport const QueryResultPanel = Object.assign(QueryResultPanelRoot, {\n AskAi: QueryResultPanelAskAi,\n});\n"]}
|
|
@@ -10,6 +10,8 @@ export type SqlEditorHeaderProps = PropsWithChildren<{
|
|
|
10
10
|
documentationPanel?: React.ReactNode;
|
|
11
11
|
/** Callback when the documentation visibility is toggled */
|
|
12
12
|
onToggleDocs?: (show: boolean) => void;
|
|
13
|
+
/** Optional callback for closing the editor surface */
|
|
14
|
+
onClose?: () => void;
|
|
13
15
|
}>;
|
|
14
16
|
export declare const SqlEditorHeader: React.FC<SqlEditorHeaderProps>;
|
|
15
17
|
//# sourceMappingURL=SqlEditorHeader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEditorHeader.d.ts","sourceRoot":"","sources":["../../src/components/SqlEditorHeader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqlEditorHeader.d.ts","sourceRoot":"","sources":["../../src/components/SqlEditorHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAM/C,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;IACnD,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACrC,4DAA4D;IAC5D,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoD1D,CAAC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, cn } from '@sqlrooms/ui';
|
|
3
|
+
import { XIcon } from 'lucide-react';
|
|
3
4
|
import { SqlReferenceButton, SqlReferenceButtonContent, } from './SqlReferenceButton';
|
|
4
|
-
export const SqlEditorHeader = ({ className, title, showDocs, documentationPanel, onToggleDocs, children, }) => {
|
|
5
|
-
return (_jsxs("div", { className: cn('flex w-full items-center gap-2 px-2 py-1', className), children: [title && _jsx("h2", { className: "
|
|
5
|
+
export const SqlEditorHeader = ({ className, title, showDocs, documentationPanel, onToggleDocs, onClose, children, }) => {
|
|
6
|
+
return (_jsxs("div", { className: cn('flex min-h-10 w-full min-w-0 items-center gap-2 px-2 py-1', className), children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [title && (_jsx("h2", { className: "ml-1 min-w-0 truncate text-base font-semibold", children: title })), children] }), _jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [documentationPanel ? (_jsx(Button, { size: "sm", variant: showDocs ? 'secondary' : 'outline', className: "shrink-0", onClick: () => onToggleDocs?.(!showDocs), children: _jsx(SqlReferenceButtonContent, {}) })) : (_jsx(SqlReferenceButton, { className: "shrink-0" })), onClose && (_jsx(Button, { type: "button", size: "icon", variant: "ghost", className: "h-9 w-9 shrink-0", onClick: onClose, "aria-label": "Close SQL editor", children: _jsx(XIcon, {}) }))] })] }));
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=SqlEditorHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlEditorHeader.js","sourceRoot":"","sources":["../../src/components/SqlEditorHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"SqlEditorHeader.js","sourceRoot":"","sources":["../../src/components/SqlEditorHeader.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,EAAE,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAEnC,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,CAAC,MAAM,eAAe,GAAmC,CAAC,EAC9D,SAAS,EACT,KAAK,EACL,QAAQ,EACR,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,QAAQ,GACT,EAAE,EAAE;IACH,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,2DAA2D,EAC3D,SAAS,CACV,aAED,eAAK,SAAS,EAAC,wCAAwC,aACpD,KAAK,IAAI,CACR,aAAI,SAAS,EAAC,+CAA+C,YAC1D,KAAK,GACH,CACN,EACA,QAAQ,IACL,EACN,eAAK,SAAS,EAAC,kCAAkC,aAC9C,kBAAkB,CAAC,CAAC,CAAC,CACpB,KAAC,MAAM,IACL,IAAI,EAAC,IAAI,EACT,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAC3C,SAAS,EAAC,UAAU,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,YAExC,KAAC,yBAAyB,KAAG,GACtB,CACV,CAAC,CAAC,CAAC,CACF,KAAC,kBAAkB,IAAC,SAAS,EAAC,UAAU,GAAG,CAC5C,EACA,OAAO,IAAI,CACV,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,IAAI,EAAC,MAAM,EACX,OAAO,EAAC,OAAO,EACf,SAAS,EAAC,kBAAkB,EAC5B,OAAO,EAAE,OAAO,gBACL,kBAAkB,YAE7B,KAAC,KAAK,KAAG,GACF,CACV,IACG,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Button, cn} from '@sqlrooms/ui';\nimport {XIcon} from 'lucide-react';\nimport React, {PropsWithChildren} from 'react';\nimport {\n SqlReferenceButton,\n SqlReferenceButtonContent,\n} from './SqlReferenceButton';\n\nexport type SqlEditorHeaderProps = PropsWithChildren<{\n /** Custom class name for styling */\n className?: string;\n /** The title of the SQL editor */\n title?: string;\n /** Whether to show the documentation panel */\n showDocs?: boolean;\n /** Optional documentation panel component */\n documentationPanel?: React.ReactNode;\n /** Callback when the documentation visibility is toggled */\n onToggleDocs?: (show: boolean) => void;\n /** Optional callback for closing the editor surface */\n onClose?: () => void;\n}>;\n\nexport const SqlEditorHeader: React.FC<SqlEditorHeaderProps> = ({\n className,\n title,\n showDocs,\n documentationPanel,\n onToggleDocs,\n onClose,\n children,\n}) => {\n return (\n <div\n className={cn(\n 'flex min-h-10 w-full min-w-0 items-center gap-2 px-2 py-1',\n className,\n )}\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n {title && (\n <h2 className=\"ml-1 min-w-0 truncate text-base font-semibold\">\n {title}\n </h2>\n )}\n {children}\n </div>\n <div className=\"flex shrink-0 items-center gap-2\">\n {documentationPanel ? (\n <Button\n size=\"sm\"\n variant={showDocs ? 'secondary' : 'outline'}\n className=\"shrink-0\"\n onClick={() => onToggleDocs?.(!showDocs)}\n >\n <SqlReferenceButtonContent />\n </Button>\n ) : (\n <SqlReferenceButton className=\"shrink-0\" />\n )}\n {onClose && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n className=\"h-9 w-9 shrink-0\"\n onClick={onClose}\n aria-label=\"Close SQL editor\"\n >\n <XIcon />\n </Button>\n )}\n </div>\n </div>\n );\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export { default as SqlEditor } from './SqlEditor';
|
|
|
8
8
|
export type { SqlEditorProps } from './SqlEditor';
|
|
9
9
|
export { default as SqlEditorModal } from './SqlEditorModal';
|
|
10
10
|
export { createSqlEditorSlice } from './SqlEditorSlice';
|
|
11
|
-
export type { QueryResult, SqlEditorSliceState } from './SqlEditorSlice';
|
|
11
|
+
export type { EnsureSqlQueryOptions, QueryResult, SqlEditorQuery, SqlEditorSliceState, } from './SqlEditorSlice';
|
|
12
12
|
export { SqlQueryDataSourcesPanel } from './components/SqlQueryDataSourcesPanel';
|
|
13
13
|
/**
|
|
14
14
|
* @deprecated Use SqlCodeMirrorEditor instead.
|
|
@@ -22,6 +22,10 @@ export { SqlMonacoEditor } from './SqlMonacoEditor';
|
|
|
22
22
|
export type { SqlMonacoEditorProps, SqlMonacoRunQueryOptions, } from './SqlMonacoEditor';
|
|
23
23
|
export { SqlCodeMirrorEditor } from './SqlCodeMirrorEditor';
|
|
24
24
|
export type { SqlCodeMirrorEditorProps } from './SqlCodeMirrorEditor';
|
|
25
|
+
export { SqlQuery } from './SqlQuery';
|
|
26
|
+
export type { SqlQueryRootProps, SqlQueryHeaderProps, SqlQueryToolbarProps, SqlQueryActionsProps, SqlQueryEditorProps, SqlQueryResultsProps, } from './SqlQuery';
|
|
27
|
+
export { SQL_QUERY_BLOCK_TYPE, SqlQueryBlock, createSqlQueryBlockDefinition, } from './SqlQueryBlock';
|
|
28
|
+
export type { SqlQueryBlockProps, CreateSqlQueryBlockDefinitionOptions, } from './SqlQueryBlock';
|
|
25
29
|
export { SqlDialects } from './codemirror/extensions/create-sql-extension';
|
|
26
30
|
export type { SqlDialect } from './codemirror/extensions/create-sql-extension';
|
|
27
31
|
export { SchemaExplorer } from './components/SchemaExplorer';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC1E,YAAY,EACV,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AACjD,YAAY,EAAC,cAAc,EAAC,MAAM,a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pB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export { SqlQueryDataSourcesPanel } from './components/SqlQueryDataSourcesPanel'
|
|
|
13
13
|
*/
|
|
14
14
|
export { SqlMonacoEditor } from './SqlMonacoEditor';
|
|
15
15
|
export { SqlCodeMirrorEditor } from './SqlCodeMirrorEditor';
|
|
16
|
+
export { SqlQuery } from './SqlQuery';
|
|
17
|
+
export { SQL_QUERY_BLOCK_TYPE, SqlQueryBlock, createSqlQueryBlockDefinition, } from './SqlQueryBlock';
|
|
16
18
|
export { SqlDialects } from './codemirror/extensions/create-sql-extension';
|
|
17
19
|
export { SchemaExplorer } from './components/SchemaExplorer';
|
|
18
20
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAK1E,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAK1E,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAC,OAAO,IAAI,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,MAAM,kBAAkB,CAAC;AAOtD,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAC/E;;;GAGG;AACH,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAE1D,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AASpC,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EAAC,WAAW,EAAC,MAAM,8CAA8C,CAAC;AAEzE,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAM3D;;GAEG;AACH,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAKrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAK/D,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAC,uBAAuB,EAAC,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAC,wBAAwB,EAAC,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAE3E,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAG7D,6CAA6C;AAC7C,2EAA2E;AAC3E,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\nexport {default as CreateTableModal} from './components/CreateTableModal';\nexport type {\n CreateTableModalProps,\n CreateTableFormInitialValues,\n} from './components/CreateTableModal';\nexport {default as SqlEditor} from './SqlEditor';\nexport type {SqlEditorProps} from './SqlEditor';\nexport {default as SqlEditorModal} from './SqlEditorModal';\nexport {createSqlEditorSlice} from './SqlEditorSlice';\nexport type {\n EnsureSqlQueryOptions,\n QueryResult,\n SqlEditorQuery,\n SqlEditorSliceState,\n} from './SqlEditorSlice';\nexport {SqlQueryDataSourcesPanel} from './components/SqlQueryDataSourcesPanel';\n/**\n * @deprecated Use SqlCodeMirrorEditor instead.\n * SqlMonacoEditor will be removed in the next major version.\n */\nexport {SqlMonacoEditor} from './SqlMonacoEditor';\n/**\n * @deprecated Use SqlCodeMirrorEditor instead.\n * SqlMonacoEditor will be removed in the next major version.\n */\nexport type {\n SqlMonacoEditorProps,\n SqlMonacoRunQueryOptions,\n} from './SqlMonacoEditor';\nexport {SqlCodeMirrorEditor} from './SqlCodeMirrorEditor';\nexport type {SqlCodeMirrorEditorProps} from './SqlCodeMirrorEditor';\nexport {SqlQuery} from './SqlQuery';\nexport type {\n SqlQueryRootProps,\n SqlQueryHeaderProps,\n SqlQueryToolbarProps,\n SqlQueryActionsProps,\n SqlQueryEditorProps,\n SqlQueryResultsProps,\n} from './SqlQuery';\nexport {\n SQL_QUERY_BLOCK_TYPE,\n SqlQueryBlock,\n createSqlQueryBlockDefinition,\n} from './SqlQueryBlock';\nexport type {\n SqlQueryBlockProps,\n CreateSqlQueryBlockDefinitionOptions,\n} from './SqlQueryBlock';\nexport {SqlDialects} from './codemirror/extensions/create-sql-extension';\nexport type {SqlDialect} from './codemirror/extensions/create-sql-extension';\nexport {SchemaExplorer} from './components/SchemaExplorer';\nexport type {\n SchemaExplorerRootProps,\n SchemaExplorerHeaderProps,\n SchemaExplorerTreeProps,\n} from './components/SchemaExplorer';\n/**\n * @deprecated Use `SchemaExplorer` instead.\n */\nexport {TableStructurePanel} from './components/TableStructurePanel';\n/**\n * @deprecated Use `SchemaExplorer` instead.\n */\nexport type {TableStructurePanelProps} from './components/TableStructurePanel';\nexport {QueryResultPanel} from './components/QueryResultPanel';\nexport type {\n QueryResultPanelProps,\n QueryResultPanelAskAiProps,\n} from './components/QueryResultPanel';\nexport {SqlEditorHeader} from './components/SqlEditorHeader';\nexport type {SqlEditorHeaderProps} from './components/SqlEditorHeader';\nexport {\n SqlReferenceButton,\n SqlReferenceButtonContent,\n} from './components/SqlReferenceButton';\nexport {QueryEditorPanel} from './components/QueryEditorPanel';\nexport type {QueryEditorPanelProps} from './components/QueryEditorPanel';\nexport {QueryEditorPanelActions} from './components/QueryEditorPanelActions';\nexport {QueryEditorPanelTabsList} from './components/QueryEditorPanelTabsList';\nexport {QueryEditorPanelEditor} from './components/QueryEditorPanelEditor';\nexport {QueryResultLimitSelect} from './components/QueryResultLimitSelect';\nexport type {QueryResultLimitSelectProps} from './components/QueryResultLimitSelect';\nexport {SqlQueryPreview} from './components/SqlQueryPreview';\nexport type {SqlQueryPreviewProps} from './components/SqlQueryPreview';\n\n// Re-export from @sqlrooms/sql-editor-config\n// Values also export their corresponding types automatically (Zod pattern)\nexport {\n SqlEditorSliceConfig,\n createDefaultSqlEditorConfig,\n} from '@sqlrooms/sql-editor-config';\n"]}
|