@feedvalue/vue 0.1.6 → 0.1.7

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.cts CHANGED
@@ -1,6 +1,7 @@
1
- import { InjectionKey, App, ShallowRef, Ref } from 'vue';
2
- import { FeedValueInstance, FeedValueConfig, FeedbackData, UserTraits } from '@feedvalue/core';
3
- export { FeedValueConfig, FeedValueEvents, FeedValueState, FeedbackData, FeedbackMetadata, UserData, UserTraits } from '@feedvalue/core';
1
+ import * as vue from 'vue';
2
+ import { InjectionKey, App, ShallowRef, Ref, ComputedRef, PropType } from 'vue';
3
+ import { FeedValueInstance, FeedValueConfig, FeedbackData, UserTraits, ReactionOption, ButtonSize, FollowUpTrigger } from '@feedvalue/core';
4
+ export { FeedValueConfig, FeedValueEvents, FeedValueState, FeedbackData, FeedbackMetadata, ReactionConfig, ReactionOption, ReactionState, ReactionTemplate, UserData, UserTraits } from '@feedvalue/core';
4
5
 
5
6
  /**
6
7
  * @feedvalue/vue - Plugin
@@ -139,4 +140,180 @@ interface UseFeedValueReturn {
139
140
  */
140
141
  declare function useFeedValue(widgetId?: string, config?: Partial<FeedValueConfig>): UseFeedValueReturn;
141
142
 
