@scalio-cloud/ui 0.49.1 → 0.50.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/README.md +13 -0
- package/base.css +9 -0
- package/nav.css +2 -0
- package/package.json +1 -1
- package/react/index.js +1 -1
- package/react/keyboard.js +36 -0
- package/react/users.js +7 -3
- package/shadcn/alert-dialog.mjs +2 -2
package/README.md
CHANGED
|
@@ -439,6 +439,19 @@ Test IDs: `confirm-dialog`, `confirm-dialog-ok`, `confirm-dialog-cancel`, `confi
|
|
|
439
439
|
with `askConfirm` and then shows `UpdateProgress` (`saas-update-progress`): it polls `/version.json` (props
|
|
440
440
|
`versionUrl`, `checkVersion`, `pollMs` 5 s, `timeoutMs` 20 min) and reloads the page once the new version runs.
|
|
441
441
|
|
|
442
|
+
## Keyboard: rows and focus ring (from 0.50.0)
|
|
443
|
+
|
|
444
|
+
ADR 0095 `kbd/K4`: a row that opens with a click is reachable with Tab and opens with Enter or Space. Spread
|
|
445
|
+
`rowOpenProps` on the row; a click or Enter on a button, link or field inside the row stays with that control:
|
|
446
|
+
|
|
447
|
+
```js
|
|
448
|
+
import { rowOpenProps } from "@scalio-cloud/ui/react";
|
|
449
|
+
<tr key={t.id} {...rowOpenProps(() => navigate(`/tickets/${t.key}`), { label: `${t.key} öffnen` })}>…</tr>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
`kbd/K5`: `base.css` draws a focus ring (`--ring`, 2px) on every link, button, field, `summary` and element with
|
|
453
|
+
`tabindex` that has no focus style of its own. The rule uses `:where()` (no specificity), so any own style wins.
|
|
454
|
+
|
|
442
455
|
## Two-factor card and license panel (React)
|
|
443
456
|
|
|
444
457
|
The same backend routes in every app, so the apps pass only their axios instance and a few helpers.
|
package/base.css
CHANGED
|
@@ -10,3 +10,12 @@ h1, h2, h3, h4, .font-display {
|
|
|
10
10
|
code, pre, kbd, .font-mono {
|
|
11
11
|
font-family: 'JetBrains Mono', ui-monospace, monospace;
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
/* Keyboard (ADR 0095 kbd/K5): every control shows where the focus is. :where() has no specificity, so a component's
|
|
15
|
+
own focus style wins; this is the fallback for controls without one. Never remove it without a replacement. */
|
|
16
|
+
:where(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])):focus-visible {
|
|
17
|
+
outline: 2px solid hsl(var(--ring));
|
|
18
|
+
outline-offset: 2px;
|
|
19
|
+
}
|
|
20
|
+
.scalio-row-open { cursor: pointer; }
|
|
21
|
+
.scalio-row-open:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: -2px; }
|
package/nav.css
CHANGED
|
@@ -837,6 +837,8 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
|
|
|
837
837
|
|
|
838
838
|
/* Dialogs instead of browser popups (ADR 0096): askConfirm, askText, showMessage, UpdateProgress. */
|
|
839
839
|
.scalio-dialog-root { z-index: 70; }
|
|
840
|
+
/* A confirmation always lies above the dialog it was opened from (e.g. delete in «Benutzer bearbeiten»). */
|
|
841
|
+
[data-scalio-dialog-host] .scalio-dialog-root { z-index: 80; }
|
|
840
842
|
.scalio-dialog {
|
|
841
843
|
display: flex; flex-direction: column; gap: 0.75rem; width: calc(100vw - 2rem); max-width: 28rem; max-height: 90vh; overflow-y: auto;
|
|
842
844
|
padding: 1.5rem; border: 1px solid hsl(var(--border)); border-radius: 2px; background: hsl(var(--background)); color: hsl(var(--foreground));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.1",
|
|
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
|
@@ -378,6 +378,6 @@ module.exports = {
|
|
|
378
378
|
TEST_IDS,
|
|
379
379
|
initials,
|
|
380
380
|
};
|
|
381
|
-
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"));
|
|
381
|
+
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"));
|
|
382
382
|
// After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
|
|
383
383
|
Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Keyboard standard of ADR 0095. kbd/K4: a row (table row, list entry, card) that opens with a click is reachable
|
|
3
|
+
// with Tab and opens with Enter or Space. Use it as <tr {...rowOpenProps(() => open(t), { label })}>.
|
|
4
|
+
|
|
5
|
+
const INTERACTIVE = "a,button,input,select,textarea,summary,label,[role=button],[role=link],[contenteditable]";
|
|
6
|
+
|
|
7
|
+
// Whether the event comes from a control inside the row (that control handles it itself).
|
|
8
|
+
function fromInner(e) {
|
|
9
|
+
const t = e.target;
|
|
10
|
+
if (!t || t === e.currentTarget || typeof t.closest !== "function") return false;
|
|
11
|
+
const hit = t.closest(INTERACTIVE);
|
|
12
|
+
return !!hit && hit !== e.currentTarget && e.currentTarget.contains(hit);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function rowOpenProps(onOpen, opts) {
|
|
16
|
+
if (typeof onOpen !== "function") return {};
|
|
17
|
+
const o = opts || {};
|
|
18
|
+
const props = {
|
|
19
|
+
tabIndex: 0,
|
|
20
|
+
onClick(e) {
|
|
21
|
+
if (fromInner(e)) return;
|
|
22
|
+
onOpen(e);
|
|
23
|
+
},
|
|
24
|
+
onKeyDown(e) {
|
|
25
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
26
|
+
if (e.target !== e.currentTarget || e.ctrlKey || e.metaKey || e.altKey || e.shiftKey) return;
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
onOpen(e);
|
|
29
|
+
},
|
|
30
|
+
className: o.className ? `scalio-row-open ${o.className}` : "scalio-row-open",
|
|
31
|
+
};
|
|
32
|
+
if (o.label) props["aria-label"] = o.label;
|
|
33
|
+
return props;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = { rowOpenProps };
|
package/react/users.js
CHANGED
|
@@ -135,16 +135,20 @@ function Dialog({ title, onClose, children, testId }) {
|
|
|
135
135
|
// Props:
|
|
136
136
|
// client (usersApi), me (id of the signed-in person), lang, labels, notify(message, tone), confirm({title, text, action, danger}),
|
|
137
137
|
// formatError(err), roles [{value, label}], defaultRole, adminRole ("admin"; emergency only for it),
|
|
138
|
-
// signInModes (subset of ["microsoft", "password", "invite"], first is the default), microsoftEnabled,
|
|
138
|
+
// signInModes (subset of ["microsoft", "password", "invite"], first is the default; always shown in that order), microsoftEnabled,
|
|
139
139
|
// canLock (accounts can be locked), accessColumn {label, render(user)}, accessField(value, onChange, role, user) -> element
|
|
140
140
|
// (create, edit and approve; value is passed as `access` in the body), onChange() after every change, testId.
|
|
141
|
+
const MODE_ORDER = ["microsoft", "password", "invite"];
|
|
141
142
|
function UserAdmin(props) {
|
|
142
143
|
const { client, me, lang, notify, confirm } = props;
|
|
143
144
|
const L = labelsFor(lang, props.labels).users;
|
|
144
145
|
const fmtErr = props.formatError || errorText;
|
|
145
146
|
const roles = props.roles || [];
|
|
146
147
|
const roleLabel = (r) => (roles.find((x) => x.value === r) || { label: r }).label;
|
|
147
|
-
|
|
148
|
+
// Same order in every app (Microsoft, password, invitation last); the app's first mode stays the default.
|
|
149
|
+
const given = (props.signInModes || ["microsoft", "password"]).filter((m) => m !== "microsoft" || props.microsoftEnabled !== false);
|
|
150
|
+
const modes = MODE_ORDER.filter((m) => given.includes(m)).concat(given.filter((m) => !MODE_ORDER.includes(m)));
|
|
151
|
+
const defaultMode = given[0];
|
|
148
152
|
const adminRole = props.adminRole || "admin";
|
|
149
153
|
const [rows, setRows] = React.useState(null);
|
|
150
154
|
const [dialog, setDialog] = React.useState(null); // {mode: create|edit|merge|secret, user, ...}
|
|
@@ -182,7 +186,7 @@ function UserAdmin(props) {
|
|
|
182
186
|
|
|
183
187
|
const openCreate = () => {
|
|
184
188
|
setError("");
|
|
185
|
-
setForm({ name: "", email: "", role: props.defaultRole || (roles[0] && roles[0].value) || "", signIn:
|
|
189
|
+
setForm({ name: "", email: "", role: props.defaultRole || (roles[0] && roles[0].value) || "", signIn: defaultMode, access: null });
|
|
186
190
|
setDialog({ mode: "create" });
|
|
187
191
|
};
|
|
188
192
|
const openEdit = (u) => {
|
package/shadcn/alert-dialog.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const AlertDialogOverlay = React.forwardRef(({ className, ...props }, ref) => /*
|
|
|
11
11
|
AlertDialogPrimitive.Overlay,
|
|
12
12
|
{
|
|
13
13
|
className: cn(
|
|
14
|
-
"fixed inset-0 z-
|
|
14
|
+
"fixed inset-0 z-[80] bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
15
15
|
className
|
|
16
16
|
),
|
|
17
17
|
...props,
|
|
@@ -24,7 +24,7 @@ const AlertDialogContent = React.forwardRef(({ className, ...props }, ref) => /*
|
|
|
24
24
|
{
|
|
25
25
|
ref,
|
|
26
26
|
className: cn(
|
|
27
|
-
"fixed left-[50%] top-[50%] z-
|
|
27
|
+
"fixed left-[50%] top-[50%] z-[80] grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
28
28
|
className
|
|
29
29
|
),
|
|
30
30
|
...props
|