@fluxy-chat/ui-kit 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fluxychat contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # @fluxy-chat/ui-kit
2
+
3
+ Drop-in **polished chat widget** and **inbox panel** for FluxyChat — closes the "headless only" gap vs hosted SDKs.
4
+
5
+ Built on `@fluxy-chat/ui` + `@fluxy-chat/react`. Optional bridge to [`assistant-ui`](https://assistant-ui.com) via `useFluxyAssistantRuntime`.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @fluxy-chat/ui-kit @fluxy-chat/ui @fluxy-chat/react @fluxy-chat/sdk
11
+ ```
12
+
13
+ ## FluxyChatWidget (3 lines)
14
+
15
+ ```tsx
16
+ import { FluxyChatWidget } from "@fluxy-chat/ui-kit";
17
+
18
+ <FluxyChatWidget
19
+ roomId="general"
20
+ workerUrl={process.env.NEXT_PUBLIC_FLUXYCHAT_WORKER_URL!}
21
+ token={memberJwt}
22
+ theme="brand"
23
+ height={520}
24
+ />
25
+ ```
26
+
27
+ ## Inbox
28
+
29
+ ```tsx
30
+ import { FluxyInboxPanel } from "@fluxy-chat/ui-kit";
31
+
32
+ <FluxyInboxPanel workerUrl={url} token={jwt} onSelectItem={(item) => openRoom(item.roomId)} />
33
+ ```
34
+
35
+ ## assistant-ui (optional)
36
+
37
+ ```bash
38
+ pnpm add @assistant-ui/react
39
+ ```
40
+
41
+ ```tsx
42
+ import { useExternalStoreRuntime, Thread } from "@assistant-ui/react";
43
+ import { useFluxyAssistantRuntime } from "@fluxy-chat/ui-kit";
44
+
45
+ const { externalStoreProps } = useFluxyAssistantRuntime({ roomId, client });
46
+ const runtime = useExternalStoreRuntime(externalStoreProps);
47
+ return <Thread runtime={runtime} />;
48
+ ```
49
+
50
+ ## CLI
51
+
52
+ ```bash
53
+ npx create-fluxy-chat my-chat --minimal
54
+ ```
55
+
56
+ Generates Vite + `FluxyChatWidget` only (no platform modules).
@@ -0,0 +1,16 @@
1
+ import { FluxyChatClient } from "@fluxy-chat/sdk";
2
+ import type { FluxyThemeId } from "@fluxy-chat/ui";
3
+ export interface FluxyChatWidgetProps {
4
+ roomId: string;
5
+ /** Pre-built client — preferred when sharing with inbox */
6
+ client?: FluxyChatClient;
7
+ workerUrl?: string;
8
+ token?: string;
9
+ userId?: string;
10
+ theme?: FluxyThemeId;
11
+ className?: string;
12
+ height?: string | number;
13
+ title?: string;
14
+ }
15
+ /** Drop-in chat widget — polished UI out of the box. */
16
+ export declare function FluxyChatWidget({ roomId, client: clientProp, workerUrl, token, userId, theme, className, height, title, }: FluxyChatWidgetProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { FluxyChatClient } from "@fluxy-chat/sdk";
5
+ import { useChat } from "@fluxy-chat/react";
6
+ import { ChatWindow, applyFluxyTheme, fluxyThemeClassName, } from "@fluxy-chat/ui";
7
+ import { useEffect } from "react";
8
+ function WidgetInner({ roomId, title, client, }) {
9
+ const { messages, sendMessage, connectionState, typingUsers, online } = useChat({
10
+ roomId,
11
+ client,
12
+ markReadLatest: true,
13
+ });
14
+ return (_jsxs("div", { className: "flex h-full min-h-0 flex-col", children: [title && (_jsxs("header", { className: "border-b border-border px-4 py-2 text-sm font-semibold", children: [title, _jsx("span", { className: "ml-2 font-normal text-muted-foreground", children: connectionState.status })] })), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(ChatWindow, { messages: messages, online: online, typingUsers: typingUsers, onSend: (text) => sendMessage(text) }) })] }));
15
+ }
16
+ /** Drop-in chat widget — polished UI out of the box. */
17
+ export function FluxyChatWidget({ roomId, client: clientProp, workerUrl, token, userId = "user-1", theme = "default", className, height = 480, title, }) {
18
+ const client = useMemo(() => {
19
+ if (clientProp)
20
+ return clientProp;
21
+ if (!workerUrl?.trim() || !token?.trim())
22
+ return null;
23
+ return new FluxyChatClient({
24
+ baseUrl: workerUrl.trim(),
25
+ userId,
26
+ token: token.trim(),
27
+ });
28
+ }, [clientProp, workerUrl, token, userId]);
29
+ useEffect(() => {
30
+ applyFluxyTheme(theme);
31
+ }, [theme]);
32
+ if (!client) {
33
+ return (_jsx("div", { className: className, style: { height, padding: 16, border: "1px solid #e4e4e7", borderRadius: 12 }, children: _jsxs("p", { style: { margin: 0, fontSize: 14 }, children: ["Set ", _jsx("code", { children: "workerUrl" }), " and ", _jsx("code", { children: "token" }), ", or pass a ", _jsx("code", { children: "client" }), "."] }) }));
34
+ }
35
+ const h = typeof height === "number" ? `${height}px` : height;
36
+ return (_jsx("div", { className: [fluxyThemeClassName(theme), className].filter(Boolean).join(" "), style: { height: h, display: "flex", flexDirection: "column", overflow: "hidden", borderRadius: 12, border: "1px solid #e4e4e7" }, children: _jsx(WidgetInner, { roomId: roomId, title: title ?? roomId, client: client }) }));
37
+ }
@@ -0,0 +1,13 @@
1
+ import { FluxyChatClient } from "@fluxy-chat/sdk";
2
+ import type { FluxyInboxItem } from "@fluxy-chat/react";
3
+ export interface FluxyInboxPanelProps {
4
+ client?: FluxyChatClient;
5
+ workerUrl?: string;
6
+ token?: string;
7
+ userId?: string;
8
+ onSelectItem?: (item: FluxyInboxItem) => void;
9
+ className?: string;
10
+ height?: string | number;
11
+ }
12
+ /** Unified inbox panel with unseen badge and mark-read. */
13
+ export declare function FluxyInboxPanel({ client: clientProp, workerUrl, token, userId, onSelectItem, className, height, }: FluxyInboxPanelProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useMemo } from "react";
4
+ import { FluxyChatClient } from "@fluxy-chat/sdk";
5
+ import { useInbox } from "@fluxy-chat/react";
6
+ function InboxList({ onSelectItem, client, }) {
7
+ const { items, unseen } = useInbox({
8
+ client,
9
+ onItem: (item) => onSelectItem?.(item),
10
+ });
11
+ return (_jsxs("div", { className: "flex h-full flex-col", children: [_jsxs("header", { className: "flex items-center justify-between border-b px-4 py-2 text-sm font-semibold", children: [_jsx("span", { children: "Inbox" }), unseen > 0 && (_jsx("span", { className: "rounded-full bg-orange-500 px-2 py-0.5 text-xs text-white", children: unseen }))] }), _jsxs("ul", { className: "flex-1 overflow-y-auto p-2", children: [items.length === 0 && (_jsx("li", { className: "p-4 text-center text-sm text-muted-foreground", children: "No items yet" })), items.map((item) => (_jsx("li", { children: _jsxs("button", { type: "button", className: "mb-1 w-full rounded-lg border border-transparent px-3 py-2 text-left text-sm hover:bg-muted", onClick: () => onSelectItem?.(item), children: [_jsx("div", { className: "font-medium", children: item.roomName ?? item.kind }), _jsx("div", { className: "text-xs text-muted-foreground", children: item.roomId })] }) }, item.id)))] })] }));
12
+ }
13
+ /** Unified inbox panel with unseen badge and mark-read. */
14
+ export function FluxyInboxPanel({ client: clientProp, workerUrl, token, userId = "user-1", onSelectItem, className, height = 360, }) {
15
+ const client = useMemo(() => {
16
+ if (clientProp)
17
+ return clientProp;
18
+ if (!workerUrl?.trim() || !token?.trim())
19
+ return null;
20
+ return new FluxyChatClient({
21
+ baseUrl: workerUrl.trim(),
22
+ userId,
23
+ token: token.trim(),
24
+ });
25
+ }, [clientProp, workerUrl, token, userId]);
26
+ if (!client)
27
+ return null;
28
+ const h = typeof height === "number" ? `${height}px` : height;
29
+ return (_jsx("div", { className: className, style: { height: h, borderRadius: 12, border: "1px solid #e4e4e7", overflow: "hidden" }, children: _jsx(InboxList, { onSelectItem: onSelectItem, client: client }) }));
30
+ }
@@ -0,0 +1,6 @@
1
+ export { FluxyChatWidget } from "./fluxy-chat-widget";
2
+ export type { FluxyChatWidgetProps } from "./fluxy-chat-widget";
3
+ export { FluxyInboxPanel } from "./fluxy-inbox-panel";
4
+ export type { FluxyInboxPanelProps } from "./fluxy-inbox-panel";
5
+ export { useFluxyAssistantRuntime } from "./use-fluxy-assistant-runtime";
6
+ export type { UseFluxyAssistantRuntimeOptions, FluxyAssistantMessage, } from "./use-fluxy-assistant-runtime";
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { FluxyChatWidget } from "./fluxy-chat-widget";
2
+ export { FluxyInboxPanel } from "./fluxy-inbox-panel";
3
+ export { useFluxyAssistantRuntime } from "./use-fluxy-assistant-runtime";
@@ -0,0 +1,39 @@
1
+ import type { FluxyChatClient } from "@fluxy-chat/sdk";
2
+ export interface UseFluxyAssistantRuntimeOptions {
3
+ roomId: string;
4
+ client: FluxyChatClient;
5
+ }
6
+ /** Message shape for assistant-ui ExternalStoreRuntime (minimal subset). */
7
+ export interface FluxyAssistantMessage {
8
+ id: string;
9
+ role: "user" | "assistant";
10
+ content: {
11
+ type: "text";
12
+ text: string;
13
+ }[];
14
+ }
15
+ /**
16
+ * Hook that exposes Fluxy messages in assistant-ui-compatible shape.
17
+ * Wire with `useExternalStoreRuntime` from `@assistant-ui/react` when installed.
18
+ */
19
+ export declare function useFluxyAssistantRuntime({ roomId, client }: UseFluxyAssistantRuntimeOptions): {
20
+ messages: FluxyAssistantMessage[];
21
+ isRunning: boolean;
22
+ onNew: (message: {
23
+ content: {
24
+ type: string;
25
+ text?: string;
26
+ }[];
27
+ }) => Promise<void>;
28
+ /** Pass to useExternalStoreRuntime({ messages, isRunning, onNew, ... }) */
29
+ externalStoreProps: {
30
+ messages: FluxyAssistantMessage[];
31
+ isRunning: boolean;
32
+ onNew: (message: {
33
+ content: {
34
+ type: string;
35
+ text?: string;
36
+ }[];
37
+ }) => Promise<void>;
38
+ };
39
+ };
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ /**
3
+ * Optional assistant-ui bridge — install `@assistant-ui/react` to use.
4
+ * Maps FluxyChat WS timeline → assistant-ui ExternalStoreRuntime.
5
+ */
6
+ import { useCallback, useEffect, useMemo, useState } from "react";
7
+ import { useChat } from "@fluxy-chat/react";
8
+ function toAssistantMessage(m) {
9
+ const role = m.userId?.startsWith("agent") || m.userId === "assistant" ? "assistant" : "user";
10
+ return {
11
+ id: String(m.id),
12
+ role,
13
+ content: [{ type: "text", text: m.content ?? "" }],
14
+ };
15
+ }
16
+ /**
17
+ * Hook that exposes Fluxy messages in assistant-ui-compatible shape.
18
+ * Wire with `useExternalStoreRuntime` from `@assistant-ui/react` when installed.
19
+ */
20
+ export function useFluxyAssistantRuntime({ roomId, client }) {
21
+ const { messages, sendMessage, connectionState, agentTyping } = useChat({
22
+ roomId,
23
+ client,
24
+ });
25
+ const assistantMessages = useMemo(() => messages.map(toAssistantMessage), [messages]);
26
+ const [isRunning, setIsRunning] = useState(false);
27
+ useEffect(() => {
28
+ setIsRunning(agentTyping || connectionState.status === "connecting");
29
+ }, [agentTyping, connectionState.status]);
30
+ const onNew = useCallback(async (message) => {
31
+ const text = message.content
32
+ .filter((p) => p.type === "text")
33
+ .map((p) => p.text ?? "")
34
+ .join("\n")
35
+ .trim();
36
+ if (!text)
37
+ return;
38
+ await sendMessage(text);
39
+ }, [sendMessage]);
40
+ return {
41
+ messages: assistantMessages,
42
+ isRunning,
43
+ onNew,
44
+ /** Pass to useExternalStoreRuntime({ messages, isRunning, onNew, ... }) */
45
+ externalStoreProps: {
46
+ messages: assistantMessages,
47
+ isRunning,
48
+ onNew,
49
+ },
50
+ };
51
+ }
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@fluxy-chat/ui-kit",
3
+ "version": "0.1.0",
4
+ "description": "Polished drop-in FluxyChat widget and inbox — built on @fluxy-chat/ui with optional assistant-ui runtime",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "peerDependencies": {
21
+ "react": ">=18",
22
+ "@fluxy-chat/sdk": "^0.6.0",
23
+ "@fluxy-chat/react": "^0.1.1",
24
+ "@fluxy-chat/ui": "^0.1.2",
25
+ "@assistant-ui/react": ">=0.10.0"
26
+ },
27
+ "peerDependenciesMeta": {
28
+ "@assistant-ui/react": {
29
+ "optional": true
30
+ }
31
+ },
32
+ "dependencies": {
33
+ "@fluxy-chat/sdk": "0.6.0",
34
+ "@fluxy-chat/react": "0.1.1",
35
+ "@fluxy-chat/ui": "0.1.2"
36
+ },
37
+ "devDependencies": {
38
+ "@types/react": "^19.2.14",
39
+ "react": "^19.2.0",
40
+ "typescript": "^5"
41
+ },
42
+ "publishConfig": {
43
+ "access": "public"
44
+ },
45
+ "scripts": {
46
+ "build": "pnpm exec tsc -p tsconfig.json",
47
+ "dev": "pnpm exec tsc -w -p tsconfig.json"
48
+ }
49
+ }