@blackbelt-technology/pi-dashboard-client-utils 0.6.1 → 0.7.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/package.json +3 -2
- package/src/AGENTS.md +2 -2
- package/src/ActionList.tsx +6 -18
- package/src/StatusPill.tsx +6 -14
- package/src/__tests__/ActionList.test.tsx +19 -0
- package/src/__tests__/StatusPill.test.tsx +19 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blackbelt-technology/pi-dashboard-client-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Small reusable React components, hooks, and helpers shared between the pi-dashboard shell and dashboard plugins. Per-subpath exports; no markdown stack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -118,7 +118,8 @@
|
|
|
118
118
|
"react-dom": ">=18.0.0"
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
-
"@blackbelt-technology/
|
|
121
|
+
"@blackbelt-technology/dashboard-plugin-runtime": "^0.7.0",
|
|
122
|
+
"@blackbelt-technology/pi-dashboard-shared": "^0.7.0",
|
|
122
123
|
"@mdi/js": "^7.4.47",
|
|
123
124
|
"@mdi/react": "^1.6.1"
|
|
124
125
|
},
|
package/src/AGENTS.md
CHANGED
|
@@ -4,7 +4,7 @@ Files in this directory. One row per source file.
|
|
|
4
4
|
|
|
5
5
|
| File | Purpose |
|
|
6
6
|
|------|---------|
|
|
7
|
-
| `ActionList.tsx` | `ui:action-list` primitive. Exports `ActionList({ actions })` — horizontal row of MDI-icon + label buttons. `ExtendedActionItem` carries `dataAction` (pluginId/sessionId/action/payload) dispatched via `sendPluginAction`, or classical `onClick`. `IconByKey`
|
|
7
|
+
| `ActionList.tsx` | `ui:action-list` primitive. Exports `ActionList({ actions })` — horizontal row of MDI-icon + label buttons. `ExtendedActionItem` carries `dataAction` (pluginId/sessionId/action/payload) dispatched via `sendPluginAction`, or classical `onClick`. `IconByKey` reads `@mdi/js` eagerly (statically imported across the shell — synchronous flat property lookup, no dynamic import) and looks up path by export-name key. See change: shrink-client-index-chunk. |
|
|
8
8
|
| `agent-card-utils.ts` | Shared helpers for agent card rendering. Exports `formatTokens`, `formatDuration`, `AgentCardStatus` type, `StatusIconDef`, `statusIconDefs` (pending/running/complete/error/blocked/stopped/background → MDI icon + color), `getStatusIcon`. Used by `FlowAgentCard` and `AgentToolRenderer`. |
|
|
9
9
|
| `AgentCardShell.tsx` | Exports `AgentCardShell` — reusable card container with status-colored border, header row (status icon + name + optional `headerRight`), optional `stats` line, clickable/selected states. `getStatusIcon` drives icon + border color. Consumers pass tool-specific content as children. |
|
|
10
10
|
| `Confirm.tsx` | Confirm preset over Dialog (size sm). Props `{open,onClose,title,message,body?,intent?,confirmLabel?,cancelLabel?,onConfirm,testId?}`. Action → onConfirm only (no auto-close); cancel/Esc/overlay → onClose. Replaces legacy ConfirmDialog. See change: unify-dialog-system. |
|
|
@@ -16,7 +16,7 @@ Files in this directory. One row per source file.
|
|
|
16
16
|
| `Popover.tsx` | `ui:popover` primitive. Exports `Popover`, `PopoverProps`, `computePopoverPosition` (pure). Anchors floating panel to `anchorEl`'s rect; flips above on bottom overflow, shifts left on right overflow; recomputes on resize/scroll. Dismisses on outside mousedown or Escape. Body portal, not modal/scroll-lock/tooltip. |
|
|
17
17
|
| `SearchableSelectDialog.tsx` | Exports `SearchableSelectDialog`, `SelectOption`. Filterable list inside `Dialog` (size `sm`). Arrow/Enter/Esc keyboard nav, scrolls selected into view, optional badge. Used for single-select choices. |
|
|
18
18
|
| `Skeleton.tsx` | Skeleton primitive for content-layout loads. Props `{variant=text\|card\|bubble\|row, count?}`. Honors prefers-reduced-motion via useMediaQuery (static, no animate-pulse). aria-hidden. data-skeleton / data-skeleton-item / data-static markers. See change: extend-client-utils-state-feedback-primitives. |
|
|
19
|
-
| `StatusPill.tsx` | `ui:status-pill` primitive. Exports `StatusPill({ state, text, icon?, tooltip? })` — state-tinted pill. `STATE_STYLE_DARK`/`STATE_STYLE_LIGHT` palettes keyed by `UiStatusPillState` (running/success/info/warn/error/muted). `useIsLightTheme` observes `data-theme` attr. `IconByKey`
|
|
19
|
+
| `StatusPill.tsx` | `ui:status-pill` primitive. Exports `StatusPill({ state, text, icon?, tooltip? })` — state-tinted pill. `STATE_STYLE_DARK`/`STATE_STYLE_LIGHT` palettes keyed by `UiStatusPillState` (running/success/info/warn/error/muted). `useIsLightTheme` observes `data-theme` attr. `IconByKey` reads `@mdi/js` eagerly (statically imported across the shell — synchronous flat lookup, no dynamic import). See change: shrink-client-index-chunk. |
|
|
20
20
|
| `statusPresentation.ts` | `statusPresentation(kind)` maps StatusKind (done\|current\|todo\|error) to `{glyph, tokenVar, label}`. Glyph = mandatory non-hue channel (✓ done, ▸ current, ○ todo, ✕ error). tokenVar references semantic --status-* / --text-muted token. `statusAriaLabel(name, kind)` returns "Name, label". WCAG 2.2 §1.4.1. Consumed by composer ArtifactChip + board BoardStatePill. See change: extend-client-utils-state-feedback-primitives. |
|
|
21
21
|
| `useFocusTrap.ts` | `useFocusTrap(ref,open)` hook. Stores prev activeElement, focuses first focusable child on open, traps Tab/Shift+Tab, restores focus on close. See change: unify-dialog-system. |
|
|
22
22
|
| `useMediaQuery.ts` | Reactive CSS media-query hook. Returns match boolean. Guards missing window.matchMedia (returns false). See change: extend-client-utils-state-feedback-primitives. |
|
package/src/ActionList.tsx
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* See change: adopt-server-driven-intent-rendering.
|
|
9
9
|
*/
|
|
10
|
-
import React from "react";
|
|
11
10
|
import Icon from "@mdi/react";
|
|
11
|
+
import * as mdi from "@mdi/js";
|
|
12
12
|
// We accept icon as a string key (MDI), look up via resolveMdiIcon at render time.
|
|
13
13
|
import type { UiActionListProps } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
14
14
|
import { sendPluginAction } from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
@@ -75,23 +75,11 @@ export function ActionList({ actions }: UiActionListProps) {
|
|
|
75
75
|
* lookup.
|
|
76
76
|
*/
|
|
77
77
|
function IconByKey({ iconKey }: { iconKey: string }) {
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
let cancelled = false;
|
|
84
|
-
import("@mdi/js")
|
|
85
|
-
.then((mdi) => {
|
|
86
|
-
if (cancelled) return;
|
|
87
|
-
const candidate = (mdi as Record<string, unknown>)[iconKey];
|
|
88
|
-
setPath(typeof candidate === "string" ? candidate : null);
|
|
89
|
-
})
|
|
90
|
-
.catch(() => setPath(null));
|
|
91
|
-
return () => {
|
|
92
|
-
cancelled = true;
|
|
93
|
-
};
|
|
94
|
-
}, [iconKey]);
|
|
78
|
+
// @mdi/js is already eager (statically imported across the shell), so this
|
|
79
|
+
// is a synchronous flat property lookup — no dynamic import, no loading
|
|
80
|
+
// state. See change: shrink-client-index-chunk.
|
|
81
|
+
const candidate = (mdi as Record<string, unknown>)[iconKey];
|
|
82
|
+
const path = typeof candidate === "string" ? candidate : null;
|
|
95
83
|
if (!path) return null;
|
|
96
84
|
return <Icon path={path} size={0.6} />;
|
|
97
85
|
}
|
package/src/StatusPill.tsx
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import React, { useEffect, useState } from "react";
|
|
12
12
|
import Icon from "@mdi/react";
|
|
13
|
+
import * as mdi from "@mdi/js";
|
|
13
14
|
import type {
|
|
14
15
|
UiStatusPillProps,
|
|
15
16
|
UiStatusPillState,
|
|
@@ -64,20 +65,11 @@ export function StatusPill({ state, text, icon, tooltip }: UiStatusPillProps) {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
function IconByKey({ iconKey }: { iconKey: string }) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
if (cancelled) return;
|
|
73
|
-
const candidate = (mdi as Record<string, unknown>)[iconKey];
|
|
74
|
-
setPath(typeof candidate === "string" ? candidate : null);
|
|
75
|
-
})
|
|
76
|
-
.catch(() => setPath(null));
|
|
77
|
-
return () => {
|
|
78
|
-
cancelled = true;
|
|
79
|
-
};
|
|
80
|
-
}, [iconKey]);
|
|
68
|
+
// @mdi/js is already eager (statically imported across the shell), so this
|
|
69
|
+
// is a synchronous flat property lookup — no dynamic import, no loading
|
|
70
|
+
// state. See change: shrink-client-index-chunk.
|
|
71
|
+
const candidate = (mdi as Record<string, unknown>)[iconKey];
|
|
72
|
+
const path = typeof candidate === "string" ? candidate : null;
|
|
81
73
|
if (!path) return null;
|
|
82
74
|
return <Icon path={path} size={0.55} />;
|
|
83
75
|
}
|
|
@@ -50,4 +50,23 @@ describe("ActionList", () => {
|
|
|
50
50
|
);
|
|
51
51
|
expect(getByRole("button").getAttribute("title")).toBe("Run flow X");
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
// Post static-conversion (change: shrink-client-index-chunk): mdi[key] is a
|
|
55
|
+
// synchronous lookup, so the icon path renders immediately with no useEffect.
|
|
56
|
+
it("renders the icon <path> synchronously for a valid mdi key (test-plan #S3)", () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<ActionList actions={[{ label: "Refresh", icon: "mdiRefresh" }]} />,
|
|
59
|
+
);
|
|
60
|
+
const p = container.querySelector("svg path");
|
|
61
|
+
expect(p).toBeTruthy();
|
|
62
|
+
expect(p?.getAttribute("d") ?? "").not.toBe("");
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("renders no icon and does not throw for an unknown mdi key (test-plan #S3)", () => {
|
|
66
|
+
const { container } = render(
|
|
67
|
+
<ActionList actions={[{ label: "Nope", icon: "mdiNotAReal" }]} />,
|
|
68
|
+
);
|
|
69
|
+
expect(container.querySelector("svg path")).toBeNull();
|
|
70
|
+
expect(container.querySelector("button")?.textContent).toContain("Nope");
|
|
71
|
+
});
|
|
53
72
|
});
|
|
@@ -41,4 +41,23 @@ describe("StatusPill", () => {
|
|
|
41
41
|
);
|
|
42
42
|
expect(container.firstChild?.parentElement?.getAttribute("title") ?? container.querySelector("[title]")?.getAttribute("title")).toBe("Currently running");
|
|
43
43
|
});
|
|
44
|
+
|
|
45
|
+
// Post static-conversion (change: shrink-client-index-chunk): mdi[key] is a
|
|
46
|
+
// synchronous lookup, so the icon path renders immediately with no useEffect.
|
|
47
|
+
it("renders the icon <path> synchronously for a valid mdi key (test-plan #S3)", () => {
|
|
48
|
+
const { container } = render(
|
|
49
|
+
<StatusPill state="running" text="Working" icon="mdiRefresh" />,
|
|
50
|
+
);
|
|
51
|
+
const p = container.querySelector("svg path");
|
|
52
|
+
expect(p).toBeTruthy();
|
|
53
|
+
expect(p?.getAttribute("d") ?? "").not.toBe("");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("renders no icon and does not throw for an unknown mdi key (test-plan #S3)", () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<StatusPill state="error" text="Failed" icon="mdiNotAReal" />,
|
|
59
|
+
);
|
|
60
|
+
expect(container.querySelector("svg path")).toBeNull();
|
|
61
|
+
expect(container.querySelector("[data-status-pill]")?.textContent).toContain("Failed");
|
|
62
|
+
});
|
|
44
63
|
});
|