@scalio-cloud/ui 0.89.0 → 0.91.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
@@ -873,6 +873,23 @@ The package holds only design values and fonts under the SIL OFL, nothing confid
873
873
  Design tokens and preset: (c) Scalio Cloud LLC, free to use in Scalio apps. Fonts: SIL Open Font License 1.1,
874
874
  see `fonts/licenses/`. Icons in `react/icons.js`: Lucide, ISC license, see `licenses/lucide-LICENSE.txt`.
875
875
 
876
+ ## Limited Mode banner: `LimitedModeBanner` (React, from 0.90.0)
877
+
878
+ One banner for all apps instead of one per app (scalio-docs ADR 0126). Over the license limit the backend
879
+ (scalio-license) sends `over` and, from day 15, `limited: true`. The banner shows nothing for the first 7 days, a yellow
880
+ notice with the date from day 8, and a red "Limited mode: read-only" from day 15. German and English, de-CH / en-GB date.
881
+
882
+ ```jsx
883
+ import { LimitedModeBanner } from "@scalio-cloud/ui/react";
884
+ <LimitedModeBanner license={license} product="Citadel" unit="users" lang={lang} onOpen={() => navigate("/settings/license")} />
885
+ ```
886
+
887
+ `license`: `{ limited, limited_reason?, over: { <kind>: { current, limit, notice_from, limited_from } } }` as the backend sends it.
888
+ `unit`: `users` (active Microsoft 365 users, default), `tenants` or `desktops`. Without an excess but with `limited: true`
889
+ (ended subscription, Atrium) the red banner shows `limited_reason` or a default text. `onOpen` adds the link "Lizenz" / "License".
890
+ Test ids: `license-limit-banner` (yellow), `license-limited-banner` (red), `license-limit-link`. `limitedModeState(license, now)`
891
+ returns the state (`null`, `notice`, `limited`, `subscription`) for apps that need it elsewhere. Texts: `LABELS.<lang>.limitedMode`.
892
+
876
893
  ## Eingabefelder prüfen: `Input` (React, from 0.44.0)
877
894
 
878
895
  Taken over from Scalio Kontor, so every app checks fields the same way. `<Input check="…">` is the native
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.89.0",
3
+ "version": "0.91.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/index.js CHANGED
@@ -386,6 +386,6 @@ module.exports = {
386
386
  TEST_IDS,
387
387
  initials,
388
388
  };
389
- Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
389
+ Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./limited_mode"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"), require("./tenancy"), require("./legal"));
390
390
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
391
391
  Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -503,6 +503,19 @@ const LABELS = {
503
503
  setUpFactor: "Zum Profil",
504
504
  run: "Auf Werkseinstellungen zurücksetzen",
505
505
  },
