@locusgraph/loop 0.1.0 → 0.2.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 (115) hide show
  1. package/README.md +2 -0
  2. package/dist/agent/pulse/gradient-label.js +86 -15
  3. package/dist/agent/pulse/marks/bars-mark.js +46 -10
  4. package/dist/agent/pulse/marks/glyph-mark.js +56 -11
  5. package/dist/agent/pulse/marks/locus-mark.js +63 -28
  6. package/dist/agent/pulse/marks/orb-mark.js +31 -8
  7. package/dist/agent/pulse/marks/spinner-mark.js +29 -1
  8. package/dist/agent/pulse/pulse.js +150 -35
  9. package/dist/agent/pulse/use-loop-animation.js +36 -17
  10. package/dist/agent/steps/step-icon.js +110 -24
  11. package/dist/agent/steps/steps.js +235 -25
  12. package/dist/agent/thinking/thinking.js +203 -23
  13. package/dist/agent/thinking/thought-duration.js +7 -9
  14. package/dist/agent/tool/json-block.js +38 -11
  15. package/dist/agent/tool/tool-status.js +51 -18
  16. package/dist/agent/tool/tool.js +184 -6
  17. package/dist/approval/inbox/inbox-row.d.ts +3 -2
  18. package/dist/approval/inbox/inbox-row.js +321 -7
  19. package/dist/approval/inbox/inbox-selection.js +7 -13
  20. package/dist/approval/inbox/inbox.d.ts +2 -1
  21. package/dist/approval/inbox/inbox.js +250 -18
  22. package/dist/approval/inbox/virtual-inbox-list.d.ts +13 -0
  23. package/dist/approval/inbox/virtual-inbox-list.js +129 -0
  24. package/dist/approval/memory/memory-choices.js +27 -22
  25. package/dist/approval/memory/memory-review.js +242 -17
  26. package/dist/approval/memory/memory-row.js +215 -19
  27. package/dist/approval/plan/plan-review.js +279 -28
  28. package/dist/approval/plan/plan-step-row.js +194 -43
  29. package/dist/approval/plan/plan-steps.js +24 -23
  30. package/dist/approval/plan/question-choices.js +158 -39
  31. package/dist/approval/plan/question.d.ts +1 -1
  32. package/dist/approval/plan/question.js +223 -26
  33. package/dist/approval/run/run-bar.js +178 -22
  34. package/dist/approval/shared/decision-line.js +1 -1
  35. package/dist/approval/shared/risk-badge.js +47 -16
  36. package/dist/approval/shared/time.js +5 -8
  37. package/dist/approval/shared/use-focus-on-mount.js +23 -6
  38. package/dist/approval/spend/raise-cap-form.js +235 -17
  39. package/dist/approval/spend/spend-gate.js +239 -21
  40. package/dist/approval/spend/spend-math.js +7 -8
  41. package/dist/approval/spend/spend-meter.js +362 -34
  42. package/dist/approval/tool/approval.js +272 -27
  43. package/dist/approval/tool/args/args-editor.js +262 -26
  44. package/dist/approval/tool/args/args-field.js +259 -19
  45. package/dist/approval/tool/args/args-validation.js +38 -47
  46. package/dist/approval/tool/deny-form.js +130 -10
  47. package/dist/approval/tool/tool-inputs.js +127 -38
  48. package/dist/chat/chat/chat-item-spacing.d.ts +3 -0
  49. package/dist/chat/chat/chat-item-spacing.js +19 -0
  50. package/dist/chat/chat/chat.d.ts +2 -1
  51. package/dist/chat/chat/chat.js +181 -5
  52. package/dist/chat/chat/use-stick-to-bottom.js +123 -47
  53. package/dist/chat/chat/virtual-chat-items.d.ts +8 -0
  54. package/dist/chat/chat/virtual-chat-items.js +153 -0
  55. package/dist/chat/composer/composer-actions.js +151 -16
  56. package/dist/chat/composer/composer.js +330 -32
  57. package/dist/chat/composer/use-auto-grow.js +24 -9
  58. package/dist/chat/files/file-meta.js +19 -19
  59. package/dist/chat/files/files.js +316 -28
  60. package/dist/chat/reply/fenced-code.js +45 -21
  61. package/dist/chat/reply/markdown-components.js +137 -17
  62. package/dist/chat/reply/reply.js +105 -10
  63. package/dist/chat/turn/group-parts.js +43 -29
  64. package/dist/chat/turn/turn.js +238 -30
  65. package/dist/cost/context.js +321 -23
  66. package/dist/cost/cost-steps.js +220 -14
  67. package/dist/cost/cost.js +521 -27
  68. package/dist/cost/model-picker.js +181 -6
  69. package/dist/cost/shared/context-breakdown.js +299 -10
  70. package/dist/cost/shared/meter-marks.js +107 -9
  71. package/dist/cost/shared/model-option-row.js +178 -21
  72. package/dist/cost/shared/step-cost-row.js +248 -20
  73. package/dist/cost/shared/usage-totals.js +22 -18
  74. package/dist/memory/cite.js +182 -11
  75. package/dist/memory/memorized.js +217 -11
  76. package/dist/memory/recall.js +296 -17
  77. package/dist/memory/shared/host-label.js +19 -22
  78. package/dist/memory/shared/source-mark.js +39 -3
  79. package/dist/memory/sources.js +255 -13
  80. package/dist/shared/decision-summary.js +133 -14
  81. package/dist/shared/panel-empty.js +78 -3
  82. package/dist/shared/panel.js +243 -13
  83. package/dist/shared/status-dot.js +38 -8
  84. package/dist/shared/virtual/use-list-virtualizer.d.ts +24 -0
  85. package/dist/shared/virtual/use-list-virtualizer.js +68 -0
  86. package/dist/thread/actions/action-button.js +65 -3
  87. package/dist/thread/actions/actions.js +184 -13
  88. package/dist/thread/actions/branch-switcher.js +102 -5
  89. package/dist/thread/canvas/canvas.js +205 -5
  90. package/dist/thread/canvas/version-switcher.js +149 -8
  91. package/dist/thread/code/code.js +186 -24
  92. package/dist/thread/code/copy-code-button.js +61 -13
  93. package/dist/thread/code/highlight.js +30 -29
  94. package/dist/thread/history/history-rows.d.ts +16 -0
  95. package/dist/thread/history/history-rows.js +23 -0
  96. package/dist/thread/history/history.d.ts +3 -2
  97. package/dist/thread/history/history.js +174 -5
  98. package/dist/thread/history/{history-row.d.ts → row/history-row.d.ts} +3 -2
  99. package/dist/thread/history/row/history-row.js +137 -0
  100. package/dist/thread/history/row/thread-item-menu.js +84 -0
  101. package/dist/thread/history/row/thread-title-editor.js +81 -0
  102. package/dist/thread/history/thread-groups.d.ts +1 -1
  103. package/dist/thread/history/thread-groups.js +40 -34
  104. package/dist/thread/history/virtual-history-list.d.ts +11 -0
  105. package/dist/thread/history/virtual-history-list.js +107 -0
  106. package/dist/thread/index.d.ts +1 -1
  107. package/dist/thread/starters/starters.js +92 -7
  108. package/dist/thread/use-copied.js +45 -15
  109. package/dist/types.js +1 -1
  110. package/package.json +6 -4
  111. package/dist/thread/history/history-row.js +0 -17
  112. package/dist/thread/history/thread-item-menu.js +0 -6
  113. package/dist/thread/history/thread-title-editor.js +0 -25
  114. /package/dist/thread/history/{thread-item-menu.d.ts → row/thread-item-menu.d.ts} +0 -0
  115. /package/dist/thread/history/{thread-title-editor.d.ts → row/thread-title-editor.d.ts} +0 -0
