@upbound/monarch-blocks 0.13.3 → 0.14.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/dist/index.js CHANGED
@@ -6614,7 +6614,7 @@ import { useCallback as useCallback10, useState as useState13 } from "react";
6614
6614
  // src/graph/graph-node.tsx
6615
6615
  import * as React14 from "react";
6616
6616
  import { getIncomers, getOutgoers, Handle, Position as Position2 } from "reactflow";
6617
- import { Badge as Badge5, Card as Card2, Icon as Icon13, Spinner, Tooltip as Tooltip9, TooltipContent as TooltipContent8, TooltipTrigger as TooltipTrigger8 } from "@upbound/monarch-core";
6617
+ import { Badge as Badge5, Button as Button10, Card as Card2, Icon as Icon13, Tooltip as Tooltip9, TooltipContent as TooltipContent8, TooltipTrigger as TooltipTrigger8 } from "@upbound/monarch-core";
6618
6618
 
6619
6619
  // src/graph/consts.ts
6620
6620
  var GRAPH_NODE_WIDTH = 260;
@@ -6663,7 +6663,7 @@ function isDefaultNode(node) {
6663
6663
  return node.type !== "loading";
6664
6664
  }
6665
6665
  function GraphNode(_a) {
6666
- var _b = _a, { id, data } = _b, props = __objRest(_b, ["id", "data"]);
6666
+ var _b = _a, { id, data, selected } = _b, props = __objRest(_b, ["id", "data", "selected"]);
6667
6667
  var _a2, _b2;
6668
6668
  const { nodes: originalNodes, edges: originalEdges } = useGraphActionsContext();
6669
6669
  const nodes = originalNodes;
@@ -6723,10 +6723,11 @@ function GraphNode(_a) {
6723
6723
  Card2,
6724
6724
  {
6725
6725
  className: cn(
6726
- "relative gap-1.5 overflow-visible rounded-lg py-0",
6726
+ "relative gap-1.5 overflow-visible rounded-xl py-0",
6727
6727
  `flex h-[106px]! w-[260px]! flex-col pt-2.5! pb-0!`,
6728
6728
  `hover:shadow-md motion-safe:transition-shadow`,
6729
- compact && `h-[47px]!`
6729
+ compact && `h-[47px]!`,
6730
+ (selected || data.isHighlighted) && "ring-primary ring-2"
6730
6731
  ),
6731
6732
  style: { height: compact ? GRAPH_NODE_COLLAPSED_HEIGHT : GRAPH_NODE_HEIGHT, width: GRAPH_NODE_WIDTH },
6732
6733
  children: [
@@ -6744,34 +6745,32 @@ function GraphNode(_a) {
6744
6745
  ),
6745
6746
  /* @__PURE__ */ jsxs18("div", { className: "flex w-full flex-1 cursor-pointer flex-col", onClick: handleClick, children: [
6746
6747
  /* @__PURE__ */ jsxs18("div", { className: cn("flex w-full justify-between gap-1 px-2.5", compact && "flex-row-reverse items-start"), children: [
6747
- !!compact && /* @__PURE__ */ jsxs18(Fragment10, { children: [
6748
- compactBadges.length > 0 && /* @__PURE__ */ jsx21("div", { className: "flex shrink-0 flex-row items-center gap-1.5 overflow-hidden", children: compactBadges.map((_c, index) => {
6749
- var _d = _c, { tooltipContent, variant } = _d, badge = __objRest(_d, ["tooltipContent", "variant"]);
6750
- return /* @__PURE__ */ jsxs18(Tooltip9, { children: [
6751
- /* @__PURE__ */ jsx21(TooltipTrigger8, { children: /* @__PURE__ */ jsx21(
6752
- Badge5,
6753
- __spreadProps(__spreadValues({
6754
- variant
6755
- }, badge), {
6756
- className: "flex size-[20px]! cursor-default! items-center justify-center p-0!",
6757
- children: badge.children
6758
- })
6759
- ) }),
6760
- tooltipContent && /* @__PURE__ */ jsx21(TooltipContent8, { children: tooltipContent })
6761
- ] }, index);
6762
- }) }),
6763
- state === "progressing" && /* @__PURE__ */ jsx21("div", { className: "flex shrink-0 flex-row items-center gap-1.5 overflow-hidden", children: /* @__PURE__ */ jsx21("div", { className: "flex size-[20px]! items-center justify-center", children: /* @__PURE__ */ jsx21(Spinner, { size: "sm" }) }) })
6764
- ] }),
6748
+ !!compact && /* @__PURE__ */ jsx21(Fragment10, { children: compactBadges.length > 0 && /* @__PURE__ */ jsx21("div", { className: "flex shrink-0 flex-row items-center gap-1.5 overflow-hidden", children: compactBadges.map((_c, index) => {
6749
+ var _d = _c, { tooltipContent, variant } = _d, badge = __objRest(_d, ["tooltipContent", "variant"]);
6750
+ return /* @__PURE__ */ jsxs18(Tooltip9, { children: [
6751
+ /* @__PURE__ */ jsx21(TooltipTrigger8, { children: /* @__PURE__ */ jsx21(
6752
+ Badge5,
6753
+ __spreadProps(__spreadValues({
6754
+ variant
6755
+ }, badge), {
6756
+ className: "flex size-[20px]! cursor-default! items-center justify-center p-0!",
6757
+ children: badge.children
6758
+ })
6759
+ ) }),
6760
+ tooltipContent && /* @__PURE__ */ jsx21(TooltipContent8, { children: tooltipContent })
6761
+ ] }, index);
6762
+ }) }) }),
6765
6763
  /* @__PURE__ */ jsxs18("div", { className: "mr-auto grow-0 overflow-hidden", children: [
6766
- /* @__PURE__ */ jsx21("h5", { className: "text-body-sm/tight truncate font-bold", children: data.title }),
6767
- /* @__PURE__ */ jsx21("p", { className: "text-body-sm truncate leading-none", children: data.subtitle }),
6768
- !compact && /* @__PURE__ */ jsx21("p", { className: "text-body-sm text-muted-foreground mt-1 truncate", children: data.name })
6764
+ /* @__PURE__ */ jsx21("h5", { className: "text-body-sm truncate font-medium", children: data.title }),
6765
+ /* @__PURE__ */ jsx21("p", { className: "text-body-sm text-muted-foreground truncate", children: data.subtitle }),
6766
+ !compact && /* @__PURE__ */ jsx21("p", { className: "text-body-sm text-muted-foreground mt-0.5 truncate", children: data.name })
6769
6767
  ] }),
6770
6768
  /* @__PURE__ */ jsx21(
6771
- "span",
6769
+ Badge5,
6772
6770
  {
6771
+ variant: "secondary",
6773
6772
  className: cn(
6774
- "bg-foreground text-background inline-flex h-[26px] w-auto shrink-0 items-center justify-center rounded-md px-[7px] text-[10px] font-semibold",
6773
+ "cursor-default!",
6775
6774
  ["progressing", "paused"].includes(state) && "opacity-30",
6776
6775
  data.typeDescriptors.className
6777
6776
  ),
@@ -6779,16 +6778,13 @@ function GraphNode(_a) {
6779
6778
  }
6780
6779
  )
6781
6780
  ] }),
6782
- !compact && /* @__PURE__ */ jsx21(Fragment10, { children: (defaultBadges.length > 0 || state === "progressing") && /* @__PURE__ */ jsxs18("div", { className: "mt-auto flex h-8 items-center border-t px-2.5", children: [
6783
- /* @__PURE__ */ jsx21("div", { className: "flex gap-1.5 overflow-hidden overflow-x-auto", children: defaultBadges.map((_e, index) => {
6784
- var _f = _e, { tooltipContent, variant } = _f, badge = __objRest(_f, ["tooltipContent", "variant"]);
6785
- return /* @__PURE__ */ jsxs18(Tooltip9, { children: [
6786
- /* @__PURE__ */ jsx21(TooltipTrigger8, { children: /* @__PURE__ */ jsx21(Badge5, __spreadProps(__spreadValues({ variant }, badge), { className: "cursor-default! py-px! whitespace-nowrap", children: badge.children })) }),
6787
- tooltipContent && /* @__PURE__ */ jsx21(TooltipContent8, { children: tooltipContent })
6788
- ] }, index);
6789
- }) }),
6790
- state === "progressing" && /* @__PURE__ */ jsx21("div", { className: "ml-auto flex size-[20px]! items-center justify-center", children: /* @__PURE__ */ jsx21(Spinner, { size: "sm" }) })
6791
- ] }) })
6781
+ !compact && /* @__PURE__ */ jsx21(Fragment10, { children: defaultBadges.length > 0 && /* @__PURE__ */ jsx21("div", { className: "mt-auto flex h-8 items-center border-t px-2.5", children: /* @__PURE__ */ jsx21("div", { className: "flex gap-1.5 overflow-hidden overflow-x-auto", children: defaultBadges.map((_e, index) => {
6782
+ var _f = _e, { tooltipContent, variant } = _f, badge = __objRest(_f, ["tooltipContent", "variant"]);
6783
+ return /* @__PURE__ */ jsxs18(Tooltip9, { children: [
6784
+ /* @__PURE__ */ jsx21(TooltipTrigger8, { children: /* @__PURE__ */ jsx21(Badge5, __spreadProps(__spreadValues({ variant }, badge), { className: "cursor-default! py-px! whitespace-nowrap", children: badge.children })) }),
6785
+ tooltipContent && /* @__PURE__ */ jsx21(TooltipContent8, { children: tooltipContent })
6786
+ ] }, index);
6787
+ }) }) }) })
6792
6788
  ] }),
6793
6789
  !!hasOutgoingEdge && /* @__PURE__ */ jsxs18(
6794
6790
  "div",
@@ -6815,11 +6811,13 @@ function GraphNode(_a) {
6815
6811
  ) }),
6816
6812
  /* @__PURE__ */ jsxs18(Tooltip9, { children: [
6817
6813
  /* @__PURE__ */ jsx21(TooltipTrigger8, { asChild: true, children: /* @__PURE__ */ jsx21(
6818
- "button",
6814
+ Button10,
6819
6815
  {
6820
6816
  type: "button",
6817
+ variant: "outline",
6818
+ size: "icon-xs",
6821
6819
  "aria-label": data.expanded ? "Collapse" : "Expand",
6822
- className: "bg-foreground text-background hover:bg-foreground/90 focus-visible:ring-ring/30 absolute top-[calc(50%)] left-[calc(50%)] inline-flex size-4 -translate-1/2 items-center justify-center rounded-full p-0 text-center text-[10px] leading-none duration-150 outline-none focus-visible:ring-2 motion-safe:transition-colors",
6820
+ className: "absolute top-1/2 left-1/2 size-5 -translate-1/2 rounded-full active:not-aria-[haspopup]:-translate-1/2",
6823
6821
  onClick: (e) => {
6824
6822
  var _a3;
6825
6823
  e.stopPropagation();
@@ -6855,7 +6853,7 @@ function GraphNodeSkeleton(_props) {
6855
6853
  Card2,
6856
6854
  {
6857
6855
  className: cn(
6858
- `flex h-[106px]! w-[260px]! flex-col gap-1.5 rounded-lg px-0 py-0 pt-2.5! pb-0! hover:shadow-md motion-safe:transition-shadow`,
6856
+ `flex h-[106px]! w-[260px]! flex-col gap-1.5 rounded-xl px-0 py-0 pt-2.5! pb-0! hover:shadow-md motion-safe:transition-shadow`,
6859
6857
  compact && `h-[47px]!`
6860
6858
  ),
6861
6859
  children: [
@@ -7226,7 +7224,15 @@ function useViewportFocus(nodeMap, viewportFocusNodeId) {
7226
7224
 
7227
7225
  // src/graph/graph-view.tsx
7228
7226
  import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
7229
- var GraphViewInternal = ({ nodeTypes: parentNodeTypes, edgeTypes: parentEdgeTypes, children, viewportFocusNodeId }) => {
7227
+ var GraphViewInternal = ({
7228
+ nodeTypes: parentNodeTypes,
7229
+ edgeTypes: parentEdgeTypes,
7230
+ children,
7231
+ viewportFocusNodeId,
7232
+ className,
7233
+ hideMiniMap = false,
7234
+ hideControls = false
7235
+ }) => {
7230
7236
  const { nodes, edges, toggleNodeExpansion } = useGraphActionsContext();
7231
7237
  const nodeTypes = React17.useMemo(
7232
7238
  () => __spreadValues({
@@ -7265,6 +7271,7 @@ var GraphViewInternal = ({ nodeTypes: parentNodeTypes, edgeTypes: parentEdgeType
7265
7271
  return /* @__PURE__ */ jsxs19(
7266
7272
  ReactFlow,
7267
7273
  {
7274
+ className: cn("overflow-hidden rounded-xl border", className),
7268
7275
  nodeTypes,
7269
7276
  edgeTypes,
7270
7277
  nodes: layoutedNodes,
@@ -7281,17 +7288,40 @@ var GraphViewInternal = ({ nodeTypes: parentNodeTypes, edgeTypes: parentEdgeType
7281
7288
  panOnScroll: true,
7282
7289
  selectionOnDrag: true,
7283
7290
  children: [
7284
- /* @__PURE__ */ jsx23(Background, { className: "bg-muted text-muted" }),
7285
- /* @__PURE__ */ jsx23(Controls, { showInteractive: false }),
7286
- /* @__PURE__ */ jsx23(MiniMap, { zoomable: true, pannable: true }),
7291
+ /* @__PURE__ */ jsx23(Background, { className: "bg-muted/50", size: 2 }),
7292
+ !hideControls && /* @__PURE__ */ jsx23(Controls, { showInteractive: false }),
7293
+ !hideMiniMap && /* @__PURE__ */ jsx23(MiniMap, { zoomable: true, pannable: true }),
7287
7294
  children
7288
7295
  ]
7289
7296
  }
7290
7297
  );
7291
7298
  };
7292
- var GraphView = React17.forwardRef(({ defaultNodes = [], defaultEdges = [], nodeTypes, edgeTypes, children, viewportFocusNodeId }, ref) => {
7293
- return /* @__PURE__ */ jsx23(ReactFlowProvider, { children: /* @__PURE__ */ jsx23(GraphActionsProvider, { ref, initialNodes: defaultNodes, initialEdges: defaultEdges, children: /* @__PURE__ */ jsx23(GraphViewInternal, { nodeTypes, edgeTypes, viewportFocusNodeId, children }) }) });
7294
- });
7299
+ var GraphView = React17.forwardRef(
7300
+ ({
7301
+ defaultNodes = [],
7302
+ defaultEdges = [],
7303
+ nodeTypes,
7304
+ edgeTypes,
7305
+ children,
7306
+ viewportFocusNodeId,
7307
+ className,
7308
+ hideMiniMap,
7309
+ hideControls
7310
+ }, ref) => {
7311
+ return /* @__PURE__ */ jsx23(ReactFlowProvider, { children: /* @__PURE__ */ jsx23(GraphActionsProvider, { ref, initialNodes: defaultNodes, initialEdges: defaultEdges, children: /* @__PURE__ */ jsx23(
7312
+ GraphViewInternal,
7313
+ {
7314
+ nodeTypes,
7315
+ edgeTypes,
7316
+ viewportFocusNodeId,
7317
+ className,
7318
+ hideMiniMap,
7319
+ hideControls,
7320
+ children
7321
+ }
7322
+ ) }) });
7323
+ }
7324
+ );
7295
7325
  GraphView.displayName = "GraphView";
7296
7326
 
7297
7327
  // src/graph/graph.tsx
@@ -7320,6 +7350,9 @@ function Graph({
7320
7350
  emptyView,
7321
7351
  showError,
7322
7352
  className,
7353
+ canvasClassName,
7354
+ hideMiniMap = false,
7355
+ hideControls = false,
7323
7356
  loading = false,
7324
7357
  ActionsComponent: Actions,
7325
7358
  disableSearch = false,
@@ -7414,6 +7447,9 @@ function Graph({
7414
7447
  ref: graphRef,
7415
7448
  nodeTypes: memoizedNodeTypes,
7416
7449
  edgeTypes: memoizedEdgeTypes,
7450
+ className: canvasClassName,
7451
+ hideMiniMap,
7452
+ hideControls,
7417
7453
  children
7418
7454
  }
7419
7455
  )