@locusgraph/loop 0.2.0 → 0.3.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 (75) hide show
  1. package/dist/agent/pulse/gradient-label.js +12 -62
  2. package/dist/agent/pulse/marks/bars-mark.js +15 -37
  3. package/dist/agent/pulse/marks/glyph-mark.js +15 -54
  4. package/dist/agent/pulse/marks/locus-mark.js +12 -36
  5. package/dist/agent/pulse/marks/orb-mark.js +9 -19
  6. package/dist/agent/pulse/marks/spinner-mark.js +20 -29
  7. package/dist/agent/pulse/pulse.js +36 -123
  8. package/dist/agent/pulse/use-loop-animation.js +12 -33
  9. package/dist/agent/steps/step-icon.js +26 -96
  10. package/dist/agent/steps/steps.js +47 -210
  11. package/dist/agent/thinking/thinking.js +2 -2
  12. package/dist/agent/tool/json-block.js +11 -31
  13. package/dist/agent/tool/tool-status.js +12 -35
  14. package/dist/approval/inbox/inbox-row.js +76 -301
  15. package/dist/approval/inbox/inbox.js +39 -190
  16. package/dist/approval/inbox/virtual-inbox-list.js +26 -102
  17. package/dist/approval/memory/memory-review.js +36 -170
  18. package/dist/approval/memory/memory-row.js +50 -185
  19. package/dist/approval/plan/plan-review.js +73 -223
  20. package/dist/approval/plan/plan-step-row.js +76 -180
  21. package/dist/approval/plan/question-choices.js +44 -130
  22. package/dist/approval/plan/question.js +38 -154
  23. package/dist/approval/run/run-bar.js +39 -123
  24. package/dist/approval/shared/risk-badge.js +9 -24
  25. package/dist/approval/shared/use-focus-on-mount.js +5 -21
  26. package/dist/approval/spend/raise-cap-form.js +48 -221
  27. package/dist/approval/spend/spend-gate.js +40 -155
  28. package/dist/approval/spend/spend-meter.js +86 -313
  29. package/dist/approval/tool/approval.js +35 -194
  30. package/dist/approval/tool/args/args-editor.js +46 -204
  31. package/dist/approval/tool/args/args-field.js +55 -238
  32. package/dist/approval/tool/deny-form.js +36 -123
  33. package/dist/approval/tool/tool-inputs.js +24 -89
  34. package/dist/chat/chat/use-stick-to-bottom.js +60 -113
  35. package/dist/chat/chat/virtual-chat-items.js +34 -127
  36. package/dist/chat/composer/composer-actions.js +46 -129
  37. package/dist/chat/composer/use-auto-grow.js +8 -23
  38. package/dist/chat/files/files.js +66 -291
  39. package/dist/chat/reply/fenced-code.js +10 -32
  40. package/dist/chat/reply/markdown-components.js +2 -2
  41. package/dist/chat/reply/reply.js +24 -99
  42. package/dist/chat/turn/turn.js +46 -197
  43. package/dist/cost/context.js +65 -282
  44. package/dist/cost/cost-steps.js +42 -195
  45. package/dist/cost/cost.js +108 -497
  46. package/dist/cost/model-picker.js +42 -172
  47. package/dist/cost/shared/context-breakdown.js +65 -281
  48. package/dist/cost/shared/meter-marks.js +34 -92
  49. package/dist/cost/shared/model-option-row.js +35 -158
  50. package/dist/cost/shared/step-cost-row.js +37 -222
  51. package/dist/memory/cite.js +58 -179
  52. package/dist/memory/memorized.js +43 -195
  53. package/dist/memory/recall.js +68 -263
  54. package/dist/memory/shared/disclosure.d.ts +2 -2
  55. package/dist/memory/shared/disclosure.js +1 -1
  56. package/dist/memory/shared/source-mark.js +10 -38
  57. package/dist/memory/sources.js +52 -230
  58. package/dist/shared/decision-summary.js +35 -117
  59. package/dist/shared/panel-empty.js +15 -73
  60. package/dist/shared/panel.js +65 -239
  61. package/dist/shared/status-dot.js +10 -32
  62. package/dist/thread/actions/action-button.js +10 -53
  63. package/dist/thread/actions/branch-switcher.js +21 -95
  64. package/dist/thread/canvas/canvas.js +1 -1
  65. package/dist/thread/canvas/version-switcher.js +31 -126
  66. package/dist/thread/code/code.js +2 -2
  67. package/dist/thread/code/copy-code-button.js +24 -56
  68. package/dist/thread/history/history.js +1 -1
  69. package/dist/thread/history/row/history-row.js +18 -97
  70. package/dist/thread/history/row/thread-item-menu.js +19 -72
  71. package/dist/thread/history/row/thread-title-editor.js +29 -72
  72. package/dist/thread/history/virtual-history-list.js +46 -82
  73. package/dist/thread/starters/starters.js +27 -87
  74. package/dist/thread/use-copied.js +10 -38
  75. package/package.json +3 -3
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { useCallback, useEffect, useRef, useState } from "react";
3
2
  const bottomThresholdPx = 48;
