@snap-rail/ui 0.4.0 → 0.4.1

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
@@ -585,7 +585,9 @@ const UI_COMPONENTS = {
585
585
  "settings.nav-icon",
586
586
  "settings.group",
587
587
  "settings.group-title",
588
- "settings.content"
588
+ "settings.content",
589
+ "settings.page",
590
+ "settings.footer"
589
591
  ] }
590
592
  };
591
593
  //#endregion
package/lib/index.js CHANGED
@@ -612,7 +612,9 @@ const UI_COMPONENTS = {
612
612
  "settings.nav-icon",
613
613
  "settings.group",
614
614
  "settings.group-title",
615
- "settings.content"
615
+ "settings.content",
616
+ "settings.page",
617
+ "settings.footer"
616
618
  ] }
617
619
  };
618
620
  //#endregion
@@ -4824,6 +4826,39 @@ function SettingsEntry(props) {
4824
4826
  onClick: props.open
4825
4827
  });
4826
4828
  }
4829
+ /** The settings footer: the running app's version plus the copyright line,
4830
+ * pinned below the page area of every settings page. The version rides the
4831
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
4832
+ * too); hosts without the update bridge — or bare contexts without client
4833
+ * services — simply get no footer instead of an error. */
4834
+ function SettingsFooter({ ctx }) {
4835
+ const [version, setVersion] = useState(void 0);
4836
+ useEffect(() => {
4837
+ let link;
4838
+ try {
4839
+ link = ctx.client.link;
4840
+ } catch {
4841
+ return;
4842
+ }
4843
+ let cancelled = false;
4844
+ link.call("update.state", {}).then((result) => {
4845
+ if (!cancelled && result.ok) setVersion(result.value.status.currentVersion);
4846
+ }).catch(() => void 0);
4847
+ return () => {
4848
+ cancelled = true;
4849
+ };
4850
+ }, [ctx]);
4851
+ if (version === void 0) return null;
4852
+ return jsxs("footer", {
4853
+ ...part("settings", "footer"),
4854
+ className: "snap-settings-footer",
4855
+ children: [jsxs("span", { children: ["snap-rail v", version] }), jsxs("span", { children: [
4856
+ "© ",
4857
+ (/* @__PURE__ */ new Date()).getFullYear(),
4858
+ " snap-rail · Apache-2.0"
4859
+ ] })]
4860
+ });
4861
+ }
4827
4862
  /** The default settings surface. */
4828
4863
  function SettingsSurface(props) {
4829
4864
  const { service, ctx } = props;
@@ -4897,14 +4932,18 @@ function SettingsSurface(props) {
4897
4932
  }), jsx("span", { children: page.title })]
4898
4933
  }, page.id))]
4899
4934
  }, group))
4900
- }), jsx("main", {
4935
+ }), jsxs("main", {
4901
4936
  ...part("settings", "content"),
4902
4937
  className: "snap-settings-content",
4903
4938
  "data-active-page": activeId,
4904
- children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
4905
- page: active.id,
4906
- children: active.render()
4907
- })
4939
+ children: [jsx("div", {
4940
+ ...part("settings", "page"),
4941
+ className: "snap-settings-page",
4942
+ children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
4943
+ page: active.id,
4944
+ children: active.render()
4945
+ })
4946
+ }), jsx(SettingsFooter, { ctx })]
4908
4947
  })]
4909
4948
  })]
4910
4949
  })
package/lib/runtime.js CHANGED
@@ -2650,6 +2650,39 @@ function SettingsEntry(props) {
2650
2650
  onClick: props.open
2651
2651
  });
2652
2652
  }
