@intentai/react 2.1.1 → 2.2.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 CHANGED
@@ -31,6 +31,149 @@ interface FeedbackData {
31
31
  }
32
32
  declare const PremiumVoiceWidget: React.FC<WidgetConfig>;
33
33
 
34
+ interface IntentAIProviderConfig {
35
+ /** Your Intent AI API key (required) */
36
+ apiKey: string;
37
+ /** API URL (defaults to production) */
38
+ apiUrl?: string;
39
+ /** User information for identifying feedback */
40
+ user?: IntentAIUser$1;
41
+ /** Additional metadata to attach to all feedback */
42
+ metadata?: Record<string, unknown>;
43
+ }
44
+ interface IntentAIUser$1 {
45
+ id?: string;
46
+ email?: string;
47
+ name?: string;
48
+ [key: string]: unknown;
49
+ }
50
+ interface IntentAIContextValue {
51
+ /** Identify the current user */
52
+ identify: (user: IntentAIUser$1) => void;
53
+ /** Set metadata to attach to feedback */
54
+ setMetadata: (metadata: Record<string, unknown>) => void;
55
+ /** Clear the current user */
56
+ clearUser: () => void;
57
+ /** Whether the provider is configured */
58
+ isConfigured: boolean;
59
+ }
60
+ /**
61
+ * Hook to access Intent AI context for user identification and metadata
62
+ */
63
+ declare function useIntentAI(): IntentAIContextValue;
64
+ interface IntentAIProviderProps extends IntentAIProviderConfig {
65
+ /** Widget configuration options */
66
+ widgetConfig?: Omit<WidgetConfig, 'onSubmit'>;
67
+ /** Children components */
68
+ children?: React.ReactNode;
69
+ /** Disable the widget (only provide context) */
70
+ disableWidget?: boolean;
71
+ /** Callback when feedback is submitted successfully */
72
+ onFeedbackSubmitted?: () => void;
73
+ /** Callback when there's an error */
74
+ onError?: (error: Error) => void;
75
+ }
76
+ /**
77
+ * Intent AI Provider - Wraps your app with feedback collection capabilities
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * import { IntentAIProvider } from '@intentai/react';
82
+ *
83
+ * function App() {
84
+ * return (
85
+ * <IntentAIProvider
86
+ * apiKey="your-api-key"
87
+ * user={{ id: 'user-123', email: 'user@example.com' }}
88
+ * >
89
+ * <YourApp />
90
+ * </IntentAIProvider>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
95
+ declare function IntentAIProvider({ apiKey, apiUrl, user: initialUser, metadata: initialMetadata, widgetConfig, children, disableWidget, onFeedbackSubmitted, onError, }: IntentAIProviderProps): React.ReactElement;
96
+ /**
97
+ * Hook to identify users - convenience wrapper around useIntentAI
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * function UserProfile({ user }) {
102
+ * const identify = useIdentify();
103
+ *
104
+ * useEffect(() => {
105
+ * identify({ id: user.id, email: user.email, name: user.name });
106
+ * }, [user]);
107
+ *
108
+ * return <div>...</div>;
109
+ * }
110
+ * ```
111
+ */
112
+ declare function useIdentify(): (user: IntentAIUser$1) => void;
113
+ /**
114
+ * Hook to set metadata - convenience wrapper around useIntentAI
115
+ *
116
+ * @example
117
+ * ```tsx
118
+ * function Dashboard({ plan }) {
119
+ * const setMetadata = useSetMetadata();
120
+ *
121
+ * useEffect(() => {
122
+ * setMetadata({ plan, feature: 'dashboard' });
123
+ * }, [plan]);
124
+ *
125
+ * return <div>...</div>;
126
+ * }
127
+ * ```
128
+ */
129
+ declare function useSetMetadata(): (metadata: Record<string, unknown>) => void;
130
+
131
+ interface FeedbackButtonProps {
132
+ /** Button variant style */
133
+ variant?: 'primary' | 'secondary' | 'ghost' | 'minimal';
134
+ /** Button size */
135
+ size?: 'sm' | 'md' | 'lg';
136
+ /** Show icon */
137
+ showIcon?: boolean;
138
+ /** Custom icon (React element) */
139
+ icon?: React.ReactNode;
140
+ /** Button label */
141
+ label?: string;
142
+ /** Additional class name */
143
+ className?: string;
144
+ /** Custom styles */
145
+ style?: React.CSSProperties;
146
+ /** Primary color */
147
+ primaryColor?: string;
148
+ /** Click handler - if provided, will be called instead of opening widget */
149
+ onClick?: () => void;
150
+ /** Disabled state */
151
+ disabled?: boolean;
152
+ }
153
+ /**
154
+ * Customizable feedback button that can trigger the widget or custom actions
155
+ *
156
+ * @example
157
+ * ```tsx
158
+ * // Basic usage - triggers widget
159
+ * <FeedbackButton />
160
+ *
161
+ * // Custom label and style
162
+ * <FeedbackButton
163
+ * label="Give Feedback"
164
+ * variant="secondary"
165
+ * size="lg"
166
+ * />
167
+ *
168
+ * // With custom click handler
169
+ * <FeedbackButton
170
+ * label="Report Issue"
171
+ * onClick={() => console.log('clicked')}
172
+ * />
173
+ * ```
174
+ */
175
+ declare function FeedbackButton({ variant, size, showIcon, icon, label, className, style, primaryColor, onClick, disabled, }: FeedbackButtonProps): React.ReactElement;
176
+
34
177
  interface IntentAIUser {
35
178
  id?: string;
36
179
  email?: string;
@@ -102,29 +245,30 @@ declare global {
102
245
  */
103
246
  declare function IntentAIWidget({ apiKey, apiUrl, widgetUrl, position, theme, primaryColor, allowVoice, allowText, allowScreenshot, customMetadata, user, onOpen: _onOpen, onClose: _onClose, onFeedbackSubmitted: _onFeedbackSubmitted, onError, }: IntentAIProps): null;
104
247
  /**
105
- * Hook to control the Intent AI widget programmatically
248
+ * Hook to control the script-tag widget programmatically
249
+ * @deprecated Use useIntentAI from IntentAIProvider instead for React apps
106
250
  *
107
251
  * @example
108
252
  * ```tsx
109
- * import { IntentAIWidget, useIntentAI } from '@intent-ai/react';
253
+ * import { IntentAIWidget, useWidgetControls } from '@intentai/react';
110
254
  *
111
255
  * function App() {
112
- * const { open, close, identify } = useIntentAI();
256
+ * const { open, close, identify } = useWidgetControls();
113
257
  *
114
258
  * return (
115
259
  * <>
116
- * <IntentAIWidget apiKey="your-api-key" />
260
+ * <IntentAIWidget apiKey="your-api-key" widgetUrl="..." apiUrl="..." />
117
261
  * <button onClick={open}>Open Feedback</button>
118
262
  * </>
119
263
  * );
120
264
  * }
121
265
  * ```
122
266
  */
123
- declare function useIntentAI(): {
267
+ declare function useWidgetControls(): {
124
268
  open: () => void;
125
269
  close: () => void;
126
270
  identify: (user: IntentAIUser) => void;
127
271
  setMetadata: (metadata: Record<string, any>) => void;
128
272
  };
129
273
 
130
- export { type IntentAIConfig, type IntentAIProps, type IntentAIUser, IntentAIWidget, PremiumVoiceWidget, type WidgetConfig as PremiumWidgetConfig, IntentAIWidget as default, useIntentAI };
274
+ export { FeedbackButton, type FeedbackButtonProps, type IntentAIConfig, type IntentAIContextValue, type IntentAIProps, IntentAIProvider, type IntentAIProviderConfig, type IntentAIProviderProps, type IntentAIUser, IntentAIWidget, PremiumVoiceWidget, type WidgetConfig as PremiumWidgetConfig, IntentAIWidget as default, useIdentify, useIntentAI, useSetMetadata, useWidgetControls };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,149 @@ interface FeedbackData {
31
31
  }
32
32
  declare const PremiumVoiceWidget: React.FC<WidgetConfig>;
33
33
 
34
+ interface IntentAIProviderConfig {
35
+ /** Your Intent AI API key (required) */
36
+ apiKey: string;
37
+ /** API URL (defaults to production) */
38
+ apiUrl?: string;
39
+ /** User information for identifying feedback */
40
+ user?: IntentAIUser$1;
41
+ /** Additional metadata to attach to all feedback */
42
+ metadata?: Record<string, unknown>;
43
+ }
44
+ interface IntentAIUser$1 {
45
+ id?: string;
46
+ email?: string;
47
+ name?: string;
48
+ [key: string]: unknown;
49
+ }
50
+ interface IntentAIContextValue {
51
+ /** Identify the current user */
52
+ identify: (user: IntentAIUser$1) => void;
53
+ /** Set metadata to attach to feedback */
54
+ setMetadata: (metadata: Record<string, unknown>) => void;
55
+ /** Clear the current user */
56
+ clearUser: () => void;
57
+ /** Whether the provider is configured */
58
+ isConfigured: boolean;
59
+ }
60
+ /**
61
+ * Hook to access Intent AI context for user identification and metadata
62
+ */
63
+ declare function useIntentAI(): IntentAIContextValue;
64
+ interface IntentAIProviderProps extends IntentAIProviderConfig {
65
+ /** Widget configuration options */
66
+ widgetConfig?: Omit<WidgetConfig, 'onSubmit'>;
67
+ /** Children components */
68
+ children?: React.ReactNode;
69
+ /** Disable the widget (only provide context) */
70
+ disableWidget?: boolean;
71
+ /** Callback when feedback is submitted successfully */
72
+ onFeedbackSubmitted?: () => void;
73
+ /** Callback when there's an error */
74
+ onError?: (error: Error) => void;
75
+ }
76
+ /**
77
+ * Intent AI Provider - Wraps your app with feedback collection capabilities
78
+ *
79
+ * @example
80
+ * ```tsx
81
+ * import { IntentAIProvider } from '@intentai/react';
82
+ *
83
+ * function App() {
84
+ * return (
85
+ * <IntentAIProvider
86
+ * apiKey="your-api-key"
87
+ * user={{ id: 'user-123', email: 'user@example.com' }}
88
+ * >
89
+ * <YourApp />
90
+ * </IntentAIProvider>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
95
+ declare function IntentAIProvider({ apiKey, apiUrl, user: initialUser, metadata: initialMetadata, widgetConfig, children, disableWidget, onFeedbackSubmitted, onError, }: IntentAIProviderProps): React.ReactElement;
96
+ /**
97
+ * Hook to identify users - convenience wrapper around useIntentAI
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * function UserProfile({ user }) {
102
+ * const identify = useIdentify();
103
+ *
104
+ * useEffect(() => {
105
+ * identify({ id: user.id, email: user.email, name: user.name });
106
+ * }, [user]);
107
+ *
108
+ * return <div>...</div>;
109
+ * }
110
+ * ```
111
+ */
112
+ declare function useIdentify(): (user: IntentAIUser$1) => void;
113
+ /**
114
+ * Hook to set metadata - convenience wrapper around useIntentAI
115
+ *
116
+ * @example
117
+ * ```tsx
118
+ * function Dashboard({ plan }) {
119
+ * const setMetadata = useSetMetadata();
120
+ *
121
+ * useEffect(() => {
122
+ * setMetadata({ plan, feature: 'dashboard' });
123
+ * }, [plan]);
124
+ *
125
+ * return <div>...</div>;
126
+ * }
127
+ * ```
128
+ */
129
+ declare function useSetMetadata(): (metadata: Record<string, unknown>) => void;
130
+
131
+ interface FeedbackButtonProps {
132
+ /** Button variant style */
133
+ variant?: 'primary' | 'secondary' | 'ghost' | 'minimal';
134
+ /** Button size */
135
+ size?: 'sm' | 'md' | 'lg';
136
+ /** Show icon */
137
+ showIcon?: boolean;
138
+ /** Custom icon (React element) */
139
+ icon?: React.ReactNode;
140
+ /** Button label */
141
+ label?: string;
142
+ /** Additional class name */
143
+ className?: string;
144
+ /** Custom styles */
145
+ style?: React.CSSProperties;
146
+ /** Primary color */
147
+ primaryColor?: string;
148
+ /** Click handler - if provided, will be called instead of opening widget */
149
+ onClick?: () => void;
150
+ /** Disabled state */
151
+ disabled?: boolean;
152
+ }
153
+ /**
154
+ * Customizable feedback button that can trigger the widget or custom actions
155
+ *
156
+ * @example
157
+ * ```tsx
158
+ * // Basic usage - triggers widget
159
+ * <FeedbackButton />
160
+ *
161
+ * // Custom label and style
162
+ * <FeedbackButton
163
+ * label="Give Feedback"
164
+ * variant="secondary"
165
+ * size="lg"
166
+ * />
167
+ *
168
+ * // With custom click handler
169
+ * <FeedbackButton
170
+ * label="Report Issue"
171
+ * onClick={() => console.log('clicked')}
172
+ * />
173
+ * ```
174
+ */
175
+ declare function FeedbackButton({ variant, size, showIcon, icon, label, className, style, primaryColor, onClick, disabled, }: FeedbackButtonProps): React.ReactElement;
176
+
34
177
  interface IntentAIUser {
35
178
  id?: string;
36
179
  email?: string;
@@ -102,29 +245,30 @@ declare global {
102
245
  */
103
246
  declare function IntentAIWidget({ apiKey, apiUrl, widgetUrl, position, theme, primaryColor, allowVoice, allowText, allowScreenshot, customMetadata, user, onOpen: _onOpen, onClose: _onClose, onFeedbackSubmitted: _onFeedbackSubmitted, onError, }: IntentAIProps): null;
104
247
  /**
105
- * Hook to control the Intent AI widget programmatically
248
+ * Hook to control the script-tag widget programmatically
249
+ * @deprecated Use useIntentAI from IntentAIProvider instead for React apps
106
250
  *
107
251
  * @example
108
252
  * ```tsx
109
- * import { IntentAIWidget, useIntentAI } from '@intent-ai/react';
253
+ * import { IntentAIWidget, useWidgetControls } from '@intentai/react';
110
254
  *
111
255
  * function App() {
112
- * const { open, close, identify } = useIntentAI();
256
+ * const { open, close, identify } = useWidgetControls();
113
257
  *
114
258
  * return (
115
259
  * <>
116
- * <IntentAIWidget apiKey="your-api-key" />
260
+ * <IntentAIWidget apiKey="your-api-key" widgetUrl="..." apiUrl="..." />
117
261
  * <button onClick={open}>Open Feedback</button>
118
262
  * </>
119
263
  * );
120
264
  * }
121
265
  * ```
122
266
  */
123
- declare function useIntentAI(): {
267
+ declare function useWidgetControls(): {
124
268
  open: () => void;
125
269
  close: () => void;
126
270
  identify: (user: IntentAIUser) => void;
127
271
  setMetadata: (metadata: Record<string, any>) => void;
128
272
  };
129
273
 
130
- export { type IntentAIConfig, type IntentAIProps, type IntentAIUser, IntentAIWidget, PremiumVoiceWidget, type WidgetConfig as PremiumWidgetConfig, IntentAIWidget as default, useIntentAI };
274
+ export { FeedbackButton, type FeedbackButtonProps, type IntentAIConfig, type IntentAIContextValue, type IntentAIProps, IntentAIProvider, type IntentAIProviderConfig, type IntentAIProviderProps, type IntentAIUser, IntentAIWidget, PremiumVoiceWidget, type WidgetConfig as PremiumWidgetConfig, IntentAIWidget as default, useIdentify, useIntentAI, useSetMetadata, useWidgetControls };