@backmatter/studio 0.0.22 → 0.0.23
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-CgGyJiC4.js → UiKitApp-DNnsTU4S.js} +2 -2
- package/dist/chunks/{WorkspaceRoutes-CzCBnhNt.js → WorkspaceRoutes-LYgvnqww.js} +19367 -19322
- package/dist/chunks/{dashboard-w-mlsGky.js → dashboard-DGd2D7_c.js} +2 -2
- package/dist/chunks/{index-_XfFuFSU.js → index-BcnHQg9d.js} +1 -1
- package/dist/dashboard.js +2 -2
- package/dist/index.js +2 -2
- package/dist/studio.css +100 -10
- package/package.json +1 -1
- package/src/fields/FieldControl.tsx +65 -7
- package/src/pages/BlocksList.tsx +35 -5
- package/src/pages/DocEditorPage.tsx +6 -9
- package/src/pages/PreviewSize.tsx +48 -3
- package/src/ui/Field.tsx +25 -3
|
@@ -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-
|
|
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-LYgvnqww.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-
|
|
1826
|
+
const Lr = ot(() => import("./UiKitApp-DNnsTU4S.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-
|
|
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-LYgvnqww.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-
|
|
2
|
-
import { G as t, H as f } from "./chunks/WorkspaceRoutes-
|
|
1
|
+
import { A as a, i as s } from "./chunks/dashboard-DGd2D7_c.js";
|
|
2
|
+
import { G as t, H as f } from "./chunks/WorkspaceRoutes-LYgvnqww.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-
|
|
4
|
-
import { X as kt } from "./chunks/WorkspaceRoutes-
|
|
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-LYgvnqww.js";
|
|
4
|
+
import { X as kt } from "./chunks/WorkspaceRoutes-LYgvnqww.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
|
@@ -169,6 +169,10 @@
|
|
|
169
169
|
border-radius: 999px;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
+
.x1pjcqnp {
|
|
173
|
+
border-radius: inherit;
|
|
174
|
+
}
|
|
175
|
+
|
|
172
176
|
.xjdkmwh {
|
|
173
177
|
border-radius: var(--x16ewcrl);
|
|
174
178
|
}
|
|
@@ -581,10 +585,18 @@
|
|
|
581
585
|
align-self: stretch;
|
|
582
586
|
}
|
|
583
587
|
|
|
588
|
+
.xmmqq2k {
|
|
589
|
+
animation-delay: .15s;
|
|
590
|
+
}
|
|
591
|
+
|
|
584
592
|
.x12l1aco {
|
|
585
593
|
animation-duration: .12s;
|
|
586
594
|
}
|
|
587
595
|
|
|
596
|
+
.xtsvl71 {
|
|
597
|
+
animation-duration: .15s;
|
|
598
|
+
}
|
|
599
|
+
|
|
588
600
|
.x5hsz1j {
|
|
589
601
|
animation-duration: .2s;
|
|
590
602
|
}
|
|
@@ -601,6 +613,10 @@
|
|
|
601
613
|
animation-fill-mode: backwards;
|
|
602
614
|
}
|
|
603
615
|
|
|
616
|
+
.x1u6ievf {
|
|
617
|
+
animation-fill-mode: both;
|
|
618
|
+
}
|
|
619
|
+
|
|
604
620
|
.xa4qsjk {
|
|
605
621
|
animation-iteration-count: infinite;
|
|
606
622
|
}
|
|
@@ -633,6 +649,10 @@
|
|
|
633
649
|
animation-timing-function: ease-in-out;
|
|
634
650
|
}
|
|
635
651
|
|
|
652
|
+
.xa3vuyk {
|
|
653
|
+
animation-timing-function: ease-out;
|
|
654
|
+
}
|
|
655
|
+
|
|
636
656
|
.x1esw782 {
|
|
637
657
|
animation-timing-function: linear;
|
|
638
658
|
}
|
|
@@ -1057,6 +1077,10 @@
|
|
|
1057
1077
|
column-gap: 48px;
|
|
1058
1078
|
}
|
|
1059
1079
|
|
|
1080
|
+
.x1q3hsim {
|
|
1081
|
+
column-gap: var(--x1ft7ks7);
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1060
1084
|
.x16qrkmw {
|
|
1061
1085
|
contain: paint;
|
|
1062
1086
|
}
|
|
@@ -1125,6 +1149,10 @@
|
|
|
1125
1149
|
flex-basis: 0%;
|
|
1126
1150
|
}
|
|
1127
1151
|
|
|
1152
|
+
.x1l7klhg {
|
|
1153
|
+
flex-basis: 100%;
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1128
1156
|
.xdl72j9 {
|
|
1129
1157
|
flex-basis: auto;
|
|
1130
1158
|
}
|
|
@@ -1934,6 +1962,10 @@
|
|
|
1934
1962
|
opacity: .8;
|
|
1935
1963
|
}
|
|
1936
1964
|
|
|
1965
|
+
.xtbifol:checked {
|
|
1966
|
+
background-color: var(--x11n7hvk);
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1937
1969
|
.x8w64xv:hover {
|
|
1938
1970
|
background-color: var(--xeg52a);
|
|
1939
1971
|
}
|
|
@@ -2079,6 +2111,10 @@
|
|
|
2079
2111
|
background-color: #e4e4e7;
|
|
2080
2112
|
}
|
|
2081
2113
|
|
|
2114
|
+
.xkfsa8o.xkfsa8o:hover {
|
|
2115
|
+
background-color: color-mix(in srgb,var(--xeg52a) 50%,transparent);
|
|
2116
|
+
}
|
|
2117
|
+
|
|
2082
2118
|
.x9ezvp6.x9ezvp6:hover {
|
|
2083
2119
|
background-color: #18181b;
|
|
2084
2120
|
}
|
|
@@ -2272,10 +2308,6 @@
|
|
|
2272
2308
|
height: 1px;
|
|
2273
2309
|
}
|
|
2274
2310
|
|
|
2275
|
-
.x1l36t39 {
|
|
2276
|
-
height: 1rem;
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
2311
|
.x1qx5ct2 {
|
|
2280
2312
|
height: 20px;
|
|
2281
2313
|
}
|
|
@@ -3032,10 +3064,6 @@
|
|
|
3032
3064
|
width: 1px;
|
|
3033
3065
|
}
|
|
3034
3066
|
|
|
3035
|
-
.xcdlrvm {
|
|
3036
|
-
width: 1rem;
|
|
3037
|
-
}
|
|
3038
|
-
|
|
3039
3067
|
.xvm51jw {
|
|
3040
3068
|
width: 2.5rem;
|
|
3041
3069
|
}
|
|
@@ -3248,6 +3276,22 @@
|
|
|
3248
3276
|
border-bottom-color: var(--x1nzi8h4);
|
|
3249
3277
|
}
|
|
3250
3278
|
|
|
3279
|
+
.x18efcp4:first-child {
|
|
3280
|
+
border-top-left-radius: calc(var(--x83d9l2) - 1px);
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
.xfra7d4:first-child {
|
|
3284
|
+
border-top-right-radius: calc(var(--x83d9l2) - 1px);
|
|
3285
|
+
}
|
|
3286
|
+
|
|
3287
|
+
.xpave9o:last-child {
|
|
3288
|
+
border-bottom-left-radius: calc(var(--x83d9l2) - 1px);
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
.x1m3jluo:last-child {
|
|
3292
|
+
border-bottom-right-radius: calc(var(--x83d9l2) - 1px);
|
|
3293
|
+
}
|
|
3294
|
+
|
|
3251
3295
|
.x1t1lzn6:last-child {
|
|
3252
3296
|
border-bottom-width: 0;
|
|
3253
3297
|
}
|
|
@@ -3305,6 +3349,10 @@
|
|
|
3305
3349
|
.x1d0y9ls:after {
|
|
3306
3350
|
background-position: 0;
|
|
3307
3351
|
}
|
|
3352
|
+
|
|
3353
|
+
.x1n6dlnu:before {
|
|
3354
|
+
border-radius: 999px;
|
|
3355
|
+
}
|
|
3308
3356
|
}
|
|
3309
3357
|
|
|
3310
3358
|
@layer priority7 {
|
|
@@ -3324,6 +3372,10 @@
|
|
|
3324
3372
|
animation-timing-function: linear;
|
|
3325
3373
|
}
|
|
3326
3374
|
|
|
3375
|
+
.x1trpwii:before {
|
|
3376
|
+
background-color: var(--x1dudhym);
|
|
3377
|
+
}
|
|
3378
|
+
|
|
3327
3379
|
.x1ghgi56:after {
|
|
3328
3380
|
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
3381
|
}
|
|
@@ -3336,11 +3388,15 @@
|
|
|
3336
3388
|
background-size: 180px 72px;
|
|
3337
3389
|
}
|
|
3338
3390
|
|
|
3391
|
+
.xuj3ll3:before {
|
|
3392
|
+
box-shadow: 0 1px 2px #0003;
|
|
3393
|
+
}
|
|
3394
|
+
|
|
3339
3395
|
.x9ecp23::placeholder {
|
|
3340
3396
|
color: var(--xw4dauw);
|
|
3341
3397
|
}
|
|
3342
3398
|
|
|
3343
|
-
.x1s928wv:after {
|
|
3399
|
+
.x1cpjm7i:before, .x1s928wv:after {
|
|
3344
3400
|
content: "";
|
|
3345
3401
|
}
|
|
3346
3402
|
|
|
@@ -3348,9 +3404,27 @@
|
|
|
3348
3404
|
pointer-events: none;
|
|
3349
3405
|
}
|
|
3350
3406
|
|
|
3351
|
-
.x1j6awrg:after {
|
|
3407
|
+
.x1hmns74:before, .x1j6awrg:after {
|
|
3352
3408
|
position: absolute;
|
|
3353
3409
|
}
|
|
3410
|
+
|
|
3411
|
+
.xqfulrc:before {
|
|
3412
|
+
transition-duration: .12s;
|
|
3413
|
+
}
|
|
3414
|
+
|
|
3415
|
+
.x1hu8v7x:before {
|
|
3416
|
+
transition-property: transform;
|
|
3417
|
+
}
|
|
3418
|
+
|
|
3419
|
+
.xiop08k:checked:before {
|
|
3420
|
+
transform: translateX(12px);
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3424
|
+
.x13sdc92.x13sdc92:before {
|
|
3425
|
+
transition-duration: 0s;
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3354
3428
|
}
|
|
3355
3429
|
|
|
3356
3430
|
@layer priority8 {
|
|
@@ -3358,14 +3432,30 @@
|
|
|
3358
3432
|
height: 100%;
|
|
3359
3433
|
}
|
|
3360
3434
|
|
|
3435
|
+
.xxt7thn:before {
|
|
3436
|
+
height: 12px;
|
|
3437
|
+
}
|
|
3438
|
+
|
|
3361
3439
|
.x1oly944:after {
|
|
3362
3440
|
left: -180px;
|
|
3363
3441
|
}
|
|
3364
3442
|
|
|
3443
|
+
.x1tymlch:before {
|
|
3444
|
+
left: 2px;
|
|
3445
|
+
}
|
|
3446
|
+
|
|
3365
3447
|
.x1m1drc7:after {
|
|
3366
3448
|
top: 0;
|
|
3367
3449
|
}
|
|
3368
3450
|
|
|
3451
|
+
.xwwlq33:before {
|
|
3452
|
+
top: 2px;
|
|
3453
|
+
}
|
|
3454
|
+
|
|
3455
|
+
.x20nr4a:before {
|
|
3456
|
+
width: 12px;
|
|
3457
|
+
}
|
|
3458
|
+
|
|
3369
3459
|
.x14wh5xp:after {
|
|
3370
3460
|
width: calc(100% + 180px);
|
|
3371
3461
|
}
|
package/package.json
CHANGED
|
@@ -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
|
|
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.
|
|
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
|
-
|
|
986
|
-
|
|
987
|
-
|
|
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.
|
|
1050
|
+
gap: space.lg,
|
|
993
1051
|
},
|
|
994
1052
|
nest: {
|
|
995
1053
|
display: "flex",
|
package/src/pages/BlocksList.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { isSortable, useSortable } from "@dnd-kit/react/sortable";
|
|
|
6
6
|
import * as stylex from "@stylexjs/stylex";
|
|
7
7
|
import type { BlockSnapshot, SchemaField } from "../api";
|
|
8
8
|
import { useBlockConfig } from "../define-studio";
|
|
9
|
-
import { FieldControl } from "../fields/FieldControl";
|
|
9
|
+
import { FieldControl, useIsSwitchField } from "../fields/FieldControl";
|
|
10
10
|
import { fieldLabel } from "../fields/field-label";
|
|
11
11
|
import { omitField } from "../fields/omit-field";
|
|
12
12
|
import { Button } from "../ui/Button";
|
|
@@ -100,6 +100,7 @@ function BlockItem({
|
|
|
100
100
|
const def = catalog.find((b) => b.name === block.type);
|
|
101
101
|
const fieldEntries = Object.entries(def?.fields ?? {});
|
|
102
102
|
const config = useBlockConfig(block.type);
|
|
103
|
+
const isSwitch = useIsSwitchField(models);
|
|
103
104
|
const Preview = config?.preview;
|
|
104
105
|
|
|
105
106
|
return (
|
|
@@ -109,7 +110,16 @@ function BlockItem({
|
|
|
109
110
|
data-block-id={block.id}
|
|
110
111
|
{...stylex.props(styles.item, isDragging && styles.itemDragging)}
|
|
111
112
|
>
|
|
112
|
-
<div
|
|
113
|
+
<div
|
|
114
|
+
data-block-bar=""
|
|
115
|
+
{...stylex.props(styles.itemBar)}
|
|
116
|
+
// The label button carries the keyboard and screen reader toggle;
|
|
117
|
+
// its click bubbles here, and so does a click on the row around it.
|
|
118
|
+
onClick={(event) => {
|
|
119
|
+
if ((event.target as Element).closest("[data-drag-handle], [data-block-actions]")) return;
|
|
120
|
+
onToggle();
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
113
123
|
<button
|
|
114
124
|
ref={handleRef}
|
|
115
125
|
type="button"
|
|
@@ -123,9 +133,9 @@ function BlockItem({
|
|
|
123
133
|
</button>
|
|
124
134
|
<button
|
|
125
135
|
type="button"
|
|
136
|
+
data-block-toggle=""
|
|
126
137
|
{...stylex.props(styles.toggle)}
|
|
127
138
|
aria-expanded={open}
|
|
128
|
-
onClick={onToggle}
|
|
129
139
|
>
|
|
130
140
|
{config?.icon ? (
|
|
131
141
|
<span {...stylex.props(styles.icon)} aria-hidden>
|
|
@@ -136,7 +146,7 @@ function BlockItem({
|
|
|
136
146
|
{config?.label ?? block.type}
|
|
137
147
|
</Text>
|
|
138
148
|
</button>
|
|
139
|
-
<div {...stylex.props(styles.itemActions)}>
|
|
149
|
+
<div data-block-actions="" {...stylex.props(styles.itemActions)}>
|
|
140
150
|
<Button
|
|
141
151
|
variant="ghost"
|
|
142
152
|
disabled={readOnly}
|
|
@@ -170,6 +180,7 @@ function BlockItem({
|
|
|
170
180
|
<Field
|
|
171
181
|
key={name}
|
|
172
182
|
label={fieldLabel(name, field)}
|
|
183
|
+
inline={isSwitch(field)}
|
|
173
184
|
hint={
|
|
174
185
|
field.description ? (
|
|
175
186
|
<span {...stylex.props(styles.fieldGuidance)}>{field.description}</span>
|
|
@@ -338,8 +349,16 @@ const styles = stylex.create({
|
|
|
338
349
|
borderBottomStyle: "solid",
|
|
339
350
|
borderBottomColor: colors.border,
|
|
340
351
|
backgroundColor: colors.bgSurface,
|
|
352
|
+
// The list stays overflow-visible for menus and drag, so the end rows
|
|
353
|
+
// round their own corners to sit inside its border.
|
|
354
|
+
":first-child": {
|
|
355
|
+
borderTopLeftRadius: `calc(${radius.md} - 1px)`,
|
|
356
|
+
borderTopRightRadius: `calc(${radius.md} - 1px)`,
|
|
357
|
+
},
|
|
341
358
|
":last-child": {
|
|
342
359
|
borderBottomWidth: 0,
|
|
360
|
+
borderBottomLeftRadius: `calc(${radius.md} - 1px)`,
|
|
361
|
+
borderBottomRightRadius: `calc(${radius.md} - 1px)`,
|
|
343
362
|
},
|
|
344
363
|
},
|
|
345
364
|
itemDragging: {
|
|
@@ -368,6 +387,16 @@ const styles = stylex.create({
|
|
|
368
387
|
paddingInlineEnd: space.md,
|
|
369
388
|
paddingInlineStart: space.xs,
|
|
370
389
|
paddingBlock: space.sm,
|
|
390
|
+
// Follows the row's rounded end corners so the hover stays inside them.
|
|
391
|
+
borderRadius: "inherit",
|
|
392
|
+
cursor: "pointer",
|
|
393
|
+
transitionProperty: "background-color",
|
|
394
|
+
transitionDuration: "120ms",
|
|
395
|
+
[hover]: {
|
|
396
|
+
":hover": {
|
|
397
|
+
backgroundColor: `color-mix(in srgb, ${colors.bgHover} 50%, transparent)`,
|
|
398
|
+
},
|
|
399
|
+
},
|
|
371
400
|
},
|
|
372
401
|
handle: {
|
|
373
402
|
display: "inline-flex",
|
|
@@ -412,6 +441,7 @@ const styles = stylex.create({
|
|
|
412
441
|
color: colors.text,
|
|
413
442
|
font: "inherit",
|
|
414
443
|
textAlign: "start",
|
|
444
|
+
cursor: "pointer",
|
|
415
445
|
},
|
|
416
446
|
itemActions: {
|
|
417
447
|
display: "flex",
|
|
@@ -421,7 +451,7 @@ const styles = stylex.create({
|
|
|
421
451
|
itemBody: {
|
|
422
452
|
display: "flex",
|
|
423
453
|
flexDirection: "column",
|
|
424
|
-
gap: space.
|
|
454
|
+
gap: space.xl,
|
|
425
455
|
paddingInline: space.md,
|
|
426
456
|
paddingBottom: space.md,
|
|
427
457
|
},
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
type SchemaPayload,
|
|
21
21
|
type SchemaField,
|
|
22
22
|
} from "../api";
|
|
23
|
-
import { FieldControl } from "../fields/FieldControl";
|
|
23
|
+
import { FieldControl, useIsSwitchField } from "../fields/FieldControl";
|
|
24
24
|
import { loadRelationDocuments } from "../fields/load-relation-documents";
|
|
25
25
|
import { omitField } from "../fields/omit-field";
|
|
26
26
|
import { linkDocumentTypes } from "../fields/link-targets";
|
|
@@ -198,6 +198,7 @@ export function DocEditorPage() {
|
|
|
198
198
|
const [confirmRevert, setConfirmRevert] = useState(false);
|
|
199
199
|
const [saveState, setSaveState] = useState<SaveState>("idle");
|
|
200
200
|
const [previewKey, setPreviewKey] = useState(0);
|
|
201
|
+
const isSwitch = useIsSwitchField(models);
|
|
201
202
|
const [previewLoading, setPreviewLoading] = useState(true);
|
|
202
203
|
const [previewFrame, setPreviewFrame] = useState(0);
|
|
203
204
|
const [previewOffer, setPreviewOffer] = useState<PreviewChannelRef | null>(null);
|
|
@@ -976,7 +977,7 @@ export function DocEditorPage() {
|
|
|
976
977
|
</div>
|
|
977
978
|
</div>
|
|
978
979
|
{previewUrl ? (
|
|
979
|
-
<PreviewViewport size={previewSize} dragging={dragging}>
|
|
980
|
+
<PreviewViewport size={previewSize} dragging={dragging} loading={previewLoading}>
|
|
980
981
|
<iframe
|
|
981
982
|
key={`${previewKey}-${previewUrl}`}
|
|
982
983
|
ref={previewFrameRef}
|
|
@@ -1005,11 +1006,7 @@ export function DocEditorPage() {
|
|
|
1005
1006
|
</Link>
|
|
1006
1007
|
</div>
|
|
1007
1008
|
) : (
|
|
1008
|
-
<
|
|
1009
|
-
{...stylex.props(styles.iframe)}
|
|
1010
|
-
aria-busy="true"
|
|
1011
|
-
aria-label="Preview waiting for checkout"
|
|
1012
|
-
/>
|
|
1009
|
+
<PreviewViewport size={previewSize} loading loadingLabel="Loading checkout…" />
|
|
1013
1010
|
)}
|
|
1014
1011
|
</aside>
|
|
1015
1012
|
|
|
@@ -1129,7 +1126,7 @@ export function DocEditorPage() {
|
|
|
1129
1126
|
detailNames.map((name) => {
|
|
1130
1127
|
const field = fieldDefs[name]!;
|
|
1131
1128
|
return (
|
|
1132
|
-
<Field key={name} label={fieldLabel(name)}>
|
|
1129
|
+
<Field key={name} label={fieldLabel(name)} inline={isSwitch(field)}>
|
|
1133
1130
|
<FieldControl
|
|
1134
1131
|
name={name}
|
|
1135
1132
|
field={field}
|
|
@@ -1532,7 +1529,7 @@ const styles = stylex.create({
|
|
|
1532
1529
|
form: {
|
|
1533
1530
|
display: "flex",
|
|
1534
1531
|
flexDirection: "column",
|
|
1535
|
-
gap: space.
|
|
1532
|
+
gap: space.xl,
|
|
1536
1533
|
paddingBottom: space.xxl,
|
|
1537
1534
|
},
|
|
1538
1535
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// packages/studio/src/pages/PreviewSize.tsx
|
|
2
2
|
import type { KeyboardEvent, ReactNode } from "react";
|
|
3
3
|
import * as stylex from "@stylexjs/stylex";
|
|
4
|
+
import { Snake } from "loading-dev";
|
|
4
5
|
import {
|
|
5
6
|
IconImac,
|
|
6
7
|
IconPhone,
|
|
7
8
|
IconTablet,
|
|
8
9
|
} from "@central-icons-react/round-outlined-radius-2-stroke-1.5";
|
|
9
|
-
import { colors, radius } from "../styles/tokens.stylex";
|
|
10
|
+
import { colors, radius, space } from "../styles/tokens.stylex";
|
|
11
|
+
import { Text } from "../ui/Text";
|
|
10
12
|
import { Tooltip } from "../ui/Tooltip";
|
|
11
13
|
import {
|
|
12
14
|
previewFrameWidth,
|
|
@@ -77,15 +79,22 @@ export function PreviewSizeSwitch({
|
|
|
77
79
|
);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Centers a fixed-width preview and scrolls sideways when the pane is narrower.
|
|
84
|
+
* While `loading`, a loader covers the page until it has something to show.
|
|
85
|
+
*/
|
|
81
86
|
export function PreviewViewport({
|
|
82
87
|
size,
|
|
83
88
|
dragging = false,
|
|
89
|
+
loading = false,
|
|
90
|
+
loadingLabel = "Loading preview…",
|
|
84
91
|
children,
|
|
85
92
|
}: {
|
|
86
93
|
size: PreviewSize;
|
|
87
94
|
dragging?: boolean;
|
|
88
|
-
|
|
95
|
+
loading?: boolean;
|
|
96
|
+
loadingLabel?: string;
|
|
97
|
+
children?: ReactNode;
|
|
89
98
|
}) {
|
|
90
99
|
const width = previewFrameWidth(size);
|
|
91
100
|
const viewport = stylex.props(styles.viewport, dragging && styles.dragging);
|
|
@@ -97,6 +106,14 @@ export function PreviewViewport({
|
|
|
97
106
|
style={width === null ? slot.style : { ...slot.style, width }}
|
|
98
107
|
>
|
|
99
108
|
{children}
|
|
109
|
+
{loading ? (
|
|
110
|
+
<div role="status" {...stylex.props(styles.loader)}>
|
|
111
|
+
<span {...stylex.props(styles.loaderMark)} aria-hidden>
|
|
112
|
+
<Snake size={20} />
|
|
113
|
+
</span>
|
|
114
|
+
<Text tone="muted" size="sm">{loadingLabel}</Text>
|
|
115
|
+
</div>
|
|
116
|
+
) : null}
|
|
100
117
|
</div>
|
|
101
118
|
</div>
|
|
102
119
|
);
|
|
@@ -104,6 +121,11 @@ export function PreviewViewport({
|
|
|
104
121
|
|
|
105
122
|
const hover = "@media (hover: hover)";
|
|
106
123
|
|
|
124
|
+
const appear = stylex.keyframes({
|
|
125
|
+
from: { opacity: 0 },
|
|
126
|
+
to: { opacity: 1 },
|
|
127
|
+
});
|
|
128
|
+
|
|
107
129
|
const styles = stylex.create({
|
|
108
130
|
group: {
|
|
109
131
|
display: "inline-flex",
|
|
@@ -170,6 +192,29 @@ const styles = stylex.create({
|
|
|
170
192
|
minHeight: 0,
|
|
171
193
|
backgroundColor: colors.bgSurface,
|
|
172
194
|
},
|
|
195
|
+
loader: {
|
|
196
|
+
position: "absolute",
|
|
197
|
+
inset: 0,
|
|
198
|
+
display: "flex",
|
|
199
|
+
flexDirection: "column",
|
|
200
|
+
alignItems: "center",
|
|
201
|
+
justifyContent: "center",
|
|
202
|
+
gap: space.md,
|
|
203
|
+
backgroundColor: colors.bgSurface,
|
|
204
|
+
// A page that loads at once never shows the loader.
|
|
205
|
+
animationName: appear,
|
|
206
|
+
animationDuration: "150ms",
|
|
207
|
+
animationDelay: "150ms",
|
|
208
|
+
animationTimingFunction: "ease-out",
|
|
209
|
+
animationFillMode: "both",
|
|
210
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
211
|
+
animationName: "none",
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
loaderMark: {
|
|
215
|
+
display: "flex",
|
|
216
|
+
color: colors.textMuted,
|
|
217
|
+
},
|
|
173
218
|
slotFixed: {
|
|
174
219
|
flexGrow: 0,
|
|
175
220
|
flexShrink: 0,
|