2653
+ /** The settings footer: the running app's version plus the copyright line,
2654
+ * pinned below the page area of every settings page. The version rides the
2655
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
2656
+ * too); hosts without the update bridge — or bare contexts without client
2657
+ * services — simply get no footer instead of an error. */
2658
+ function SettingsFooter({ ctx }) {
2659
+ const [version, setVersion] = useState(void 0);
2660
+ useEffect(() => {
2661
+ let link;
2662
+ try {
2663
+ link = ctx.client.link;
2664
+ } catch {
2665
+ return;
2666
+ }
2667
+ let cancelled = false;
2668
+ link.call("update.state", {}).then((result) => {
2669
+ if (!cancelled && result.ok) setVersion(result.value.status.currentVersion);
2670
+ }).catch(() => void 0);
2671
+ return () => {
2672
+ cancelled = true;
2673
+ };
2674
+ }, [ctx]);
2675
+ if (version === void 0) return null;
2676
+ return jsxs("footer", {
2677
+ ...part("settings", "footer"),
2678
+ className: "snap-settings-footer",
2679
+ children: [jsxs("span", { children: ["snap-rail v", version] }), jsxs("span", { children: [
2680
+ "© ",
2681
+ (/* @__PURE__ */ new Date()).getFullYear(),
2682
+ " snap-rail · Apache-2.0"
2683
+ ] })]
2684
+ });
2685
+ }
2653
2686
  /** The default settings surface. */
2654
2687
  function SettingsSurface(props) {
2655
2688
  const { service, ctx } = props;
@@ -2723,14 +2756,18 @@ function SettingsSurface(props) {
2723
2756
  }), jsx("span", { children: page.title })]
2724
2757
  }, page.id))]
2725
2758
  }, group))
2726
- }), jsx("main", {
2759
+ }), jsxs("main", {
2727
2760
  ...part("settings", "content"),
2728
2761
  className: "snap-settings-content",
2729
2762
  "data-active-page": activeId,
2730
- children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2731
- page: active.id,
2732
- children: active.render()
2733
- })
2763
+ children: [jsx("div", {
2764
+ ...part("settings", "page"),
2765
+ className: "snap-settings-page",
2766
+ children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2767
+ page: active.id,
2768
+ children: active.render()
2769
+ })
2770
+ }), jsx(SettingsFooter, { ctx })]
2734
2771
  })]
2735
2772
  })]
2736
2773
  })
package/lib/settings.js CHANGED
@@ -1939,6 +1939,39 @@ function SettingsEntry(props) {
1939
1939
  onClick: props.open
1940
1940
  });
1941
1941
  }
1942
+ /** The settings footer: the running app's version plus the copyright line,
1943
+ * pinned below the page area of every settings page. The version rides the
1944
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
1945
+ * too); hosts without the update bridge — or bare contexts without client
1946
+ * services — simply get no footer instead of an error. */
1947
+ function SettingsFooter({ ctx }) {
1948
+ const [version, setVersion] = useState(void 0);
1949
+ useEffect(() => {
1950
+ let link;
1951
+ try {
1952
+ link = ctx.client.link;
1953
+ } catch {
1954
+ return;
1955
+ }
1956
+ let cancelled = false;
1957
+ link.call("update.state", {}).then((result) => {
1958
+ if (!cancelled && result.ok) setVersion(result.value.status.currentVersion);
1959
+ }).catch(() => void 0);
1960
+ return () => {
1961
+ cancelled = true;
1962
+ };
1963
+ }, [ctx]);
1964
+ if (version === void 0) return null;
1965
+ return jsxs("footer", {
1966
+ ...part("settings", "footer"),
1967
+ className: "snap-settings-footer",
1968
+ children: [jsxs("span", { children: ["snap-rail v", version] }), jsxs("span", { children: [
1969
+ "© ",
1970
+ (/* @__PURE__ */ new Date()).getFullYear(),
1971
+ " snap-rail · Apache-2.0"
1972
+ ] })]
1973
+ });
1974
+ }
1942
1975
  /** The default settings surface. */
1943
1976
  function SettingsSurface(props) {
1944
1977
  const { service, ctx } = props;
@@ -2012,14 +2045,18 @@ function SettingsSurface(props) {
2012
2045
  }), jsx("span", { children: page.title })]
