@mordn/chat-widget 0.5.1 → 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/index.d.mts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +480 -272
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +464 -256
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -89,6 +89,68 @@ interface ChatWidgetConfig {
|
|
|
89
89
|
* overlays from the outside that fight the widget's own z-index.
|
|
90
90
|
*/
|
|
91
91
|
headerActions?: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Generic in-input autocomplete plugins. Each plugin is triggered by a
|
|
94
|
+
* single character (`@`, `/`, `#`, …); when the user types that
|
|
95
|
+
* character the widget opens a popover, calls `fetch(query)` as they
|
|
96
|
+
* keep typing, renders the returned items, and on selection splices
|
|
97
|
+
* `onSelect(item)` text into the input.
|
|
98
|
+
*
|
|
99
|
+
* The widget knows nothing about the consumer's domain — the host app
|
|
100
|
+
* provides both the data (via `fetch`) and the inserted text shape
|
|
101
|
+
* (via `onSelect`). Add as many plugins as you want; one per trigger
|
|
102
|
+
* character.
|
|
103
|
+
*/
|
|
104
|
+
inputPlugins?: InputPlugin[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Item returned by an InputPlugin's fetch function. Renders as one row
|
|
108
|
+
* in the popover.
|
|
109
|
+
*/
|
|
110
|
+
interface InputPluginItem {
|
|
111
|
+
/** Stable id, used as the React key + passed back to onSelect. */
|
|
112
|
+
id: string;
|
|
113
|
+
/** Primary line shown in the popover row. */
|
|
114
|
+
label: string;
|
|
115
|
+
/** Optional muted second line (e.g. "8 holdings · USD"). */
|
|
116
|
+
sublabel?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Definition of a single trigger-driven autocomplete in the chat input.
|
|
120
|
+
*/
|
|
121
|
+
interface InputPlugin {
|
|
122
|
+
/**
|
|
123
|
+
* Unique id used for keying / debugging. Not user-visible.
|
|
124
|
+
*/
|
|
125
|
+
id: string;
|
|
126
|
+
/**
|
|
127
|
+
* Single character that opens the popover. Must be exactly one
|
|
128
|
+
* character. Common picks: '@', '/', '#'.
|
|
129
|
+
*/
|
|
130
|
+
trigger: string;
|
|
131
|
+
/**
|
|
132
|
+
* Optional heading shown above results in the popover (e.g. "Mention",
|
|
133
|
+
* "Commands"). When omitted, no heading.
|
|
134
|
+
*/
|
|
135
|
+
heading?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Called with whatever the user has typed AFTER the trigger character
|
|
138
|
+
* (empty string immediately after triggering). Should return the
|
|
139
|
+
* matching items to render. The widget debounces calls; you don't
|
|
140
|
+
* need to.
|
|
141
|
+
*/
|
|
142
|
+
fetch: (query: string) => Promise<InputPluginItem[]> | InputPluginItem[];
|
|
143
|
+
/**
|
|
144
|
+
* Called when the user picks an item. Returns the string to splice
|
|
145
|
+
* into the input in place of the trigger + query span. Include any
|
|
146
|
+
* trailing space the input should have after insertion.
|
|
147
|
+
*/
|
|
148
|
+
onSelect: (item: InputPluginItem) => string;
|
|
149
|
+
/**
|
|
150
|
+
* Optional empty-state copy when fetch returns zero results.
|
|
151
|
+
* Defaults to "No results".
|
|
152
|
+
*/
|
|
153
|
+
emptyText?: string;
|
|
92
154
|
}
|
|
93
155
|
interface StarterPrompt {
|
|
94
156
|
/**
|
|
@@ -314,4 +376,4 @@ type StarterMessageItemProps = HTMLAttributes<HTMLButtonElement> & {
|
|
|
314
376
|
};
|
|
315
377
|
declare function StarterMessageItem({ className, prompt, onClick, ...props }: StarterMessageItemProps): react_jsx_runtime.JSX.Element;
|
|
316
378
|
|
|
317
|
-
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|
|
379
|
+
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, type InputPlugin, type InputPluginItem, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|
package/dist/index.d.ts
CHANGED
|
@@ -89,6 +89,68 @@ interface ChatWidgetConfig {
|
|
|
89
89
|
* overlays from the outside that fight the widget's own z-index.
|
|
90
90
|
*/
|
|
91
91
|
headerActions?: ReactNode;
|
|
92
|
+
/**
|
|
93
|
+
* Generic in-input autocomplete plugins. Each plugin is triggered by a
|
|
94
|
+
* single character (`@`, `/`, `#`, …); when the user types that
|
|
95
|
+
* character the widget opens a popover, calls `fetch(query)` as they
|
|
96
|
+
* keep typing, renders the returned items, and on selection splices
|
|
97
|
+
* `onSelect(item)` text into the input.
|
|
98
|
+
*
|
|
99
|
+
* The widget knows nothing about the consumer's domain — the host app
|
|
100
|
+
* provides both the data (via `fetch`) and the inserted text shape
|
|
101
|
+
* (via `onSelect`). Add as many plugins as you want; one per trigger
|
|
102
|
+
* character.
|
|
103
|
+
*/
|
|
104
|
+
inputPlugins?: InputPlugin[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Item returned by an InputPlugin's fetch function. Renders as one row
|
|
108
|
+
* in the popover.
|
|
109
|
+
*/
|
|
110
|
+
interface InputPluginItem {
|
|
111
|
+
/** Stable id, used as the React key + passed back to onSelect. */
|
|
112
|
+
id: string;
|
|
113
|
+
/** Primary line shown in the popover row. */
|
|
114
|
+
label: string;
|
|
115
|
+
/** Optional muted second line (e.g. "8 holdings · USD"). */
|
|
116
|
+
sublabel?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Definition of a single trigger-driven autocomplete in the chat input.
|
|
120
|
+
*/
|
|
121
|
+
interface InputPlugin {
|
|
122
|
+
/**
|
|
123
|
+
* Unique id used for keying / debugging. Not user-visible.
|
|
124
|
+
*/
|
|
125
|
+
id: string;
|
|
126
|
+
/**
|
|
127
|
+
* Single character that opens the popover. Must be exactly one
|
|
128
|
+
* character. Common picks: '@', '/', '#'.
|
|
129
|
+
*/
|
|
130
|
+
trigger: string;
|
|
131
|
+
/**
|
|
132
|
+
* Optional heading shown above results in the popover (e.g. "Mention",
|
|
133
|
+
* "Commands"). When omitted, no heading.
|
|
134
|
+
*/
|
|
135
|
+
heading?: string;
|
|
136
|
+
/**
|
|
137
|
+
* Called with whatever the user has typed AFTER the trigger character
|
|
138
|
+
* (empty string immediately after triggering). Should return the
|
|
139
|
+
* matching items to render. The widget debounces calls; you don't
|
|
140
|
+
* need to.
|
|
141
|
+
*/
|
|
142
|
+
fetch: (query: string) => Promise<InputPluginItem[]> | InputPluginItem[];
|
|
143
|
+
/**
|
|
144
|
+
* Called when the user picks an item. Returns the string to splice
|
|
145
|
+
* into the input in place of the trigger + query span. Include any
|
|
146
|
+
* trailing space the input should have after insertion.
|
|
147
|
+
*/
|
|
148
|
+
onSelect: (item: InputPluginItem) => string;
|
|
149
|
+
/**
|
|
150
|
+
* Optional empty-state copy when fetch returns zero results.
|
|
151
|
+
* Defaults to "No results".
|
|
152
|
+
*/
|
|
153
|
+
emptyText?: string;
|
|
92
154
|
}
|
|
93
155
|
interface StarterPrompt {
|
|
94
156
|
/**
|
|
@@ -314,4 +376,4 @@ type StarterMessageItemProps = HTMLAttributes<HTMLButtonElement> & {
|
|
|
314
376
|
};
|
|
315
377
|
declare function StarterMessageItem({ className, prompt, onClick, ...props }: StarterMessageItemProps): react_jsx_runtime.JSX.Element;
|
|
316
378
|
|
|
317
|
-
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|
|
379
|
+
export { Button, ChatStorageProvider, type ChatTheme, ChatWidget, type ChatWidgetConfig, type ChatWidgetProps, type ChatWidgetSize, type ConversationStarter, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, type DisplayConfig, type FeatureConfig, Input, type InputPlugin, type InputPluginItem, StarterMessageItem, StarterMessages, type StarterPrompt, type ThemeConfig, type ThemeMode, ChatWidget as default, fontOptions, useChatStorageKey, useChatTheme };
|