@protolabsai/ui 0.22.0 → 0.22.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.
@@ -2896,11 +2896,16 @@ a.pl-changelog__version:hover {
2896
2896
  overflow: hidden;
2897
2897
  }
2898
2898
 
2899
+ .pl-toolcard__head-row {
2900
+ display: flex;
2901
+ align-items: center;
2902
+ }
2899
2903
  .pl-toolcard__head {
2904
+ flex: 1 1 auto;
2905
+ min-width: 0;
2900
2906
  display: flex;
2901
2907
  align-items: center;
2902
2908
  gap: 7px;
2903
- width: 100%;
2904
2909
  padding: 6px 9px;
2905
2910
  background: none;
2906
2911
  border: none;
@@ -2910,6 +2915,14 @@ a.pl-changelog__version:hover {
2910
2915
  text-align: left;
2911
2916
  cursor: pointer;
2912
2917
  }
2918
+ .pl-toolcard__actions {
2919
+ flex: none;
2920
+ display: inline-flex;
2921
+ align-items: center;
2922
+ gap: 2px;
2923
+ padding-right: 6px;
2924
+ color: var(--pl-color-fg-muted);
2925
+ }
2913
2926
  .pl-toolcard__head:disabled {
2914
2927
  cursor: default;
2915
2928
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protolabsai/ui",
3
- "version": "0.22.0",
3
+ "version": "0.22.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,7 +21,26 @@ export const States: Story = {
21
21
  render: () => (
22
22
  <div style={{ maxWidth: 460 }}>
23
23
  <ToolCardList>
24
- <ToolCard name="web_fetch" status="done" icon={<Globe />} duration={1240} defaultOpen>
24
+ <ToolCard
25
+ name="web_fetch"
26
+ status="done"
27
+ icon={<Globe />}
28
+ duration={1240}
29
+ defaultOpen
30
+ actions={
31
+ <button
32
+ type="button"
33
+ className="pl-btn pl-btn--ghost pl-btn--icon pl-btn--sm"
34
+ title="Re-run"
35
+ onClick={(e) => e.stopPropagation()}
36
+ >
37
+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
38
+ <path d="M23 4v6h-6M1 20v-6h6" />
39
+ <path d="M3.5 9a9 9 0 0 1 14.9-3.4L23 10M1 14l4.6 4.4A9 9 0 0 0 20.5 15" />
40
+ </svg>
41
+ </button>
42
+ }
43
+ >
25
44
  <ToolSection label="input" copyText='{"url":"https://protolabs.studio"}'>
26
45
  <Mono>{`{ "url": "https://protolabs.studio" }`}</Mono>
27
46
  </ToolSection>
@@ -24,11 +24,16 @@
24
24
  overflow: hidden;
25
25
  }
26
26
 
27
+ .pl-toolcard__head-row {
28
+ display: flex;
29
+ align-items: center;
30
+ }
27
31
  .pl-toolcard__head {
32
+ flex: 1 1 auto;
33
+ min-width: 0;
28
34
  display: flex;
29
35
  align-items: center;
30
36
  gap: 7px;
31
- width: 100%;
32
37
  padding: 6px 9px;
33
38
  background: none;
34
39
  border: none;
@@ -38,6 +43,14 @@
38
43
  text-align: left;
39
44
  cursor: pointer;
40
45
  }
46
+ .pl-toolcard__actions {
47
+ flex: none;
48
+ display: inline-flex;
49
+ align-items: center;
50
+ gap: 2px;
51
+ padding-right: 6px;
52
+ color: var(--pl-color-fg-muted);
53
+ }
41
54
  .pl-toolcard__head:disabled {
42
55
  cursor: default;
43
56
  }
package/src/tool-card.tsx CHANGED
@@ -61,6 +61,7 @@ export function ToolCard({
61
61
  duration,
62
62
  defaultOpen = false,
63
63
  nested,
64
+ actions,
64
65
  children,
65
66
  className,
66
67
  }: {
@@ -73,6 +74,9 @@ export function ToolCard({
73
74
  defaultOpen?: boolean;
74
75
  /** Indented child tool cards for a subagent `task`. */
75
76
  nested?: ReactNode;
77
+ /** Trailing header slot — hang a re-run / per-tool affordance here. Sits outside
78
+ * the disclosure toggle (so it can hold its own buttons). */
79
+ actions?: ReactNode;
76
80
  /** Expanded body — the rendered input/result (compose `ToolSection`s). */
77
81
  children?: ReactNode;
78
82
  className?: string;
@@ -81,34 +85,37 @@ export function ToolCard({
81
85
  const hasBody = children != null;
82
86
  const card = (
83
87
  <div className={cx("pl-toolcard", `pl-toolcard--${status}`, className)}>
84
- <button
85
- type="button"
86
- className="pl-toolcard__head"
87
- aria-expanded={hasBody ? open : undefined}
88
- disabled={!hasBody}
89
- onClick={() => setOpen((v) => !v)}
90
- >
91
- <span
92
- className={cx(
93
- "pl-toolcard__caret",
94
- !hasBody && "pl-toolcard__caret--hidden",
95
- open && "pl-toolcard__caret--open",
96
- )}
97
- aria-hidden
88
+ <div className="pl-toolcard__head-row">
89
+ <button
90
+ type="button"
91
+ className="pl-toolcard__head"
92
+ aria-expanded={hasBody ? open : undefined}
93
+ disabled={!hasBody}
94
+ onClick={() => setOpen((v) => !v)}
98
95
  >
99
- <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round">
100
- <path d="M9 6l6 6-6 6" />
101
- </svg>
102
- </span>
103
- {icon != null && (
104
- <span className="pl-toolcard__icon" aria-hidden>
105
- {icon}
96
+ <span
97
+ className={cx(
98
+ "pl-toolcard__caret",
99
+ !hasBody && "pl-toolcard__caret--hidden",
100
+ open && "pl-toolcard__caret--open",
101
+ )}
102
+ aria-hidden
103
+ >
104
+ <svg viewBox="0 0 24 24" width="13" height="13" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round" strokeLinejoin="round">
105
+ <path d="M9 6l6 6-6 6" />
106
+ </svg>
106
107
  </span>
107
- )}
108
- <span className="pl-toolcard__name">{name}</span>
109
- {duration != null && <span className="pl-toolcard__dur">{formatDuration(duration)}</span>}
110
- <StatusGlyph status={status} />
111
- </button>
108
+ {icon != null && (
109
+ <span className="pl-toolcard__icon" aria-hidden>
110
+ {icon}
111
+ </span>
112
+ )}
113
+ <span className="pl-toolcard__name">{name}</span>
114
+ {duration != null && <span className="pl-toolcard__dur">{formatDuration(duration)}</span>}
115
+ <StatusGlyph status={status} />
116
+ </button>
117
+ {actions != null && <div className="pl-toolcard__actions">{actions}</div>}
118
+ </div>
112
119
  {hasBody && open && <div className="pl-toolcard__body">{children}</div>}
113
120
  </div>
114
121
  );