@malloy-publisher/sdk 0.3.1 → 0.4.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.
Files changed (136) hide show
  1. package/README.md +33 -9
  2. package/dist/{DocumentStorageProvider-tGvodI8f.es.js → DocumentStorage-BiFqO15i.es.js} +7126 -6943
  3. package/dist/DocumentStorage-CMyLifsz.cjs.js +134 -0
  4. package/dist/RenderedResult-CZzE8wv-.cjs.js +115 -0
  5. package/dist/{RenderedResult-mDE-4u8S.es.js → RenderedResult-CvrmYyr5.es.js} +64 -57
  6. package/dist/{ServerProvider-X2Ma0HRs.es.js → ServerProvider-BWOEKg0O.es.js} +1217 -1244
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +52 -52
  9. package/dist/builder/index.es.js +3961 -3960
  10. package/dist/client/api.d.ts +100 -42
  11. package/dist/client/index.cjs.js +1 -1
  12. package/dist/client/index.es.js +1 -1
  13. package/dist/components/AppDialog.d.ts +30 -0
  14. package/dist/components/BackLink.d.ts +32 -0
  15. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  16. package/dist/components/Dashboard/telemetry.d.ts +24 -7
  17. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +12 -10
  18. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +20 -2
  19. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +21 -11
  20. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  21. package/dist/components/DashboardBuilder/spliceDocument.d.ts +10 -1
  22. package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
  23. package/dist/components/DocumentStorage/index.d.ts +1 -0
  24. package/dist/components/ItemRow.d.ts +38 -0
  25. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  26. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  27. package/dist/components/Materializations/Materializations.d.ts +7 -3
  28. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  29. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  30. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  31. package/dist/components/Materializations/index.d.ts +0 -1
  32. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  33. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  34. package/dist/components/Package/index.d.ts +0 -1
  35. package/dist/components/PackageSection.d.ts +23 -0
  36. package/dist/components/buttons.d.ts +53 -0
  37. package/dist/components/index.d.ts +5 -0
  38. package/dist/components/styles.d.ts +49 -40
  39. package/dist/hooks/useCrudMutation.d.ts +42 -0
  40. package/dist/index.cjs.js +22 -26
  41. package/dist/index.d.ts +1 -0
  42. package/dist/index.es.js +17431 -20676
  43. package/dist/telemetry/consoleEvents.d.ts +60 -0
  44. package/dist/utils/sha256.d.ts +2 -0
  45. package/package.json +1 -1
  46. package/src/components/AppDialog.tsx +115 -0
  47. package/src/components/BackLink.tsx +83 -0
  48. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  49. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  50. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  51. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  52. package/src/components/Dashboard/telemetry.ts +24 -5
  53. package/src/components/DashboardBuilder/AddTileDialog.tsx +141 -143
  54. package/src/components/DashboardBuilder/BuilderToolbar.tsx +110 -218
  55. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +5 -11
  56. package/src/components/DashboardBuilder/DashboardBuilder.tsx +202 -171
  57. package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
  58. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  59. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +2 -25
  60. package/src/components/DashboardBuilder/DashboardEditor.tsx +442 -94
  61. package/src/components/DashboardBuilder/DiffDialog.tsx +75 -82
  62. package/src/components/DashboardBuilder/DrillDialog.tsx +144 -156
  63. package/src/components/DashboardBuilder/FilterDialog.tsx +276 -295
  64. package/src/components/DashboardBuilder/FilterStrip.tsx +11 -10
  65. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  66. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  67. package/src/components/DashboardBuilder/spliceDocument.spec.ts +53 -0
  68. package/src/components/DashboardBuilder/spliceDocument.ts +45 -8
  69. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +56 -0
  70. package/src/components/DashboardBuilder/useDashboardEditor.ts +12 -4
  71. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
  72. package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
  73. package/src/components/DocumentStorage/index.ts +1 -0
  74. package/src/components/Environment/About.tsx +14 -28
  75. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  76. package/src/components/Environment/Connections.tsx +125 -205
  77. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  78. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  79. package/src/components/Environment/Environment.tsx +34 -36
  80. package/src/components/Environment/Packages.tsx +63 -128
  81. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  82. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  83. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  84. package/src/components/Home/Home.tsx +101 -214
  85. package/src/components/ItemRow.tsx +165 -0
  86. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  87. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  88. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  89. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  90. package/src/components/Materializations/Materializations.tsx +137 -140
  91. package/src/components/Materializations/ScopeButton.tsx +85 -0
  92. package/src/components/Materializations/SectionLabel.tsx +7 -4
  93. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  94. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  95. package/src/components/Materializations/cron.spec.ts +113 -0
  96. package/src/components/Materializations/index.ts +0 -1
  97. package/src/components/Materializations/utils.spec.ts +182 -0
  98. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  99. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  100. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  101. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  102. package/src/components/Package/Package.tsx +184 -238
  103. package/src/components/Package/index.ts +0 -1
  104. package/src/components/PackageSection.tsx +85 -0
  105. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  106. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  107. package/src/components/ResultsDialog.tsx +8 -32
  108. package/src/components/buttons.tsx +114 -0
  109. package/src/components/designSystem.spec.tsx +316 -0
  110. package/src/components/given/paramCodec.spec.ts +1 -1
  111. package/src/components/index.ts +10 -0
  112. package/src/components/styles.ts +49 -85
  113. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  114. package/src/hooks/useCrudMutation.tsx +85 -0
  115. package/src/index.ts +9 -0
  116. package/src/telemetry/consoleEvents.spec.ts +130 -0
  117. package/src/telemetry/consoleEvents.ts +124 -0
  118. package/src/theme/defaults.ts +34 -23
  119. package/src/theme/resolveTheme.spec.ts +9 -4
  120. package/src/theme/resolveTheme.ts +12 -8
  121. package/src/utils/sha256.ts +13 -0
  122. package/test/README.md +1 -1
  123. package/test/serverProvider.tsx +5 -2
  124. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +0 -134
  125. package/dist/RenderedResult-CPi6uQWq.cjs.js +0 -115
  126. package/dist/ServerProvider-CH71GsoL.cjs.js +0 -1
  127. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  128. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  129. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  130. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  131. package/dist/components/Package/Models.d.ts +0 -6
  132. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  133. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  134. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  135. package/src/components/Materializations/TriggerChip.tsx +0 -44
  136. package/src/components/Package/Models.tsx +0 -71
