@locusgraph/loop 0.3.0 → 0.4.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.
Files changed (130) hide show
  1. package/dist/agent/index.d.ts +1 -1
  2. package/dist/agent/pulse/gradient-label.js +70 -17
  3. package/dist/agent/pulse/marks/bars-mark.js +39 -15
  4. package/dist/agent/pulse/marks/glyph-mark.js +57 -16
  5. package/dist/agent/pulse/marks/locus-mark.js +39 -13
  6. package/dist/agent/pulse/marks/orb-mark.js +21 -9
  7. package/dist/agent/pulse/pulse.js +1 -1
  8. package/dist/agent/pulse/use-loop-animation.d.ts +0 -1
  9. package/dist/agent/pulse/use-loop-animation.js +36 -15
  10. package/dist/agent/steps/step-icon.js +20 -13
  11. package/dist/agent/steps/steps.js +39 -37
  12. package/dist/agent/thinking/thinking.js +65 -62
  13. package/dist/agent/tool/json-block.js +10 -7
  14. package/dist/agent/tool/tool-status.d.ts +2 -0
  15. package/dist/agent/tool/tool-status.js +16 -13
  16. package/dist/agent/tool/tool.d.ts +8 -1
  17. package/dist/agent/tool/tool.js +238 -119
  18. package/dist/approval/inbox/inbox-row.d.ts +3 -3
  19. package/dist/approval/inbox/inbox-row.js +248 -86
  20. package/dist/approval/inbox/inbox.d.ts +3 -3
  21. package/dist/approval/inbox/inbox.js +251 -57
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +3 -3
  23. package/dist/approval/inbox/virtual-inbox-list.js +107 -30
  24. package/dist/approval/memory/memory-review.js +228 -91
  25. package/dist/approval/memory/memory-row.js +192 -56
  26. package/dist/approval/plan/plan-review.js +241 -108
  27. package/dist/approval/plan/plan-step-row.js +184 -77
  28. package/dist/approval/plan/plan-steps.d.ts +1 -1
  29. package/dist/approval/plan/plan-steps.js +2 -2
  30. package/dist/approval/plan/question-choices.js +139 -48
  31. package/dist/approval/plan/question.js +189 -67
  32. package/dist/approval/run/run-bar.js +138 -49
  33. package/dist/approval/shared/approval-line.d.ts +27 -0
  34. package/dist/approval/shared/approval-line.js +85 -0
  35. package/dist/approval/shared/risk-badge.d.ts +3 -5
  36. package/dist/approval/shared/risk-badge.js +11 -19
  37. package/dist/approval/shared/time.d.ts +0 -1
  38. package/dist/approval/shared/time.js +0 -1
  39. package/dist/approval/shared/use-focus-on-mount.js +23 -5
  40. package/dist/approval/shared/use-focus-when-settled.d.ts +2 -0
  41. package/dist/approval/shared/use-focus-when-settled.js +18 -0
  42. package/dist/approval/spend/raise-cap-form.d.ts +2 -2
  43. package/dist/approval/spend/raise-cap-form.js +235 -52
  44. package/dist/approval/spend/spend-gate.js +200 -106
  45. package/dist/approval/spend/spend-math.d.ts +1 -0
  46. package/dist/approval/spend/spend-math.js +5 -2
  47. package/dist/approval/spend/spend-meter.js +5 -5
  48. package/dist/approval/tool/approval.js +157 -96
  49. package/dist/approval/tool/args/args-editor.js +232 -81
  50. package/dist/approval/tool/args/args-field.js +333 -60
  51. package/dist/approval/tool/deny-form.js +114 -32
  52. package/dist/approval/tool/tool-inputs.js +93 -33
  53. package/dist/chat/chat/chat.js +5 -4
  54. package/dist/chat/chat/use-stick-to-bottom.js +116 -63
  55. package/dist/chat/chat/virtual-chat-items.js +129 -34
  56. package/dist/chat/composer/composer-actions.d.ts +1 -2
  57. package/dist/chat/composer/composer-actions.js +136 -50
  58. package/dist/chat/composer/composer-status.d.ts +2 -0
  59. package/dist/chat/composer/composer-status.js +3 -0
  60. package/dist/chat/composer/composer.d.ts +1 -1
  61. package/dist/chat/composer/composer.js +6 -4
  62. package/dist/chat/composer/use-auto-grow.js +29 -8
  63. package/dist/chat/files/files.js +296 -67
  64. package/dist/chat/index.d.ts +1 -1
  65. package/dist/chat/index.js +1 -1
  66. package/dist/chat/reply/fenced-code.js +1 -1
  67. package/dist/chat/reply/markdown-components.js +9 -116
  68. package/dist/chat/reply/reply.js +2 -2
  69. package/dist/chat/turn/group-parts.d.ts +1 -0
  70. package/dist/chat/turn/group-parts.js +6 -3
  71. package/dist/chat/turn/turn.js +13 -4
  72. package/dist/cost/context.js +3 -3
  73. package/dist/cost/cost-steps.js +31 -30
  74. package/dist/cost/cost.js +39 -39
  75. package/dist/cost/model-picker.js +176 -43
  76. package/dist/cost/shared/context-breakdown.js +10 -11
  77. package/dist/cost/shared/model-option-row.js +4 -3
  78. package/dist/cost/shared/step-cost-row.js +11 -12
  79. package/dist/cost/shared/usage-totals.d.ts +1 -0
  80. package/dist/cost/shared/usage-totals.js +19 -1
  81. package/dist/memory/cite.js +190 -59
  82. package/dist/memory/memorized.js +231 -62
  83. package/dist/memory/recall.js +272 -85
  84. package/dist/memory/shared/host-label.d.ts +1 -1
  85. package/dist/memory/shared/host-label.js +2 -2
  86. package/dist/memory/shared/source-mark.js +1 -1
  87. package/dist/memory/sources.d.ts +2 -1
  88. package/dist/memory/sources.js +277 -62
  89. package/dist/shared/decision-summary.js +2 -1
  90. package/dist/shared/line.d.ts +10 -0
  91. package/dist/shared/line.js +11 -0
  92. package/dist/shared/live-status.d.ts +3 -0
  93. package/dist/shared/live-status.js +11 -0
  94. package/dist/shared/reduced-motion.d.ts +1 -0
  95. package/dist/shared/reduced-motion.js +3 -0
  96. package/dist/shared/virtual/use-list-virtualizer.js +2 -0
  97. package/dist/thread/actions/action-button.js +1 -1
  98. package/dist/thread/actions/actions.d.ts +3 -1
  99. package/dist/thread/actions/actions.js +100 -81
  100. package/dist/thread/actions/branch-switcher.js +129 -23
  101. package/dist/thread/canvas/canvas-meta.d.ts +9 -0
  102. package/dist/thread/canvas/canvas-meta.js +35 -0
  103. package/dist/thread/canvas/canvas.d.ts +1 -1
  104. package/dist/thread/canvas/canvas.js +64 -74
  105. package/dist/thread/canvas/version-switcher.d.ts +1 -0
  106. package/dist/thread/canvas/version-switcher.js +161 -45
  107. package/dist/thread/code/code.js +4 -6
  108. package/dist/thread/code/copy-code-button.d.ts +2 -1
  109. package/dist/thread/code/copy-code-button.js +91 -26
  110. package/dist/thread/history/history.d.ts +1 -1
  111. package/dist/thread/history/history.js +104 -104
  112. package/dist/thread/history/row/history-row.js +106 -22
  113. package/dist/thread/history/row/thread-item-menu.js +84 -20
  114. package/dist/thread/history/row/thread-title-editor.js +74 -29
  115. package/dist/thread/history/virtual-history-list.js +83 -46
  116. package/dist/thread/index.d.ts +1 -0
  117. package/dist/thread/index.js +1 -0
  118. package/dist/thread/starters/starters.js +91 -28
  119. package/dist/thread/use-copied.js +40 -10
  120. package/package.json +6 -6
  121. package/dist/agent/shared/status-dot.d.ts +0 -1
  122. package/dist/agent/shared/status-dot.js +0 -1
  123. package/dist/approval/shared/decision-line.d.ts +0 -1
  124. package/dist/approval/shared/decision-line.js +0 -1
  125. package/dist/memory/shared/disclosure.d.ts +0 -6
  126. package/dist/memory/shared/disclosure.js +0 -6
  127. package/dist/shared/panel.d.ts +0 -19
  128. package/dist/shared/panel.js +0 -77
  129. package/dist/shared/status-dot.d.ts +0 -6
  130. package/dist/shared/status-dot.js +0 -20
