@anvia/react-ui 1.3.0 → 1.3.2
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/attachment/index.d.ts +3 -21
- package/dist/attachment/index.js +3 -12
- package/dist/attachment-By2pged3.js +91 -0
- package/dist/attachment-By2pged3.js.map +1 -0
- package/dist/chat/index.d.ts +3 -152
- package/dist/chat/index.js +3 -25
- package/dist/chat-Dgz8hsVT.js +1210 -0
- package/dist/chat-Dgz8hsVT.js.map +1 -0
- package/dist/completion/index.d.ts +3 -29
- package/dist/completion/index.js +3 -16
- package/dist/completion-DDTKoZRJ.js +124 -0
- package/dist/completion-DDTKoZRJ.js.map +1 -0
- package/dist/connection-DeNq8wHS.js +203 -0
- package/dist/connection-DeNq8wHS.js.map +1 -0
- package/dist/contexts-B4ijG24z.js +212 -0
- package/dist/contexts-B4ijG24z.js.map +1 -0
- package/dist/elements-D4vmkkF8.js +19 -0
- package/dist/elements-D4vmkkF8.js.map +1 -0
- package/dist/graph-explorer/index.d.ts +54 -73
- package/dist/graph-explorer/index.d.ts.map +1 -0
- package/dist/graph-explorer/index.js +181 -248
- package/dist/graph-explorer/index.js.map +1 -1
- package/dist/human-input/index.d.ts +3 -78
- package/dist/human-input/index.js +3 -21
- package/dist/human-input-CsCbZomZ.js +314 -0
- package/dist/human-input-CsCbZomZ.js.map +1 -0
- package/dist/image/index.d.ts +3 -40
- package/dist/image/index.js +3 -12
- package/dist/image-aCWm6hFe.js +303 -0
- package/dist/image-aCWm6hFe.js.map +1 -0
- package/dist/index-B1Qs2Cjv.d.ts +145 -0
- package/dist/index-B1Qs2Cjv.d.ts.map +1 -0
- package/dist/index-BCBVcl0D.d.ts +277 -0
- package/dist/index-BCBVcl0D.d.ts.map +1 -0
- package/dist/index-CE22tsua.d.ts +20 -0
- package/dist/index-CE22tsua.d.ts.map +1 -0
- package/dist/index-CGqtpc6b.d.ts +25 -0
- package/dist/index-CGqtpc6b.d.ts.map +1 -0
- package/dist/index-DqdyM0Jm.d.ts +7 -0
- package/dist/index-DqdyM0Jm.d.ts.map +1 -0
- package/dist/index-Mw3ltwSG.d.ts +318 -0
- package/dist/index-Mw3ltwSG.d.ts.map +1 -0
- package/dist/index.d.ts +7 -40
- package/dist/index.js +34 -118
- package/dist/index.js.map +1 -1
- package/dist/message/index.d.ts +3 -105
- package/dist/message/index.js +3 -20
- package/dist/message-CElFEKgL.js +783 -0
- package/dist/message-CElFEKgL.js.map +1 -0
- package/dist/primitives-xfE7zfwJ.js +15 -0
- package/dist/primitives-xfE7zfwJ.js.map +1 -0
- package/dist/refs-Djj9rSvB.js +10 -0
- package/dist/refs-Djj9rSvB.js.map +1 -0
- package/dist/sandbox-desktop/index.d.ts +100 -104
- package/dist/sandbox-desktop/index.d.ts.map +1 -0
- package/dist/sandbox-desktop/index.js +344 -342
- package/dist/sandbox-desktop/index.js.map +1 -1
- package/dist/sandbox-terminal/index.d.ts +52 -56
- package/dist/sandbox-terminal/index.d.ts.map +1 -0
- package/dist/sandbox-terminal/index.js +217 -208
- package/dist/sandbox-terminal/index.js.map +1 -1
- package/dist/selection-toolbar/index.d.ts +3 -21
- package/dist/selection-toolbar/index.js +3 -13
- package/dist/selection-toolbar-CIkOoM-7.js +171 -0
- package/dist/selection-toolbar-CIkOoM-7.js.map +1 -0
- package/dist/shared-BSYElFU2.d.ts +2 -0
- package/dist/shared.d.ts +4 -14
- package/dist/shared.js +1 -43
- package/dist/stream/index.d.ts +2 -22
- package/dist/stream/index.js +1 -8
- package/dist/stream-CAO0x8_1.js +298 -0
- package/dist/stream-CAO0x8_1.js.map +1 -0
- package/dist/thread-list/index.d.ts +3 -47
- package/dist/thread-list/index.js +3 -18
- package/dist/thread-list-xJbGXFrE.js +228 -0
- package/dist/thread-list-xJbGXFrE.js.map +1 -0
- package/dist/ticket-CoJHBpdF.d.ts +32 -0
- package/dist/ticket-CoJHBpdF.d.ts.map +1 -0
- package/dist/url-CiYZkDks.js +52 -0
- package/dist/url-CiYZkDks.js.map +1 -0
- package/dist/value-BGGrx72L.js +13 -0
- package/dist/value-BGGrx72L.js.map +1 -0
- package/package.json +22 -22
- package/dist/attachment/index.js.map +0 -1
- package/dist/attachment-mbjsroli.d.ts +0 -9
- package/dist/chat/index.js.map +0 -1
- package/dist/chat-PSj1Fo4W.d.ts +0 -88
- package/dist/chunk-22EZJUPM.js +0 -120
- package/dist/chunk-22EZJUPM.js.map +0 -1
- package/dist/chunk-5FZKTDZR.js +0 -201
- package/dist/chunk-5FZKTDZR.js.map +0 -1
- package/dist/chunk-6XOJFLX4.js +0 -22
- package/dist/chunk-6XOJFLX4.js.map +0 -1
- package/dist/chunk-CKA4CE26.js +0 -25
- package/dist/chunk-CKA4CE26.js.map +0 -1
- package/dist/chunk-DLBNFBXQ.js +0 -425
- package/dist/chunk-DLBNFBXQ.js.map +0 -1
- package/dist/chunk-E73S3SOF.js +0 -404
- package/dist/chunk-E73S3SOF.js.map +0 -1
- package/dist/chunk-F6AKBUO3.js +0 -380
- package/dist/chunk-F6AKBUO3.js.map +0 -1
- package/dist/chunk-HGOPGZNQ.js +0 -195
- package/dist/chunk-HGOPGZNQ.js.map +0 -1
- package/dist/chunk-KHB5CHAU.js +0 -220
- package/dist/chunk-KHB5CHAU.js.map +0 -1
- package/dist/chunk-LHABOAOP.js +0 -316
- package/dist/chunk-LHABOAOP.js.map +0 -1
- package/dist/chunk-N5XQU36W.js +0 -410
- package/dist/chunk-N5XQU36W.js.map +0 -1
- package/dist/chunk-T3ZFZ3NP.js +0 -30
- package/dist/chunk-T3ZFZ3NP.js.map +0 -1
- package/dist/chunk-T4IYUEPH.js +0 -1612
- package/dist/chunk-T4IYUEPH.js.map +0 -1
- package/dist/chunk-W2AHKMRS.js +0 -1092
- package/dist/chunk-W2AHKMRS.js.map +0 -1
- package/dist/completion/index.js.map +0 -1
- package/dist/completion-input-DHlwrhxB.d.ts +0 -24
- package/dist/composer-6iCSIq6L.d.ts +0 -111
- package/dist/human-input/index.js.map +0 -1
- package/dist/human-input-CkLrZ8IC.d.ts +0 -27
- package/dist/image/index.js.map +0 -1
- package/dist/image-VZv6Ddsn.d.ts +0 -14
- package/dist/message/index.js.map +0 -1
- package/dist/message-CNRnZQwU.d.ts +0 -14
- package/dist/render-CRKWam2v.d.ts +0 -8
- package/dist/selection-toolbar/index.js.map +0 -1
- package/dist/selection-toolbar-Cwjbuv5S.d.ts +0 -14
- package/dist/shared.js.map +0 -1
- package/dist/stream/index.js.map +0 -1
- package/dist/thread-Bz6-1zaJ.d.ts +0 -12
- package/dist/thread-list/index.js.map +0 -1
- package/dist/thread-list-On8db4XL.d.ts +0 -34
- package/dist/ticket-pexI1zIa.d.ts +0 -33
|
@@ -1,261 +1,194 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
} from "../chunk-T3ZFZ3NP.js";
|
|
4
|
-
import {
|
|
5
|
-
GraphExplorerProvider,
|
|
6
|
-
InternalGraphExplorerNodeProvider,
|
|
7
|
-
useGraphExplorerContext,
|
|
8
|
-
useGraphExplorerNode,
|
|
9
|
-
useOptionalGraphExplorerNode
|
|
10
|
-
} from "../chunk-E73S3SOF.js";
|
|
11
|
-
|
|
12
|
-
// src/graph-explorer/parts.tsx
|
|
1
|
+
import { A as useGraphExplorerContext, M as useOptionalGraphExplorerNode, O as GraphExplorerProvider, j as useGraphExplorerNode, k as InternalGraphExplorerNodeProvider } from "../contexts-B4ijG24z.js";
|
|
2
|
+
import { t as renderPrimitive } from "../primitives-xfE7zfwJ.js";
|
|
13
3
|
import { forwardRef, useCallback } from "react";
|
|
14
|
-
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
15
5
|
// src/graph-explorer/helpers.ts
|
|
16
6
|
function graphExplorerNodeLabel(node) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
for (const key of [
|
|
8
|
+
"name",
|
|
9
|
+
"title",
|
|
10
|
+
"label"
|
|
11
|
+
]) {
|
|
12
|
+
const value = node.properties[key];
|
|
13
|
+
if (typeof value === "string" && value.trim().length > 0) return value;
|
|
14
|
+
}
|
|
15
|
+
if (node.key !== void 0) return node.key;
|
|
16
|
+
return `${node.type} ${node.id}`;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
// src/graph-explorer/parts.tsx
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
"data-state": state.selected ? "selected" : "unselected",
|
|
169
|
-
role: props.role ?? (inherited === void 0 ? void 0 : "listitem")
|
|
170
|
-
},
|
|
171
|
-
ref
|
|
172
|
-
) });
|
|
173
|
-
}
|
|
174
|
-
);
|
|
175
|
-
var GraphExplorerNodeTrigger = forwardRef(
|
|
176
|
-
function GraphExplorerNodeTrigger2({ onClick, ...props }, ref) {
|
|
177
|
-
const explorer = useGraphExplorerContext();
|
|
178
|
-
const state = useGraphExplorerNode();
|
|
179
|
-
const handleClick = useCallback(
|
|
180
|
-
(event) => {
|
|
181
|
-
onClick?.(event);
|
|
182
|
-
if (!event.defaultPrevented && !props.disabled) explorer.selectNode(state.node.id);
|
|
183
|
-
},
|
|
184
|
-
[explorer, onClick, props.disabled, state.node.id]
|
|
185
|
-
);
|
|
186
|
-
return renderPrimitive(
|
|
187
|
-
"button",
|
|
188
|
-
{
|
|
189
|
-
...props,
|
|
190
|
-
children: props.children ?? graphExplorerNodeLabel(state.node),
|
|
191
|
-
onClick: handleClick,
|
|
192
|
-
type: props.type ?? "button",
|
|
193
|
-
"aria-pressed": state.selected
|
|
194
|
-
},
|
|
195
|
-
ref
|
|
196
|
-
);
|
|
197
|
-
}
|
|
198
|
-
);
|
|
199
|
-
var GraphExplorerNodeExpand = forwardRef(
|
|
200
|
-
function GraphExplorerNodeExpand2({ onClick, options, ...props }, ref) {
|
|
201
|
-
const explorer = useGraphExplorerContext();
|
|
202
|
-
const state = useGraphExplorerNode();
|
|
203
|
-
const disabled = props.disabled ?? explorer.status === "loading";
|
|
204
|
-
const expand = useCallback(
|
|
205
|
-
() => explorer.expandNode(state.node.id, options),
|
|
206
|
-
[explorer, options, state.node.id]
|
|
207
|
-
);
|
|
208
|
-
const handleClick = useAsyncAction(onClick, disabled, expand);
|
|
209
|
-
return renderPrimitive(
|
|
210
|
-
"button",
|
|
211
|
-
{
|
|
212
|
-
...props,
|
|
213
|
-
children: props.children ?? "Expand",
|
|
214
|
-
disabled,
|
|
215
|
-
onClick: handleClick,
|
|
216
|
-
type: props.type ?? "button"
|
|
217
|
-
},
|
|
218
|
-
ref
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
);
|
|
19
|
+
const GraphExplorerRoot = forwardRef(function GraphExplorerRoot(props, ref) {
|
|
20
|
+
const explorer = useGraphExplorerContext();
|
|
21
|
+
const truncated = explorer.truncated.nodes || explorer.truncated.relationships;
|
|
22
|
+
return renderPrimitive("div", {
|
|
23
|
+
...props,
|
|
24
|
+
"aria-busy": explorer.status === "loading",
|
|
25
|
+
"data-role": "graph-explorer",
|
|
26
|
+
"data-state": explorer.status,
|
|
27
|
+
"data-truncated": truncated ? "true" : "false"
|
|
28
|
+
}, ref);
|
|
29
|
+
});
|
|
30
|
+
const GraphExplorerSearch = forwardRef(function GraphExplorerSearch({ onChange, ...props }, ref) {
|
|
31
|
+
const explorer = useGraphExplorerContext();
|
|
32
|
+
const handleChange = useCallback((event) => {
|
|
33
|
+
onChange?.(event);
|
|
34
|
+
if (!event.defaultPrevented) explorer.setQuery(event.currentTarget.value);
|
|
35
|
+
}, [explorer, onChange]);
|
|
36
|
+
return renderPrimitive("input", {
|
|
37
|
+
...props,
|
|
38
|
+
"aria-label": props["aria-label"] ?? "Search graph",
|
|
39
|
+
"data-state": explorer.query.length === 0 ? "empty" : "populated",
|
|
40
|
+
onChange: handleChange,
|
|
41
|
+
type: props.type ?? "search",
|
|
42
|
+
value: explorer.query
|
|
43
|
+
}, ref);
|
|
44
|
+
});
|
|
45
|
+
const GraphExplorerViewport = forwardRef(function GraphExplorerViewport(props, ref) {
|
|
46
|
+
return renderPrimitive("div", {
|
|
47
|
+
...props,
|
|
48
|
+
"data-role": "graph-explorer-viewport"
|
|
49
|
+
}, ref);
|
|
50
|
+
});
|
|
51
|
+
const GraphExplorerNodes = forwardRef(function GraphExplorerNodes({ children, keepMounted = false, ...props }, ref) {
|
|
52
|
+
const explorer = useGraphExplorerContext();
|
|
53
|
+
const empty = explorer.nodes.length === 0;
|
|
54
|
+
if (empty && !keepMounted) return null;
|
|
55
|
+
return renderPrimitive("div", {
|
|
56
|
+
...props,
|
|
57
|
+
children: explorer.nodes.map((node) => {
|
|
58
|
+
const state = {
|
|
59
|
+
node,
|
|
60
|
+
selected: node.id === explorer.selectedNodeId,
|
|
61
|
+
matched: explorer.matchedNodeIds.has(node.id)
|
|
62
|
+
};
|
|
63
|
+
return /* @__PURE__ */ jsx(InternalGraphExplorerNodeProvider, {
|
|
64
|
+
value: state,
|
|
65
|
+
children: typeof children === "function" ? children(node, state) : children ?? /* @__PURE__ */ jsx(GraphExplorerNodeRoot, { children: /* @__PURE__ */ jsx(GraphExplorerNodeTrigger, {}) })
|
|
66
|
+
}, node.id);
|
|
67
|
+
}),
|
|
68
|
+
"data-state": empty ? "empty" : "populated",
|
|
69
|
+
role: props.role ?? "list"
|
|
70
|
+
}, ref);
|
|
71
|
+
});
|
|
72
|
+
const GraphExplorerEmpty = forwardRef(function GraphExplorerEmpty(props, ref) {
|
|
73
|
+
const explorer = useGraphExplorerContext();
|
|
74
|
+
if (explorer.nodes.length > 0 || explorer.status === "loading") return null;
|
|
75
|
+
return renderPrimitive("div", {
|
|
76
|
+
...props,
|
|
77
|
+
children: props.children ?? "No graph nodes."
|
|
78
|
+
}, ref);
|
|
79
|
+
});
|
|
80
|
+
const GraphExplorerStatus = forwardRef(function GraphExplorerStatus({ children, ...props }, ref) {
|
|
81
|
+
const explorer = useGraphExplorerContext();
|
|
82
|
+
const content = typeof children === "function" ? children(explorer) : children ?? statusText(explorer);
|
|
83
|
+
return renderPrimitive("div", {
|
|
84
|
+
...props,
|
|
85
|
+
children: content,
|
|
86
|
+
"data-state": explorer.status,
|
|
87
|
+
role: props.role ?? "status"
|
|
88
|
+
}, ref);
|
|
89
|
+
});
|
|
90
|
+
const GraphExplorerRefresh = forwardRef(function GraphExplorerRefresh({ onClick, ...props }, ref) {
|
|
91
|
+
const explorer = useGraphExplorerContext();
|
|
92
|
+
const disabled = props.disabled ?? explorer.status === "loading";
|
|
93
|
+
const handleClick = useAsyncAction(onClick, disabled, explorer.refresh);
|
|
94
|
+
return renderPrimitive("button", {
|
|
95
|
+
...props,
|
|
96
|
+
children: props.children ?? "Refresh graph",
|
|
97
|
+
disabled,
|
|
98
|
+
onClick: handleClick,
|
|
99
|
+
type: props.type ?? "button"
|
|
100
|
+
}, ref);
|
|
101
|
+
});
|
|
102
|
+
const GraphExplorerNodeRoot = forwardRef(function GraphExplorerNodeRoot({ nodeId, ...props }, ref) {
|
|
103
|
+
const explorer = useGraphExplorerContext();
|
|
104
|
+
const inherited = useOptionalGraphExplorerNode();
|
|
105
|
+
const node = nodeId === void 0 ? inherited?.node : explorer.nodeById.get(nodeId);
|
|
106
|
+
if (node === void 0) throw new Error(nodeId === void 0 ? "GraphExplorerNodePrimitive.Root requires a nodeId outside GraphExplorerPrimitive.Nodes." : `Graph explorer node ${nodeId} is not loaded.`);
|
|
107
|
+
const state = {
|
|
108
|
+
node,
|
|
109
|
+
selected: node.id === explorer.selectedNodeId,
|
|
110
|
+
matched: explorer.matchedNodeIds.has(node.id)
|
|
111
|
+
};
|
|
112
|
+
return /* @__PURE__ */ jsx(InternalGraphExplorerNodeProvider, {
|
|
113
|
+
value: state,
|
|
114
|
+
children: renderPrimitive("div", {
|
|
115
|
+
...props,
|
|
116
|
+
"data-match": state.matched ? "matched" : "unmatched",
|
|
117
|
+
"data-node-id": state.node.id,
|
|
118
|
+
"data-node-type": state.node.type,
|
|
119
|
+
"data-state": state.selected ? "selected" : "unselected",
|
|
120
|
+
role: props.role ?? (inherited === void 0 ? void 0 : "listitem")
|
|
121
|
+
}, ref)
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
const GraphExplorerNodeTrigger = forwardRef(function GraphExplorerNodeTrigger({ onClick, ...props }, ref) {
|
|
125
|
+
const explorer = useGraphExplorerContext();
|
|
126
|
+
const state = useGraphExplorerNode();
|
|
127
|
+
const handleClick = useCallback((event) => {
|
|
128
|
+
onClick?.(event);
|
|
129
|
+
if (!event.defaultPrevented && !props.disabled) explorer.selectNode(state.node.id);
|
|
130
|
+
}, [
|
|
131
|
+
explorer,
|
|
132
|
+
onClick,
|
|
133
|
+
props.disabled,
|
|
134
|
+
state.node.id
|
|
135
|
+
]);
|
|
136
|
+
return renderPrimitive("button", {
|
|
137
|
+
...props,
|
|
138
|
+
children: props.children ?? graphExplorerNodeLabel(state.node),
|
|
139
|
+
onClick: handleClick,
|
|
140
|
+
type: props.type ?? "button",
|
|
141
|
+
"aria-pressed": state.selected
|
|
142
|
+
}, ref);
|
|
143
|
+
});
|
|
144
|
+
const GraphExplorerNodeExpand = forwardRef(function GraphExplorerNodeExpand({ onClick, options, ...props }, ref) {
|
|
145
|
+
const explorer = useGraphExplorerContext();
|
|
146
|
+
const state = useGraphExplorerNode();
|
|
147
|
+
const disabled = props.disabled ?? explorer.status === "loading";
|
|
148
|
+
const handleClick = useAsyncAction(onClick, disabled, useCallback(() => explorer.expandNode(state.node.id, options), [
|
|
149
|
+
explorer,
|
|
150
|
+
options,
|
|
151
|
+
state.node.id
|
|
152
|
+
]));
|
|
153
|
+
return renderPrimitive("button", {
|
|
154
|
+
...props,
|
|
155
|
+
children: props.children ?? "Expand",
|
|
156
|
+
disabled,
|
|
157
|
+
onClick: handleClick,
|
|
158
|
+
type: props.type ?? "button"
|
|
159
|
+
}, ref);
|
|
160
|
+
});
|
|
222
161
|
function useAsyncAction(onClick, disabled, action) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
162
|
+
return useCallback((event) => {
|
|
163
|
+
onClick?.(event);
|
|
164
|
+
if (event.defaultPrevented || disabled) return;
|
|
165
|
+
action().catch(() => void 0);
|
|
166
|
+
}, [
|
|
167
|
+
action,
|
|
168
|
+
disabled,
|
|
169
|
+
onClick
|
|
170
|
+
]);
|
|
231
171
|
}
|
|
232
172
|
function statusText(explorer) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
173
|
+
if (explorer.status === "loading") return "Loading graph.";
|
|
174
|
+
if (explorer.status === "error") return "Graph exploration failed.";
|
|
175
|
+
return `${explorer.nodes.length} nodes, ${explorer.relationships.length} relationships.`;
|
|
236
176
|
}
|
|
237
|
-
|
|
238
177
|
// src/graph-explorer/index.ts
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
178
|
+
const GraphExplorerPrimitive = {
|
|
179
|
+
Root: GraphExplorerRoot,
|
|
180
|
+
Viewport: GraphExplorerViewport,
|
|
181
|
+
Search: GraphExplorerSearch,
|
|
182
|
+
Nodes: GraphExplorerNodes,
|
|
183
|
+
Empty: GraphExplorerEmpty,
|
|
184
|
+
Status: GraphExplorerStatus,
|
|
185
|
+
Refresh: GraphExplorerRefresh
|
|
247
186
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
};
|
|
253
|
-
export {
|
|
254
|
-
GraphExplorerNodePrimitive,
|
|
255
|
-
GraphExplorerPrimitive,
|
|
256
|
-
GraphExplorerProvider,
|
|
257
|
-
graphExplorerNodeLabel,
|
|
258
|
-
useGraphExplorerContext,
|
|
259
|
-
useGraphExplorerNode
|
|
187
|
+
const GraphExplorerNodePrimitive = {
|
|
188
|
+
Root: GraphExplorerNodeRoot,
|
|
189
|
+
Trigger: GraphExplorerNodeTrigger,
|
|
190
|
+
Expand: GraphExplorerNodeExpand
|
|
260
191
|
};
|
|
192
|
+
export { GraphExplorerNodePrimitive, GraphExplorerPrimitive, GraphExplorerProvider, graphExplorerNodeLabel, useGraphExplorerContext, useGraphExplorerNode };
|
|
193
|
+
|
|
261
194
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/graph-explorer/parts.tsx","../../src/graph-explorer/helpers.ts","../../src/graph-explorer/index.ts"],"sourcesContent":["import type { GraphExploreNode } from \"@anvia/graph\";\nimport { forwardRef, type ChangeEvent, type MouseEvent, type ReactNode, useCallback } from \"react\";\n\nimport {\n InternalGraphExplorerNodeProvider,\n type GraphExplorerController,\n type GraphExplorerExpandNodeOptions,\n type GraphExplorerNodeContextValue,\n useGraphExplorerContext,\n useGraphExplorerNode,\n useOptionalGraphExplorerNode,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\nimport { graphExplorerNodeLabel } from \"./helpers\";\n\nexport const GraphExplorerRoot = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerRoot(props, ref) {\n const explorer = useGraphExplorerContext();\n const truncated = explorer.truncated.nodes || explorer.truncated.relationships;\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"aria-busy\": explorer.status === \"loading\",\n \"data-role\": \"graph-explorer\",\n \"data-state\": explorer.status,\n \"data-truncated\": truncated ? \"true\" : \"false\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerSearch = forwardRef<HTMLInputElement, PrimitiveProps<\"input\">>(\n function GraphExplorerSearch({ onChange, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n if (!event.defaultPrevented) explorer.setQuery(event.currentTarget.value);\n },\n [explorer, onChange],\n );\n return renderPrimitive(\n \"input\",\n {\n ...props,\n \"aria-label\": props[\"aria-label\"] ?? \"Search graph\",\n \"data-state\": explorer.query.length === 0 ? \"empty\" : \"populated\",\n onChange: handleChange,\n type: props.type ?? \"search\",\n value: explorer.query,\n } as PrimitiveProps<\"input\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerViewport = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerViewport(props, ref) {\n return renderPrimitive(\n \"div\",\n { ...props, \"data-role\": \"graph-explorer-viewport\" } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerNodesChildren =\n | ReactNode\n | ((node: GraphExploreNode, state: GraphExplorerNodeContextValue) => ReactNode);\n\ntype GraphExplorerNodesProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: GraphExplorerNodesChildren;\n keepMounted?: boolean;\n};\n\nexport const GraphExplorerNodes = forwardRef<HTMLDivElement, GraphExplorerNodesProps>(\n function GraphExplorerNodes({ children, keepMounted = false, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const empty = explorer.nodes.length === 0;\n if (empty && !keepMounted) return null;\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: explorer.nodes.map((node) => {\n const state: GraphExplorerNodeContextValue = {\n node,\n selected: node.id === explorer.selectedNodeId,\n matched: explorer.matchedNodeIds.has(node.id),\n };\n return (\n <InternalGraphExplorerNodeProvider key={node.id} value={state}>\n {typeof children === \"function\"\n ? children(node, state)\n : (children ?? (\n <GraphExplorerNodeRoot>\n <GraphExplorerNodeTrigger />\n </GraphExplorerNodeRoot>\n ))}\n </InternalGraphExplorerNodeProvider>\n );\n }),\n \"data-state\": empty ? \"empty\" : \"populated\",\n role: props.role ?? \"list\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerEmpty = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerEmpty(props, ref) {\n const explorer = useGraphExplorerContext();\n if (explorer.nodes.length > 0 || explorer.status === \"loading\") return null;\n return renderPrimitive(\n \"div\",\n { ...props, children: props.children ?? \"No graph nodes.\" } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerStatusChildren = ReactNode | ((explorer: GraphExplorerController) => ReactNode);\ntype GraphExplorerStatusProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: GraphExplorerStatusChildren;\n};\n\nexport const GraphExplorerStatus = forwardRef<HTMLDivElement, GraphExplorerStatusProps>(\n function GraphExplorerStatus({ children, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const content =\n typeof children === \"function\" ? children(explorer) : (children ?? statusText(explorer));\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: content,\n \"data-state\": explorer.status,\n role: props.role ?? \"status\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerRefresh = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function GraphExplorerRefresh({ onClick, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const disabled = props.disabled ?? explorer.status === \"loading\";\n const handleClick = useAsyncAction(onClick, disabled, explorer.refresh);\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Refresh graph\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport type GraphExplorerNodeRootProps = PrimitiveProps<\"div\"> & { nodeId?: string };\n\nexport const GraphExplorerNodeRoot = forwardRef<HTMLDivElement, GraphExplorerNodeRootProps>(\n function GraphExplorerNodeRoot({ nodeId, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const inherited = useOptionalGraphExplorerNode();\n const node = nodeId === undefined ? inherited?.node : explorer.nodeById.get(nodeId);\n if (node === undefined) {\n throw new Error(\n nodeId === undefined\n ? \"GraphExplorerNodePrimitive.Root requires a nodeId outside GraphExplorerPrimitive.Nodes.\"\n : `Graph explorer node ${nodeId} is not loaded.`,\n );\n }\n const state: GraphExplorerNodeContextValue = {\n node,\n selected: node.id === explorer.selectedNodeId,\n matched: explorer.matchedNodeIds.has(node.id),\n };\n return (\n <InternalGraphExplorerNodeProvider value={state}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-match\": state.matched ? \"matched\" : \"unmatched\",\n \"data-node-id\": state.node.id,\n \"data-node-type\": state.node.type,\n \"data-state\": state.selected ? \"selected\" : \"unselected\",\n role: props.role ?? (inherited === undefined ? undefined : \"listitem\"),\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalGraphExplorerNodeProvider>\n );\n },\n);\n\nexport const GraphExplorerNodeTrigger = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function GraphExplorerNodeTrigger({ onClick, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const state = useGraphExplorerNode();\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (!event.defaultPrevented && !props.disabled) explorer.selectNode(state.node.id);\n },\n [explorer, onClick, props.disabled, state.node.id],\n );\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? graphExplorerNodeLabel(state.node),\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"aria-pressed\": state.selected,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerNodeExpandOptions = Omit<GraphExplorerExpandNodeOptions, \"abortSignal\">;\ntype GraphExplorerNodeExpandProps = PrimitiveProps<\"button\"> & {\n options?: GraphExplorerNodeExpandOptions;\n};\n\nexport const GraphExplorerNodeExpand = forwardRef<HTMLButtonElement, GraphExplorerNodeExpandProps>(\n function GraphExplorerNodeExpand({ onClick, options, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const state = useGraphExplorerNode();\n const disabled = props.disabled ?? explorer.status === \"loading\";\n const expand = useCallback(\n () => explorer.expandNode(state.node.id, options),\n [explorer, options, state.node.id],\n );\n const handleClick = useAsyncAction(onClick, disabled, expand);\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Expand\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nfunction useAsyncAction(\n onClick: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined,\n disabled: boolean,\n action: () => Promise<unknown>,\n) {\n return useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) return;\n void action().catch(() => undefined);\n },\n [action, disabled, onClick],\n );\n}\n\nfunction statusText(explorer: GraphExplorerController): ReactNode {\n if (explorer.status === \"loading\") return \"Loading graph.\";\n if (explorer.status === \"error\") return \"Graph exploration failed.\";\n return `${explorer.nodes.length} nodes, ${explorer.relationships.length} relationships.`;\n}\n","import type { GraphExploreNode } from \"@anvia/graph\";\n\nexport function graphExplorerNodeLabel(node: GraphExploreNode): string {\n for (const key of [\"name\", \"title\", \"label\"] as const) {\n const value = node.properties[key];\n if (typeof value === \"string\" && value.trim().length > 0) return value;\n }\n if (node.key !== undefined) return node.key;\n return `${node.type} ${node.id}`;\n}\n","import {\n GraphExplorerEmpty,\n GraphExplorerNodes,\n GraphExplorerRefresh,\n GraphExplorerRoot,\n GraphExplorerSearch,\n GraphExplorerStatus,\n GraphExplorerViewport,\n GraphExplorerNodeExpand,\n GraphExplorerNodeRoot,\n GraphExplorerNodeTrigger,\n} from \"./parts\";\n\nexport const GraphExplorerPrimitive = {\n Root: GraphExplorerRoot,\n Viewport: GraphExplorerViewport,\n Search: GraphExplorerSearch,\n Nodes: GraphExplorerNodes,\n Empty: GraphExplorerEmpty,\n Status: GraphExplorerStatus,\n Refresh: GraphExplorerRefresh,\n} as const;\n\nexport const GraphExplorerNodePrimitive = {\n Root: GraphExplorerNodeRoot,\n Trigger: GraphExplorerNodeTrigger,\n Expand: GraphExplorerNodeExpand,\n} as const;\n\nexport type {\n GraphExplorerController,\n GraphExplorerExpandNodeOptions,\n GraphExplorerNodeContextValue,\n GraphExplorerProviderProps,\n GraphExplorerStatus,\n} from \"../contexts/graph-explorer\";\nexport {\n GraphExplorerProvider,\n useGraphExplorerContext,\n useGraphExplorerNode,\n} from \"../contexts/graph-explorer\";\nexport { graphExplorerNodeLabel } from \"./helpers\";\nexport type { GraphExplorerNodeRootProps } from \"./parts\";\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,YAA+D,mBAAmB;;;ACCpF,SAAS,uBAAuB,MAAgC;AACrE,aAAW,OAAO,CAAC,QAAQ,SAAS,OAAO,GAAY;AACrD,UAAM,QAAQ,KAAK,WAAW,GAAG;AACjC,QAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,EAAG,QAAO;AAAA,EACnE;AACA,MAAI,KAAK,QAAQ,OAAW,QAAO,KAAK;AACxC,SAAO,GAAG,KAAK,IAAI,IAAI,KAAK,EAAE;AAChC;;;ADyFsB;AAnFf,IAAM,oBAAoB;AAAA,EAC/B,SAASA,mBAAkB,OAAO,KAAK;AACrC,UAAM,WAAW,wBAAwB;AACzC,UAAM,YAAY,SAAS,UAAU,SAAS,SAAS,UAAU;AACjE,WAAO;AAAA,MACL;AAAA,MACA;AAAA,QACE,GAAG;AAAA,QACH,aAAa,SAAS,WAAW;AAAA,QACjC,aAAa;AAAA,QACb,cAAc,SAAS;AAAA,QACvB,kBAAkB,YAAY,SAAS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xC,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AACV;","names":["GraphExplorerRoot","GraphExplorerSearch","GraphExplorerViewport","GraphExplorerNodes","GraphExplorerEmpty","GraphExplorerStatus","GraphExplorerRefresh","GraphExplorerNodeRoot","GraphExplorerNodeTrigger","GraphExplorerNodeExpand"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/graph-explorer/helpers.ts","../../src/graph-explorer/parts.tsx","../../src/graph-explorer/index.ts"],"sourcesContent":["import type { GraphExploreNode } from \"@anvia/graph\";\n\nexport function graphExplorerNodeLabel(node: GraphExploreNode): string {\n for (const key of [\"name\", \"title\", \"label\"] as const) {\n const value = node.properties[key];\n if (typeof value === \"string\" && value.trim().length > 0) return value;\n }\n if (node.key !== undefined) return node.key;\n return `${node.type} ${node.id}`;\n}\n","import type { GraphExploreNode } from \"@anvia/graph\";\nimport { forwardRef, type ChangeEvent, type MouseEvent, type ReactNode, useCallback } from \"react\";\n\nimport {\n InternalGraphExplorerNodeProvider,\n type GraphExplorerController,\n type GraphExplorerExpandNodeOptions,\n type GraphExplorerNodeContextValue,\n useGraphExplorerContext,\n useGraphExplorerNode,\n useOptionalGraphExplorerNode,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\nimport { graphExplorerNodeLabel } from \"./helpers\";\n\nexport const GraphExplorerRoot = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerRoot(props, ref) {\n const explorer = useGraphExplorerContext();\n const truncated = explorer.truncated.nodes || explorer.truncated.relationships;\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"aria-busy\": explorer.status === \"loading\",\n \"data-role\": \"graph-explorer\",\n \"data-state\": explorer.status,\n \"data-truncated\": truncated ? \"true\" : \"false\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerSearch = forwardRef<HTMLInputElement, PrimitiveProps<\"input\">>(\n function GraphExplorerSearch({ onChange, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const handleChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n onChange?.(event);\n if (!event.defaultPrevented) explorer.setQuery(event.currentTarget.value);\n },\n [explorer, onChange],\n );\n return renderPrimitive(\n \"input\",\n {\n ...props,\n \"aria-label\": props[\"aria-label\"] ?? \"Search graph\",\n \"data-state\": explorer.query.length === 0 ? \"empty\" : \"populated\",\n onChange: handleChange,\n type: props.type ?? \"search\",\n value: explorer.query,\n } as PrimitiveProps<\"input\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerViewport = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerViewport(props, ref) {\n return renderPrimitive(\n \"div\",\n { ...props, \"data-role\": \"graph-explorer-viewport\" } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerNodesChildren =\n | ReactNode\n | ((node: GraphExploreNode, state: GraphExplorerNodeContextValue) => ReactNode);\n\ntype GraphExplorerNodesProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: GraphExplorerNodesChildren;\n keepMounted?: boolean;\n};\n\nexport const GraphExplorerNodes = forwardRef<HTMLDivElement, GraphExplorerNodesProps>(\n function GraphExplorerNodes({ children, keepMounted = false, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const empty = explorer.nodes.length === 0;\n if (empty && !keepMounted) return null;\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: explorer.nodes.map((node) => {\n const state: GraphExplorerNodeContextValue = {\n node,\n selected: node.id === explorer.selectedNodeId,\n matched: explorer.matchedNodeIds.has(node.id),\n };\n return (\n <InternalGraphExplorerNodeProvider key={node.id} value={state}>\n {typeof children === \"function\"\n ? children(node, state)\n : (children ?? (\n <GraphExplorerNodeRoot>\n <GraphExplorerNodeTrigger />\n </GraphExplorerNodeRoot>\n ))}\n </InternalGraphExplorerNodeProvider>\n );\n }),\n \"data-state\": empty ? \"empty\" : \"populated\",\n role: props.role ?? \"list\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerEmpty = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function GraphExplorerEmpty(props, ref) {\n const explorer = useGraphExplorerContext();\n if (explorer.nodes.length > 0 || explorer.status === \"loading\") return null;\n return renderPrimitive(\n \"div\",\n { ...props, children: props.children ?? \"No graph nodes.\" } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerStatusChildren = ReactNode | ((explorer: GraphExplorerController) => ReactNode);\ntype GraphExplorerStatusProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: GraphExplorerStatusChildren;\n};\n\nexport const GraphExplorerStatus = forwardRef<HTMLDivElement, GraphExplorerStatusProps>(\n function GraphExplorerStatus({ children, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const content =\n typeof children === \"function\" ? children(explorer) : (children ?? statusText(explorer));\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: content,\n \"data-state\": explorer.status,\n role: props.role ?? \"status\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nexport const GraphExplorerRefresh = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function GraphExplorerRefresh({ onClick, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const disabled = props.disabled ?? explorer.status === \"loading\";\n const handleClick = useAsyncAction(onClick, disabled, explorer.refresh);\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Refresh graph\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nexport type GraphExplorerNodeRootProps = PrimitiveProps<\"div\"> & { nodeId?: string };\n\nexport const GraphExplorerNodeRoot = forwardRef<HTMLDivElement, GraphExplorerNodeRootProps>(\n function GraphExplorerNodeRoot({ nodeId, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const inherited = useOptionalGraphExplorerNode();\n const node = nodeId === undefined ? inherited?.node : explorer.nodeById.get(nodeId);\n if (node === undefined) {\n throw new Error(\n nodeId === undefined\n ? \"GraphExplorerNodePrimitive.Root requires a nodeId outside GraphExplorerPrimitive.Nodes.\"\n : `Graph explorer node ${nodeId} is not loaded.`,\n );\n }\n const state: GraphExplorerNodeContextValue = {\n node,\n selected: node.id === explorer.selectedNodeId,\n matched: explorer.matchedNodeIds.has(node.id),\n };\n return (\n <InternalGraphExplorerNodeProvider value={state}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-match\": state.matched ? \"matched\" : \"unmatched\",\n \"data-node-id\": state.node.id,\n \"data-node-type\": state.node.type,\n \"data-state\": state.selected ? \"selected\" : \"unselected\",\n role: props.role ?? (inherited === undefined ? undefined : \"listitem\"),\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalGraphExplorerNodeProvider>\n );\n },\n);\n\nexport const GraphExplorerNodeTrigger = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function GraphExplorerNodeTrigger({ onClick, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const state = useGraphExplorerNode();\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (!event.defaultPrevented && !props.disabled) explorer.selectNode(state.node.id);\n },\n [explorer, onClick, props.disabled, state.node.id],\n );\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? graphExplorerNodeLabel(state.node),\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"aria-pressed\": state.selected,\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype GraphExplorerNodeExpandOptions = Omit<GraphExplorerExpandNodeOptions, \"abortSignal\">;\ntype GraphExplorerNodeExpandProps = PrimitiveProps<\"button\"> & {\n options?: GraphExplorerNodeExpandOptions;\n};\n\nexport const GraphExplorerNodeExpand = forwardRef<HTMLButtonElement, GraphExplorerNodeExpandProps>(\n function GraphExplorerNodeExpand({ onClick, options, ...props }, ref) {\n const explorer = useGraphExplorerContext();\n const state = useGraphExplorerNode();\n const disabled = props.disabled ?? explorer.status === \"loading\";\n const expand = useCallback(\n () => explorer.expandNode(state.node.id, options),\n [explorer, options, state.node.id],\n );\n const handleClick = useAsyncAction(onClick, disabled, expand);\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Expand\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nfunction useAsyncAction(\n onClick: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined,\n disabled: boolean,\n action: () => Promise<unknown>,\n) {\n return useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) return;\n void action().catch(() => undefined);\n },\n [action, disabled, onClick],\n );\n}\n\nfunction statusText(explorer: GraphExplorerController): ReactNode {\n if (explorer.status === \"loading\") return \"Loading graph.\";\n if (explorer.status === \"error\") return \"Graph exploration failed.\";\n return `${explorer.nodes.length} nodes, ${explorer.relationships.length} relationships.`;\n}\n","import {\n GraphExplorerEmpty,\n GraphExplorerNodes,\n GraphExplorerRefresh,\n GraphExplorerRoot,\n GraphExplorerSearch,\n GraphExplorerStatus,\n GraphExplorerViewport,\n GraphExplorerNodeExpand,\n GraphExplorerNodeRoot,\n GraphExplorerNodeTrigger,\n} from \"./parts\";\n\nexport const GraphExplorerPrimitive = {\n Root: GraphExplorerRoot,\n Viewport: GraphExplorerViewport,\n Search: GraphExplorerSearch,\n Nodes: GraphExplorerNodes,\n Empty: GraphExplorerEmpty,\n Status: GraphExplorerStatus,\n Refresh: GraphExplorerRefresh,\n} as const;\n\nexport const GraphExplorerNodePrimitive = {\n Root: GraphExplorerNodeRoot,\n Trigger: GraphExplorerNodeTrigger,\n Expand: GraphExplorerNodeExpand,\n} as const;\n\nexport type {\n GraphExplorerController,\n GraphExplorerExpandNodeOptions,\n GraphExplorerNodeContextValue,\n GraphExplorerProviderProps,\n GraphExplorerStatus,\n} from \"../contexts/graph-explorer\";\nexport {\n GraphExplorerProvider,\n useGraphExplorerContext,\n useGraphExplorerNode,\n} from \"../contexts/graph-explorer\";\nexport { graphExplorerNodeLabel } from \"./helpers\";\nexport type { GraphExplorerNodeRootProps } from \"./parts\";\n"],"mappings":";;;;;AAEA,SAAgB,uBAAuB,MAAgC;CACrE,KAAK,MAAM,OAAO;EAAC;EAAQ;EAAS;CAAO,GAAY;EACrD,MAAM,QAAQ,KAAK,WAAW;EAC9B,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,OAAO;CACnE;CACA,IAAI,KAAK,QAAQ,KAAA,GAAW,OAAO,KAAK;CACxC,OAAO,GAAG,KAAK,KAAK,GAAG,KAAK;AAC9B;;ACMA,MAAa,oBAAoB,WAC/B,SAAS,kBAAkB,OAAO,KAAK;CACrC,MAAM,WAAW,wBAAwB;CACzC,MAAM,YAAY,SAAS,UAAU,SAAS,SAAS,UAAU;CACjE,OAAO,gBACL,OACA;EACE,GAAG;EACH,aAAa,SAAS,WAAW;EACjC,aAAa;EACb,cAAc,SAAS;EACvB,kBAAkB,YAAY,SAAS;CACzC,GACA,GACF;AACF,CACF;AAEA,MAAa,sBAAsB,WACjC,SAAS,oBAAoB,EAAE,UAAU,GAAG,SAAS,KAAK;CACxD,MAAM,WAAW,wBAAwB;CACzC,MAAM,eAAe,aAClB,UAAyC;EACxC,WAAW,KAAK;EAChB,IAAI,CAAC,MAAM,kBAAkB,SAAS,SAAS,MAAM,cAAc,KAAK;CAC1E,GACA,CAAC,UAAU,QAAQ,CACrB;CACA,OAAO,gBACL,SACA;EACE,GAAG;EACH,cAAc,MAAM,iBAAiB;EACrC,cAAc,SAAS,MAAM,WAAW,IAAI,UAAU;EACtD,UAAU;EACV,MAAM,MAAM,QAAQ;EACpB,OAAO,SAAS;CAClB,GACA,GACF;AACF,CACF;AAEA,MAAa,wBAAwB,WACnC,SAAS,sBAAsB,OAAO,KAAK;CACzC,OAA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|
|
3
|
-
|
|
4
|
-
export { A as ApprovalContextValue, Q as QuestionContextValue, a as QuestionPromptContextValue, u as useApproval, b as useQuestion, c as useQuestionPrompt } from '../human-input-CkLrZ8IC.js';
|
|
5
|
-
import { c as useHumanInput } from '../chat-PSj1Fo4W.js';
|
|
6
|
-
export { u as useChatContext } from '../chat-PSj1Fo4W.js';
|
|
7
|
-
import { P as PrimitiveProps } from '../render-CRKWam2v.js';
|
|
8
|
-
import '@anvia/client';
|
|
9
|
-
import '@anvia/react';
|
|
10
|
-
|
|
11
|
-
type ApprovalChildren = ReactNode | ((approval: ApprovalInteraction) => ReactNode);
|
|
12
|
-
type HumanInputFilter = "pending" | "all";
|
|
13
|
-
|
|
14
|
-
type QuestionChildren = ReactNode | ((question: QuestionInteraction) => ReactNode);
|
|
15
|
-
|
|
16
|
-
declare const HumanInputPrimitive: {
|
|
17
|
-
readonly Panel: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
18
|
-
asChild?: boolean;
|
|
19
|
-
} & {
|
|
20
|
-
filter?: HumanInputFilter;
|
|
21
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
22
|
-
readonly Status: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
23
|
-
children?: react.ReactNode | ((state: ReturnType<typeof useHumanInput>) => react.ReactNode);
|
|
24
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
25
|
-
readonly Approvals: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
26
|
-
asChild?: boolean;
|
|
27
|
-
} & {
|
|
28
|
-
filter?: HumanInputFilter;
|
|
29
|
-
keepMounted?: boolean;
|
|
30
|
-
children?: ApprovalChildren;
|
|
31
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
32
|
-
readonly Approval: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
33
|
-
asChild?: boolean;
|
|
34
|
-
} & {
|
|
35
|
-
children?: ApprovalChildren;
|
|
36
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
37
|
-
readonly ApprovalReason: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "asChild"> & {
|
|
38
|
-
asChild?: boolean;
|
|
39
|
-
} & react.RefAttributes<HTMLTextAreaElement>>;
|
|
40
|
-
readonly Approve: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
41
|
-
asChild?: boolean;
|
|
42
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
|
43
|
-
readonly Reject: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
44
|
-
asChild?: boolean;
|
|
45
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
|
46
|
-
readonly Questions: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
47
|
-
asChild?: boolean;
|
|
48
|
-
} & {
|
|
49
|
-
filter?: HumanInputFilter;
|
|
50
|
-
keepMounted?: boolean;
|
|
51
|
-
children?: QuestionChildren;
|
|
52
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
53
|
-
readonly Question: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
54
|
-
asChild?: boolean;
|
|
55
|
-
} & {
|
|
56
|
-
children?: QuestionChildren;
|
|
57
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
58
|
-
readonly QuestionPrompt: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
59
|
-
asChild?: boolean;
|
|
60
|
-
} & {
|
|
61
|
-
promptId?: string;
|
|
62
|
-
} & react.RefAttributes<HTMLDivElement>>;
|
|
63
|
-
readonly QuestionChoice: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
64
|
-
asChild?: boolean;
|
|
65
|
-
} & {
|
|
66
|
-
value?: string;
|
|
67
|
-
answer?: string;
|
|
68
|
-
custom?: boolean;
|
|
69
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
|
70
|
-
readonly QuestionTextAnswer: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "asChild"> & {
|
|
71
|
-
asChild?: boolean;
|
|
72
|
-
} & react.RefAttributes<HTMLTextAreaElement>>;
|
|
73
|
-
readonly QuestionSubmit: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
74
|
-
asChild?: boolean;
|
|
75
|
-
} & react.RefAttributes<HTMLButtonElement>>;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
export { HumanInputPrimitive, useHumanInput };
|
|
1
|
+
import { C as QuestionPromptContextValue, E as useQuestionPrompt, T as useQuestion, at as useChatContext, ot as useHumanInput, w as useApproval, x as QuestionContextValue, y as ApprovalContextValue } from "../index-Mw3ltwSG.js";
|
|
2
|
+
import { p as HumanInputPrimitive } from "../index-BCBVcl0D.js";
|
|
3
|
+
export { type ApprovalContextValue, HumanInputPrimitive, type QuestionContextValue, type QuestionPromptContextValue, useApproval, useChatContext, useHumanInput, useQuestion, useQuestionPrompt };
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "../chunk-CKA4CE26.js";
|
|
5
|
-
import "../chunk-T3ZFZ3NP.js";
|
|
6
|
-
import {
|
|
7
|
-
useApproval,
|
|
8
|
-
useChatContext,
|
|
9
|
-
useHumanInput,
|
|
10
|
-
useQuestion,
|
|
11
|
-
useQuestionPrompt
|
|
12
|
-
} from "../chunk-E73S3SOF.js";
|
|
13
|
-
export {
|
|
14
|
-
HumanInputPrimitive,
|
|
15
|
-
useApproval,
|
|
16
|
-
useChatContext,
|
|
17
|
-
useHumanInput,
|
|
18
|
-
useQuestion,
|
|
19
|
-
useQuestionPrompt
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { C as useQuestionPrompt, I as useChatContext, L as useHumanInput, S as useQuestion, x as useApproval } from "../contexts-B4ijG24z.js";
|
|
2
|
+
import { t as HumanInputPrimitive } from "../human-input-CsCbZomZ.js";
|
|
3
|
+
export { HumanInputPrimitive, useApproval, useChatContext, useHumanInput, useQuestion, useQuestionPrompt };
|