@refraction-ui/react 0.9.2 → 0.10.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.
@@ -0,0 +1,97 @@
1
+ import { ConversationState, ConversationAPI, ConversationConfig, MessageAttachment } from '../conversation/index.cjs';
2
+ export { ChatAuthor, ChatMessage, ChatRole, ChatTransport, Conversation, ConversationAPI, ConversationConfig, ConversationState, MessageStatus, SendContext, SendOptions, ThreadingMode, TransportChunk, createConversation, findMessage, getReplyCount, rootIdOf, selectMainTimeline, selectReplies, selectRoots, selectThreadMessages, selectTimelineFromState } from '../conversation/index.cjs';
3
+ import * as React from 'react';
4
+
5
+ interface UseConversationResult {
6
+ /** Live store snapshot (re-renders on change) */
7
+ state: ConversationState;
8
+ /** The underlying store, for advanced/imperative use */
9
+ api: ConversationAPI;
10
+ sendMessage: ConversationAPI['sendMessage'];
11
+ newConversation: ConversationAPI['newConversation'];
12
+ selectConversation: ConversationAPI['selectConversation'];
13
+ deleteConversation: ConversationAPI['deleteConversation'];
14
+ renameConversation: ConversationAPI['renameConversation'];
15
+ editMessage: ConversationAPI['editMessage'];
16
+ deleteMessage: ConversationAPI['deleteMessage'];
17
+ react: ConversationAPI['react'];
18
+ retryLast: ConversationAPI['retryLast'];
19
+ stop: ConversationAPI['stop'];
20
+ openThread: ConversationAPI['openThread'];
21
+ closeThread: ConversationAPI['closeThread'];
22
+ setThreadingMode: ConversationAPI['setThreadingMode'];
23
+ }
24
+ /**
25
+ * useConversation — binds the headless `createConversation` store to React via
26
+ * `useSyncExternalStore`. The store is created once; a changing `config.transport`
27
+ * is hot-swapped so consumers can wire the backend after mount.
28
+ */
29
+ declare function useConversation(config?: ConversationConfig): UseConversationResult;
30
+
31
+ /** A `/` command entry. */
32
+ interface SlashCommand {
33
+ id: string;
34
+ label: string;
35
+ description?: string;
36
+ icon?: string;
37
+ /** Text inserted into the composer when chosen. If omitted, `onSlashCommand` fires and the trigger is removed. */
38
+ insertText?: string;
39
+ }
40
+ /** An `@` mention candidate. */
41
+ interface Mention {
42
+ id: string;
43
+ label: string;
44
+ avatarUrl?: string;
45
+ }
46
+ interface ComposerProps {
47
+ placeholder?: string;
48
+ busy?: boolean;
49
+ /** `/` command palette entries */
50
+ slashCommands?: SlashCommand[];
51
+ /** `@` mention candidates — array or (async) resolver of a query */
52
+ mentions?: Mention[] | ((query: string) => Mention[] | Promise<Mention[]>);
53
+ /** Show the markdown formatting toolbar (default true) */
54
+ toolbar?: boolean;
55
+ /** Enable `:` emoji autocomplete (default true) */
56
+ emoji?: boolean;
57
+ /** Enable the attach button (default true) */
58
+ attachments?: boolean;
59
+ onSubmit: (content: string, attachments?: MessageAttachment[]) => void;
60
+ onStop?: () => void;
61
+ /** Called when a `/` command without `insertText` is chosen */
62
+ onSlashCommand?: (cmd: SlashCommand) => void;
63
+ autoFocus?: boolean;
64
+ }
65
+ /**
66
+ * Composer — rich message input: markdown formatting toolbar + Cmd/Ctrl shortcuts,
67
+ * and `/` command, `@` mention, and `:` emoji autocomplete menus.
68
+ */
69
+ declare function Composer({ placeholder, busy, slashCommands, mentions, toolbar, emoji, attachments, onSubmit, onStop, onSlashCommand, autoFocus, }: ComposerProps): React.DetailedReactHTMLElement<{
70
+ className: string;
71
+ }, HTMLElement>;
72
+
73
+ interface ChatProps {
74
+ conversation: UseConversationResult;
75
+ showConversationList?: boolean;
76
+ showModeToggle?: boolean;
77
+ placeholder?: string;
78
+ currentUserId?: string;
79
+ emptyState?: React.ReactNode;
80
+ className?: string;
81
+ slashCommands?: SlashCommand[];
82
+ mentions?: Mention[] | ((query: string) => Mention[] | Promise<Mention[]>);
83
+ onSlashCommand?: (cmd: SlashCommand) => void;
84
+ composerToolbar?: boolean;
85
+ }
86
+ /**
87
+ * Chat — batteries-included composite over `useConversation()`:
88
+ * conversation sidebar + main timeline + rich composer + thread side panel.
89
+ * Hybrid layout: assistant replies full-width, user messages in a right-aligned
90
+ * bubble. Markdown/code/gifs, reactions, edit/delete, streaming, and a composer
91
+ * with `/` commands, `@` mentions, `:` emoji, and a formatting toolbar.
92
+ */
93
+ declare function Chat({ conversation, showConversationList, showModeToggle, placeholder, currentUserId, emptyState, className, slashCommands, mentions, onSlashCommand, composerToolbar, }: ChatProps): React.DetailedReactHTMLElement<{
94
+ className: string;
95
+ }, HTMLElement>;
96
+
97
+ export { Chat, type ChatProps, Composer, type ComposerProps, type Mention, type SlashCommand, type UseConversationResult, useConversation };
@@ -0,0 +1,97 @@
1
+ import { ConversationState, ConversationAPI, ConversationConfig, MessageAttachment } from '../conversation/index.js';
2
+ export { ChatAuthor, ChatMessage, ChatRole, ChatTransport, Conversation, ConversationAPI, ConversationConfig, ConversationState, MessageStatus, SendContext, SendOptions, ThreadingMode, TransportChunk, createConversation, findMessage, getReplyCount, rootIdOf, selectMainTimeline, selectReplies, selectRoots, selectThreadMessages, selectTimelineFromState } from '../conversation/index.js';
3
+ import * as React from 'react';
4
+
5
+ interface UseConversationResult {
6
+ /** Live store snapshot (re-renders on change) */
7
+ state: ConversationState;
8
+ /** The underlying store, for advanced/imperative use */
9
+ api: ConversationAPI;
10
+ sendMessage: ConversationAPI['sendMessage'];
11
+ newConversation: ConversationAPI['newConversation'];
12
+ selectConversation: ConversationAPI['selectConversation'];
13
+ deleteConversation: ConversationAPI['deleteConversation'];
14
+ renameConversation: ConversationAPI['renameConversation'];
15
+ editMessage: ConversationAPI['editMessage'];
16
+ deleteMessage: ConversationAPI['deleteMessage'];
17
+ react: ConversationAPI['react'];
18
+ retryLast: ConversationAPI['retryLast'];
19
+ stop: ConversationAPI['stop'];
20
+ openThread: ConversationAPI['openThread'];
21
+ closeThread: ConversationAPI['closeThread'];
22
+ setThreadingMode: ConversationAPI['setThreadingMode'];
23
+ }
24
+ /**
25
+ * useConversation — binds the headless `createConversation` store to React via
26
+ * `useSyncExternalStore`. The store is created once; a changing `config.transport`
27
+ * is hot-swapped so consumers can wire the backend after mount.
28
+ */
29
+ declare function useConversation(config?: ConversationConfig): UseConversationResult;
30
+
31
+ /** A `/` command entry. */
32
+ interface SlashCommand {
33
+ id: string;
34
+ label: string;
35
+ description?: string;
36
+ icon?: string;
37
+ /** Text inserted into the composer when chosen. If omitted, `onSlashCommand` fires and the trigger is removed. */
38
+ insertText?: string;
39
+ }
40
+ /** An `@` mention candidate. */
41
+ interface Mention {
42
+ id: string;
43
+ label: string;
44
+ avatarUrl?: string;
45
+ }
46
+ interface ComposerProps {
47
+ placeholder?: string;
48
+ busy?: boolean;
49
+ /** `/` command palette entries */
50
+ slashCommands?: SlashCommand[];
51
+ /** `@` mention candidates — array or (async) resolver of a query */
52
+ mentions?: Mention[] | ((query: string) => Mention[] | Promise<Mention[]>);
53
+ /** Show the markdown formatting toolbar (default true) */
54
+ toolbar?: boolean;
55
+ /** Enable `:` emoji autocomplete (default true) */
56
+ emoji?: boolean;
57
+ /** Enable the attach button (default true) */
58
+ attachments?: boolean;
59
+ onSubmit: (content: string, attachments?: MessageAttachment[]) => void;
60
+ onStop?: () => void;
61
+ /** Called when a `/` command without `insertText` is chosen */
62
+ onSlashCommand?: (cmd: SlashCommand) => void;
63
+ autoFocus?: boolean;
64
+ }
65
+ /**
66
+ * Composer — rich message input: markdown formatting toolbar + Cmd/Ctrl shortcuts,
67
+ * and `/` command, `@` mention, and `:` emoji autocomplete menus.
68
+ */
69
+ declare function Composer({ placeholder, busy, slashCommands, mentions, toolbar, emoji, attachments, onSubmit, onStop, onSlashCommand, autoFocus, }: ComposerProps): React.DetailedReactHTMLElement<{
70
+ className: string;
71
+ }, HTMLElement>;
72
+
73
+ interface ChatProps {
74
+ conversation: UseConversationResult;
75
+ showConversationList?: boolean;
76
+ showModeToggle?: boolean;
77
+ placeholder?: string;
78
+ currentUserId?: string;
79
+ emptyState?: React.ReactNode;
80
+ className?: string;
81
+ slashCommands?: SlashCommand[];
82
+ mentions?: Mention[] | ((query: string) => Mention[] | Promise<Mention[]>);
83
+ onSlashCommand?: (cmd: SlashCommand) => void;
84
+ composerToolbar?: boolean;
85
+ }
86
+ /**
87
+ * Chat — batteries-included composite over `useConversation()`:
88
+ * conversation sidebar + main timeline + rich composer + thread side panel.
89
+ * Hybrid layout: assistant replies full-width, user messages in a right-aligned
90
+ * bubble. Markdown/code/gifs, reactions, edit/delete, streaming, and a composer
91
+ * with `/` commands, `@` mentions, `:` emoji, and a formatting toolbar.
92
+ */
93
+ declare function Chat({ conversation, showConversationList, showModeToggle, placeholder, currentUserId, emptyState, className, slashCommands, mentions, onSlashCommand, composerToolbar, }: ChatProps): React.DetailedReactHTMLElement<{
94
+ className: string;
95
+ }, HTMLElement>;
96
+
97
+ export { Chat, type ChatProps, Composer, type ComposerProps, type Mention, type SlashCommand, type UseConversationResult, useConversation };
@@ -0,0 +1,46 @@
1
+ import { CookieConsentState, CookieConsentAPI, CookieConsentConfig } from '../cookie-consent/index.cjs';
2
+ export { ConsentPreferences, CookieCategory, CookieConsentAPI, CookieConsentConfig, CookieConsentState, CookieStorage, DEFAULT_CATEGORIES, createCookieConsent } from '../cookie-consent/index.cjs';
3
+ import * as React from 'react';
4
+
5
+ interface UseCookieConsentResult {
6
+ state: CookieConsentState;
7
+ api: CookieConsentAPI;
8
+ acceptAll: CookieConsentAPI['acceptAll'];
9
+ rejectAll: CookieConsentAPI['rejectAll'];
10
+ savePreferences: CookieConsentAPI['savePreferences'];
11
+ setPreference: CookieConsentAPI['setPreference'];
12
+ reset: CookieConsentAPI['reset'];
13
+ openSettings: CookieConsentAPI['openSettings'];
14
+ close: CookieConsentAPI['close'];
15
+ }
16
+ /**
17
+ * useCookieConsent — binds the headless cookie-consent store to React via
18
+ * `useSyncExternalStore`, defaulting persistence to localStorage.
19
+ */
20
+ declare function useCookieConsent(config?: CookieConsentConfig): UseCookieConsentResult;
21
+
22
+ interface CookieConsentProps {
23
+ /** Result of `useCookieConsent()` */
24
+ consent: UseCookieConsentResult;
25
+ /** Banner position (default 'bottom') */
26
+ position?: 'bottom' | 'top';
27
+ title?: string;
28
+ description?: React.ReactNode;
29
+ /** Link to the full cookie/privacy policy */
30
+ policyUrl?: string;
31
+ policyLabel?: string;
32
+ className?: string;
33
+ }
34
+ /**
35
+ * CookieConsent — batteries-included consent banner over `useCookieConsent()`.
36
+ * Shows a prompt (Accept all / Reject all / Manage), with a settings view of
37
+ * per-category toggles. Renders nothing once the user has consented.
38
+ */
39
+ declare function CookieConsent({ consent, position, title, description, policyUrl, policyLabel, className, }: CookieConsentProps): React.DetailedReactHTMLElement<{
40
+ className: string;
41
+ role: "dialog";
42
+ 'aria-label': string;
43
+ 'aria-modal': false;
44
+ }, HTMLElement> | null;
45
+
46
+ export { CookieConsent, type CookieConsentProps, type UseCookieConsentResult, useCookieConsent };
@@ -0,0 +1,46 @@
1
+ import { CookieConsentState, CookieConsentAPI, CookieConsentConfig } from '../cookie-consent/index.js';
2
+ export { ConsentPreferences, CookieCategory, CookieConsentAPI, CookieConsentConfig, CookieConsentState, CookieStorage, DEFAULT_CATEGORIES, createCookieConsent } from '../cookie-consent/index.js';
3
+ import * as React from 'react';
4
+
5
+ interface UseCookieConsentResult {
6
+ state: CookieConsentState;
7
+ api: CookieConsentAPI;
8
+ acceptAll: CookieConsentAPI['acceptAll'];
9
+ rejectAll: CookieConsentAPI['rejectAll'];
10
+ savePreferences: CookieConsentAPI['savePreferences'];
11
+ setPreference: CookieConsentAPI['setPreference'];
12
+ reset: CookieConsentAPI['reset'];
13
+ openSettings: CookieConsentAPI['openSettings'];
14
+ close: CookieConsentAPI['close'];
15
+ }
16
+ /**
17
+ * useCookieConsent — binds the headless cookie-consent store to React via
18
+ * `useSyncExternalStore`, defaulting persistence to localStorage.
19
+ */
20
+ declare function useCookieConsent(config?: CookieConsentConfig): UseCookieConsentResult;
21
+
22
+ interface CookieConsentProps {
23
+ /** Result of `useCookieConsent()` */
24
+ consent: UseCookieConsentResult;
25
+ /** Banner position (default 'bottom') */
26
+ position?: 'bottom' | 'top';
27
+ title?: string;
28
+ description?: React.ReactNode;
29
+ /** Link to the full cookie/privacy policy */
30
+ policyUrl?: string;
31
+ policyLabel?: string;
32
+ className?: string;
33
+ }
34
+ /**
35
+ * CookieConsent — batteries-included consent banner over `useCookieConsent()`.
36
+ * Shows a prompt (Accept all / Reject all / Manage), with a settings view of
37
+ * per-category toggles. Renders nothing once the user has consented.
38
+ */
39
+ declare function CookieConsent({ consent, position, title, description, policyUrl, policyLabel, className, }: CookieConsentProps): React.DetailedReactHTMLElement<{
40
+ className: string;
41
+ role: "dialog";
42
+ 'aria-label': string;
43
+ 'aria-modal': false;
44
+ }, HTMLElement> | null;
45
+
46
+ export { CookieConsent, type CookieConsentProps, type UseCookieConsentResult, useCookieConsent };
package/dist/theme.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  var React2 = require('react');
package/dist/theme.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { devWarn } from './chunk-VZLV27H2.js';
2
3
  import * as React2 from 'react';
