@backmatter/studio 0.0.17 → 0.0.19

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 (48) hide show
  1. package/dist/chunks/{UiKitApp-D7vllRQE.js → UiKitApp-B1ANqCac.js} +528 -481
  2. package/dist/chunks/{WorkspaceRoutes-DH1LD-2Q.js → WorkspaceRoutes-BHNGrf-j.js} +24955 -24119
  3. package/dist/chunks/{dashboard-Dsaeud2x.js → dashboard-b-W6dGm5.js} +586 -565
  4. package/dist/chunks/{index-CGMqw2NH.js → index-HYioDjux.js} +104 -104
  5. package/dist/dashboard.js +2 -2
  6. package/dist/index.js +166 -159
  7. package/dist/site-widget.css +25 -6
  8. package/dist/site-widget.js +6925 -6840
  9. package/dist/studio.css +171 -42
  10. package/package.json +2 -2
  11. package/src/api.ts +44 -1
  12. package/src/chat/ChatMessage.tsx +4 -4
  13. package/src/chat/ChatProvider.tsx +6 -0
  14. package/src/chat/chat-helpers.ts +54 -2
  15. package/src/chrome/CommandPalette.tsx +3 -3
  16. package/src/chrome/ContentExplorerSidebar.tsx +421 -74
  17. package/src/chrome/WorkspaceStatusBar.tsx +24 -24
  18. package/src/chrome/commit-error.ts +48 -60
  19. package/src/chrome/commit-failure.tsx +2 -2
  20. package/src/chrome/content-path-tree.ts +4 -0
  21. package/src/chrome/explorer-row-menu.ts +28 -0
  22. package/src/chrome/folder-create-context.ts +14 -0
  23. package/src/chrome/use-publish-check.ts +75 -0
  24. package/src/{pages/code-session-routes.ts → content-routes.ts} +6 -6
  25. package/src/fields/FieldControl.tsx +198 -64
  26. package/src/fields/LinkFieldInput.tsx +315 -0
  27. package/src/fields/choose-field-input.ts +5 -0
  28. package/src/fields/link-targets.ts +60 -0
  29. package/src/host-path.ts +13 -0
  30. package/src/pages/CodeSessionPage.tsx +6 -241
  31. package/src/pages/DocEditorPage.tsx +121 -178
  32. package/src/pages/EmbedPublishPage.tsx +13 -5
  33. package/src/pages/GithubConnectPage.tsx +1 -1
  34. package/src/pages/LoginPage.tsx +67 -5
  35. package/src/pages/MediaFieldInput.tsx +712 -37
  36. package/src/pages/MediaGalleryPage.tsx +69 -5
  37. package/src/pages/PreviewAddress.tsx +293 -0
  38. package/src/pages/WorkspaceHomePage.tsx +1 -1
  39. package/src/pages/code-session-boot.ts +0 -12
  40. package/src/pages/media-selection.ts +79 -0
  41. package/src/pages/ui-kit/colors.tsx +2 -0
  42. package/src/pages/ui-kit/fields.tsx +60 -0
  43. package/src/styles/themes.ts +2 -0
  44. package/src/styles/tokens.stylex.ts +1 -0
  45. package/src/ui/Button.tsx +14 -0
  46. package/src/ui/Field.tsx +12 -1
  47. package/src/ui/Input.tsx +191 -97
  48. package/src/ui/popup.ts +13 -6
package/src/ui/Button.tsx CHANGED
@@ -11,6 +11,8 @@ export type ButtonSize = "sm" | "md";
11
11
  type Common = {
12
12
  variant?: ButtonVariant;
13
13
  size?: ButtonSize;
14
+ /** Recede the label. Use for actions that sit beside a title. */
15
+ muted?: boolean;
14
16
  children: React.ReactNode;
15
17
  disabled?: boolean;
16
18
  };
