@backmatter/studio 0.0.22 → 0.0.24

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.
@@ -3,7 +3,7 @@ var st = (e, t, n) => t in e ? rt(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var $ = (e, t, n) => st(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as w, jsx as i, Fragment as re } from "react/jsx-runtime";
5
5
  import { useRef as qe, useCallback as it, useSyncExternalStore as at, useState as E, useEffect as W, lazy as ot, Suspense as lt } from "react";
6
- import { X as Ie, V as R, k as ze, an as Be, ao as be, ap as ct, aq as ut, ar as Fe, as as Me, at as De, au as dt, av as ft, P as He, aw as ht, ax as ae, ah as K, Z as We, ay as xt, az as $e, ai as pt, ak as se, aa as Q, ab as Z, Y as oe, aA as gt, W as F, aB as mt, J as we, aC as ee, aj as yt, aD as vt, aE as bt, aF as wt, aG as kt, aH as St, f as Rt, aI as Et, a6 as _t, aJ as jt, aK as Tt, z as Pt, B as Ot, I as Lt, aL as Nt, aM as Ut, aN as At, K as Ct, aO as qt, R as It, L as zt, M as Bt, N as Ft, O as D, Q as Mt, U as Dt } from "./WorkspaceRoutes-CzCBnhNt.js";
6
+ import { X as Ie, V as R, k as ze, an as Be, ao as be, ap as ct, aq as ut, ar as Fe, as as Me, at as De, au as dt, av as ft, P as He, aw as ht, ax as ae, ah as K, Z as We, ay as xt, az as $e, ai as pt, ak as se, aa as Q, ab as Z, Y as oe, aA as gt, W as F, aB as mt, J as we, aC as ee, aj as yt, aD as vt, aE as bt, aF as wt, aG as kt, aH as St, f as Rt, aI as Et, a6 as _t, aJ as jt, aK as Tt, z as Pt, B as Ot, I as Lt, aL as Nt, aM as Ut, aN as At, K as Ct, aO as qt, R as It, L as zt, M as Bt, N as Ft, O as D, Q as Mt, U as Dt } from "./WorkspaceRoutes-DuwT2y7A.js";
7
7
  const te = /* @__PURE__ */ Object.create(null), G = (e) => {
8
8
  var t, n;
9
9
  return ((t = globalThis.process) == null ? void 0 : t.env) || ((n = globalThis.Deno) == null ? void 0 : n.env.toObject()) || globalThis.__env__ || (e ? te : globalThis);
@@ -1823,7 +1823,7 @@ function Or(e) {
1823
1823
  const t = e.replace(/\/$/, "") || "/";
1824
1824
  return t === "/__ui" || /^\/__ui\/[^/]+$/.test(t);
1825
1825
  }
1826
- const Lr = ot(() => import("./UiKitApp-CgGyJiC4.js").then((e) => ({
1826
+ const Lr = ot(() => import("./UiKitApp-BW_SpUgQ.js").then((e) => ({
1827
1827
  default: e.UiKitApp
1828
1828
  })));
1829
1829
  function Ir() {
@@ -1,7 +1,7 @@
1
1
  var Rs = Object.defineProperty;
2
2
  var Es = (r, e, t) => e in r ? Rs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var M = (r, e, t) => Es(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { aP as Bt, aQ as Bs, aR as a0, aS as ct, aT as xt, aU as ea, aV as Gn, aW as Is, aX as Ls, aY as Ds, aZ as La, a_ as Ps, a$ as Os, b0 as Le, b1 as qs } from "./WorkspaceRoutes-CzCBnhNt.js";
4
+ import { aP as Bt, aQ as Bs, aR as a0, aS as ct, aT as xt, aU as ea, aV as Gn, aW as Is, aX as Ls, aY as Ds, aZ as La, a_ as Ps, a$ as Os, b0 as Le, b1 as qs } from "./WorkspaceRoutes-DuwT2y7A.js";
5
5
  function Fs() {
6
6
  return {
7
7
  enter: {
package/dist/dashboard.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as a, i as s } from "./chunks/dashboard-w-mlsGky.js";
2
- import { G as t, H as f } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
1
+ import { A as a, i as s } from "./chunks/dashboard-RFDdTeMV.js";
2
+ import { G as t, H as f } from "./chunks/WorkspaceRoutes-DuwT2y7A.js";
3
3
  export {
4
4
  a as DashboardApp,
5
5
  t as configureStudio,
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as t, jsxs as u, Fragment as he } from "react/jsx-runtime";
2
2
  import { useLayoutEffect as pe, useEffect as p, useRef as ee, useState as m, useMemo as fe } from "react";
3
- import { i as te, T as ge, E as be, C as ye, a as we, b as ve, u as ke, D as V, c as ne, d as H, e as qe, f as re, g as W, h as ze, p as Ee, j as Ce, k as w, l as v, m as Ne, n as Se, o as L, s as Le, r as Pe, q as Re, t as je, v as Ue, w as Te, x as Me, y as $e, z as Fe, B as Be, A as Oe, S as Ae, F as De, G as ie, H as U, I as Ge, J as _e, K as Ie, R as Ke, L as Ve, M as He, N as We, O as P, P as X, Q as Xe, U as Je, V as J, W as Qe } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
4
- import { X as kt } from "./chunks/WorkspaceRoutes-CzCBnhNt.js";
3
+ import { i as te, T as ge, E as be, C as ye, a as we, b as ve, u as ke, D as V, c as ne, d as H, e as qe, f as re, g as W, h as ze, p as Ee, j as Ce, k as w, l as v, m as Ne, n as Se, o as L, s as Le, r as Pe, q as Re, t as je, v as Ue, w as Te, x as Me, y as $e, z as Fe, B as Be, A as Oe, S as Ae, F as De, G as ie, H as U, I as Ge, J as _e, K as Ie, R as Ke, L as Ve, M as He, N as We, O as P, P as X, Q as Xe, U as Je, V as J, W as Qe } from "./chunks/WorkspaceRoutes-DuwT2y7A.js";
4
+ import { X as kt } from "./chunks/WorkspaceRoutes-DuwT2y7A.js";
5
5
  import { u as Ye, S as Ze } from "./chunks/define-studio-DlYjgrwr.js";
6
6
  import { d as zt } from "./chunks/define-studio-DlYjgrwr.js";
7
7
  const R = {
package/dist/studio.css CHANGED
@@ -31,6 +31,10 @@
31
31
  margin: 0;
32
32
  }
33
33
 
34
+ .x1bpp3o7 {
35
+ margin: auto;
36
+ }
37
+
34
38
  .x1717udv {
35
39
  padding: 0;
36
40
  }
@@ -169,6 +173,10 @@
169
173
  border-radius: 999px;
170
174
  }
171
175
 
176
+ .x1pjcqnp {
177
+ border-radius: inherit;
178
+ }
179
+
172
180
  .xjdkmwh {
173
181
  border-radius: var(--x16ewcrl);
174
182
  }
@@ -459,7 +467,7 @@
459
467
  border-color: color-mix(in srgb,var(--xw4dauw) 45%,var(--xz3qvk5));
460
468
  }
461
469
 
462
- .x1gdl68u:focus-within {
470
+ .x1gdl68u:focus-within, .x1kayw1c:focus-visible {
463
471
  border-color: var(--x1nzi8h4);
464
472
  }
465
473
 
@@ -581,10 +589,18 @@
581
589
  align-self: stretch;
582
590
  }
583
591
 
592
+ .xmmqq2k {
593
+ animation-delay: .15s;
594
+ }
595
+
584
596
  .x12l1aco {
585
597
  animation-duration: .12s;
586
598
  }
587
599
 
600
+ .xtsvl71 {
601
+ animation-duration: .15s;
602
+ }
603
+
588
604
  .x5hsz1j {
589
605
  animation-duration: .2s;
590
606
  }
@@ -601,6 +617,10 @@
601
617
  animation-fill-mode: backwards;
602
618
  }
603
619
 
620
+ .x1u6ievf {
621
+ animation-fill-mode: both;
622
+ }
623
+
604
624
  .xa4qsjk {
605
625
  animation-iteration-count: infinite;
606
626
  }
@@ -633,6 +653,10 @@
633
653
  animation-timing-function: ease-in-out;
634
654
  }
635
655
 
656
+ .xa3vuyk {
657
+ animation-timing-function: ease-out;
658
+ }
659
+
636
660
  .x1esw782 {
637
661
  animation-timing-function: linear;
638
662
  }
@@ -1057,6 +1081,10 @@
1057
1081
  column-gap: 48px;
1058
1082
  }
1059
1083
 
1084
+ .x1q3hsim {
1085
+ column-gap: var(--x1ft7ks7);
1086
+ }
1087
+
1060
1088
  .x16qrkmw {
1061
1089
  contain: paint;
1062
1090
  }
@@ -1125,6 +1153,10 @@
1125
1153
  flex-basis: 0%;
1126
1154
  }
1127
1155
 
1156
+ .x1l7klhg {
1157
+ flex-basis: 100%;
1158
+ }
1159
+
1128
1160
  .xdl72j9 {
1129
1161
  flex-basis: auto;
1130
1162
  }
@@ -1253,6 +1285,10 @@
1253
1285
  font-weight: 700;
1254
1286
  }
1255
1287
 
1288
+ .x1th50cv {
1289
+ grid-template-columns: 11rem minmax(0, 1fr);
1290
+ }
1291
+
1256
1292
  .x1o61qjw {
1257
1293
  grid-template-columns: 1fr 1fr;
1258
1294
  }
@@ -1281,10 +1317,18 @@
1281
1317
  grid-template-columns: repeat(auto-fill, 72px);
1282
1318
  }
1283
1319
 
1320
+ .x1oqazeo {
1321
+ grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
1322
+ }
1323
+
1284
1324
  .x10vl0y4 {
1285
1325
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
1286
1326
  }
1287
1327
 
1328
+ .xrw2u2m {
1329
+ grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
1330
+ }
1331
+
1288
1332
  .xc8icb0 {
1289
1333
  isolation: isolate;
1290
1334
  }
@@ -1830,6 +1874,10 @@
1830
1874
  }
1831
1875
  }
