@malloy-publisher/sdk 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +22 -9
  2. package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
  3. package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
  4. package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
  5. package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
  6. package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +105 -0
  9. package/dist/builder/index.d.ts +2 -0
  10. package/dist/builder/index.es.js +9482 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/api.d.ts +100 -42
  13. package/dist/client/index.cjs.js +1 -1
  14. package/dist/client/index.es.js +1 -1
  15. package/dist/components/AppDialog.d.ts +30 -0
  16. package/dist/components/BackLink.d.ts +32 -0
  17. package/dist/components/Dashboard/Dashboard.d.ts +19 -14
  18. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  19. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  20. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  21. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  22. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  23. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  24. package/dist/components/Dashboard/index.d.ts +2 -0
  25. package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
  26. package/dist/components/Dashboard/telemetry.d.ts +48 -0
  27. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  28. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
  29. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
  30. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
  31. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  32. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  33. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  34. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  36. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  37. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  38. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  39. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  40. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  41. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  42. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  43. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  44. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  45. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  46. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  47. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  48. package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
  49. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  50. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  51. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  52. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  53. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  54. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  55. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  56. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
  57. package/dist/components/DocumentStorage/index.d.ts +1 -1
  58. package/dist/components/FloatingIconButton.d.ts +16 -0
  59. package/dist/components/ItemRow.d.ts +38 -0
  60. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  61. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  62. package/dist/components/Materializations/Materializations.d.ts +7 -3
  63. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  64. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  65. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  66. package/dist/components/Materializations/index.d.ts +0 -1
  67. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  68. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  69. package/dist/components/Package/index.d.ts +0 -1
  70. package/dist/components/PackageSection.d.ts +23 -0
  71. package/dist/components/Prose.d.ts +46 -0
  72. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  73. package/dist/components/RenderedResult/index.d.ts +1 -0
  74. package/dist/components/buttons.d.ts +53 -0
  75. package/dist/components/drill/index.d.ts +1 -1
  76. package/dist/components/drill/resolveDrill.d.ts +22 -0
  77. package/dist/components/drill/useDrill.d.ts +11 -2
  78. package/dist/components/index.d.ts +6 -0
  79. package/dist/components/styles.d.ts +49 -44
  80. package/dist/hooks/index.d.ts +2 -0
  81. package/dist/hooks/useCrudMutation.d.ts +42 -0
  82. package/dist/hooks/useDocumentControls.d.ts +70 -0
  83. package/dist/hooks/useQueryResult.d.ts +40 -0
  84. package/dist/index.cjs.js +22 -273
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.es.js +16888 -44451
  87. package/dist/telemetry/consoleEvents.d.ts +60 -0
  88. package/dist/utils/malloyLiteral.d.ts +11 -0
  89. package/dist/utils/sha256.d.ts +2 -0
  90. package/package.json +24 -9
  91. package/src/builder-entry.ts +55 -0
  92. package/src/components/AppDialog.tsx +115 -0
  93. package/src/components/BackLink.tsx +83 -0
  94. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  95. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  96. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  97. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  98. package/src/components/Dashboard/Dashboard.tsx +165 -175
  99. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  100. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  101. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  102. package/src/components/Dashboard/DashboardTile.tsx +66 -123
  103. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  104. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  105. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  106. package/src/components/Dashboard/TileCard.tsx +120 -0
  107. package/src/components/Dashboard/index.ts +2 -0
  108. package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
  109. package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
  110. package/src/components/Dashboard/telemetry.ts +51 -0
  111. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  112. package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
  113. package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
  114. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
  115. package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
  116. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  117. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
  118. package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
  119. package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
  120. package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
  121. package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
  122. package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
  123. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  124. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  125. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  126. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  127. package/src/components/DashboardBuilder/catalog.ts +225 -0
  128. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  129. package/src/components/DashboardBuilder/controls.ts +398 -0
  130. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  131. package/src/components/DashboardBuilder/diff.ts +93 -0
  132. package/src/components/DashboardBuilder/document.ts +209 -0
  133. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  134. package/src/components/DashboardBuilder/layout.ts +143 -0
  135. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  136. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  137. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  138. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  139. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  140. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  141. package/src/components/DashboardBuilder/preview.ts +172 -0
  142. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  143. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  144. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  145. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
  146. package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
  147. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  148. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  149. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
  150. package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
  151. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  152. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  153. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  154. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  155. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  156. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  157. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  158. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  159. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
  160. package/src/components/DocumentStorage/index.ts +1 -0
  161. package/src/components/Environment/About.tsx +16 -62
  162. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  163. package/src/components/Environment/Connections.tsx +125 -205
  164. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  165. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  166. package/src/components/Environment/Environment.tsx +34 -36
  167. package/src/components/Environment/Packages.tsx +63 -128
  168. package/src/components/FloatingIconButton.tsx +41 -0
  169. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  170. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  171. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  172. package/src/components/Home/Home.tsx +101 -214
  173. package/src/components/ItemRow.tsx +165 -0
  174. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  175. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  176. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  177. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  178. package/src/components/Materializations/Materializations.tsx +137 -140
  179. package/src/components/Materializations/ScopeButton.tsx +85 -0
  180. package/src/components/Materializations/SectionLabel.tsx +7 -4
  181. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  182. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  183. package/src/components/Materializations/cron.spec.ts +113 -0
  184. package/src/components/Materializations/index.ts +0 -1
  185. package/src/components/Materializations/utils.spec.ts +182 -0
  186. package/src/components/Model/Model.tsx +6 -23
  187. package/src/components/Model/ModelCell.tsx +33 -72
  188. package/src/components/Notebook/Notebook.tsx +25 -88
  189. package/src/components/Notebook/NotebookCell.tsx +35 -183
  190. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  191. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  192. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  193. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  194. package/src/components/Package/Package.tsx +179 -238
  195. package/src/components/Package/index.ts +0 -1
  196. package/src/components/PackageSection.tsx +85 -0
  197. package/src/components/Prose.spec.tsx +85 -0
  198. package/src/components/Prose.tsx +179 -0
  199. package/src/components/QueryResult/QueryResult.tsx +15 -43
  200. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  201. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  202. package/src/components/RenderedResult/ResultContainer.tsx +4 -12
  203. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  204. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  205. package/src/components/RenderedResult/index.ts +1 -0
  206. package/src/components/ResultsDialog.tsx +8 -32
  207. package/src/components/buttons.tsx +114 -0
  208. package/src/components/designSystem.spec.tsx +316 -0
  209. package/src/components/drill/index.ts +1 -0
  210. package/src/components/drill/resolveDrill.ts +22 -1
  211. package/src/components/drill/useDrill.spec.tsx +94 -0
  212. package/src/components/drill/useDrill.tsx +52 -12
  213. package/src/components/given/GivensPanel.tsx +1 -1
  214. package/src/components/given/paramCodec.spec.ts +1 -1
  215. package/src/components/index.ts +16 -0
  216. package/src/components/styles.ts +49 -122
  217. package/src/hooks/index.ts +13 -0
  218. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  219. package/src/hooks/useCrudMutation.tsx +85 -0
  220. package/src/hooks/useDocumentControls.ts +170 -0
  221. package/src/hooks/useQueryResult.ts +82 -0
  222. package/src/index.ts +9 -0
  223. package/src/telemetry/consoleEvents.spec.ts +130 -0
  224. package/src/telemetry/consoleEvents.ts +124 -0
  225. package/src/theme/defaults.ts +34 -23
  226. package/src/theme/resolveTheme.spec.ts +9 -4
  227. package/src/theme/resolveTheme.ts +12 -8
  228. package/src/utils/malloyLiteral.spec.ts +43 -0
  229. package/src/utils/malloyLiteral.ts +76 -0
  230. package/src/utils/sha256.ts +13 -0
  231. package/test/README.md +1 -1
  232. package/test/serverProvider.tsx +5 -2
  233. package/vite.config.ts +5 -0
  234. package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
  235. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  236. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  237. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  238. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  239. package/dist/components/Package/Models.d.ts +0 -6
  240. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  241. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  242. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  243. package/src/components/Materializations/TriggerChip.tsx +0 -44
  244. package/src/components/Package/Models.tsx +0 -71