4
3
  function distanceFromBottom(element) {
@@ -11,123 +10,71 @@ function scrolledUpByReader(viewport, previous) {
11
10
  return viewport.scrollTop < previous.top && viewport.scrollHeight === previous.height;
12
11
  }
13
12
  export function useStickToBottom() {
14
- const $ = _c(8);
15
13
  const viewportRef = useRef(null);
16
14
  const contentRef = useRef(null);
17
15
  const stuckRef = useRef(true);
18
- let t0;
19
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
- t0 = {
21
- top: 0,
22
- height: 0
23
- };
24
- $[0] = t0;
25
- } else {
26
- t0 = $[0];
27
- }
28
- const lastScrollRef = useRef(t0);
16
+ const lastScrollRef = useRef({
17
+ top: 0,
18
+ height: 0
19
+ });
29
20
  const [isAtBottom, setIsAtBottom] = useState(true);
30
- let t1;
31
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
32
- t1 = () => {
33
- const viewport = viewportRef.current;
34
- if (viewport) {
35
- viewport.scrollTop = viewport.scrollHeight;
36
- }
37
- };
38
- $[1] = t1;
39
- } else {
40
- t1 = $[1];
41
- }
42
- const pinToBottom = t1;
43
- let t2;
44
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
45
- t2 = () => {
46
- const viewport_0 = viewportRef.current;
47
- if (!viewport_0) {
48
- return;
49
- }
50
- const atBottom = distanceFromBottom(viewport_0) <= bottomThresholdPx;
51
- const readerScrolledUp = scrolledUpByReader(viewport_0, lastScrollRef.current);
52
- lastScrollRef.current = {
53
- top: viewport_0.scrollTop,
54
- height: viewport_0.scrollHeight
55
- };
56
- if (atBottom) {
57
- stuckRef.current = true;
58
- } else {
59
- if (readerScrolledUp) {
60
- stuckRef.current = false;
61
- } else {
62
- if (stuckRef.current) {
63
- pinToBottom();
64
- }
65
- }
66
- }
67
- setIsAtBottom(stuckRef.current);
21
+ const pinToBottom = useCallback(() => {
22
+ const viewport = viewportRef.current;
23
+ if (viewport) {
24
+ viewport.scrollTop = viewport.scrollHeight;
25
+ }
26
+ }, []);
27
+ const handleScroll = useCallback(() => {
28
+ const viewport = viewportRef.current;
29
+ if (!viewport) {
30
+ return;
31
+ }
32
+ const atBottom = distanceFromBottom(viewport) <= bottomThresholdPx;
33
+ const readerScrolledUp = scrolledUpByReader(viewport, lastScrollRef.current);
34
+ lastScrollRef.current = {
35
+ top: viewport.scrollTop,
36
+ height: viewport.scrollHeight
68
37
  };
69
- $[2] = t2;
70
- } else {
71
- t2 = $[2];
72
- }
73
- const handleScroll = t2;
74
- let t3;
75
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
76
- t3 = () => {
77
- const viewport_1 = viewportRef.current;
78
- if (!viewport_1) {
79
- return;
80
- }
38
+ if (atBottom) {
81
39
  stuckRef.current = true;
82
- setIsAtBottom(true);
83
- viewport_1.scrollTo({
84
- top: viewport_1.scrollHeight,
85
- behavior: prefersReducedMotion() ? "auto" : "smooth"
86
- });
87
- };
88
- $[3] = t3;
89
- } else {
90
- t3 = $[3];
91
- }
92
- const scrollToLatest = t3;
93
- let t4;
94
- let t5;
95
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
96
- t4 = () => {
97
- const content = contentRef.current;
98
- if (!content || typeof ResizeObserver === "undefined") {
99
- return;
100
- }
40
+ } else if (readerScrolledUp) {
41
+ stuckRef.current = false;
42
+ } else if (stuckRef.current) {
101
43
  pinToBottom();
102
- const observer = new ResizeObserver(() => {
103
- if (stuckRef.current) {
104
- pinToBottom();
105
- }
106
- });
107
- observer.observe(content);
108
- return () => observer.disconnect();
109
- };
110
- t5 = [pinToBottom];
111
- $[4] = t4;
112
- $[5] = t5;
113
- } else {
114
- t4 = $[4];
115
- t5 = $[5];
116
- }
117
- useEffect(t4, t5);
118
- let t6;
119
- if ($[6] !== isAtBottom) {
120
- t6 = {
121
- viewportRef,
122
- contentRef,
123
- isAtBottom,
124
- handleScroll,
125
- scrollToLatest
126
- };
127
- $[6] = isAtBottom;
128
- $[7] = t6;
129
- } else {
130
- t6 = $[7];
131
- }
132
- return t6;
44
+ }
45
+ setIsAtBottom(stuckRef.current);
46
+ }, [pinToBottom]);
47
+ const scrollToLatest = useCallback(() => {
48
+ const viewport = viewportRef.current;
49
+ if (!viewport) {
50
+ return;
51
+ }
52
+ stuckRef.current = true;
53
+ setIsAtBottom(true);
54
+ viewport.scrollTo({
55
+ top: viewport.scrollHeight,
56
+ behavior: prefersReducedMotion() ? "auto" : "smooth"
57
+ });
58
+ }, []);
59
+ useEffect(() => {
60
+ const content = contentRef.current;
61
+ if (!content || typeof ResizeObserver === "undefined") {
62
+ return;
63
+ }
64
+ pinToBottom();
65
+ const observer = new ResizeObserver(() => {
66
+ if (stuckRef.current) {
67
+ pinToBottom();
68
+ }
69
+ });
70
+ observer.observe(content);
71
+ return () => observer.disconnect();
72
+ }, [pinToBottom]);
73
+ return {
74
+ viewportRef,
75
+ contentRef,
76
+ isAtBottom,
77
+ handleScroll,
78
+ scrollToLatest
79
+ };
133
80
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { cn } from "@locusgraph/components";
3
2
  import { cloneElement, isValidElement, useEffect, useLayoutEffect } from "react";
