@squeletteapp/widget-react 0.1.0 → 1.0.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/hooks.d.ts DELETED
@@ -1,20 +0,0 @@
1
- export interface WidgetOptions {
2
- buttonSelector: string;
3
- position?: 'top' | 'bottom' | 'left' | 'right';
4
- theme?: string;
5
- onLoad?: () => void;
6
- onOpenChange?: (isOpen: boolean) => void;
7
- }
8
- export interface WidgetInstance {
9
- destroy: () => void;
10
- }
11
- export declare function useFeedbackWidget(workspaceSlug: string, boardSlug: string | undefined, options: WidgetOptions): WidgetInstance | null;
12
- export declare function useRoadmapWidget(workspaceSlug: string, boardSlug: string, options: WidgetOptions): WidgetInstance | null;
13
- export declare function useChangelogWidget(workspaceSlug: string, options: WidgetOptions): WidgetInstance | null;
14
- export declare function useWidget(options: {
15
- url: string;
16
- buttonSelector: string;
17
- position?: 'top' | 'bottom' | 'left' | 'right';
18
- onLoad?: () => void;
19
- onOpenChange?: (isOpen: boolean) => void;
20
- }): WidgetInstance | null;
package/dist/hooks.js DELETED
@@ -1,78 +0,0 @@
1
- import { useEffect, useRef, useCallback } from 'react';
2
- import { createFeedbackWidget, createRoadmapWidget, createChangelogWidget, createWidget } from '@squeletteapp/widget';
3
- export function useFeedbackWidget(workspaceSlug, boardSlug, options) {
4
- const widgetRef = useRef(null);
5
- const initWidget = useCallback(() => {
6
- if (widgetRef.current) {
7
- widgetRef.current.destroy();
8
- }
9
- widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, options);
10
- return widgetRef.current;
11
- }, [workspaceSlug, boardSlug, options]);
12
- useEffect(() => {
13
- const widget = initWidget();
14
- return () => {
15
- if (widget) {
16
- widget.destroy();
17
- }
18
- };
19
- }, [initWidget]);
20
- return widgetRef.current;
21
- }
22
- export function useRoadmapWidget(workspaceSlug, boardSlug, options) {
23
- const widgetRef = useRef(null);
24
- const initWidget = useCallback(() => {
25
- if (widgetRef.current) {
26
- widgetRef.current.destroy();
27
- }
28
- widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);
29
- return widgetRef.current;
30
- }, [workspaceSlug, boardSlug, options]);
31
- useEffect(() => {
32
- const widget = initWidget();
33
- return () => {
34
- if (widget) {
35
- widget.destroy();
36
- }
37
- };
38
- }, [initWidget]);
39
- return widgetRef.current;
40
- }
41
- export function useChangelogWidget(workspaceSlug, options) {
42
- const widgetRef = useRef(null);
43
- const initWidget = useCallback(() => {
44
- if (widgetRef.current) {
45
- widgetRef.current.destroy();
46
- }
47
- widgetRef.current = createChangelogWidget(workspaceSlug, options);
48
- return widgetRef.current;
49
- }, [workspaceSlug, options]);
50
- useEffect(() => {
51
- const widget = initWidget();
52
- return () => {
53
- if (widget) {
54
- widget.destroy();
55
- }
56
- };
57
- }, [initWidget]);
58
- return widgetRef.current;
59
- }
60
- export function useWidget(options) {
61
- const widgetRef = useRef(null);
62
- const initWidget = useCallback(() => {
63
- if (widgetRef.current) {
64
- widgetRef.current.destroy();
65
- }
66
- widgetRef.current = createWidget(options);
67
- return widgetRef.current;
68
- }, [options]);
69
- useEffect(() => {
70
- const widget = initWidget();
71
- return () => {
72
- if (widget) {
73
- widget.destroy();
74
- }
75
- };
76
- }, [initWidget]);
77
- return widgetRef.current;
78
- }