@@ -1,82 +1,164 @@
1
- import { ArrowRight as ArrowRightIcon, ListChecked as ListChecksIcon } from "@carbon/icons-react";
2
- import { Button } from "@locusgraph/components";
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { Button, cn } from "@locusgraph/components";
3
5
  import { pluralize } from "@locusgraph/utils";
6
+ import { ArrowRight as ArrowRightIcon, ListChecks as ListChecksIcon } from "@phosphor-icons/react/ssr";
4
7
  import { useEffect, useId, useState } from "react";
5
- import { ApprovalPanel, LiveStatus, PanelBody, PanelFooter, PanelHeader, PanelTitle } from "../../shared/panel.js";
6
- import { DecisionSummary } from "../shared/decision-line.js";
8
+ import { DecisionSummary } from "../../shared/decision-summary.js";
9
+ import { LiveStatus } from "../../shared/live-status.js";
10
+ import { ApprovalHeadline, SettledLine } from "../shared/approval-line.js";
7
11
  import { useFocusOnMount } from "../shared/use-focus-on-mount.js";
12
+ import { useFocusWhenSettled } from "../shared/use-focus-when-settled.js";
8
13
  import { PlanStepRow, stepControlId } from "./plan-step-row.js";
9
14
  import { applyStepAction, describeStepAction, focusAfterAction } from "./plan-steps.js";