4
3
  import { rowOffsetStyle, useListVirtualizer, virtualRowClassName } from "../../shared/virtual/use-list-virtualizer.js";
@@ -17,137 +16,45 @@ function withSetPosition(item, index, count) {
17
16
  "aria-setsize": count
18
17
  });
19
18
  }
20
- export function VirtualChatItems(t0) {
21
- const $ = _c(27);
22
- const {
23
- items,
24
- viewportRef,
25
- onScrollingChange
26
- } = t0;
27
- let t1;
28
- if ($[0] !== viewportRef) {
29
- t1 = () => viewportRef.current;
30
- $[0] = viewportRef;
31
- $[1] = t1;
32
- } else {
33
- t1 = $[1];
34
- }
35
- let t2;
36
- if ($[2] !== items) {
37
- t2 = index => itemKey(items[index], index);
38
- $[2] = items;
39
- $[3] = t2;
40
- } else {
41
- t2 = $[3];
42
- }
43
- let t3;
44
- if ($[4] !== items.length || $[5] !== t1 || $[6] !== t2) {
45
- t3 = {
46
- count: items.length,
47
- getScrollElement: t1,
48
- estimateSize: _temp,
49
- getItemKey: t2,
50
- anchorTo: "end"
51
- };
52
- $[4] = items.length;
53
- $[5] = t1;
54
- $[6] = t2;
55
- $[7] = t3;
56
- } else {
57
- t3 = $[7];
58
- }
19
+ export function VirtualChatItems({
20
+ items,
21
+ viewportRef,
22
+ onScrollingChange
23
+ }) {
59
24
  const {
60
25
  virtualizer,
61
26
  rows,
62
27
  totalSize,
63
28
  isScrolling,
64
29
  itemProps
65
- } = useListVirtualizer(t3);
66
- let t4;
67
- let t5;
68
- if ($[8] !== virtualizer) {
69
- t4 = () => {
70
- virtualizer.scrollToEnd();
71
- };
72
- t5 = [virtualizer];
73
- $[8] = virtualizer;
74
- $[9] = t4;
75
- $[10] = t5;
76
- } else {
77
- t4 = $[9];
78
- t5 = $[10];
79
- }
80
- useLayoutEffect(t4, t5);
81
- let t6;
82
- let t7;
83
- if ($[11] !== isScrolling || $[12] !== onScrollingChange) {
84
- t6 = () => {
85
- onScrollingChange(isScrolling);
86
- };
87
- t7 = [isScrolling, onScrollingChange];
88
- $[11] = isScrolling;
89
- $[12] = onScrollingChange;
90
- $[13] = t6;
91
- $[14] = t7;
92
- } else {
93
- t6 = $[13];
94
- t7 = $[14];
95
- }
96
- useEffect(t6, t7);
97
- let t8;
98
- if ($[15] !== totalSize) {
99
- t8 = {
30
+ } = useListVirtualizer({
31
+ count: items.length,
32
+ getScrollElement: () => viewportRef.current,
33
+ estimateSize: () => estimatedTurnHeightPx,
34
+ getItemKey: index => itemKey(items[index], index),
35
+ anchorTo: "end"
36
+ });
37
+ useLayoutEffect(() => {
38
+ virtualizer.scrollToEnd();
39
+ }, [virtualizer]);
40
+ useEffect(() => {
41
+ onScrollingChange(isScrolling);
42
+ }, [isScrolling, onScrollingChange]);
43
+ return /*#__PURE__*/_jsx("div", {
44
+ "data-slot": "chat-virtual-list",
45
+ className: "relative w-full",
46
+ style: {
100
47
  height: totalSize
101
- };
102
- $[15] = totalSize;
103
- $[16] = t8;
104
- } else {
105
- t8 = $[16];
106
- }
107
- let t9;
108
- if ($[17] !== itemProps || $[18] !== items || $[19] !== rows) {
109
- let t10;
110
- if ($[21] !== itemProps || $[22] !== items) {
111
- t10 = row => /*#__PURE__*/_jsx("div", {
112
- "data-slot": "chat-item",
113
- ...itemProps(row.index),
114
- className: cn(virtualRowClassName, "flex flex-col"),
115
- style: {
116
- ...rowOffsetStyle(row.start),
117
- paddingTop: gapBeforeItem(items, row.index)
118
- },
119
- children: withSetPosition(items[row.index], row.index, items.length)
120
- }, row.key);
121
- $[21] = itemProps;
122
- $[22] = items;
123
- $[23] = t10;
124
- } else {
125
- t10 = $[23];
126
- }
127
- t9 = rows.map(t10);
128
- $[17] = itemProps;
129
- $[18] = items;
130
- $[19] = rows;
131
- $[20] = t9;
132
- } else {
133
- t9 = $[20];
134
- }
135
- let t10;
136
- if ($[24] !== t8 || $[25] !== t9) {
137
- t10 = /*#__PURE__*/_jsx("div", {
138
- "data-slot": "chat-virtual-list",
139
- className: "relative w-full",
140
- style: t8,
141
- children: t9
142
- });
143
- $[24] = t8;
144
- $[25] = t9;
145
- $[26] = t10;
146
- } else {
147
- t10 = $[26];
148
- }
149
- return t10;
150
- }
151
- function _temp() {
152
- return estimatedTurnHeightPx;
48
+ },
49
+ children: rows.map(row => /*#__PURE__*/_jsx("div", {
50
+ "data-slot": "chat-item",
51
+ ...itemProps(row.index),
52
+ className: cn(virtualRowClassName, "flex flex-col"),
53
+ style: {
54
+ ...rowOffsetStyle(row.start),
55
+ paddingTop: gapBeforeItem(items, row.index)
56
+ },
57
+ children: withSetPosition(items[row.index], row.index, items.length)
58
+ }, row.key))
59
+ });
153
60
  }
