@scalio-cloud/ui 0.54.0 → 0.55.0

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/README.md CHANGED
@@ -240,18 +240,21 @@ Pages that belong together under one menu item keep their own addresses: the ite
240
240
  on top. An app with two work areas (Nexus Identity and HR) puts `<WorkspaceSwitcher options value onSelect />`
241
241
  into the sidebar's `top`.
242
242
 
243
- **One button in the sidebar** (from 0.54.0, Markus 2026-11-10): the sidebar shows the search, the one blue
244
- `primaryAction` (the app's main action) and the menu. No buttons below Übersicht and no second way to the same action:
245
- a page does not repeat the main action in its header. Page actions (Neu …, Import, Zurück) stay in the page header;
246
- `<PageActions>` renders them in place. `<Sidebar pageActions />` and `<ActionSlot />` (0.18.0 to 0.53.x) are still
247
- accepted but do nothing.
243
+ **Main action of the page** (from 0.55.0, Markus 2026-11-10): the one blue button above Übersicht is always the main
244
+ action of the page you are on. A page declares it with `<MainAction>`; without one the sidebar shows the app's
245
+ `primaryAction` (the main action of the start page). Leaving the page brings the start page's action back. On phones
246
+ (no sidebar) `MainAction` renders a blue button in place. A page never shows its main action a second time, and no
247
+ buttons sit below Übersicht.
248
248
 
249
249
  ```jsx
250
- <PageHeader title="Kontakte" actions={<PageActions><Button onClick={add}><Plus /> Kontakt</Button></PageActions>} />
250
+ <MainAction label="Kunde" icon={Plus} onSelect={() => setOpen(true)} testId="customer-add" />
251
+ <MainAction label="Blueprint" icon={Plus} to="/blueprints/new" link={Link} testId="new-blueprint-btn" />
251
252
  ```
252
253
 
253
- At most two page actions per page, only one of them blue. Labels without "Neu"/"New": the + icon says it
254
- ("+ Kontakt", not "+ Neuer Kontakt"). Filters, search, tabs and Speichern stay on the page.
254
+ Further page actions (Feststellungen, Versionen vergleichen, Zurück) stay in the page header and are not blue;
255
+ `<PageActions>` renders them in place. `UserAdmin` («Benutzer hinzufügen») and `RoleAdmin` («Rolle») use
256
+ `MainAction` themselves. `<Sidebar pageActions />` and `<ActionSlot />` (0.18.0 to 0.53.x) still do nothing.
257
+ Labels without "Neu"/"New": the + icon says it ("+ Kontakt", not "+ Neuer Kontakt").
255
258
 
256
259
  ## Page templates (React, from 0.33.0)
257
260
 
package/nav.css CHANGED
@@ -882,3 +882,6 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
882
882
  .scalio-progress-step.is-active, .scalio-progress-step.is-done { color: hsl(var(--foreground)); }
883
883
  .scalio-progress-step.is-done .scalio-icon { color: #059669; }
884
884
  .scalio-progress-dot { width: 0.875rem; height: 0.875rem; border: 2px solid hsl(var(--border)); border-radius: 999px; }
885
+ /* Main action of a page (react/actions.js MainAction): in the sidebar as .scalio-nav-cta; on phones in place. */
886
+ .scalio-nav-cta:disabled { opacity: 0.6; cursor: default; }
887
+ .scalio-main-action-inline { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 0; text-decoration: none; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.54.0",
3
+ "version": "0.55.0",
4
4
  "description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "private": false,
package/react/actions.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
- // Page actions (UISPEC section 2, "Seitenaktionen"). From 0.18.0 to 0.53.x they moved into a slot in the sidebar
3
- // below Übersicht. Since 0.54.0 (Markus 2026-11-10: no buttons below Übersicht, only one blue button in the
4
- // sidebar, the main action) they stay where the page puts them: in the page header.
5
- //
6
- // <PageActions> and <ActionSlot> stay exported so apps keep building; ActionSlot renders nothing and PageActions
7
- // renders its children in place.
2
+ // Page actions (UISPEC section 2).
3
+ // - Main action (from 0.55.0, Markus 2026-11-10): the one blue button above Übersicht in the sidebar is always the
4
+ // main action of the page you are on («+ Kunde», «+ Umgebung», «Export hochladen», «+ Benutzer hinzufügen»). A
5
+ // page declares it with <MainAction label icon to|onSelect />; without one the sidebar shows the app's
6
+ // primaryAction (the main action of the start page). On phones (no sidebar) MainAction renders a blue button in
7
+ // place. A page never shows its main action a second time.
8
+ // - Further actions (Feststellungen, Versionen vergleichen, Zurück) stay in the page header, never blue.
9
+ // <PageActions> renders them in place; ActionSlot renders nothing (0.18.0 to 0.53.x moved them into the sidebar).
8
10
  const React = require("react");
9
11
  const h = React.createElement;
10
12
 
@@ -53,6 +55,75 @@ function useDesktop() {
53
55
  return desktop;
54
56
  }
55
57
 
58
+ // Main action of the current page. A small stack: the last mounted MainAction wins, unmounting restores the one below.
59
+ let mainStack = [];
60
+ const mainListeners = new Set();
61
+ let mainSnapshot = null;
62
+ function emitMain() {
63
+ mainSnapshot = mainStack.length ? mainStack[mainStack.length - 1].action : null;
64
+ mainListeners.forEach((fn) => fn());
65
+ }
66
+ function subscribeMain(fn) {
67
+ mainListeners.add(fn);
68
+ return () => mainListeners.delete(fn);
69
+ }
70
+ const getMain = () => mainSnapshot;
71
+
72
+ // The page's main action, or null (the sidebar then shows the app's primaryAction).
73
+ function useMainAction() {
74
+ return React.useSyncExternalStore(subscribeMain, getMain, () => null);
75
+ }
76
+
77
+ // Desktop sidebars that show the main action. MainAction renders nothing in place while one is mounted on a desktop.
78
+ let sidebars = 0;
79
+ const sidebarListeners = new Set();
80
+ function subscribeSidebars(fn) {
81
+ sidebarListeners.add(fn);
82
+ return () => sidebarListeners.delete(fn);
83
+ }
84
+ function useSidebarHost(on) {
85
+ React.useEffect(() => {
86
+ if (!on) return undefined;
87
+ sidebars += 1;
88
+ sidebarListeners.forEach((fn) => fn());
89
+ return () => {
90
+ sidebars -= 1;
91
+ sidebarListeners.forEach((fn) => fn());
92
+ };
93
+ }, [on]);
94
+ }
95
+ function useHasSidebar() {
96
+ return React.useSyncExternalStore(subscribeSidebars, () => sidebars > 0, () => false);
97
+ }
98
+
99
+ // <MainAction label="Kunde" icon={Plus} to="/customers/new" /> or onSelect={open}. testId names the button.
100
+ function MainAction(props) {
101
+ const { label, icon, to, onSelect, testId, disabled, link } = props;
102
+ const ref = React.useRef(props);
103
+ ref.current = props;
104
+ React.useLayoutEffect(() => {
105
+ const entry = {
106
+ action: { label, icon, to, testId, disabled: !!disabled, onSelect: onSelect ? () => ref.current.onSelect && ref.current.onSelect() : undefined },
107
+ };
108
+ mainStack = mainStack.concat([entry]);
109
+ emitMain();
110
+ return () => {
111
+ mainStack = mainStack.filter((e) => e !== entry);
112
+ emitMain();
113
+ };
114
+ }, [label, icon, to, testId, disabled, !!onSelect]); // eslint-disable-line react-hooks/exhaustive-deps
115
+ const hasSidebar = useHasSidebar();
116
+ const desktop = useDesktop();
117
+ if (hasSidebar && desktop) return null;
118
+ const Icon = icon;
119
+ const content = [Icon ? h(Icon, { key: "i", className: "scalio-icon", "aria-hidden": "true" }) : null, h("span", { key: "l" }, label)];
120
+ const cls = "scalio-btn-primary scalio-main-action-inline";
121
+ if (to && link) return h(link, { to, className: cls, "data-testid": testId || "main-action" }, content);
122
+ if (to) return h("a", { href: to, className: cls, "data-testid": testId || "main-action" }, content);
123
+ return h("button", { type: "button", className: cls, disabled: !!disabled,
124
+ onClick: () => onSelect && onSelect(), "data-testid": testId || "main-action" }, content);
125
+ }
126
+
56
127
  // Kept for older apps: renders nothing (no page actions in the sidebar since 0.54.0).
57
128
  function ActionSlot() {
58
129
  setActionSlot(null);
@@ -66,4 +137,4 @@ function PageActions({ children }) {
66
137
  return h(React.Fragment, null, children);
67
138
  }
68
139
 
69
- module.exports = { PageActions, ActionSlot, useActionSlot, useDesktop, setActionSlot };
140
+ module.exports = { PageActions, ActionSlot, useActionSlot, useDesktop, setActionSlot, MainAction, useMainAction, useSidebarHost };
package/react/nav.js CHANGED
@@ -5,6 +5,7 @@
5
5
  const React = require("react");
6
6
  const h = React.createElement;
7
7
  const Icons = require("./icons");
8
+ const { useMainAction, useSidebarHost } = require("./actions");
8
9
  const { labelsFor } = require("./labels");
9
10
 
10
11
  function cx() {
@@ -71,6 +72,7 @@ function PrimaryAction({ action, link, onNavigate, testIdPrefix }) {
71
72
  type: "button",
72
73
  className: "scalio-nav-cta",
73
74
  "data-testid": testId,
75
+ disabled: action.disabled || undefined,
74
76
  onClick: () => {
75
77
  if (onNavigate) onNavigate();
76
78
  if (action.onSelect) action.onSelect();
@@ -101,8 +103,9 @@ function SearchButton({ search, lang, labels, testIdPrefix, onNavigate }) {
101
103
 
102
104
  // Sidebar. variant "desktop" shows from 768px, "drawer" is the same content inside NavDrawer.
103
105
  // link: the router's NavLink (gets to, end, className(fn), onClick); without it plain <a> + activePath.
104
- // Only one button in the sidebar: the blue primaryAction on top (Markus 2026-11-10, no buttons below Übersicht).
105
- // pageActions is still accepted for older apps but does nothing: page actions stay in the page header.
106
+ // One button in the sidebar, above Übersicht: the main action of the current page (<MainAction>, react/actions.js),
107
+ // else primaryAction, the main action of the start page (Markus 2026-11-10). No buttons below Übersicht.
108
+ // pageActions is still accepted for older apps but does nothing: further page actions stay in the page header.
106
109
  function Sidebar(props) {
107
110
  const {
108
111
  nav, link, activePath, top, search, primaryAction, footer, version, commit, lang, labels,
@@ -112,6 +115,8 @@ function Sidebar(props) {
112
115
  const L = labelsFor(lang, labels);
113
116
  const sections = visibleSections(nav);
114
117
  const rest = sections;
118
+ const pageMain = useMainAction();
119
+ useSidebarHost(variant !== "drawer");
115
120
  const section = (sec, i) =>
116
121
  h(
117
122
  "div",
@@ -128,7 +133,7 @@ function Sidebar(props) {
128
133
  },
129
134
  top ? h("div", { className: "scalio-sidebar-top" }, top) : null,
130
135
  h(SearchButton, { search, lang, labels, testIdPrefix: prefix, onNavigate }),
131
- h(PrimaryAction, { action: primaryAction, link, onNavigate, testIdPrefix: prefix }),
136
+ h(PrimaryAction, { action: pageMain || primaryAction, link, onNavigate, testIdPrefix: prefix }),
132
137
  h("div", { className: "scalio-sidebar-scroll" }, rest.map(section)),
133
138
  footer || version
134
139
  ? h(
package/react/roles.js CHANGED
@@ -9,6 +9,7 @@ const React = require("react");
9
9
  const { askConfirm } = require("./dialog");
10
10
  const h = React.createElement;
11
11
  const Icons = require("./icons");
12
+ const { MainAction } = require("./actions");
12
13
 
13
14
  const TEXT = {
14
15
  de: {
@@ -370,8 +371,7 @@ function RoleAdmin(props) {
370
371
  return h("div", { className: "scalio-users scalio-roles", "data-testid": props.testId || "role-admin" },
371
372
  h("div", { className: "scalio-users-bar" },
372
373
  h("p", { className: "scalio-users-hint" }, own.length ? L.readOnly : L.empty),
373
- canEdit ? h("button", { type: "button", className: "scalio-btn is-primary", onClick: () => openAdd(null), disabled: busy, "data-testid": "role-add" },
374
- h(Icons.Plus, { className: "scalio-icon" }), L.add) : null),
374
+ canEdit ? h(MainAction, { label: L.add, icon: Icons.Plus, onSelect: () => openAdd(null), disabled: busy, testId: "role-add" }) : null),
375
375
  h("div", { className: "scalio-users-table-wrap" },
376
376
  h("table", { className: "scalio-users-table scalio-roles-table", "data-testid": "roles-table" },
377
377
  h("thead", null, head), h("tbody", null, body))),
package/react/users.js CHANGED
@@ -8,6 +8,7 @@ const React = require("react");
8
8
  const { askConfirm } = require("./dialog");
9
9
  const h = React.createElement;
10
10
  const Icons = require("./icons");
11
+ const { MainAction } = require("./actions");
11
12
  const { labelsFor } = require("./labels");
12
13
 
13
14
  function cx() {
@@ -270,8 +271,8 @@ function UserAdmin(props) {
270
271
  { className: "scalio-users-bar" },
271
272
  h("input", { className: "scalio-input scalio-users-search", type: "search", value: query, placeholder: L.search, "aria-label": L.search,
272
273
  onChange: (e) => setQuery(e.target.value), "data-testid": "users-search" }),
273
- h("button", { type: "button", className: "scalio-btn is-primary", onClick: openCreate, "data-testid": "user-add" },
274
- h(Icons.Plus, { className: "scalio-icon" }), L.add)
274
+ // Main action of the page: the blue button above Übersicht (inline on phones or without a sidebar).
275
+ h(MainAction, { label: L.add, icon: Icons.Plus, onSelect: openCreate, testId: "user-add" })
275
276
  );
276
277
 
277
278
  const table = shown.length