506
+ limitedMode: {
507
+ license: "Lizenz",
508
+ limitedTitle: "Eingeschränkter Modus: nur lesen",
509
+ limited: "{current} {unit}, die Lizenz deckt {limit}. {product} liest nur noch, bis die Lizenz erweitert wird oder die Zahl sinkt.",
510
+ notice: "{current} {unit}, die Lizenz deckt {limit}. Ab {date} liest {product} nur noch (eingeschränkter Modus). Bitte erweitern Sie die Lizenz oder senken Sie die Zahl.",
511
+ noticeNoDate: "{current} {unit}, die Lizenz deckt {limit}. Bald liest {product} nur noch (eingeschränkter Modus). Bitte erweitern Sie die Lizenz oder senken Sie die Zahl.",
512
+ subscription: "Das Abonnement ist abgelaufen. {product} liest nur noch, bis ein neuer Lizenzschlüssel eingegeben wird. Die Daten bleiben erhalten.",
513
+ units: {
514
+ users: { title: "Mehr Benutzer als lizenziert", count: "aktive Microsoft-365-Benutzer" },
515
+ tenants: { title: "Mehr Tenants als lizenziert", count: "Tenants" },
516
+ desktops: { title: "Mehr Desktops als lizenziert", count: "Desktops" },
517
+ },
518
+ },
506
519
  license: {
507
520
  title: "Lizenz",
508
521
  hint: "Lizenzen kaufen und verlängern Sie in Scalio Compass. Der Schlüssel gilt nur für die Installations-ID unten.",
@@ -1075,6 +1088,19 @@ const LABELS = {
1075
1088
  setUpFactor: "Go to profile",
1076
1089
  run: "Reset to factory settings",
1077
1090
  },
1091
+ limitedMode: {
1092
+ license: "License",
1093
+ limitedTitle: "Limited mode: read-only",
1094
+ limited: "{current} {unit}, the license covers {limit}. {product} only reads until the license is extended or the number drops.",
1095
+ notice: "{current} {unit}, the license covers {limit}. From {date} {product} only reads (limited mode). Please extend the license or reduce the number.",
1096
+ noticeNoDate: "{current} {unit}, the license covers {limit}. Soon {product} will only read (limited mode). Please extend the license or reduce the number.",
1097
+ subscription: "The subscription has ended. {product} only reads until a new license key is entered. Data is kept.",
1098
+ units: {
1099
+ users: { title: "More users than licensed", count: "active Microsoft 365 users" },
1100
+ tenants: { title: "More tenants than licensed", count: "tenants" },
1101
+ desktops: { title: "More desktops than licensed", count: "desktops" },
1102
+ },
1103
+ },
1078
1104
  license: {
1079
1105
  title: "License",
1080
1106
  hint: "Buy or extend a license in Scalio Compass. The key is bound to the installation ID below.",
@@ -1164,6 +1190,7 @@ function labelsFor(lang, overrides) {
1164
1190
  mfa: Object.assign({}, base.mfa, o.mfa),
1165
1191
  users: Object.assign({}, base.users, o.users),
1166
1192
  license: Object.assign({}, base.license, o.license),
1193
+ limitedMode: Object.assign({}, base.limitedMode, o.limitedMode, { units: Object.assign({}, base.limitedMode.units, (o.limitedMode || {}).units) }),
1167
1194
  edition: Object.assign({}, base.edition, o.edition),
1168
1195
  accountTabs: Object.assign({}, base.accountTabs, o.accountTabs),
1169
1196
  passwordPolicy: Object.assign({}, base.passwordPolicy, o.passwordPolicy),
package/react/license.js CHANGED
@@ -271,12 +271,12 @@ function LicensePanel(props) {
271
271
  : m.managed
272
272
  ? null
273
273
  : h(
274
- "div",
275
- { key: "form", className: "scalio-license-form" },
274
+ "form",
275
+ { key: "form", className: "scalio-license-form", onSubmit: (e) => { e.preventDefault(); if (!busy && addon.trim()) addAddon(); } },
276
276
  h("textarea", { className: "scalio-input scalio-textarea", rows: 2, value: addon, placeholder: L.addonPlaceholder, disabled: busy,
277
277
  "aria-label": L.addonPlaceholder, "data-testid": "license-addon-input", onChange: (e) => setAddon(e.target.value) }),
278
278
  h("div", { className: "scalio-license-actions" },
279
- h("button", { type: "button", className: "scalio-btn is-primary", disabled: busy || !addon.trim(), onClick: addAddon, "data-testid": "license-addon-add" },
279
+ h("button", { type: "submit", className: "scalio-btn is-primary", disabled: busy || !addon.trim(), "data-testid": "license-addon-add" },
280
280
  h(Icons.Plus, { className: "scalio-icon" }), L.add))
281
281
  ),
282
282
  ];
@@ -284,14 +284,14 @@ function LicensePanel(props) {
284
284
  const keyCard = m.keyReadOnly
285
285
  ? h("div", { className: "scalio-notice is-info", "data-testid": "license-key-readonly" }, m.keyReadOnly)
286
286
  : h(
287
- "div",
288
- { className: "scalio-license-form" },
287
+ "form",
288
+ { className: "scalio-license-form", onSubmit: (e) => { e.preventDefault(); if (!busy && key.trim()) activate(); } },
289
289
  h("textarea", { className: "scalio-input scalio-textarea", rows: 3, value: key, placeholder: L.keyPlaceholder, disabled: busy,
290
290
  "aria-label": L.keyPlaceholder, "data-testid": "license-key-input", onChange: (e) => setKey(e.target.value) }),
291
291
  h(
292
292
  "div",
293
293
  { className: "scalio-license-actions" },
294
- h("button", { type: "button", className: "scalio-btn is-primary", disabled: busy || !key.trim(), onClick: activate, "data-testid": "license-activate" },
294
+ h("button", { type: "submit", className: "scalio-btn is-primary", disabled: busy || !key.trim(), "data-testid": "license-activate" },
295
295
  h(Icons.ShieldCheck, { className: "scalio-icon" }), L.activate),
296
296
  m.keyPresent
297
297
  ? h("button", { type: "button", className: "scalio-btn is-danger", disabled: busy, onClick: remove, "data-testid": "license-remove" },
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ // Limited Mode banner (scalio-docs ADR 0126): over the license limit the app warns for 7 days, announces the date
3
+ // from day 8 (yellow), and is read-only from day 15 (red). The backend (scalio-license) sends `over` and `limited`:
4
+ // license = { limited: bool, limited_reason?: string,
5
+ // over: { <kind>: { current, limit, since, notice_from, limited_from } } }
6
+ // The banner only shows what the backend decided; nothing is calculated except "has notice_from passed".
7
+ const React = require("react");
8
+ const h = React.createElement;
9
+ const Icons = require("./icons");
10
+ const { labelsFor } = require("./labels");
11
+ const { Notice } = require("./blocks");
12
+
13
+ function fill(text, values) {
14
+ return String(text || "").replace(/\{(\w+)\}/g, (m, k) => (values && values[k] !== undefined ? values[k] : m));
15
+ }
16
+
17
+ function validDate(v) {
18
+ const d = v instanceof Date ? v : new Date(v);
19
+ return Number.isNaN(d.getTime()) ? null : d;
20
+ }
21
+
22
+ // -> null (show nothing) | { kind: "notice", current, limit, ... } | { kind: "limited", ... } |
23
+ // { kind: "subscription", reason } (read-only without an excess, e.g. an ended subscription).
24
+ function limitedModeState(license, now) {
25
+ if (!license) return null;
26
+ const over = Object.values(license.over || {})[0];
27
+ if (!over) return license.limited ? { kind: "subscription", reason: license.limited_reason || "" } : null;
28
+ if (license.limited) return { kind: "limited", ...over };
29
+ const from = validDate(over.notice_from);
30
+ if (from && (now || new Date()) >= from) return { kind: "notice", ...over };
31
+ return null;
32
+ }
33
+
34
+ // Props: license, product ("Citadel"), unit ("users" | "tenants" | "desktops", default users), lang, labels,
35
+ // onOpen (adds the link "Lizenz" / "License"), icon, now (tests), testId prefix is fixed:
36
+ // license-limited-banner (red), license-limit-banner (yellow), license-limit-link.
37
+ function LimitedModeBanner(props) {
38
+ const s = limitedModeState(props.license, props.now);
39
+ if (!s) return null;
40
+ const L = labelsFor(props.lang, props.labels).limitedMode;
41
+ const product = props.product || "Scalio";
42
+ const unit = (L.units[props.unit] || L.units.users);
43
+ const action = props.onOpen ? { label: L.license, onClick: props.onOpen, testId: "license-limit-link" } : undefined;
44
+ const common = { banner: true, icon: props.icon || Icons.Alert, lang: props.lang, labels: props.labels, action };
45
+ if (s.kind === "subscription")
46
+ return h(Notice, Object.assign({ kind: "error", testId: "license-limited-banner", title: L.limitedTitle }, common),
47
+ s.reason || fill(L.subscription, { product }));
48
+ const values = { current: s.current, limit: s.limit, unit: unit.count, product };
49
+ if (s.kind === "limited")
50
+ return h(Notice, Object.assign({ kind: "error", testId: "license-limited-banner", title: L.limitedTitle }, common),
51
+ fill(L.limited, values));
52
+ const date = validDate(s.limited_from);
53
+ const when = date ? date.toLocaleDateString(props.lang === "en" ? "en-GB" : "de-CH") : "";
54
+ return h(Notice, Object.assign({ kind: "warn", testId: "license-limit-banner", title: unit.title }, common),
55
+ fill(date ? L.notice : L.noticeNoDate, Object.assign(values, { date: when })));
56
+ }
57
+
58
+ module.exports = { LimitedModeBanner, limitedModeState };
package/react/mail.js CHANGED
@@ -752,7 +752,7 @@ function MailTemplates(props) {
752
752
  }
753
753
  setBusy(false);
754
754
  };
755
- const save = () => run(async () => apply(await client.saveTemplate(kind, tlang, { subject, body }), kind, tlang), L.templateSaved);
755
+ const saveTemplate = () => run(async () => apply(await client.saveTemplate(kind, tlang, { subject, body }), kind, tlang), L.templateSaved);
756
756
  const reset = () => run(async () => apply(await client.resetTemplate(kind, tlang), kind, tlang), L.templateReset);
757
757
  const testMe = () => run(() => client.testTemplate({ kind, lang: tlang, subject, body }), (r) => L.testSent.replace("{to}", (r && r.to) || ""));
758
758
  const toggle = (on) => run(async () => {
@@ -767,9 +767,10 @@ function MailTemplates(props) {
767
767
  : h("textarea", { id: "mail-template-body", className: "scalio-input scalio-textarea scalio-mail-body", rows: 14, value: body, maxLength: 50000,
768
768
  "data-testid": "mail-template-body", onChange: (e) => setBody(e.target.value) });
769
769
 
770
+ const onSubmit = (e) => { e.preventDefault(); if (!busy && subject.trim() && body.trim()) saveTemplate(); };
770
771
  return section(h(
771
- "div",
772
- { className: "scalio-settings-form" },
772
+ "form",
773
+ { className: "scalio-settings-form", onSubmit },
773
774
  provider === "off" ? h("div", { className: "scalio-notice is-info", "data-testid": "mail-templates-off" }, L.off) : null,
774
775
  h("div", { className: "scalio-mail-grid" },
775
776
  h(Field, { id: "mail-template-kind", label: L.kind, hint: meta.description[lang === "en" ? "en" : "de"] },
@@ -810,7 +811,7 @@ function MailTemplates(props) {
810
811
  : null,
811
812
  h("button", { type: "button", className: "scalio-btn", onClick: testMe, disabled: busy || provider === "off", "data-testid": "mail-template-test" },
812
813
  h(Icons.CornerDownLeft, { className: "scalio-icon" }), L.testToMe),
813
- h("button", { type: "button", className: "scalio-btn is-primary", onClick: save, disabled: busy || !subject.trim() || !body.trim(), "data-testid": "mail-template-save" },
814
+ h("button", { type: "submit", className: "scalio-btn is-primary", disabled: busy || !subject.trim() || !body.trim(), "data-testid": "mail-template-save" },
814
815
  h(Icons.Check, { className: "scalio-icon" }), L.saveTemplate))
815
816
  ));
816
817
  }
package/react/nav.js CHANGED
@@ -512,14 +512,26 @@ function SupportDrawer({ open, onClose, onSubmit, client, page, context, lang, l
512
512
  const [description, setDescription] = React.useState("");
513
513
  const [busy, setBusy] = React.useState(false);
514
514
  const [error, setError] = React.useState("");
515
+ const panel = React.useRef(null);
516
+ // ADR 0095 K2: Escape closes, Tab stays inside the drawer.
515
517
  React.useEffect(() => {
516
518
  if (!open) return undefined;
517
519
  function onKey(e) {
518
520
  if (e.key === "Escape" && onClose) onClose();
521
+ else if (e.key === "Tab") require("./wizard").trapTab(e, panel.current);
519
522
  }
520
523
  document.addEventListener("keydown", onKey);
521
524
  return () => document.removeEventListener("keydown", onKey);
522
525
  }, [open, onClose]);
526
+ // The focus moves into the drawer on open and returns to the trigger on close.
527
+ React.useEffect(() => {
528
+ if (!open) return undefined;
529
+ const before = document.activeElement;
530
+ const node = panel.current;
531
+ const first = node && (node.querySelector("input,textarea") || node.querySelector("button"));
532
+ if (first) first.focus();
533
+ return () => { if (before && typeof before.focus === "function" && document.contains(before)) before.focus(); };
534
+ }, [open]);
523
535
  if (!open) return null;
524
536
  const submit = async (e) => {
525
537
  e.preventDefault();
@@ -542,7 +554,7 @@ function SupportDrawer({ open, onClose, onSubmit, client, page, context, lang, l
542
554
  h("div", { className: "scalio-drawer-backdrop", onClick: onClose }),
543
555
  h(
544
556
  "div",
545
- { className: "scalio-support", role: "dialog", "aria-modal": "true", "aria-label": L.supportTitle, "data-testid": "scalio-support-drawer" },
557
+ { ref: panel, className: "scalio-support", role: "dialog", "aria-modal": "true", "aria-label": L.supportTitle, "data-testid": "scalio-support-drawer" },
546
558
  h(
547
559
  "div",
548
560
  { className: "scalio-support-head" },
@@ -424,11 +424,11 @@ function SaasUpdatesPanel(props) {
424
424
  h(Icons.Download, { className: "scalio-icon" }), L.now)));
425
425
  // Postponing only makes sense against a deadline; a pre-release has none.
426
426
  if (offer.due_at || !pre) rows.push(h(Field, { key: "post", id: "saas-updates-until", label: L.postpone },
427
- h("div", { style: { display: "flex", gap: "0.5rem" } },
427
+ h("form", { style: { display: "flex", gap: "0.5rem" },
428
+ onSubmit: (e) => { e.preventDefault(); if (!busy && until) act("postpone", { until: new Date(`${until}T00:00:00`).toISOString() }); } },
428
429
  h("input", { id: "saas-updates-until", type: "date", className: "scalio-input", value: until, max: due, disabled: busy,
429
430
  "data-testid": "saas-updates-until", onChange: (e) => setUntil(e.target.value) }),
430
- h("button", { type: "button", className: "scalio-btn", disabled: busy || !until, "data-testid": "saas-updates-postpone",
431
- onClick: () => act("postpone", { until: new Date(`${until}T00:00:00`).toISOString() }) }, L.postponeGo))));
431
+ h("button", { type: "submit", className: "scalio-btn", disabled: busy || !until, "data-testid": "saas-updates-postpone" }, L.postponeGo))));
432
432
  }
433
433
  }
434
434
  if (preSwitch) rows.push(preSwitch);
@@ -439,6 +439,7 @@ function SaasUpdatesPanel(props) {
439
439
  h("span", null, m === "auto" ? L.modeAuto : L.modeManual)))));
440
440
  const toggleDay = (d) => setWin(Object.assign({}, win, { days: win.days.includes(d) ? win.days.filter((x) => x !== d) : win.days.concat([d]).sort() }));
441
441
  rows.push(h(Field, { key: "win", label: `${L.window} (${st.own_window ? L.ownWindow : L.defaultWindow})`, hint: L.windowHint },
442
+ h("form", { onSubmit: (e) => { e.preventDefault(); if (!busy) act("window", { window: win }); } },
442
443
  h("div", { className: "scalio-settings-text" }, L.days),
443
444
  h("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.75rem" } },
444
445
  L.weekdays.map((name, d) => h("label", { key: d, className: "scalio-settings-check" },
@@ -452,8 +453,8 @@ function SaasUpdatesPanel(props) {
452
453
  h("label", null, L.tz, " ", h("input", { className: "scalio-input", value: win.tz, disabled: busy, "data-testid": "saas-updates-tz",
453
454
  onChange: (e) => setWin(Object.assign({}, win, { tz: e.target.value })) }))),
454
455
  h("div", { className: "scalio-settings-section-footer" },
455
- h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "saas-updates-save-window", onClick: () => act("window", { window: win }) }, L.save),
456
- st.own_window ? h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "saas-updates-default-window", onClick: () => act("window", {}) }, L.useDefault) : null)));
456
+ h("button", { type: "submit", className: "scalio-btn", disabled: busy, "data-testid": "saas-updates-save-window" }, L.save),
457
+ st.own_window ? h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "saas-updates-default-window", onClick: () => act("window", {}) }, L.useDefault) : null))));
457
458
  if (st.last) rows.push(h(Field, { key: "last", label: L.last },
458
459
  h("div", { className: "scalio-settings-text", "data-testid": "saas-updates-last" },
459
460
  fill(st.last.state === "done" ? L.lastDone : L.lastError, { version: st.last.version, at: when(st.last.at, props.lang) }))));