@malloy-publisher/sdk 0.9.16 → 0.10.1
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/{RenderedResult-5hOs5XnV.cjs.js → RenderedResult-B5f4qOjp.cjs.js} +1 -1
- package/dist/{RenderedResult-DxmHGZNQ.es.js → RenderedResult-vf6tu8tf.es.js} +2 -2
- package/dist/{ServerProvider-D7neZcTk.es.js → ServerProvider-B6RLAbgV.es.js} +48 -24
- package/dist/builder/index.cjs.js +17 -17
- package/dist/builder/index.es.js +278 -266
- package/dist/client/api.d.ts +64 -28
- package/dist/client/index.es.js +1 -1
- package/dist/components/ReportBuilder/TextTileBody.d.ts +9 -2
- package/dist/components/legacy/malloynb/CellRunnerView.d.ts +6 -6
- package/dist/hooks/useSettled.d.ts +5 -8
- package/dist/hooks/useSettledDraft.d.ts +33 -0
- package/dist/index.cjs.js +10 -10
- package/dist/index.es.js +3769 -3779
- package/dist/useCompiledDocument-C995sQ3j.cjs.js +142 -0
- package/dist/{useCompiledDocument-CaYP_OYG.es.js → useCompiledDocument-CLbTFtsJ.es.js} +5449 -5294
- package/dist/utils/malloyLiteral.d.ts +2 -0
- package/package.json +11 -16
- package/src/components/ReportBuilder/BuilderGrid.tsx +1 -0
- package/src/components/ReportBuilder/TextTileBody.tsx +24 -4
- package/src/components/ReportBuilder/placement.spec.ts +27 -0
- package/src/components/ReportBuilder/placement.ts +8 -4
- package/src/components/given/GivenInput.spec.tsx +447 -2
- package/src/components/given/GivenInput.tsx +192 -80
- package/src/components/given/GivensPanel.spec.tsx +59 -0
- package/src/components/given/GivensPanel.tsx +14 -2
- package/src/components/legacy/malloynb/CellRunnerView.tsx +6 -6
- package/src/hooks/useDimensionFilters.ts +1 -35
- package/src/hooks/useDimensionFiltersQuery.ts +2 -36
- package/src/hooks/useDimensionalFilterRangeData.ts +1 -35
- package/src/hooks/useGivensState.spec.ts +106 -1
- package/src/hooks/useGivensState.ts +48 -13
- package/src/hooks/useSettled.ts +5 -8
- package/src/hooks/useSettledDraft.ts +127 -0
- package/src/utils/malloyLiteral.spec.ts +12 -1
- package/src/utils/malloyLiteral.ts +32 -0
- package/vite.config.ts +0 -2
- package/.eslintrc +0 -36
- package/dist/components/DOMElement/DOMElement.d.ts +0 -5
- package/dist/components/DOMElement/index.d.ts +0 -1
- package/dist/components/Package/FileTreeView.d.ts +0 -9
- package/dist/useCompiledDocument-zYEfLogf.cjs.js +0 -142
- package/src/components/DOMElement/DOMElement.tsx +0 -22
- package/src/components/DOMElement/index.ts +0 -4
- package/src/components/Package/FileTreeView.tsx +0 -244
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { useEffect, useRef } from "react";
|
|
5
|
-
|
|
6
|
-
interface DOMElement {
|
|
7
|
-
element: HTMLElement;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default function DOMElement({ element }: DOMElement) {
|
|
11
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
12
|
-
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const parent = ref.current;
|
|
15
|
-
if (parent) {
|
|
16
|
-
parent.innerHTML = "";
|
|
17
|
-
parent.appendChild(element);
|
|
18
|
-
}
|
|
19
|
-
}, [element]);
|
|
20
|
-
|
|
21
|
-
return <div ref={ref}></div>;
|
|
22
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
import {
|
|
6
|
-
TreeItem2Content,
|
|
7
|
-
TreeItem2Label,
|
|
8
|
-
TreeItem2Root,
|
|
9
|
-
TreeItem2IconContainer,
|
|
10
|
-
} from "@mui/x-tree-view/TreeItem2";
|
|
11
|
-
import { RichTreeView } from "@mui/x-tree-view/RichTreeView";
|
|
12
|
-
import { TreeItem2Provider } from "@mui/x-tree-view/TreeItem2Provider";
|
|
13
|
-
import { TreeViewBaseItem } from "@mui/x-tree-view/models";
|
|
14
|
-
import {
|
|
15
|
-
unstable_useTreeItem2 as useTreeItem2,
|
|
16
|
-
UseTreeItem2Parameters,
|
|
17
|
-
} from "@mui/x-tree-view/useTreeItem2";
|
|
18
|
-
import { TreeItem2Icon } from "@mui/x-tree-view/TreeItem2Icon";
|
|
19
|
-
import FolderIcon from "@mui/icons-material/FolderOutlined";
|
|
20
|
-
import ArticleIcon from "@mui/icons-material/ArticleOutlined";
|
|
21
|
-
import ErrorIcon from "@mui/icons-material/ErrorOutlined";
|
|
22
|
-
import { TransitionProps } from "@mui/material/transitions";
|
|
23
|
-
import { animated, useSpring } from "@react-spring/web";
|
|
24
|
-
import Collapse from "@mui/material/Collapse";
|
|
25
|
-
import DnsIcon from "@mui/icons-material/DnsOutlined";
|
|
26
|
-
import DataArrayIcon from "@mui/icons-material/DataArrayOutlined";
|
|
27
|
-
import { Database, Model } from "../../client";
|
|
28
|
-
import { Typography, Tooltip } from "@mui/material";
|
|
29
|
-
|
|
30
|
-
interface FiieTreeViewProps {
|
|
31
|
-
items: Model[] | Database[];
|
|
32
|
-
defaultExpandedItems: string[];
|
|
33
|
-
onClickTreeNode?: (to: string, event?: React.MouseEvent) => void;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function FileTreeView({
|
|
37
|
-
items,
|
|
38
|
-
defaultExpandedItems,
|
|
39
|
-
onClickTreeNode,
|
|
40
|
-
}: FiieTreeViewProps) {
|
|
41
|
-
return (
|
|
42
|
-
<RichTreeView
|
|
43
|
-
items={getTreeView(items, onClickTreeNode)}
|
|
44
|
-
defaultExpandedItems={defaultExpandedItems}
|
|
45
|
-
slots={{ item: CustomTreeItem }}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const AnimatedCollapse = animated(Collapse);
|
|
51
|
-
|
|
52
|
-
function TransitionComponent(props: TransitionProps) {
|
|
53
|
-
const style = useSpring({
|
|
54
|
-
to: {
|
|
55
|
-
opacity: props.in ? 1 : 0,
|
|
56
|
-
transform: `translate3d(0,${props.in ? 0 : 20}px,0)`,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return <AnimatedCollapse style={style} {...props} />;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
type FileType = "directory" | "model" | "notebook" | "database" | "unknown";
|
|
64
|
-
|
|
65
|
-
type ExtendedTreeItemProps = {
|
|
66
|
-
id: string;
|
|
67
|
-
label: string;
|
|
68
|
-
fileType: FileType;
|
|
69
|
-
selectable: boolean;
|
|
70
|
-
link: ((event?: React.MouseEvent) => void) | undefined;
|
|
71
|
-
error?: string;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
interface CustomLabelProps {
|
|
75
|
-
item: ExtendedTreeItemProps;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function CustomTreeItem2Label({ item, ...other }: CustomLabelProps) {
|
|
79
|
-
const label = (
|
|
80
|
-
<TreeItem2Label
|
|
81
|
-
{...other}
|
|
82
|
-
sx={{
|
|
83
|
-
display: "flex",
|
|
84
|
-
alignItems: "center",
|
|
85
|
-
color: item.error ? "error.main" : "grey.600",
|
|
86
|
-
}}
|
|
87
|
-
>
|
|
88
|
-
{(item.fileType === "directory" && <FolderIcon />) ||
|
|
89
|
-
(item.fileType === "notebook" && <ArticleIcon />) ||
|
|
90
|
-
(item.fileType === "model" && <DataArrayIcon />) ||
|
|
91
|
-
(item.fileType == "database" && <DnsIcon />) || <ErrorIcon />}
|
|
92
|
-
<Typography
|
|
93
|
-
variant="body2"
|
|
94
|
-
sx={{ marginLeft: "5px" }}
|
|
95
|
-
color={
|
|
96
|
-
item.error
|
|
97
|
-
? "error.main"
|
|
98
|
-
: item.link
|
|
99
|
-
? "primary.main"
|
|
100
|
-
: "grey.600"
|
|
101
|
-
}
|
|
102
|
-
>
|
|
103
|
-
{item.label}
|
|
104
|
-
</Typography>
|
|
105
|
-
</TreeItem2Label>
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
return item.error ? (
|
|
109
|
-
<Tooltip title={item.error} placement="right">
|
|
110
|
-
{label}
|
|
111
|
-
</Tooltip>
|
|
112
|
-
) : (
|
|
113
|
-
label
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
interface CustomTreeItemProps
|
|
118
|
-
extends Omit<UseTreeItem2Parameters, "rootRef">,
|
|
119
|
-
Omit<React.HTMLAttributes<HTMLLIElement>, "onFocus"> {}
|
|
120
|
-
|
|
121
|
-
const CustomTreeItem = React.forwardRef(function CustomTreeItem(
|
|
122
|
-
props: CustomTreeItemProps,
|
|
123
|
-
ref: React.Ref<HTMLLIElement>,
|
|
124
|
-
) {
|
|
125
|
-
const { id, itemId, label, children, disabled, ...other } = props;
|
|
126
|
-
const {
|
|
127
|
-
getRootProps,
|
|
128
|
-
getContentProps,
|
|
129
|
-
getLabelProps,
|
|
130
|
-
getIconContainerProps,
|
|
131
|
-
getGroupTransitionProps,
|
|
132
|
-
status,
|
|
133
|
-
publicAPI,
|
|
134
|
-
} = useTreeItem2({
|
|
135
|
-
id,
|
|
136
|
-
itemId,
|
|
137
|
-
children,
|
|
138
|
-
label,
|
|
139
|
-
disabled,
|
|
140
|
-
rootRef: ref,
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const item = publicAPI.getItem(itemId);
|
|
144
|
-
|
|
145
|
-
// Disable select and focus. We want to either click through to a model or notebook or just exapnd
|
|
146
|
-
// collapse
|
|
147
|
-
status.selected = false;
|
|
148
|
-
status.focused = false;
|
|
149
|
-
|
|
150
|
-
return (
|
|
151
|
-
<TreeItem2Provider itemId={itemId}>
|
|
152
|
-
<TreeItem2Root {...getRootProps(other)}>
|
|
153
|
-
<TreeItem2Content
|
|
154
|
-
{...getContentProps()}
|
|
155
|
-
{...(item.link && {
|
|
156
|
-
onClick: (event) => item.link(event),
|
|
157
|
-
})}
|
|
158
|
-
sx={{
|
|
159
|
-
// If the item is not selectable, disable pointer events.
|
|
160
|
-
pointerEvents: !item.selectable && "none",
|
|
161
|
-
}}
|
|
162
|
-
>
|
|
163
|
-
<TreeItem2IconContainer {...getIconContainerProps()}>
|
|
164
|
-
<TreeItem2Icon status={status} />
|
|
165
|
-
</TreeItem2IconContainer>
|
|
166
|
-
<CustomTreeItem2Label
|
|
167
|
-
{...getLabelProps({
|
|
168
|
-
item,
|
|
169
|
-
})}
|
|
170
|
-
/>
|
|
171
|
-
</TreeItem2Content>
|
|
172
|
-
{children && <TransitionComponent {...getGroupTransitionProps()} />}
|
|
173
|
-
</TreeItem2Root>
|
|
174
|
-
</TreeItem2Provider>
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
function getTreeView(
|
|
179
|
-
metadataEntries: Model[] | Database[],
|
|
180
|
-
onClickTreeNode: (to: string, event?: React.MouseEvent) => void,
|
|
181
|
-
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
182
|
-
const tree = new Map<string, unknown>();
|
|
183
|
-
metadataEntries.map((entry: Model | Database) => {
|
|
184
|
-
let node = tree;
|
|
185
|
-
const pathParts = entry.path.split("/");
|
|
186
|
-
pathParts.forEach((part, index) => {
|
|
187
|
-
if (index === pathParts.length - 1) {
|
|
188
|
-
node.set(part, entry);
|
|
189
|
-
} else if (!node.has(part)) {
|
|
190
|
-
node.set(part, new Map<string, unknown>());
|
|
191
|
-
node = node.get(part) as Map<string, unknown>;
|
|
192
|
-
} else {
|
|
193
|
-
node = node.get(part) as Map<string, unknown>;
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
return getTreeViewRecursive(tree, "", onClickTreeNode);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
function getTreeViewRecursive(
|
|
201
|
-
node: Map<string, unknown>,
|
|
202
|
-
path: string,
|
|
203
|
-
onClickNode: (to: string, event?: React.MouseEvent) => void,
|
|
204
|
-
): TreeViewBaseItem<ExtendedTreeItemProps>[] {
|
|
205
|
-
const treeViewItems: TreeViewBaseItem<ExtendedTreeItemProps>[] = [];
|
|
206
|
-
node.forEach((value, key) => {
|
|
207
|
-
const fileType =
|
|
208
|
-
(key.endsWith(".malloy") && "model") ||
|
|
209
|
-
(key.endsWith(".malloynb") && "notebook") ||
|
|
210
|
-
(key.endsWith(".parquet") && "database") ||
|
|
211
|
-
"unknown";
|
|
212
|
-
if (fileType !== "unknown") {
|
|
213
|
-
// This is a model or database.
|
|
214
|
-
const entry = value as Model | Database;
|
|
215
|
-
treeViewItems.push({
|
|
216
|
-
id: path + key,
|
|
217
|
-
label: key,
|
|
218
|
-
fileType: fileType,
|
|
219
|
-
link:
|
|
220
|
-
fileType === "model" || fileType === "notebook"
|
|
221
|
-
? (event) => onClickNode(path + key, event)
|
|
222
|
-
: undefined,
|
|
223
|
-
selectable: fileType === "model" || fileType === "notebook",
|
|
224
|
-
error: "error" in entry ? entry.error : undefined,
|
|
225
|
-
});
|
|
226
|
-
} else {
|
|
227
|
-
// This is a directory.
|
|
228
|
-
const childPath = path + key + "/";
|
|
229
|
-
treeViewItems.push({
|
|
230
|
-
id: childPath,
|
|
231
|
-
label: key,
|
|
232
|
-
fileType: "directory",
|
|
233
|
-
selectable: true,
|
|
234
|
-
link: undefined,
|
|
235
|
-
children: getTreeViewRecursive(
|
|
236
|
-
value as Map<string, unknown>,
|
|
237
|
-
childPath,
|
|
238
|
-
onClickNode,
|
|
239
|
-
),
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
return treeViewItems;
|
|
244
|
-
}
|