@malloy-publisher/sdk 0.2.6 → 0.3.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.
- package/README.md +172 -204
- package/dist/ServerProvider-CGnLjzag.cjs.js +1 -0
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-DSK9rfSY.es.js} +245 -245
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +4 -2
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +36 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +18 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +1 -0
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +2 -3
- package/dist/components/styles.d.ts +3 -3
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-xdZbLgaF.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +281 -1
- package/dist/index.es.js +45803 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/package.json +2 -6
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.tsx +60 -95
- package/src/components/Dashboard/DashboardTile.tsx +25 -2
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +137 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +129 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +46 -0
- package/src/components/DocumentStorage/index.ts +15 -0
- package/src/components/Environment/Connections.tsx +15 -15
- package/src/components/Model/ModelCell.tsx +2 -1
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +10 -76
- package/src/components/Notebook/NotebookCell.tsx +2 -8
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +21 -24
- package/src/components/RenderedResult/index.ts +15 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +5 -0
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +5 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/vite.config.ts +0 -1
- package/dist/ServerProvider-xXW1HJOJ.cjs.js +0 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-RvrkY1Ss.cjs.js +0 -148
- package/dist/index-B3scIDRd.cjs.js +0 -356
- package/dist/index-Bda7HuZc.es.js +0 -66409
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- package/src/components/Workbook/index.ts +0 -10
package/dist/markdown-editor.css
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
.w-md-editor-bar {
|
|
2
|
-
position: absolute;
|
|
3
|
-
cursor: s-resize;
|
|
4
|
-
right: 0;
|
|
5
|
-
bottom: 0;
|
|
6
|
-
margin-top: -11px;
|
|
7
|
-
margin-right: 0;
|
|
8
|
-
width: 14px;
|
|
9
|
-
z-index: 3;
|
|
10
|
-
height: 10px;
|
|
11
|
-
border-radius: 0 0 3px 0;
|
|
12
|
-
-webkit-user-select: none;
|
|
13
|
-
user-select: none;
|
|
14
|
-
}
|
|
15
|
-
.w-md-editor-bar svg {
|
|
16
|
-
display: block;
|
|
17
|
-
margin: 0 auto;
|
|
18
|
-
}
|
|
19
|
-
.w-md-editor-area {
|
|
20
|
-
overflow: auto;
|
|
21
|
-
border-radius: 5px;
|
|
22
|
-
}
|
|
23
|
-
.w-md-editor-text {
|
|
24
|
-
min-height: 100%;
|
|
25
|
-
position: relative;
|
|
26
|
-
text-align: left;
|
|
27
|
-
white-space: pre-wrap;
|
|
28
|
-
word-break: keep-all;
|
|
29
|
-
overflow-wrap: break-word;
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
padding: 10px;
|
|
32
|
-
margin: 0;
|
|
33
|
-
font-size: 14px !important;
|
|
34
|
-
line-height: 18px !important;
|
|
35
|
-
font-variant-ligatures: common-ligatures;
|
|
36
|
-
}
|
|
37
|
-
.w-md-editor-text-pre,
|
|
38
|
-
.w-md-editor-text-input,
|
|
39
|
-
.w-md-editor-text > .w-md-editor-text-pre {
|
|
40
|
-
margin: 0;
|
|
41
|
-
border: 0;
|
|
42
|
-
background: none;
|
|
43
|
-
box-sizing: inherit;
|
|
44
|
-
display: inherit;
|
|
45
|
-
font-family: inherit;
|
|
46
|
-
font-family: var(--md-editor-font-family) !important;
|
|
47
|
-
font-size: inherit;
|
|
48
|
-
font-style: inherit;
|
|
49
|
-
font-variant-ligatures: inherit;
|
|
50
|
-
font-weight: inherit;
|
|
51
|
-
letter-spacing: inherit;
|
|
52
|
-
line-height: inherit;
|
|
53
|
-
tab-size: inherit;
|
|
54
|
-
text-indent: inherit;
|
|
55
|
-
text-rendering: inherit;
|
|
56
|
-
text-transform: inherit;
|
|
57
|
-
white-space: inherit;
|
|
58
|
-
overflow-wrap: inherit;
|
|
59
|
-
word-break: inherit;
|
|
60
|
-
word-break: normal;
|
|
61
|
-
padding: 0;
|
|
62
|
-
}
|
|
63
|
-
.w-md-editor-text-pre {
|
|
64
|
-
position: relative;
|
|
65
|
-
margin: 0px !important;
|
|
66
|
-
pointer-events: none;
|
|
67
|
-
background-color: transparent !important;
|
|
68
|
-
}
|
|
69
|
-
.w-md-editor-text-pre > code {
|
|
70
|
-
padding: 0 !important;
|
|
71
|
-
font-family: var(--md-editor-font-family) !important;
|
|
72
|
-
font-size: 14px !important;
|
|
73
|
-
line-height: 18px !important;
|
|
74
|
-
}
|
|
75
|
-
.w-md-editor-text-input {
|
|
76
|
-
position: absolute;
|
|
77
|
-
top: 0px;
|
|
78
|
-
left: 0px;
|
|
79
|
-
height: 100%;
|
|
80
|
-
width: 100%;
|
|
81
|
-
resize: none;
|
|
82
|
-
color: inherit;
|
|
83
|
-
overflow: hidden;
|
|
84
|
-
outline: 0;
|
|
85
|
-
padding: inherit;
|
|
86
|
-
-webkit-font-smoothing: antialiased;
|
|
87
|
-
-webkit-text-fill-color: transparent;
|
|
88
|
-
}
|
|
89
|
-
.w-md-editor-text-input:empty {
|
|
90
|
-
-webkit-text-fill-color: inherit !important;
|
|
91
|
-
}
|
|
92
|
-
.w-md-editor-text-pre,
|
|
93
|
-
.w-md-editor-text-input {
|
|
94
|
-
word-wrap: pre;
|
|
95
|
-
word-break: break-word;
|
|
96
|
-
white-space: pre-wrap;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Hack to apply on some CSS on IE10 and IE11
|
|
100
|
-
*/
|
|
101
|
-
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
|
|
102
|
-
/**
|
|
103
|
-
* IE doesn't support '-webkit-text-fill-color'
|
|
104
|
-
* So we use 'color: transparent' to make the text transparent on IE
|
|
105
|
-
* Unlike other browsers, it doesn't affect caret color in IE
|
|
106
|
-
*/
|
|
107
|
-
.w-md-editor-text-input {
|
|
108
|
-
color: transparent !important;
|
|
109
|
-
}
|
|
110
|
-
.w-md-editor-text-input::selection {
|
|
111
|
-
background-color: #accef7 !important;
|
|
112
|
-
color: transparent !important;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
.w-md-editor-text-pre .punctuation {
|
|
116
|
-
color: var(--color-prettylights-syntax-comment, #8b949e) !important;
|
|
117
|
-
}
|
|
118
|
-
.w-md-editor-text-pre .token.url,
|
|
119
|
-
.w-md-editor-text-pre .token.content {
|
|
120
|
-
color: var(--color-prettylights-syntax-constant, #0550ae) !important;
|
|
121
|
-
}
|
|
122
|
-
.w-md-editor-text-pre .token.title.important {
|
|
123
|
-
color: var(--color-prettylights-syntax-markup-bold, #24292f);
|
|
124
|
-
}
|
|
125
|
-
.w-md-editor-text-pre .token.code-block .function {
|
|
126
|
-
color: var(--color-prettylights-syntax-entity, #8250df);
|
|
127
|
-
}
|
|
128
|
-
.w-md-editor-text-pre .token.bold {
|
|
129
|
-
font-weight: unset !important;
|
|
130
|
-
}
|
|
131
|
-
.w-md-editor-text-pre .token.title {
|
|
132
|
-
line-height: unset !important;
|
|
133
|
-
font-size: unset !important;
|
|
134
|
-
font-weight: unset !important;
|
|
135
|
-
}
|
|
136
|
-
.w-md-editor-text-pre .token.code.keyword {
|
|
137
|
-
color: var(--color-prettylights-syntax-constant, #0550ae) !important;
|
|
138
|
-
}
|
|
139
|
-
.w-md-editor-text-pre .token.strike,
|
|
140
|
-
.w-md-editor-text-pre .token.strike .content {
|
|
141
|
-
color: var(--color-prettylights-syntax-markup-deleted-text, #82071e) !important;
|
|
142
|
-
}
|
|
143
|
-
.w-md-editor-toolbar-child {
|
|
144
|
-
position: absolute;
|
|
145
|
-
border-radius: 3px;
|
|
146
|
-
box-shadow: 0 0 0 1px var(--md-editor-box-shadow-color), 0 0 0 var(--md-editor-box-shadow-color), 0 1px 1px var(--md-editor-box-shadow-color);
|
|
147
|
-
background-color: var(--md-editor-background-color);
|
|
148
|
-
z-index: 1;
|
|
149
|
-
display: none;
|
|
150
|
-
}
|
|
151
|
-
.w-md-editor-toolbar-child.active {
|
|
152
|
-
display: block;
|
|
153
|
-
}
|
|
154
|
-
.w-md-editor-toolbar-child .w-md-editor-toolbar {
|
|
155
|
-
border-bottom: 0;
|
|
156
|
-
padding: 3px;
|
|
157
|
-
border-radius: 3px;
|
|
158
|
-
}
|
|
159
|
-
.w-md-editor-toolbar-child .w-md-editor-toolbar ul > li {
|
|
160
|
-
display: block;
|
|
161
|
-
}
|
|
162
|
-
.w-md-editor-toolbar-child .w-md-editor-toolbar ul > li button {
|
|
163
|
-
width: -webkit-fill-available;
|
|
164
|
-
height: initial;
|
|
165
|
-
box-sizing: border-box;
|
|
166
|
-
padding: 3px 4px 2px 4px;
|
|
167
|
-
margin: 0;
|
|
168
|
-
}
|
|
169
|
-
.w-md-editor-toolbar {
|
|
170
|
-
border-bottom: 1px solid var(--md-editor-box-shadow-color);
|
|
171
|
-
background-color: var(--md-editor-background-color);
|
|
172
|
-
padding: 3px;
|
|
173
|
-
display: flex;
|
|
174
|
-
justify-content: space-between;
|
|
175
|
-
align-items: center;
|
|
176
|
-
border-radius: 3px 3px 0 0;
|
|
177
|
-
-webkit-user-select: none;
|
|
178
|
-
user-select: none;
|
|
179
|
-
flex-wrap: wrap;
|
|
180
|
-
}
|
|
181
|
-
.w-md-editor-toolbar.bottom {
|
|
182
|
-
border-bottom: 0px;
|
|
183
|
-
border-top: 1px solid var(--md-editor-box-shadow-color);
|
|
184
|
-
border-radius: 0 0 3px 3px;
|
|
185
|
-
}
|
|
186
|
-
.w-md-editor-toolbar ul,
|
|
187
|
-
.w-md-editor-toolbar li {
|
|
188
|
-
margin: 0;
|
|
189
|
-
padding: 0;
|
|
190
|
-
list-style: none;
|
|
191
|
-
line-height: initial;
|
|
192
|
-
}
|
|
193
|
-
.w-md-editor-toolbar li {
|
|
194
|
-
display: inline-block;
|
|
195
|
-
font-size: 14px;
|
|
196
|
-
}
|
|
197
|
-
.w-md-editor-toolbar li + li {
|
|
198
|
-
margin: 0;
|
|
199
|
-
}
|
|
200
|
-
.w-md-editor-toolbar li > button {
|
|
201
|
-
border: none;
|
|
202
|
-
height: 20px;
|
|
203
|
-
line-height: 14px;
|
|
204
|
-
background: none;
|
|
205
|
-
padding: 4px;
|
|
206
|
-
margin: 0 1px;
|
|
207
|
-
border-radius: 2px;
|
|
208
|
-
text-transform: none;
|
|
209
|
-
font-weight: normal;
|
|
210
|
-
overflow: visible;
|
|
211
|
-
outline: none;
|
|
212
|
-
cursor: pointer;
|
|
213
|
-
transition: all 0.3s;
|
|
214
|
-
white-space: nowrap;
|
|
215
|
-
color: var(--color-fg-default);
|
|
216
|
-
}
|
|
217
|
-
.w-md-editor-toolbar li > button:hover,
|
|
218
|
-
.w-md-editor-toolbar li > button:focus {
|
|
219
|
-
background-color: var(--color-neutral-muted);
|
|
220
|
-
color: var(--color-accent-fg);
|
|
221
|
-
}
|
|
222
|
-
.w-md-editor-toolbar li > button:active {
|
|
223
|
-
background-color: var(--color-neutral-muted);
|
|
224
|
-
color: var(--color-danger-fg);
|
|
225
|
-
}
|
|
226
|
-
.w-md-editor-toolbar li > button:disabled {
|
|
227
|
-
color: var(--md-editor-box-shadow-color);
|
|
228
|
-
cursor: not-allowed;
|
|
229
|
-
}
|
|
230
|
-
.w-md-editor-toolbar li > button:disabled:hover {
|
|
231
|
-
background-color: transparent;
|
|
232
|
-
color: var(--md-editor-box-shadow-color);
|
|
233
|
-
}
|
|
234
|
-
.w-md-editor-toolbar li.active > button {
|
|
235
|
-
color: var(--color-accent-fg);
|
|
236
|
-
background-color: var(--color-neutral-muted);
|
|
237
|
-
}
|
|
238
|
-
.w-md-editor-toolbar-divider {
|
|
239
|
-
height: 14px;
|
|
240
|
-
width: 1px;
|
|
241
|
-
margin: -3px 3px 0 3px !important;
|
|
242
|
-
vertical-align: middle;
|
|
243
|
-
background-color: var(--md-editor-box-shadow-color);
|
|
244
|
-
}
|
|
245
|
-
.w-md-editor {
|
|
246
|
-
text-align: left;
|
|
247
|
-
border-radius: 3px;
|
|
248
|
-
padding-bottom: 1px;
|
|
249
|
-
position: relative;
|
|
250
|
-
color: var(--color-fg-default);
|
|
251
|
-
--md-editor-font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
252
|
-
--md-editor-background-color: var(--color-canvas-default, #ffffff);
|
|
253
|
-
--md-editor-box-shadow-color: var(--color-border-default, #d0d7de);
|
|
254
|
-
box-shadow: 0 0 0 1px var(--md-editor-box-shadow-color), 0 0 0 var(--md-editor-box-shadow-color), 0 1px 1px var(--md-editor-box-shadow-color);
|
|
255
|
-
background-color: var(--md-editor-background-color);
|
|
256
|
-
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
257
|
-
display: flex;
|
|
258
|
-
flex-direction: column;
|
|
259
|
-
}
|
|
260
|
-
.w-md-editor.w-md-editor-rtl {
|
|
261
|
-
direction: rtl !important;
|
|
262
|
-
text-align: right !important;
|
|
263
|
-
}
|
|
264
|
-
.w-md-editor.w-md-editor-rtl .w-md-editor-preview {
|
|
265
|
-
right: unset !important;
|
|
266
|
-
left: 0;
|
|
267
|
-
text-align: right !important;
|
|
268
|
-
box-shadow: inset -1px 0 0 0 var(--md-editor-box-shadow-color);
|
|
269
|
-
}
|
|
270
|
-
.w-md-editor.w-md-editor-rtl .w-md-editor-text {
|
|
271
|
-
text-align: right !important;
|
|
272
|
-
}
|
|
273
|
-
.w-md-editor-toolbar {
|
|
274
|
-
height: fit-content;
|
|
275
|
-
}
|
|
276
|
-
.w-md-editor-content {
|
|
277
|
-
height: 100%;
|
|
278
|
-
overflow: auto;
|
|
279
|
-
position: relative;
|
|
280
|
-
border-radius: 0 0 3px 0;
|
|
281
|
-
}
|
|
282
|
-
.w-md-editor .copied {
|
|
283
|
-
display: none !important;
|
|
284
|
-
}
|
|
285
|
-
.w-md-editor-input {
|
|
286
|
-
width: 50%;
|
|
287
|
-
height: 100%;
|
|
288
|
-
}
|
|
289
|
-
.w-md-editor-text-pre > code {
|
|
290
|
-
word-break: break-word !important;
|
|
291
|
-
white-space: pre-wrap !important;
|
|
292
|
-
}
|
|
293
|
-
.w-md-editor-preview {
|
|
294
|
-
width: 50%;
|
|
295
|
-
box-sizing: border-box;
|
|
296
|
-
box-shadow: inset 1px 0 0 0 var(--md-editor-box-shadow-color);
|
|
297
|
-
position: absolute;
|
|
298
|
-
padding: 10px 20px;
|
|
299
|
-
overflow: auto;
|
|
300
|
-
top: 0;
|
|
301
|
-
right: 0;
|
|
302
|
-
bottom: 0;
|
|
303
|
-
border-radius: 0 0 5px 0;
|
|
304
|
-
display: flex;
|
|
305
|
-
flex-direction: column;
|
|
306
|
-
}
|
|
307
|
-
.w-md-editor-preview .anchor {
|
|
308
|
-
display: none;
|
|
309
|
-
}
|
|
310
|
-
.w-md-editor-preview .contains-task-list li.task-list-item {
|
|
311
|
-
list-style: none;
|
|
312
|
-
}
|
|
313
|
-
.w-md-editor-show-preview .w-md-editor-input {
|
|
314
|
-
width: 0%;
|
|
315
|
-
overflow: hidden;
|
|
316
|
-
background-color: var(--md-editor-background-color);
|
|
317
|
-
}
|
|
318
|
-
.w-md-editor-show-preview .w-md-editor-preview {
|
|
319
|
-
width: 100%;
|
|
320
|
-
box-shadow: inset 0 0 0 0;
|
|
321
|
-
}
|
|
322
|
-
.w-md-editor-show-edit .w-md-editor-input {
|
|
323
|
-
width: 100%;
|
|
324
|
-
}
|
|
325
|
-
.w-md-editor-show-edit .w-md-editor-preview {
|
|
326
|
-
width: 0%;
|
|
327
|
-
padding: 0;
|
|
328
|
-
}
|
|
329
|
-
.w-md-editor-fullscreen {
|
|
330
|
-
overflow: hidden;
|
|
331
|
-
position: fixed;
|
|
332
|
-
z-index: 99999;
|
|
333
|
-
top: 0;
|
|
334
|
-
left: 0;
|
|
335
|
-
right: 0;
|
|
336
|
-
bottom: 0;
|
|
337
|
-
height: 100% !important;
|
|
338
|
-
}
|
|
339
|
-
.w-md-editor-fullscreen .w-md-editor-content {
|
|
340
|
-
height: 100%;
|
|
341
|
-
}
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
// Copyright (c) Credible Data Inc.
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
|
|
4
|
-
import { Add, Launch } from "@mui/icons-material";
|
|
5
|
-
import {
|
|
6
|
-
Box,
|
|
7
|
-
Button,
|
|
8
|
-
Dialog,
|
|
9
|
-
DialogContent,
|
|
10
|
-
DialogTitle,
|
|
11
|
-
FormControl,
|
|
12
|
-
InputLabel,
|
|
13
|
-
ListItemIcon,
|
|
14
|
-
ListItemText,
|
|
15
|
-
Menu,
|
|
16
|
-
MenuItem,
|
|
17
|
-
Select,
|
|
18
|
-
Stack,
|
|
19
|
-
TextField,
|
|
20
|
-
Typography,
|
|
21
|
-
} from "@mui/material";
|
|
22
|
-
import React from "react";
|
|
23
|
-
import { WorkbookList } from "./Workbook";
|
|
24
|
-
import { useWorkbookStorage } from "./Workbook/WorkbookStorageProvider";
|
|
25
|
-
import type { WorkbookLocator, Workspace } from "./Workbook/WorkbookStorage";
|
|
26
|
-
|
|
27
|
-
export interface AnalyzePackageButtonProps {
|
|
28
|
-
onWorkbookSelect: (
|
|
29
|
-
workbook: WorkbookLocator,
|
|
30
|
-
event: React.MouseEvent,
|
|
31
|
-
) => void;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function AnalyzePackageButton({
|
|
35
|
-
onWorkbookSelect,
|
|
36
|
-
}: AnalyzePackageButtonProps) {
|
|
37
|
-
const { workbookStorage } = useWorkbookStorage();
|
|
38
|
-
const [workbookName, setWorkbookName] = React.useState("");
|
|
39
|
-
const [selectedWorkspace, setSelectedWorkspace] = React.useState("");
|
|
40
|
-
const [availableWorkspaces, setAvailableWorkspaces] = React.useState<
|
|
41
|
-
Workspace[]
|
|
42
|
-
>([]);
|
|
43
|
-
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
44
|
-
const [newDialogOpen, setNewDialogOpen] = React.useState(false);
|
|
45
|
-
const [openDialogOpen, setOpenDialogOpen] = React.useState(false);
|
|
46
|
-
|
|
47
|
-
const open = Boolean(anchorEl);
|
|
48
|
-
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
49
|
-
setAnchorEl(event.currentTarget);
|
|
50
|
-
};
|
|
51
|
-
const handleMenuClose = () => {
|
|
52
|
-
setAnchorEl(null);
|
|
53
|
-
};
|
|
54
|
-
const handleOpenDialogClose = () => {
|
|
55
|
-
setOpenDialogOpen(false);
|
|
56
|
-
};
|
|
57
|
-
const handleNewDialogClose = () => {
|
|
58
|
-
setNewDialogOpen(false);
|
|
59
|
-
setWorkbookName("");
|
|
60
|
-
setSelectedWorkspace("");
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// Fetch available workspaces when the new dialog opens
|
|
64
|
-
React.useEffect(() => {
|
|
65
|
-
if (workbookStorage) {
|
|
66
|
-
console.log("fetching workspaces");
|
|
67
|
-
workbookStorage
|
|
68
|
-
.listWorkspaces(true) // Only show writeable workspaces
|
|
69
|
-
.then((workspaces) => {
|
|
70
|
-
setAvailableWorkspaces(workspaces);
|
|
71
|
-
// If only one workspace, select it by default
|
|
72
|
-
if (workspaces.length === 1) {
|
|
73
|
-
setSelectedWorkspace(workspaces[0].name);
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
.catch((error) => {
|
|
77
|
-
console.error("Error fetching workspaces:", error);
|
|
78
|
-
setAvailableWorkspaces([]);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}, [workbookStorage]);
|
|
82
|
-
|
|
83
|
-
const handleWorkbookClick = (
|
|
84
|
-
workbook: WorkbookLocator,
|
|
85
|
-
event: React.MouseEvent,
|
|
86
|
-
) => {
|
|
87
|
-
setOpenDialogOpen(false);
|
|
88
|
-
onWorkbookSelect(workbook, event);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const createWorkbookClick = (event?: React.MouseEvent) => {
|
|
92
|
-
setNewDialogOpen(false);
|
|
93
|
-
onWorkbookSelect(
|
|
94
|
-
{
|
|
95
|
-
path: workbookName,
|
|
96
|
-
workspace: selectedWorkspace,
|
|
97
|
-
},
|
|
98
|
-
event,
|
|
99
|
-
);
|
|
100
|
-
setWorkbookName("");
|
|
101
|
-
setSelectedWorkspace("");
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const noWorkspaces = availableWorkspaces.length === 0;
|
|
105
|
-
return (
|
|
106
|
-
<>
|
|
107
|
-
<Button
|
|
108
|
-
aria-controls={open ? "basic-menu" : undefined}
|
|
109
|
-
aria-haspopup="true"
|
|
110
|
-
aria-expanded={open ? "true" : undefined}
|
|
111
|
-
onClick={handleClick}
|
|
112
|
-
variant="contained"
|
|
113
|
-
sx={{
|
|
114
|
-
height: "40px",
|
|
115
|
-
px: 2,
|
|
116
|
-
backgroundColor: "#fbbb04",
|
|
117
|
-
"&:hover": {
|
|
118
|
-
backgroundColor: "#eab308",
|
|
119
|
-
},
|
|
120
|
-
}}
|
|
121
|
-
>
|
|
122
|
-
Analyze Package
|
|
123
|
-
</Button>
|
|
124
|
-
<Menu
|
|
125
|
-
id="basic-menu"
|
|
126
|
-
anchorEl={anchorEl}
|
|
127
|
-
open={open}
|
|
128
|
-
onClose={handleMenuClose}
|
|
129
|
-
MenuListProps={{
|
|
130
|
-
"aria-labelledby": "basic-button",
|
|
131
|
-
sx: { py: 0.5 },
|
|
132
|
-
}}
|
|
133
|
-
>
|
|
134
|
-
<MenuItem
|
|
135
|
-
onClick={() => {
|
|
136
|
-
setNewDialogOpen(true);
|
|
137
|
-
handleMenuClose();
|
|
138
|
-
}}
|
|
139
|
-
sx={{ py: 1, px: 2 }}
|
|
140
|
-
disabled={noWorkspaces}
|
|
141
|
-
>
|
|
142
|
-
<ListItemIcon>
|
|
143
|
-
<Add fontSize="small" />
|
|
144
|
-
</ListItemIcon>
|
|
145
|
-
<ListItemText>
|
|
146
|
-
<Typography variant="body2" fontWeight={500}>
|
|
147
|
-
New Workbook
|
|
148
|
-
</Typography>
|
|
149
|
-
{noWorkspaces ? (
|
|
150
|
-
<Typography variant="caption" color="text.secondary">
|
|
151
|
-
No workspaces available
|
|
152
|
-
</Typography>
|
|
153
|
-
) : (
|
|
154
|
-
<Typography variant="caption" color="text.secondary">
|
|
155
|
-
Create a new analysis workbook
|
|
156
|
-
</Typography>
|
|
157
|
-
)}
|
|
158
|
-
</ListItemText>
|
|
159
|
-
</MenuItem>
|
|
160
|
-
<MenuItem
|
|
161
|
-
onClick={() => {
|
|
162
|
-
setOpenDialogOpen(true);
|
|
163
|
-
handleMenuClose();
|
|
164
|
-
}}
|
|
165
|
-
sx={{ py: 1, px: 2 }}
|
|
166
|
-
>
|
|
167
|
-
<ListItemIcon>
|
|
168
|
-
<Launch fontSize="small" />
|
|
169
|
-
</ListItemIcon>
|
|
170
|
-
<ListItemText>
|
|
171
|
-
<Typography variant="body2" fontWeight={500}>
|
|
172
|
-
Open Workbook
|
|
173
|
-
</Typography>
|
|
174
|
-
<Typography variant="caption" color="text.secondary">
|
|
175
|
-
Open an existing workbook
|
|
176
|
-
</Typography>
|
|
177
|
-
</ListItemText>
|
|
178
|
-
</MenuItem>
|
|
179
|
-
</Menu>
|
|
180
|
-
|
|
181
|
-
{/* Create New Workbook Dialog */}
|
|
182
|
-
<Dialog
|
|
183
|
-
open={newDialogOpen}
|
|
184
|
-
onClose={handleNewDialogClose}
|
|
185
|
-
maxWidth="sm"
|
|
186
|
-
fullWidth
|
|
187
|
-
>
|
|
188
|
-
<DialogTitle sx={{ pb: 1, pt: 2, px: 2 }}>
|
|
189
|
-
<Typography
|
|
190
|
-
fontWeight={600}
|
|
191
|
-
sx={{ fontSize: "1.5rem", mb: 0.5 }}
|
|
192
|
-
>
|
|
193
|
-
Create New Workbook
|
|
194
|
-
</Typography>
|
|
195
|
-
<Typography variant="body2" color="text.secondary">
|
|
196
|
-
Start a new analysis workbook to explore your data
|
|
197
|
-
</Typography>
|
|
198
|
-
</DialogTitle>
|
|
199
|
-
<DialogContent sx={{ px: 2, pb: 2 }}>
|
|
200
|
-
<Stack spacing={2} sx={{ mt: 1 }}>
|
|
201
|
-
{availableWorkspaces.length > 1 ? (
|
|
202
|
-
<FormControl fullWidth size="small">
|
|
203
|
-
<InputLabel>Workspace</InputLabel>
|
|
204
|
-
<Select
|
|
205
|
-
value={selectedWorkspace}
|
|
206
|
-
label="Workspace"
|
|
207
|
-
onChange={(e) =>
|
|
208
|
-
setSelectedWorkspace(e.target.value)
|
|
209
|
-
}
|
|
210
|
-
>
|
|
211
|
-
{availableWorkspaces.map((workspace) => (
|
|
212
|
-
<MenuItem
|
|
213
|
-
key={workspace.name}
|
|
214
|
-
value={workspace.name}
|
|
215
|
-
>
|
|
216
|
-
<Box>
|
|
217
|
-
<Typography
|
|
218
|
-
variant="body2"
|
|
219
|
-
fontWeight={500}
|
|
220
|
-
>
|
|
221
|
-
{workspace.name}
|
|
222
|
-
</Typography>
|
|
223
|
-
<Typography
|
|
224
|
-
variant="caption"
|
|
225
|
-
color="text.secondary"
|
|
226
|
-
>
|
|
227
|
-
{workspace.description}
|
|
228
|
-
</Typography>
|
|
229
|
-
</Box>
|
|
230
|
-
</MenuItem>
|
|
231
|
-
))}
|
|
232
|
-
</Select>
|
|
233
|
-
</FormControl>
|
|
234
|
-
) : availableWorkspaces.length === 1 ? (
|
|
235
|
-
<Box
|
|
236
|
-
sx={(theme) => ({
|
|
237
|
-
p: 2,
|
|
238
|
-
border: 1,
|
|
239
|
-
borderColor: "divider",
|
|
240
|
-
borderRadius: 1,
|
|
241
|
-
backgroundColor:
|
|
242
|
-
theme.palette.mode === "dark"
|
|
243
|
-
? "rgba(255, 255, 255, 0.04)"
|
|
244
|
-
: "grey.50",
|
|
245
|
-
})}
|
|
246
|
-
>
|
|
247
|
-
<Typography
|
|
248
|
-
variant="body2"
|
|
249
|
-
fontWeight={500}
|
|
250
|
-
gutterBottom
|
|
251
|
-
>
|
|
252
|
-
Workspace: {availableWorkspaces[0].name}
|
|
253
|
-
</Typography>
|
|
254
|
-
<Typography variant="caption" color="text.secondary">
|
|
255
|
-
{availableWorkspaces[0].description}
|
|
256
|
-
</Typography>
|
|
257
|
-
</Box>
|
|
258
|
-
) : null}
|
|
259
|
-
<FormControl fullWidth>
|
|
260
|
-
<TextField
|
|
261
|
-
label="Workbook Name"
|
|
262
|
-
value={workbookName}
|
|
263
|
-
onChange={(e) => setWorkbookName(e.target.value)}
|
|
264
|
-
placeholder="Enter workbook name..."
|
|
265
|
-
fullWidth
|
|
266
|
-
autoFocus
|
|
267
|
-
size="small"
|
|
268
|
-
/>
|
|
269
|
-
</FormControl>
|
|
270
|
-
<Stack direction="row" spacing={1} justifyContent="flex-end">
|
|
271
|
-
<Button
|
|
272
|
-
onClick={handleNewDialogClose}
|
|
273
|
-
variant="outlined"
|
|
274
|
-
size="small"
|
|
275
|
-
>
|
|
276
|
-
Cancel
|
|
277
|
-
</Button>
|
|
278
|
-
<Button
|
|
279
|
-
onClick={(event) => createWorkbookClick(event)}
|
|
280
|
-
variant="contained"
|
|
281
|
-
disabled={
|
|
282
|
-
!workbookName.trim() ||
|
|
283
|
-
(availableWorkspaces.length > 1 &&
|
|
284
|
-
!selectedWorkspace)
|
|
285
|
-
}
|
|
286
|
-
size="small"
|
|
287
|
-
>
|
|
288
|
-
Create Workbook
|
|
289
|
-
</Button>
|
|
290
|
-
</Stack>
|
|
291
|
-
</Stack>
|
|
292
|
-
</DialogContent>
|
|
293
|
-
</Dialog>
|
|
294
|
-
|
|
295
|
-
{/* Open Workbook Dialog */}
|
|
296
|
-
<Dialog
|
|
297
|
-
open={openDialogOpen}
|
|
298
|
-
onClose={handleOpenDialogClose}
|
|
299
|
-
maxWidth="md"
|
|
300
|
-
fullWidth
|
|
301
|
-
>
|
|
302
|
-
<DialogTitle sx={{ pb: 1, pt: 2, px: 2 }}>
|
|
303
|
-
<Typography
|
|
304
|
-
fontWeight={600}
|
|
305
|
-
sx={{ mb: 0.5, fontSize: "1.5rem" }}
|
|
306
|
-
>
|
|
307
|
-
Open Workbook
|
|
308
|
-
</Typography>
|
|
309
|
-
<Typography variant="body2" color="text.secondary">
|
|
310
|
-
Select an existing workbook to continue your analysis
|
|
311
|
-
</Typography>
|
|
312
|
-
</DialogTitle>
|
|
313
|
-
<DialogContent sx={{ px: 2, pb: 2 }}>
|
|
314
|
-
<WorkbookList onWorkbookClick={handleWorkbookClick} />
|
|
315
|
-
</DialogContent>
|
|
316
|
-
</Dialog>
|
|
317
|
-
</>
|
|
318
|
-
);
|
|
319
|
-
}
|