@malloy-publisher/sdk 0.0.147 → 0.0.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RenderedResult/ResultContainer.d.ts +1 -3
- package/dist/index.cjs.js +7 -7
- package/dist/index.es.js +161 -176
- package/package.json +1 -1
- package/src/components/Model/ModelCell.tsx +0 -2
- package/src/components/Notebook/NotebookCell.tsx +0 -16
- package/src/components/RenderedResult/RenderedResult.tsx +28 -8
- package/src/components/RenderedResult/ResultContainer.tsx +2 -6
- package/src/components/ResultsDialog.tsx +2 -4
- package/src/components/Workbook/MutableCell.tsx +2 -6
- package/src/components/filter/DimensionFilter.tsx +13 -3
- package/src/components/styles.ts +1 -1
package/package.json
CHANGED
|
@@ -441,27 +441,11 @@ export function NotebookCell({
|
|
|
441
441
|
>
|
|
442
442
|
<ResultContainer
|
|
443
443
|
result={cell.result}
|
|
444
|
-
minHeight={200}
|
|
445
444
|
maxHeight={700}
|
|
446
445
|
maxResultSize={maxResultSize}
|
|
447
446
|
/>
|
|
448
447
|
</Box>
|
|
449
448
|
|
|
450
|
-
{/* Fade effect at bottom to indicate more content */}
|
|
451
|
-
<Box
|
|
452
|
-
sx={{
|
|
453
|
-
position: "absolute",
|
|
454
|
-
bottom: 0,
|
|
455
|
-
left: 0,
|
|
456
|
-
right: 0,
|
|
457
|
-
height: "40px",
|
|
458
|
-
background:
|
|
459
|
-
"linear-gradient(transparent, rgba(255, 255, 255, 0.9))",
|
|
460
|
-
pointerEvents: "none",
|
|
461
|
-
zIndex: 1,
|
|
462
|
-
}}
|
|
463
|
-
/>
|
|
464
|
-
|
|
465
449
|
{/* Top right corner controls */}
|
|
466
450
|
<Stack
|
|
467
451
|
sx={{
|
|
@@ -42,11 +42,12 @@ const createRenderer = async (onDrill?: (element: unknown) => void) => {
|
|
|
42
42
|
// Inner component that actually renders the visualization
|
|
43
43
|
function RenderedResultInner({
|
|
44
44
|
result,
|
|
45
|
-
height,
|
|
45
|
+
height: inputHeight,
|
|
46
46
|
onDrill,
|
|
47
47
|
onSizeChange,
|
|
48
48
|
}: RenderedResultProps) {
|
|
49
49
|
const ref = useRef<HTMLDivElement>(null);
|
|
50
|
+
const hasMeasuredRef = useRef(false);
|
|
50
51
|
|
|
51
52
|
// Render the visualization once the component mounts
|
|
52
53
|
useLayoutEffect(() => {
|
|
@@ -60,22 +61,41 @@ function RenderedResultInner({
|
|
|
60
61
|
element.removeChild(element.firstChild);
|
|
61
62
|
}
|
|
62
63
|
|
|
64
|
+
// Reset measurement flag when result changes
|
|
65
|
+
hasMeasuredRef.current = false;
|
|
66
|
+
|
|
63
67
|
// Set up observer to measure size after render completes
|
|
64
68
|
let observer: MutationObserver | null = null;
|
|
65
69
|
let measureTimeout: NodeJS.Timeout | null = null;
|
|
66
70
|
|
|
67
71
|
const measureRenderedSize = () => {
|
|
68
|
-
if
|
|
69
|
-
|
|
72
|
+
// Skip if already measured or unmounted
|
|
73
|
+
if (hasMeasuredRef.current || !isMounted || !element.firstElementChild)
|
|
74
|
+
return;
|
|
70
75
|
// It's the grandchild that is the actual visualization.
|
|
71
76
|
const child = element.firstElementChild as HTMLElement;
|
|
72
77
|
const grandchild = child.firstElementChild as HTMLElement;
|
|
73
78
|
if (!grandchild) return;
|
|
74
|
-
const
|
|
79
|
+
const greatgrandchild = grandchild.firstElementChild as HTMLElement;
|
|
80
|
+
let renderedHeight =
|
|
75
81
|
grandchild.scrollHeight || grandchild.offsetHeight || 0;
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
// HACK - malloy dashboards height are determined by the greatgrandchild.
|
|
84
|
+
if (
|
|
85
|
+
greatgrandchild &&
|
|
86
|
+
grandchild.classList.contains("malloy-dashboard")
|
|
87
|
+
) {
|
|
88
|
+
renderedHeight =
|
|
89
|
+
greatgrandchild.scrollHeight ||
|
|
90
|
+
greatgrandchild.offsetHeight ||
|
|
91
|
+
0;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (renderedHeight > 0) {
|
|
95
|
+
hasMeasuredRef.current = true;
|
|
96
|
+
if (onSizeChange) {
|
|
97
|
+
onSizeChange(renderedHeight);
|
|
98
|
+
}
|
|
79
99
|
}
|
|
80
100
|
};
|
|
81
101
|
|
|
@@ -119,13 +139,13 @@ function RenderedResultInner({
|
|
|
119
139
|
};
|
|
120
140
|
}, [result, onDrill, onSizeChange]);
|
|
121
141
|
|
|
122
|
-
//
|
|
142
|
+
// Malloy renderer requires explicit pixel height to render visualizations
|
|
123
143
|
return (
|
|
124
144
|
<div
|
|
125
145
|
ref={ref}
|
|
126
146
|
style={{
|
|
127
147
|
width: "100%",
|
|
128
|
-
height:
|
|
148
|
+
height: inputHeight ? `${inputHeight}px` : "400px",
|
|
129
149
|
}}
|
|
130
150
|
/>
|
|
131
151
|
);
|
|
@@ -7,9 +7,7 @@ const RenderedResult = lazy(() => import("../RenderedResult/RenderedResult"));
|
|
|
7
7
|
|
|
8
8
|
interface ResultContainerProps {
|
|
9
9
|
result: string | undefined;
|
|
10
|
-
minHeight: number;
|
|
11
10
|
maxHeight: number;
|
|
12
|
-
hideToggle?: boolean;
|
|
13
11
|
// if Results are larger than this size, show a warning and a button to proceed
|
|
14
12
|
// this is to prevent performance issues with large results.
|
|
15
13
|
// the default is 0, which means no warning will be shown.
|
|
@@ -22,9 +20,7 @@ interface ResultContainerProps {
|
|
|
22
20
|
// Non-fill elements that are smaller than minHeight will be shrunk down to their natural height.
|
|
23
21
|
export default function ResultContainer({
|
|
24
22
|
result,
|
|
25
|
-
minHeight,
|
|
26
23
|
maxHeight,
|
|
27
|
-
hideToggle: _hideToggle = false,
|
|
28
24
|
maxResultSize = 0,
|
|
29
25
|
}: ResultContainerProps) {
|
|
30
26
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
@@ -41,7 +37,7 @@ export default function ResultContainer({
|
|
|
41
37
|
return (
|
|
42
38
|
<Box
|
|
43
39
|
sx={{
|
|
44
|
-
minHeight: `${minHeight}px`,
|
|
40
|
+
// minHeight: `${minHeight}px`,
|
|
45
41
|
display: "flex",
|
|
46
42
|
flexDirection: "column",
|
|
47
43
|
alignItems: "center",
|
|
@@ -79,7 +75,7 @@ export default function ResultContainer({
|
|
|
79
75
|
ref={containerRef}
|
|
80
76
|
sx={{
|
|
81
77
|
position: "relative",
|
|
82
|
-
height:
|
|
78
|
+
height: "auto",
|
|
83
79
|
border: "0px",
|
|
84
80
|
borderRadius: 0,
|
|
85
81
|
overflow: "hidden",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Dialog, DialogContent, DialogTitle, IconButton } from "@mui/material";
|
|
3
1
|
import CloseIcon from "@mui/icons-material/Close";
|
|
2
|
+
import { Dialog, DialogContent, DialogTitle, IconButton } from "@mui/material";
|
|
4
3
|
import ResultContainer from "./RenderedResult/ResultContainer";
|
|
5
4
|
|
|
6
5
|
interface ResultsDialogProps {
|
|
@@ -51,9 +50,8 @@ export default function ResultsDialog({
|
|
|
51
50
|
>
|
|
52
51
|
<ResultContainer
|
|
53
52
|
result={result}
|
|
54
|
-
minHeight={800}
|
|
55
53
|
maxHeight={800}
|
|
56
|
-
|
|
54
|
+
maxResultSize={1000000}
|
|
57
55
|
/>
|
|
58
56
|
</DialogContent>
|
|
59
57
|
</Dialog>
|
|
@@ -24,10 +24,10 @@ import {
|
|
|
24
24
|
QueryExplorerResult,
|
|
25
25
|
SourceAndPath,
|
|
26
26
|
} from "../Model/SourcesExplorer";
|
|
27
|
-
import { WorkbookCellValue } from "./WorkbookManager";
|
|
28
27
|
import ResultContainer from "../RenderedResult/ResultContainer";
|
|
29
28
|
import { StyledCard } from "../styles";
|
|
30
29
|
import { EditableMalloyCell } from "./EditableMalloyCell";
|
|
30
|
+
import { WorkbookCellValue } from "./WorkbookManager";
|
|
31
31
|
|
|
32
32
|
interface NotebookCellProps {
|
|
33
33
|
cell: WorkbookCellValue;
|
|
@@ -423,11 +423,7 @@ export function MutableCell({
|
|
|
423
423
|
))}
|
|
424
424
|
{!editingMalloy && cell.result && (
|
|
425
425
|
<StyledCard variant="outlined" sx={{ borderRadius: 0 }}>
|
|
426
|
-
<ResultContainer
|
|
427
|
-
result={cell.result}
|
|
428
|
-
minHeight={300}
|
|
429
|
-
maxHeight={800}
|
|
430
|
-
/>
|
|
426
|
+
<ResultContainer result={cell.result} maxHeight={800} />
|
|
431
427
|
</StyledCard>
|
|
432
428
|
)}
|
|
433
429
|
{!editingMalloy && !cell.result && (
|
|
@@ -320,12 +320,20 @@ export function DimensionFilter({
|
|
|
320
320
|
"& .MuiInputBase-root": { fontSize: "0.75rem" },
|
|
321
321
|
"& .MuiInputBase-input": { padding: "6px 10px" },
|
|
322
322
|
"& .MuiSelect-select": { padding: "6px 10px !important" },
|
|
323
|
-
"& .MuiAutocomplete-input": { padding: "
|
|
323
|
+
"& .MuiAutocomplete-input": { padding: "0 !important" },
|
|
324
324
|
"& .MuiAutocomplete-root .MuiInputBase-root": {
|
|
325
|
-
padding: "
|
|
325
|
+
padding: "5px 10px",
|
|
326
|
+
minHeight: "29.5px",
|
|
327
|
+
maxHeight: "29.5px",
|
|
328
|
+
boxSizing: "border-box",
|
|
329
|
+
overflow: "hidden",
|
|
326
330
|
},
|
|
327
|
-
"& .MuiChip-root": { height: "
|
|
331
|
+
"& .MuiChip-root": { height: "16px", margin: "0 2px 0 0" },
|
|
328
332
|
"& .MuiChip-label": { fontSize: "0.7rem", padding: "0 6px" },
|
|
333
|
+
"& .MuiChip-deleteIcon": {
|
|
334
|
+
fontSize: "14px",
|
|
335
|
+
margin: "0 2px 0 -4px",
|
|
336
|
+
},
|
|
329
337
|
"& .MuiInputLabel-root": {
|
|
330
338
|
fontSize: "0.75rem",
|
|
331
339
|
transform: "translate(10px, 6px) scale(1)",
|
|
@@ -420,6 +428,7 @@ export function DimensionFilter({
|
|
|
420
428
|
renderInput={(params) => (
|
|
421
429
|
<TextField
|
|
422
430
|
{...params}
|
|
431
|
+
size="small"
|
|
423
432
|
label="Values"
|
|
424
433
|
placeholder="Select values..."
|
|
425
434
|
/>
|
|
@@ -542,6 +551,7 @@ export function DimensionFilter({
|
|
|
542
551
|
renderInput={(params) => (
|
|
543
552
|
<TextField
|
|
544
553
|
{...params}
|
|
554
|
+
size="small"
|
|
545
555
|
label="Search Values"
|
|
546
556
|
placeholder="Type to search..."
|
|
547
557
|
onFocus={() => setRetrievalFocused(true)}
|
package/src/components/styles.ts
CHANGED
|
@@ -23,7 +23,7 @@ export const StyledCardMedia = styled(CardMedia)({
|
|
|
23
23
|
// New clean notebook styles
|
|
24
24
|
export const CleanNotebookContainer = styled("div")({
|
|
25
25
|
backgroundColor: "#ffffff",
|
|
26
|
-
padding: "0
|
|
26
|
+
padding: "0 8px 0px 8px",
|
|
27
27
|
borderRadius: "12px",
|
|
28
28
|
boxShadow: "none",
|
|
29
29
|
border: "none",
|