1832
1876
 
1877
+ .x11exl2m:focus-visible {
1878
+ background-color: var(--xeg52a);
1879
+ }
1880
+
1833
1881
  .xjanfmb:focus-visible {
1834
1882
  background-size: 2px 100%;
1835
1883
  }
@@ -1934,6 +1982,10 @@
1934
1982
  opacity: .8;
1935
1983
  }
1936
1984
 
1985
+ .xtbifol:checked {
1986
+ background-color: var(--x11n7hvk);
1987
+ }
1988
+
1937
1989
  .x8w64xv:hover {
1938
1990
  background-color: var(--xeg52a);
1939
1991
  }
@@ -2014,6 +2066,12 @@
2014
2066
  }
2015
2067
  }
2016
2068
 
2069
+ @media (width <= 640px) {
2070
+ .xkaaz9w.xkaaz9w {
2071
+ display: none;
2072
+ }
2073
+ }
2074
+
2017
2075
  @media (prefers-reduced-motion: reduce) {
2018
2076
  .xkio4u3.xkio4u3 {
2019
2077
  display: none;
@@ -2044,6 +2102,12 @@
2044
2102
  }
2045
2103
  }
2046
2104
 
2105
+ @media (width <= 640px) {
2106
+ .x4jmfmw.x4jmfmw {
2107
+ grid-template-columns: minmax(0, 1fr);
2108
+ }
2109
+ }
2110
+
2047
2111
  @media (width <= 800px) {
2048
2112
  .x1kk4rku.x1kk4rku {
2049
2113
  grid-template-columns: repeat(2, minmax(0, 1fr));
@@ -2079,6 +2143,10 @@
2079
2143
  background-color: #e4e4e7;
2080
2144
  }
2081
2145
 
2146
+ .xkfsa8o.xkfsa8o:hover {
2147
+ background-color: color-mix(in srgb,var(--xeg52a) 50%,transparent);
2148
+ }
2149
+
2082
2150
  .x9ezvp6.x9ezvp6:hover {
2083
2151
  background-color: #18181b;
2084
2152
  }
@@ -2272,10 +2340,6 @@
2272
2340
  height: 1px;
2273
2341
  }