@@ -1,50 +1,201 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { ArrowDown as ArrowDownIcon, ArrowUp as ArrowUpIcon, Edit as PencilIcon, TrashCan as Trash2Icon, } from "@carbon/icons-react";
1
+ import { c as _c } from "react/compiler-runtime";
2
+ import { ArrowDown as ArrowDownIcon, ArrowUp as ArrowUpIcon, Edit as PencilIcon, TrashCan as Trash2Icon } from "@carbon/icons-react";
3
3
  import { Button, cn } from "@locusgraph/components";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
5
  export function stepControlId(idPrefix, stepId, action) {
5
- return `${idPrefix}-${stepId}-${action}`;
6
+ return `${idPrefix}-${stepId}-${action}`;
6
7
  }
7
8
  function selectInputById(id) {
8
- const element = document.getElementById(id);
9
- if (element instanceof HTMLInputElement) {
10
- element.focus();
11
- element.select();
12
- }
9
+ const element = document.getElementById(id);
10
+ if (element instanceof HTMLInputElement) {
11
+ element.focus();
12
+ element.select();
13
+ }
13
14
  }
14
- export function PlanStepRow({ idPrefix, step, position, count, onRename, onAction, }) {
15
- const number = position + 1;
15
+ export function PlanStepRow(t0) {
16
+ const $ = _c(34);
17
+ const {
18
+ idPrefix,
19
+ step,
20
+ position,
21
+ count,
22
+ onRename,
23
+ onAction
24
+ } = t0;
25
+ const number = position + 1;
26
+ let t1;
27
+ let t2;
28
+ let t3;
29
+ let t4;
30
+ let t5;
31
+ let t6;
32
+ if ($[0] !== count || $[1] !== idPrefix || $[2] !== number || $[3] !== onAction || $[4] !== onRename || $[5] !== position || $[6] !== step.detail || $[7] !== step.id || $[8] !== step.title) {
16
33
  const titleId = stepControlId(idPrefix, step.id, "title");
17
- const blank = step.title.trim() === "";
18
- const controls = [
19
- {
20
- id: `${idPrefix}-${step.id}-edit`,
21
- label: `Edit step ${number}`,
22
- icon: PencilIcon,
23
- disabled: false,
24
- onClick: () => selectInputById(titleId),
25
- },
26
- {
27
- id: stepControlId(idPrefix, step.id, "up"),
28
- label: `Move step ${number} up`,
29
- icon: ArrowUpIcon,
30
- disabled: position === 0,
31
- onClick: () => onAction("up"),
32
- },
33
- {
34
- id: stepControlId(idPrefix, step.id, "down"),
35
- label: `Move step ${number} down`,
36
- icon: ArrowDownIcon,
37
- disabled: position === count - 1,
38
- onClick: () => onAction("down"),
39
- },
40
- {
41
- id: stepControlId(idPrefix, step.id, "remove"),
42
- label: `Remove step ${number}`,
43
- icon: Trash2Icon,
44
- disabled: count === 1,
45
- onClick: () => onAction("remove"),
46
- danger: true,
47
- },
48
- ];
49
- return (_jsxs("li", { "data-slot": "plan-step", 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", children: [_jsx("span", { "aria-hidden": true, 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", children: number }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsx("input", { id: titleId, "aria-label": `Step ${number} title`, value: step.title, placeholder: "Name this step", "aria-invalid": blank || undefined, onChange: (event) => onRename(event.target.value), 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") }), step.detail && _jsx("p", { className: "text-xs text-muted-foreground", children: step.detail })] }), _jsx("div", { 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", children: controls.map(({ id, label, icon: Icon, disabled, onClick, danger }) => (_jsx(Button, { id: id, type: "button", variant: "ghost", size: "icon-xs", "aria-label": label, title: label, disabled: disabled, onClick: onClick, className: cn("text-muted-foreground hover:text-foreground", danger && "hover:text-destructive"), children: _jsx(Icon, { "aria-hidden": true }) }, id))) })] }));
34
+ let t7;
35
+ if ($[15] !== step.title) {
36
+ t7 = step.title.trim();
37
+ $[15] = step.title;
38
+ $[16] = t7;
39
+ } else {
40
+ t7 = $[16];
41
+ }
42
+ const blank = t7 === "";
43
+ const controls = [{
44
+ id: `${idPrefix}-${step.id}-edit`,
45
+ label: `Edit step ${number}`,
46
+ icon: PencilIcon,
47
+ disabled: false,
48
+ onClick: () => selectInputById(titleId)
49
+ }, {
50
+ id: stepControlId(idPrefix, step.id, "up"),
51
+ label: `Move step ${number} up`,
52
+ icon: ArrowUpIcon,
53
+ disabled: position === 0,
54
+ onClick: () => onAction("up")
55
+ }, {
56
+ id: stepControlId(idPrefix, step.id, "down"),
57
+ label: `Move step ${number} down`,
58
+ icon: ArrowDownIcon,
59
+ disabled: position === count - 1,
60
+ onClick: () => onAction("down")
61
+ }, {
62
+ id: stepControlId(idPrefix, step.id, "remove"),
63
+ label: `Remove step ${number}`,
64
+ icon: Trash2Icon,
65
+ disabled: count === 1,
66
+ onClick: () => onAction("remove"),
67
+ danger: true
68
+ }];
69
+ t3 = "plan-step";
70
+ t4 = "group flex items-start gap-3 px-5 py-2.5 focus-within:bg-accent/50 hover:bg-accent/50 motion-safe:transition-colors";
71
+ if ($[17] !== number) {
72
+ t5 = /*#__PURE__*/_jsx("span", {
73
+ "aria-hidden": true,
74
+ 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",
75
+ children: number
76
+ });
77
+ $[17] = number;
78
+ $[18] = t5;
79
+ } else {
80
+ t5 = $[18];
81
+ }
82
+ const t8 = step.title;
83
+ let t9;
84
+ if ($[19] !== onRename) {
85
+ t9 = event => onRename(event.target.value);
86
+ $[19] = onRename;
87
+ $[20] = t9;
88
+ } else {
89
+ t9 = $[20];
90
+ }
91
+ const t10 = blank && "ring-1 ring-destructive/70";
92
+ let t11;
93
+ if ($[21] !== t10) {
94
+ t11 = 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", t10);
95
+ $[21] = t10;
96
+ $[22] = t11;
97
+ } else {
98
+ t11 = $[22];
99
+ }
100
+ let t12;
101
+ if ($[23] !== step.detail) {
102
+ t12 = step.detail && /*#__PURE__*/_jsx("p", {
103
+ className: "text-xs text-muted-foreground",
104
+ children: step.detail
105
+ });
106
+ $[23] = step.detail;
107
+ $[24] = t12;
108
+ } else {
109
+ t12 = $[24];
110
+ }
111
+ t6 = /*#__PURE__*/_jsxs("div", {
112
+ className: "flex min-w-0 flex-1 flex-col gap-0.5",
113
+ children: [/*#__PURE__*/_jsx("input", {
114
+ id: titleId,
115
+ "aria-label": `Step ${number} title`,
116
+ value: t8,
117
+ placeholder: "Name this step",
118
+ "aria-invalid": blank || undefined,
119
+ onChange: t9,
120
+ className: t11
121
+ }), t12]
122
+ });
123
+ 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";
124
+ t2 = controls.map(_temp);
125
+ $[0] = count;
126
+ $[1] = idPrefix;
127
+ $[2] = number;
128
+ $[3] = onAction;
129
+ $[4] = onRename;
130
+ $[5] = position;
131
+ $[6] = step.detail;
132
+ $[7] = step.id;
133
+ $[8] = step.title;
134
+ $[9] = t1;
135
+ $[10] = t2;
136
+ $[11] = t3;
137
+ $[12] = t4;
138
+ $[13] = t5;
139
+ $[14] = t6;
140
+ } else {
141
+ t1 = $[9];
142
+ t2 = $[10];
143
+ t3 = $[11];
144
+ t4 = $[12];
145
+ t5 = $[13];
146
+ t6 = $[14];
147
+ }
148
+ let t7;
149
+ if ($[25] !== t1 || $[26] !== t2) {
150
+ t7 = /*#__PURE__*/_jsx("div", {
151
+ className: t1,
152
+ children: t2
153
+ });
154
+ $[25] = t1;
155
+ $[26] = t2;
156
+ $[27] = t7;
157
+ } else {
158
+ t7 = $[27];
159
+ }
160
+ let t8;
161
+ if ($[28] !== t3 || $[29] !== t4 || $[30] !== t5 || $[31] !== t6 || $[32] !== t7) {
162
+ t8 = /*#__PURE__*/_jsxs("li", {
163
+ "data-slot": t3,
164
+ className: t4,
165
+ children: [t5, t6, t7]
166
+ });
167
+ $[28] = t3;
168
+ $[29] = t4;
169
+ $[30] = t5;
170
+ $[31] = t6;
171
+ $[32] = t7;
172
+ $[33] = t8;
173
+ } else {
174
+ t8 = $[33];
175
+ }
176
+ return t8;
177
+ }
178
+ function _temp(t0) {
179
+ const {
180
+ id,
181
+ label,
182
+ icon: Icon,
183
+ disabled,
184
+ onClick,
185
+ danger
186
+ } = t0;
187
+ return /*#__PURE__*/_jsx(Button, {
188
+ id: id,
189
+ type: "button",
190
+ variant: "ghost",
191
+ size: "icon-xs",
192
+ "aria-label": label,
193
+ title: label,
194
+ disabled: disabled,
195
+ onClick: onClick,
196
+ className: cn("text-muted-foreground hover:text-foreground", danger && "hover:text-destructive"),
197
+ children: /*#__PURE__*/_jsx(Icon, {
198
+ "aria-hidden": true
199
+ })
200
+ }, id);
50
201
  }
