@reforma/components 0.5.0 → 0.6.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/SortableList/SortableList.d.ts +9 -3
- package/dist/SortableList/SortableList.d.ts.map +1 -1
- package/dist/SortableList/SortableList.js +178 -163
- package/dist/SortableList/SortableList.js.map +1 -1
- package/dist/chat/ComposerBanner/ComposerBanner.d.ts +1 -1
- package/dist/chat/ComposerBanner/ComposerBanner.d.ts.map +1 -1
- package/dist/chat/ComposerBanner/ComposerBanner.js.map +1 -1
- package/dist/chat/ComposerBanner/ComposerBanner.module.css +1 -1
- package/dist/chat/ComposerBanner/ComposerBanner.module.css.js +5 -5
- package/dist/chat/Tool/bash/BashTool.d.ts.map +1 -1
- package/dist/chat/Tool/bash/BashTool.js +42 -48
- package/dist/chat/Tool/bash/BashTool.js.map +1 -1
- package/dist/chat/Tool/bash/BashTool.module.css +1 -1
- package/dist/chat/Tool/bash/BashTool.module.css.js +6 -8
- package/dist/chat/Tool/bash/BashTool.module.css.js.map +1 -1
- package/package.json +2 -2
|
@@ -35,13 +35,19 @@ interface SortableListBaseProps<T> {
|
|
|
35
35
|
items: readonly T[];
|
|
36
36
|
getKey?: (item: T, path: readonly number[]) => string;
|
|
37
37
|
getTextValue: (item: T) => string;
|
|
38
|
-
|
|
38
|
+
/** `move` is the dragged item and its index among its new siblings. */
|
|
39
|
+
onChange: (items: T[], move: {
|
|
40
|
+
item: T;
|
|
41
|
+
index: number;
|
|
42
|
+
}) => void;
|
|
39
43
|
children: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;
|
|
40
44
|
canDrop?: (context: SortableListDropContext<T>) => boolean;
|
|
41
45
|
getDragHandleOptions?: (item: T, context: SortableListItemContext<T>) => SortableListDragHandleOptions;
|
|
42
46
|
className?: string;
|
|
43
47
|
gap?: 'sm' | 'md';
|
|
44
48
|
nestedGap?: 'sm' | 'md';
|
|
49
|
+
/** `false` drops the grip: the whole item starts a drag. Default `true`. */
|
|
50
|
+
handle?: boolean;
|
|
45
51
|
'aria-label': string;
|
|
46
52
|
}
|
|
47
53
|
interface FlatSortableListProps {
|
|
@@ -56,12 +62,12 @@ interface NestedSortableListProps<T> {
|
|
|
56
62
|
}
|
|
57
63
|
export type SortableListProps<T> = SortableListBaseProps<T> & (FlatSortableListProps | NestedSortableListProps<T>);
|
|
58
64
|
/**
|
|
59
|
-
* Sortable collection with a
|
|
65
|
+
* Sortable collection with a pointer handle (or whole-item drag) and optional child groups.
|
|
60
66
|
*
|
|
61
67
|
* The rendered item is the complete draggable surface. Child collections can
|
|
62
68
|
* accept moves when the caller's drop rules allow it.
|
|
63
69
|
*/
|
|
64
|
-
export declare function SortableList<T>({ items, getKey: getItemKey, getTextValue, getChildren, setChildren, canHaveChildren, onChange, children, canDrop, getDragHandleOptions, className, gap, nestedGap, 'aria-label': ariaLabel, }: SortableListProps<T>): import("react").JSX.Element;
|
|
70
|
+
export declare function SortableList<T>({ items, getKey: getItemKey, getTextValue, getChildren, setChildren, canHaveChildren, onChange, children, canDrop, getDragHandleOptions, className, gap, nestedGap, handle, 'aria-label': ariaLabel, }: SortableListProps<T>): import("react").JSX.Element;
|
|
65
71
|
export declare namespace SortableList {
|
|
66
72
|
var displayName: string;
|
|
67
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableList.d.ts","sourceRoot":"","sources":["../../src/SortableList/SortableList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SortableList.d.ts","sourceRoot":"","sources":["../../src/SortableList/SortableList.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,MAAM,MAAM,+BAA+B,GAAG,QAAQ,GAAG,KAAK,CAAC;AAC/D,MAAM,MAAM,gCAAgC,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;AACpE,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,SA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AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAC5B,KAAK,EACL,MAAM,EAAE,UAAU,EAClB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,SAAS,EACT,GAAU,EACV,SAAe,EACf,MAAa,EACb,YAAY,EAAE,SAAS,GAC1B,EAAE,iBAAiB,CAAC,CAAC,CAAC,+BAgKtB;yBAhLe,YAAY"}
|
|
@@ -1,192 +1,203 @@
|
|
|
1
|
-
import { DragDropProvider as
|
|
2
|
-
import { isSortable as _, useSortable as
|
|
3
|
-
import { DotsDrag as
|
|
4
|
-
import { cn as
|
|
5
|
-
import {
|
|
6
|
-
import { For as
|
|
1
|
+
import { DragDropProvider as ee, PointerSensor as ne, DragOverlay as te, useDroppable as re } from "@dnd-kit/react";
|
|
2
|
+
import { isSortable as _, useSortable as ie } from "@dnd-kit/react/sortable";
|
|
3
|
+
import { DotsDrag as oe } from "@reforma/icons/14";
|
|
4
|
+
import { cn as ae } from "@reforma/lib";
|
|
5
|
+
import { useCallback as le, useMemo as se, useState as de } from "react";
|
|
6
|
+
import { For as j } from "../For/For.js";
|
|
7
|
+
import { Show as ce } from "../Show/Show.js";
|
|
7
8
|
import f from "./SortableList.module.css.js";
|
|
8
|
-
import { buildSortableTree as
|
|
9
|
-
import { jsxs as
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
import { buildSortableTree as ue, moveSortableTreeNodeToIndex as fe, restoreSortableTree as me, findSortableTreeNode as $ } from "./sortableTree.js";
|
|
10
|
+
import { jsxs as A, jsx as o } from "react/jsx-runtime";
|
|
11
|
+
const H = "reforma-sortable:root", D = "reforma-sortable:children:", ve = "reforma-sortable:item", pe = "reforma-sortable:collection", ge = [ne], he = "sortable:primitive:", w = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
let F = 0;
|
|
13
|
+
function be({
|
|
12
14
|
items: e,
|
|
13
15
|
getKey: n,
|
|
14
16
|
getTextValue: t,
|
|
15
17
|
getChildren: r,
|
|
16
18
|
setChildren: i,
|
|
17
19
|
canHaveChildren: a,
|
|
18
|
-
onChange:
|
|
19
|
-
children:
|
|
20
|
-
canDrop:
|
|
20
|
+
onChange: c,
|
|
21
|
+
children: m,
|
|
22
|
+
canDrop: v,
|
|
21
23
|
getDragHandleOptions: x,
|
|
22
24
|
className: P,
|
|
23
|
-
gap:
|
|
24
|
-
nestedGap:
|
|
25
|
-
|
|
25
|
+
gap: b = "md",
|
|
26
|
+
nestedGap: S = b,
|
|
27
|
+
handle: u = !0,
|
|
28
|
+
"aria-label": I
|
|
26
29
|
}) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (typeof c != "object" || c == null)
|
|
35
|
-
return `${me}${v.join(".")}`;
|
|
36
|
-
const d = g.current.objectKeys.get(c);
|
|
30
|
+
const y = le((s, g) => {
|
|
31
|
+
const E = n?.(s, g);
|
|
32
|
+
if (E != null)
|
|
33
|
+
return E;
|
|
34
|
+
if (typeof s != "object" || s == null)
|
|
35
|
+
return `${he}${g.join(".")}`;
|
|
36
|
+
const d = w.get(s);
|
|
37
37
|
if (d)
|
|
38
38
|
return d;
|
|
39
|
-
const
|
|
40
|
-
return
|
|
41
|
-
}, [n]), p =
|
|
42
|
-
getKey:
|
|
39
|
+
const h = `sortable:item:${F}`;
|
|
40
|
+
return F += 1, w.set(s, h), h;
|
|
41
|
+
}, [n]), p = se(() => ue(e, {
|
|
42
|
+
getKey: y,
|
|
43
43
|
getTextValue: t,
|
|
44
44
|
getChildren: r,
|
|
45
45
|
canHaveChildren: a
|
|
46
|
-
}), [a, r,
|
|
46
|
+
}), [a, r, y, t, e]), [N, Q] = de({
|
|
47
47
|
items: e,
|
|
48
48
|
revision: 0
|
|
49
49
|
});
|
|
50
|
-
|
|
50
|
+
N.items !== e && Q({
|
|
51
51
|
items: e,
|
|
52
|
-
revision:
|
|
52
|
+
revision: N.revision + 1
|
|
53
53
|
});
|
|
54
|
-
function
|
|
54
|
+
function U(s) {
|
|
55
55
|
const {
|
|
56
|
-
canceled:
|
|
57
|
-
operation:
|
|
58
|
-
} =
|
|
56
|
+
canceled: g,
|
|
57
|
+
operation: E
|
|
58
|
+
} = s, {
|
|
59
59
|
source: d,
|
|
60
|
-
target:
|
|
61
|
-
} =
|
|
62
|
-
if (
|
|
60
|
+
target: h
|
|
61
|
+
} = E;
|
|
62
|
+
if (g || !d || !_(d))
|
|
63
63
|
return;
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
64
|
+
const T = O(d)?.node;
|
|
65
|
+
if (!T)
|
|
66
66
|
return;
|
|
67
|
-
const
|
|
67
|
+
const C = J(h), L = C?.kind === "node" ? C.node : null;
|
|
68
68
|
let l;
|
|
69
|
-
if (
|
|
70
|
-
parentNode:
|
|
71
|
-
index:
|
|
69
|
+
if (C?.kind === "collection" ? l = {
|
|
70
|
+
parentNode: C.parentNode,
|
|
71
|
+
index: C.parentNode?.children.length ?? p.length,
|
|
72
72
|
dropPosition: "end"
|
|
73
|
-
} : L &&
|
|
73
|
+
} : L && h && _(h) ? l = xe(p, h.group, d.index, L) : l = null, !l)
|
|
74
74
|
return;
|
|
75
|
-
const
|
|
76
|
-
if (!
|
|
75
|
+
const Z = X(T, l.parentNode, L, l.dropPosition);
|
|
76
|
+
if (!z(T, l.parentNode) || v && !v(Z))
|
|
77
77
|
return;
|
|
78
|
-
const K =
|
|
78
|
+
const K = q(d.initialGroup), R = l.parentNode?.id ?? null;
|
|
79
79
|
if (K !== void 0 && K === R && d.initialIndex === l.index)
|
|
80
80
|
return;
|
|
81
|
-
const
|
|
82
|
-
|
|
81
|
+
const G = fe(p, T.id, R, l.index);
|
|
82
|
+
c(me(G, i), {
|
|
83
|
+
item: T.value,
|
|
84
|
+
index: l.index
|
|
85
|
+
});
|
|
83
86
|
}
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
87
|
+
return /* @__PURE__ */ A(
|
|
88
|
+
ee,
|
|
89
|
+
{
|
|
90
|
+
sensors: ge,
|
|
91
|
+
onDragEnd: U,
|
|
92
|
+
children: [/* @__PURE__ */ o(M, {
|
|
93
|
+
nodes: p,
|
|
94
|
+
rootNodes: p,
|
|
95
|
+
parentNode: null,
|
|
96
|
+
renderItem: m,
|
|
97
|
+
canDrop: v,
|
|
98
|
+
getDragHandleOptions: x,
|
|
99
|
+
className: P,
|
|
100
|
+
gap: b,
|
|
101
|
+
nestedGap: S,
|
|
102
|
+
handle: u,
|
|
103
|
+
ariaLabel: I
|
|
104
|
+
}), /* @__PURE__ */ o(te, {
|
|
105
|
+
className: f.dragOverlay,
|
|
106
|
+
dropAnimation: {
|
|
107
|
+
duration: 160,
|
|
108
|
+
easing: "cubic-bezier(0.25, 1, 0.5, 1)"
|
|
109
|
+
},
|
|
110
|
+
children: (s) => {
|
|
111
|
+
const g = O(s)?.node;
|
|
112
|
+
return g ? /* @__PURE__ */ o(Y, {
|
|
113
|
+
node: g,
|
|
114
|
+
renderItem: m,
|
|
115
|
+
nestedGap: S
|
|
116
|
+
}) : null;
|
|
117
|
+
}
|
|
118
|
+
})]
|
|
119
|
+
},
|
|
120
|
+
r ? N.revision : void 0
|
|
121
|
+
);
|
|
114
122
|
}
|
|
115
|
-
function
|
|
123
|
+
function M({
|
|
116
124
|
nodes: e,
|
|
117
125
|
rootNodes: n,
|
|
118
126
|
parentNode: t,
|
|
119
127
|
renderItem: r,
|
|
120
128
|
canDrop: i,
|
|
121
129
|
getDragHandleOptions: a,
|
|
122
|
-
className:
|
|
123
|
-
gap:
|
|
124
|
-
nestedGap:
|
|
125
|
-
|
|
130
|
+
className: c,
|
|
131
|
+
gap: m,
|
|
132
|
+
nestedGap: v,
|
|
133
|
+
handle: x,
|
|
134
|
+
ariaLabel: P
|
|
126
135
|
}) {
|
|
127
136
|
const {
|
|
128
|
-
ref:
|
|
129
|
-
isDropTarget:
|
|
130
|
-
} =
|
|
131
|
-
id:
|
|
132
|
-
type:
|
|
137
|
+
ref: b,
|
|
138
|
+
isDropTarget: S
|
|
139
|
+
} = re({
|
|
140
|
+
id: Pe(t),
|
|
141
|
+
type: pe,
|
|
133
142
|
data: {
|
|
134
143
|
kind: "collection",
|
|
135
144
|
parentNode: t
|
|
136
145
|
},
|
|
137
146
|
disabled: e.length > 0,
|
|
138
147
|
collisionPriority: 1,
|
|
139
|
-
accept: (
|
|
148
|
+
accept: (u) => W(u, t, null, "end", i)
|
|
140
149
|
});
|
|
141
150
|
return /* @__PURE__ */ o("div", {
|
|
142
|
-
ref:
|
|
151
|
+
ref: b,
|
|
143
152
|
role: "list",
|
|
144
|
-
className:
|
|
145
|
-
"data-gap":
|
|
146
|
-
"data-drop-target":
|
|
147
|
-
"aria-label":
|
|
148
|
-
children: /* @__PURE__ */ o(
|
|
153
|
+
className: ae(f.list, c),
|
|
154
|
+
"data-gap": m,
|
|
155
|
+
"data-drop-target": S || void 0,
|
|
156
|
+
"aria-label": P,
|
|
157
|
+
children: /* @__PURE__ */ o(j, {
|
|
149
158
|
each: e,
|
|
150
|
-
children: (
|
|
151
|
-
node:
|
|
159
|
+
children: (u) => /* @__PURE__ */ o(Se, {
|
|
160
|
+
node: u,
|
|
152
161
|
rootNodes: n,
|
|
153
162
|
renderItem: r,
|
|
154
163
|
canDrop: i,
|
|
155
164
|
getDragHandleOptions: a,
|
|
156
|
-
nestedGap:
|
|
157
|
-
|
|
165
|
+
nestedGap: v,
|
|
166
|
+
handle: x
|
|
167
|
+
}, u.id)
|
|
158
168
|
})
|
|
159
169
|
});
|
|
160
170
|
}
|
|
161
|
-
function
|
|
171
|
+
function Se({
|
|
162
172
|
node: e,
|
|
163
173
|
rootNodes: n,
|
|
164
174
|
renderItem: t,
|
|
165
175
|
canDrop: r,
|
|
166
176
|
getDragHandleOptions: i,
|
|
167
|
-
nestedGap: a
|
|
177
|
+
nestedGap: a,
|
|
178
|
+
handle: c
|
|
168
179
|
}) {
|
|
169
|
-
const
|
|
170
|
-
alignment:
|
|
171
|
-
edgeOffset:
|
|
172
|
-
variant:
|
|
173
|
-
} = i?.(e.value,
|
|
174
|
-
handleRef:
|
|
175
|
-
ref:
|
|
176
|
-
targetRef:
|
|
177
|
-
isDragging:
|
|
178
|
-
isDropTarget:
|
|
179
|
-
} =
|
|
180
|
+
const m = B(e), {
|
|
181
|
+
alignment: v = "center",
|
|
182
|
+
edgeOffset: x = "none",
|
|
183
|
+
variant: P = "plain"
|
|
184
|
+
} = i?.(e.value, m) ?? {}, {
|
|
185
|
+
handleRef: b,
|
|
186
|
+
ref: S,
|
|
187
|
+
targetRef: u,
|
|
188
|
+
isDragging: I,
|
|
189
|
+
isDropTarget: y
|
|
190
|
+
} = ie({
|
|
180
191
|
id: e.id,
|
|
181
192
|
index: e.index,
|
|
182
|
-
group:
|
|
183
|
-
type:
|
|
193
|
+
group: V(ye(n, e)),
|
|
194
|
+
type: ve,
|
|
184
195
|
data: {
|
|
185
196
|
kind: "node",
|
|
186
197
|
node: e
|
|
187
198
|
},
|
|
188
|
-
accept: (
|
|
189
|
-
}),
|
|
199
|
+
accept: (N) => W(N, e.parent == null ? null : k(n, e), e, "before", r)
|
|
200
|
+
}), p = e.canHaveChildren ? /* @__PURE__ */ o(M, {
|
|
190
201
|
nodes: e.children,
|
|
191
202
|
rootNodes: n,
|
|
192
203
|
parentNode: e,
|
|
@@ -195,44 +206,48 @@ function pe({
|
|
|
195
206
|
getDragHandleOptions: i,
|
|
196
207
|
gap: a,
|
|
197
208
|
nestedGap: a,
|
|
209
|
+
handle: c,
|
|
198
210
|
ariaLabel: `${e.textValue} items`
|
|
199
211
|
}) : null;
|
|
200
|
-
return /* @__PURE__ */
|
|
201
|
-
ref:
|
|
212
|
+
return /* @__PURE__ */ A("div", {
|
|
213
|
+
ref: S,
|
|
202
214
|
role: "listitem",
|
|
203
215
|
className: f.item,
|
|
204
216
|
"data-level": e.level,
|
|
205
|
-
"data-dragging":
|
|
206
|
-
"data-drop-target":
|
|
217
|
+
"data-dragging": I || void 0,
|
|
218
|
+
"data-drop-target": y || void 0,
|
|
207
219
|
children: [/* @__PURE__ */ o("div", {
|
|
208
|
-
ref:
|
|
220
|
+
ref: u,
|
|
209
221
|
className: f.dropTarget,
|
|
210
222
|
"data-container": e.canHaveChildren || void 0,
|
|
211
223
|
"aria-hidden": !0
|
|
212
|
-
}), /* @__PURE__ */ o(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
224
|
+
}), /* @__PURE__ */ o(ce, {
|
|
225
|
+
when: c,
|
|
226
|
+
children: /* @__PURE__ */ o("span", {
|
|
227
|
+
ref: b,
|
|
228
|
+
className: f.dragHandle,
|
|
229
|
+
"data-alignment": v,
|
|
230
|
+
"data-edge-offset": x,
|
|
231
|
+
"data-variant": P,
|
|
220
232
|
"aria-hidden": !0,
|
|
221
|
-
|
|
222
|
-
|
|
233
|
+
children: /* @__PURE__ */ o(oe, {
|
|
234
|
+
"aria-hidden": !0,
|
|
235
|
+
width: 14,
|
|
236
|
+
height: 14
|
|
237
|
+
})
|
|
223
238
|
})
|
|
224
239
|
}), /* @__PURE__ */ o("div", {
|
|
225
240
|
className: f.content,
|
|
226
241
|
children: t(e.value, {
|
|
227
|
-
...
|
|
228
|
-
nestedItems:
|
|
229
|
-
isDragging:
|
|
230
|
-
isDropTarget:
|
|
242
|
+
...m,
|
|
243
|
+
nestedItems: p,
|
|
244
|
+
isDragging: I,
|
|
245
|
+
isDropTarget: y
|
|
231
246
|
})
|
|
232
247
|
})]
|
|
233
248
|
});
|
|
234
249
|
}
|
|
235
|
-
function
|
|
250
|
+
function Y({
|
|
236
251
|
node: e,
|
|
237
252
|
renderItem: n,
|
|
238
253
|
nestedGap: t
|
|
@@ -240,9 +255,9 @@ function M({
|
|
|
240
255
|
const r = e.canHaveChildren ? /* @__PURE__ */ o("div", {
|
|
241
256
|
className: f.previewList,
|
|
242
257
|
"data-gap": t,
|
|
243
|
-
children: /* @__PURE__ */ o(
|
|
258
|
+
children: /* @__PURE__ */ o(j, {
|
|
244
259
|
each: e.children,
|
|
245
|
-
children: (i) => /* @__PURE__ */ o(
|
|
260
|
+
children: (i) => /* @__PURE__ */ o(Y, {
|
|
246
261
|
node: i,
|
|
247
262
|
renderItem: n,
|
|
248
263
|
nestedGap: t
|
|
@@ -252,14 +267,14 @@ function M({
|
|
|
252
267
|
return /* @__PURE__ */ o("div", {
|
|
253
268
|
className: f.dragPreviewItem,
|
|
254
269
|
children: n(e.value, {
|
|
255
|
-
...
|
|
270
|
+
...B(e),
|
|
256
271
|
nestedItems: r,
|
|
257
272
|
isDragging: !1,
|
|
258
273
|
isDropTarget: !1
|
|
259
274
|
})
|
|
260
275
|
});
|
|
261
276
|
}
|
|
262
|
-
function
|
|
277
|
+
function B(e) {
|
|
263
278
|
return {
|
|
264
279
|
level: e.level,
|
|
265
280
|
parent: e.parent,
|
|
@@ -271,11 +286,11 @@ function Y(e) {
|
|
|
271
286
|
canHaveChildren: e.canHaveChildren
|
|
272
287
|
};
|
|
273
288
|
}
|
|
274
|
-
function
|
|
289
|
+
function W(e, n, t, r, i) {
|
|
275
290
|
const a = O(e)?.node;
|
|
276
|
-
return !a || !
|
|
291
|
+
return !a || !z(a, n) ? !1 : i?.(X(a, n, t, r)) ?? !0;
|
|
277
292
|
}
|
|
278
|
-
function
|
|
293
|
+
function X(e, n, t, r) {
|
|
279
294
|
return {
|
|
280
295
|
items: [e.value],
|
|
281
296
|
target: t?.value ?? null,
|
|
@@ -286,36 +301,36 @@ function W(e, n, t, r) {
|
|
|
286
301
|
dropPosition: r
|
|
287
302
|
};
|
|
288
303
|
}
|
|
289
|
-
function
|
|
304
|
+
function z(e, n) {
|
|
290
305
|
return n == null || n.id !== e.id && $(e.children, n.id) == null;
|
|
291
306
|
}
|
|
292
|
-
function
|
|
293
|
-
const i =
|
|
307
|
+
function xe(e, n, t, r) {
|
|
308
|
+
const i = q(n);
|
|
294
309
|
if (i === void 0)
|
|
295
310
|
return null;
|
|
296
311
|
const a = i == null ? null : $(e, i);
|
|
297
312
|
if (i != null && !a)
|
|
298
313
|
return null;
|
|
299
|
-
const
|
|
314
|
+
const c = r != null && t > r.index;
|
|
300
315
|
return {
|
|
301
316
|
parentNode: a,
|
|
302
317
|
index: t,
|
|
303
|
-
dropPosition:
|
|
318
|
+
dropPosition: c ? "after" : "before"
|
|
304
319
|
};
|
|
305
320
|
}
|
|
306
|
-
function
|
|
307
|
-
return
|
|
308
|
-
}
|
|
309
|
-
function z(e) {
|
|
310
|
-
return e == null ? A : `${D}${e}`;
|
|
321
|
+
function Pe(e) {
|
|
322
|
+
return V(e?.id ?? null);
|
|
311
323
|
}
|
|
312
324
|
function V(e) {
|
|
313
|
-
|
|
325
|
+
return e == null ? H : `${D}${e}`;
|
|
326
|
+
}
|
|
327
|
+
function q(e) {
|
|
328
|
+
if (e === H)
|
|
314
329
|
return null;
|
|
315
330
|
if (typeof e == "string" && e.startsWith(D))
|
|
316
331
|
return e.slice(D.length);
|
|
317
332
|
}
|
|
318
|
-
function
|
|
333
|
+
function ye(e, n) {
|
|
319
334
|
return k(e, n)?.id ?? null;
|
|
320
335
|
}
|
|
321
336
|
function k(e, n) {
|
|
@@ -328,7 +343,7 @@ function k(e, n) {
|
|
|
328
343
|
}
|
|
329
344
|
return null;
|
|
330
345
|
}
|
|
331
|
-
function
|
|
346
|
+
function J(e) {
|
|
332
347
|
const n = e?.data;
|
|
333
348
|
return n?.kind === "node" && "node" in n ? {
|
|
334
349
|
kind: "node",
|
|
@@ -339,11 +354,11 @@ function q(e) {
|
|
|
339
354
|
} : null;
|
|
340
355
|
}
|
|
341
356
|
function O(e) {
|
|
342
|
-
const n =
|
|
357
|
+
const n = J(e);
|
|
343
358
|
return n?.kind === "node" ? n : null;
|
|
344
359
|
}
|
|
345
|
-
|
|
360
|
+
be.displayName = "SortableList";
|
|
346
361
|
export {
|
|
347
|
-
|
|
362
|
+
be as SortableList
|
|
348
363
|
};
|
|
349
364
|
//# sourceMappingURL=SortableList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SortableList.js","sources":["../../src/SortableList/SortableList.tsx"],"sourcesContent":["import {\n DragDropProvider,\n DragOverlay,\n PointerSensor,\n useDroppable,\n type DragEndEvent,\n} from '@dnd-kit/react';\nimport { isSortable, useSortable } from '@dnd-kit/react/sortable';\nimport { DotsDrag } from '@reforma/icons/14';\nimport { cn } from '@reforma/lib';\nimport { useCallback, useMemo, useRef } from 'react';\n\nimport { For } from '../For';\nimport styles from './SortableList.module.css';\nimport {\n buildSortableTree,\n findSortableTreeNode,\n moveSortableTreeNodeToIndex,\n restoreSortableTree,\n type SortableTreeNode,\n} from './sortableTree';\n\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortableListDragHandleAlignment = 'center' | 'top';\nexport type SortableListDragHandleEdgeOffset = 'none' | 'sm' | 'md';\nexport type SortableListDragHandleVariant = 'plain' | 'surface';\n\nexport interface SortableListDragHandleOptions {\n alignment?: SortableListDragHandleAlignment;\n edgeOffset?: SortableListDragHandleEdgeOffset;\n variant?: SortableListDragHandleVariant;\n}\n\nexport interface SortableListItemContext<T> {\n level: number;\n parent: T | null;\n index: number;\n siblingCount: number;\n isFirst: boolean;\n isLast: boolean;\n hasChildren: boolean;\n canHaveChildren: boolean;\n}\n\nexport interface SortableListItemRenderProps<T> extends SortableListItemContext<T> {\n nestedItems: ReactNode;\n isDragging: boolean;\n isDropTarget: boolean;\n}\n\nexport interface SortableListDropContext<T> {\n items: readonly T[];\n target: T | null;\n sourceParent: T | null;\n sourceLevel: number;\n parent: T | null;\n targetLevel: number;\n dropPosition: 'on' | 'before' | 'after' | 'end';\n}\n\ninterface SortableListBaseProps<T> {\n items: readonly T[];\n getKey?: (item: T, path: readonly number[]) => string;\n getTextValue: (item: T) => string;\n onChange: (items: T[]) => void;\n children: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n canDrop?: (context: SortableListDropContext<T>) => boolean;\n getDragHandleOptions?: (\n item: T,\n context: SortableListItemContext<T>\n ) => SortableListDragHandleOptions;\n className?: string;\n gap?: 'sm' | 'md';\n nestedGap?: 'sm' | 'md';\n 'aria-label': string;\n}\n\ninterface FlatSortableListProps {\n getChildren?: never;\n setChildren?: never;\n canHaveChildren?: never;\n}\n\ninterface NestedSortableListProps<T> {\n getChildren: (item: T) => readonly T[];\n setChildren: (item: T, children: T[]) => T;\n canHaveChildren?: (item: T) => boolean;\n}\n\nexport type SortableListProps<T> = SortableListBaseProps<T>\n & (FlatSortableListProps | NestedSortableListProps<T>);\n\ninterface SortableNodeData<T> {\n kind: 'node';\n node: SortableTreeNode<T>;\n}\n\ninterface SortableCollectionData<T> {\n kind: 'collection';\n parentNode: SortableTreeNode<T> | null;\n}\n\ninterface SortableCollectionProps<T> {\n nodes: readonly SortableTreeNode<T>[];\n rootNodes: readonly SortableTreeNode<T>[];\n parentNode: SortableTreeNode<T> | null;\n renderItem: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n canDrop?: (context: SortableListDropContext<T>) => boolean;\n getDragHandleOptions?: (\n item: T,\n context: SortableListItemContext<T>\n ) => SortableListDragHandleOptions;\n className?: string;\n gap: 'sm' | 'md';\n nestedGap: 'sm' | 'md';\n ariaLabel: string;\n}\n\ninterface SortableItemProps<T> extends Omit<SortableCollectionProps<T>, 'nodes' | 'className' | 'gap' | 'ariaLabel' | 'parentNode'> {\n node: SortableTreeNode<T>;\n}\n\ninterface SortableDestination<T> {\n parentNode: SortableTreeNode<T> | null;\n index: number;\n dropPosition: 'before' | 'after' | 'end';\n}\n\nconst ROOT_COLLECTION_ID = 'reforma-sortable:root';\nconst CHILD_COLLECTION_PREFIX = 'reforma-sortable:children:';\nconst SORTABLE_ITEM_TYPE = 'reforma-sortable:item';\nconst SORTABLE_COLLECTION_TYPE = 'reforma-sortable:collection';\nconst POINTER_SENSORS = [PointerSensor];\nconst PRIMITIVE_KEY_PREFIX = 'sortable:primitive:';\n\n/**\n * Sortable collection with a dedicated pointer handle and optional child groups.\n *\n * The rendered item is the complete draggable surface. Child collections can\n * accept moves when the caller's drop rules allow it.\n */\nexport function SortableList<T>({\n items,\n getKey: getItemKey,\n getTextValue,\n getChildren,\n setChildren,\n canHaveChildren,\n onChange,\n children,\n canDrop,\n getDragHandleOptions,\n className,\n gap = 'md',\n nestedGap = gap,\n 'aria-label': ariaLabel,\n}: SortableListProps<T>) {\n const keyState = useRef({\n nextId: 0,\n objectKeys: new WeakMap<object, string>(),\n });\n const getNodeKey = useCallback((item: T, path: readonly number[]) => {\n const itemKey = getItemKey?.(item, path);\n\n if (itemKey != null) {\n return itemKey;\n }\n\n if (typeof item !== 'object' || item == null) {\n return `${ PRIMITIVE_KEY_PREFIX }${ path.join('.') }`;\n }\n\n const existingKey = keyState.current.objectKeys.get(item);\n\n if (existingKey) {\n return existingKey;\n }\n\n const key = `sortable:item:${ keyState.current.nextId }`;\n\n keyState.current.nextId += 1;\n keyState.current.objectKeys.set(item, key);\n\n return key;\n }, [getItemKey]);\n const nodes = useMemo(() => buildSortableTree(items, {\n getKey: getNodeKey,\n getTextValue,\n getChildren,\n canHaveChildren,\n }), [canHaveChildren, getChildren, getNodeKey, getTextValue, items]);\n const renderState = useRef({ items, revision: 0 });\n\n if (renderState.current.items !== items) {\n renderState.current = {\n items,\n revision: renderState.current.revision + 1,\n };\n }\n\n function handleDragEnd(event: DragEndEvent) {\n const { canceled, operation } = event;\n const { source, target } = operation;\n\n if (canceled || !source || !isSortable(source)) {\n return;\n }\n\n const sourceNode = nodeData<T>(source)?.node;\n\n if (!sourceNode) {\n return;\n }\n\n const targetData = entityData<T>(target);\n const targetNode = targetData?.kind === 'node' ? targetData.node : null;\n let destination: SortableDestination<T> | null;\n\n if (targetData?.kind === 'collection') {\n destination = {\n parentNode: targetData.parentNode,\n index: targetData.parentNode?.children.length ?? nodes.length,\n dropPosition: 'end' as const,\n };\n }\n else if (targetNode\n && target\n && isSortable(target)) {\n destination = destinationFromSortable(\n nodes,\n target.group,\n source.index,\n targetNode\n );\n }\n else {\n destination = null;\n }\n\n if (!destination) {\n return;\n }\n\n const context = createDropContext(\n sourceNode,\n destination.parentNode,\n targetNode,\n destination.dropPosition\n );\n\n if (!canMoveToParent(sourceNode, destination.parentNode)\n || (canDrop && !canDrop(context))) {\n return;\n }\n\n const initialParentKey = parentKeyFromCollectionId(source.initialGroup);\n const destinationParentKey = destination.parentNode?.id ?? null;\n const isSamePosition = initialParentKey !== undefined\n && initialParentKey === destinationParentKey\n && source.initialIndex === destination.index;\n\n if (isSamePosition) {\n return;\n }\n\n const movedNodes = moveSortableTreeNodeToIndex(\n nodes,\n sourceNode.id,\n destinationParentKey,\n destination.index\n );\n\n onChange(restoreSortableTree(movedNodes, setChildren));\n }\n\n return (\n <DragDropProvider\n key={ renderState.current.revision }\n sensors={ POINTER_SENSORS }\n onDragEnd={ handleDragEnd }\n >\n <SortableCollection\n nodes={ nodes }\n rootNodes={ nodes }\n parentNode={ null }\n renderItem={ children }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n className={ className }\n gap={ gap }\n nestedGap={ nestedGap }\n ariaLabel={ ariaLabel }\n />\n\n <DragOverlay\n className={ styles.dragOverlay }\n dropAnimation={ {\n duration: 160,\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\n } }\n >\n { (source) => {\n const node = nodeData<T>(source)?.node;\n\n return node\n ? (\n <SortablePreview\n node={ node }\n renderItem={ children }\n nestedGap={ nestedGap }\n />\n )\n : null;\n } }\n </DragOverlay>\n </DragDropProvider>\n );\n}\n\nfunction SortableCollection<T>({\n nodes,\n rootNodes,\n parentNode,\n renderItem,\n canDrop,\n getDragHandleOptions,\n className,\n gap,\n nestedGap,\n ariaLabel,\n}: SortableCollectionProps<T>) {\n const { ref, isDropTarget } = useDroppable<SortableCollectionData<T>>({\n id: collectionId(parentNode),\n type: SORTABLE_COLLECTION_TYPE,\n data: { kind: 'collection', parentNode },\n disabled: nodes.length > 0,\n collisionPriority: 1,\n accept: source => canAcceptDrop(\n source,\n parentNode,\n null,\n 'end',\n canDrop\n ),\n });\n\n return (\n <div\n ref={ ref }\n role=\"list\"\n className={ cn(styles.list, className) }\n data-gap={ gap }\n data-drop-target={ isDropTarget || undefined }\n aria-label={ ariaLabel }\n >\n <For each={ nodes }>\n { node => (\n <SortableItem\n key={ node.id }\n node={ node }\n rootNodes={ rootNodes }\n renderItem={ renderItem }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n nestedGap={ nestedGap }\n />\n ) }\n </For>\n </div>\n );\n}\n\nfunction SortableItem<T>({\n node,\n rootNodes,\n renderItem,\n canDrop,\n getDragHandleOptions,\n nestedGap,\n}: SortableItemProps<T>) {\n const context = itemContext(node);\n const {\n alignment = 'center',\n edgeOffset = 'none',\n variant = 'plain',\n } = getDragHandleOptions?.(node.value, context) ?? {};\n const {\n handleRef,\n ref,\n targetRef,\n isDragging,\n isDropTarget,\n } = useSortable<SortableNodeData<T>>({\n id: node.id,\n index: node.index,\n group: collectionIdFromParentKey(nodeParentKey(rootNodes, node)),\n type: SORTABLE_ITEM_TYPE,\n data: { kind: 'node', node },\n accept: source => canAcceptDrop(\n source,\n node.parent == null\n ? null\n : findParentNode(rootNodes, node),\n node,\n 'before',\n canDrop\n ),\n });\n const nestedItems = node.canHaveChildren\n ? (\n <SortableCollection\n nodes={ node.children }\n rootNodes={ rootNodes }\n parentNode={ node }\n renderItem={ renderItem }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n gap={ nestedGap }\n nestedGap={ nestedGap }\n ariaLabel={ `${ node.textValue } items` }\n />\n )\n : null;\n\n return (\n <div\n ref={ ref }\n role=\"listitem\"\n className={ styles.item }\n data-level={ node.level }\n data-dragging={ isDragging || undefined }\n data-drop-target={ isDropTarget || undefined }\n >\n <div\n ref={ targetRef }\n className={ styles.dropTarget }\n data-container={ node.canHaveChildren || undefined }\n aria-hidden\n />\n\n <span\n ref={ handleRef }\n className={ styles.dragHandle }\n data-alignment={ alignment }\n data-edge-offset={ edgeOffset }\n data-variant={ variant }\n aria-hidden\n >\n <DotsDrag aria-hidden width={ 14 } height={ 14 } />\n </span>\n\n <div className={ styles.content }>\n { renderItem(node.value, {\n ...context,\n nestedItems,\n isDragging,\n isDropTarget,\n }) }\n </div>\n </div>\n );\n}\n\nfunction SortablePreview<T>({\n node,\n renderItem,\n nestedGap,\n}: {\n node: SortableTreeNode<T>;\n renderItem: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n nestedGap: 'sm' | 'md';\n}): ReactElement {\n const nestedItems = node.canHaveChildren\n ? (\n <div className={ styles.previewList } data-gap={ nestedGap }>\n <For each={ node.children }>\n { child => (\n <SortablePreview\n key={ child.id }\n node={ child }\n renderItem={ renderItem }\n nestedGap={ nestedGap }\n />\n ) }\n </For>\n </div>\n )\n : null;\n\n return (\n <div className={ styles.dragPreviewItem }>\n { renderItem(node.value, {\n ...itemContext(node),\n nestedItems,\n isDragging: false,\n isDropTarget: false,\n }) }\n </div>\n );\n}\n\nfunction itemContext<T>(node: SortableTreeNode<T>): SortableListItemContext<T> {\n return {\n level: node.level,\n parent: node.parent,\n index: node.index,\n siblingCount: node.siblingCount,\n isFirst: node.index === 0,\n isLast: node.index === node.siblingCount - 1,\n hasChildren: node.children.length > 0,\n canHaveChildren: node.canHaveChildren,\n };\n}\n\nfunction canAcceptDrop<T>(\n source: { data: Record<string, unknown> },\n parentNode: SortableTreeNode<T> | null,\n targetNode: SortableTreeNode<T> | null,\n dropPosition: SortableListDropContext<T>['dropPosition'],\n canDrop?: (context: SortableListDropContext<T>) => boolean\n): boolean {\n const sourceNode = nodeData<T>(source)?.node;\n\n if (!sourceNode || !canMoveToParent(sourceNode, parentNode)) {\n return false;\n }\n\n return canDrop?.(\n createDropContext(sourceNode, parentNode, targetNode, dropPosition)\n ) ?? true;\n}\n\nfunction createDropContext<T>(\n sourceNode: SortableTreeNode<T>,\n parentNode: SortableTreeNode<T> | null,\n targetNode: SortableTreeNode<T> | null,\n dropPosition: SortableListDropContext<T>['dropPosition']\n): SortableListDropContext<T> {\n return {\n items: [sourceNode.value],\n target: targetNode?.value ?? null,\n sourceParent: sourceNode.parent,\n sourceLevel: sourceNode.level,\n parent: parentNode?.value ?? null,\n targetLevel: parentNode ? parentNode.level + 1 : 1,\n dropPosition,\n };\n}\n\nfunction canMoveToParent<T>(\n sourceNode: SortableTreeNode<T>,\n parentNode: SortableTreeNode<T> | null\n): boolean {\n return parentNode == null\n || (parentNode.id !== sourceNode.id\n && findSortableTreeNode(sourceNode.children, parentNode.id) == null);\n}\n\nfunction destinationFromSortable<T>(\n nodes: readonly SortableTreeNode<T>[],\n group: string | number | undefined,\n index: number,\n targetNode: SortableTreeNode<T> | null\n): SortableDestination<T> | null {\n const parentKey = parentKeyFromCollectionId(group);\n\n if (parentKey === undefined) {\n return null;\n }\n\n const parentNode = parentKey == null\n ? null\n : findSortableTreeNode(nodes, parentKey);\n\n if (parentKey != null && !parentNode) {\n return null;\n }\n\n const isAfterTarget = targetNode != null && index > targetNode.index;\n\n return {\n parentNode,\n index,\n dropPosition: isAfterTarget ? 'after' : 'before',\n };\n}\n\nfunction collectionId<T>(parentNode: SortableTreeNode<T> | null): string {\n return collectionIdFromParentKey(parentNode?.id ?? null);\n}\n\nfunction collectionIdFromParentKey(parentKey: string | null): string {\n return parentKey == null\n ? ROOT_COLLECTION_ID\n : `${ CHILD_COLLECTION_PREFIX }${ parentKey }`;\n}\n\nfunction parentKeyFromCollectionId(\n collectionId: string | number | undefined\n): string | null | undefined {\n if (collectionId === ROOT_COLLECTION_ID) {\n return null;\n }\n\n if (typeof collectionId === 'string'\n && collectionId.startsWith(CHILD_COLLECTION_PREFIX)) {\n return collectionId.slice(CHILD_COLLECTION_PREFIX.length);\n }\n\n return undefined;\n}\n\nfunction nodeParentKey<T>(\n nodes: readonly SortableTreeNode<T>[],\n target: SortableTreeNode<T>\n): string | null {\n return findParentNode(nodes, target)?.id ?? null;\n}\n\nfunction findParentNode<T>(\n nodes: readonly SortableTreeNode<T>[],\n target: SortableTreeNode<T>\n): SortableTreeNode<T> | null {\n for (const node of nodes) {\n if (node.children.some(child => child.id === target.id)) {\n return node;\n }\n\n const parent = findParentNode(node.children, target);\n\n if (parent) {\n return parent;\n }\n }\n\n return null;\n}\n\nfunction entityData<T>(\n entity: { data: Record<string, unknown> } | null\n): SortableNodeData<T> | SortableCollectionData<T> | null {\n const data = entity?.data;\n\n if (data?.kind === 'node' && 'node' in data) {\n return {\n kind: 'node',\n node: data.node as SortableTreeNode<T>,\n };\n }\n\n if (data?.kind === 'collection' && 'parentNode' in data) {\n return {\n kind: 'collection',\n parentNode: data.parentNode as SortableTreeNode<T> | null,\n };\n }\n\n return null;\n}\n\nfunction nodeData<T>(\n entity: { data: Record<string, unknown> } | null\n): SortableNodeData<T> | null {\n const data = entityData<T>(entity);\n\n return data?.kind === 'node' ? data : null;\n}\n\nSortableList.displayName = 'SortableList';\n"],"names":["ROOT_COLLECTION_ID","CHILD_COLLECTION_PREFIX","SORTABLE_ITEM_TYPE","SORTABLE_COLLECTION_TYPE","POINTER_SENSORS","PointerSensor","PRIMITIVE_KEY_PREFIX","SortableList","items","getItemKey","getTextValue","getChildren","setChildren","canHaveChildren","onChange","children","canDrop","getDragHandleOptions","className","gap","nestedGap","ariaLabel","keyState","useRef","getNodeKey","useCallback","item","path","itemKey","existingKey","key","nodes","useMemo","buildSortableTree","renderState","handleDragEnd","event","canceled","operation","source","target","isSortable","sourceNode","nodeData","targetData","entityData","targetNode","destination","destinationFromSortable","context","createDropContext","canMoveToParent","initialParentKey","parentKeyFromCollectionId","destinationParentKey","movedNodes","moveSortableTreeNodeToIndex","restoreSortableTree","DragDropProvider","_jsx","SortableCollection","DragOverlay","styles","node","SortablePreview","rootNodes","parentNode","renderItem","ref","isDropTarget","useDroppable","collectionId","canAcceptDrop","cn","For","SortableItem","itemContext","alignment","edgeOffset","variant","handleRef","targetRef","isDragging","useSortable","collectionIdFromParentKey","nodeParentKey","findParentNode","nestedItems","DotsDrag","child","dropPosition","findSortableTreeNode","group","index","parentKey","isAfterTarget","parent","entity","data"],"mappings":";;;;;;;;;AASA,MAAMA,IAAqB,yBACrBC,IAA0B,8BAC1BC,KAAqB,yBACrBC,KAA2B,+BAC3BC,KAAkB,CAACC,CAAa,GAChCC,KAAuB;AAQtB,SAASC,GAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,QAAQC;AAAA,EACR,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,WAAAC,IAAYD;AAAA,EACZ,cAAcE;AAChB,GAAG;AACD,QAAMC,IAAWC,EAAO;AAAA,IACtB,QAAQ;AAAA,IACR,gCAAgB,QAAA;AAAA,EAAQ,CACzB,GACKC,IAAaC,GAAY,CAACC,GAAMC,MAAS;AAC7C,UAAMC,IAAUnB,IAAaiB,GAAMC,CAAI;AACvC,QAAIC,KAAW;AACb,aAAOA;AAET,QAAI,OAAOF,KAAS,YAAYA,KAAQ;AACtC,aAAO,GAAGpB,EAAoB,GAAGqB,EAAK,KAAK,GAAG,CAAC;AAEjD,UAAME,IAAcP,EAAS,QAAQ,WAAW,IAAII,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D;AACA,SAASkB,EAA0BU,GAAW;AAC5C,SAAOA,KAAa,OAAO9F,IAAqB,GAAGC,CAAuB,GAAG6F,CAAS;AACxF;AACA,SAASzC,EAA0BkB,GAAc;AAC/C,MAAIA,MAAiBvE;AACnB,WAAO;AAET,MAAI,OAAOuE,KAAiB,YAAYA,EAAa,WAAWtE,CAAuB;AACrF,WAAOsE,EAAa,MAAMtE,EAAwB,MAAM;AAG5D;AACA,SAASoF,GAActD,GAAOS,GAAQ;AACpC,SAAO8C,EAAevD,GAAOS,CAAM,GAAG,MAAM;AAC9C;AACA,SAAS8C,EAAevD,GAAOS,GAAQ;AACrC,aAAWuB,KAAQhC,GAAO;AACxB,QAAIgC,EAAK,SAAS,KAAK,CAAA0B,MAASA,EAAM,OAAOjD,EAAO,EAAE;AACpD,aAAOuB;AAET,UAAMiC,IAASV,EAAevB,EAAK,UAAUvB,CAAM;AACnD,QAAIwD;AACF,aAAOA;AAAA,EAEX;AACA,SAAO;AACT;AACA,SAASnD,EAAWoD,GAAQ;AAC1B,QAAMC,IAAOD,GAAQ;AACrB,SAAIC,GAAM,SAAS,UAAU,UAAUA,IAC9B;AAAA,IACL,MAAM;AAAA,IACN,MAAMA,EAAK;AAAA,EAAA,IAGXA,GAAM,SAAS,gBAAgB,gBAAgBA,IAC1C;AAAA,IACL,MAAM;AAAA,IACN,YAAYA,EAAK;AAAA,EAAA,IAGd;AACT;AACA,SAASvD,EAASsD,GAAQ;AACxB,QAAMC,IAAOrD,EAAWoD,CAAM;AAC9B,SAAOC,GAAM,SAAS,SAASA,IAAO;AACxC;AACA3F,GAAa,cAAc;"}
|
|
1
|
+
{"version":3,"file":"SortableList.js","sources":["../../src/SortableList/SortableList.tsx"],"sourcesContent":["import {\n DragDropProvider,\n DragOverlay,\n PointerSensor,\n useDroppable,\n type DragEndEvent,\n} from '@dnd-kit/react';\nimport { isSortable, useSortable } from '@dnd-kit/react/sortable';\nimport { DotsDrag } from '@reforma/icons/14';\nimport { cn } from '@reforma/lib';\nimport { useCallback, useMemo, useState } from 'react';\n\nimport { For } from '../For';\nimport { Show } from '../Show';\nimport styles from './SortableList.module.css';\nimport {\n buildSortableTree,\n findSortableTreeNode,\n moveSortableTreeNodeToIndex,\n restoreSortableTree,\n type SortableTreeNode,\n} from './sortableTree';\n\nimport type { ReactElement, ReactNode } from 'react';\n\nexport type SortableListDragHandleAlignment = 'center' | 'top';\nexport type SortableListDragHandleEdgeOffset = 'none' | 'sm' | 'md';\nexport type SortableListDragHandleVariant = 'plain' | 'surface';\n\nexport interface SortableListDragHandleOptions {\n alignment?: SortableListDragHandleAlignment;\n edgeOffset?: SortableListDragHandleEdgeOffset;\n variant?: SortableListDragHandleVariant;\n}\n\nexport interface SortableListItemContext<T> {\n level: number;\n parent: T | null;\n index: number;\n siblingCount: number;\n isFirst: boolean;\n isLast: boolean;\n hasChildren: boolean;\n canHaveChildren: boolean;\n}\n\nexport interface SortableListItemRenderProps<T> extends SortableListItemContext<T> {\n nestedItems: ReactNode;\n isDragging: boolean;\n isDropTarget: boolean;\n}\n\nexport interface SortableListDropContext<T> {\n items: readonly T[];\n target: T | null;\n sourceParent: T | null;\n sourceLevel: number;\n parent: T | null;\n targetLevel: number;\n dropPosition: 'on' | 'before' | 'after' | 'end';\n}\n\ninterface SortableListBaseProps<T> {\n items: readonly T[];\n getKey?: (item: T, path: readonly number[]) => string;\n getTextValue: (item: T) => string;\n /** `move` is the dragged item and its index among its new siblings. */\n onChange: (items: T[], move: { item: T; index: number }) => void;\n children: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n canDrop?: (context: SortableListDropContext<T>) => boolean;\n getDragHandleOptions?: (\n item: T,\n context: SortableListItemContext<T>\n ) => SortableListDragHandleOptions;\n className?: string;\n gap?: 'sm' | 'md';\n nestedGap?: 'sm' | 'md';\n /** `false` drops the grip: the whole item starts a drag. Default `true`. */\n handle?: boolean;\n 'aria-label': string;\n}\n\ninterface FlatSortableListProps {\n getChildren?: never;\n setChildren?: never;\n canHaveChildren?: never;\n}\n\ninterface NestedSortableListProps<T> {\n getChildren: (item: T) => readonly T[];\n setChildren: (item: T, children: T[]) => T;\n canHaveChildren?: (item: T) => boolean;\n}\n\nexport type SortableListProps<T> = SortableListBaseProps<T>\n & (FlatSortableListProps | NestedSortableListProps<T>);\n\ninterface SortableNodeData<T> {\n kind: 'node';\n node: SortableTreeNode<T>;\n}\n\ninterface SortableCollectionData<T> {\n kind: 'collection';\n parentNode: SortableTreeNode<T> | null;\n}\n\ninterface SortableCollectionProps<T> {\n nodes: readonly SortableTreeNode<T>[];\n rootNodes: readonly SortableTreeNode<T>[];\n parentNode: SortableTreeNode<T> | null;\n renderItem: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n canDrop?: (context: SortableListDropContext<T>) => boolean;\n getDragHandleOptions?: (\n item: T,\n context: SortableListItemContext<T>\n ) => SortableListDragHandleOptions;\n className?: string;\n gap: 'sm' | 'md';\n nestedGap: 'sm' | 'md';\n handle: boolean;\n ariaLabel: string;\n}\n\ninterface SortableItemProps<T> extends Omit<SortableCollectionProps<T>, 'nodes' | 'className' | 'gap' | 'ariaLabel' | 'parentNode'> {\n node: SortableTreeNode<T>;\n}\n\ninterface SortableDestination<T> {\n parentNode: SortableTreeNode<T> | null;\n index: number;\n dropPosition: 'before' | 'after' | 'end';\n}\n\nconst ROOT_COLLECTION_ID = 'reforma-sortable:root';\nconst CHILD_COLLECTION_PREFIX = 'reforma-sortable:children:';\nconst SORTABLE_ITEM_TYPE = 'reforma-sortable:item';\nconst SORTABLE_COLLECTION_TYPE = 'reforma-sortable:collection';\nconst POINTER_SENSORS = [PointerSensor];\nconst PRIMITIVE_KEY_PREFIX = 'sortable:primitive:';\n\n/** Keys for items without `getKey`: stable per object, unique across lists. */\nconst objectKeys = new WeakMap<object, string>();\nlet nextObjectKey = 0;\n\n/**\n * Sortable collection with a pointer handle (or whole-item drag) and optional child groups.\n *\n * The rendered item is the complete draggable surface. Child collections can\n * accept moves when the caller's drop rules allow it.\n */\nexport function SortableList<T>({\n items,\n getKey: getItemKey,\n getTextValue,\n getChildren,\n setChildren,\n canHaveChildren,\n onChange,\n children,\n canDrop,\n getDragHandleOptions,\n className,\n gap = 'md',\n nestedGap = gap,\n handle = true,\n 'aria-label': ariaLabel,\n}: SortableListProps<T>) {\n const getNodeKey = useCallback((item: T, path: readonly number[]) => {\n const itemKey = getItemKey?.(item, path);\n\n if (itemKey != null) {\n return itemKey;\n }\n\n if (typeof item !== 'object' || item == null) {\n return `${ PRIMITIVE_KEY_PREFIX }${ path.join('.') }`;\n }\n\n const existingKey = objectKeys.get(item);\n\n if (existingKey) {\n return existingKey;\n }\n\n const key = `sortable:item:${ nextObjectKey }`;\n\n nextObjectKey += 1;\n objectKeys.set(item, key);\n\n return key;\n }, [getItemKey]);\n const nodes = useMemo(() => buildSortableTree(items, {\n getKey: getNodeKey,\n getTextValue,\n getChildren,\n canHaveChildren,\n }), [canHaveChildren, getChildren, getNodeKey, getTextValue, items]);\n const [renderState, setRenderState] = useState({ items, revision: 0 });\n\n if (renderState.items !== items) {\n setRenderState({ items, revision: renderState.revision + 1 });\n }\n\n function handleDragEnd(event: DragEndEvent) {\n const { canceled, operation } = event;\n const { source, target } = operation;\n\n if (canceled || !source || !isSortable(source)) {\n return;\n }\n\n const sourceNode = nodeData<T>(source)?.node;\n\n if (!sourceNode) {\n return;\n }\n\n const targetData = entityData<T>(target);\n const targetNode = targetData?.kind === 'node' ? targetData.node : null;\n let destination: SortableDestination<T> | null;\n\n if (targetData?.kind === 'collection') {\n destination = {\n parentNode: targetData.parentNode,\n index: targetData.parentNode?.children.length ?? nodes.length,\n dropPosition: 'end' as const,\n };\n }\n else if (targetNode\n && target\n && isSortable(target)) {\n destination = destinationFromSortable(\n nodes,\n target.group,\n source.index,\n targetNode\n );\n }\n else {\n destination = null;\n }\n\n if (!destination) {\n return;\n }\n\n const context = createDropContext(\n sourceNode,\n destination.parentNode,\n targetNode,\n destination.dropPosition\n );\n\n if (!canMoveToParent(sourceNode, destination.parentNode)\n || (canDrop && !canDrop(context))) {\n return;\n }\n\n const initialParentKey = parentKeyFromCollectionId(source.initialGroup);\n const destinationParentKey = destination.parentNode?.id ?? null;\n const isSamePosition = initialParentKey !== undefined\n && initialParentKey === destinationParentKey\n && source.initialIndex === destination.index;\n\n if (isSamePosition) {\n return;\n }\n\n const movedNodes = moveSortableTreeNodeToIndex(\n nodes,\n sourceNode.id,\n destinationParentKey,\n destination.index\n );\n\n onChange(restoreSortableTree(movedNodes, setChildren), {\n item: sourceNode.value,\n index: destination.index,\n });\n }\n\n return (\n <DragDropProvider\n // A cross-parent drop moves DOM nodes React does not own: remount nested trees on change.\n // Flat lists reconcile the optimistic order in place; a remount would cut the drop animation.\n key={ getChildren ? renderState.revision : undefined }\n sensors={ POINTER_SENSORS }\n onDragEnd={ handleDragEnd }\n >\n <SortableCollection\n nodes={ nodes }\n rootNodes={ nodes }\n parentNode={ null }\n renderItem={ children }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n className={ className }\n gap={ gap }\n nestedGap={ nestedGap }\n handle={ handle }\n ariaLabel={ ariaLabel }\n />\n\n <DragOverlay\n className={ styles.dragOverlay }\n dropAnimation={ {\n duration: 160,\n easing: 'cubic-bezier(0.25, 1, 0.5, 1)',\n } }\n >\n { (source) => {\n const node = nodeData<T>(source)?.node;\n\n return node\n ? (\n <SortablePreview\n node={ node }\n renderItem={ children }\n nestedGap={ nestedGap }\n />\n )\n : null;\n } }\n </DragOverlay>\n </DragDropProvider>\n );\n}\n\nfunction SortableCollection<T>({\n nodes,\n rootNodes,\n parentNode,\n renderItem,\n canDrop,\n getDragHandleOptions,\n className,\n gap,\n nestedGap,\n handle,\n ariaLabel,\n}: SortableCollectionProps<T>) {\n const { ref, isDropTarget } = useDroppable<SortableCollectionData<T>>({\n id: collectionId(parentNode),\n type: SORTABLE_COLLECTION_TYPE,\n data: { kind: 'collection', parentNode },\n disabled: nodes.length > 0,\n collisionPriority: 1,\n accept: source => canAcceptDrop(\n source,\n parentNode,\n null,\n 'end',\n canDrop\n ),\n });\n\n return (\n <div\n ref={ ref }\n role=\"list\"\n className={ cn(styles.list, className) }\n data-gap={ gap }\n data-drop-target={ isDropTarget || undefined }\n aria-label={ ariaLabel }\n >\n <For each={ nodes }>\n { node => (\n <SortableItem\n key={ node.id }\n node={ node }\n rootNodes={ rootNodes }\n renderItem={ renderItem }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n nestedGap={ nestedGap }\n handle={ handle }\n />\n ) }\n </For>\n </div>\n );\n}\n\nfunction SortableItem<T>({\n node,\n rootNodes,\n renderItem,\n canDrop,\n getDragHandleOptions,\n nestedGap,\n handle,\n}: SortableItemProps<T>) {\n const context = itemContext(node);\n const {\n alignment = 'center',\n edgeOffset = 'none',\n variant = 'plain',\n } = getDragHandleOptions?.(node.value, context) ?? {};\n const {\n handleRef,\n ref,\n targetRef,\n isDragging,\n isDropTarget,\n } = useSortable<SortableNodeData<T>>({\n id: node.id,\n index: node.index,\n group: collectionIdFromParentKey(nodeParentKey(rootNodes, node)),\n type: SORTABLE_ITEM_TYPE,\n data: { kind: 'node', node },\n accept: source => canAcceptDrop(\n source,\n node.parent == null\n ? null\n : findParentNode(rootNodes, node),\n node,\n 'before',\n canDrop\n ),\n });\n const nestedItems = node.canHaveChildren\n ? (\n <SortableCollection\n nodes={ node.children }\n rootNodes={ rootNodes }\n parentNode={ node }\n renderItem={ renderItem }\n canDrop={ canDrop }\n getDragHandleOptions={ getDragHandleOptions }\n gap={ nestedGap }\n nestedGap={ nestedGap }\n handle={ handle }\n ariaLabel={ `${ node.textValue } items` }\n />\n )\n : null;\n\n return (\n <div\n ref={ ref }\n role=\"listitem\"\n className={ styles.item }\n data-level={ node.level }\n data-dragging={ isDragging || undefined }\n data-drop-target={ isDropTarget || undefined }\n >\n <div\n ref={ targetRef }\n className={ styles.dropTarget }\n data-container={ node.canHaveChildren || undefined }\n aria-hidden\n />\n\n <Show when={ handle }>\n <span\n ref={ handleRef }\n className={ styles.dragHandle }\n data-alignment={ alignment }\n data-edge-offset={ edgeOffset }\n data-variant={ variant }\n aria-hidden\n >\n <DotsDrag aria-hidden width={ 14 } height={ 14 } />\n </span>\n </Show>\n\n <div className={ styles.content }>\n { renderItem(node.value, {\n ...context,\n nestedItems,\n isDragging,\n isDropTarget,\n }) }\n </div>\n </div>\n );\n}\n\nfunction SortablePreview<T>({\n node,\n renderItem,\n nestedGap,\n}: {\n node: SortableTreeNode<T>;\n renderItem: (item: T, props: SortableListItemRenderProps<T>) => ReactNode;\n nestedGap: 'sm' | 'md';\n}): ReactElement {\n const nestedItems = node.canHaveChildren\n ? (\n <div className={ styles.previewList } data-gap={ nestedGap }>\n <For each={ node.children }>\n { child => (\n <SortablePreview\n key={ child.id }\n node={ child }\n renderItem={ renderItem }\n nestedGap={ nestedGap }\n />\n ) }\n </For>\n </div>\n )\n : null;\n\n return (\n <div className={ styles.dragPreviewItem }>\n { renderItem(node.value, {\n ...itemContext(node),\n nestedItems,\n isDragging: false,\n isDropTarget: false,\n }) }\n </div>\n );\n}\n\nfunction itemContext<T>(node: SortableTreeNode<T>): SortableListItemContext<T> {\n return {\n level: node.level,\n parent: node.parent,\n index: node.index,\n siblingCount: node.siblingCount,\n isFirst: node.index === 0,\n isLast: node.index === node.siblingCount - 1,\n hasChildren: node.children.length > 0,\n canHaveChildren: node.canHaveChildren,\n };\n}\n\nfunction canAcceptDrop<T>(\n source: { data: Record<string, unknown> },\n parentNode: SortableTreeNode<T> | null,\n targetNode: SortableTreeNode<T> | null,\n dropPosition: SortableListDropContext<T>['dropPosition'],\n canDrop?: (context: SortableListDropContext<T>) => boolean\n): boolean {\n const sourceNode = nodeData<T>(source)?.node;\n\n if (!sourceNode || !canMoveToParent(sourceNode, parentNode)) {\n return false;\n }\n\n return canDrop?.(\n createDropContext(sourceNode, parentNode, targetNode, dropPosition)\n ) ?? true;\n}\n\nfunction createDropContext<T>(\n sourceNode: SortableTreeNode<T>,\n parentNode: SortableTreeNode<T> | null,\n targetNode: SortableTreeNode<T> | null,\n dropPosition: SortableListDropContext<T>['dropPosition']\n): SortableListDropContext<T> {\n return {\n items: [sourceNode.value],\n target: targetNode?.value ?? null,\n sourceParent: sourceNode.parent,\n sourceLevel: sourceNode.level,\n parent: parentNode?.value ?? null,\n targetLevel: parentNode ? parentNode.level + 1 : 1,\n dropPosition,\n };\n}\n\nfunction canMoveToParent<T>(\n sourceNode: SortableTreeNode<T>,\n parentNode: SortableTreeNode<T> | null\n): boolean {\n return parentNode == null\n || (parentNode.id !== sourceNode.id\n && findSortableTreeNode(sourceNode.children, parentNode.id) == null);\n}\n\nfunction destinationFromSortable<T>(\n nodes: readonly SortableTreeNode<T>[],\n group: string | number | undefined,\n index: number,\n targetNode: SortableTreeNode<T> | null\n): SortableDestination<T> | null {\n const parentKey = parentKeyFromCollectionId(group);\n\n if (parentKey === undefined) {\n return null;\n }\n\n const parentNode = parentKey == null\n ? null\n : findSortableTreeNode(nodes, parentKey);\n\n if (parentKey != null && !parentNode) {\n return null;\n }\n\n const isAfterTarget = targetNode != null && index > targetNode.index;\n\n return {\n parentNode,\n index,\n dropPosition: isAfterTarget ? 'after' : 'before',\n };\n}\n\nfunction collectionId<T>(parentNode: SortableTreeNode<T> | null): string {\n return collectionIdFromParentKey(parentNode?.id ?? null);\n}\n\nfunction collectionIdFromParentKey(parentKey: string | null): string {\n return parentKey == null\n ? ROOT_COLLECTION_ID\n : `${ CHILD_COLLECTION_PREFIX }${ parentKey }`;\n}\n\nfunction parentKeyFromCollectionId(\n collectionId: string | number | undefined\n): string | null | undefined {\n if (collectionId === ROOT_COLLECTION_ID) {\n return null;\n }\n\n if (typeof collectionId === 'string'\n && collectionId.startsWith(CHILD_COLLECTION_PREFIX)) {\n return collectionId.slice(CHILD_COLLECTION_PREFIX.length);\n }\n\n return undefined;\n}\n\nfunction nodeParentKey<T>(\n nodes: readonly SortableTreeNode<T>[],\n target: SortableTreeNode<T>\n): string | null {\n return findParentNode(nodes, target)?.id ?? null;\n}\n\nfunction findParentNode<T>(\n nodes: readonly SortableTreeNode<T>[],\n target: SortableTreeNode<T>\n): SortableTreeNode<T> | null {\n for (const node of nodes) {\n if (node.children.some(child => child.id === target.id)) {\n return node;\n }\n\n const parent = findParentNode(node.children, target);\n\n if (parent) {\n return parent;\n }\n }\n\n return null;\n}\n\nfunction entityData<T>(\n entity: { data: Record<string, unknown> } | null\n): SortableNodeData<T> | SortableCollectionData<T> | null {\n const data = entity?.data;\n\n if (data?.kind === 'node' && 'node' in data) {\n return {\n kind: 'node',\n node: data.node as SortableTreeNode<T>,\n };\n }\n\n if (data?.kind === 'collection' && 'parentNode' in data) {\n return {\n kind: 'collection',\n parentNode: data.parentNode as SortableTreeNode<T> | null,\n };\n }\n\n return null;\n}\n\nfunction nodeData<T>(\n entity: { data: Record<string, unknown> } | null\n): SortableNodeData<T> | null {\n const data = entityData<T>(entity);\n\n return data?.kind === 'node' ? data : null;\n}\n\nSortableList.displayName = 'SortableList';\n"],"names":["ROOT_COLLECTION_ID","CHILD_COLLECTION_PREFIX","SORTABLE_ITEM_TYPE","SORTABLE_COLLECTION_TYPE","POINTER_SENSORS","PointerSensor","PRIMITIVE_KEY_PREFIX","objectKeys","nextObjectKey","SortableList","items","getItemKey","getTextValue","getChildren","setChildren","canHaveChildren","onChange","children","canDrop","getDragHandleOptions","className","gap","nestedGap","handle","ariaLabel","getNodeKey","useCallback","item","path","itemKey","existingKey","key","nodes","useMemo","buildSortableTree","renderState","setRenderState","useState","handleDragEnd","event","canceled","operation","source","target","isSortable","sourceNode","nodeData","targetData","entityData","targetNode","destination","destinationFromSortable","context","createDropContext","canMoveToParent","initialParentKey","parentKeyFromCollectionId","destinationParentKey","movedNodes","moveSortableTreeNodeToIndex","restoreSortableTree","_jsxs","DragDropProvider","_jsx","SortableCollection","DragOverlay","styles","node","SortablePreview","rootNodes","parentNode","renderItem","ref","isDropTarget","useDroppable","collectionId","canAcceptDrop","cn","For","SortableItem","itemContext","alignment","edgeOffset","variant","handleRef","targetRef","isDragging","useSortable","collectionIdFromParentKey","nodeParentKey","findParentNode","nestedItems","Show","DotsDrag","child","dropPosition","findSortableTreeNode","group","index","parentKey","isAfterTarget","parent","entity","data"],"mappings":";;;;;;;;;;AAUA,MAAMA,IAAqB,yBACrBC,IAA0B,8BAC1BC,KAAqB,yBACrBC,KAA2B,+BAC3BC,KAAkB,CAACC,EAAa,GAChCC,KAAuB,uBAGvBC,wBAAiB,QAAA;AACvB,IAAIC,IAAgB;AAQb,SAASC,GAAa;AAAA,EAC3B,OAAAC;AAAA,EACA,QAAQC;AAAA,EACR,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,WAAAC,IAAYD;AAAA,EACZ,QAAAE,IAAS;AAAA,EACT,cAAcC;AAChB,GAAG;AACD,QAAMC,IAAaC,GAAY,CAACC,GAAMC,MAAS;AAC7C,UAAMC,IAAUlB,IAAagB,GAAMC,CAAI;AACvC,QAAIC,KAAW;AACb,aAAOA;AAET,QAAI,OAAOF,KAAS,YAAYA,KAAQ;AACtC,aAAO,GAAGrB,EAAoB,GAAGsB,EAAK,KAAK,GAAG,CAAC;AAEjD,UAAME,IAAcvB,EAAW,IAAIoB,CAAI;AACvC,QAAIG;AACF,aAAOA;AAET,UAAMC,IAAM,iBAAiBvB,CAAa;AAC1C,WAAAA,KAAiB,GACjBD,EAAW,IAAIoB,GAAMI,CAAG,GACjBA;AAAA,EACT,GAAG,CAACpB,CAAU,CAAC,GACTqB,IAAQC,GAAQ,MAAMC,GAAkBxB,GAAO;AAAA,IACnD,QAAQe;AAAA,IACR,cAAAb;AAAA,IACA,aAAAC;AAAA,IACA,iBAAAE;AAAA,EAAA,CACD,GAAG,CAACA,GAAiBF,GAAaY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AACA,SAAS3C,EAA0BmB,GAAc;AAC/C,MAAIA,MAAiB3E;AACnB,WAAO;AAET,MAAI,OAAO2E,KAAiB,YAAYA,EAAa,WAAW1E,CAAuB;AACrF,WAAO0E,EAAa,MAAM1E,EAAwB,MAAM;AAG5D;AACA,SAASwF,GAAczD,GAAOW,GAAQ;AACpC,SAAO+C,EAAe1D,GAAOW,CAAM,GAAG,MAAM;AAC9C;AACA,SAAS+C,EAAe1D,GAAOW,GAAQ;AACrC,aAAWwB,KAAQnC,GAAO;AACxB,QAAImC,EAAK,SAAS,KAAK,CAAA2B,MAASA,EAAM,OAAOnD,EAAO,EAAE;AACpD,aAAOwB;AAET,UAAMkC,IAASX,EAAevB,EAAK,UAAUxB,CAAM;AACnD,QAAI0D;AACF,aAAOA;AAAA,EAEX;AACA,SAAO;AACT;AACA,SAASrD,EAAWsD,GAAQ;AAC1B,QAAMC,IAAOD,GAAQ;AACrB,SAAIC,GAAM,SAAS,UAAU,UAAUA,IAC9B;AAAA,IACL,MAAM;AAAA,IACN,MAAMA,EAAK;AAAA,EAAA,IAGXA,GAAM,SAAS,gBAAgB,gBAAgBA,IAC1C;AAAA,IACL,MAAM;AAAA,IACN,YAAYA,EAAK;AAAA,EAAA,IAGd;AACT;AACA,SAASzD,EAASwD,GAAQ;AACxB,QAAMC,IAAOvD,EAAWsD,CAAM;AAC9B,SAAOC,GAAM,SAAS,SAASA,IAAO;AACxC;AACA9F,GAAa,cAAc;"}
|
|
@@ -13,7 +13,7 @@ export type ComposerBannerStatusProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
13
13
|
onAction?: () => void;
|
|
14
14
|
/** Action button tint. Default `secondary`. */
|
|
15
15
|
actionColor?: ButtonColor;
|
|
16
|
-
/** Press anywhere on the row except the action. */
|
|
16
|
+
/** Press anywhere on the row except the action. The action then shows on hover or focus. */
|
|
17
17
|
onPress?: () => void;
|
|
18
18
|
icon?: ReactNode;
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerBanner.d.ts","sourceRoot":"","sources":["../../../src/chat/ComposerBanner/ComposerBanner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAMxD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,GAAG;IAC9E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,yDAAyD;IACzD,KAAK,CAAC,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,EACJ,GAAG,KAAK,EACX,EAAE,mBAAmB,+BAYrB;AAED,MAAM,MAAM,yBAAyB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACrE,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,
|
|
1
|
+
{"version":3,"file":"ComposerBanner.d.ts","sourceRoot":"","sources":["../../../src/chat/ComposerBanner/ComposerBanner.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAMxD,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,GAAG;IAC9E,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,yDAAyD;IACzD,KAAK,CAAC,EAAE,QAAQ,CAAC;CACpB,CAAC;AAEF,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,EAC3B,QAAQ,EACR,SAAS,EACT,KAAK,EACL,IAAI,EACJ,GAAG,KAAK,EACX,EAAE,mBAAmB,+BAYrB;AAED,MAAM,MAAM,yBAAyB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACrE,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,4FAA4F;IAC5F,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,uEAAuE;AACvE,wBAAgB,oBAAoB,CAAC,EACjC,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,WAAyB,EACzB,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,KAAK,EACX,EAAE,yBAAyB,+BAsC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerBanner.js","sources":["../../../src/chat/ComposerBanner/ComposerBanner.tsx"],"sourcesContent":["import { cn } from '@reforma/lib';\n\nimport { Button, type ButtonColor } from '../../Button';\nimport { Pressable } from '../../Pressable';\nimport { Show } from '../../Show';\nimport { Text } from '../../Text';\nimport styles from './ComposerBanner.module.css';\n\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nexport type ComposerBannerProps = Omit<HTMLAttributes<HTMLDivElement>, 'color'> & {\n children?: ReactNode;\n /** Plate tint. Default is the muted interrupt chrome. */\n color?: 'danger';\n};\n\n/** Shared plate above the composer — chrome only. */\nexport function ComposerBanner({\n children,\n className,\n color,\n role,\n ...props\n}: ComposerBannerProps) {\n return (\n <div\n data-slot=\"composer-banner\"\n data-color={ color }\n role={ role ?? (color === 'danger' ? 'alert' : undefined) }\n className={ cn(styles.root, className) }\n { ...props }\n >\n { children }\n </div>\n );\n}\n\nexport type ComposerBannerStatusProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n action: string;\n onAction?: () => void;\n /** Action button tint. Default `secondary`. */\n actionColor?: ButtonColor;\n /** Press anywhere on the row except the action. */\n onPress?: () => void;\n icon?: ReactNode;\n};\n\n/** One status row inside {@link ComposerBanner} — message + action. */\nexport function ComposerBannerStatus({\n children,\n action,\n onAction,\n actionColor = 'secondary',\n onPress,\n icon,\n className,\n ...props\n}: ComposerBannerStatusProps) {\n const message = (\n <>\n <Show when={ icon }>\n <span className={ styles.icon }>\n { icon }\n </span>\n </Show>\n <Text variant=\"xs\" className={ styles.text }>\n { children }\n </Text>\n </>\n );\n\n return (\n <div className={ cn(styles.status, className) } data-pressable={ onPress ? true : undefined } { ...props }>\n <Show when={ onPress } fallback={ message }>\n { press => (\n <Pressable onPress={ press }>\n <span role=\"button\" tabIndex={ 0 } className={ styles.press }>\n { message }\n </span>\n </Pressable>\n ) }\n </Show>\n\n <Button\n size=\"xs\"\n variant=\"ghost\"\n color={ actionColor }\n className={ styles.action }\n isDisabled={ !onAction }\n onPress={ onAction }\n >\n { action }\n </Button>\n </div>\n );\n}\n"],"names":["ComposerBanner","children","className","color","role","props","cn","styles","ComposerBannerStatus","action","onAction","actionColor","onPress","icon","message","_Fragment","_jsx","Show","Text","press","Pressable","Button"],"mappings":";;;;;;;AAQO,SAASA,EAAe;AAAA,EAC7B,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,GAAGC;AACL,GAAG;AACD,2BAAyB,OAAO;AAAA,IAC9B,aAAa;AAAA,IACb,cAAcF;AAAA,IACd,MAAMC,MAASD,MAAU,WAAW,UAAU;AAAA,IAC9C,WAAWG,EAAGC,EAAO,MAAML,CAAS;AAAA,IACpC,GAAGG;AAAA,IACH,UAAAJ;AAAA,EAAA,CACD;AACH;AAEO,SAASO,EAAqB;AAAA,EACnC,UAAAP;AAAA,EACA,QAAAQ;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,WAAAX;AAAA,EACA,GAAGG;AACL,GAAG;AACD,QAAMS,sBAA6BC,GAAW;AAAA,IAC5C,UAAU,CAAcC,gBAAAA,EAAKC,GAAM;AAAA,MACjC,MAAMJ;AAAA,MACN,4BAA4B,QAAQ;AAAA,QAClC,WAAWN,EAAO;AAAA,QAClB,UAAUM;AAAA,MAAA,CACX;AAAA,IAAA,CACF,GAAgBG,gBAAAA,EAAKE,GAAM;AAAA,MAC1B,SAAS;AAAA,MACT,WAAWX,EAAO;AAAA,MAClB,UAAAN;AAAA,IAAA,CACD,CAAC;AAAA,EAAA,CACH;AACD,2BAA0B,OAAO;AAAA,IAC/B,WAAWK,EAAGC,EAAO,QAAQL,CAAS;AAAA,IACtC,kBAAkBU,IAAU,KAAO;AAAA,IACnC,GAAGP;AAAA,IACH,UAAU,CAAcW,gBAAAA,EAAKC,GAAM;AAAA,MACjC,MAAML;AAAA,MACN,UAAUE;AAAA,MACV,UAAU,CAAAK,MAAsBH,gBAAAA,EAAKI,GAAW;AAAA,QAC9C,SAASD;AAAA,QACT,4BAA4B,QAAQ;AAAA,UAClC,MAAM;AAAA,UACN,UAAU;AAAA,UACV,WAAWZ,EAAO;AAAA,UAClB,UAAUO;AAAA,QAAA,CACX;AAAA,MAAA,CACF;AAAA,IAAA,CACF,GAAgBE,gBAAAA,EAAKK,GAAQ;AAAA,MAC5B,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAOV;AAAA,MACP,WAAWJ,EAAO;AAAA,MAClB,YAAY,CAACG;AAAA,MACb,SAASA;AAAA,MACT,UAAUD;AAAA,IAAA,CACX,CAAC;AAAA,EAAA,CACH;AACH;"}
|
|
1
|
+
{"version":3,"file":"ComposerBanner.js","sources":["../../../src/chat/ComposerBanner/ComposerBanner.tsx"],"sourcesContent":["import { cn } from '@reforma/lib';\n\nimport { Button, type ButtonColor } from '../../Button';\nimport { Pressable } from '../../Pressable';\nimport { Show } from '../../Show';\nimport { Text } from '../../Text';\nimport styles from './ComposerBanner.module.css';\n\nimport type { HTMLAttributes, ReactNode } from 'react';\n\nexport type ComposerBannerProps = Omit<HTMLAttributes<HTMLDivElement>, 'color'> & {\n children?: ReactNode;\n /** Plate tint. Default is the muted interrupt chrome. */\n color?: 'danger';\n};\n\n/** Shared plate above the composer — chrome only. */\nexport function ComposerBanner({\n children,\n className,\n color,\n role,\n ...props\n}: ComposerBannerProps) {\n return (\n <div\n data-slot=\"composer-banner\"\n data-color={ color }\n role={ role ?? (color === 'danger' ? 'alert' : undefined) }\n className={ cn(styles.root, className) }\n { ...props }\n >\n { children }\n </div>\n );\n}\n\nexport type ComposerBannerStatusProps = HTMLAttributes<HTMLDivElement> & {\n children: ReactNode;\n action: string;\n onAction?: () => void;\n /** Action button tint. Default `secondary`. */\n actionColor?: ButtonColor;\n /** Press anywhere on the row except the action. The action then shows on hover or focus. */\n onPress?: () => void;\n icon?: ReactNode;\n};\n\n/** One status row inside {@link ComposerBanner} — message + action. */\nexport function ComposerBannerStatus({\n children,\n action,\n onAction,\n actionColor = 'secondary',\n onPress,\n icon,\n className,\n ...props\n}: ComposerBannerStatusProps) {\n const message = (\n <>\n <Show when={ icon }>\n <span className={ styles.icon }>\n { icon }\n </span>\n </Show>\n <Text variant=\"xs\" className={ styles.text }>\n { children }\n </Text>\n </>\n );\n\n return (\n <div className={ cn(styles.status, className) } data-pressable={ onPress ? true : undefined } { ...props }>\n <Show when={ onPress } fallback={ message }>\n { press => (\n <Pressable onPress={ press }>\n <span role=\"button\" tabIndex={ 0 } className={ styles.press }>\n { message }\n </span>\n </Pressable>\n ) }\n </Show>\n\n <Button\n size=\"xs\"\n variant=\"ghost\"\n color={ actionColor }\n className={ styles.action }\n isDisabled={ !onAction }\n onPress={ onAction }\n >\n { action }\n </Button>\n </div>\n );\n}\n"],"names":["ComposerBanner","children","className","color","role","props","cn","styles","ComposerBannerStatus","action","onAction","actionColor","onPress","icon","message","_Fragment","_jsx","Show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AO;AAAA,UAClB,UAAUO;AAAA,QAAA,CACX;AAAA,MAAA,CACF;AAAA,IAAA,CACF,GAAgBE,gBAAAA,EAAKK,GAAQ;AAAA,MAC5B,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAOV;AAAA,MACP,WAAWJ,EAAO;AAAA,MAClB,YAAY,CAACG;AAAA,MACb,SAASA;AAAA,MACT,UAAUD;AAAA,IAAA,CACX,CAAC;AAAA,EAAA,CACH;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer components{.ComposerBanner_root_HyjFf2{display:flex;flex-direction:column;margin:0 var(--spacing-md);border-top-right-radius:calc(var(--radius-md) * var(--squircle-radius-factor));border-top-left-radius:calc(var(--radius-md) * var(--squircle-radius-factor));min-width:0;corner-shape:superellipse(var(--squircle-value)) superellipse(var(--squircle-value)) square square;background-color:var(--color-secondary-muted-light);overflow:hidden}.dark .ComposerBanner_root_HyjFf2:not([data-color]){background-color:var(--color-light-700)}.ComposerBanner_root_HyjFf2[data-color=danger]{background-color:var(--color-danger-muted-light);color:var(--color-danger-text)}.ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS{position:relative}.ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS:before{position:absolute;top:0;right:var(--spacing-sm);left:var(--spacing-sm);border-top:1px solid var(--color-secondary-muted-border);content:""}.ComposerBanner_root_HyjFf2[data-color=danger] .ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS:before{border-top-color:var(--color-danger-muted-border)}.ComposerBanner_status_EIdxnS{display:flex;justify-content:space-between;align-items:center;gap:var(--spacing-sm);padding:var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) var(--spacing-lg);word-wrap:break-word}.ComposerBanner_icon_5Md4lZ{display:flex;flex-shrink:0;color:var(--color-secondary-muted-text)}.ComposerBanner_text_UFktfG{flex:1;max-height:3lh;overflow:hidden}.ComposerBanner_status_EIdxnS[data-pressable]{position:relative}.ComposerBanner_press_FFVYdF{display:flex;flex:1;align-items:center;gap:var(--spacing-sm);cursor:pointer;outline:none;min-width:0}.ComposerBanner_press_FFVYdF:after{position:absolute;inset:0;content:""}.ComposerBanner_press_FFVYdF:focus-visible:after{outline:var(--spacing-4) solid var(--color-primary-muted-border);outline-offset:calc(var(--spacing-4) * -1)}.
|
|
1
|
+
@layer components{.ComposerBanner_root_HyjFf2{display:flex;flex-direction:column;margin:0 var(--spacing-md);border-top-right-radius:calc(var(--radius-md) * var(--squircle-radius-factor));border-top-left-radius:calc(var(--radius-md) * var(--squircle-radius-factor));min-width:0;corner-shape:superellipse(var(--squircle-value)) superellipse(var(--squircle-value)) square square;background-color:var(--color-secondary-muted-light);overflow:hidden}.dark .ComposerBanner_root_HyjFf2:not([data-color]){background-color:var(--color-light-700)}.ComposerBanner_root_HyjFf2[data-color=danger]{background-color:var(--color-danger-muted-light);color:var(--color-danger-text)}.ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS{position:relative}.ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS:before{position:absolute;top:0;right:var(--spacing-sm);left:var(--spacing-sm);border-top:1px solid var(--color-secondary-muted-border);content:""}.ComposerBanner_root_HyjFf2[data-color=danger] .ComposerBanner_status_EIdxnS+.ComposerBanner_status_EIdxnS:before{border-top-color:var(--color-danger-muted-border)}.ComposerBanner_status_EIdxnS{display:flex;justify-content:space-between;align-items:center;gap:var(--spacing-sm);padding:var(--spacing-sm) var(--spacing-sm) var(--spacing-sm) var(--spacing-lg);word-wrap:break-word}.ComposerBanner_icon_5Md4lZ{display:flex;flex-shrink:0;color:var(--color-secondary-muted-text)}.ComposerBanner_text_UFktfG{flex:1;max-height:3lh;overflow:hidden}.ComposerBanner_status_EIdxnS[data-pressable]{position:relative;isolation:isolate;min-height:calc(var(--spacing-30) + var(--spacing-xs) * 2)}.ComposerBanner_status_EIdxnS[data-pressable]:after{position:absolute;z-index:-1;inset:var(--spacing-xs);border-radius:calc(var(--radius-sm) * var(--squircle-radius-factor));content:"";corner-shape:superellipse(var(--squircle-value));transition:background-color var(--transition-duration-fast);pointer-events:none}.ComposerBanner_status_EIdxnS[data-pressable]:hover:after{background-color:var(--color-secondary-muted-light)}@media(hover:hover){.ComposerBanner_status_EIdxnS[data-pressable] .ComposerBanner_action_EUqshm{opacity:0;transition:opacity var(--transition-duration-fast)}.ComposerBanner_status_EIdxnS[data-pressable]:hover .ComposerBanner_action_EUqshm,.ComposerBanner_status_EIdxnS[data-pressable]:focus-within .ComposerBanner_action_EUqshm{opacity:1}}.ComposerBanner_press_FFVYdF{display:flex;flex:1;align-items:center;gap:var(--spacing-sm);cursor:pointer;outline:none;min-width:0}.ComposerBanner_press_FFVYdF:after{position:absolute;inset:0;content:""}.ComposerBanner_press_FFVYdF:focus-visible:after{outline:var(--spacing-4) solid var(--color-primary-muted-border);outline-offset:calc(var(--spacing-4) * -1)}.ComposerBanner_action_EUqshm{position:relative}}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const o = "ComposerBanner_root_HyjFf2", s = "ComposerBanner_status_EIdxnS", t = "ComposerBanner_icon_5Md4lZ", n = "ComposerBanner_text_UFktfG", e = "
|
|
1
|
+
const o = "ComposerBanner_root_HyjFf2", s = "ComposerBanner_status_EIdxnS", t = "ComposerBanner_icon_5Md4lZ", n = "ComposerBanner_text_UFktfG", e = "ComposerBanner_action_EUqshm", r = "ComposerBanner_press_FFVYdF", a = {
|
|
2
2
|
root: o,
|
|
3
3
|
status: s,
|
|
4
4
|
icon: t,
|
|
5
5
|
text: n,
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
action: e,
|
|
7
|
+
press: r
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
e as action,
|
|
11
11
|
a as default,
|
|
12
12
|
t as icon,
|
|
13
|
-
|
|
13
|
+
r as press,
|
|
14
14
|
o as root,
|
|
15
15
|
s as status,
|
|
16
16
|
n as text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BashTool.d.ts","sourceRoot":"","sources":["../../../../src/chat/Tool/bash/BashTool.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BashTool.d.ts","sourceRoot":"","sources":["../../../../src/chat/Tool/bash/BashTool.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAqKlD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,iBAAiB,sCAyEhD"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { Completed as
|
|
2
|
-
import { isStaticToolUIPart as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { Show as
|
|
5
|
-
import { TerminalContent as
|
|
1
|
+
import { Completed as b, Oclock as k, Terminal as y } from "@reforma/icons/14";
|
|
2
|
+
import { isStaticToolUIPart as w, getToolName as C } from "@reforma/types";
|
|
3
|
+
import { useMemo as u } from "react";
|
|
4
|
+
import { Show as h } from "../../../Show/Show.js";
|
|
5
|
+
import { TerminalContent as S } from "../../../Terminal/Terminal.js";
|
|
6
6
|
import { Text as O } from "../../../Text/Text.js";
|
|
7
7
|
import { Approval as R, ApprovalRequest as j, ApprovalButtons as A } from "../../Approval/Approval.js";
|
|
8
8
|
import { getToolFailureRowState as P, isToolInvocationInProgress as $ } from "../helpers.js";
|
|
9
9
|
import { ToolShell as F, ToolShellHeader as I, ToolShellContent as N, ToolShellFooter as q } from "../shell/ToolShell.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
function H(t) {
|
|
10
|
+
import g from "./BashTool.module.css.js";
|
|
11
|
+
import { jsxs as T, jsx as s } from "react/jsx-runtime";
|
|
12
|
+
function D(t) {
|
|
14
13
|
const r = t?.input;
|
|
15
14
|
if (r == null || typeof r != "object")
|
|
16
15
|
return {
|
|
@@ -27,7 +26,7 @@ function H(t) {
|
|
|
27
26
|
background: o.background === !0
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
function
|
|
29
|
+
function H(t) {
|
|
31
30
|
if (!t)
|
|
32
31
|
return {
|
|
33
32
|
stdout: "",
|
|
@@ -48,28 +47,28 @@ function L(t) {
|
|
|
48
47
|
signal: c
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
|
-
function
|
|
50
|
+
function l(t) {
|
|
52
51
|
return t.command === "" && (t.background || t.id != null);
|
|
53
52
|
}
|
|
54
|
-
function
|
|
55
|
-
return t.background ||
|
|
53
|
+
function L(t) {
|
|
54
|
+
return t.background || l(t);
|
|
56
55
|
}
|
|
57
|
-
function
|
|
58
|
-
return
|
|
56
|
+
function M(t, r) {
|
|
57
|
+
return l(t) && r.status !== "running";
|
|
59
58
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
59
|
+
function _(t, r) {
|
|
60
|
+
return l(t) ? r.status === "running" ? "Background task" : "Background task finished" : t.description !== "" ? t.description : t.command !== "" ? t.command : "Bash";
|
|
62
61
|
}
|
|
63
|
-
function
|
|
62
|
+
function B(t) {
|
|
64
63
|
const r = [];
|
|
65
64
|
return typeof t.exitCode == "number" && r.push(`exit ${t.exitCode}`), t.signal && r.push(`signal ${t.signal}`), r.length === 0 && t.status && t.status !== "running" && r.push(t.status), r.join(`
|
|
66
65
|
`);
|
|
67
66
|
}
|
|
68
|
-
const
|
|
69
|
-
function
|
|
67
|
+
const z = "\x1B[32m$\x1B[0m";
|
|
68
|
+
function E(t) {
|
|
70
69
|
return t.split("\x1B").join("");
|
|
71
70
|
}
|
|
72
|
-
function
|
|
71
|
+
function U(t) {
|
|
73
72
|
const {
|
|
74
73
|
stdout: r = "",
|
|
75
74
|
stderr: o = ""
|
|
@@ -79,58 +78,53 @@ function W(t) {
|
|
|
79
78
|
`) && (n += `
|
|
80
79
|
`), n += `\x1B[31m${o}\x1B[0m`), n;
|
|
81
80
|
}
|
|
82
|
-
function
|
|
83
|
-
const o =
|
|
81
|
+
function W(t, r) {
|
|
82
|
+
const o = U(r), e = [t.command === "" ? B(r) : "", o].filter((i) => i !== "").join(`
|
|
84
83
|
`);
|
|
85
|
-
return t.command === "" ? e : `${
|
|
84
|
+
return t.command === "" ? e : `${z} ${E(t.command)}
|
|
86
85
|
` + e;
|
|
87
86
|
}
|
|
88
|
-
function
|
|
87
|
+
function rt(t) {
|
|
89
88
|
const {
|
|
90
89
|
onToolApprovalResponse: r
|
|
91
|
-
} = t, o =
|
|
90
|
+
} = t, o = w(t.part) && C(t.part) === "Bash" ? t.part : null, n = u(() => D(o), [o]), e = u(() => H(o), [o]), a = u(() => W(n, e), [n, e]);
|
|
92
91
|
if (!o)
|
|
93
92
|
return null;
|
|
94
|
-
const i = o.state, c = P(o), d = o.approval,
|
|
95
|
-
return /* @__PURE__ */
|
|
96
|
-
collapsible:
|
|
93
|
+
const i = o.state, c = P(o), d = o.approval, m = $(i, !0), v = !!(e.stdout || e.stderr || B(e)), f = n.command !== "" || v, p = M(n, e), x = L(n) && !p;
|
|
94
|
+
return /* @__PURE__ */ T(F, {
|
|
95
|
+
collapsible: f,
|
|
97
96
|
"data-slot": "bash-tool",
|
|
98
97
|
children: [/* @__PURE__ */ s(I, {
|
|
99
98
|
state: i,
|
|
100
99
|
statusDetail: c.tooltip,
|
|
101
|
-
title:
|
|
100
|
+
title: _(n, e),
|
|
102
101
|
truncateTitle: !0,
|
|
103
|
-
icon:
|
|
102
|
+
icon: p ? /* @__PURE__ */ s(b, {
|
|
104
103
|
"aria-hidden": !0
|
|
105
|
-
}) :
|
|
104
|
+
}) : x ? /* @__PURE__ */ s(k, {
|
|
106
105
|
"aria-hidden": !0
|
|
107
106
|
}) : /* @__PURE__ */ s(y, {
|
|
108
107
|
"aria-hidden": !0
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
labels: ["background"],
|
|
113
|
-
"aria-label": "Background"
|
|
114
|
-
}) : void 0
|
|
115
|
-
}), /* @__PURE__ */ s(T, {
|
|
116
|
-
when: p,
|
|
108
|
+
})
|
|
109
|
+
}), /* @__PURE__ */ s(h, {
|
|
110
|
+
when: f,
|
|
117
111
|
children: /* @__PURE__ */ s(N, {
|
|
118
|
-
className:
|
|
119
|
-
children: /* @__PURE__ */ s(
|
|
120
|
-
autoScroll:
|
|
121
|
-
isStreaming:
|
|
112
|
+
className: g.content,
|
|
113
|
+
children: /* @__PURE__ */ s(S, {
|
|
114
|
+
autoScroll: m,
|
|
115
|
+
isStreaming: m,
|
|
122
116
|
output: a,
|
|
123
|
-
className:
|
|
117
|
+
className: g.terminalPanel
|
|
124
118
|
})
|
|
125
119
|
})
|
|
126
|
-
}), /* @__PURE__ */ s(
|
|
120
|
+
}), /* @__PURE__ */ s(h, {
|
|
127
121
|
when: i === "approval-requested",
|
|
128
122
|
children: /* @__PURE__ */ s(q, {
|
|
129
123
|
children: /* @__PURE__ */ s(R, {
|
|
130
124
|
approval: d,
|
|
131
125
|
state: i,
|
|
132
126
|
onToolApprovalResponse: r,
|
|
133
|
-
children: /* @__PURE__ */
|
|
127
|
+
children: /* @__PURE__ */ T(j, {
|
|
134
128
|
children: [/* @__PURE__ */ s(O, {
|
|
135
129
|
children: "Confirm you want to run this command"
|
|
136
130
|
}), /* @__PURE__ */ s(A, {})]
|
|
@@ -141,6 +135,6 @@ function st(t) {
|
|
|
141
135
|
});
|
|
142
136
|
}
|
|
143
137
|
export {
|
|
144
|
-
|
|
138
|
+
rt as BashTool
|
|
145
139
|
};
|
|
146
140
|
//# sourceMappingURL=BashTool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BashTool.js","sources":["../../../../src/chat/Tool/bash/BashTool.tsx"],"sourcesContent":["import { Completed, Oclock, Terminal } from '@reforma/icons/14';\nimport { getToolName, isStaticToolUIPart } from '@reforma/types';\nimport { useMemo } from 'react';\n\nimport { Show } from '../../../Show';\nimport { TerminalContent } from '../../../Terminal';\nimport { Text } from '../../../Text';\nimport {\n Approval,\n ApprovalButtons,\n ApprovalRequest,\n} from '../../Approval';\nimport {\n getToolFailureRowState,\n isToolInvocationInProgress,\n} from '../helpers';\nimport {\n ToolShell,\n ToolShellContent,\n ToolShellFooter,\n ToolShellHeader,\n ToolSummaryBadges,\n} from '../shell';\nimport styles from './BashTool.module.css';\n\nimport type { ToolUIPart } from 'ai';\nimport type { ToolRendererProps } from '../types';\n\ntype ParsedBashInput = {\n command: string;\n description: string;\n cwd?: string;\n id?: string;\n background: boolean;\n};\n\nfunction parseBashInput(part: ToolUIPart | null): ParsedBashInput {\n const input = part?.input;\n\n if (input == null || typeof input !== 'object') {\n return {\n command: '',\n description: '',\n background: false,\n };\n }\n\n const o = input as Record<string, unknown>;\n const command = typeof o.command === 'string' ? o.command : '';\n const description = typeof o.description === 'string' ? o.description.trim() : '';\n const cwd = typeof o.cwd === 'string' ? o.cwd.trim() : undefined;\n const id = typeof o.id === 'string' ? o.id.trim() : '';\n\n return {\n command,\n description,\n cwd: cwd !== '' ? cwd : undefined,\n id: id !== '' ? id : undefined,\n background: o.background === true,\n };\n}\n\ntype ParsedBashOutput = {\n stdout?: string;\n stderr?: string;\n status?: string;\n exitCode?: number;\n signal?: string;\n};\n\nfunction parseBashOutput(part: ToolUIPart | null): ParsedBashOutput {\n if (!part) {\n return {\n stdout: '',\n stderr: '',\n };\n }\n\n const isError = part.state === 'output-error';\n const output = (part.output ?? '') as ParsedBashOutput | string;\n\n if (typeof output === 'string') {\n return {\n stdout: output,\n stderr: isError ? part.errorText : '',\n };\n }\n\n const record = output as Record<string, unknown>;\n const stdout = typeof record.stdout === 'string' ? record.stdout : undefined;\n const stderr = typeof record.stderr === 'string' ? record.stderr : undefined;\n const status = typeof record.status === 'string' ? record.status : undefined;\n const signal = typeof record.signal === 'string' ? record.signal : undefined;\n const exitCode = typeof record.exitCode === 'number' ? record.exitCode : undefined;\n\n return {\n stdout,\n stderr,\n status,\n exitCode,\n signal,\n };\n}\n\n/** A poll or finished job: id, no command. The launch itself still has a command. */\nfunction isBackgroundResult(input: ParsedBashInput): boolean {\n return input.command === '' && (input.background || input.id != null);\n}\n\nfunction isBackgroundBash(input: ParsedBashInput): boolean {\n return input.background || isBackgroundResult(input);\n}\n\n/** Poll that already left the running state. Still-running work keeps the clock and badge. */\nfunction isFinishedBackgroundResult(input: ParsedBashInput, output: ParsedBashOutput): boolean {\n return isBackgroundResult(input) && output.status !== 'running';\n}\n\nfunction bashTitle(input: ParsedBashInput, output: ParsedBashOutput): string {\n if (isBackgroundResult(input)) {\n return output.status === 'running' ? 'Background task' : 'Background task finished';\n }\n\n if (input.description !== '') {\n return input.description;\n }\n\n if (input.command !== '') {\n return input.command;\n }\n\n return 'Bash';\n}\n\nfunction backgroundResultNote(output: ParsedBashOutput): string {\n const lines: string[] = [];\n\n if (typeof output.exitCode === 'number') {\n lines.push(`exit ${ output.exitCode }`);\n }\n\n if (output.signal) {\n lines.push(`signal ${ output.signal }`);\n }\n\n if (lines.length === 0 && output.status && output.status !== 'running') {\n lines.push(output.status);\n }\n\n return lines.join('\\n');\n}\n\n/** Green `$` */\nconst BASH_PROMPT_DOLLAR = '\\x1b[32m$\\x1b[0m';\n\n/** Avoid breaking the ANSI stream if the command string ever contained escape bytes. */\nfunction sanitizeCommandForTerminalPrompt(command: string): string {\n return command.split('\\u001b').join('');\n}\n\n/** stdout + stderr (stderr wrapped in ANSI red). */\nfunction bashOutputForTerminal(parsed: ParsedBashOutput): string {\n const { stdout = '', stderr = '' } = parsed;\n let s = stdout;\n\n if (stderr) {\n if (s !== '' && !s.endsWith('\\n')) {\n s += '\\n';\n }\n\n s += `\\x1b[31m${ stderr }\\x1b[0m`;\n }\n\n return s;\n}\n\n/** `$ command` when there is one, then stdout/stderr. A result poll has no command. */\nfunction printToTerminal(input: ParsedBashInput, output: ParsedBashOutput): string {\n const body = bashOutputForTerminal(output);\n const note = input.command === '' ? backgroundResultNote(output) : '';\n const outputText = [note, body].filter(part => part !== '').join('\\n');\n\n if (input.command === '') {\n return outputText;\n }\n\n const line = `${ BASH_PROMPT_DOLLAR } ${ sanitizeCommandForTerminalPrompt(input.command) }\\n`;\n\n return line + outputText;\n}\n\nexport function BashTool(props: ToolRendererProps) {\n const { onToolApprovalResponse } = props;\n\n const part = (isStaticToolUIPart(props.part) && getToolName(props.part) === 'Bash')\n ? props.part\n : null;\n\n const parsedInput = useMemo(() => parseBashInput(part), [part]);\n const parsedOutput = useMemo(() => parseBashOutput(part), [part]);\n\n const printOutput = useMemo(\n () => printToTerminal(parsedInput, parsedOutput),\n [parsedInput, parsedOutput]\n );\n\n if (!part) {\n return null;\n }\n\n const state = part.state;\n const failure = getToolFailureRowState(part);\n const approval = part.approval;\n const live = isToolInvocationInProgress(state, true);\n\n const hasOutput = Boolean(parsedOutput.stdout || parsedOutput.stderr || backgroundResultNote(parsedOutput));\n const showTerminal = parsedInput.command !== '' || hasOutput;\n const finished = isFinishedBackgroundResult(parsedInput, parsedOutput);\n const background = isBackgroundBash(parsedInput) && !finished;\n\n return (\n <ToolShell\n collapsible={ showTerminal }\n data-slot=\"bash-tool\"\n >\n <ToolShellHeader\n state={ state }\n statusDetail={ failure.tooltip }\n title={ bashTitle(parsedInput, parsedOutput) }\n truncateTitle\n icon={ finished\n ? <Completed aria-hidden />\n : background\n ? <Oclock aria-hidden />\n : <Terminal aria-hidden /> }\n beforeTitle={ background\n ? (\n <ToolSummaryBadges\n className={ styles.badge }\n labels={ ['background'] }\n aria-label=\"Background\"\n />\n )\n : undefined }\n />\n\n <Show when={ showTerminal }>\n <ToolShellContent className={ styles.content }>\n <TerminalContent\n autoScroll={ live }\n isStreaming={ live }\n output={ printOutput }\n className={ styles.terminalPanel }\n />\n </ToolShellContent>\n </Show>\n\n <Show when={ state === 'approval-requested' }>\n <ToolShellFooter>\n <Approval\n approval={ approval }\n state={ state }\n onToolApprovalResponse={ onToolApprovalResponse }\n >\n <ApprovalRequest>\n <Text>Confirm you want to run this command</Text>\n <ApprovalButtons />\n </ApprovalRequest>\n </Approval>\n </ToolShellFooter>\n </Show>\n </ToolShell>\n );\n}\n"],"names":["parseBashInput","part","input","command","description","cwd","id","parseBashOutput","isError","output","record","stdout","stderr","status","signal","exitCode","isBackgroundResult","isBackgroundBash","isFinishedBackgroundResult","bashTitle","backgroundResultNote","lines","BASH_PROMPT_DOLLAR","sanitizeCommandForTerminalPrompt","bashOutputForTerminal","parsed","s","printToTerminal","body","outputText","BashTool","props","onToolApprovalResponse","isStaticToolUIPart","getToolName","parsedInput","useMemo","parsedOutput","printOutput","state","failure","getToolFailureRowState","approval","live","isToolInvocationInProgress","hasOutput","showTerminal","finished","background","ToolShell","_jsx","ToolShellHeader","Completed","Oclock","Terminal","ToolSummaryBadges","styles","Show","ToolShellContent","TerminalContent","ToolShellFooter","Approval","ApprovalRequest","Text","ApprovalButtons"],"mappings":";;;;;;;;;;;;AAWA,SAASA,EAAeC,GAAM;AAC5B,QAAMC,IAAQD,GAAM;AACpB,MAAIC,KAAS,QAAQ,OAAOA,KAAU;AACpC,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,MACb,YAAY;AAAA,IAAA;AAGhB,QAAM,IAAIA,GACJC,IAAU,OAAO,EAAE,WAAY,WAAW,EAAE,UAAU,IACtDC,IAAc,OAAO,EAAE,eAAgB,WAAW,EAAE,YAAY,SAAS,IACzEC,IAAM,OAAO,EAAE,OAAQ,WAAW,EAAE,IAAI,SAAS,QACjDC,IAAK,OAAO,EAAE,MAAO,WAAW,EAAE,GAAG,SAAS;AACpD,SAAO;AAAA,IACL,SAAAH;AAAA,IACA,aAAAC;AAAA,IACA,KAAKC,MAAQ,KAAKA,IAAM;AAAA,IACxB,IAAIC,MAAO,KAAKA,IAAK;AAAA,IACrB,YAAY,EAAE,eAAe;AAAA,EAAA;AAEjC;AACA,SAASC,EAAgBN,GAAM;AAC7B,MAAI,CAACA;AACH,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IAAA;AAGZ,QAAMO,IAAUP,EAAK,UAAU,gBACzBQ,IAASR,EAAK,UAAU;AAC9B,MAAI,OAAOQ,KAAW;AACpB,WAAO;AAAA,MACL,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AU,CAAcZ,gBAAAA,EAAKa,GAAM;AAAA,cACjC,UAAU;AAAA,YAAA,CACX,GAAgBb,gBAAAA,EAAKc,GAAiB,EAAE,CAAC;AAAA,UAAA,CAC3C;AAAA,QAAA,CACF;AAAA,MAAA,CACF;AAAA,IAAA,CACF,CAAC;AAAA,EAAA,CACH;AACH;"}
|
|
1
|
+
{"version":3,"file":"BashTool.js","sources":["../../../../src/chat/Tool/bash/BashTool.tsx"],"sourcesContent":["import { Completed, Oclock, Terminal } from '@reforma/icons/14';\nimport { getToolName, isStaticToolUIPart } from '@reforma/types';\nimport { useMemo } from 'react';\n\nimport { Show } from '../../../Show';\nimport { TerminalContent } from '../../../Terminal';\nimport { Text } from '../../../Text';\nimport {\n Approval,\n ApprovalButtons,\n ApprovalRequest,\n} from '../../Approval';\nimport {\n getToolFailureRowState,\n isToolInvocationInProgress,\n} from '../helpers';\nimport {\n ToolShell,\n ToolShellContent,\n ToolShellFooter,\n ToolShellHeader,\n} from '../shell';\nimport styles from './BashTool.module.css';\n\nimport type { ToolUIPart } from 'ai';\nimport type { ToolRendererProps } from '../types';\n\ntype ParsedBashInput = {\n command: string;\n description: string;\n cwd?: string;\n id?: string;\n background: boolean;\n};\n\nfunction parseBashInput(part: ToolUIPart | null): ParsedBashInput {\n const input = part?.input;\n\n if (input == null || typeof input !== 'object') {\n return {\n command: '',\n description: '',\n background: false,\n };\n }\n\n const o = input as Record<string, unknown>;\n const command = typeof o.command === 'string' ? o.command : '';\n const description = typeof o.description === 'string' ? o.description.trim() : '';\n const cwd = typeof o.cwd === 'string' ? o.cwd.trim() : undefined;\n const id = typeof o.id === 'string' ? o.id.trim() : '';\n\n return {\n command,\n description,\n cwd: cwd !== '' ? cwd : undefined,\n id: id !== '' ? id : undefined,\n background: o.background === true,\n };\n}\n\ntype ParsedBashOutput = {\n stdout?: string;\n stderr?: string;\n status?: string;\n exitCode?: number;\n signal?: string;\n};\n\nfunction parseBashOutput(part: ToolUIPart | null): ParsedBashOutput {\n if (!part) {\n return {\n stdout: '',\n stderr: '',\n };\n }\n\n const isError = part.state === 'output-error';\n const output = (part.output ?? '') as ParsedBashOutput | string;\n\n if (typeof output === 'string') {\n return {\n stdout: output,\n stderr: isError ? part.errorText : '',\n };\n }\n\n const record = output as Record<string, unknown>;\n const stdout = typeof record.stdout === 'string' ? record.stdout : undefined;\n const stderr = typeof record.stderr === 'string' ? record.stderr : undefined;\n const status = typeof record.status === 'string' ? record.status : undefined;\n const signal = typeof record.signal === 'string' ? record.signal : undefined;\n const exitCode = typeof record.exitCode === 'number' ? record.exitCode : undefined;\n\n return {\n stdout,\n stderr,\n status,\n exitCode,\n signal,\n };\n}\n\n/** A poll or finished job: id, no command. The launch itself still has a command. */\nfunction isBackgroundResult(input: ParsedBashInput): boolean {\n return input.command === '' && (input.background || input.id != null);\n}\n\nfunction isBackgroundBash(input: ParsedBashInput): boolean {\n return input.background || isBackgroundResult(input);\n}\n\n/** Poll that already left the running state. Still-running work keeps the clock and badge. */\nfunction isFinishedBackgroundResult(input: ParsedBashInput, output: ParsedBashOutput): boolean {\n return isBackgroundResult(input) && output.status !== 'running';\n}\n\nfunction bashTitle(input: ParsedBashInput, output: ParsedBashOutput): string {\n if (isBackgroundResult(input)) {\n return output.status === 'running' ? 'Background task' : 'Background task finished';\n }\n\n if (input.description !== '') {\n return input.description;\n }\n\n if (input.command !== '') {\n return input.command;\n }\n\n return 'Bash';\n}\n\nfunction backgroundResultNote(output: ParsedBashOutput): string {\n const lines: string[] = [];\n\n if (typeof output.exitCode === 'number') {\n lines.push(`exit ${ output.exitCode }`);\n }\n\n if (output.signal) {\n lines.push(`signal ${ output.signal }`);\n }\n\n if (lines.length === 0 && output.status && output.status !== 'running') {\n lines.push(output.status);\n }\n\n return lines.join('\\n');\n}\n\n/** Green `$` */\nconst BASH_PROMPT_DOLLAR = '\\x1b[32m$\\x1b[0m';\n\n/** Avoid breaking the ANSI stream if the command string ever contained escape bytes. */\nfunction sanitizeCommandForTerminalPrompt(command: string): string {\n return command.split('\\u001b').join('');\n}\n\n/** stdout + stderr (stderr wrapped in ANSI red). */\nfunction bashOutputForTerminal(parsed: ParsedBashOutput): string {\n const { stdout = '', stderr = '' } = parsed;\n let s = stdout;\n\n if (stderr) {\n if (s !== '' && !s.endsWith('\\n')) {\n s += '\\n';\n }\n\n s += `\\x1b[31m${ stderr }\\x1b[0m`;\n }\n\n return s;\n}\n\n/** `$ command` when there is one, then stdout/stderr. A result poll has no command. */\nfunction printToTerminal(input: ParsedBashInput, output: ParsedBashOutput): string {\n const body = bashOutputForTerminal(output);\n const note = input.command === '' ? backgroundResultNote(output) : '';\n const outputText = [note, body].filter(part => part !== '').join('\\n');\n\n if (input.command === '') {\n return outputText;\n }\n\n const line = `${ BASH_PROMPT_DOLLAR } ${ sanitizeCommandForTerminalPrompt(input.command) }\\n`;\n\n return line + outputText;\n}\n\nexport function BashTool(props: ToolRendererProps) {\n const { onToolApprovalResponse } = props;\n\n const part = (isStaticToolUIPart(props.part) && getToolName(props.part) === 'Bash')\n ? props.part\n : null;\n\n const parsedInput = useMemo(() => parseBashInput(part), [part]);\n const parsedOutput = useMemo(() => parseBashOutput(part), [part]);\n\n const printOutput = useMemo(\n () => printToTerminal(parsedInput, parsedOutput),\n [parsedInput, parsedOutput]\n );\n\n if (!part) {\n return null;\n }\n\n const state = part.state;\n const failure = getToolFailureRowState(part);\n const approval = part.approval;\n const live = isToolInvocationInProgress(state, true);\n\n const hasOutput = Boolean(parsedOutput.stdout || parsedOutput.stderr || backgroundResultNote(parsedOutput));\n const showTerminal = parsedInput.command !== '' || hasOutput;\n const finished = isFinishedBackgroundResult(parsedInput, parsedOutput);\n const background = isBackgroundBash(parsedInput) && !finished;\n\n return (\n <ToolShell\n collapsible={ showTerminal }\n data-slot=\"bash-tool\"\n >\n <ToolShellHeader\n state={ state }\n statusDetail={ failure.tooltip }\n title={ bashTitle(parsedInput, parsedOutput) }\n truncateTitle\n icon={ finished\n ? <Completed aria-hidden />\n : background\n ? <Oclock aria-hidden />\n : <Terminal aria-hidden /> }\n />\n\n <Show when={ showTerminal }>\n <ToolShellContent className={ styles.content }>\n <TerminalContent\n autoScroll={ live }\n isStreaming={ live }\n output={ printOutput }\n className={ styles.terminalPanel }\n />\n </ToolShellContent>\n </Show>\n\n <Show when={ state === 'approval-requested' }>\n <ToolShellFooter>\n <Approval\n approval={ approval }\n state={ state }\n onToolApprovalResponse={ onToolApprovalResponse }\n >\n <ApprovalRequest>\n <Text>Confirm you want to run this command</Text>\n <ApprovalButtons />\n </ApprovalRequest>\n </Approval>\n </ToolShellFooter>\n </Show>\n </ToolShell>\n );\n}\n"],"names":["parseBashInput","part","input","command","description","cwd","id","parseBashOutput","isError","output","record","stdout","stderr","status","signal","exitCode","isBackgroundResult","isBackgroundBash","isFinishedBackgroundResult","bashTitle","backgroundResultNote","lines","BASH_PROMPT_DOLLAR","sanitizeCommandForTerminalPrompt","bashOutputForTerminal","parsed","s","printToTerminal","body","outputText","BashTool","props","onToolApprovalResponse","isStaticToolUIPart","getToolName","parsedInput","useMemo","parsedOutput","printOutput","state","failure","getToolFailureRowState","approval","live","isToolInvocationInProgress","hasOutput","showTerminal","finished","background","ToolShell","_jsx","ToolShellHeader","Completed","Oclock","Terminal","Show","ToolShellContent","styles","TerminalContent","ToolShellFooter","Approval","ApprovalRequest","Text","ApprovalButtons"],"mappings":";;;;;;;;;;;AAWA,SAASA,EAAeC,GAAM;AAC5B,QAAMC,IAAQD,GAAM;AACpB,MAAIC,KAAS,QAAQ,OAAOA,KAAU;AACpC,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa;AAAA,MACb,YAAY;AAAA,IAAA;AAGhB,QAAM,IAAIA,GACJC,IAAU,OAAO,EAAE,WAAY,WAAW,EAAE,UAAU,IACtDC,IAAc,OAAO,EAAE,eAAgB,WAAW,EAAE,YAAY,SAAS,IACzEC,IAAM,OAAO,EAAE,OAAQ,WAAW,EAAE,IAAI,SAAS,QACjDC,IAAK,OAAO,EAAE,M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AAAA,QAAA,CACnB;AAAA,MAAA,CACF;AAAA,IAAA,CACF,GAAgBP,gBAAAA,EAAKK,GAAM;AAAA,MAC1B,MAAMhB,MAAU;AAAA,MAChB,4BAA4BoB,GAAiB;AAAA,QAC3C,4BAA4BC,GAAU;AAAA,UACpC,UAAAlB;AAAA,UACA,OAAAH;AAAA,UACA,wBAAAP;AAAA,UACA,4BAA6B6B,GAAiB;AAAA,YAC5C,UAAU,CAAcX,gBAAAA,EAAKY,GAAM;AAAA,cACjC,UAAU;AAAA,YAAA,CACX,GAAgBZ,gBAAAA,EAAKa,GAAiB,EAAE,CAAC;AAAA,UAAA,CAC3C;AAAA,QAAA,CACF;AAAA,MAAA,CACF;AAAA,IAAA,CACF,CAAC;AAAA,EAAA,CACH;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
.BashTool_content_jQUS2j{padding:0}.BashTool_terminalPanel_bCKi82{--terminal-max-body-height: none}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
const n = "
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
terminalPanel: e
|
|
1
|
+
const n = "BashTool_content_jQUS2j", t = "BashTool_terminalPanel_bCKi82", e = {
|
|
2
|
+
content: n,
|
|
3
|
+
terminalPanel: t
|
|
5
4
|
};
|
|
6
5
|
export {
|
|
7
|
-
n as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
e as terminalPanel
|
|
6
|
+
n as content,
|
|
7
|
+
e as default,
|
|
8
|
+
t as terminalPanel
|
|
11
9
|
};
|
|
12
10
|
//# sourceMappingURL=BashTool.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BashTool.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BashTool.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@reforma/components",
|
|
3
3
|
"description": "A components library for Reforma",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Reforma, Inc. <dev@reforma.ai>",
|
|
8
8
|
"repository": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@reforma/constants": "1.1.0",
|
|
73
73
|
"@reforma/icons": "0.1.0",
|
|
74
74
|
"@reforma/lib": "0.1.7",
|
|
75
|
-
"@reforma/types": "1.
|
|
75
|
+
"@reforma/types": "1.6.0",
|
|
76
76
|
"@shikijs/transformers": "^4.0.2",
|
|
77
77
|
"@streamdown/cjk": "1.0.3",
|
|
78
78
|
"@streamdown/code": "1.1.1",
|