@backmatter/studio 0.0.21 → 0.0.22
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/chunks/{UiKitApp-CMMcsaX4.js → UiKitApp-CgGyJiC4.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-DW0sLdpJ.js → WorkspaceRoutes-CzCBnhNt.js} +18900 -18798
- package/dist/chunks/{dashboard-By0P4Yny.js → dashboard-w-mlsGky.js} +2 -2
- package/dist/chunks/{index-DTPUqaHE.js → index-_XfFuFSU.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +2 -2
- package/dist/studio.css +28 -0
- package/package.json +1 -1
- package/src/fields/LinkFieldInput.tsx +182 -33
- package/src/pages/MediaFieldInput.tsx +1 -1
- package/src/pages/MediaGalleryPage.tsx +36 -3
- package/src/ui/Input.tsx +134 -35
package/src/ui/Input.tsx
CHANGED
|
@@ -13,7 +13,47 @@ export function Input(props: Props) {
|
|
|
13
13
|
return <BaseInput {...stylex.props(styles.input, styles.inputFocus)} {...props} />;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export type SelectOption = {
|
|
16
|
+
export type SelectOption = {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
/** A muted second line under the label, such as a route. Searched too. */
|
|
20
|
+
description?: string;
|
|
21
|
+
/** Options sharing a group sit under its heading. Options with none come first. */
|
|
22
|
+
group?: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type OptionGroup = { value: string; items: SelectOption[] };
|
|
27
|
+
|
|
28
|
+
/** Groups in order of first appearance, with ungrouped options first. */
|
|
29
|
+
function groupOptions(options: SelectOption[]): OptionGroup[] {
|
|
30
|
+
const groups = new Map<string, SelectOption[]>();
|
|
31
|
+
for (const option of options) {
|
|
32
|
+
const key = option.group ?? "";
|
|
33
|
+
const list = groups.get(key);
|
|
34
|
+
if (list) list.push(option);
|
|
35
|
+
else groups.set(key, [option]);
|
|
36
|
+
}
|
|
37
|
+
const ungrouped = groups.get("");
|
|
38
|
+
groups.delete("");
|
|
39
|
+
const ordered = [...groups.entries()].map(([value, items]) => ({ value, items }));
|
|
40
|
+
return ungrouped ? [{ value: "", items: ungrouped }, ...ordered] : ordered;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function OptionText({ option }: { option: SelectOption }) {
|
|
44
|
+
return (
|
|
45
|
+
<span {...stylex.props(styles.optionText)}>
|
|
46
|
+
<span data-select-option-label="" {...stylex.props(styles.optionLabel)}>
|
|
47
|
+
{option.label}
|
|
48
|
+
</span>
|
|
49
|
+
{option.description ? (
|
|
50
|
+
<span data-select-option-description="" {...stylex.props(styles.optionDescription)}>
|
|
51
|
+
{option.description}
|
|
52
|
+
</span>
|
|
53
|
+
) : null}
|
|
54
|
+
</span>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
17
57
|
|
|
18
58
|
type SelectProps = {
|
|
19
59
|
options: SelectOption[];
|
|
@@ -41,7 +81,11 @@ export function Select(props: SelectProps) {
|
|
|
41
81
|
function matchesQuery(option: SelectOption, query: string) {
|
|
42
82
|
const q = query.trim().toLowerCase();
|
|
43
83
|
if (!q) return true;
|
|
44
|
-
return
|
|
84
|
+
return (
|
|
85
|
+
option.label.toLowerCase().includes(q) ||
|
|
86
|
+
option.value.toLowerCase().includes(q) ||
|
|
87
|
+
(option.description?.toLowerCase().includes(q) ?? false)
|
|
88
|
+
);
|
|
45
89
|
}
|
|
46
90
|
|
|
47
91
|
function FilterSelect({
|
|
@@ -58,6 +102,30 @@ function FilterSelect({
|
|
|
58
102
|
}: SelectProps) {
|
|
59
103
|
const selected = options.find((opt) => opt.value === value) ?? null;
|
|
60
104
|
const [open, setOpen] = useState(false);
|
|
105
|
+
const grouped = options.some((opt) => opt.group !== undefined);
|
|
106
|
+
const renderItem = (opt: SelectOption) => (
|
|
107
|
+
<Combobox.Item
|
|
108
|
+
key={opt.value}
|
|
109
|
+
value={opt}
|
|
110
|
+
disabled={opt.disabled}
|
|
111
|
+
data-no-ring=""
|
|
112
|
+
className={(state) =>
|
|
113
|
+
cx(
|
|
114
|
+
popup.item,
|
|
115
|
+
state.highlighted && popup.itemHighlighted,
|
|
116
|
+
state.selected && popup.itemSelected,
|
|
117
|
+
state.disabled && popup.itemDisabled,
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
>
|
|
121
|
+
<span {...stylex.props(popup.itemIndicator)}>
|
|
122
|
+
<Combobox.ItemIndicator>
|
|
123
|
+
<CheckIcon />
|
|
124
|
+
</Combobox.ItemIndicator>
|
|
125
|
+
</span>
|
|
126
|
+
<OptionText option={opt} />
|
|
127
|
+
</Combobox.Item>
|
|
128
|
+
);
|
|
61
129
|
const clear = (event: { preventDefault: () => void; stopPropagation: () => void }) => {
|
|
62
130
|
event.preventDefault();
|
|
63
131
|
event.stopPropagation();
|
|
@@ -65,7 +133,7 @@ function FilterSelect({
|
|
|
65
133
|
};
|
|
66
134
|
return (
|
|
67
135
|
<Combobox.Root
|
|
68
|
-
items={options}
|
|
136
|
+
items={grouped ? groupOptions(options) : options}
|
|
69
137
|
value={selected}
|
|
70
138
|
name={name}
|
|
71
139
|
disabled={disabled}
|
|
@@ -79,6 +147,9 @@ function FilterSelect({
|
|
|
79
147
|
{chip && selected ? (
|
|
80
148
|
<span {...stylex.props(styles.chip)}>
|
|
81
149
|
<span {...stylex.props(styles.chipLabel)}>{selected.label}</span>
|
|
150
|
+
{selected.description ? (
|
|
151
|
+
<span {...stylex.props(styles.chipDescription)}>{selected.description}</span>
|
|
152
|
+
) : null}
|
|
82
153
|
</span>
|
|
83
154
|
) : (
|
|
84
155
|
<Combobox.Value>
|
|
@@ -149,37 +220,18 @@ function FilterSelect({
|
|
|
149
220
|
/>
|
|
150
221
|
<Combobox.Empty className={cx(popup.empty)}>No matches</Combobox.Empty>
|
|
151
222
|
<Combobox.List>
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
>
|
|
167
|
-
<span {...stylex.props(popup.itemIndicator)}>
|
|
168
|
-
<Combobox.ItemIndicator>
|
|
169
|
-
<svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
170
|
-
<path
|
|
171
|
-
d="M3.5 8.5 6.5 11.5 12.5 4.5"
|
|
172
|
-
stroke="currentColor"
|
|
173
|
-
strokeWidth="1.5"
|
|
174
|
-
strokeLinecap="round"
|
|
175
|
-
strokeLinejoin="round"
|
|
176
|
-
/>
|
|
177
|
-
</svg>
|
|
178
|
-
</Combobox.ItemIndicator>
|
|
179
|
-
</span>
|
|
180
|
-
{opt.label}
|
|
181
|
-
</Combobox.Item>
|
|
182
|
-
)}
|
|
223
|
+
{grouped
|
|
224
|
+
? (group: OptionGroup) => (
|
|
225
|
+
<Combobox.Group key={group.value} items={group.items}>
|
|
226
|
+
{group.value ? (
|
|
227
|
+
<Combobox.GroupLabel data-select-group-label="" className={cx(popup.groupLabel)}>
|
|
228
|
+
{group.value}
|
|
229
|
+
</Combobox.GroupLabel>
|
|
230
|
+
) : null}
|
|
231
|
+
<Combobox.Collection>{renderItem}</Combobox.Collection>
|
|
232
|
+
</Combobox.Group>
|
|
233
|
+
)
|
|
234
|
+
: renderItem}
|
|
183
235
|
</Combobox.List>
|
|
184
236
|
</Combobox.Popup>
|
|
185
237
|
</Combobox.Positioner>
|
|
@@ -300,7 +352,9 @@ function ListSelect({
|
|
|
300
352
|
</svg>
|
|
301
353
|
</BaseSelect.ItemIndicator>
|
|
302
354
|
</span>
|
|
303
|
-
<BaseSelect.ItemText>
|
|
355
|
+
<BaseSelect.ItemText>
|
|
356
|
+
<OptionText option={opt} />
|
|
357
|
+
</BaseSelect.ItemText>
|
|
304
358
|
</BaseSelect.Item>
|
|
305
359
|
))}
|
|
306
360
|
</BaseSelect.List>
|
|
@@ -311,6 +365,20 @@ function ListSelect({
|
|
|
311
365
|
);
|
|
312
366
|
}
|
|
313
367
|
|
|
368
|
+
function CheckIcon() {
|
|
369
|
+
return (
|
|
370
|
+
<svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
371
|
+
<path
|
|
372
|
+
d="M3.5 8.5 6.5 11.5 12.5 4.5"
|
|
373
|
+
stroke="currentColor"
|
|
374
|
+
strokeWidth="1.5"
|
|
375
|
+
strokeLinecap="round"
|
|
376
|
+
strokeLinejoin="round"
|
|
377
|
+
/>
|
|
378
|
+
</svg>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
|
|
314
382
|
export function Textarea({
|
|
315
383
|
mono,
|
|
316
384
|
...props
|
|
@@ -392,6 +460,15 @@ const styles = stylex.create({
|
|
|
392
460
|
textOverflow: "ellipsis",
|
|
393
461
|
whiteSpace: "nowrap",
|
|
394
462
|
},
|
|
463
|
+
chipDescription: {
|
|
464
|
+
minWidth: 0,
|
|
465
|
+
// The route gives up its room before the title does.
|
|
466
|
+
flexShrink: 3,
|
|
467
|
+
overflow: "hidden",
|
|
468
|
+
textOverflow: "ellipsis",
|
|
469
|
+
whiteSpace: "nowrap",
|
|
470
|
+
color: colors.textMuted,
|
|
471
|
+
},
|
|
395
472
|
selectActions: {
|
|
396
473
|
display: "inline-flex",
|
|
397
474
|
alignItems: "center",
|
|
@@ -422,6 +499,28 @@ const styles = stylex.create({
|
|
|
422
499
|
},
|
|
423
500
|
selectPopup: {
|
|
424
501
|
minWidth: "var(--anchor-width)",
|
|
502
|
+
// Long labels truncate instead of stretching the menu across the window.
|
|
503
|
+
maxWidth: "min(max(var(--anchor-width), 24rem), var(--available-width))",
|
|
504
|
+
maxHeight: "min(var(--available-height), 24rem)",
|
|
505
|
+
},
|
|
506
|
+
optionText: {
|
|
507
|
+
flex: 1,
|
|
508
|
+
display: "flex",
|
|
509
|
+
flexDirection: "column",
|
|
510
|
+
minWidth: 0,
|
|
511
|
+
gap: 1,
|
|
512
|
+
},
|
|
513
|
+
optionLabel: {
|
|
514
|
+
overflow: "hidden",
|
|
515
|
+
textOverflow: "ellipsis",
|
|
516
|
+
whiteSpace: "nowrap",
|
|
517
|
+
},
|
|
518
|
+
optionDescription: {
|
|
519
|
+
overflow: "hidden",
|
|
520
|
+
textOverflow: "ellipsis",
|
|
521
|
+
whiteSpace: "nowrap",
|
|
522
|
+
fontSize: type.xs,
|
|
523
|
+
color: colors.textMuted,
|
|
425
524
|
},
|
|
426
525
|
textarea: {
|
|
427
526
|
minHeight: "8rem",
|