2274
2342
 
2275
- .x1l36t39 {
2276
- height: 1rem;
2277
- }
2278
-
2279
2343
  .x1qx5ct2 {
2280
2344
  height: 20px;
2281
2345
  }
@@ -2376,6 +2440,10 @@
2376
2440
  height: min(640px,calc(100vh - 68px - env(safe-area-inset-bottom, 0px)));
2377
2441
  }
2378
2442
 
2443
+ .x10ng2aq {
2444
+ height: min(760px, 100vh - 32px);
2445
+ }
2446
+
2379
2447
  .x6zskup {
2380
2448
  left: -4px;
2381
2449
  }
@@ -2604,6 +2672,10 @@
2604
2672
  max-width: 360px;
2605
2673
  }
2606
2674
 
2675
+ .xf2d64e {
2676
+ max-width: 40rem;
2677
+ }
2678
+
2607
2679
  .x1lr1uin {
2608
2680
  max-width: 420px;
2609
2681
  }
@@ -2616,6 +2688,10 @@
2616
2688
  max-width: 460px;
2617
2689
  }
2618
2690
 
2691
+ .xthy2uy {
2692
+ max-width: 50%;
2693
+ }
2694
+
2619
2695
  .xh9uqaf {
2620
2696
  max-width: 60%;
2621
2697
  }
