@snap-rail/ui 0.4.1 → 0.4.2

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/lib/contract.js CHANGED
@@ -52,6 +52,12 @@ const UI_SLOT_MODES = {
52
52
  [UI_SLOT_IDS.settingsEntry]: "one",
53
53
  [UI_SLOT_IDS.settingsSurface]: "one"
54
54
  };
55
+ /** The window controls a layout exposes to its chrome contributions. */
56
+ const WINDOW_CONTROLS = [
57
+ "minimize",
58
+ "toggle-maximize",
59
+ "close"
60
+ ];
55
61
  /** Diagnostic kinds surfaced by the UI registry. */
56
62
  const UI_DIAGNOSTIC_KINDS = [
57
63
  "unknown-slot",
@@ -591,4 +597,4 @@ const UI_COMPONENTS = {
591
597
  ] }
592
598
  };
593
599
  //#endregion
594
- export { CUSTOM_SLOT_PATTERN, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, isValidSlotId };
600
+ export { CUSTOM_SLOT_PATTERN, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, WINDOW_CONTROLS, isValidSlotId };
package/lib/fallback.js CHANGED
@@ -265,6 +265,12 @@ const UI_SLOT_IDS = {
265
265
  settingsSurface: "settings.surface"
266
266
  };
267
267
  UI_SLOT_IDS.layout, UI_SLOT_IDS.titlebar, UI_SLOT_IDS.titlebarActions, UI_SLOT_IDS.sidebar, UI_SLOT_IDS.statusbar, UI_SLOT_IDS.overlay, UI_SLOT_IDS.ball, UI_SLOT_IDS.settingsEntry, UI_SLOT_IDS.settingsSurface;
268
+ /** The window controls a layout exposes to its chrome contributions. */
269
+ const WINDOW_CONTROLS = [
270
+ "minimize",
271
+ "toggle-maximize",
272
+ "close"
273
+ ];
268
274
  //#endregion
269
275
  //#region lib/types/pages.js
