@protobase/ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/app/app.js
CHANGED
|
@@ -28,7 +28,7 @@ const Routes = ({ workspace, sidebarMode, assistant }) => {
|
|
|
28
28
|
const { state, signOut } = useAuth();
|
|
29
29
|
if (state.kind !== "signed-in") throw new Error("The shell is only rendered for a signed-in user");
|
|
30
30
|
const { user } = state;
|
|
31
|
-
const { path, basePath, navigate } = useRouter();
|
|
31
|
+
const { path, params, basePath, navigate } = useRouter();
|
|
32
32
|
const route = matchRoute(path);
|
|
33
33
|
const search = useGlobalSearch();
|
|
34
34
|
const recent = useNavRecent(meta, basePath, route);
|
|
@@ -60,6 +60,7 @@ const Routes = ({ workspace, sidebarMode, assistant }) => {
|
|
|
60
60
|
const assistantPanel = assistantUrl && assistantOpen && /* @__PURE__ */ jsx(AssistantPanel, {
|
|
61
61
|
url: assistantUrl,
|
|
62
62
|
client: assistant,
|
|
63
|
+
page: params.size > 0 ? `${path}?${params}` : path,
|
|
63
64
|
onClose: () => setAssistantOpen(false)
|
|
64
65
|
});
|
|
65
66
|
const breadcrumb = breadcrumbFor({
|
|
@@ -12,28 +12,31 @@ const AssistantButton = ({ open, onToggle }) => /* @__PURE__ */ jsxs(Button, {
|
|
|
12
12
|
onClick: onToggle,
|
|
13
13
|
children: [/* @__PURE__ */ jsx(Sparkles, { className: "size-3.5" }), "Assistant"]
|
|
14
14
|
});
|
|
15
|
-
const ConnectedDock = ({ client, onClose }) => {
|
|
15
|
+
const ConnectedDock = ({ client, page, onClose }) => {
|
|
16
16
|
const { state, offline, error, send, act } = useAssistant(client);
|
|
17
17
|
return /* @__PURE__ */ jsx(AssistantDock, {
|
|
18
18
|
state,
|
|
19
19
|
offline,
|
|
20
20
|
error,
|
|
21
|
-
onSend: send,
|
|
21
|
+
onSend: (text) => send(text, page),
|
|
22
22
|
onAction: act,
|
|
23
23
|
onClose
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
|
-
const OwnDock = ({ url,
|
|
26
|
+
const OwnDock = ({ url, ...props }) => /* @__PURE__ */ jsx(ConnectedDock, {
|
|
27
27
|
client: useAssistantClient(url),
|
|
28
|
-
|
|
28
|
+
...props
|
|
29
29
|
});
|
|
30
|
-
/**
|
|
31
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The dock for the backend `/meta` names, signed in as the user, sending each message with the `page` the user is on;
|
|
32
|
+
* `client` replaces it in stories and tests.
|
|
33
|
+
*/
|
|
34
|
+
const AssistantPanel = ({ url, client, ...props }) => client ? /* @__PURE__ */ jsx(ConnectedDock, {
|
|
32
35
|
client,
|
|
33
|
-
|
|
36
|
+
...props
|
|
34
37
|
}) : /* @__PURE__ */ jsx(OwnDock, {
|
|
35
38
|
url,
|
|
36
|
-
|
|
39
|
+
...props
|
|
37
40
|
});
|
|
38
41
|
//#endregion
|
|
39
42
|
export { AssistantButton, AssistantPanel };
|
|
@@ -5,7 +5,7 @@ export declare const useAssistant: (client: AssistantClient | undefined) => {
|
|
|
5
5
|
state: import("@protobase/schema").AssistantState;
|
|
6
6
|
offline: boolean;
|
|
7
7
|
error: string | undefined;
|
|
8
|
-
send: (text: string) => void | undefined;
|
|
8
|
+
send: (text: string, page?: string) => void | undefined;
|
|
9
9
|
act: (partId: string, actionId: string) => void | undefined;
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
@@ -19,7 +19,7 @@ const useAssistant = (client) => {
|
|
|
19
19
|
state,
|
|
20
20
|
offline,
|
|
21
21
|
error,
|
|
22
|
-
send: (text) => client && deliver(client.send(text)),
|
|
22
|
+
send: (text, page) => client && deliver(client.send(text, page)),
|
|
23
23
|
act: (partId, actionId) => client && deliver(client.act(partId, actionId))
|
|
24
24
|
};
|
|
25
25
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The Protobase admin app and the React hooks and components for custom UI.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"react-dom": "^19.3.0",
|
|
39
39
|
"recharts": "^3.10.1",
|
|
40
40
|
"tailwindcss": "^4.3.3",
|
|
41
|
-
"@protobase/client": "0.
|
|
42
|
-
"@protobase/layout": "0.
|
|
43
|
-
"@protobase/schema": "0.
|
|
41
|
+
"@protobase/client": "0.3.0",
|
|
42
|
+
"@protobase/layout": "0.3.0",
|
|
43
|
+
"@protobase/schema": "0.3.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "tsdown"
|