@@ -3024,6 +3100,10 @@
3024
3100
  width: 16px;
3025
3101
  }
3026
3102
 
3103
+ .x1e67fm3 {
3104
+ width: 16rem;
3105
+ }
3106
+
3027
3107
  .x1xp8n7a {
3028
3108
  width: 18px;
3029
3109
  }
@@ -3032,10 +3112,6 @@
3032
3112
  width: 1px;
3033
3113
  }
3034
3114
 
3035
- .xcdlrvm {
3036
- width: 1rem;
3037
- }
3038
-
3039
3115
  .xvm51jw {
3040
3116
  width: 2.5rem;
3041
3117
  }
@@ -3184,6 +3260,10 @@
3184
3260
  width: calc(min(360px, 38vw) - 48px);
3185
3261
  }
3186
3262
 
3263
+ .x10br60o {
3264
+ width: min(1080px, 100vw - 32px);
3265
+ }
3266
+
3187
3267
  .x3bfboh {
3188
3268
  width: min(360px, 38vw);
3189
3269
  }
@@ -3248,6 +3328,22 @@
3248
3328
  border-bottom-color: var(--x1nzi8h4);
3249
3329
  }
3250
3330
 
3331
+ .x18efcp4:first-child {
3332
+ border-top-left-radius: calc(var(--x83d9l2) - 1px);
3333
+ }
3334
+
3335
+ .xfra7d4:first-child {
3336
+ border-top-right-radius: calc(var(--x83d9l2) - 1px);
3337
+ }
3338
+
3339
+ .xpave9o:last-child {
3340
+ border-bottom-left-radius: calc(var(--x83d9l2) - 1px);
3341
+ }
3342
+
3343
+ .x1m3jluo:last-child {
3344
+ border-bottom-right-radius: calc(var(--x83d9l2) - 1px);
3345
+ }
3346
+
3251
3347
  .x1t1lzn6:last-child {
3252
3348
  border-bottom-width: 0;
3253
3349
  }
@@ -3305,6 +3401,10 @@
3305
3401
  .x1d0y9ls:after {
3306
3402
  background-position: 0;
3307
3403
  }
3404
+
3405
+ .x1n6dlnu:before {
3406
+ border-radius: 999px;
3407
+ }
3308
3408
  }
3309
3409
 
3310
3410
  @layer priority7 {
@@ -3324,6 +3424,10 @@
3324
3424
  animation-timing-function: linear;
3325
3425
  }
3326
3426
 
3427
+ .x1trpwii:before {
3428
+ background-color: var(--x1dudhym);
3429
+ }
3430
+
3327
3431
  .x1ghgi56:after {
3328
3432
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 72' fill='none'%3E%3Cdefs%3E%3Cfilter id='b' x='-100%25' y='-100%25' width='300%25' height='300%25'%3E%3CfeGaussianBlur stdDeviation='6'/%3E%3C/filter%3E%3C/defs%3E%3Cg transform='rotate(-30 90 36)' filter='url(%23b)'%3E%3Crect x='72' y='18' width='36' height='36' fill='%2318181b' fill-opacity='.45'/%3E%3Crect x='84' y='16' width='12' height='40' fill='%2318181b'/%3E%3C/g%3E%3C/svg%3E");
3329
3433
  }
@@ -3336,11 +3440,15 @@
3336
3440
  background-size: 180px 72px;
3337
3441
  }
3338
3442
 
3443
+ .xuj3ll3:before {
3444
+ box-shadow: 0 1px 2px #0003;
3445
+ }
3446
+
3339
3447
  .x9ecp23::placeholder {
3340
3448
  color: var(--xw4dauw);
3341
3449
  }
3342
3450
 