@@ -0,0 +1,269 @@
1
+ // Copyright (c) Credible Data Inc.
2
+ // SPDX-License-Identifier: MIT
3
+
4
+ import {
5
+ Box,
6
+ Button,
7
+ Checkbox,
8
+ ListItemText,
9
+ MenuItem,
10
+ Stack,
11
+ TextField,
12
+ Typography,
13
+ } from "@mui/material";
14
+ import { useEffect, useState } from "react";
15
+ import { usePublisherTheme } from "../../theme/ThemeContext";
16
+ import { AppDialog } from "../AppDialog";
17
+ import type {
18
+ DashboardDocument,
19
+ DashboardDrill,
20
+ DashboardSource,
21
+ } from "./document";
22
+
23
+ /**
24
+ * Which cells click, and where a click goes.
25
+ *
26
+ * The format's drill is a `# drill { to=… given=… }` tag on a dimension, and
27
+ * the builder writes tags on declarations this file owns — so what is offered
28
+ * here is every dimension the tile's source declares IN THIS FILE, each with
29
+ * its destinations (this dashboard, other dashboards in the package) and the
30
+ * control the clicked value is written into. A dimension the model declares
31
+ * is tagged in the model, and the dialog says so rather than offering a tag it
32
+ * cannot write.
33
+ *
34
+ * Committed once, on Apply, as one history entry.
35
+ */
36
+ const SELF = "self";
37
+
38
+ export interface DrillDialogProps {
39
+ open: boolean;
40
+ document: DashboardDocument;
41
+ /** The tile's source: the extension whose dimensions are offered. */
42
+ source: DashboardSource | undefined;
43
+ /** The controls a click can write into: the dashboard's and the model's. */
44
+ givenNames: string[];
45
+ /** Other dashboards in the package, by slug, as `to=` destinations. */
46
+ dashboards: string[];
47
+ onClose: () => void;
48
+ /** Every drill on `source`, replacing what the document had for it. */
49
+ onApply: (drills: DashboardDrill[]) => void;
50
+ }
51
+
52
+ interface Row {
53
+ name: string;
54
+ expression: string;
55
+ to: string[];
56
+ given: string;
57
+ }
58
+
59
+ export function DrillDialog({
60
+ open,
61
+ document,
62
+ source,
63
+ givenNames,
64
+ dashboards,
65
+ onClose,
66
+ onApply,
67
+ }: DrillDialogProps) {
68
+ const { theme } = usePublisherTheme();
69
+ const [rows, setRows] = useState<Row[]>([]);
70
+
71
+ useEffect(() => {
72
+ if (!open || !source) return;
73
+ const declared = (document.drills ?? []).filter(
74
+ (d) => d.source === source.name,
75
+ );
76
+ setRows(
77
+ (source.dimensions ?? []).map((dimension) => {
78
+ const drill = declared.find((d) => d.name === dimension.name);
79
+ return {
80
+ name: dimension.name,
81
+ expression: dimension.expression,
82
+ to: drill?.to ?? [],
83
+ given: drill?.given ?? "",
84
+ };
85
+ }),
86
+ );
87
+ }, [open, source, document]);
88
+
89
+ const patch = (index: number, change: (row: Row) => void) =>
90
+ setRows((previous) =>
91
+ previous.map((row, i) => {
92
+ if (i !== index) return row;
93
+ const next = { ...row };
94
+ change(next);
95
+ return next;
96
+ }),
97
+ );
98
+
99
+ const destinations = [SELF, ...dashboards.filter((d) => d !== SELF)];
100
+ const labelFor = (destination: string) =>
101
+ destination === SELF ? "This dashboard" : destination;
102
+
103
+ const apply = () => {
104
+ if (!source) return;
105
+ onApply(
106
+ rows
107
+ .filter((row) => row.to.length > 0)
108
+ .map((row) => ({
109
+ source: source.name,
110
+ name: row.name,
111
+ expression: row.expression,
112
+ to: row.to,
113
+ ...(row.given ? { given: row.given } : {}),
114
+ })),
115
+ );
116
+ onClose();
117
+ };
118
+
119
+ return (
120
+ <AppDialog
121
+ open={open}
122
+ onClose={onClose}
123
+ title="Clickable cells"
124
+ description="A cell in a column that groups by one of these dimensions becomes a link. Clicking it writes the value into a control — here, or on the dashboard it opens."
125
+ actions={
126
+ <>
127
+ <Button onClick={onClose}>Cancel</Button>
128
+ <Button
129
+ variant="contained"
130
+ onClick={apply}
131
+ disabled={rows.length === 0}
132
+ >
133
+ Apply
134
+ </Button>
135
+ </>
136
+ }
137
+ >
138
+ <Stack sx={{ gap: 2, pt: 1 }}>
139
+ {rows.length === 0 ? (
140
+ <Typography variant="body2" sx={{ color: theme.tileTitle }}>
141
+ {source ? (
142
+ <>
143
+ <Box component="code">{source.name}</Box> declares no
144
+ dimensions of its own in this file. A drill is a tag on
145
+ the dimension&apos;s declaration, so a dimension the
146
+ model declares is made clickable in the model; to make
147
+ one clickable here, declare it in{" "}
148
+ <Box component="code">{source.name}</Box> and group by
149
+ it.
150
+ </>
151
+ ) : (
152
+ "This tile's source is not declared in this file."
153
+ )}
154
+ </Typography>
155
+ ) : (
156
+ rows.map((row, index) => (
157
+ <Box
158
+ key={row.name}
159
+ sx={{
160
+ display: "grid",
161
+ gridTemplateColumns: {
162
+ xs: "1fr",
163
+ sm: "minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)",
164
+ },
165
+ gap: 1.5,
166
+ alignItems: "start",
167
+ }}
168
+ >
169
+ <Box sx={{ minWidth: 0, pt: 0.75 }}>
170
+ <Typography
171
+ variant="body2"
172
+ sx={{
173
+ fontFamily: "ui-monospace, monospace",
174
+ fontSize: 13,
175
+ }}
176
+ >
177
+ {row.name}
178
+ </Typography>
179
+ <Typography
180
+ variant="caption"
181
+ sx={{
182
+ color: theme.tileTitle,
183
+ display: "block",
184
+ overflow: "hidden",
185
+ textOverflow: "ellipsis",
186
+ whiteSpace: "nowrap",
187
+ }}
188
+ title={row.expression}
189
+ >
190
+ is {row.expression}
191
+ </Typography>
192
+ </Box>
193
+ <TextField
194
+ select
195
+ size="small"
196
+ label="Clicks go to"
197
+ value={row.to}
198
+ inputProps={{
199
+ "aria-label": `Where ${row.name} goes`,
200
+ }}
201
+ SelectProps={{
202
+ multiple: true,
203
+ renderValue: (selected) =>
204
+ (selected as string[]).length === 0
205
+ ? "Not clickable"
206
+ : (selected as string[])
207
+ .map(labelFor)
208
+ .join(", "),
209
+ displayEmpty: true,
210
+ }}
211
+ InputLabelProps={{ shrink: true }}
212
+ onChange={(event) =>
213
+ patch(index, (r) => {
214
+ const value = event.target.value as unknown;
215
+ r.to = Array.isArray(value)
216
+ ? (value as string[])
217
+ : String(value).split(",").filter(Boolean);
218
+ })
219
+ }
220
+ >
221
+ {destinations.map((destination) => (
222
+ <MenuItem key={destination} value={destination}>
223
+ <Checkbox
224
+ size="small"
225
+ checked={row.to.includes(destination)}
226
+ sx={{ p: 0, mr: 1 }}
227
+ />
228
+ <ListItemText primary={labelFor(destination)} />
229
+ </MenuItem>
230
+ ))}
231
+ </TextField>
232
+ <TextField
233
+ select
234
+ size="small"
235
+ label="Sets the control"
236
+ value={row.given}
237
+ disabled={row.to.length === 0}
238
+ inputProps={{
239
+ "aria-label": `Control ${row.name} sets`,
240
+ }}
241
+ SelectProps={{ displayEmpty: true }}
242
+ InputLabelProps={{ shrink: true }}
243
+ helperText={
244
+ row.given === ""
245
+ ? `Named ${row.name}, like the dimension`
246
+ : undefined
247
+ }
248
+ onChange={(event) =>
249
+ patch(index, (r) => {
250
+ r.given = event.target.value;
251
+ })
252
+ }
253
+ >
254
+ <MenuItem value="">
255
+ <em>Same name as the dimension</em>
256
+ </MenuItem>
257
+ {givenNames.map((name) => (
258
+ <MenuItem key={name} value={name}>
259
+ {name}
260
+ </MenuItem>
261
+ ))}
262
+ </TextField>
263
+ </Box>
264
+ ))
265
+ )}
266
+ </Stack>
267
+ </AppDialog>
268
+ );
269
+ }