3
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@refraction-ui/react",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "description": "All Refraction UI React components in one package — headless, accessible, zero-dependency",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,7 @@
28
28
  "dist"
29
29
  ],
30
30
  "scripts": {
31
- "build": "tsup && cp src/styles.css dist/styles.css && node ./scripts/embed-internal-types.mjs",
31
+ "build": "tsup && cp src/styles.css dist/styles.css && node ./scripts/embed-internal-types.mjs && node ./scripts/ensure-use-client.mjs",
32
32
  "dev": "tsup --watch",
33
33
  "test": "vitest run --passWithNoTests",
34
34
  "test:watch": "vitest",
@@ -68,7 +68,9 @@
68
68
  "@refraction-ui/react-collapsible": "workspace:*",
69
69
  "@refraction-ui/react-combobox": "workspace:*",
70
70
  "@refraction-ui/react-command": "workspace:*",
71
+ "@refraction-ui/react-conversation": "workspace:*",
71
72
  "@refraction-ui/react-content-protection": "workspace:*",
73
+ "@refraction-ui/react-cookie-consent": "workspace:*",
72
74
  "@refraction-ui/react-data-table": "workspace:*",
73
75
  "@refraction-ui/react-date-picker": "workspace:*",
74
76
  "@refraction-ui/react-device-frame": "workspace:*",