@@ -20,6 +22,7 @@ const hover = "@media (hover: hover)";
20
22
  export function Button({
21
23
  variant = "primary",
22
24
  size = "md",
25
+ muted = false,
23
26
  disabled,
24
27
  children,
25
28
  type = "button",
@@ -39,6 +42,7 @@ export function Button({
39
42
  variant === "secondary" && styles.secondary,
40
43
  variant === "ghost" && styles.ghost,
41
44
  variant === "danger" && styles.danger,
45
+ muted && styles.muted,
42
46
  disabled && styles.disabled,
43
47
  )}
44
48
  {...rest}
@@ -51,6 +55,7 @@ export function Button({
51
55
  export function ButtonLink({
52
56
  variant = "primary",
53
57
  size = "md",
58
+ muted = false,
54
59
  to,
55
60
  href,
56
61
  children,
@@ -64,6 +69,7 @@ export function ButtonLink({
64
69
  variant === "secondary" && styles.secondary,
65
70
  variant === "ghost" && styles.ghost,
66
71
  variant === "danger" && styles.danger,
72
+ muted && styles.muted,
67
73
  disabled && styles.disabled,
68
74
  );
69
75
  if (href) {
@@ -149,6 +155,14 @@ const styles = stylex.create({
149
155
  },
150
156
  },
151
157
  },
158
+ muted: {
159
+ color: colors.textMuted,
160
+ [hover]: {
161
+ ":hover": {
162
+ color: colors.text,
163
+ },
164
+ },
165
+ },
152
166
  danger: {
153
167
  backgroundColor: "transparent",
154
168
  borderColor: "transparent",
package/src/ui/Field.tsx CHANGED
@@ -13,7 +13,7 @@ export function Field({
13
13
  children: React.ReactNode;
14
14
  }) {
15
15
  return (
16
- <label {...stylex.props(styles.field)}>
16
+ <label {...stylex.props(styles.field)} onClickCapture={keepButtonsUnpressed}>
17
17
  <span {...stylex.props(styles.label)}>{label}</span>
18
18
  {children}
19
19
  {hint ? <span {...stylex.props(styles.hint)}>{hint}</span> : null}
@@ -21,6 +21,17 @@ export function Field({
21
21
  );
22
22
  }
23
23
 
24
+ /**
25
+ * A label forwards a click on its plain content to its first labelable descendant.
26
+ * In a composite control that is an arbitrary button, such as a gallery's first remove button.
27
+ */
28
+ function keepButtonsUnpressed(event: React.MouseEvent<HTMLLabelElement>) {
29
+ const control = event.currentTarget.control;
30
+ if (!(control instanceof HTMLButtonElement) || control.getAttribute("role") === "combobox") return;
31
+ if (event.target instanceof Element && event.target.closest("button, a, input, select, textarea")) return;
32
+ event.preventDefault();
33
+ }
34
+
24
35
  const styles = stylex.create({
25
36
  field: {
26
37
  display: "block",
package/src/ui/Input.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  // packages/studio/src/ui/Input.tsx
2
2
  import { useState, type ComponentPropsWithoutRef } from "react";
3
+ import { Combobox } from "@base-ui/react/combobox";
3
4
  import { Input as BaseInput } from "@base-ui/react/input";
4
5
  import { Select as BaseSelect } from "@base-ui/react/select";
5
6
  import * as stylex from "@stylexjs/stylex";
@@ -14,20 +15,7 @@ export function Input(props: Props) {
14
15
 
15
16
  export type SelectOption = { value: string; label: string; disabled?: boolean };
16
17
 
17
- /** Form select built on Base UI `Select`; styled like `Input`. */
18
- export function Select({
19
- options,
20
- value,
21
- onValueChange,
22
- placeholder = "Select…",
23
- name,
24
- disabled,
25
- chip = false,
26
- clearable = false,
27
- searchable = false,
28
- "aria-label": ariaLabel,
29
- id,
30
- }: {
18
+ type SelectProps = {
31
19
  options: SelectOption[];
32
20
  value: string | null;
33
21
  onValueChange: (value: string | null) => void;
@@ -36,22 +24,183 @@ export function Select({
36
24
  disabled?: boolean;
37
25
  /** Selected value sits in the field as a removable chip. */
38
26
  chip?: boolean;
39
- /** Chip × and the field clear control clear the value. Ignored when `chip` is false. */
27
+ /** A clear control beside the chevron. Ignored when `chip` is false. */
40
28
  clearable?: boolean;
41
- /** Filter the menu by label or value. The closed field stays a select. */
29
+ /** Filter the menu by label or value. The closed field stays a button. */
42
30
  searchable?: boolean;
43
31
  "aria-label"?: string;
44
32
  id?: string;
45
- }) {
33
+ };
34
+
35
+ /** A list of choices styled like `Input`. A filterable list is a Base UI Combobox. */
36
+ export function Select(props: SelectProps) {
37
+ if (props.searchable) return <FilterSelect {...props} />;
38
+ return <ListSelect {...props} />;
39
+ }
40
+
41
+ function matchesQuery(option: SelectOption, query: string) {
42
+ const q = query.trim().toLowerCase();
43
+ if (!q) return true;
44
+ return option.label.toLowerCase().includes(q) || option.value.toLowerCase().includes(q);
45
+ }
46
+
47
+ function FilterSelect({
48
+ options,
49
+ value,
50
+ onValueChange,
51
+ placeholder = "Select…",
52
+ name,
53
+ disabled,
54
+ chip = false,
55
+ clearable = false,
56
+ "aria-label": ariaLabel,
57
+ id,
58
+ }: SelectProps) {
59
+ const selected = options.find((opt) => opt.value === value) ?? null;
60
+ const [open, setOpen] = useState(false);
61
+ const clear = (event: { preventDefault: () => void; stopPropagation: () => void }) => {
62
+ event.preventDefault();
63
+ event.stopPropagation();
64
+ onValueChange(null);
65
+ };
66
+ return (
67
+ <Combobox.Root
68
+ items={options}
69
+ value={selected}
70
+ name={name}
71
+ disabled={disabled}
72
+ autoHighlight
73
+ isItemEqualToValue={(item, current) => item.value === current.value}
74
+ filter={matchesQuery}
75
+ onValueChange={(next) => onValueChange(next == null ? null : next.value)}
76
+ onOpenChange={(next) => setOpen(next)}
77
+ >
78
+ <Combobox.Trigger id={id} aria-label={ariaLabel} className={cx(styles.input, styles.selectTrigger)}>
79
+ {chip && selected ? (
80
+ <span {...stylex.props(styles.chip)}>
81
+ <span {...stylex.props(styles.chipLabel)}>{selected.label}</span>
82
+ </span>
83
+ ) : (
84
+ <Combobox.Value>
85
+ {(current: SelectOption | null) =>
86
+ current ? (
87
+ <span {...stylex.props(styles.selectValue)}>{current.label}</span>
88
+ ) : (
89
+ <span {...stylex.props(styles.selectValue, styles.placeholder)}>{placeholder}</span>
90
+ )
91
+ }
92
+ </Combobox.Value>
93
+ )}
94
+ <span {...stylex.props(styles.selectActions)}>
95
+ {chip && clearable && selected && !disabled ? (
96
+ <span
97
+ data-select-clear
98
+ role="button"
99
+ aria-label="Clear"
100
+ {...stylex.props(styles.fieldClear)}
101
+ onPointerDown={(event) => event.stopPropagation()}
102
+ onClick={clear}
103
+ >
104
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden>
105
+ <circle cx="8" cy="8" r="6.25" stroke="currentColor" strokeWidth="1.25" />
106
+ <path
107
+ d="M6 6l4 4M10 6l-4 4"
108
+ stroke="currentColor"
109
+ strokeWidth="1.25"
110
+ strokeLinecap="round"
111
+ />
112
+ </svg>
113
+ </span>
114
+ ) : null}
115
+ <Combobox.Icon className={cx(styles.selectIcon, open && styles.selectIconOpen)}>
116
+ <svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden>
117
+ <path
118
+ d="M4.5 6.25 8 9.75l3.5-3.5"
119
+ stroke="currentColor"
120
+ strokeWidth="1.5"
121
+ strokeLinecap="round"
122
+ strokeLinejoin="round"
123
+ />
124
+ </svg>
125
+ </Combobox.Icon>
126
+ </span>
127
+ </Combobox.Trigger>
128
+ <Combobox.Portal>
129
+ <Combobox.Positioner
130
+ side="bottom"
131
+ align="start"
132
+ sideOffset={6}
133
+ className={cx(popup.positioner)}
134
+ >
135
+ <Combobox.Popup
136
+ aria-label={ariaLabel}
137
+ className={(state) => popupClassName(state, styles.selectPopup)}
138
+ >
139
+ <Combobox.Input
140
+ data-select-search=""
141
+ data-no-ring=""
142
+ data-1p-ignore=""
143
+ data-lpignore=""
144
+ placeholder="Search"
145
+ aria-label="Search"
146
+ spellCheck={false}
147
+ autoComplete="off"
148
+ {...stylex.props(popup.searchInput)}
149
+ />
150
+ <Combobox.Empty className={cx(popup.empty)}>No matches</Combobox.Empty>
151
+ <Combobox.List>
152
+ {(opt: SelectOption) => (
153
+ <Combobox.Item
154
+ key={opt.value}
155
+ value={opt}
156
+ disabled={opt.disabled}
157
+ data-no-ring=""
158
+ className={(state) =>
159
+ cx(
160
+ popup.item,
161
+ state.highlighted && popup.itemHighlighted,
162
+ state.selected && popup.itemSelected,
163
+ state.disabled && popup.itemDisabled,
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
+ )}
183
+ </Combobox.List>
184
+ </Combobox.Popup>
185
+ </Combobox.Positioner>
186
+ </Combobox.Portal>
187
+ </Combobox.Root>
188
+ );
189
+ }
190
+
191
+ function ListSelect({
192
+ options,
193
+ value,
194
+ onValueChange,
195
+ placeholder = "Select…",
196
+ name,
197
+ disabled,
198
+ chip = false,
199
+ clearable = false,
200
+ "aria-label": ariaLabel,
201
+ id,
202
+ }: SelectProps) {
46
203
  const selected = options.find((opt) => opt.value === value) ?? null;
47
- const [search, setSearch] = useState("");
48
- const query = search.trim().toLowerCase();
49
- const visible = query
50
- ? options.filter(
51
- (opt) =>
52
- opt.label.toLowerCase().includes(query) || opt.value.toLowerCase().includes(query),
53
- )
54
- : options;
55
204
  const clear = (event: { preventDefault: () => void; stopPropagation: () => void }) => {
56
205
  event.preventDefault();
57
206
  event.stopPropagation();
@@ -62,37 +211,18 @@ export function Select({
62
211
  items={options}
63
212
  value={value}
64
213
  onValueChange={(next) => onValueChange(typeof next === "string" ? next : null)}
65
- onOpenChange={(open) => {
66
- if (!open) setSearch("");
67
- }}
68
214
  name={name}
69
215
  disabled={disabled}
70
216
  >
71
- <BaseSelect.Trigger
72
- id={id}
73
- aria-label={ariaLabel}
74
- data-no-ring=""
75
- className={cx(styles.input, styles.selectTrigger)}
76
- >
217
+ <BaseSelect.Trigger id={id} aria-label={ariaLabel} className={cx(styles.input, styles.selectTrigger)}>
77
218
  {chip && selected ? (
78
219
  <span {...stylex.props(styles.chip)}>
79
220
  <span {...stylex.props(styles.chipLabel)}>{selected.label}</span>
80
- {clearable && !disabled ? (
81
- <span
82
- data-select-clear
83
- aria-hidden
84
- {...stylex.props(styles.chipRemove)}
85
- onPointerDown={(event) => event.stopPropagation()}
86
- onClick={clear}
87
- >
88
- ×
89
- </span>
90
- ) : null}
91
221
  </span>
92
222
  ) : (
93
223
  <BaseSelect.Value
94
224
  placeholder={placeholder}
95
- className={cx(styles.selectValue, chip && styles.placeholder)}
225
+ className={(state) => cx(styles.selectValue, state.placeholder && styles.placeholder)}
96
226
  />
97
227
  )}
98
228
  <span {...stylex.props(styles.selectActions)}>
@@ -116,7 +246,9 @@ export function Select({
116
246
  </svg>
117
247
  </span>
118
248
  ) : null}
119
- <BaseSelect.Icon className={cx(styles.selectIcon)}>
249
+ <BaseSelect.Icon
250
+ className={(state) => cx(styles.selectIcon, state.open && styles.selectIconOpen)}
251
+ >
120
252
  <svg width="12" height="12" viewBox="0 0 16 16" fill="none" aria-hidden>
121
253
  <path
122
254
  d="M4.5 6.25 8 9.75l3.5-3.5"
@@ -133,37 +265,19 @@ export function Select({
133
265
  <BaseSelect.Positioner
134
266
  side="bottom"
135
267
  align="start"
136
- sideOffset={4}
268
+ sideOffset={6}
137
269
  alignItemWithTrigger={false}
138
270
  className={cx(popup.positioner)}
139
271
  >
140
272
  <BaseSelect.Popup className={(state) => popupClassName(state, styles.selectPopup)}>
141
- {searchable ? (
142
- <input
143
- data-select-search
144
- data-no-ring=""
145
- value={search}
146
- placeholder="Search"
147
- spellCheck={false}
148
- autoComplete="off"
149
- className={cx(popup.searchInput)}
150
- onChange={(event) => setSearch(event.target.value)}
151
- onMouseDown={(event) => {
152
- event.preventDefault();
153
- event.stopPropagation();
154
- event.currentTarget.focus();
155
- }}
156
- onPointerDown={(event) => event.stopPropagation()}
157
- onKeyDown={(event) => event.stopPropagation()}
158
- />
159
- ) : null}
160
273
  <BaseSelect.List>
161
- {visible.map((opt) => (
274
+ {options.map((opt) => (
162
275
  <BaseSelect.Item
163
276
  key={opt.value}
164
277
  value={opt.value}
165
278
  label={opt.label}
166
279
  disabled={opt.disabled}
280
+ data-no-ring=""
167
281
  className={(state) =>
168
282
  cx(
169
283
  popup.item,
@@ -246,22 +360,6 @@ const styles = stylex.create({
246
360
  textAlign: "left",
247
361
  fontFamily: type.sans,
248
362
  cursor: "pointer",
249
- outline: "none",
250
- boxShadow: "none",
251
- ":focus": {
252
- borderColor: colors.border,
253
- outlineStyle: "none",
254
- outlineWidth: 0,
255
- outlineOffset: 0,
256
- boxShadow: "none",
257
- },
258
- ":focus-visible": {
259
- borderColor: colors.border,
260
- outlineStyle: "none",
261
- outlineWidth: 0,
262
- outlineOffset: 0,
263
- boxShadow: "none",
264
- },
265
363
  },
266
364
  selectValue: {
267
365
  minWidth: 0,
@@ -294,19 +392,6 @@ const styles = stylex.create({
294
392
  textOverflow: "ellipsis",
295
393
  whiteSpace: "nowrap",
296
394
  },
297
- chipRemove: {
298
- display: "inline-flex",
299
- alignItems: "center",
300
- justifyContent: "center",
301
- margin: 0,
302
- padding: 0,
303
- borderWidth: 0,
304
- backgroundColor: "transparent",
305
- color: colors.textMuted,
306
- fontSize: type.sm,
307
- lineHeight: 1,
308
- cursor: "pointer",
309
- },
310
395
  selectActions: {
311
396
  display: "inline-flex",
312
397
  alignItems: "center",
@@ -325,6 +410,15 @@ const styles = stylex.create({
325
410
  display: "inline-flex",
326
411
  flexShrink: 0,
327
412
  color: colors.textMuted,
413
+ transitionProperty: "transform",
414
+ transitionDuration: "150ms",
415
+ transitionTimingFunction: "ease",
416
+ "@media (prefers-reduced-motion: reduce)": {
417
+ transitionDuration: "0ms",
418
+ },
419
+ },
420
+ selectIconOpen: {
421
+ transform: "rotate(180deg)",
328
422
  },
329
423
  selectPopup: {
330
424
  minWidth: "var(--anchor-width)",
package/src/ui/popup.ts CHANGED
@@ -138,10 +138,12 @@ export const popup = stylex.create({
138
138
  },
139
139
  empty: {
140
140
  margin: 0,
141
- paddingInline: space.lg,
141
+ // Same left edge as an item label (item inset + check column + gap).
142
+ paddingLeft: `calc(${space.xs} + ${space.md} + 14px + ${space.sm})`,
143
+ paddingRight: space.lg,
142
144
  // Combobox.Empty stays mounted while items exist; collapse it then.
143
145
  paddingBlock: { default: space.md, ":empty": 0 },
144
- fontSize: type.sm,
146
+ fontSize: type.xs,
145
147
  color: colors.textMuted,
146
148
  },
147
149
  quietInput: {
@@ -172,16 +174,21 @@ export const popup = stylex.create({
172
174
  boxSizing: "border-box",
173
175
  marginTop: `calc(${space.xs} * -1)`,
174
176
  marginBottom: space.xs,
177
+ appearance: "none",
175
178
  borderWidth: 0,
179
+ borderRadius: 0,
176
180
  borderBottomWidth: 1,
177
181
  borderBottomStyle: "solid",
178
182
  borderBottomColor: colors.border,
179
183
  backgroundColor: "transparent",
180
184
  color: colors.text,
181
- paddingInline: space.lg,
185
+ // Same left edge as an item label (item inset + check column + gap).
186
+ paddingLeft: `calc(${space.xs} + ${space.md} + 14px + ${space.sm})`,
187
+ paddingRight: space.lg,
182
188
  paddingBlock: space.md,
183
189
  fontFamily: type.sans,
184
- fontSize: type.sm,
190
+ fontSize: type.xs,
191
+ lineHeight: 1.4,
185
192
  outline: "none",
186
193
  boxShadow: "none",
187
194
  ":focus": {
@@ -189,14 +196,14 @@ export const popup = stylex.create({
189
196
  outlineWidth: 0,
190
197
  outlineOffset: 0,
191
198
  boxShadow: "none",
192
- borderBottomColor: colors.border,
199
+ borderBottomColor: colors.focus,
193
200
  },
194
201
  ":focus-visible": {
195
202
  outlineStyle: "none",
196
203
  outlineWidth: 0,
197
204
  outlineOffset: 0,
198
205
  boxShadow: "none",
199
- borderBottomColor: colors.border,
206
+ borderBottomColor: colors.focus,
200
207
  },
201
208
  "::placeholder": {
202
209
  color: colors.textMuted,