@@ -1,29 +1,30 @@
1
1
  export function applyStepAction(steps, stepId, action) {
2
- const index = steps.findIndex((step) => step.id === stepId);
3
- if (index === -1)
4
- return steps;
5
- if (action === "remove")
6
- return steps.filter((step) => step.id !== stepId);
7
- const target = action === "up" ? index - 1 : index + 1;
8
- if (target < 0 || target >= steps.length)
9
- return steps;
10
- const reordered = [...steps];
11
- const [moved] = reordered.splice(index, 1);
12
- if (moved)
13
- reordered.splice(target, 0, moved);
14
- return reordered;
2
+ const index = steps.findIndex(step => step.id === stepId);
3
+ if (index === -1) return steps;
4
+ if (action === "remove") return steps.filter(step => step.id !== stepId);
5
+ const target = action === "up" ? index - 1 : index + 1;
6
+ if (target < 0 || target >= steps.length) return steps;
7
+ const reordered = [...steps];
8
+ const [moved] = reordered.splice(index, 1);
9
+ if (moved) reordered.splice(target, 0, moved);
10
+ return reordered;
15
11
  }
16
12
  export function focusAfterAction(steps, stepId, action) {
17
- if (action !== "remove") {
18
- const index = steps.findIndex((step) => step.id === stepId);
19
- const atEdge = action === "up" ? index === 0 : index === steps.length - 1;
20
- return { stepId, control: atEdge ? "title" : action };
21
- }
22
- const neighbor = steps[0];
23
- return neighbor ? { stepId: neighbor.id, control: "title" } : null;
13
+ if (action !== "remove") {
14
+ const index = steps.findIndex(step => step.id === stepId);
15
+ const atEdge = action === "up" ? index === 0 : index === steps.length - 1;
16
+ return {
17
+ stepId,
18
+ control: atEdge ? "title" : action
19
+ };
20
+ }
21
+ const neighbor = steps[0];
22
+ return neighbor ? {
23
+ stepId: neighbor.id,
24
+ control: "title"
25
+ } : null;
24
26
  }