@@ -1,4 +1,3 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { ArrowUp as ArrowUpIcon, Attachment as PaperclipIcon, StopFilledAlt as SquareIcon } from "@carbon/icons-react";
3
2
  import { Button } from "@locusgraph/components";
4
3
  import { useRef } from "react";
@@ -6,97 +5,45 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
6
5
  export function isComposerBusy(status) {
7
6
  return status === "submitting" || status === "streaming";
8
7
  }
9
- export function ComposerSubmit(t0) {
10
- const $ = _c(7);
11
- const {
12
- status,
13
- canSend,
14
- onStop
15
- } = t0;
8
+ export function ComposerSubmit({
9
+ status,
10
+ canSend,
11
+ onStop
12
+ }) {
16
13
  if (isComposerBusy(status)) {
17
- const t1 = !onStop;
18
- let t2;
19
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
20
- t2 = /*#__PURE__*/_jsx(SquareIcon, {
14
+ return /*#__PURE__*/_jsxs(Button, {
15
+ type: "button",
16
+ size: "sm",
17
+ variant: "outline",
18
+ "data-slot": "composer-stop",
19
+ "aria-label": "Stop",
20
+ disabled: !onStop,
21
+ onClick: onStop,
22
+ children: [/*#__PURE__*/_jsx(SquareIcon, {
21
23
  "aria-hidden": "true",
22
24
  className: "size-2.5 fill-current"
23
- });
24
- $[0] = t2;
25
- } else {
26
- t2 = $[0];
27
- }
28
- let t3;
29
- if ($[1] !== onStop || $[2] !== t1) {
30
- t3 = /*#__PURE__*/_jsxs(Button, {
31
- type: "button",
32
- size: "sm",
33
- variant: "outline",
34
- "data-slot": "composer-stop",
35
- "aria-label": "Stop",
36
- disabled: t1,
37
- onClick: onStop,
38
- children: [t2, "Stop"]
39
- });
40
- $[1] = onStop;
41
- $[2] = t1;
42
- $[3] = t3;
43
- } else {
44
- t3 = $[3];
45
- }
46
- return t3;
47
- }
48
- const t1 = !canSend;
49
- let t2;
50
- if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
51
- t2 = /*#__PURE__*/_jsx(ArrowUpIcon, {
52
- "aria-hidden": "true"
53
- });
54
- $[4] = t2;
55
- } else {
56
- t2 = $[4];
57
- }
58
- let t3;
59
- if ($[5] !== t1) {
60
- t3 = /*#__PURE__*/_jsx(Button, {
61
- type: "submit",
62
- size: "icon-sm",
63
- "data-slot": "composer-send",
64
- "aria-label": "Send",
65
- disabled: t1,
66
- children: t2
25
+ }), "Stop"]
67
26
  });
68
- $[5] = t1;
69
- $[6] = t3;
70
- } else {
71
- t3 = $[6];
72
27
  }
73
- return t3;
28
+ return /*#__PURE__*/_jsx(Button, {
29
+ type: "submit",
30
+ size: "icon-sm",
31
+ "data-slot": "composer-send",
32
+ "aria-label": "Send",
33
+ disabled: !canSend,
34
+ children: /*#__PURE__*/_jsx(ArrowUpIcon, {
35
+ "aria-hidden": "true"
36
+ })
37
+ });
74
38
  }
75
- export function ComposerAttachButton(t0) {
76
- const $ = _c(12);
77
- const {
78
- accept,
79
- disabled,
80
- onAttachFiles
81
- } = t0;
39
+ export function ComposerAttachButton({
40
+ accept,
41
+ disabled,
42
+ onAttachFiles
43
+ }) {
82
44
  const inputRef = useRef(null);
83
- let t1;
84
- if ($[0] !== onAttachFiles) {
85
- t1 = event => {
86
- const picked = Array.from(event.currentTarget.files ?? []);
87
- event.currentTarget.value = "";
88
- if (picked.length > 0) {
89
- onAttachFiles(picked);
90
- }
91
- };
92
- $[0] = onAttachFiles;
93
- $[1] = t1;
94
- } else {
95
- t1 = $[1];
96
- }
97
- let t2;
98
- if ($[2] !== accept || $[3] !== t1) {
99
- t2 = /*#__PURE__*/_jsx("input", {
45
+ return /*#__PURE__*/_jsxs(_Fragment, {
46
+ children: [/*#__PURE__*/_jsx("input", {
100
47
  ref: inputRef,
101
48
  type: "file",
102
49
  multiple: true,
@@ -104,30 +51,14 @@ export function ComposerAttachButton(t0) {
104
51
  accept: accept,
105
52
  tabIndex: -1,
106
53
  "aria-hidden": "true",
107
- onChange: t1
108
- });
109
- $[2] = accept;
110
- $[3] = t1;
111
- $[4] = t2;
112
- } else {
113
- t2 = $[4];
114
- }
115
- let t3;
116
- let t4;
117
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
118
- t3 = () => inputRef.current?.click();
119
- t4 = /*#__PURE__*/_jsx(PaperclipIcon, {
120
- "aria-hidden": "true"
121
- });
122
- $[5] = t3;
123
- $[6] = t4;
124
- } else {
125
- t3 = $[5];
126
- t4 = $[6];
127
- }
128
- let t5;
129
- if ($[7] !== disabled) {
130
- t5 = /*#__PURE__*/_jsx(Button, {
54
+ onChange: event => {
55
+ const picked = Array.from(event.currentTarget.files ?? []);
56
+ event.currentTarget.value = "";
57
+ if (picked.length > 0) {
58
+ onAttachFiles(picked);
59
+ }
60
+ }
61
+ }), /*#__PURE__*/_jsx(Button, {
131
62
  type: "button",
132
63
  size: "icon-sm",
133
64
  variant: "ghost",
@@ -135,24 +66,10 @@ export function ComposerAttachButton(t0) {
135
66
  "aria-label": "Attach files",
136
67
  className: "text-muted-foreground hover:text-foreground",
137
68
  disabled: disabled,
138
- onClick: t3,
139
- children: t4
140
- });
141
- $[7] = disabled;
142
- $[8] = t5;
143
- } else {
144
- t5 = $[8];
145
- }
146
- let t6;
147
- if ($[9] !== t2 || $[10] !== t5) {
148
- t6 = /*#__PURE__*/_jsxs(_Fragment, {
149
- children: [t2, t5]
150
- });
151
- $[9] = t2;
152
- $[10] = t5;
153
- $[11] = t6;
154
- } else {
155
- t6 = $[11];
156
- }
157
- return t6;
69
+ onClick: () => inputRef.current?.click(),
70
+ children: /*#__PURE__*/_jsx(PaperclipIcon, {
71
+ "aria-hidden": "true"
72
+ })
73
+ })]
74
+ });
158
75
  }
@@ -1,29 +1,14 @@
1
- import { c as _c } from "react/compiler-runtime";
2
1
  import { useLayoutEffect } from "react";
3
2
  function supportsFieldSizing() {
4
3
  return typeof CSS !== "undefined" && CSS.supports?.("field-sizing", "content") === true;
5
4
  }
6
5
  export function useAutoGrow(textareaRef, text) {
7
- const $ = _c(4);
8
- let t0;
9
- let t1;
10
- if ($[0] !== text || $[1] !== textareaRef) {
11
- t0 = () => {
12
- const textarea = textareaRef.current;
13
- if (!textarea || supportsFieldSizing() || text === undefined) {
14
- return;
15
- }
16
- textarea.style.height = "auto";
17
- textarea.style.height = `${textarea.scrollHeight}px`;
18
- };
19
- t1 = [textareaRef, text];
20
- $[0] = text;
21
- $[1] = textareaRef;
22
- $[2] = t0;
23
- $[3] = t1;
24
- } else {
25
- t0 = $[2];
26
- t1 = $[3];
27
- }
28
- useLayoutEffect(t0, t1);
6
+ useLayoutEffect(() => {
7
+ const textarea = textareaRef.current;
8
+ if (!textarea || supportsFieldSizing() || text === undefined) {
9
+ return;
10
+ }
11
+ textarea.style.height = "auto";
12
+ textarea.style.height = `${textarea.scrollHeight}px`;
13
+ }, [textareaRef, text]);
29
14
  }