2013
2046
  }, page.id))]
2014
2047
  }, group))
2015
- }), jsx("main", {
2048
+ }), jsxs("main", {
2016
2049
  ...part("settings", "content"),
2017
2050
  className: "snap-settings-content",
2018
2051
  "data-active-page": activeId,
2019
- children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2020
- page: active.id,
2021
- children: active.render()
2022
- })
2052
+ children: [jsx("div", {
2053
+ ...part("settings", "page"),
2054
+ className: "snap-settings-page",
2055
+ children: active === void 0 ? jsx(EmptyState, { title: "暂无设置页" }) : jsx(SettingsPageBoundary, {
2056
+ page: active.id,
2057
+ children: active.render()
2058
+ })
2059
+ }), jsx(SettingsFooter, { ctx })]
2023
2060
  })]
2024
2061
  })]
2025
2062
  })
@@ -363,7 +363,7 @@ export declare const UI_COMPONENTS: {
363
363
  readonly props: readonly ["state"];
364
364
  };
365
365
  readonly settings: {
366
- readonly parts: readonly ["settings.root", "settings.header", "settings.title", "settings.body", "settings.nav", "settings.nav-item", "settings.nav-icon", "settings.group", "settings.group-title", "settings.content"];
366
+ readonly parts: readonly ["settings.root", "settings.header", "settings.title", "settings.body", "settings.nav", "settings.nav-item", "settings.nav-icon", "settings.group", "settings.group-title", "settings.content", "settings.page", "settings.footer"];
367
367
  };
368
368
  };
369
369
  /** One semantic component name. */
@@ -246,6 +246,8 @@ export const UI_COMPONENTS = {
246
246
  'settings.group',
247
247
  'settings.group-title',
248
248
  'settings.content',
249
+ 'settings.page',
250
+ 'settings.footer',
249
251
  ],
250
252
  },
251
253
  };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Component, useState, useSyncExternalStore } from 'react';
2
+ import { Component, useEffect, useState, useSyncExternalStore } from 'react';
3
3
  import { Button, Dialog, DialogContent, DialogTitle, EmptyState, IconButton, } from "./components/index.js";
4
4
  import { UI_SLOT_IDS } from "./contract.js";
5
5
  import { AppearancePage } from "./settings-pages/appearance.js";
@@ -42,6 +42,32 @@ export function SettingsEntry(props) {
42
42
  }
43
43
  return _jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u8BBE\u7F6E", active: props.isOpen, onClick: props.open });
44
44
  }
45
+ /** The settings footer: the running app's version plus the copyright line,
46
+ * pinned below the page area of every settings page. The version rides the
47
+ * existing `update.state` snapshot (`app.getVersion()`, populated in dev
48
+ * too); hosts without the update bridge — or bare contexts without client
49
+ * services — simply get no footer instead of an error. */
50
+ function SettingsFooter({ ctx }) {
51
+ const [version, setVersion] = useState(undefined);
52
+ useEffect(() => {
53
+ let link;
54
+ try {
55
+ link = ctx.client.link;
56
+ }
57
+ catch {
58
+ return;
59
+ }
60
+ let cancelled = false;
61
+ void link.call('update.state', {}).then(result => {
62
+ if (!cancelled && result.ok)
63
+ setVersion(result.value.status.currentVersion);
64
+ }).catch(() => undefined);
65
+ return () => { cancelled = true; };
66
+ }, [ctx]);
67
+ if (version === undefined)
68
+ return null;
69
+ return (_jsxs("footer", { ...part('settings', 'footer'), className: "snap-settings-footer", children: [_jsxs("span", { children: ["snap-rail v", version] }), _jsxs("span", { children: ["\u00A9 ", new Date().getFullYear(), " snap-rail \u00B7 Apache-2.0"] })] }));
70
+ }
45
71
  /** The default settings surface. */