10
15
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
- function DecidedSteps({
12
- steps
13
- }) {
14
- return /*#__PURE__*/_jsx("ol", {
15
- className: "flex flex-col gap-1 pl-6.5 text-sm text-muted-foreground",
16
- children: steps.map((step, position) => /*#__PURE__*/_jsxs("li", {
17
- className: "flex gap-3",
18
- children: [/*#__PURE__*/_jsx("span", {
19
- className: "w-4 shrink-0 font-mono text-xs leading-5 tabular-nums",
20
- children: position + 1
21
- }), /*#__PURE__*/_jsx("span", {
22
- className: "min-w-0",
23
- children: step.title
24
- })]
25
- }, step.id))
26
- });
16
+ function DecidedSteps(t0) {
17
+ const $ = _c(4);
18
+ const {
19
+ steps
20
+ } = t0;
21
+ let t1;
22
+ if ($[0] !== steps) {
23
+ t1 = steps.map(_temp);
24
+ $[0] = steps;
25
+ $[1] = t1;
26
+ } else {
27
+ t1 = $[1];
28
+ }
29
+ let t2;
30
+ if ($[2] !== t1) {
31
+ t2 = /*#__PURE__*/_jsx("ol", {
32
+ className: "flex flex-col gap-1 pt-2 text-sm text-muted-foreground",
33
+ children: t1
34
+ });
35
+ $[2] = t1;
36
+ $[3] = t2;
37
+ } else {
38
+ t2 = $[3];
39
+ }
40
+ return t2;
41
+ }
42
+ function _temp(step, position) {
43
+ return /*#__PURE__*/_jsxs("li", {
44
+ className: "flex gap-3",
45
+ children: [/*#__PURE__*/_jsx("span", {
46
+ className: "w-4 shrink-0 text-xs leading-5 text-faint tabular-nums",
47
+ children: position + 1
48
+ }), /*#__PURE__*/_jsx("span", {
49
+ className: "min-w-0",
50
+ children: step.title
51
+ })]
52
+ }, step.id);
27
53
  }
28
- export function PlanReview({
29
- steps: initialSteps,
30
- title = "Review the plan",
31
- description = "The agent will run these steps in order. Edit, reorder or remove steps before it starts.",
32
- actionLabel,
33
- decision,
34
- onApprove,
35
- onCancel,
36
- autoFocus = true,
37
- className
38
- }) {
54
+ export function PlanReview(t0) {
55
+ const $ = _c(36);
56
+ const {
57
+ steps: initialSteps,
58
+ title: t1,
59
+ description: t2,
60
+ actionLabel,
61
+ decision,
62
+ onApprove,
63
+ onCancel,
64
+ autoFocus: t3,
65
+ className
66
+ } = t0;
67
+ const title = t1 === undefined ? "Review the plan" : t1;
68
+ const description = t2 === undefined ? "The agent will run these steps in order. Edit, reorder or remove steps before it starts." : t2;
69
+ const autoFocus = t3 === undefined ? true : t3;
39
70
  const idPrefix = useId();
40
71
  const [steps, setSteps] = useState(initialSteps);
41
72
  const [announcement, setAnnouncement] = useState("");
42
73
  const [pendingFocus, setPendingFocus] = useState(null);
43
74
  const approveRef = useFocusOnMount(autoFocus && !decision);
44
- const hasBlankTitle = steps.some(step => step.title.trim() === "");
45
- useEffect(() => {
46
- if (pendingFocus) document.getElementById(pendingFocus.id)?.focus();
47
- }, [pendingFocus]);
48
- function handleAction(stepId, position, action) {
49
- const next = applyStepAction(steps, stepId, action);
50
- const focus = focusAfterAction(next, stepId, action);
51
- setSteps(next);
52
- setAnnouncement(describeStepAction(position, action));
53
- setPendingFocus(focus ? {
54
- id: stepControlId(idPrefix, focus.stepId, focus.control)
55
- } : null);
75
+ const settleRef = useFocusWhenSettled(!decision);
76
+ let t4;
77
+ if ($[0] !== steps) {
78
+ t4 = steps.some(_temp2);
79
+ $[0] = steps;
80
+ $[1] = t4;
81
+ } else {
82
+ t4 = $[1];
56
83
  }
57
- function renameStep(stepId, nextTitle) {
58
- setSteps(current => current.map(item => item.id === stepId ? {
59
- ...item,
60
- title: nextTitle
61
- } : item));
84
+ const hasBlankTitle = t4;
85
+ let t5;
86
+ let t6;
87
+ if ($[2] !== pendingFocus) {
88
+ t5 = () => {
89
+ if (pendingFocus) {
90
+ document.getElementById(pendingFocus.id)?.focus();
91
+ }
92
+ };
93
+ t6 = [pendingFocus];
94
+ $[2] = pendingFocus;
95
+ $[3] = t5;
96
+ $[4] = t6;
97
+ } else {
98
+ t5 = $[3];
99
+ t6 = $[4];
62
100
  }
63
- return /*#__PURE__*/_jsxs(ApprovalPanel, {
64
- "data-slot": "plan-review",
65
- "data-decided": decision ? true : undefined,
66
- "aria-label": title,
67
- className: className,
68
- children: [/*#__PURE__*/_jsx(PanelHeader, {
101
+ useEffect(t5, t6);
102
+ let t7;
103
+ if ($[5] !== idPrefix || $[6] !== steps) {
104
+ t7 = function handleAction(stepId, position, action) {
105
+ const next = applyStepAction(steps, stepId, action);
106
+ const focus = focusAfterAction(next, stepId, action, position);
107
+ setSteps(next);
108
+ setAnnouncement(describeStepAction(position, action));
109
+ setPendingFocus(focus ? {
110
+ id: stepControlId(idPrefix, focus.stepId, focus.control)
111
+ } : null);
112
+ };
113
+ $[5] = idPrefix;
114
+ $[6] = steps;
115
+ $[7] = t7;
116
+ } else {
117
+ t7 = $[7];
118
+ }
119
+ const handleAction = t7;
120
+ let t8;
121
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
122
+ t8 = function renameStep(stepId_0, nextTitle) {
123
+ setSteps(current => current.map(item => item.id === stepId_0 ? {
124
+ ...item,
125
+ title: nextTitle
126
+ } : item));
127
+ };
128
+ $[8] = t8;
129
+ } else {
130
+ t8 = $[8];
131
+ }
132
+ const renameStep = t8;
133
+ let t9;
134
+ if ($[9] !== steps.length) {
135
+ t9 = pluralize(steps.length, "step");
136
+ $[9] = steps.length;
137
+ $[10] = t9;
138
+ } else {
139
+ t9 = $[10];
140
+ }
141
+ const stepCount = t9;
142
+ const t10 = decision ? true : undefined;
143
+ const t11 = !decision && "gap-3";
144
+ let t12;
145
+ if ($[11] !== className || $[12] !== t11) {
146
+ t12 = cn("flex min-w-0 flex-col outline-none", t11, className);
147
+ $[11] = className;
148
+ $[12] = t11;
149
+ $[13] = t12;
150
+ } else {
151
+ t12 = $[13];
152
+ }
153
+ let t13;
154
+ if ($[14] !== actionLabel || $[15] !== approveRef || $[16] !== decision || $[17] !== description || $[18] !== handleAction || $[19] !== hasBlankTitle || $[20] !== idPrefix || $[21] !== initialSteps || $[22] !== onApprove || $[23] !== onCancel || $[24] !== stepCount || $[25] !== steps) {
155
+ t13 = decision ? /*#__PURE__*/_jsxs(SettledLine, {
156
+ name: pluralize(initialSteps.length, "step"),
157
+ verb: "Planned",
69
158
  icon: /*#__PURE__*/_jsx(ListChecksIcon, {
159
+ weight: "bold",
70
160
  "aria-hidden": true
71
161
  }),
72
- eyebrow: "Plan",
73
- status: decision ? decision.approved ? "Approved" : "Cancelled" : "Waiting for you",
74
- tone: decision ? decision.approved ? "done" : "danger" : "waiting",
75
- aside: pluralize(steps.length, "step")
76
- }), /*#__PURE__*/_jsx(PanelTitle, {
77
- className: decision ? "text-muted-foreground" : undefined,
78
- children: title
79
- }), decision ? /*#__PURE__*/_jsxs(PanelBody, {
80
162
  children: [/*#__PURE__*/_jsx(DecisionSummary, {
81
163
  decision: decision,
82
164
  deniedVerb: "Cancelled",
@@ -85,55 +167,106 @@ export function PlanReview({
85
167
  steps: initialSteps
86
168
  })]
87
169
  }) : /*#__PURE__*/_jsxs(_Fragment, {
88
- children: [/*#__PURE__*/_jsx("p", {
89
- className: "px-5 pt-1 text-sm text-muted-foreground",
90
- children: description
91
- }), /*#__PURE__*/_jsx(PanelBody, {
92
- className: "pb-0",
93
- children: /*#__PURE__*/_jsx("ol", {
94
- className: "-mx-5 flex flex-col divide-y border-t",
95
- children: steps.map((step, position) => /*#__PURE__*/_jsx(PlanStepRow, {
96
- idPrefix: idPrefix,
97
- step: step,
98
- position: position,
99
- count: steps.length,
100
- onRename: nextTitle => renameStep(step.id, nextTitle),
101
- onAction: action => handleAction(step.id, position, action)
102
- }, step.id))
170
+ children: [/*#__PURE__*/_jsx(ApprovalHeadline, {
171
+ name: stepCount,
172
+ action: "to run",
173
+ icon: /*#__PURE__*/_jsx(ListChecksIcon, {
174
+ weight: "bold",
175
+ "aria-hidden": true
103
176
  })
104
- }), /*#__PURE__*/_jsxs(PanelFooter, {
105
- className: "justify-between",
106
- children: [hasBlankTitle ? /*#__PURE__*/_jsx("span", {
177
+ }), /*#__PURE__*/_jsx("p", {
178
+ className: "-mt-2 text-sm text-faint",
179
+ children: description
180
+ }), /*#__PURE__*/_jsx("ol", {
181
+ className: "flex flex-col",
182
+ children: steps.map((step_0, position_0) => /*#__PURE__*/_jsx(PlanStepRow, {
183
+ idPrefix: idPrefix,
184
+ step: step_0,
185
+ position: position_0,
186
+ count: steps.length,
187
+ onRename: nextTitle_0 => renameStep(step_0.id, nextTitle_0),
188
+ onAction: action_0 => handleAction(step_0.id, position_0, action_0)
189
+ }, step_0.id))
190
+ }), /*#__PURE__*/_jsxs("div", {
191
+ className: "flex flex-wrap items-center gap-2 pt-1",
192
+ children: [/*#__PURE__*/_jsxs(Button, {
193
+ ref: approveRef,
194
+ type: "button",
195
+ size: "sm",
196
+ disabled: hasBlankTitle || steps.length === 0,
197
+ onClick: () => onApprove(steps.map(_temp3)),
198
+ children: [actionLabel ?? `Run ${stepCount}`, /*#__PURE__*/_jsx(ArrowRightIcon, {
199
+ weight: "bold",
200
+ "aria-hidden": true
201
+ })]
202
+ }), /*#__PURE__*/_jsx(Button, {
203
+ type: "button",
204
+ size: "sm",
205
+ variant: "ghost",
206
+ onClick: onCancel,
207
+ children: "Cancel"
208
+ }), hasBlankTitle && /*#__PURE__*/_jsx("span", {
107
209
  className: "text-xs text-destructive",
108
210
  children: "Every step needs a title."
109
- }) : /*#__PURE__*/_jsx("span", {
110
- className: "hidden font-mono text-[11px] text-muted-foreground sm:inline",
111
- children: "The run starts when you approve"
112
- }), /*#__PURE__*/_jsxs("span", {
113
- className: "ml-auto flex gap-2",
114
- children: [/*#__PURE__*/_jsx(Button, {
115
- type: "button",
116
- size: "sm",
117
- variant: "ghost",
118
- onClick: onCancel,
119
- children: "Cancel"
120
- }), /*#__PURE__*/_jsxs(Button, {
121
- ref: approveRef,
122
- type: "button",
123
- size: "sm",
124
- disabled: hasBlankTitle || steps.length === 0,
125
- onClick: () => onApprove(steps.map(step => ({
126
- ...step,
127
- title: step.title.trim()
128
- }))),
129
- children: [actionLabel ?? `Run ${pluralize(steps.length, "step")}`, /*#__PURE__*/_jsx(ArrowRightIcon, {
130
- "aria-hidden": true
131
- })]
132
- })]
133
211
  })]
134
212
  })]
135
- }), /*#__PURE__*/_jsx(LiveStatus, {
136
- message: decision ? decision.approved ? "Plan approved" : "Plan cancelled" : announcement
137
- })]
138
- });
213
+ });
214
+ $[14] = actionLabel;
215
+ $[15] = approveRef;
216
+ $[16] = decision;
217
+ $[17] = description;
218
+ $[18] = handleAction;
219
+ $[19] = hasBlankTitle;
220
+ $[20] = idPrefix;
221
+ $[21] = initialSteps;
222
+ $[22] = onApprove;
223
+ $[23] = onCancel;
224
+ $[24] = stepCount;
225
+ $[25] = steps;
226
+ $[26] = t13;
227
+ } else {
228
+ t13 = $[26];
229
+ }
230
+ const t14 = decision ? decision.approved ? "Plan approved" : "Plan cancelled" : announcement;
231
+ let t15;
232
+ if ($[27] !== t14) {
233
+ t15 = /*#__PURE__*/_jsx(LiveStatus, {
234
+ message: t14
235
+ });
236
+ $[27] = t14;
237
+ $[28] = t15;
238
+ } else {
239
+ t15 = $[28];
240
+ }
241
+ let t16;
242
+ if ($[29] !== settleRef || $[30] !== t10 || $[31] !== t12 || $[32] !== t13 || $[33] !== t15 || $[34] !== title) {
243
+ t16 = /*#__PURE__*/_jsxs("section", {
244
+ ref: settleRef,
245
+ tabIndex: -1,
246
+ "data-slot": "plan-review",
247
+ "data-decided": t10,
248
+ "aria-label": title,
249
+ className: t12,
250
+ children: [t13, t15]
251
+ });
252
+ $[29] = settleRef;
253
+ $[30] = t10;
254
+ $[31] = t12;
255
+ $[32] = t13;
256
+ $[33] = t15;
257
+ $[34] = title;
258
+ $[35] = t16;
259
+ } else {
260
+ t16 = $[35];
261
+ }
262
+ return t16;
263
+ }
264
+ function _temp3(step_1) {
265
+ return {
266
+ ...step_1,
267
+ title: step_1.title.trim()
268
+ };
269
+ }
270
+ function _temp2(step) {
271
+ return step.title.trim() === "";
139
272
  }
@@ -1,5 +1,8 @@
1
- import { ArrowDown as ArrowDownIcon, ArrowUp as ArrowUpIcon, Edit as PencilIcon, TrashCan as Trash2Icon } from "@carbon/icons-react";
1
+ "use client";
2
+
3
+ import { c as _c } from "react/compiler-runtime";
2
4
  import { Button, cn } from "@locusgraph/components";
5
+ import { ArrowDown as ArrowDownIcon, ArrowUp as ArrowUpIcon, PencilSimple as PencilIcon, Trash as Trash2Icon } from "@phosphor-icons/react/ssr";
3
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
7
  export function stepControlId(idPrefix, stepId, action) {
5
8
  return `${idPrefix}-${stepId}-${action}`;
@@ -11,87 +14,191 @@ function selectInputById(id) {
11
14
  element.select();
12
15
  }
13
16
  }
14
- export function PlanStepRow({
15
- idPrefix,
16
- step,
17
- position,
18
- count,
19
- onRename,
20
- onAction
21
- }) {
17
+ export function PlanStepRow(t0) {
18
+ const $ = _c(34);
19
+ const {
20
+ idPrefix,
21
+ step,
22
+ position,
23
+ count,
24
+ onRename,
25
+ onAction
26
+ } = t0;
22
27
  const number = position + 1;
23
- const titleId = stepControlId(idPrefix, step.id, "title");
24
- const blank = step.title.trim() === "";
25
- const controls = [{
26
- id: `${idPrefix}-${step.id}-edit`,
27
- label: `Edit step ${number}`,
28
- icon: PencilIcon,
29
- disabled: false,
30
- onClick: () => selectInputById(titleId)
31
- }, {
32
- id: stepControlId(idPrefix, step.id, "up"),
33
- label: `Move step ${number} up`,
34
- icon: ArrowUpIcon,
35
- disabled: position === 0,
36
- onClick: () => onAction("up")
37
- }, {
38
- id: stepControlId(idPrefix, step.id, "down"),
39
- label: `Move step ${number} down`,
40
- icon: ArrowDownIcon,
41
- disabled: position === count - 1,
42
- onClick: () => onAction("down")
43
- }, {
44
- id: stepControlId(idPrefix, step.id, "remove"),
45
- label: `Remove step ${number}`,
46
- icon: Trash2Icon,
47
- disabled: count === 1,
48
- onClick: () => onAction("remove"),
49
- danger: true
50
- }];
51
- return /*#__PURE__*/_jsxs("li", {
52
- "data-slot": "plan-step",
53
- className: "group flex items-start gap-3 px-5 py-2.5 focus-within:bg-accent/50 hover:bg-accent/50 motion-safe:transition-colors",
54
- children: [/*#__PURE__*/_jsx("span", {
55
- "aria-hidden": true,
56
- className: "mt-0.5 flex size-5 shrink-0 items-center justify-center font-mono text-[11px] text-muted-foreground tabular-nums ring-1 ring-input",
57
- children: number
58
- }), /*#__PURE__*/_jsxs("div", {
28
+ let t1;
29
+ let t2;
30
+ let t3;
31
+ let t4;
32
+ let t5;
33
+ let t6;
34
+ if ($[0] !== count || $[1] !== idPrefix || $[2] !== number || $[3] !== onAction || $[4] !== onRename || $[5] !== position || $[6] !== step.detail || $[7] !== step.id || $[8] !== step.title) {
35
+ const titleId = stepControlId(idPrefix, step.id, "title");
36
+ let t7;
37
+ if ($[15] !== step.title) {
38
+ t7 = step.title.trim();
39
+ $[15] = step.title;
40
+ $[16] = t7;
41
+ } else {
42
+ t7 = $[16];
43
+ }
44
+ const blank = t7 === "";
45
+ const controls = [{
46
+ id: `${idPrefix}-${step.id}-edit`,
47
+ label: `Edit step ${number}`,
48
+ icon: PencilIcon,
49
+ disabled: false,
50
+ onClick: () => selectInputById(titleId)
51
+ }, {
52
+ id: stepControlId(idPrefix, step.id, "up"),
53
+ label: `Move step ${number} up`,
54
+ icon: ArrowUpIcon,
55
+ disabled: position === 0,
56
+ onClick: () => onAction("up")
57
+ }, {
58
+ id: stepControlId(idPrefix, step.id, "down"),
59
+ label: `Move step ${number} down`,
60
+ icon: ArrowDownIcon,
61
+ disabled: position === count - 1,
62
+ onClick: () => onAction("down")
63
+ }, {
64
+ id: stepControlId(idPrefix, step.id, "remove"),
65
+ label: `Remove step ${number}`,
66
+ icon: Trash2Icon,
67
+ disabled: count === 1,
68
+ onClick: () => onAction("remove"),
69
+ danger: true
70
+ }];
71
+ t3 = "plan-step";
72
+ t4 = "group flex items-start gap-3 py-1";
73
+ if ($[17] !== number) {
74
+ t5 = /*#__PURE__*/_jsx("span", {
75
+ "aria-hidden": true,
76
+ className: "flex h-control-xs w-5 shrink-0 items-center text-xs text-faint tabular-nums",
77
+ children: number
78
+ });
79
+ $[17] = number;
80
+ $[18] = t5;
81
+ } else {
82
+ t5 = $[18];
83
+ }
84
+ const t8 = step.title;
85
+ let t9;
86
+ if ($[19] !== onRename) {
87
+ t9 = event => onRename(event.target.value);
88
+ $[19] = onRename;
89
+ $[20] = t9;
90
+ } else {
91
+ t9 = $[20];
92
+ }
93
+ const t10 = blank && "ring-1 ring-destructive/70";
94
+ let t11;
95
+ if ($[21] !== t10) {
96
+ t11 = cn("-mx-1.5 h-control-xs min-w-0 bg-transparent px-1.5 text-sm text-foreground outline-none placeholder:text-faint hover:bg-muted/50 focus-visible:bg-muted focus-visible:ring-1 focus-visible:ring-ring", t10);
97
+ $[21] = t10;
98
+ $[22] = t11;
99
+ } else {
100
+ t11 = $[22];
101
+ }
102
+ let t12;
103
+ if ($[23] !== step.detail) {
104
+ t12 = step.detail && /*#__PURE__*/_jsx("p", {
105
+ className: "text-xs text-faint",
106
+ children: step.detail
107
+ });
108
+ $[23] = step.detail;
109
+ $[24] = t12;
110
+ } else {
111
+ t12 = $[24];
112
+ }
113
+ t6 = /*#__PURE__*/_jsxs("div", {
59
114
  className: "flex min-w-0 flex-1 flex-col gap-0.5",
60
115
  children: [/*#__PURE__*/_jsx("input", {
61
116
  id: titleId,
62
117
  "aria-label": `Step ${number} title`,
63
- value: step.title,
118
+ value: t8,
64
119
  placeholder: "Name this step",
65
120
  "aria-invalid": blank || undefined,
66
- onChange: event => onRename(event.target.value),
67
- className: cn("-mx-1.5 h-6 min-w-0 bg-transparent px-1.5 text-sm font-medium outline-none placeholder:font-normal placeholder:text-muted-foreground focus-visible:bg-background focus-visible:ring-1 focus-visible:ring-ring", blank && "ring-1 ring-destructive/70")
68
- }), step.detail && /*#__PURE__*/_jsx("p", {
69
- className: "text-xs text-muted-foreground",
70
- children: step.detail
71
- })]
72
- }), /*#__PURE__*/_jsx("div", {
73
- className: "flex shrink-0 gap-0.5 sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100 sm:motion-safe:transition-opacity",
74
- children: controls.map(({
75
- id,
76
- label,
77
- icon: Icon,
78
- disabled,
79
- onClick,
80
- danger
81
- }) => /*#__PURE__*/_jsx(Button, {
82
- id: id,
83
- type: "button",
84
- variant: "ghost",
85
- size: "icon-xs",
86
- "aria-label": label,
87
- title: label,
88
- disabled: disabled,
89
- onClick: onClick,
90
- className: cn("text-muted-foreground hover:text-foreground", danger && "hover:text-destructive"),
91
- children: /*#__PURE__*/_jsx(Icon, {
92
- "aria-hidden": true
93
- })
94
- }, id))
95
- })]
96
- });
121
+ onChange: t9,
122
+ className: t11
123
+ }), t12]
124
+ });
125
+ t1 = "flex shrink-0 gap-0.5 sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100 sm:motion-safe:transition-opacity";
126
+ t2 = controls.map(_temp);
127
+ $[0] = count;
128
+ $[1] = idPrefix;
129
+ $[2] = number;
130
+ $[3] = onAction;
131
+ $[4] = onRename;
132
+ $[5] = position;
133
+ $[6] = step.detail;
134
+ $[7] = step.id;
135
+ $[8] = step.title;
136
+ $[9] = t1;
137
+ $[10] = t2;
138
+ $[11] = t3;
139
+ $[12] = t4;
140
+ $[13] = t5;
141
+ $[14] = t6;
142
+ } else {
143
+ t1 = $[9];
144
+ t2 = $[10];
145
+ t3 = $[11];
146
+ t4 = $[12];
147
+ t5 = $[13];
148
+ t6 = $[14];
149
+ }
150
+ let t7;
151
+ if ($[25] !== t1 || $[26] !== t2) {
152
+ t7 = /*#__PURE__*/_jsx("div", {
153
+ className: t1,
154
+ children: t2
155
+ });
156
+ $[25] = t1;
157
+ $[26] = t2;
158
+ $[27] = t7;
159
+ } else {
160
+ t7 = $[27];
161
+ }
162
+ let t8;
163
+ if ($[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7) {
164
+ t8 = /*#__PURE__*/_jsxs("li", {
165
+ "data-slot": t3,
166
+ className: t4,
167
+ children: [t5, t6, t7]
168
+ });
169
+ $[28] = t3;
170
+ $[29] = t4;
171
+ $[30] = t5;
172
+ $[31] = t6;
173
+ $[32] = t7;
174
+ $[33] = t8;
175
+ } else {
176
+ t8 = $[33];
177
+ }
178
+ return t8;
179
+ }
180
+ function _temp(t0) {
181
+ const {
182
+ id,
183
+ label,
184
+ icon: Icon,
185
+ disabled,
186
+ onClick,
187
+ danger
188
+ } = t0;
189
+ return /*#__PURE__*/_jsx(Button, {
190
+ id: id,
191
+ type: "button",
192
+ variant: "ghost",
193
+ size: "icon-xs",
194
+ "aria-label": label,
195
+ title: label,
196
+ disabled: disabled,
197
+ onClick: onClick,
198
+ className: cn("text-faint hover:bg-transparent hover:text-interactive", danger && "hover:text-destructive"),
199
+ children: /*#__PURE__*/_jsx(Icon, {
200
+ weight: "bold",
201
+ "aria-hidden": true
202
+ })
203
+ }, id);
97
204
  }
@@ -1,7 +1,7 @@
1
1
  import type { PlanStepDraft } from "../types.js";
2
2
  import type { StepAction } from "./plan-step-row.js";
3
3
  export declare function applyStepAction(steps: PlanStepDraft[], stepId: string, action: StepAction): PlanStepDraft[];
4
- export declare function focusAfterAction(steps: PlanStepDraft[], stepId: string, action: StepAction): {
4
+ export declare function focusAfterAction(steps: PlanStepDraft[], stepId: string, action: StepAction, removedPosition?: number): {
5
5
  stepId: string;
6
6
  control: StepAction | "title";
7
7
  } | null;