270
276
  /**
@@ -336,15 +342,14 @@ function Glyph(props) {
336
342
  children: props.children
337
343
  });
338
344
  }
339
- /** The fallback body. */
340
- function FallbackShell(props) {
341
- useUiVersion(props.ctx.ui);
342
- usePagesVersion(props.ctx);
343
- const active = props.ctx.pages.active();
344
- const control = (action) => {
345
- props.ctx.client.link.call("window.control", { action }).catch(() => {});
346
- };
347
- const header = jsxs("div", {
345
+ /**
346
+ * The fallback titlebar: the product name and the active page on the left; the
347
+ * contributed `shell.titlebar.actions`, the settings seat, and the window
348
+ * controls on the right. The whole bar is replaced when a plugin occupies
349
+ * `shell.titlebar` — that occupant then owns its own controls.
350
+ */
351
+ function DefaultTitlebar(props) {
352
+ return jsxs("div", {
348
353
  className: "snap-fallback-titlebar",
349
354
  style: {
350
355
  display: "flex",
@@ -358,7 +363,7 @@ function FallbackShell(props) {
358
363
  color: "var(--snap-color-muted)",
359
364
  fontSize: "var(--snap-text-sm)"
360
365
  },
361
- children: ["snap-rail", active !== void 0 ? ` · ${active.title}` : ""]
366
+ children: ["snap-rail", props.title !== void 0 ? ` · ${props.title}` : ""]
362
367
  }), jsxs("div", {
363
368
  style: {
364
369
  display: "flex",
@@ -366,6 +371,13 @@ function FallbackShell(props) {
366
371
  gap: 4
367
372
  },
368
373
  children: [
374
+ jsx(Slot$1, {
375
+ name: UI_SLOT_IDS.titlebarActions,
376
+ context: {
377
+ surface: "main",
378
+ controls: WINDOW_CONTROLS
379
+ }
380
+ }),
369
381
  jsx(Slot$1, {
370
382
  name: UI_SLOT_IDS.settingsEntry,
371
383
  context: {
@@ -377,23 +389,78 @@ function FallbackShell(props) {
377
389
  jsx(IconButton, {
378
390
  icon: jsx(Glyph, { children: "—" }),
379
391
  label: "最小化",
380
- onClick: () => control("minimize")
392
+ onClick: () => props.control("minimize")
381
393
  }),
382
394
  jsx(IconButton, {
383
395
  icon: jsx(Glyph, { children: "□" }),
384
396
  label: "最大化切换",
385
- onClick: () => control("toggle-maximize")
397
+ onClick: () => props.control("toggle-maximize")
386
398
  }),
387
399
  jsx(IconButton, {
388
400
  icon: jsx(Glyph, { children: "×" }),
389
401
  label: "关闭",
390
- onClick: () => control("close")
402
+ onClick: () => props.control("close")
391
403
  })
392
404
  ]
393
405
  })]
394
406
  });
407
+ }
408
+ /** The fallback body. */
409
+ function FallbackShell(props) {
410
+ useUiVersion(props.ctx.ui);
411
+ usePagesVersion(props.ctx);
412
+ const active = props.ctx.pages.active();
413
+ const control = (action) => {
414
+ props.ctx.client.link.call("window.control", { action }).catch(() => {});
415
+ };
416
+ const titlebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.titlebar).length > 0;
417
+ const sidebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.sidebar).length > 0;
418
+ const statusbarOccupied = props.ctx.ui.list(UI_SLOT_IDS.statusbar).length > 0;
419
+ const header = titlebarOccupied ? jsx(Slot$1, {
420
+ name: UI_SLOT_IDS.titlebar,
421
+ context: {
422
+ surface: "main",
423
+ controls: WINDOW_CONTROLS
424
+ }
425
+ }) : jsx(DefaultTitlebar, {
426
+ ctx: props.ctx,
427
+ title: active?.title,
428
+ control
429
+ });
430
+ const sidebar = sidebarOccupied ? jsx("div", {
431
+ className: "snap-fallback-sidebar",
432
+ style: {
433
+ display: "flex",
434
+ flexDirection: "column",
435
+ height: "100%",
436
+ minHeight: 0,
437
+ padding: "4px 8px"
438
+ },
439
+ children: jsx(Slot$1, {
440
+ name: UI_SLOT_IDS.sidebar,
441
+ context: { surface: "main" }
442
+ })
443
+ }) : void 0;
444
+ const statusbar = statusbarOccupied ? jsx("div", {
445
+ className: "snap-fallback-statusbar",
446
+ style: {
447
+ display: "flex",
448
+ alignItems: "center",
449
+ gap: 12,
450
+ minHeight: 28,
451
+ padding: "0 12px",
452
+ color: "var(--snap-color-muted)",
453
+ fontSize: "var(--snap-text-sm)"
454
+ },
455
+ children: jsx(Slot$1, {
456
+ name: UI_SLOT_IDS.statusbar,
457
+ context: { surface: "main" }
458
+ })
459
+ }) : void 0;
395
460
  return jsx(AppShell, {
396
461
  header,
462
+ ...sidebar !== void 0 ? { sidebar } : {},
463
+ ...statusbar !== void 0 ? { footer: statusbar } : {},
397
464
  children: active !== void 0 ? active.render() : jsx("div", {
398
465
  style: {
399
466
  display: "flex",
package/lib/index.js CHANGED
@@ -79,6 +79,12 @@ const UI_SLOT_MODES = {
79
79
  [UI_SLOT_IDS.settingsEntry]: "one",
80
80
  [UI_SLOT_IDS.settingsSurface]: "one"
81
81
  };
82
+ /** The window controls a layout exposes to its chrome contributions. */
83
+ const WINDOW_CONTROLS = [
84
+ "minimize",
85
+ "toggle-maximize",
86
+ "close"
87
+ ];
82
88
  /** Diagnostic kinds surfaced by the UI registry. */
83
89
  const UI_DIAGNOSTIC_KINDS = [
84
90
  "unknown-slot",
@@ -3414,15 +3420,14 @@ function Glyph(props) {
3414
3420
  children: props.children
3415
3421
  });
3416
3422
  }
3417
- /** The fallback body. */
3418
- function FallbackShell(props) {
3419
- useUiVersion(props.ctx.ui);
3420
- usePagesVersion(props.ctx);
3421
- const active = props.ctx.pages.active();
3422
- const control = (action) => {
3423
- props.ctx.client.link.call("window.control", { action }).catch(() => {});
3424
- };
3425
- const header = jsxs("div", {
3423
+ /**
3424
+ * The fallback titlebar: the product name and the active page on the left; the
3425
+ * contributed `shell.titlebar.actions`, the settings seat, and the window
3426
+ * controls on the right. The whole bar is replaced when a plugin occupies
3427
+ * `shell.titlebar` — that occupant then owns its own controls.
3428
+ */
3429
+ function DefaultTitlebar(props) {
3430
+ return jsxs("div", {
3426
3431
  className: "snap-fallback-titlebar",
3427
3432
  style: {
3428
3433
  display: "flex",
@@ -3436,7 +3441,7 @@ function FallbackShell(props) {
3436
3441
  color: "var(--snap-color-muted)",
3437
3442
  fontSize: "var(--snap-text-sm)"
3438
3443
  },
3439
- children: ["snap-rail", active !== void 0 ? ` · ${active.title}` : ""]
3444
+ children: ["snap-rail", props.title !== void 0 ? ` · ${props.title}` : ""]
3440
3445
  }), jsxs("div", {
3441
3446
  style: {
3442
3447
  display: "flex",
@@ -3444,6 +3449,13 @@ function FallbackShell(props) {
3444
3449
  gap: 4
3445
3450
  },
3446
3451
  children: [
3452
+ jsx(Slot, {
3453
+ name: UI_SLOT_IDS.titlebarActions,
3454
+ context: {
3455
+ surface: "main",
3456
+ controls: WINDOW_CONTROLS
3457
+ }
3458
+ }),
3447
3459
  jsx(Slot, {
3448
3460
  name: UI_SLOT_IDS.settingsEntry,
3449
3461
  context: {
@@ -3455,23 +3467,78 @@ function FallbackShell(props) {
3455
3467
  jsx(IconButton, {
3456
3468
  icon: jsx(Glyph, { children: "—" }),
3457
3469
  label: "最小化",
3458
- onClick: () => control("minimize")
3470
+ onClick: () => props.control("minimize")
3459
3471
  }),
3460
3472
  jsx(IconButton, {
3461
3473
  icon: jsx(Glyph, { children: "□" }),
3462
3474
  label: "最大化切换",
3463
- onClick: () => control("toggle-maximize")
3475
+ onClick: () => props.control("toggle-maximize")
3464
3476
  }),
3465
3477
  jsx(IconButton, {
3466
3478
  icon: jsx(Glyph, { children: "×" }),
3467
3479
  label: "关闭",
3468
- onClick: () => control("close")
3480
+ onClick: () => props.control("close")
3469
3481
  })
3470
3482
  ]
3471
3483
  })]
3472
3484
  });
3485
+ }
3486
+ /** The fallback body. */
3487
+ function FallbackShell(props) {
3488
+ useUiVersion(props.ctx.ui);
3489
+ usePagesVersion(props.ctx);
3490
+ const active = props.ctx.pages.active();
3491
+ const control = (action) => {
3492
+ props.ctx.client.link.call("window.control", { action }).catch(() => {});
3493
+ };
3494
+ const titlebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.titlebar).length > 0;
3495
+ const sidebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.sidebar).length > 0;
3496
+ const statusbarOccupied = props.ctx.ui.list(UI_SLOT_IDS.statusbar).length > 0;
3497
+ const header = titlebarOccupied ? jsx(Slot, {
3498
+ name: UI_SLOT_IDS.titlebar,
3499
+ context: {
3500
+ surface: "main",
3501
+ controls: WINDOW_CONTROLS
3502
+ }
3503
+ }) : jsx(DefaultTitlebar, {
3504
+ ctx: props.ctx,
3505
+ title: active?.title,
3506
+ control
3507
+ });
3508
+ const sidebar = sidebarOccupied ? jsx("div", {
3509
+ className: "snap-fallback-sidebar",
3510
+ style: {
3511
+ display: "flex",
3512
+ flexDirection: "column",
3513
+ height: "100%",
3514
+ minHeight: 0,
3515
+ padding: "4px 8px"
3516
+ },
3517
+ children: jsx(Slot, {
3518
+ name: UI_SLOT_IDS.sidebar,
3519
+ context: { surface: "main" }
3520
+ })
3521
+ }) : void 0;
3522
+ const statusbar = statusbarOccupied ? jsx("div", {
3523
+ className: "snap-fallback-statusbar",
3524
+ style: {
3525
+ display: "flex",
3526
+ alignItems: "center",
3527
+ gap: 12,
3528
+ minHeight: 28,
3529
+ padding: "0 12px",
3530
+ color: "var(--snap-color-muted)",
3531
+ fontSize: "var(--snap-text-sm)"
3532
+ },
3533
+ children: jsx(Slot, {
3534
+ name: UI_SLOT_IDS.statusbar,
3535
+ context: { surface: "main" }
3536
+ })
3537
+ }) : void 0;
3473
3538
  return jsx(AppShell, {
3474
3539
  header,
3540
+ ...sidebar !== void 0 ? { sidebar } : {},
3541
+ ...statusbar !== void 0 ? { footer: statusbar } : {},
3475
3542
  children: active !== void 0 ? active.render() : jsx("div", {
3476
3543
  style: {
3477
3544
  display: "flex",
@@ -5320,4 +5387,4 @@ async function createClientRuntime(handle, options) {
5320
5387
  };
5321
5388
  }
5322
5389
  //#endregion
5323
- export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, CUSTOM_SLOT_PATTERN, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartFrame, Checkbox, ClientProvider, Combobox, Controller, DEFAULT_DARK, DEFAULT_DARK_ID, DEFAULT_LIGHT, DEFAULT_LIGHT_ID, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, SettingsEntry, SettingsSurface, Sheet, Skeleton, SkinsProvider, Slider, Slot, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, UiProvider, Visualization, attachBallDrag, attachDragPan, chartThemeOf, cn, controlHeight, createClientRuntime, dismissToast, fallbackPlugin, isValidSlotId, literalValuesOf, pagesPlugin, part, schemaNodeOf, settingsPageInfo, settingsPlugin, skinTokenVar, skinsPlugin, slotsPlugin, space, toast, useActiveLayout, useChartTheme, useClient, useController, useFieldArray, useForm, useFormContext, useFormState, usePagesVersion, useSkinId, useSkinTokens, useSkins, useUi, useUiVersion, useWatch, zodResolver };
5390
+ export { Alert, AlertDescription, AlertTitle, AppShell, Badge, Button, CUSTOM_SLOT_PATTERN, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, ChartFrame, Checkbox, ClientProvider, Combobox, Controller, DEFAULT_DARK, DEFAULT_DARK_ID, DEFAULT_LIGHT, DEFAULT_LIGHT_ID, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, DragScroll, EmptyState, Field, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, FormProvider, Grid, IconButton, Input, Label, Led, List, ListItem, Menu, MenuCheckboxItem, MenuContent, MenuGroup, MenuItem, MenuLabel, MenuSeparator, MenuTrigger, NumberInput, Page, Panel, Popover, PopoverAnchor, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, Row, SchemaForm, ScrollArea, Section, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectTrigger, SelectValue, Separator, SettingsEntry, SettingsSurface, Sheet, Skeleton, SkinsProvider, Slider, Slot, Spinner, Split, Stack, Switch, Table, TableBody, TableCell, TableEmpty, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toaster, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TouchSelect, UI_COMPONENTS, UI_DIAGNOSTIC_KINDS, UI_PROFILES, UI_SLOT_IDS, UI_SLOT_MODES, UiProvider, Visualization, WINDOW_CONTROLS, attachBallDrag, attachDragPan, chartThemeOf, cn, controlHeight, createClientRuntime, dismissToast, fallbackPlugin, isValidSlotId, literalValuesOf, pagesPlugin, part, schemaNodeOf, settingsPageInfo, settingsPlugin, skinTokenVar, skinsPlugin, slotsPlugin, space, toast, useActiveLayout, useChartTheme, useClient, useController, useFieldArray, useForm, useFormContext, useFormState, usePagesVersion, useSkinId, useSkinTokens, useSkins, useUi, useUiVersion, useWatch, zodResolver };
package/lib/runtime.js CHANGED
@@ -690,6 +690,12 @@ const UI_SLOT_MODES = {
690
690
  [UI_SLOT_IDS.settingsEntry]: "one",
691
691
  [UI_SLOT_IDS.settingsSurface]: "one"
692
692
  };
693
+ /** The window controls a layout exposes to its chrome contributions. */
694
+ const WINDOW_CONTROLS = [
695
+ "minimize",
696
+ "toggle-maximize",
697
+ "close"
698
+ ];
693
699
  //#endregion
694
700
  //#region lib/types/pages.js
695
701
  /**
@@ -989,15 +995,14 @@ function Glyph(props) {
989
995
  children: props.children
990
996
  });
991
997
  }
992
- /** The fallback body. */
993
- function FallbackShell(props) {
994
- useUiVersion(props.ctx.ui);
995
- usePagesVersion(props.ctx);
996
- const active = props.ctx.pages.active();
997
- const control = (action) => {
998
- props.ctx.client.link.call("window.control", { action }).catch(() => {});
999
- };
1000
- const header = jsxs("div", {
998
+ /**
999
+ * The fallback titlebar: the product name and the active page on the left; the
1000
+ * contributed `shell.titlebar.actions`, the settings seat, and the window
1001
+ * controls on the right. The whole bar is replaced when a plugin occupies
1002
+ * `shell.titlebar` — that occupant then owns its own controls.
1003
+ */
1004
+ function DefaultTitlebar(props) {
1005
+ return jsxs("div", {
1001
1006
  className: "snap-fallback-titlebar",
1002
1007
  style: {
1003
1008
  display: "flex",
@@ -1011,7 +1016,7 @@ function FallbackShell(props) {
1011
1016
  color: "var(--snap-color-muted)",
1012
1017
  fontSize: "var(--snap-text-sm)"
1013
1018
  },
1014
- children: ["snap-rail", active !== void 0 ? ` · ${active.title}` : ""]
1019
+ children: ["snap-rail", props.title !== void 0 ? ` · ${props.title}` : ""]
1015
1020
  }), jsxs("div", {
1016
1021
  style: {
1017
1022
  display: "flex",
@@ -1019,6 +1024,13 @@ function FallbackShell(props) {
1019
1024
  gap: 4
1020
1025
  },
1021
1026
  children: [
1027
+ jsx(Slot, {
1028
+ name: UI_SLOT_IDS.titlebarActions,
1029
+ context: {
1030
+ surface: "main",
1031
+ controls: WINDOW_CONTROLS
1032
+ }
1033
+ }),
1022
1034
  jsx(Slot, {
1023
1035
  name: UI_SLOT_IDS.settingsEntry,
1024
1036
  context: {
@@ -1030,23 +1042,78 @@ function FallbackShell(props) {
1030
1042
  jsx(IconButton, {
1031
1043
  icon: jsx(Glyph, { children: "—" }),
1032
1044
  label: "最小化",
1033
- onClick: () => control("minimize")
1045
+ onClick: () => props.control("minimize")
1034
1046
  }),
1035
1047
  jsx(IconButton, {
1036
1048
  icon: jsx(Glyph, { children: "□" }),
1037
1049
  label: "最大化切换",
1038
- onClick: () => control("toggle-maximize")
1050
+ onClick: () => props.control("toggle-maximize")
1039
1051
  }),
1040
1052
  jsx(IconButton, {
1041
1053
  icon: jsx(Glyph, { children: "×" }),
1042
1054
  label: "关闭",
1043
- onClick: () => control("close")
1055
+ onClick: () => props.control("close")
1044
1056
  })
1045
1057
  ]
1046
1058
  })]
1047
1059
  });
1060
+ }
1061
+ /** The fallback body. */
1062
+ function FallbackShell(props) {
1063
+ useUiVersion(props.ctx.ui);
1064
+ usePagesVersion(props.ctx);
1065
+ const active = props.ctx.pages.active();
1066
+ const control = (action) => {
1067
+ props.ctx.client.link.call("window.control", { action }).catch(() => {});
1068
+ };
1069
+ const titlebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.titlebar).length > 0;
1070
+ const sidebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.sidebar).length > 0;
1071
+ const statusbarOccupied = props.ctx.ui.list(UI_SLOT_IDS.statusbar).length > 0;
1072
+ const header = titlebarOccupied ? jsx(Slot, {
1073
+ name: UI_SLOT_IDS.titlebar,
1074
+ context: {
1075
+ surface: "main",
1076
+ controls: WINDOW_CONTROLS
1077
+ }
1078
+ }) : jsx(DefaultTitlebar, {
1079
+ ctx: props.ctx,
1080
+ title: active?.title,
1081
+ control
1082
+ });
1083
+ const sidebar = sidebarOccupied ? jsx("div", {
1084
+ className: "snap-fallback-sidebar",
1085
+ style: {
1086
+ display: "flex",
1087
+ flexDirection: "column",
1088
+ height: "100%",
1089
+ minHeight: 0,
1090
+ padding: "4px 8px"
1091
+ },
1092
+ children: jsx(Slot, {
1093
+ name: UI_SLOT_IDS.sidebar,
1094
+ context: { surface: "main" }
1095
+ })
1096
+ }) : void 0;
1097
+ const statusbar = statusbarOccupied ? jsx("div", {
1098
+ className: "snap-fallback-statusbar",
1099
+ style: {
1100
+ display: "flex",
1101
+ alignItems: "center",
1102
+ gap: 12,
1103
+ minHeight: 28,
1104
+ padding: "0 12px",
1105
+ color: "var(--snap-color-muted)",
1106
+ fontSize: "var(--snap-text-sm)"
1107
+ },
1108
+ children: jsx(Slot, {
1109
+ name: UI_SLOT_IDS.statusbar,
1110
+ context: { surface: "main" }
1111
+ })
1112
+ }) : void 0;
1048
1113
  return jsx(AppShell, {
1049
1114
  header,
1115
+ ...sidebar !== void 0 ? { sidebar } : {},
1116
+ ...statusbar !== void 0 ? { footer: statusbar } : {},
1050
1117
  children: active !== void 0 ? active.render() : jsx("div", {
1051
1118
  style: {
1052
1119
  display: "flex",
@@ -54,8 +54,10 @@ export declare const UI_SLOT_MODES: {
54
54
  readonly "settings.entry": "one";
55
55
  readonly "settings.surface": "one";
56
56
  };
57
+ /** The window controls a layout exposes to its chrome contributions. */
58
+ export declare const WINDOW_CONTROLS: readonly ["minimize", "toggle-maximize", "close"];
57
59
  /** The operator-window controls a layout exposes to chrome contributions. */
58
- export type WindowControl = 'minimize' | 'toggle-maximize' | 'close';
60
+ export type WindowControl = (typeof WINDOW_CONTROLS)[number];
59
61
  /** The context a settings trigger receives from the layout that hosts it. */
60
62
  export interface SettingsEntryContext {
61
63
  /** `icon` for a glyph-only chrome button, `label` for a labelled action. */
@@ -89,11 +91,11 @@ export interface SlotContextMap {
89
91
  };
90
92
  'shell.titlebar': {
91
93
  surface: SurfaceId;
92
- controls: WindowControl;
94
+ controls: readonly WindowControl[];
93
95
  };
94
96
  'shell.titlebar.actions': {
95
97
  surface: SurfaceId;
96
- controls: WindowControl;
98
+ controls: readonly WindowControl[];
97
99
  };
98
100
  'shell.sidebar': {
99
101
  surface: SurfaceId;
@@ -48,6 +48,8 @@ export const UI_SLOT_MODES = {
48
48
  [UI_SLOT_IDS.settingsEntry]: 'one',
49
49
  [UI_SLOT_IDS.settingsSurface]: 'one',
50
50
  };
51
+ /** The window controls a layout exposes to its chrome contributions. */
52
+ export const WINDOW_CONTROLS = ['minimize', 'toggle-maximize', 'close'];
51
53
  /** Diagnostic kinds surfaced by the UI registry. */
52
54
  export const UI_DIAGNOSTIC_KINDS = [
53
55
  'unknown-slot',
@@ -5,6 +5,13 @@
5
5
  * suite layout with higher precedence replaces it and its disposal brings the
6
6
  * fallback back automatically.
7
7
  *
8
+ * It renders **every** slot it declares: `shell.titlebar` and
9
+ * `shell.titlebar.actions` in the window bar, `shell.sidebar` and
10
+ * `shell.statusbar` in the shell frame once something contributes to them,
11
+ * `settings.entry` next to the window controls. A slot declared but never
12
+ * rendered would swallow contributions without a trace, so the two lists stay
13
+ * in step.
14
+ *
8
15
  * @module @snap-rail/ui/fallback
9
16
  */
10
17
  import { type Plugin } from '@snap-rail/cordis';
@@ -1,12 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { AppShell, Button, EmptyState, IconButton } from "./components/index.js";
3
- import { UI_SLOT_IDS } from "./contract.js";
3
+ import { UI_SLOT_IDS, WINDOW_CONTROLS } from "./contract.js";
4
4
  import { usePagesVersion } from "./pages.js";
5
5
  import { Slot, useUiVersion } from "./slots.js";
6
6
  /** A compact glyph for the window controls. */
7
7
  function Glyph(props) {
8
8
  return _jsx("span", { "aria-hidden": "true", style: { lineHeight: 1 }, children: props.children });
9
9
  }
10
+ /**
11
+ * The fallback titlebar: the product name and the active page on the left; the
12
+ * contributed `shell.titlebar.actions`, the settings seat, and the window
13
+ * controls on the right. The whole bar is replaced when a plugin occupies
14
+ * `shell.titlebar` — that occupant then owns its own controls.
15
+ */
16
+ function DefaultTitlebar(props) {
17
+ return (_jsxs("div", { className: "snap-fallback-titlebar", style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', minHeight: 48, paddingLeft: 16 }, children: [_jsxs("span", { style: { color: 'var(--snap-color-muted)', fontSize: 'var(--snap-text-sm)' }, children: ["snap-rail", props.title !== undefined ? ` · ${props.title}` : ''] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(Slot, { name: UI_SLOT_IDS.titlebarActions, context: { surface: 'main', controls: WINDOW_CONTROLS } }), _jsx(Slot, { name: UI_SLOT_IDS.settingsEntry, context: {
18
+ presentation: 'icon',
19
+ open: () => props.ctx.settings.open(),
20
+ isOpen: props.ctx.settings.isOpen(),
21
+ } }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u2014" }), label: "\u6700\u5C0F\u5316", onClick: () => props.control('minimize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u25A1" }), label: "\u6700\u5927\u5316\u5207\u6362", onClick: () => props.control('toggle-maximize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u00D7" }), label: "\u5173\u95ED", onClick: () => props.control('close') })] })] }));
22
+ }
10
23
  /** The fallback body. */
11
24
  function FallbackShell(props) {
12
25
  useUiVersion(props.ctx.ui);
@@ -15,12 +28,31 @@ function FallbackShell(props) {
15
28
  const control = (action) => {
16
29
  void props.ctx.client.link.call('window.control', { action }).catch(() => { });
17
30
  };
18
- const header = (_jsxs("div", { className: "snap-fallback-titlebar", style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', minHeight: 48, paddingLeft: 16 }, children: [_jsxs("span", { style: { color: 'var(--snap-color-muted)', fontSize: 'var(--snap-text-sm)' }, children: ["snap-rail", active !== undefined ? ` · ${active.title}` : ''] }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(Slot, { name: UI_SLOT_IDS.settingsEntry, context: {
19
- presentation: 'icon',
20
- open: () => props.ctx.settings.open(),
21
- isOpen: props.ctx.settings.isOpen(),
22
- } }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u2014" }), label: "\u6700\u5C0F\u5316", onClick: () => control('minimize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u25A1" }), label: "\u6700\u5927\u5316\u5207\u6362", onClick: () => control('toggle-maximize') }), _jsx(IconButton, { icon: _jsx(Glyph, { children: "\u00D7" }), label: "\u5173\u95ED", onClick: () => control('close') })] })] }));
23
- return (_jsx(AppShell, { header: header, children: active !== undefined
31
+ // The window bar has one occupant (a layout-level replacement); the sidebar
32
+ // and statusbar are extension seats, so they only take space once something
33
+ // contributes — an empty strip would be a permanent visual tax on every
34
+ // installation that never uses them.
35
+ const titlebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.titlebar).length > 0;
36
+ const sidebarOccupied = props.ctx.ui.list(UI_SLOT_IDS.sidebar).length > 0;
37
+ const statusbarOccupied = props.ctx.ui.list(UI_SLOT_IDS.statusbar).length > 0;
38
+ const header = titlebarOccupied
39
+ ? _jsx(Slot, { name: UI_SLOT_IDS.titlebar, context: { surface: 'main', controls: WINDOW_CONTROLS } })
40
+ : _jsx(DefaultTitlebar, { ctx: props.ctx, title: active?.title, control: control });
41
+ const sidebar = sidebarOccupied
42
+ ? (_jsx("div", { className: "snap-fallback-sidebar", style: { display: 'flex', flexDirection: 'column', height: '100%', minHeight: 0, padding: '4px 8px' }, children: _jsx(Slot, { name: UI_SLOT_IDS.sidebar, context: { surface: 'main' } }) }))
43
+ : undefined;
44
+ const statusbar = statusbarOccupied
45
+ ? (_jsx("div", { className: "snap-fallback-statusbar", style: {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ gap: 12,
49
+ minHeight: 28,
50
+ padding: '0 12px',
51
+ color: 'var(--snap-color-muted)',
52
+ fontSize: 'var(--snap-text-sm)',
53
+ }, children: _jsx(Slot, { name: UI_SLOT_IDS.statusbar, context: { surface: 'main' } }) }))
54
+ : undefined;
55
+ return (_jsx(AppShell, { header: header, ...sidebar !== undefined ? { sidebar } : {}, ...statusbar !== undefined ? { footer: statusbar } : {}, children: active !== undefined
24
56
  ? active.render()
25
57
  : (_jsx("div", { style: { display: 'flex', minHeight: '100%', alignItems: 'center', justifyContent: 'center', padding: 24 }, children: _jsx(EmptyState, { title: "\u5C1A\u672A\u6FC0\u6D3B\u4E1A\u52A1\u5957\u4EF6", action: _jsx(Button, { intent: "primary", onClick: () => props.ctx.settings.open('plugins'), children: "\u6253\u5F00\u8BBE\u7F6E" }) }) })) }));
26
58
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snap-rail/ui",
3
3
  "description": "The built-in UI substrate: semantic components, typed region slots, skins, settings and renderer runtime",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -84,10 +84,10 @@
84
84
  "react": ">=19",
85
85
  "react-dom": ">=19",
86
86
  "zod": "^4.4.3",
87
- "@snap-rail/cordis": "^4.0.3",
88
87
  "@snap-rail/connection": "^0.1.0",
89
- "@snap-rail/shell": "^0.2.4",
90
- "@snap-rail/protocol": "^0.1.3"
88
+ "@snap-rail/cordis": "^4.0.3",
89
+ "@snap-rail/protocol": "^0.1.3",
90
+ "@snap-rail/shell": "^0.2.5"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@types/react": "^19.2.14",
@@ -99,14 +99,14 @@
99
99
  "typescript": "^6.0.3",
100
100
  "vitest": "^4.1.8",
101
101
  "zod": "^4.4.3",
102
+ "@snap-rail/app-boot": "^0.1.3",
103
+ "@snap-rail/connection": "^0.1.0",
102
104
  "@snap-rail/cordis": "^4.0.3",
103
- "@snap-rail/client-kernel": "^0.1.2",
104
105
  "@snap-rail/cordis-plugin-timer": "^1.1.3",
105
- "@snap-rail/connection": "^0.1.0",
106
- "@snap-rail/app-boot": "^0.1.3",
107
- "@snap-rail/protocol": "^0.1.3",
108
- "@snap-rail/shell": "^0.2.4",
109
- "@snap-rail/station-rpc": "^0.1.0"
106
+ "@snap-rail/client-kernel": "^0.1.2",
107
+ "@snap-rail/shell": "^0.2.5",
108
+ "@snap-rail/station-rpc": "^0.1.0",
109
+ "@snap-rail/protocol": "^0.1.3"
110
110
  },
111
111
  "snapRail": {
112
112
  "layer": "base",