142
- export { FEEDVALUE_KEY, FEEDVALUE_OPTIONS_KEY, type FeedValuePluginOptions, type UseFeedValueReturn, createFeedValue, useFeedValue };
143
+ /**
144
+ * @feedvalue/vue - useReaction Composable
145
+ *
146
+ * Composable for reaction widgets in Vue applications.
147
+ * Provides a simple API for submitting reactions.
148
+ */
149
+
150
+ /**
151
+ * Return type for useReaction composable
152
+ */
153
+ interface UseReactionReturn {
154
+ /** Available reaction options */
155
+ options: ComputedRef<ReactionOption[] | null>;
156
+ /** Currently submitting */
157
+ isSubmitting: Readonly<Ref<boolean>>;
158
+ /** Successfully submitted value (null if not yet submitted) */
159
+ submitted: Readonly<Ref<string | null>>;
160
+ /** Error if submission failed */
161
+ error: Readonly<Ref<Error | null>>;
162
+ /** Option value requiring follow-up input (null if none) */
163
+ showFollowUp: Readonly<Ref<string | null>>;
164
+ /** Submit a reaction */
165
+ react: (value: string, followUp?: string) => Promise<void>;
166
+ /** Set which option is showing follow-up input */
167
+ setShowFollowUp: (value: string | null) => void;
168
+ /** Clear the submitted state to allow re-submission */
169
+ clearSubmitted: () => void;
170
+ /** Check if widget is a reaction type */
171
+ isReactionWidget: ComputedRef<boolean>;
172
+ /** Widget configuration is ready */
173
+ isReady: Readonly<Ref<boolean>>;
174
+ /** Whether to show text labels next to icons */
175
+ showLabels: ComputedRef<boolean>;
176
+ /** Button size */
177
+ buttonSize: ComputedRef<ButtonSize>;
178
+ /** When to show follow-up input */
179
+ followUpTrigger: ComputedRef<FollowUpTrigger>;
180
+ /** Check if an option should show follow-up based on followUpTrigger */
181
+ shouldShowFollowUp: (optionValue: string) => boolean;
182
+ }
183
+ /**
184
+ * Composable for reaction widgets
185
+ *
186
+ * Provides reaction options, submission handling, and follow-up state management.
187
+ * Can be used with or without the FeedValue plugin.
188
+ *
189
+ * @param widgetId - Optional widget ID override (uses plugin widget if not provided)
190
+ *
191
+ * @example
192
+ * ```vue
193
+ * <script setup>
194
+ * import { useReaction } from '@feedvalue/vue';
195
+ *
196
+ * const {
197
+ * options,
198
+ * react,
199
+ * isSubmitting,
200
+ * submitted,
201
+ * error,
202
+ * showFollowUp,
203
+ * setShowFollowUp,
204
+ * isReady,
205
+ * } = useReaction();
206
+ *
207
+ * const handleClick = (option) => {
208
+ * if (option.showFollowUp) {
209
+ * setShowFollowUp(option.value);
210
+ * } else {
211
+ * react(option.value);
212
+ * }
213
+ * };
214
+ * </script>
215
+ *
216
+ * <template>
217
+ * <div v-if="isReady && options">
218
+ * <div v-if="submitted">Thanks for your feedback!</div>
219
+ *
220
+ * <template v-else>
221
+ * <button
222
+ * v-for="option in options"
223
+ * :key="option.value"
224
+ * @click="handleClick(option)"
225
+ * :disabled="isSubmitting"
226
+ * >
227
+ * {{ option.icon }} {{ option.label }}
228
+ * </button>
229
+ *
230
+ * <form v-if="showFollowUp" @submit.prevent="react(showFollowUp, followUpText)">
231
+ * <input v-model="followUpText" placeholder="Tell us more..." />
232
+ * <button type="submit">Send</button>
233
+ * </form>
234
+ *
235
+ * <div v-if="error">Error: {{ error.message }}</div>
236
+ * </template>
237
+ * </div>
238
+ * </template>
239
+ * ```
240
+ */
241
+ declare function useReaction(widgetId?: string): UseReactionReturn;
242
+
243
+ /**
244
+ * ReactionButtons Component
245
+ *
246
+ * Pre-built reaction buttons with follow-up input support.
247
+ *
248
+ * @example
249
+ * ```vue
250
+ * <template>
251
+ * <ReactionButtons widget-id="xxx" @react="onReact" />
252
+ * </template>
253
+ *
254
+ * <script setup>
255
+ * import { ReactionButtons } from '@feedvalue/vue';
256
+ *
257
+ * const onReact = (value, followUp) => {
258
+ * console.log('Reacted:', value, followUp);
259
+ * };
260
+ * </script>
261
+ * ```
262
+ */
263
+ declare const ReactionButtons: vue.DefineComponent<vue.ExtractPropTypes<{
264
+ /** Widget ID (optional if using FeedValue plugin) */
265
+ widgetId: {
266
+ type: PropType<string | undefined>;
267
+ default: undefined;
268
+ };
269
+ /** Custom thank you message (overrides widget config) */
270
+ thankYouMessage: {
271
+ type: PropType<string | undefined>;
272
+ default: undefined;
273
+ };
274
+ /** Custom class for the container */
275
+ containerClass: {
276
+ type: StringConstructor;
277
+ default: string;
278
+ };
279
+ /** Custom class for buttons */
280
+ buttonClass: {
281
+ type: StringConstructor;
282
+ default: string;
283
+ };
284
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
285
+ [key: string]: any;
286
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
287
+ /** Emitted when a reaction is submitted */
288
+ react: (value: string, _followUp?: string) => boolean;
289
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
290
+ /** Widget ID (optional if using FeedValue plugin) */
291
+ widgetId: {
292
+ type: PropType<string | undefined>;
293
+ default: undefined;
294
+ };
295
+ /** Custom thank you message (overrides widget config) */
296
+ thankYouMessage: {
297
+ type: PropType<string | undefined>;
298
+ default: undefined;
299
+ };
300
+ /** Custom class for the container */
301
+ containerClass: {
302
+ type: StringConstructor;
303
+ default: string;
304
+ };
305
+ /** Custom class for buttons */
306
+ buttonClass: {
307
+ type: StringConstructor;
308
+ default: string;
309
+ };
310
+ }>> & Readonly<{
311
+ onReact?: (value: string, _followUp?: string | undefined) => any;
312
+ }>, {
313
+ widgetId: string | undefined;
314
+ thankYouMessage: string | undefined;
315
+ containerClass: string;
316
+ buttonClass: string;
317
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
318
+
319
+ export { FEEDVALUE_KEY, FEEDVALUE_OPTIONS_KEY, type FeedValuePluginOptions, ReactionButtons, type UseFeedValueReturn, type UseReactionReturn, createFeedValue, useFeedValue, useReaction };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { InjectionKey, App, ShallowRef, Ref } from 'vue';
2
- import { FeedValueInstance, FeedValueConfig, FeedbackData, UserTraits } from '@feedvalue/core';
3
- export { FeedValueConfig, FeedValueEvents, FeedValueState, FeedbackData, FeedbackMetadata, UserData, UserTraits } from '@feedvalue/core';
1
+ import * as vue from 'vue';
2
+ import { InjectionKey, App, ShallowRef, Ref, ComputedRef, PropType } from 'vue';
3
+ import { FeedValueInstance, FeedValueConfig, FeedbackData, UserTraits, ReactionOption, ButtonSize, FollowUpTrigger } from '@feedvalue/core';
4
+ export { FeedValueConfig, FeedValueEvents, FeedValueState, FeedbackData, FeedbackMetadata, ReactionConfig, ReactionOption, ReactionState, ReactionTemplate, UserData, UserTraits } from '@feedvalue/core';
4
5
 
5
6
  /**
6
7
  * @feedvalue/vue - Plugin
@@ -139,4 +140,180 @@ interface UseFeedValueReturn {
139
140
  */
140
141
  declare function useFeedValue(widgetId?: string, config?: Partial<FeedValueConfig>): UseFeedValueReturn;
141
142
 
142
- export { FEEDVALUE_KEY, FEEDVALUE_OPTIONS_KEY, type FeedValuePluginOptions, type UseFeedValueReturn, createFeedValue, useFeedValue };
143
+ /**
144
+ * @feedvalue/vue - useReaction Composable
145
+ *
146
+ * Composable for reaction widgets in Vue applications.
147
+ * Provides a simple API for submitting reactions.
148
+ */
149
+
150
+ /**
151
+ * Return type for useReaction composable
152
+ */
153
+ interface UseReactionReturn {
154
+ /** Available reaction options */
155
+ options: ComputedRef<ReactionOption[] | null>;
156
+ /** Currently submitting */
157
+ isSubmitting: Readonly<Ref<boolean>>;
158
+ /** Successfully submitted value (null if not yet submitted) */
159
+ submitted: Readonly<Ref<string | null>>;
160
+ /** Error if submission failed */
161
+ error: Readonly<Ref<Error | null>>;
162
+ /** Option value requiring follow-up input (null if none) */
163
+ showFollowUp: Readonly<Ref<string | null>>;
164
+ /** Submit a reaction */
165
+ react: (value: string, followUp?: string) => Promise<void>;
166
+ /** Set which option is showing follow-up input */
167
+ setShowFollowUp: (value: string | null) => void;
168
+ /** Clear the submitted state to allow re-submission */
169
+ clearSubmitted: () => void;
170
+ /** Check if widget is a reaction type */
171
+ isReactionWidget: ComputedRef<boolean>;
172
+ /** Widget configuration is ready */
173
+ isReady: Readonly<Ref<boolean>>;
174
+ /** Whether to show text labels next to icons */
175
+ showLabels: ComputedRef<boolean>;
176
+ /** Button size */
177
+ buttonSize: ComputedRef<ButtonSize>;
178
+ /** When to show follow-up input */
179
+ followUpTrigger: ComputedRef<FollowUpTrigger>;
180
+ /** Check if an option should show follow-up based on followUpTrigger */
181
+ shouldShowFollowUp: (optionValue: string) => boolean;
182
+ }
183
+ /**
184
+ * Composable for reaction widgets
185
+ *
186
+ * Provides reaction options, submission handling, and follow-up state management.
187
+ * Can be used with or without the FeedValue plugin.
188
+ *
189
+ * @param widgetId - Optional widget ID override (uses plugin widget if not provided)
190
+ *
191
+ * @example
192
+ * ```vue
193
+ * <script setup>
194
+ * import { useReaction } from '@feedvalue/vue';
195
+ *
196
+ * const {
197
+ * options,
198
+ * react,
199
+ * isSubmitting,
200
+ * submitted,
201
+ * error,
202
+ * showFollowUp,
203
+ * setShowFollowUp,
204
+ * isReady,
205
+ * } = useReaction();
206
+ *
207
+ * const handleClick = (option) => {
208
+ * if (option.showFollowUp) {
209
+ * setShowFollowUp(option.value);
210
+ * } else {
211
+ * react(option.value);
212
+ * }
213
+ * };
214
+ * </script>
215
+ *
216
+ * <template>
217
+ * <div v-if="isReady && options">
218
+ * <div v-if="submitted">Thanks for your feedback!</div>
219
+ *
220
+ * <template v-else>
221
+ * <button
222
+ * v-for="option in options"
223
+ * :key="option.value"
224
+ * @click="handleClick(option)"
225
+ * :disabled="isSubmitting"
226
+ * >
227
+ * {{ option.icon }} {{ option.label }}
228
+ * </button>
229
+ *
230
+ * <form v-if="showFollowUp" @submit.prevent="react(showFollowUp, followUpText)">
231
+ * <input v-model="followUpText" placeholder="Tell us more..." />
232
+ * <button type="submit">Send</button>
233
+ * </form>
234
+ *
235
+ * <div v-if="error">Error: {{ error.message }}</div>
236
+ * </template>
237
+ * </div>
238
+ * </template>
239
+ * ```
240
+ */
241
+ declare function useReaction(widgetId?: string): UseReactionReturn;
242
+
243
+ /**
244
+ * ReactionButtons Component
245
+ *
246
+ * Pre-built reaction buttons with follow-up input support.
247
+ *
248
+ * @example
249
+ * ```vue
250
+ * <template>
251
+ * <ReactionButtons widget-id="xxx" @react="onReact" />
252
+ * </template>
253
+ *
254
+ * <script setup>
255
+ * import { ReactionButtons } from '@feedvalue/vue';
256
+ *
257
+ * const onReact = (value, followUp) => {
258
+ * console.log('Reacted:', value, followUp);
259
+ * };
260
+ * </script>
261
+ * ```
262
+ */
263
+ declare const ReactionButtons: vue.DefineComponent<vue.ExtractPropTypes<{
264
+ /** Widget ID (optional if using FeedValue plugin) */
265
+ widgetId: {
266
+ type: PropType<string | undefined>;
267
+ default: undefined;
268
+ };
269
+ /** Custom thank you message (overrides widget config) */
270
+ thankYouMessage: {
271
+ type: PropType<string | undefined>;
272
+ default: undefined;
273
+ };
274
+ /** Custom class for the container */
275
+ containerClass: {
276
+ type: StringConstructor;
277
+ default: string;
278
+ };
279
+ /** Custom class for buttons */
280
+ buttonClass: {
281
+ type: StringConstructor;
282
+ default: string;
283
+ };
284
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
285
+ [key: string]: any;
286
+ }> | null, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
287
+ /** Emitted when a reaction is submitted */
288
+ react: (value: string, _followUp?: string) => boolean;
289
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
290
+ /** Widget ID (optional if using FeedValue plugin) */
291
+ widgetId: {
292
+ type: PropType<string | undefined>;
293
+ default: undefined;
294
+ };
295
+ /** Custom thank you message (overrides widget config) */
296
+ thankYouMessage: {
297
+ type: PropType<string | undefined>;
298
+ default: undefined;
299
+ };
300
+ /** Custom class for the container */
301
+ containerClass: {
302
+ type: StringConstructor;
303
+ default: string;
304
+ };
305
+ /** Custom class for buttons */
306
+ buttonClass: {
307
+ type: StringConstructor;
308
+ default: string;
309
+ };
310
+ }>> & Readonly<{
311
+ onReact?: (value: string, _followUp?: string | undefined) => any;
312
+ }>, {
313
+ widgetId: string | undefined;
314
+ thankYouMessage: string | undefined;
315
+ containerClass: string;
316
+ buttonClass: string;
317
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
318
+
319
+ export { FEEDVALUE_KEY, FEEDVALUE_OPTIONS_KEY, type FeedValuePluginOptions, ReactionButtons, type UseFeedValueReturn, type UseReactionReturn, createFeedValue, useFeedValue, useReaction };