@@ -1,18 +1,11 @@
1
1
  // Copyright (c) Credible Data Inc.
2
2
  // SPDX-License-Identifier: MIT
3
3
 
4
- import {
5
- Box,
6
- Button,
7
- Dialog,
8
- DialogActions,
9
- DialogContent,
10
- DialogTitle,
11
- Typography,
12
- } from "@mui/material";
4
+ import { Box, Button } from "@mui/material";
13
5
  import { useMemo } from "react";
14
6
  import { usePublisherTheme } from "../../theme/ThemeContext";
15
7
  import { foldUnchanged, lineDiff } from "./diff";
8
+ import { AppDialog } from "../AppDialog";
16
9
 
17
10
  /**
18
11
  * What a save will do to the file, before it does it.
@@ -43,14 +36,13 @@ export function DiffDialog({
43
36
  const added = lines.filter((l) => l.kind === "add").length;
44
37
  const removed = lines.filter((l) => l.kind === "del").length;
45
38
  return (
46
- <Dialog open={open} onClose={onClose} maxWidth="md" fullWidth>
47
- <DialogTitle sx={{ pb: 0.5 }}>
48
- Review the change to the file
49
- <Typography
50
- component="div"
51
- variant="caption"
52
- sx={{ color: theme.tileTitle, mt: 0.25 }}
53
- >
39
+ <AppDialog
40
+ open={open}
41
+ onClose={onClose}
42
+ maxWidth="md"
43
+ title="Review the change to the file"
44
+ description={
45
+ <>
54
46
  A tile was added or removed, which moves declarations. Lines the
55
47
  builder does not own — comments, other Malloy — are left where
56
48
  they were; check they still read right.{" "}
@@ -60,70 +52,71 @@ export function DiffDialog({
60
52
  >
61
53
  +{added} −{removed}
62
54
  </Box>
63
- </Typography>
64
- </DialogTitle>
65
- <DialogContent dividers sx={{ p: 0 }}>
66
- <Box
67
- component="pre"
68
- aria-label="File changes"
69
- sx={{
70
- m: 0,
71
- px: 2,
72
- py: 1,
73
- fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
74
- fontSize: 12,
75
- lineHeight: 1.6,
76
- overflowX: "auto",
77
- bgcolor: theme.background,
78
- color: theme.foreground,
79
- }}
80
- >
81
- {lines.map((line, index) =>
82
- line.kind === "fold" ? (
83
- <Box
84
- key={index}
85
- component="span"
86
- sx={{ display: "block", opacity: 0.55, py: 0.25 }}
87
- >
88
- {`⋯ ${line.count} unchanged line${line.count === 1 ? "" : "s"}`}
89
- </Box>
90
- ) : (
91
- <Box
92
- key={index}
93
- component="span"
94
- sx={{
95
- display: "block",
96
- mx: -2,
97
- px: 2,
98
- whiteSpace: "pre",
99
- bgcolor:
100
- line.kind === "add"
101
- ? "rgba(46, 125, 91, 0.16)"
102
- : line.kind === "del"
103
- ? "rgba(168, 41, 31, 0.14)"
104
- : "transparent",
105
- textDecoration:
106
- line.kind === "del" ? "line-through" : "none",
107
- opacity: line.kind === "del" ? 0.8 : 1,
108
- }}
109
- >
110
- {line.kind === "add"
111
- ? "+ "
112
- : line.kind === "del"
113
- ? "− "
114
- : " "}
115
- {line.text}
116
- </Box>
117
- ),
118
- )}
119
- </Box>
120
- </DialogContent>
121
- <DialogActions sx={{ px: 3, py: 1.5 }}>
122
- <Button onClick={onClose}>Keep editing</Button>
123
- <Button variant="contained" onClick={onConfirm}>
124
- Save this
125
- </Button>
126
- </DialogActions>
127
- </Dialog>
55
+ </>
56
+ }
57
+ actions={
58
+ <>
59
+ <Button onClick={onClose}>Keep editing</Button>
60
+ <Button variant="contained" onClick={onConfirm}>
61
+ Save this
62
+ </Button>
63
+ </>
64
+ }
65
+ >
66
+ <Box
67
+ component="pre"
68
+ aria-label="File changes"
69
+ sx={{
70
+ m: 0,
71
+ px: 2,
72
+ py: 1,
73
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
74
+ fontSize: 12,
75
+ lineHeight: 1.6,
76
+ overflowX: "auto",
77
+ bgcolor: theme.background,
78
+ color: theme.foreground,
79
+ }}
80
+ >
81
+ {lines.map((line, index) =>
82
+ line.kind === "fold" ? (
83
+ <Box
84
+ key={index}
85
+ component="span"
86
+ sx={{ display: "block", opacity: 0.55, py: 0.25 }}
87
+ >
88
+ {`⋯ ${line.count} unchanged line${line.count === 1 ? "" : "s"}`}
89
+ </Box>
90
+ ) : (
91
+ <Box
92
+ key={index}
93
+ component="span"
94
+ sx={{
95
+ display: "block",
96
+ mx: -2,
97
+ px: 2,
98
+ whiteSpace: "pre",
99
+ bgcolor:
100
+ line.kind === "add"
101
+ ? "rgba(46, 125, 91, 0.16)"
102
+ : line.kind === "del"
103
+ ? "rgba(168, 41, 31, 0.14)"
104
+ : "transparent",
105
+ textDecoration:
106
+ line.kind === "del" ? "line-through" : "none",
107
+ opacity: line.kind === "del" ? 0.8 : 1,
108
+ }}
109
+ >
110
+ {line.kind === "add"
111
+ ? "+ "
112
+ : line.kind === "del"
113
+ ? "− "
114
+ : " "}
115
+ {line.text}
116
+ </Box>
117
+ ),
118
+ )}
119
+ </Box>
120
+ </AppDialog>
128
121
  );
129
122
  }
@@ -5,10 +5,6 @@ import {
5
5
  Box,
6
6
  Button,
7
7
  Checkbox,
8
- Dialog,
9
- DialogActions,
10
- DialogContent,
11
- DialogTitle,
12
8
  ListItemText,
13
9
  MenuItem,
14
10
  Stack,
@@ -17,6 +13,7 @@ import {
17
13
  } from "@mui/material";
18
14
  import { useEffect, useState } from "react";
19
15
  import { usePublisherTheme } from "../../theme/ThemeContext";
16
+ import { AppDialog } from "../AppDialog";
20
17
  import type {
21
18
  DashboardDocument,
22
19
  DashboardDrill,
@@ -120,162 +117,153 @@ export function DrillDialog({
120
117
  };
121
118
 
122
119
  return (
123
- <Dialog open={open} onClose={onClose} maxWidth="sm" fullWidth>
124
- <DialogTitle sx={{ pb: 0.5 }}>
125
- Clickable cells
126
- <Typography
127
- component="div"
128
- variant="caption"
129
- sx={{ color: theme.tileTitle, mt: 0.25 }}
130
- >
131
- A cell in a column that groups by one of these dimensions becomes
132
- a link. Clicking it writes the value into a control — here, or on
133
- the dashboard it opens.
134
- </Typography>
135
- </DialogTitle>
136
- <DialogContent>
137
- <Stack sx={{ gap: 2, pt: 1 }}>
138
- {rows.length === 0 ? (
139
- <Typography variant="body2" sx={{ color: theme.tileTitle }}>
140
- {source ? (
141
- <>
142
- <Box component="code">{source.name}</Box> declares no
143
- dimensions of its own in this file. A drill is a tag
144
- on the dimension&apos;s declaration, so a dimension
145
- the model declares is made clickable in the model; to
146
- make one clickable here, declare it in{" "}
147
- <Box component="code">{source.name}</Box> and group
148
- by it.
149
- </>
150
- ) : (
151
- "This tile's source is not declared in this file."
152
- )}
153
- </Typography>
154
- ) : (
155
- rows.map((row, index) => (
156
- <Box
157
- key={row.name}
158
- sx={{
159
- display: "grid",
160
- gridTemplateColumns: {
161
- xs: "1fr",
162
- sm: "minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr)",
163
- },
164
- gap: 1.5,
165
- alignItems: "start",
166
- }}
167
- >
168
- <Box sx={{ minWidth: 0, pt: 0.75 }}>
169
- <Typography
170
- variant="body2"
171
- sx={{
172
- fontFamily: "ui-monospace, monospace",
173
- fontSize: 13,
174
- }}
175
- >
176
- {row.name}
177
- </Typography>
178
- <Typography
179
- variant="caption"
180
- sx={{
181
- color: theme.tileTitle,
182
- display: "block",
183
- overflow: "hidden",
184
- textOverflow: "ellipsis",
185
- whiteSpace: "nowrap",
186
- }}
187
- title={row.expression}
188
- >
189
- is {row.expression}
190
- </Typography>
191
- </Box>
192
- <TextField
193
- select
194
- size="small"
195
- label="Clicks go to"
196
- value={row.to}
197
- inputProps={{
198
- "aria-label": `Where ${row.name} goes`,
199
- }}
200
- SelectProps={{
201
- multiple: true,
202
- renderValue: (selected) =>
203
- (selected as string[]).length === 0
204
- ? "Not clickable"
205
- : (selected as string[])
206
- .map(labelFor)
207
- .join(", "),
208
- displayEmpty: true,
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,
209
175
  }}
210
- InputLabelProps={{ shrink: true }}
211
- onChange={(event) =>
212
- patch(index, (r) => {
213
- const value = event.target.value as unknown;
214
- r.to = Array.isArray(value)
215
- ? (value as string[])
216
- : String(value).split(",").filter(Boolean);
217
- })
218
- }
219
176
  >
220
- {destinations.map((destination) => (
221
- <MenuItem key={destination} value={destination}>
222
- <Checkbox
223
- size="small"
224
- checked={row.to.includes(destination)}
225
- sx={{ p: 0, mr: 1 }}
226
- />
227
- <ListItemText
228
- primary={labelFor(destination)}
229
- />
230
- </MenuItem>
231
- ))}
232
- </TextField>
233
- <TextField
234
- select
235
- size="small"
236
- label="Sets the control"
237
- value={row.given}
238
- disabled={row.to.length === 0}
239
- inputProps={{
240
- "aria-label": `Control ${row.name} sets`,
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",
241
187
  }}
242
- SelectProps={{ displayEmpty: true }}
243
- InputLabelProps={{ shrink: true }}
244
- helperText={
245
- row.given === ""
246
- ? `Named ${row.name}, like the dimension`
247
- : undefined
248
- }
249
- onChange={(event) =>
250
- patch(index, (r) => {
251
- r.given = event.target.value;
252
- })
253
- }
188
+ title={row.expression}
254
189
  >
255
- <MenuItem value="">
256
- <em>Same name as the dimension</em>
257
- </MenuItem>
258
- {givenNames.map((name) => (
259
- <MenuItem key={name} value={name}>
260
- {name}
261
- </MenuItem>
262
- ))}
263
- </TextField>
190
+ is {row.expression}
191
+ </Typography>
264
192
  </Box>
265
- ))
266
- )}
267
- </Stack>
268
- </DialogContent>
269
- <DialogActions sx={{ px: 3, py: 1.5 }}>
270
- <Button onClick={onClose}>Cancel</Button>
271
- <Button
272
- variant="contained"
273
- disabled={rows.length === 0}
274
- onClick={apply}
275
- >
276
- Apply
277
- </Button>
278
- </DialogActions>
279
- </Dialog>
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>
280
268
  );
281
269
  }