@kukeon/ui 0.0.0-stage → 0.10.0-edge.g21af9f59
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/dist/disclosure.d.ts +17 -0
- package/dist/disclosure.js +38 -0
- package/dist/focus.d.ts +3 -0
- package/dist/focus.js +38 -0
- package/dist/icons.d.ts +55 -0
- package/dist/icons.js +58 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/status.d.ts +29 -0
- package/dist/status.js +46 -0
- package/package.json +30 -4
- package/README.md +0 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export declare function useDisclosure(id: string, defaultOpen?: boolean): [boolean, (open: boolean) => void];
|
|
3
|
+
export declare function Disclosure({ title, summary, badge, className, label, level, open, onToggle, children }: {
|
|
4
|
+
title: string;
|
|
5
|
+
level?: 2 | 3;
|
|
6
|
+
summary?: ReactNode;
|
|
7
|
+
badge?: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
open: boolean;
|
|
11
|
+
onToggle: (open: boolean) => void;
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
export declare function StoredDisclosure({ id, ...props }: Omit<Parameters<typeof Disclosure>[0], "open" | "onToggle"> & {
|
|
15
|
+
id: string;
|
|
16
|
+
}): import("react").JSX.Element;
|
|
17
|
+
export declare const disclosedKinds: string[];
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
// Collapsible panels (#1568). A panel's heading row is the <summary>, so it opens with a click, Enter or
|
|
4
|
+
// Space, and it shows a one-line digest of its content while collapsed.
|
|
5
|
+
const storageKey = "kukeon-disclosures";
|
|
6
|
+
function storedStates() {
|
|
7
|
+
try {
|
|
8
|
+
const value = JSON.parse(localStorage.getItem(storageKey) ?? "{}");
|
|
9
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// useDisclosure remembers a section's open state under its id; sections start collapsed unless stored open.
|
|
16
|
+
export function useDisclosure(id, defaultOpen = false) {
|
|
17
|
+
const [open, setOpen] = useState(() => { const stored = storedStates()[id]; return typeof stored === "boolean" ? stored : defaultOpen; });
|
|
18
|
+
return [open, next => {
|
|
19
|
+
setOpen(next);
|
|
20
|
+
try {
|
|
21
|
+
localStorage.setItem(storageKey, JSON.stringify({ ...storedStates(), [id]: next }));
|
|
22
|
+
}
|
|
23
|
+
catch { /* Preferences are optional. */ }
|
|
24
|
+
}];
|
|
25
|
+
}
|
|
26
|
+
// Disclosure is the controlled panel: the caller owns the open state (a form opens the sections that hold
|
|
27
|
+
// invalid fields). StoredDisclosure below is the self-contained variant that remembers the operator's choice.
|
|
28
|
+
export function Disclosure({ title, summary, badge, className = "", label, level = 2, open, onToggle, children }) {
|
|
29
|
+
return _jsx("section", { className: `panel disclosure ${className}`.trim(), "aria-label": label, children: _jsxs("details", { open: open, onToggle: event => { if (event.currentTarget.open !== open)
|
|
30
|
+
onToggle(event.currentTarget.open); }, children: [_jsxs("summary", { className: "panel-heading", children: [level === 3 ? _jsx("h3", { children: title }) : _jsx("h2", { children: title }), _jsx("span", { className: "disclosure-summary", children: summary }), badge] }), children] }) });
|
|
31
|
+
}
|
|
32
|
+
export function StoredDisclosure({ id, ...props }) {
|
|
33
|
+
const [open, setOpen] = useDisclosure(id);
|
|
34
|
+
return _jsx(Disclosure, { ...props, open: open, onToggle: setOpen });
|
|
35
|
+
}
|
|
36
|
+
// Cell and container pages tuck their runtime internals (network, cgroup) behind disclosures; the realm,
|
|
37
|
+
// space and stack pages keep the plain panels.
|
|
38
|
+
export const disclosedKinds = ["cell", "container"];
|
package/dist/focus.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
export declare function rememberFocus(fallback?: () => HTMLElement | null | undefined): () => void;
|
|
3
|
+
export declare function useModalDialog(dialog: RefObject<HTMLDialogElement | null>, fallback?: () => HTMLElement | null | undefined): void;
|
package/dist/focus.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
// Keyboard focus helpers (#1567, item B).
|
|
3
|
+
// Focus can only return to an element that is still in the document and rendered: not removed,
|
|
4
|
+
// not inside a closed <details>, not display: none. The body is never a useful target.
|
|
5
|
+
function canReceiveFocus(element) {
|
|
6
|
+
return element instanceof HTMLElement && element !== document.body && element.isConnected && element.getClientRects().length > 0;
|
|
7
|
+
}
|
|
8
|
+
// Records the focused element now; the returned function focuses it again, or the fallback when it is gone.
|
|
9
|
+
// A button inside a closed <details> still has layout boxes in Chromium but refuses focus, so each
|
|
10
|
+
// candidate is tried in turn and kept only if it actually became the active element.
|
|
11
|
+
export function rememberFocus(fallback) {
|
|
12
|
+
const previous = document.activeElement;
|
|
13
|
+
return () => {
|
|
14
|
+
for (const target of [previous, fallback?.() ?? null]) {
|
|
15
|
+
if (!canReceiveFocus(target))
|
|
16
|
+
continue;
|
|
17
|
+
target.focus();
|
|
18
|
+
if (document.activeElement === target)
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Opens the dialog as a modal for the component's lifetime and, when it unmounts (Cancel, Escape,
|
|
24
|
+
// backdrop click or Confirm), returns focus to the control that opened it, or to the fallback when
|
|
25
|
+
// that control is no longer rendered, for example a button inside a menu that has since closed.
|
|
26
|
+
export function useModalDialog(dialog, fallback) {
|
|
27
|
+
const fallbackRef = useRef(fallback);
|
|
28
|
+
fallbackRef.current = fallback;
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const element = dialog.current;
|
|
31
|
+
if (!element)
|
|
32
|
+
return;
|
|
33
|
+
const restore = rememberFocus(() => fallbackRef.current?.());
|
|
34
|
+
element.showModal();
|
|
35
|
+
return () => { if (element.open)
|
|
36
|
+
element.close(); restore(); };
|
|
37
|
+
}, [dialog]);
|
|
38
|
+
}
|
package/dist/icons.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
declare const glyphs: {
|
|
3
|
+
attach: import("react").JSX.Element;
|
|
4
|
+
detach: import("react").JSX.Element;
|
|
5
|
+
reconnect: import("react").JSX.Element;
|
|
6
|
+
expand: import("react").JSX.Element;
|
|
7
|
+
collapse: import("react").JSX.Element;
|
|
8
|
+
start: import("react").JSX.Element;
|
|
9
|
+
stop: import("react").JSX.Element;
|
|
10
|
+
restart: import("react").JSX.Element;
|
|
11
|
+
tornado: import("react").JSX.Element;
|
|
12
|
+
sidebarCollapse: import("react").JSX.Element;
|
|
13
|
+
sidebarExpand: import("react").JSX.Element;
|
|
14
|
+
warning: import("react").JSX.Element;
|
|
15
|
+
info: import("react").JSX.Element;
|
|
16
|
+
document: import("react").JSX.Element;
|
|
17
|
+
kill: import("react").JSX.Element;
|
|
18
|
+
delete: import("react").JSX.Element;
|
|
19
|
+
purge: import("react").JSX.Element;
|
|
20
|
+
edit: import("react").JSX.Element;
|
|
21
|
+
terminal: import("react").JSX.Element;
|
|
22
|
+
exec: import("react").JSX.Element;
|
|
23
|
+
manage: import("react").JSX.Element;
|
|
24
|
+
create: import("react").JSX.Element;
|
|
25
|
+
majordomo: import("react").JSX.Element;
|
|
26
|
+
agent: import("react").JSX.Element;
|
|
27
|
+
pending: import("react").JSX.Element;
|
|
28
|
+
sidePanel: import("react").JSX.Element;
|
|
29
|
+
remove: import("react").JSX.Element;
|
|
30
|
+
};
|
|
31
|
+
export type IconName = keyof typeof glyphs;
|
|
32
|
+
export declare function Icon({ name }: {
|
|
33
|
+
name: IconName;
|
|
34
|
+
}): import("react").JSX.Element;
|
|
35
|
+
export declare function RowAction({ icon, label, title, href, onClick, danger, disabled, busy, newTab }: {
|
|
36
|
+
icon: IconName;
|
|
37
|
+
label: string;
|
|
38
|
+
title: string;
|
|
39
|
+
href?: string;
|
|
40
|
+
onClick?: () => void;
|
|
41
|
+
danger?: boolean;
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
busy?: boolean;
|
|
44
|
+
newTab?: boolean;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
export declare function RowActions({ children, busy }: {
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
busy?: boolean;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
export declare function DocumentRowLink({ href, label, newTab }: {
|
|
51
|
+
href: string;
|
|
52
|
+
label: string;
|
|
53
|
+
newTab?: boolean;
|
|
54
|
+
}): import("react").JSX.Element;
|
|
55
|
+
export {};
|
package/dist/icons.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Inline stroke glyphs drawn on the same 24px grid as the toolbar refresh and appearance icons.
|
|
3
|
+
const glyphs = {
|
|
4
|
+
attach: _jsxs(_Fragment, { children: [_jsx("path", { d: "M9 15 15 9" }), _jsx("path", { d: "M11 6.5 13 4.5a4 4 0 0 1 5.66 5.66L16.5 12.3" }), _jsx("path", { d: "M13 17.5 11 19.5a4 4 0 0 1-5.66-5.66L7.5 11.7" })] }),
|
|
5
|
+
detach: _jsxs(_Fragment, { children: [_jsx("path", { d: "M11 6.5 13 4.5a4 4 0 0 1 5.66 5.66L16.5 12.3" }), _jsx("path", { d: "M13 17.5 11 19.5a4 4 0 0 1-5.66-5.66L7.5 11.7" }), _jsx("path", { d: "M4 4l16 16" })] }),
|
|
6
|
+
reconnect: _jsxs(_Fragment, { children: [_jsx("path", { d: "M20 11a8.1 8.1 0 0 0-14.9-4L3 10" }), _jsx("path", { d: "M3 4v6h6" }), _jsx("path", { d: "M9.5 14.5l5-5" }), _jsx("path", { d: "M13 16.5l-1.5 1.5a3 3 0 0 1-4.24-4.24L8.5 12.5" })] }),
|
|
7
|
+
expand: _jsxs(_Fragment, { children: [_jsx("path", { d: "M14 4h6v6" }), _jsx("path", { d: "M20 4l-6.5 6.5" }), _jsx("path", { d: "M10 20H4v-6" }), _jsx("path", { d: "M4 20l6.5-6.5" })] }),
|
|
8
|
+
collapse: _jsxs(_Fragment, { children: [_jsx("path", { d: "M20 10h-6V4" }), _jsx("path", { d: "M14 10l6.5-6.5" }), _jsx("path", { d: "M4 14h6v6" }), _jsx("path", { d: "M10 14l-6.5 6.5" })] }),
|
|
9
|
+
start: _jsx("path", { d: "M8 5.5v13l10.5-6.5Z" }),
|
|
10
|
+
stop: _jsx("rect", { x: "6", y: "6", width: "12", height: "12", rx: "1.5" }),
|
|
11
|
+
restart: _jsxs(_Fragment, { children: [_jsx("path", { d: "M20 12a8 8 0 1 1-2.34-5.66" }), _jsx("path", { d: "M20 4v5h-5" })] }),
|
|
12
|
+
// Tornado mark for the brand, collapsed rail and favicon (web/apps/local/src/favicon.svg mirrors these strokes).
|
|
13
|
+
tornado: _jsxs(_Fragment, { children: [_jsx("path", { d: "M3 4.5h18" }), _jsx("path", { d: "M5 8.5h14" }), _jsx("path", { d: "M7.5 12.5h9.5" }), _jsx("path", { d: "M9 16.5h6" }), _jsx("path", { d: "M10.5 20.5h3" })] }),
|
|
14
|
+
sidebarCollapse: _jsxs(_Fragment, { children: [_jsx("rect", { x: "3.5", y: "4.5", width: "17", height: "15", rx: "2" }), _jsx("path", { d: "M9 4.5v15" }), _jsx("path", { d: "m15.5 10-2 2 2 2" })] }),
|
|
15
|
+
sidebarExpand: _jsxs(_Fragment, { children: [_jsx("rect", { x: "3.5", y: "4.5", width: "17", height: "15", rx: "2" }), _jsx("path", { d: "M9 4.5v15" }), _jsx("path", { d: "m13.5 10 2 2-2 2" })] }),
|
|
16
|
+
warning: _jsxs(_Fragment, { children: [_jsx("path", { d: "M10.3 4.2 2.8 17.5A2 2 0 0 0 4.5 20.5h15a2 2 0 0 0 1.7-3L13.7 4.2a2 2 0 0 0-3.4 0Z" }), _jsx("path", { d: "M12 9.5v4.5" }), _jsx("path", { d: "M12 17.5h.01" })] }),
|
|
17
|
+
info: _jsxs(_Fragment, { children: [_jsx("circle", { cx: "12", cy: "12", r: "9" }), _jsx("path", { d: "M12 11v5" }), _jsx("path", { d: "M12 7.5h.01" })] }),
|
|
18
|
+
document: _jsxs(_Fragment, { children: [_jsx("path", { d: "M14 3.5H7a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8.5Z" }), _jsx("path", { d: "M14 3.5v5h5" }), _jsx("path", { d: "M9 13h6M9 16.5h4" })] }),
|
|
19
|
+
// Row quick-action glyphs (#1494).
|
|
20
|
+
kill: _jsx("path", { d: "M13 3 5.5 13.5h5.5L10 21l7.5-10.5H12Z" }),
|
|
21
|
+
delete: _jsxs(_Fragment, { children: [_jsx("path", { d: "M4.5 7h15" }), _jsx("path", { d: "M9.5 7V4.5h5V7" }), _jsx("path", { d: "m6.5 7 1 12a1.5 1.5 0 0 0 1.5 1.5h6a1.5 1.5 0 0 0 1.5-1.5l1-12" })] }),
|
|
22
|
+
purge: _jsxs(_Fragment, { children: [_jsx("path", { d: "M4.5 7h15" }), _jsx("path", { d: "M9.5 7V4.5h5V7" }), _jsx("path", { d: "m6.5 7 1 12a1.5 1.5 0 0 0 1.5 1.5h6a1.5 1.5 0 0 0 1.5-1.5l1-12" }), _jsx("path", { d: "m10 11.5 4 4m0-4-4 4" })] }),
|
|
23
|
+
edit: _jsxs(_Fragment, { children: [_jsx("path", { d: "M4.5 19.5h4l10-10a2.83 2.83 0 0 0-4-4l-10 10Z" }), _jsx("path", { d: "m13 7 4 4" })] }),
|
|
24
|
+
terminal: _jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "4.5", width: "18", height: "15", rx: "2" }), _jsx("path", { d: "m7 9.5 3 2.5-3 2.5" }), _jsx("path", { d: "M12.5 15H17" })] }),
|
|
25
|
+
// Exec (#1432): a bare shell prompt, without the terminal glyph's window frame.
|
|
26
|
+
exec: _jsxs(_Fragment, { children: [_jsx("path", { d: "m5 7 6 5-6 5" }), _jsx("path", { d: "M13 17.5h6.5" })] }),
|
|
27
|
+
// Manage, the resource side of the view switch: two sliders.
|
|
28
|
+
manage: _jsxs(_Fragment, { children: [_jsx("path", { d: "M4 7.5h9M17 7.5h3M4 16.5h3M11 16.5h9" }), _jsx("circle", { cx: "15", cy: "7.5", r: "2" }), _jsx("circle", { cx: "9", cy: "16.5", r: "2" })] }),
|
|
29
|
+
create: _jsx("path", { d: "M12 5v14M5 12h14" }),
|
|
30
|
+
// Majordomo: a bell on its base.
|
|
31
|
+
majordomo: _jsxs(_Fragment, { children: [_jsx("path", { d: "M5.5 16.5a6.5 6.5 0 0 1 13 0Z" }), _jsx("path", { d: "M12 10V7.5" }), _jsx("path", { d: "M10 7.5h4" }), _jsx("path", { d: "M3.5 19.5h17" })] }),
|
|
32
|
+
// An agent, a Config whose cells are its instances (#1686): a robot head with an antenna.
|
|
33
|
+
agent: _jsxs(_Fragment, { children: [_jsx("rect", { x: "4.5", y: "8.5", width: "15", height: "11", rx: "2.5" }), _jsx("path", { d: "M12 8.5V5" }), _jsx("circle", { cx: "12", cy: "4", r: "1" }), _jsx("path", { d: "M9.5 13v1.5M14.5 13v1.5" })] }),
|
|
34
|
+
pending: _jsx("path", { d: "M12 3.5a8.5 8.5 0 1 0 8.5 8.5" }),
|
|
35
|
+
// The side panel (#1777): a window with its right column filled in, and a cross to take a cell out.
|
|
36
|
+
sidePanel: _jsxs(_Fragment, { children: [_jsx("rect", { x: "3.5", y: "4.5", width: "17", height: "15", rx: "2" }), _jsx("path", { d: "M15 4.5v15" }), _jsx("path", { d: "M17.5 8.5v7" })] }),
|
|
37
|
+
remove: _jsx("path", { d: "m6.5 6.5 11 11M17.5 6.5l-11 11" }),
|
|
38
|
+
};
|
|
39
|
+
export function Icon({ name }) {
|
|
40
|
+
return _jsx("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: "false", children: glyphs[name] });
|
|
41
|
+
}
|
|
42
|
+
// One quiet per-row icon action, revealed on row hover and keyboard focus. A link when given href,
|
|
43
|
+
// otherwise a button. label is the accessible name (action and target); title is the short tooltip.
|
|
44
|
+
export function RowAction({ icon, label, title, href, onClick, danger = false, disabled = false, busy = false, newTab = false }) {
|
|
45
|
+
const className = `row-action${danger ? " is-danger" : ""}${busy ? " is-busy" : ""}`;
|
|
46
|
+
const glyph = _jsx(Icon, { name: busy ? "pending" : icon });
|
|
47
|
+
if (href !== undefined)
|
|
48
|
+
return _jsx("a", { className: className, href: href, "aria-label": label, title: title, ...newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: glyph });
|
|
49
|
+
return _jsx("button", { className: className, type: "button", "aria-label": label, title: title, "aria-busy": busy || undefined, disabled: disabled, onClick: onClick, children: glyph });
|
|
50
|
+
}
|
|
51
|
+
// Compact group of row actions for a table's td.row-actions cell.
|
|
52
|
+
export function RowActions({ children, busy = false }) {
|
|
53
|
+
return _jsx("span", { className: "row-action-group", "aria-busy": busy || undefined, children: children });
|
|
54
|
+
}
|
|
55
|
+
// Quiet per-row document link, revealed on row hover and keyboard focus.
|
|
56
|
+
export function DocumentRowLink({ href, label, newTab = false }) {
|
|
57
|
+
return _jsx(RowAction, { icon: "document", href: href, label: `View document for ${label}`, title: "View document", newTab: newTab });
|
|
58
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @kukeon/ui: the React primitives the kukeon console is built from. They carry the console's class
|
|
2
|
+
// names; @kukeon/console's stylesheet styles them.
|
|
3
|
+
export * from "./icons.js";
|
|
4
|
+
export * from "./disclosure.js";
|
|
5
|
+
export * from "./focus.js";
|
|
6
|
+
export * from "./status.js";
|
package/dist/status.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type StatusTone = "ok" | "stopped" | "warning" | "error" | "pending" | "neutral";
|
|
2
|
+
export declare function stateTone(state?: string): StatusTone;
|
|
3
|
+
export declare function StateBadge({ state }: {
|
|
4
|
+
state?: string;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function RollupDot({ state }: {
|
|
7
|
+
state?: string;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
export type DriftStatus = {
|
|
10
|
+
outOfSync?: boolean;
|
|
11
|
+
outOfSyncReason?: string;
|
|
12
|
+
outOfSyncError?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function hasDrift(status?: DriftStatus): boolean;
|
|
15
|
+
export declare function driftReason(status?: DriftStatus): string;
|
|
16
|
+
export declare function DriftBadge({ status }: {
|
|
17
|
+
status?: DriftStatus;
|
|
18
|
+
}): import("react").JSX.Element | null;
|
|
19
|
+
export declare function PathText({ segments, joiner }: {
|
|
20
|
+
segments: string[];
|
|
21
|
+
joiner?: string;
|
|
22
|
+
}): import("react").JSX.Element;
|
|
23
|
+
export declare function ScopePath({ parts, empty }: {
|
|
24
|
+
parts: string[];
|
|
25
|
+
empty?: string;
|
|
26
|
+
}): import("react").JSX.Element;
|
|
27
|
+
export declare function SocketPath({ path }: {
|
|
28
|
+
path: string;
|
|
29
|
+
}): import("react").JSX.Element;
|
package/dist/status.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
export function stateTone(state) {
|
|
4
|
+
return ["Ready", "Running", "done", "cloned", "fetched"].includes(state ?? "") ? "ok"
|
|
5
|
+
: ["Failed", "Error", "failed"].includes(state ?? "") ? "error"
|
|
6
|
+
: ["Degraded", "Not ready", "Pausing"].includes(state ?? "") ? "warning"
|
|
7
|
+
: ["Pending", "Creating", "Starting", "Stopping"].includes(state ?? "") ? "pending"
|
|
8
|
+
: ["Stopped", "Exited", "Paused"].includes(state ?? "") ? "stopped" : "neutral";
|
|
9
|
+
}
|
|
10
|
+
export function StateBadge({ state }) {
|
|
11
|
+
return _jsxs("span", { className: `state-badge tone-${stateTone(state)}`, children: [_jsx("span", { className: "state-dot", "aria-hidden": "true" }), state || "Not reported"] });
|
|
12
|
+
}
|
|
13
|
+
// The one state dot of an agent row or heading (#1686): the roll-up state as a toned dot, named for
|
|
14
|
+
// assistive technology and in its tooltip, never colour alone.
|
|
15
|
+
export function RollupDot({ state }) {
|
|
16
|
+
const label = state || "State not reported";
|
|
17
|
+
return _jsxs("span", { className: `rollup-dot tone-${stateTone(state)}`, title: label, children: [_jsx("span", { className: "state-dot", "aria-hidden": "true" }), _jsx("span", { className: "sr-only", children: label })] });
|
|
18
|
+
}
|
|
19
|
+
export function hasDrift(status) {
|
|
20
|
+
return !!status?.outOfSync || !!status?.outOfSyncError;
|
|
21
|
+
}
|
|
22
|
+
export function driftReason(status) {
|
|
23
|
+
return status?.outOfSyncError ? `Configuration comparison failed: ${status.outOfSyncError}`
|
|
24
|
+
: `Configuration out of sync: ${status?.outOfSyncReason || "reason not reported"}`;
|
|
25
|
+
}
|
|
26
|
+
export function DriftBadge({ status }) {
|
|
27
|
+
if (!hasDrift(status))
|
|
28
|
+
return null;
|
|
29
|
+
const reason = driftReason(status);
|
|
30
|
+
return _jsxs("span", { className: "state-badge tone-warning drift-badge", title: reason, children: [_jsx("span", { className: "state-dot", "aria-hidden": "true" }), status?.outOfSyncError ? "Drift unknown" : "Drift", _jsxs("span", { className: "sr-only", children: [". ", reason] })] });
|
|
31
|
+
}
|
|
32
|
+
// Scope and socket paths wrap only at their separators (#1567). Each segment, with the separator that
|
|
33
|
+
// ends it, is an inline-block, so lines break between segments; a segment breaks inside only when it
|
|
34
|
+
// alone is wider than the line.
|
|
35
|
+
export function PathText({ segments, joiner = "" }) {
|
|
36
|
+
return _jsx(_Fragment, { children: segments.map((segment, i) => _jsxs(Fragment, { children: [i > 0 && joiner, _jsx("span", { className: "path-segment", children: segment })] }, i)) });
|
|
37
|
+
}
|
|
38
|
+
// realm / space / stack, breaking only after a " /". The space inside a segment does not break: the
|
|
39
|
+
// inline-block keeps its max-content width whenever that fits on the line.
|
|
40
|
+
export function ScopePath({ parts, empty = "—" }) {
|
|
41
|
+
return parts.length ? _jsx(PathText, { segments: parts.map((part, i) => i < parts.length - 1 ? `${part} /` : part), joiner: " " }) : _jsx(_Fragment, { children: empty });
|
|
42
|
+
}
|
|
43
|
+
// A socket endpoint such as unix:///run/kukeon/kukeond.sock, breaking only after a "/".
|
|
44
|
+
export function SocketPath({ path }) {
|
|
45
|
+
return _jsx(PathText, { segments: path.split(/(?<=\/)/) });
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kukeon/ui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.10.0-edge.g21af9f59",
|
|
4
|
+
"description": "React primitives of the kukeon web console: icons, row actions, disclosures, state badges and focus helpers.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/eminwux/kukeon.git",
|
|
9
|
+
"directory": "web/packages/ui"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"@kukeon/source": "./src/index.ts",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsc -p tsconfig.build.json",
|
|
27
|
+
"typecheck": "tsc --noEmit"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": "^19.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
package/README.md
DELETED