46
72
  export function SettingsSurface(props) {
47
73
  const { service, ctx } = props;
@@ -61,9 +87,9 @@ export function SettingsSurface(props) {
61
87
  bucket.push(page);
62
88
  }
63
89
  return (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: open, onOpenChange: next => { if (!next)
64
- service.close(); }, children: _jsx(DialogContent, { presentation: "fullscreen", showClose: false, children: _jsxs("div", { ...part('settings', 'root'), className: "snap-settings", children: [_jsxs("header", { ...part('settings', 'header'), className: "snap-settings-header", children: [_jsx(DialogTitle, { children: "\u8BBE\u7F6E" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u914D\u7F6E\u63D2\u4EF6\u6E90", onClick: () => setFeedOpen(true) }), _jsx(IconButton, { icon: _jsx(CloseIcon, {}), label: "\u5173\u95ED", onClick: () => service.close() })] })] }), _jsxs("div", { ...part('settings', 'body'), className: "snap-settings-body", children: [_jsx("nav", { ...part('settings', 'nav'), className: "snap-settings-nav", "aria-label": "\u8BBE\u7F6E\u9875", children: [...groups.entries()].map(([group, entries]) => (_jsxs("div", { ...part('settings', 'group'), className: "snap-settings-group", children: [_jsx("div", { ...part('settings', 'group-title'), className: "snap-settings-group-title", children: group }), entries.map(page => (_jsxs("button", { type: "button", ...part('settings', 'nav-item'), className: cn('snap-settings-nav-item', page.id === activeId && 'is-active'), "data-active": page.id === activeId || undefined, "aria-current": page.id === activeId ? 'page' : undefined, onClick: () => service.open(page.id), children: [page.icon !== undefined && _jsx("span", { ...part('settings', 'nav-icon'), children: page.icon }), _jsx("span", { children: page.title })] }, page.id)))] }, group))) }), _jsx("main", { ...part('settings', 'content'), className: "snap-settings-content", "data-active-page": activeId, children: active === undefined
65
- ? _jsx(EmptyState, { title: "\u6682\u65E0\u8BBE\u7F6E\u9875" })
66
- : _jsx(SettingsPageBoundary, { page: active.id, children: active.render() }) })] })] }) }) }), _jsx(PluginFeedDialog, { ctx: ctx, open: feedOpen, onOpenChange: setFeedOpen })] }));
90
+ service.close(); }, children: _jsx(DialogContent, { presentation: "fullscreen", showClose: false, children: _jsxs("div", { ...part('settings', 'root'), className: "snap-settings", children: [_jsxs("header", { ...part('settings', 'header'), className: "snap-settings-header", children: [_jsx(DialogTitle, { children: "\u8BBE\u7F6E" }), _jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [_jsx(IconButton, { icon: _jsx(GearIcon, {}), label: "\u914D\u7F6E\u63D2\u4EF6\u6E90", onClick: () => setFeedOpen(true) }), _jsx(IconButton, { icon: _jsx(CloseIcon, {}), label: "\u5173\u95ED", onClick: () => service.close() })] })] }), _jsxs("div", { ...part('settings', 'body'), className: "snap-settings-body", children: [_jsx("nav", { ...part('settings', 'nav'), className: "snap-settings-nav", "aria-label": "\u8BBE\u7F6E\u9875", children: [...groups.entries()].map(([group, entries]) => (_jsxs("div", { ...part('settings', 'group'), className: "snap-settings-group", children: [_jsx("div", { ...part('settings', 'group-title'), className: "snap-settings-group-title", children: group }), entries.map(page => (_jsxs("button", { type: "button", ...part('settings', 'nav-item'), className: cn('snap-settings-nav-item', page.id === activeId && 'is-active'), "data-active": page.id === activeId || undefined, "aria-current": page.id === activeId ? 'page' : undefined, onClick: () => service.open(page.id), children: [page.icon !== undefined && _jsx("span", { ...part('settings', 'nav-icon'), children: page.icon }), _jsx("span", { children: page.title })] }, page.id)))] }, group))) }), _jsxs("main", { ...part('settings', 'content'), className: "snap-settings-content", "data-active-page": activeId, children: [_jsx("div", { ...part('settings', 'page'), className: "snap-settings-page", children: active === undefined
91
+ ? _jsx(EmptyState, { title: "\u6682\u65E0\u8BBE\u7F6E\u9875" })
92
+ : _jsx(SettingsPageBoundary, { page: active.id, children: active.render() }) }), _jsx(SettingsFooter, { ctx: ctx })] })] })] }) }) }), _jsx(PluginFeedDialog, { ctx: ctx, open: feedOpen, onOpenChange: setFeedOpen })] }));
67
93
  }