25
27
  export function describeStepAction(position, action) {
26
- if (action === "remove")
27
- return `Step ${position + 1} removed.`;
28
- return `Step moved ${action}.`;
28
+ if (action === "remove") return `Step ${position + 1} removed.`;
29
+ return `Step moved ${action}.`;
29
30
  }
@@ -1,47 +1,166 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { c as _c } from "react/compiler-runtime";
2
2
  import { cn } from "@locusgraph/components";
3
3
  import { useEffect, useRef } from "react";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
5
  const nextIndexByKey = {
5
- ArrowRight: (index, count) => (index + 1) % count,
6
- ArrowDown: (index, count) => (index + 1) % count,
7
- ArrowLeft: (index, count) => (index - 1 + count) % count,
8
- ArrowUp: (index, count) => (index - 1 + count) % count,
9
- Home: () => 0,
10
- End: (_index, count) => count - 1,
6
+ ArrowRight: (index, count) => (index + 1) % count,
7
+ ArrowDown: (index, count) => (index + 1) % count,
8
+ ArrowLeft: (index, count) => (index - 1 + count) % count,
9
+ ArrowUp: (index, count) => (index - 1 + count) % count,
10
+ Home: () => 0,
11
+ End: (_index, count) => count - 1
11
12
  };
12
13
  function indexFromDigitKey(key, count) {
13
- const digit = Number(key);
14
- return Number.isInteger(digit) && digit >= 1 && digit <= count ? digit - 1 : undefined;
14
+ const digit = Number(key);
15
+ return Number.isInteger(digit) && digit >= 1 && digit <= count ? digit - 1 : undefined;
15
16
  }
