@camstack/ui-library 1.2.261 → 1.2.262
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/composites/role-node-pill.d.ts +12 -5
- package/dist/index.cjs +44 -19
- package/dist/index.js +44 -19
- package/package.json +1 -1
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* RoleNodePill —
|
|
3
|
-
*
|
|
2
|
+
* RoleNodePill — a node tinted by its palette colour (agent-settings `color`,
|
|
3
|
+
* else stable hash). With a `roleLabel`, shows role · node · colour (Assignments).
|
|
4
|
+
* Without, colour icon + name only (Nodes selector and similar).
|
|
4
5
|
*/
|
|
5
6
|
import type { NodeColorId } from "@camstack/types";
|
|
6
|
-
import type { JSX } from "react";
|
|
7
|
+
import type { JSX, ReactNode } from "react";
|
|
7
8
|
export interface RoleNodePillProps {
|
|
8
|
-
|
|
9
|
+
/** When omitted, the pill is colour icon + node name only. */
|
|
10
|
+
readonly roleLabel?: string;
|
|
9
11
|
readonly nodeName: string;
|
|
10
12
|
readonly colorId: NodeColorId;
|
|
11
13
|
readonly emphasized?: boolean;
|
|
12
14
|
readonly pinned?: boolean;
|
|
15
|
+
/** When set, the pill is a selectable control (`role="tab"`). */
|
|
16
|
+
readonly onSelect?: () => void;
|
|
17
|
+
readonly disabled?: boolean;
|
|
18
|
+
/** Extra trailing content inside the pill (e.g. "offline"). */
|
|
19
|
+
readonly trailing?: ReactNode;
|
|
13
20
|
}
|
|
14
|
-
export declare function RoleNodePill({ roleLabel, nodeName, colorId, emphasized, pinned }: RoleNodePillProps): JSX.Element;
|
|
21
|
+
export declare function RoleNodePill({ roleLabel, nodeName, colorId, emphasized, pinned, onSelect, disabled, trailing }: RoleNodePillProps): JSX.Element;
|
package/dist/index.cjs
CHANGED
|
@@ -32854,26 +32854,51 @@ var NODE_RING_CLASS = {
|
|
|
32854
32854
|
"node-g": "ring-node-g/45",
|
|
32855
32855
|
"node-h": "ring-node-h/45"
|
|
32856
32856
|
};
|
|
32857
|
-
function RoleNodePill({ roleLabel, nodeName, colorId, emphasized = false, pinned = false }) {
|
|
32858
|
-
|
|
32857
|
+
function RoleNodePill({ roleLabel, nodeName, colorId, emphasized = false, pinned = false, onSelect, disabled = false, trailing }) {
|
|
32858
|
+
const title = roleLabel !== void 0 ? pinned ? `${roleLabel} pinned on ${nodeName}` : `${roleLabel} on ${nodeName}` : nodeName;
|
|
32859
|
+
const className = cn("inline-flex max-w-full items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight ring-1 ring-inset", emphasized ? cn("role-node-pill-emphasized font-semibold ring-2", NODE_BG_EMPHASIZED_CLASS[colorId], NODE_RING_CLASS[colorId], nodeTextColorClass(colorId)) : cn("font-medium text-foreground-muted ring-border/60", NODE_BG_SOFT_CLASS[colorId]), onSelect !== void 0 && !disabled && "cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40", disabled && "cursor-not-allowed opacity-50");
|
|
32860
|
+
const colorIcon = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32861
|
+
className: cn("h-1.5 w-1.5 shrink-0 rounded-full", nodeColorClass(colorId)),
|
|
32862
|
+
"aria-hidden": true
|
|
32863
|
+
});
|
|
32864
|
+
const body = roleLabel !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
32865
|
+
pinned && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pin, {
|
|
32866
|
+
className: "h-2.5 w-2.5 shrink-0 opacity-80",
|
|
32867
|
+
"aria-label": "pinned"
|
|
32868
|
+
}),
|
|
32869
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32870
|
+
className: "shrink-0",
|
|
32871
|
+
children: roleLabel
|
|
32872
|
+
}),
|
|
32873
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32874
|
+
className: cn("min-w-0 truncate", emphasized ? nodeTextColorClass(colorId) : "text-foreground-subtle"),
|
|
32875
|
+
children: nodeName
|
|
32876
|
+
}),
|
|
32877
|
+
colorIcon
|
|
32878
|
+
] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
32879
|
+
colorIcon,
|
|
32880
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32881
|
+
className: cn("min-w-0 truncate font-medium", emphasized ? nodeTextColorClass(colorId) : "text-foreground"),
|
|
32882
|
+
children: nodeName
|
|
32883
|
+
}),
|
|
32884
|
+
trailing
|
|
32885
|
+
] });
|
|
32886
|
+
if (onSelect !== void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
32887
|
+
type: "button",
|
|
32888
|
+
role: "tab",
|
|
32889
|
+
"aria-selected": emphasized,
|
|
32859
32890
|
"data-testid": "role-node-pill",
|
|
32860
|
-
title
|
|
32861
|
-
|
|
32862
|
-
|
|
32863
|
-
|
|
32864
|
-
|
|
32865
|
-
|
|
32866
|
-
|
|
32867
|
-
|
|
32868
|
-
|
|
32869
|
-
|
|
32870
|
-
|
|
32871
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32872
|
-
className: cn("min-w-0 truncate", emphasized ? nodeTextColorClass(colorId) : "text-foreground-subtle"),
|
|
32873
|
-
children: nodeName
|
|
32874
|
-
}),
|
|
32875
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: cn("h-1.5 w-1.5 shrink-0 rounded-full", nodeColorClass(colorId)) })
|
|
32876
|
-
]
|
|
32891
|
+
title,
|
|
32892
|
+
disabled,
|
|
32893
|
+
onClick: onSelect,
|
|
32894
|
+
className,
|
|
32895
|
+
children: body
|
|
32896
|
+
});
|
|
32897
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
32898
|
+
"data-testid": "role-node-pill",
|
|
32899
|
+
title,
|
|
32900
|
+
className,
|
|
32901
|
+
children: body
|
|
32877
32902
|
});
|
|
32878
32903
|
}
|
|
32879
32904
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -32830,26 +32830,51 @@ var NODE_RING_CLASS = {
|
|
|
32830
32830
|
"node-g": "ring-node-g/45",
|
|
32831
32831
|
"node-h": "ring-node-h/45"
|
|
32832
32832
|
};
|
|
32833
|
-
function RoleNodePill({ roleLabel, nodeName, colorId, emphasized = false, pinned = false }) {
|
|
32834
|
-
|
|
32833
|
+
function RoleNodePill({ roleLabel, nodeName, colorId, emphasized = false, pinned = false, onSelect, disabled = false, trailing }) {
|
|
32834
|
+
const title = roleLabel !== void 0 ? pinned ? `${roleLabel} pinned on ${nodeName}` : `${roleLabel} on ${nodeName}` : nodeName;
|
|
32835
|
+
const className = cn("inline-flex max-w-full items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight ring-1 ring-inset", emphasized ? cn("role-node-pill-emphasized font-semibold ring-2", NODE_BG_EMPHASIZED_CLASS[colorId], NODE_RING_CLASS[colorId], nodeTextColorClass(colorId)) : cn("font-medium text-foreground-muted ring-border/60", NODE_BG_SOFT_CLASS[colorId]), onSelect !== void 0 && !disabled && "cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40", disabled && "cursor-not-allowed opacity-50");
|
|
32836
|
+
const colorIcon = /* @__PURE__ */ jsx("span", {
|
|
32837
|
+
className: cn("h-1.5 w-1.5 shrink-0 rounded-full", nodeColorClass(colorId)),
|
|
32838
|
+
"aria-hidden": true
|
|
32839
|
+
});
|
|
32840
|
+
const body = roleLabel !== void 0 ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
32841
|
+
pinned && /* @__PURE__ */ jsx(Pin, {
|
|
32842
|
+
className: "h-2.5 w-2.5 shrink-0 opacity-80",
|
|
32843
|
+
"aria-label": "pinned"
|
|
32844
|
+
}),
|
|
32845
|
+
/* @__PURE__ */ jsx("span", {
|
|
32846
|
+
className: "shrink-0",
|
|
32847
|
+
children: roleLabel
|
|
32848
|
+
}),
|
|
32849
|
+
/* @__PURE__ */ jsx("span", {
|
|
32850
|
+
className: cn("min-w-0 truncate", emphasized ? nodeTextColorClass(colorId) : "text-foreground-subtle"),
|
|
32851
|
+
children: nodeName
|
|
32852
|
+
}),
|
|
32853
|
+
colorIcon
|
|
32854
|
+
] }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
32855
|
+
colorIcon,
|
|
32856
|
+
/* @__PURE__ */ jsx("span", {
|
|
32857
|
+
className: cn("min-w-0 truncate font-medium", emphasized ? nodeTextColorClass(colorId) : "text-foreground"),
|
|
32858
|
+
children: nodeName
|
|
32859
|
+
}),
|
|
32860
|
+
trailing
|
|
32861
|
+
] });
|
|
32862
|
+
if (onSelect !== void 0) return /* @__PURE__ */ jsx("button", {
|
|
32863
|
+
type: "button",
|
|
32864
|
+
role: "tab",
|
|
32865
|
+
"aria-selected": emphasized,
|
|
32835
32866
|
"data-testid": "role-node-pill",
|
|
32836
|
-
title
|
|
32837
|
-
|
|
32838
|
-
|
|
32839
|
-
|
|
32840
|
-
|
|
32841
|
-
|
|
32842
|
-
|
|
32843
|
-
|
|
32844
|
-
|
|
32845
|
-
|
|
32846
|
-
|
|
32847
|
-
/* @__PURE__ */ jsx("span", {
|
|
32848
|
-
className: cn("min-w-0 truncate", emphasized ? nodeTextColorClass(colorId) : "text-foreground-subtle"),
|
|
32849
|
-
children: nodeName
|
|
32850
|
-
}),
|
|
32851
|
-
/* @__PURE__ */ jsx("span", { className: cn("h-1.5 w-1.5 shrink-0 rounded-full", nodeColorClass(colorId)) })
|
|
32852
|
-
]
|
|
32867
|
+
title,
|
|
32868
|
+
disabled,
|
|
32869
|
+
onClick: onSelect,
|
|
32870
|
+
className,
|
|
32871
|
+
children: body
|
|
32872
|
+
});
|
|
32873
|
+
return /* @__PURE__ */ jsx("span", {
|
|
32874
|
+
"data-testid": "role-node-pill",
|
|
32875
|
+
title,
|
|
32876
|
+
className,
|
|
32877
|
+
children: body
|
|
32853
32878
|
});
|
|
32854
32879
|
}
|
|
32855
32880
|
//#endregion
|