68
94
  /** Mount the settings registry and its default slot contributions. */
69
95
  const settingsPlugin = {
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.0",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -85,9 +85,9 @@
85
85
  "react-dom": ">=19",
86
86
  "zod": "^4.4.3",
87
87
  "@snap-rail/cordis": "^4.0.3",
88
- "@snap-rail/protocol": "^0.1.3",
88
+ "@snap-rail/connection": "^0.1.0",
89
89
  "@snap-rail/shell": "^0.2.4",
90
- "@snap-rail/connection": "^0.1.0"
90
+ "@snap-rail/protocol": "^0.1.3"
91
91
  },
92
92
  "devDependencies": {
93
93
  "@types/react": "^19.2.14",
@@ -99,11 +99,11 @@
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/client-kernel": "^0.1.2",
104
- "@snap-rail/connection": "^0.1.0",
105
102
  "@snap-rail/cordis": "^4.0.3",
103
+ "@snap-rail/client-kernel": "^0.1.2",
106
104
  "@snap-rail/cordis-plugin-timer": "^1.1.3",
105
+ "@snap-rail/connection": "^0.1.0",
106
+ "@snap-rail/app-boot": "^0.1.3",
107
107
  "@snap-rail/protocol": "^0.1.3",
108
108
  "@snap-rail/shell": "^0.2.4",
109
109
  "@snap-rail/station-rpc": "^0.1.0"
@@ -337,11 +337,28 @@
337
337
  }
338
338
 
339
339
  [data-snap-part='settings.content'] {
340
+ display: flex;
341
+ flex-direction: column;
340
342
  flex: 1;
341
343
  min-width: 0;
344
+ min-height: 0;
345
+ overflow: hidden;
346
+ }
347
+
348
+ [data-snap-part='settings.page'] {
349
+ flex: 1;
350
+ min-height: 0;
342
351
  overflow: auto;
343
352
  }
344
353
 
354
+ [data-snap-part='settings.footer'] {
355
+ display: flex;
356
+ align-items: center;
357
+ justify-content: space-between;
358
+ gap: var(--snap-space-sm);
359
+ flex-shrink: 0;
360
+ }
361
+
345
362
  [data-snap-part='settings.nav-item'] {
346
363
  display: flex;
347
364
  align-items: center;
@@ -940,13 +940,20 @@
940
940
  box-shadow: inset 3px 0 0 var(--snap-color-primary);
941
941
  }
942
942
 
943
- :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='settings.content'] {
943
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='settings.page'] {
944
944
  padding: var(--snap-space-lg);
945
945
  /* Deep bottom padding: the scrolled pane's last control must clear the
946
946
  * window edge instead of hanging sliced across it. */
947
947
  padding-bottom: var(--snap-space-xl);
948
948
  }
949
949
 
950
+ :is([data-snap-skin='default-light'], [data-snap-skin='default-dark']) [data-snap-part='settings.footer'] {
951
+ padding: var(--snap-space-sm) var(--snap-space-lg);
952
+ border-top: var(--snap-border-width) solid var(--snap-color-border);
953
+ color: var(--snap-color-muted);
954
+ font-size: var(--snap-text-xs);
955
+ }
956
+
950
957
  @keyframes snap-spin {
951
958
  to { transform: rotate(360deg); }
952
959
  }