16
- export function QuestionChoices({ label, options, selectedId, onSelect, autoFocus = false, }) {
17
- const buttons = useRef([]);
18
- useEffect(() => {
19
- if (autoFocus)
20
- buttons.current[0]?.focus({ preventScroll: true });
21
- }, [autoFocus]);
22
- const selectedIndex = options.findIndex((option) => option.id === selectedId);
23
- const tabStop = selectedIndex === -1 ? 0 : selectedIndex;
24
- function selectIndex(next) {
25
- const option = options[next];
26
- if (!option)
27
- return;
28
- onSelect(option.id);
29
- buttons.current[next]?.focus();
30
- }
31
- function handleKeyDown(event, index) {
32
- const byDigit = indexFromDigitKey(event.key, options.length);
33
- const move = nextIndexByKey[event.key];
34
- if (byDigit === undefined && !move)
35
- return;
36
- event.preventDefault();
37
- selectIndex(byDigit ?? move?.(index, options.length) ?? index);
17
+ export function QuestionChoices(t0) {
18
+ const $ = _c(25);
19
+ const {
20
+ label,
21
+ options,
22
+ selectedId,
23
+ onSelect,
24
+ autoFocus: t1
25
+ } = t0;
26
+ const autoFocus = t1 === undefined ? false : t1;
27
+ let t2;
28
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
29
+ t2 = [];
30
+ $[0] = t2;
31
+ } else {
32
+ t2 = $[0];
33
+ }
34
+ const buttons = useRef(t2);
35
+ let t3;
36
+ let t4;
37
+ if ($[1] !== autoFocus) {
38
+ t3 = () => {
39
+ if (autoFocus) {
40
+ buttons.current[0]?.focus({
41
+ preventScroll: true
42
+ });
43
+ }
44
+ };
45
+ t4 = [autoFocus];
46
+ $[1] = autoFocus;
47
+ $[2] = t3;
48
+ $[3] = t4;
49
+ } else {
50
+ t3 = $[2];
51
+ t4 = $[3];
52
+ }
53
+ useEffect(t3, t4);
54
+ let t5;
55
+ if ($[4] !== options || $[5] !== selectedId) {
56
+ let t6;
57
+ if ($[7] !== selectedId) {
58
+ t6 = option => option.id === selectedId;
59
+ $[7] = selectedId;
60
+ $[8] = t6;
61
+ } else {
62
+ t6 = $[8];
38
63
  }
39
- return (_jsx("div", { role: "radiogroup", "aria-label": label, "data-slot": "question-choices", className: "-mx-5 flex flex-col divide-y border-y", children: options.map((option, index) => {
40
- const checked = option.id === selectedId;
41
- return (_jsxs("button", { ref: (element) => {
42
- buttons.current[index] = element;
43
- }, type: "button", role: "radio", "aria-checked": checked, tabIndex: index === tabStop ? 0 : -1, "data-state": checked ? "checked" : "unchecked", onClick: () => onSelect(option.id), onKeyDown: (event) => handleKeyDown(event, index), className: cn("group relative flex items-center gap-3 px-5 py-2.5 text-left text-sm outline-none motion-safe:transition-colors focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset", checked ? "bg-accent" : "hover:bg-accent/50"), children: [_jsx("span", { "aria-hidden": true, className: cn("flex size-5 shrink-0 items-center justify-center font-mono text-[11px] ring-1", checked
44
- ? "bg-primary text-primary-foreground ring-primary"
45
- : "text-muted-foreground ring-input"), children: index + 1 }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("span", { className: "font-medium", children: option.label }), option.description && (_jsx("span", { className: "text-xs text-muted-foreground", children: option.description }))] })] }, option.id));
46
- }) }));
64
+ t5 = options.findIndex(t6);
65
+ $[4] = options;
66
+ $[5] = selectedId;
67
+ $[6] = t5;
68
+ } else {
69
+ t5 = $[6];
70
+ }
71
+ const selectedIndex = t5;
72
+ const tabStop = selectedIndex === -1 ? 0 : selectedIndex;
73
+ let t10;
74
+ let t6;
75
+ let t7;
76
+ let t8;
77
+ let t9;
78
+ if ($[9] !== label || $[10] !== onSelect || $[11] !== options || $[12] !== selectedId || $[13] !== tabStop) {
79
+ const selectIndex = function selectIndex(next) {
80
+ const option_0 = options[next];
81
+ if (!option_0) {
82
+ return;
83
+ }
84
+ onSelect(option_0.id);
85
+ buttons.current[next]?.focus();
86
+ };
87
+ const handleKeyDown = function handleKeyDown(event, index) {
88
+ const byDigit = indexFromDigitKey(event.key, options.length);
89
+ const move = nextIndexByKey[event.key];
90
+ if (byDigit === undefined && !move) {
91
+ return;
92
+ }
93
+ event.preventDefault();
94
+ selectIndex(byDigit ?? move?.(index, options.length) ?? index);
95
+ };
96
+ t6 = "radiogroup";
97
+ t7 = label;
98
+ t8 = "question-choices";
99
+ t9 = "-mx-5 flex flex-col divide-y border-y";
100
+ t10 = options.map((option_1, index_0) => {
101
+ const checked = option_1.id === selectedId;
102
+ return /*#__PURE__*/_jsxs("button", {
103
+ ref: element => {
104
+ buttons.current[index_0] = element;
105
+ },
106
+ type: "button",
107
+ role: "radio",
108
+ "aria-checked": checked,
109
+ tabIndex: index_0 === tabStop ? 0 : -1,
110
+ "data-state": checked ? "checked" : "unchecked",
111
+ onClick: () => onSelect(option_1.id),
112
+ onKeyDown: event_0 => handleKeyDown(event_0, index_0),
113
+ className: cn("group relative flex items-center gap-3 px-5 py-2.5 text-left text-sm outline-none motion-safe:transition-colors focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-ring/70 focus-visible:ring-inset", checked ? "bg-accent" : "hover:bg-accent/50"),
114
+ children: [/*#__PURE__*/_jsx("span", {
115
+ "aria-hidden": true,
116
+ className: cn("flex size-5 shrink-0 items-center justify-center font-mono text-[11px] ring-1", checked ? "bg-primary text-primary-foreground ring-primary" : "text-muted-foreground ring-input"),
117
+ children: index_0 + 1
118
+ }), /*#__PURE__*/_jsxs("span", {
119
+ className: "flex min-w-0 flex-1 flex-col",
120
+ children: [/*#__PURE__*/_jsx("span", {
121
+ className: "font-medium",
122
+ children: option_1.label
123
+ }), option_1.description && /*#__PURE__*/_jsx("span", {
124
+ className: "text-xs text-muted-foreground",
125
+ children: option_1.description
126
+ })]
127
+ })]
128
+ }, option_1.id);
129
+ });
130
+ $[9] = label;
131
+ $[10] = onSelect;
132
+ $[11] = options;
133
+ $[12] = selectedId;
134
+ $[13] = tabStop;
135
+ $[14] = t10;
136
+ $[15] = t6;
137
+ $[16] = t7;
138
+ $[17] = t8;
139
+ $[18] = t9;
140
+ } else {
141
+ t10 = $[14];
142
+ t6 = $[15];
143
+ t7 = $[16];
144
+ t8 = $[17];
145
+ t9 = $[18];
146
+ }
147
+ let t11;
148
+ if ($[19] !== t10 || $[20] !== t6 || $[21] !== t7 || $[22] !== t8 || $[23] !== t9) {
149
+ t11 = /*#__PURE__*/_jsx("div", {
150
+ role: t6,
151
+ "aria-label": t7,
152
+ "data-slot": t8,
153
+ className: t9,
154
+ children: t10
155
+ });
156
+ $[19] = t10;
157
+ $[20] = t6;
158
+ $[21] = t7;
159
+ $[22] = t8;
160
+ $[23] = t9;
161
+ $[24] = t11;
162
+ } else {
163
+ t11 = $[24];
164
+ }
165
+ return t11;
47
166
  }
@@ -15,4 +15,4 @@ export type QuestionProps = {
15
15
  autoFocus?: boolean;
16
16
  className?: string;
17
17
  };
18
- export declare function Question({ question, options, allowText, textLabel, textPlaceholder, submitLabel, answer, onAnswer, autoFocus, className, }: QuestionProps): import("react").JSX.Element;
18
+ export declare function Question({ question, options, allowText: allowTextProp, textLabel: textLabelProp, textPlaceholder: textPlaceholderProp, submitLabel, answer, onAnswer, autoFocus, className, }: QuestionProps): import("react").JSX.Element;