3343
- .x1s928wv:after {
3451
+ .x1cpjm7i:before, .x1s928wv:after {
3344
3452
  content: "";
3345
3453
  }
3346
3454
 
@@ -3348,9 +3456,27 @@
3348
3456
  pointer-events: none;
3349
3457
  }
3350
3458
 
3351
- .x1j6awrg:after {
3459
+ .x1hmns74:before, .x1j6awrg:after {
3352
3460
  position: absolute;
3353
3461
  }
3462
+
3463
+ .xqfulrc:before {
3464
+ transition-duration: .12s;
3465
+ }
3466
+
3467
+ .x1hu8v7x:before {
3468
+ transition-property: transform;
3469
+ }
3470
+
3471
+ .xiop08k:checked:before {
3472
+ transform: translateX(12px);
3473
+ }
3474
+
3475
+ @media (prefers-reduced-motion: reduce) {
3476
+ .x13sdc92.x13sdc92:before {
3477
+ transition-duration: 0s;
3478
+ }
3479
+ }
3354
3480
  }
3355
3481
 
3356
3482
  @layer priority8 {
@@ -3358,14 +3484,30 @@
3358
3484
  height: 100%;
3359
3485
  }
3360
3486
 
3487
+ .xxt7thn:before {
3488
+ height: 12px;
3489
+ }
3490
+
3361
3491
  .x1oly944:after {
3362
3492
  left: -180px;
3363
3493
  }
3364
3494
 
3495
+ .x1tymlch:before {
3496
+ left: 2px;
3497
+ }
3498
+
3365
3499
  .x1m1drc7:after {
3366
3500
  top: 0;
3367
3501
  }
3368
3502
 
3503
+ .xwwlq33:before {
3504
+ top: 2px;
3505
+ }
3506
+
3507
+ .x20nr4a:before {
3508
+ width: 12px;
3509
+ }
3510
+
3369
3511
  .x14wh5xp:after {
3370
3512
  width: calc(100% + 180px);
3371
3513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backmatter/studio",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "The Backmatter editing surface: document editor, AI chat, publish. Mounted on your site or hosted on the dashboard.",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -56,7 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@ai-sdk/react": "^4.0.100",
59
- "@backmatter/core": "^0.0.38",
59
+ "@backmatter/core": "^0.0.39",
60
60
  "@base-ui/react": "^1.6.0",
61
61
  "@central-icons-react/round-outlined-radius-2-stroke-1.5": "1.2.15",
62
62
  "@dnd-kit/abstract": "^0.5.0",
@@ -15,6 +15,7 @@ import { SettingsUsersPage } from "./pages/SettingsUsersPage";
15
15
  import { GithubConnectPage } from "./pages/GithubConnectPage";
16
16
  import { DocEditorPage } from "./pages/DocEditorPage";
17
17
  import { MediaGalleryPage } from "./pages/MediaGalleryPage";
18
+ import { BlocksLibraryPage } from "./pages/BlocksLibraryPage";
18
19
  import CodeSessionPage from "./pages/CodeSessionPage";
19
20
 
20
21
  /**
@@ -40,6 +41,7 @@ export function workspaceRoutes() {
40
41
  </Route>
41
42
  <Route path="content/:type/:docSlug" element={<DocEditorPage />} />
42
43
  <Route path="media" element={<MediaGalleryPage />} />
44
+ <Route path="blocks" element={<BlocksLibraryPage />} />
43
45
  </Route>
44
46
  );
45
47
  }
package/src/api.ts CHANGED
@@ -353,6 +353,9 @@ export function unbindGithub(workspaceId: string) {
353
353
  );
354
354
  }
355
355
 
356
+ /** "grouped" opens on block groups, "flat" lists every block, "auto" groups long catalogs. */
357
+ export type BlockPickerView = "auto" | "grouped" | "flat";
358
+
356
359
  export type SchemaField = {
357
360
  kind: string;
358
361
  multiple?: boolean;
@@ -369,6 +372,8 @@ export type SchemaField = {
369
372
  max?: number;
370
373
  step?: number;
371
374
  where?: Record<string, string | number | boolean>;
375
+ /** For blocks fields: layout of the "Add block" picker. */
376
+ picker?: BlockPickerView;
372
377
  /** Guidance from the site developer: what goes here. */
373
378
  description?: string;
374
379
  };
@@ -24,6 +24,8 @@ import {
24
24
  isWorkspaceCodePath,
25
25
  isWorkspaceEditorPath,
26
26
  isWorkspaceMediaPath,
27
+ isWorkspaceBlocksPath,
28
+ blocksPath,
27
29
  isWorkspaceSettingsPath,
28
30
  mediaPath,
29
31
  settingsPath,
@@ -47,6 +49,7 @@ import {
47
49
  ExplorerRailCodeIcon,
48
50
  ExplorerRailFilesIcon,
49
51
  ExplorerRailMediaIcon,
52
+ ExplorerRailBlocksIcon,
50
53
  ExplorerRailSearchIcon,
51
54
  ExplorerRailSettingsIcon,
52
55
  ExplorerTwistie,
@@ -345,6 +348,19 @@ export function ActivityRail({
345
348
  <ExplorerRailMediaIcon />
346
349
  </Link>
347
350
  </Tooltip>
351
+ <Tooltip label="Blocks" side="right">
352
+ <Link
353
+ to={blocksPath(workspaceSlug)}
354
+ aria-label="Blocks"
355
+ aria-current={isWorkspaceBlocksPath(location.pathname) ? "page" : undefined}
356
+ {...stylex.props(
357
+ styles.railBtn,
358
+ isWorkspaceBlocksPath(location.pathname) && styles.railBtnActive,
359
+ )}
360
+ >
361
+ <ExplorerRailBlocksIcon />
362
+ </Link>
363
+ </Tooltip>
348
364
  {codeHref ? (
349
365
  <Tooltip label="Code session" side="right">
350
366
  <Link
@@ -13,6 +13,7 @@ import {
13
13
  IconGit,
14
14
  IconHistory,
15
15
  IconImages1,
16
+ IconBlocks,
16
17
  IconListBullets,
17
18
  IconMagnifyingGlass,
18
19
  IconPageAdd,
@@ -71,6 +72,10 @@ export function ExplorerRailMediaIcon() {
71
72
  return <Central icon={IconImages1} size={RAIL} />;
72
73
  }
73
74
 
75
+ export function ExplorerRailBlocksIcon() {
76
+ return <Central icon={IconBlocks} size={RAIL} />;
77
+ }
78
+
74
79
  export function ExplorerRailCodeIcon() {
75
80
  return <Central icon={IconCode} size={RAIL} />;
76
81
  }
@@ -3,7 +3,10 @@
3
3
  // so custom inputs and block previews are ordinary React components. The
4
4
  // dashboard runs with an empty definition.
5
5
  import { createContext, useContext, type ComponentType, type ReactNode } from "react";
6
- import type { SchemaField } from "./api";
6
+ import type { BlockPickerView, SchemaField } from "./api";
7
+ import type { StudioBlockGroupConfig } from "./pages/block-groups";
8
+
9
+ export type { StudioBlockGroupConfig };
7
10
 
8
11
  export type StudioFieldInputProps = {
9
12
  /** Field name in the model or block. */
@@ -48,6 +51,14 @@ export type StudioDefinition = {
48
51
  fields?: Record<string, StudioFieldInput>;
49
52
  /** Per block name (as in `defineBlock({ name })`). */
50
53
  blocks?: Record<string, StudioBlockConfig>;
54
+ /**
55
+ * Default layout of the "Add block" picker. A blocks field overrides it with
56
+ * `field.blocks({ picker })`. Default "auto": grouped once there are more
57
+ * than 8 blocks in at least two groups.
58
+ */
59
+ blockPicker?: BlockPickerView;
60
+ /** Per block group name (as in `defineBlock({ group })`): label, cover image, order. */
61
+ blockGroups?: Record<string, StudioBlockGroupConfig>;
51
62
  /** Extra links in the Studio sidebar, e.g. back to the site. */
52
63
  menu?: StudioMenuItem[];
53
64
  };
@@ -237,6 +237,7 @@ function ObjectFieldEditor({
237
237
  onChange,
238
238
  }: SharedFieldProps) {
239
239
  const resolved = resolveObjectFields(field, objects);
240
+ const isSwitch = useIsSwitchField(models);
240
241
  if (!resolved) {
241
242
  return (
242
243
  <JsonField
@@ -255,7 +256,12 @@ function ObjectFieldEditor({
255
256
  const body = (
256
257
  <div {...stylex.props(styles.objectFields)}>
257
258
  {Object.entries(resolved).map(([fieldName, nestedField]) => (
258
- <NestedField key={fieldName} name={fieldName} field={nestedField}>
259
+ <NestedField
260
+ key={fieldName}
261
+ name={fieldName}
262
+ field={nestedField}
263
+ inline={isSwitch(nestedField)}
264
+ >
259
265
  <FieldControl
260
266
  name={`${name}.${fieldName}`}
261
267
  field={nestedField}
@@ -295,14 +301,24 @@ function ObjectFieldEditor({
295
301
  );
296
302
  }
297
303
 
304
+ /** Tells which fields show as a switch, so their row can set it beside the label. */
305
+ export function useIsSwitchField(
306
+ models: Array<{ type: string; external?: boolean }>,
307
+ ): (field: SchemaField) => boolean {
308
+ const definition = useStudioDefinition();
309
+ return (field) => chooseFieldInput(definition, field, models) === "boolean";
310
+ }
311
+
298
312
  /** Composite fields hold their own labeled inputs, so they get a group, not a `<label>`. */
299
313
  function NestedField({
300
314
  name,
301
315
  field,
316
+ inline,
302
317
  children,
303
318
  }: {
304
319
  name: string;
305
320
  field: SchemaField;
321
+ inline: boolean;
306
322
  children: ReactNode;
307
323
  }) {
308
324
  const label = fieldLabel(name, field);
@@ -317,7 +333,7 @@ function NestedField({
317
333
  );
318
334
  }
319
335
  return (
320
- <Field label={label} hint={hint}>
336
+ <Field label={label} hint={hint} inline={inline}>
321
337
  {children}
322
338
  </Field>
323
339
  );
@@ -802,9 +818,10 @@ export function FieldControl({
802
818
  return (
803
819
  <input
804
820
  type="checkbox"
821
+ role="switch"
805
822
  checked={value === true}
806
823
  disabled={readOnly}
807
- {...stylex.props(styles.check)}
824
+ {...stylex.props(styles.switch)}
808
825
  onChange={(event) => {
809
826
  if (readOnly) return;
810
827
  onChange(event.target.checked);
@@ -982,14 +999,55 @@ const styles = stylex.create({
982
999
  backgroundColor: "transparent",
983
1000
  cursor: "pointer",
984
1001
  },
985
- check: {
986
- width: "1rem",
987
- height: "1rem",
1002
+ switch: {
1003
+ appearance: "none",
1004
+ position: "relative",
1005
+ flexShrink: 0,
1006
+ width: "28px",
1007
+ height: "16px",
1008
+ margin: 0,
1009
+ borderRadius: "999px",
1010
+ backgroundColor: colors.border,
1011
+ cursor: "pointer",
1012
+ transitionProperty: "background-color",
1013
+ transitionDuration: "120ms",
1014
+ "::before": {
1015
+ content: '""',
1016
+ position: "absolute",
1017
+ top: "2px",
1018
+ left: "2px",
1019
+ width: "12px",
1020
+ height: "12px",
1021
+ borderRadius: "999px",
1022
+ backgroundColor: colors.bgSurface,
1023
+ boxShadow: "0 1px 2px rgba(0, 0, 0, 0.2)",
1024
+ transitionProperty: "transform",
1025
+ transitionDuration: "120ms",
1026
+ "@media (prefers-reduced-motion: reduce)": {
1027
+ transitionDuration: "0s",
1028
+ },
1029
+ },
1030
+ ":checked": {
1031
+ backgroundColor: colors.accent,
1032
+ },
1033
+ ":checked::before": {
1034
+ transform: "translateX(12px)",
1035
+ },
1036
+ ":disabled": {
1037
+ cursor: "default",
1038
+ opacity: 0.5,
1039
+ },
1040
+ ":focus-visible": {
1041
+ outlineWidth: 2,
1042
+ outlineStyle: "solid",
1043
+ outlineColor: colors.focus,
1044
+ outlineOffset: 2,
1045
+ },
988
1046
  },
989
1047
  objectFields: {
990
1048
  display: "flex",
991
1049
  flexDirection: "column",
992
- gap: space.md,
1050
+ gap: space.lg,
993
1051
  },
994
1052
  nest: {
995
1053
  display: "flex",
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ export { SiteStudio, configureSiteStudio, bounceToEnter, type SiteStudioProps }
4
4
  export {
5
5
  defineStudio,
6
6
  type StudioBlockConfig,
7
+ type StudioBlockGroupConfig,
7
8
  type StudioBlockPreviewProps,
8
9
  type StudioDefinition,
9
10
  type StudioFieldInput,