@squeletteapp/widget-react 0.1.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/README.md +113 -0
- package/dist/components.d.ts +22 -0
- package/dist/components.js +27 -0
- package/dist/hooks.d.ts +20 -0
- package/dist/hooks.js +78 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +175 -0
- package/dist/index.esm.js.map +7 -0
- package/dist/index.js +188 -0
- package/dist/index.js.map +7 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @squeletteapp/widget-react
|
|
2
|
+
|
|
3
|
+
React components and hooks for Squelette feedback widgets.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @squeletteapp/widget-react
|
|
9
|
+
# or
|
|
10
|
+
yarn add @squeletteapp/widget-react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Using Components (Recommended)
|
|
16
|
+
|
|
17
|
+
The easiest way to use Squelette widgets in React. Components automatically generate unique IDs using React's `useId()` hook:
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { FeedbackWidget, RoadmapWidget, ChangelogWidget } from '@squeletteapp/widget-react';
|
|
21
|
+
|
|
22
|
+
function App() {
|
|
23
|
+
return (
|
|
24
|
+
<div>
|
|
25
|
+
<FeedbackWidget
|
|
26
|
+
workspaceSlug="your-workspace"
|
|
27
|
+
boardSlug="feature-requests"
|
|
28
|
+
theme="light"
|
|
29
|
+
position="top"
|
|
30
|
+
onOpenChange={(isOpen) => console.log('Widget open:', isOpen)}
|
|
31
|
+
>
|
|
32
|
+
Give Feedback
|
|
33
|
+
</FeedbackWidget>
|
|
34
|
+
|
|
35
|
+
<RoadmapWidget
|
|
36
|
+
workspaceSlug="your-workspace"
|
|
37
|
+
boardSlug="roadmap"
|
|
38
|
+
theme="dark"
|
|
39
|
+
>
|
|
40
|
+
View Roadmap
|
|
41
|
+
</RoadmapWidget>
|
|
42
|
+
|
|
43
|
+
<ChangelogWidget
|
|
44
|
+
workspaceSlug="your-workspace"
|
|
45
|
+
theme="light"
|
|
46
|
+
>
|
|
47
|
+
What's New
|
|
48
|
+
</ChangelogWidget>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Using Hooks
|
|
55
|
+
|
|
56
|
+
For more control, use the hooks directly:
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { useFeedbackWidget } from '@squeletteapp/widget-react';
|
|
60
|
+
|
|
61
|
+
function CustomButton() {
|
|
62
|
+
const widget = useFeedbackWidget('your-workspace', 'feature-requests', {
|
|
63
|
+
buttonSelector: '#my-feedback-button',
|
|
64
|
+
theme: 'light',
|
|
65
|
+
position: 'top',
|
|
66
|
+
onLoad: () => console.log('Widget loaded'),
|
|
67
|
+
onOpenChange: (isOpen) => console.log('Widget open:', isOpen),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<button id="my-feedback-button">
|
|
72
|
+
Custom Feedback Button
|
|
73
|
+
</button>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## API
|
|
79
|
+
|
|
80
|
+
### Components
|
|
81
|
+
|
|
82
|
+
#### `<FeedbackWidget>`
|
|
83
|
+
- `workspaceSlug: string` - Your workspace slug
|
|
84
|
+
- `boardSlug?: string` - Board slug (optional)
|
|
85
|
+
- `theme?: 'light' | 'dark'` - Widget theme
|
|
86
|
+
- `position?: 'top' | 'bottom' | 'left' | 'right'` - Widget position
|
|
87
|
+
- `onLoad?: () => void` - Called when widget loads
|
|
88
|
+
- `onOpenChange?: (isOpen: boolean) => void` - Called when widget opens/closes
|
|
89
|
+
- `className?: string` - CSS class for the button
|
|
90
|
+
- `children: ReactNode` - Button content
|
|
91
|
+
|
|
92
|
+
#### `<RoadmapWidget>`
|
|
93
|
+
Same props as FeedbackWidget, but `boardSlug` is required.
|
|
94
|
+
|
|
95
|
+
#### `<ChangelogWidget>`
|
|
96
|
+
Same props as FeedbackWidget, but no `boardSlug` prop.
|
|
97
|
+
|
|
98
|
+
### Hooks
|
|
99
|
+
|
|
100
|
+
#### `useFeedbackWidget(workspaceSlug, boardSlug, options)`
|
|
101
|
+
#### `useRoadmapWidget(workspaceSlug, boardSlug, options)`
|
|
102
|
+
#### `useChangelogWidget(workspaceSlug, options)`
|
|
103
|
+
#### `useWidget(options)`
|
|
104
|
+
|
|
105
|
+
All hooks return a widget instance with a `destroy()` method, or `null` if not initialized.
|
|
106
|
+
|
|
107
|
+
## TypeScript
|
|
108
|
+
|
|
109
|
+
This package includes full TypeScript support with proper type definitions.
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
Built with esbuild for fast compilation and optimized bundles. Supports both CommonJS and ESM formats.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WidgetOptions } from './hooks';
|
|
3
|
+
export interface FeedbackWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
4
|
+
workspaceSlug: string;
|
|
5
|
+
boardSlug?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface RoadmapWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
10
|
+
workspaceSlug: string;
|
|
11
|
+
boardSlug: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ChangelogWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
16
|
+
workspaceSlug: string;
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function FeedbackWidget({ workspaceSlug, boardSlug, children, className, ...options }: FeedbackWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function RoadmapWidget({ workspaceSlug, boardSlug, children, className, ...options }: RoadmapWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
export declare function ChangelogWidget({ workspaceSlug, children, className, ...options }: ChangelogWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { useFeedbackWidget, useRoadmapWidget, useChangelogWidget } from './hooks';
|
|
4
|
+
export function FeedbackWidget({ workspaceSlug, boardSlug, children, className, ...options }) {
|
|
5
|
+
const buttonId = useId();
|
|
6
|
+
const widget = useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
7
|
+
...options,
|
|
8
|
+
buttonSelector: `#${buttonId}`,
|
|
9
|
+
});
|
|
10
|
+
return (_jsx("button", { id: buttonId, className: className, type: "button", children: children }));
|
|
11
|
+
}
|
|
12
|
+
export function RoadmapWidget({ workspaceSlug, boardSlug, children, className, ...options }) {
|
|
13
|
+
const buttonId = useId();
|
|
14
|
+
const widget = useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
15
|
+
...options,
|
|
16
|
+
buttonSelector: `#${buttonId}`,
|
|
17
|
+
});
|
|
18
|
+
return (_jsx("button", { id: buttonId, className: className, type: "button", children: children }));
|
|
19
|
+
}
|
|
20
|
+
export function ChangelogWidget({ workspaceSlug, children, className, ...options }) {
|
|
21
|
+
const buttonId = useId();
|
|
22
|
+
const widget = useChangelogWidget(workspaceSlug, {
|
|
23
|
+
...options,
|
|
24
|
+
buttonSelector: `#${buttonId}`,
|
|
25
|
+
});
|
|
26
|
+
return (_jsx("button", { id: buttonId, className: className, type: "button", children: children }));
|
|
27
|
+
}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { useFeedbackWidget, useRoadmapWidget, useChangelogWidget, useWidget, type WidgetOptions, type WidgetInstance, } from './hooks';
|
|
2
|
+
export { FeedbackWidget, RoadmapWidget, ChangelogWidget, type FeedbackWidgetProps, type RoadmapWidgetProps, type ChangelogWidgetProps, } from './components';
|
|
3
|
+
export { createFeedbackWidget, createRoadmapWidget, createChangelogWidget, createWidget, } from '@squeletteapp/widget';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// src/hooks.ts
|
|
2
|
+
import { useEffect, useRef, useCallback } from "react";
|
|
3
|
+
import {
|
|
4
|
+
createFeedbackWidget,
|
|
5
|
+
createRoadmapWidget,
|
|
6
|
+
createChangelogWidget,
|
|
7
|
+
createWidget
|
|
8
|
+
} from "@squeletteapp/widget";
|
|
9
|
+
function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
10
|
+
const widgetRef = useRef(null);
|
|
11
|
+
const initWidget = useCallback(() => {
|
|
12
|
+
if (widgetRef.current) {
|
|
13
|
+
widgetRef.current.destroy();
|
|
14
|
+
}
|
|
15
|
+
widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, options);
|
|
16
|
+
return widgetRef.current;
|
|
17
|
+
}, [workspaceSlug, boardSlug, options]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const widget = initWidget();
|
|
20
|
+
return () => {
|
|
21
|
+
if (widget) {
|
|
22
|
+
widget.destroy();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}, [initWidget]);
|
|
26
|
+
return widgetRef.current;
|
|
27
|
+
}
|
|
28
|
+
function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
29
|
+
const widgetRef = useRef(null);
|
|
30
|
+
const initWidget = useCallback(() => {
|
|
31
|
+
if (widgetRef.current) {
|
|
32
|
+
widgetRef.current.destroy();
|
|
33
|
+
}
|
|
34
|
+
widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);
|
|
35
|
+
return widgetRef.current;
|
|
36
|
+
}, [workspaceSlug, boardSlug, options]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const widget = initWidget();
|
|
39
|
+
return () => {
|
|
40
|
+
if (widget) {
|
|
41
|
+
widget.destroy();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}, [initWidget]);
|
|
45
|
+
return widgetRef.current;
|
|
46
|
+
}
|
|
47
|
+
function useChangelogWidget(workspaceSlug, options) {
|
|
48
|
+
const widgetRef = useRef(null);
|
|
49
|
+
const initWidget = useCallback(() => {
|
|
50
|
+
if (widgetRef.current) {
|
|
51
|
+
widgetRef.current.destroy();
|
|
52
|
+
}
|
|
53
|
+
widgetRef.current = createChangelogWidget(workspaceSlug, options);
|
|
54
|
+
return widgetRef.current;
|
|
55
|
+
}, [workspaceSlug, options]);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const widget = initWidget();
|
|
58
|
+
return () => {
|
|
59
|
+
if (widget) {
|
|
60
|
+
widget.destroy();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}, [initWidget]);
|
|
64
|
+
return widgetRef.current;
|
|
65
|
+
}
|
|
66
|
+
function useWidget(options) {
|
|
67
|
+
const widgetRef = useRef(null);
|
|
68
|
+
const initWidget = useCallback(() => {
|
|
69
|
+
if (widgetRef.current) {
|
|
70
|
+
widgetRef.current.destroy();
|
|
71
|
+
}
|
|
72
|
+
widgetRef.current = createWidget(options);
|
|
73
|
+
return widgetRef.current;
|
|
74
|
+
}, [options]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const widget = initWidget();
|
|
77
|
+
return () => {
|
|
78
|
+
if (widget) {
|
|
79
|
+
widget.destroy();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}, [initWidget]);
|
|
83
|
+
return widgetRef.current;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// src/components.tsx
|
|
87
|
+
import { useId } from "react";
|
|
88
|
+
import { jsx } from "react/jsx-runtime";
|
|
89
|
+
function FeedbackWidget({
|
|
90
|
+
workspaceSlug,
|
|
91
|
+
boardSlug,
|
|
92
|
+
children,
|
|
93
|
+
className,
|
|
94
|
+
...options
|
|
95
|
+
}) {
|
|
96
|
+
const buttonId = useId();
|
|
97
|
+
const widget = useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
98
|
+
...options,
|
|
99
|
+
buttonSelector: `#${buttonId}`
|
|
100
|
+
});
|
|
101
|
+
return /* @__PURE__ */ jsx(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
id: buttonId,
|
|
105
|
+
className,
|
|
106
|
+
type: "button",
|
|
107
|
+
children
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function RoadmapWidget({
|
|
112
|
+
workspaceSlug,
|
|
113
|
+
boardSlug,
|
|
114
|
+
children,
|
|
115
|
+
className,
|
|
116
|
+
...options
|
|
117
|
+
}) {
|
|
118
|
+
const buttonId = useId();
|
|
119
|
+
const widget = useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
120
|
+
...options,
|
|
121
|
+
buttonSelector: `#${buttonId}`
|
|
122
|
+
});
|
|
123
|
+
return /* @__PURE__ */ jsx(
|
|
124
|
+
"button",
|
|
125
|
+
{
|
|
126
|
+
id: buttonId,
|
|
127
|
+
className,
|
|
128
|
+
type: "button",
|
|
129
|
+
children
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
function ChangelogWidget({
|
|
134
|
+
workspaceSlug,
|
|
135
|
+
children,
|
|
136
|
+
className,
|
|
137
|
+
...options
|
|
138
|
+
}) {
|
|
139
|
+
const buttonId = useId();
|
|
140
|
+
const widget = useChangelogWidget(workspaceSlug, {
|
|
141
|
+
...options,
|
|
142
|
+
buttonSelector: `#${buttonId}`
|
|
143
|
+
});
|
|
144
|
+
return /* @__PURE__ */ jsx(
|
|
145
|
+
"button",
|
|
146
|
+
{
|
|
147
|
+
id: buttonId,
|
|
148
|
+
className,
|
|
149
|
+
type: "button",
|
|
150
|
+
children
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// src/index.ts
|
|
156
|
+
import {
|
|
157
|
+
createFeedbackWidget as createFeedbackWidget2,
|
|
158
|
+
createRoadmapWidget as createRoadmapWidget2,
|
|
159
|
+
createChangelogWidget as createChangelogWidget2,
|
|
160
|
+
createWidget as createWidget2
|
|
161
|
+
} from "@squeletteapp/widget";
|
|
162
|
+
export {
|
|
163
|
+
ChangelogWidget,
|
|
164
|
+
FeedbackWidget,
|
|
165
|
+
RoadmapWidget,
|
|
166
|
+
createChangelogWidget2 as createChangelogWidget,
|
|
167
|
+
createFeedbackWidget2 as createFeedbackWidget,
|
|
168
|
+
createRoadmapWidget2 as createRoadmapWidget,
|
|
169
|
+
createWidget2 as createWidget,
|
|
170
|
+
useChangelogWidget,
|
|
171
|
+
useFeedbackWidget,
|
|
172
|
+
useRoadmapWidget,
|
|
173
|
+
useWidget
|
|
174
|
+
};
|
|
175
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/hooks.ts", "../src/components.tsx", "../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { useEffect, useRef, useCallback } from 'react';\nimport { \n createFeedbackWidget, \n createRoadmapWidget, \n createChangelogWidget,\n createWidget\n} from '@squeletteapp/widget';\n\nexport interface WidgetOptions {\n buttonSelector: string;\n position?: 'top' | 'bottom' | 'left' | 'right';\n theme?: string;\n onLoad?: () => void;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface WidgetInstance {\n destroy: () => void;\n}\n\nexport function useFeedbackWidget(\n workspaceSlug: string,\n boardSlug: string | undefined,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useRoadmapWidget(\n workspaceSlug: string,\n boardSlug: string,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useChangelogWidget(\n workspaceSlug: string,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createChangelogWidget(workspaceSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useWidget(options: {\n url: string;\n buttonSelector: string;\n position?: 'top' | 'bottom' | 'left' | 'right';\n onLoad?: () => void;\n onOpenChange?: (isOpen: boolean) => void;\n}): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createWidget(options);\n return widgetRef.current;\n }, [options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}", "import React, { useId } from 'react';\nimport { useFeedbackWidget, useRoadmapWidget, useChangelogWidget, WidgetOptions } from './hooks';\n\nexport interface FeedbackWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug?: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport interface RoadmapWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport interface ChangelogWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport function FeedbackWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n ...options\n}: FeedbackWidgetProps) {\n const buttonId = useId();\n\n const widget = useFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}\n\nexport function RoadmapWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n ...options\n}: RoadmapWidgetProps) {\n const buttonId = useId();\n\n const widget = useRoadmapWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}\n\nexport function ChangelogWidget({\n workspaceSlug,\n children,\n className,\n ...options\n}: ChangelogWidgetProps) {\n const buttonId = useId();\n\n const widget = useChangelogWidget(workspaceSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}", "// Export hooks\nexport {\n useFeedbackWidget,\n useRoadmapWidget,\n useChangelogWidget,\n useWidget,\n type WidgetOptions,\n type WidgetInstance,\n} from './hooks';\n\n// Export components\nexport {\n FeedbackWidget,\n RoadmapWidget,\n ChangelogWidget,\n type FeedbackWidgetProps,\n type RoadmapWidgetProps,\n type ChangelogWidgetProps,\n} from './components';\n\n// Re-export functions from the base widget package\nexport { \n createFeedbackWidget,\n createRoadmapWidget,\n createChangelogWidget,\n createWidget,\n} from '@squeletteapp/widget';"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,WAAW,QAAQ,mBAAmB;AAC/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAcA,SAAS,kBACd,eACA,WACA,SACuB;AACvB,QAAM,YAAY,OAA8B,IAAI;AAEpD,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,UAAU,SAAS;AACrB,gBAAU,QAAQ,QAAQ;AAAA,IAC5B;AAEA,cAAU,UAAU,qBAAqB,eAAe,WAAW,OAAO;AAC1E,WAAO,UAAU;AAAA,EACnB,GAAG,CAAC,eAAe,WAAW,OAAO,CAAC;AAEtC,YAAU,MAAM;AACd,UAAM,SAAS,WAAW;AAE1B,WAAO,MAAM;AACX,UAAI,QAAQ;AACV,eAAO,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,UAAU;AACnB;AAEO,SAAS,iBACd,eACA,WACA,SACuB;AACvB,QAAM,YAAY,OAA8B,IAAI;AAEpD,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,UAAU,SAAS;AACrB,gBAAU,QAAQ,QAAQ;AAAA,IAC5B;AAEA,cAAU,UAAU,oBAAoB,eAAe,WAAW,OAAO;AACzE,WAAO,UAAU;AAAA,EACnB,GAAG,CAAC,eAAe,WAAW,OAAO,CAAC;AAEtC,YAAU,MAAM;AACd,UAAM,SAAS,WAAW;AAE1B,WAAO,MAAM;AACX,UAAI,QAAQ;AACV,eAAO,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,UAAU;AACnB;AAEO,SAAS,mBACd,eACA,SACuB;AACvB,QAAM,YAAY,OAA8B,IAAI;AAEpD,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,UAAU,SAAS;AACrB,gBAAU,QAAQ,QAAQ;AAAA,IAC5B;AAEA,cAAU,UAAU,sBAAsB,eAAe,OAAO;AAChE,WAAO,UAAU;AAAA,EACnB,GAAG,CAAC,eAAe,OAAO,CAAC;AAE3B,YAAU,MAAM;AACd,UAAM,SAAS,WAAW;AAE1B,WAAO,MAAM;AACX,UAAI,QAAQ;AACV,eAAO,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,UAAU;AACnB;AAEO,SAAS,UAAU,SAMA;AACxB,QAAM,YAAY,OAA8B,IAAI;AAEpD,QAAM,aAAa,YAAY,MAAM;AACnC,QAAI,UAAU,SAAS;AACrB,gBAAU,QAAQ,QAAQ;AAAA,IAC5B;AAEA,cAAU,UAAU,aAAa,OAAO;AACxC,WAAO,UAAU;AAAA,EACnB,GAAG,CAAC,OAAO,CAAC;AAEZ,YAAU,MAAM;AACd,UAAM,SAAS,WAAW;AAE1B,WAAO,MAAM;AACX,UAAI,QAAQ;AACV,eAAO,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,UAAU,CAAC;AAEf,SAAO,UAAU;AACnB;;;ACvIA,SAAgB,aAAa;AAsCzB;AAfG,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAwB;AACtB,QAAM,WAAW,MAAM;AAEvB,QAAM,SAAS,kBAAkB,eAAe,WAAW;AAAA,IACzD,GAAG;AAAA,IACH,gBAAgB,IAAI,QAAQ;AAAA,EAC9B,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,cAAc;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAuB;AACrB,QAAM,WAAW,MAAM;AAEvB,QAAM,SAAS,iBAAiB,eAAe,WAAW;AAAA,IACxD,GAAG;AAAA,IACH,gBAAgB,IAAI,QAAQ;AAAA,EAC9B,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAyB;AACvB,QAAM,WAAW,MAAM;AAEvB,QAAM,SAAS,mBAAmB,eAAe;AAAA,IAC/C,GAAG;AAAA,IACH,gBAAgB,IAAI,QAAQ;AAAA,EAC9B,CAAC;AAED,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAI;AAAA,MACJ;AAAA,MACA,MAAK;AAAA,MAEJ;AAAA;AAAA,EACH;AAEJ;;;AC1EA;AAAA,EACE,wBAAAA;AAAA,EACA,uBAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,gBAAAC;AAAA,OACK;",
|
|
6
|
+
"names": ["createFeedbackWidget", "createRoadmapWidget", "createChangelogWidget", "createWidget"]
|
|
7
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
ChangelogWidget: () => ChangelogWidget,
|
|
24
|
+
FeedbackWidget: () => FeedbackWidget,
|
|
25
|
+
RoadmapWidget: () => RoadmapWidget,
|
|
26
|
+
createChangelogWidget: () => import_widget2.createChangelogWidget,
|
|
27
|
+
createFeedbackWidget: () => import_widget2.createFeedbackWidget,
|
|
28
|
+
createRoadmapWidget: () => import_widget2.createRoadmapWidget,
|
|
29
|
+
createWidget: () => import_widget2.createWidget,
|
|
30
|
+
useChangelogWidget: () => useChangelogWidget,
|
|
31
|
+
useFeedbackWidget: () => useFeedbackWidget,
|
|
32
|
+
useRoadmapWidget: () => useRoadmapWidget,
|
|
33
|
+
useWidget: () => useWidget
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
|
|
37
|
+
// src/hooks.ts
|
|
38
|
+
var import_react = require("react");
|
|
39
|
+
var import_widget = require("@squeletteapp/widget");
|
|
40
|
+
function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
41
|
+
const widgetRef = (0, import_react.useRef)(null);
|
|
42
|
+
const initWidget = (0, import_react.useCallback)(() => {
|
|
43
|
+
if (widgetRef.current) {
|
|
44
|
+
widgetRef.current.destroy();
|
|
45
|
+
}
|
|
46
|
+
widgetRef.current = (0, import_widget.createFeedbackWidget)(workspaceSlug, boardSlug, options);
|
|
47
|
+
return widgetRef.current;
|
|
48
|
+
}, [workspaceSlug, boardSlug, options]);
|
|
49
|
+
(0, import_react.useEffect)(() => {
|
|
50
|
+
const widget = initWidget();
|
|
51
|
+
return () => {
|
|
52
|
+
if (widget) {
|
|
53
|
+
widget.destroy();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [initWidget]);
|
|
57
|
+
return widgetRef.current;
|
|
58
|
+
}
|
|
59
|
+
function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
60
|
+
const widgetRef = (0, import_react.useRef)(null);
|
|
61
|
+
const initWidget = (0, import_react.useCallback)(() => {
|
|
62
|
+
if (widgetRef.current) {
|
|
63
|
+
widgetRef.current.destroy();
|
|
64
|
+
}
|
|
65
|
+
widgetRef.current = (0, import_widget.createRoadmapWidget)(workspaceSlug, boardSlug, options);
|
|
66
|
+
return widgetRef.current;
|
|
67
|
+
}, [workspaceSlug, boardSlug, options]);
|
|
68
|
+
(0, import_react.useEffect)(() => {
|
|
69
|
+
const widget = initWidget();
|
|
70
|
+
return () => {
|
|
71
|
+
if (widget) {
|
|
72
|
+
widget.destroy();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}, [initWidget]);
|
|
76
|
+
return widgetRef.current;
|
|
77
|
+
}
|
|
78
|
+
function useChangelogWidget(workspaceSlug, options) {
|
|
79
|
+
const widgetRef = (0, import_react.useRef)(null);
|
|
80
|
+
const initWidget = (0, import_react.useCallback)(() => {
|
|
81
|
+
if (widgetRef.current) {
|
|
82
|
+
widgetRef.current.destroy();
|
|
83
|
+
}
|
|
84
|
+
widgetRef.current = (0, import_widget.createChangelogWidget)(workspaceSlug, options);
|
|
85
|
+
return widgetRef.current;
|
|
86
|
+
}, [workspaceSlug, options]);
|
|
87
|
+
(0, import_react.useEffect)(() => {
|
|
88
|
+
const widget = initWidget();
|
|
89
|
+
return () => {
|
|
90
|
+
if (widget) {
|
|
91
|
+
widget.destroy();
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}, [initWidget]);
|
|
95
|
+
return widgetRef.current;
|
|
96
|
+
}
|
|
97
|
+
function useWidget(options) {
|
|
98
|
+
const widgetRef = (0, import_react.useRef)(null);
|
|
99
|
+
const initWidget = (0, import_react.useCallback)(() => {
|
|
100
|
+
if (widgetRef.current) {
|
|
101
|
+
widgetRef.current.destroy();
|
|
102
|
+
}
|
|
103
|
+
widgetRef.current = (0, import_widget.createWidget)(options);
|
|
104
|
+
return widgetRef.current;
|
|
105
|
+
}, [options]);
|
|
106
|
+
(0, import_react.useEffect)(() => {
|
|
107
|
+
const widget = initWidget();
|
|
108
|
+
return () => {
|
|
109
|
+
if (widget) {
|
|
110
|
+
widget.destroy();
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}, [initWidget]);
|
|
114
|
+
return widgetRef.current;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/components.tsx
|
|
118
|
+
var import_react2 = require("react");
|
|
119
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
120
|
+
function FeedbackWidget({
|
|
121
|
+
workspaceSlug,
|
|
122
|
+
boardSlug,
|
|
123
|
+
children,
|
|
124
|
+
className,
|
|
125
|
+
...options
|
|
126
|
+
}) {
|
|
127
|
+
const buttonId = (0, import_react2.useId)();
|
|
128
|
+
const widget = useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
129
|
+
...options,
|
|
130
|
+
buttonSelector: `#${buttonId}`
|
|
131
|
+
});
|
|
132
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
id: buttonId,
|
|
136
|
+
className,
|
|
137
|
+
type: "button",
|
|
138
|
+
children
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
function RoadmapWidget({
|
|
143
|
+
workspaceSlug,
|
|
144
|
+
boardSlug,
|
|
145
|
+
children,
|
|
146
|
+
className,
|
|
147
|
+
...options
|
|
148
|
+
}) {
|
|
149
|
+
const buttonId = (0, import_react2.useId)();
|
|
150
|
+
const widget = useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
151
|
+
...options,
|
|
152
|
+
buttonSelector: `#${buttonId}`
|
|
153
|
+
});
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
+
"button",
|
|
156
|
+
{
|
|
157
|
+
id: buttonId,
|
|
158
|
+
className,
|
|
159
|
+
type: "button",
|
|
160
|
+
children
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
function ChangelogWidget({
|
|
165
|
+
workspaceSlug,
|
|
166
|
+
children,
|
|
167
|
+
className,
|
|
168
|
+
...options
|
|
169
|
+
}) {
|
|
170
|
+
const buttonId = (0, import_react2.useId)();
|
|
171
|
+
const widget = useChangelogWidget(workspaceSlug, {
|
|
172
|
+
...options,
|
|
173
|
+
buttonSelector: `#${buttonId}`
|
|
174
|
+
});
|
|
175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
176
|
+
"button",
|
|
177
|
+
{
|
|
178
|
+
id: buttonId,
|
|
179
|
+
className,
|
|
180
|
+
type: "button",
|
|
181
|
+
children
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/index.ts
|
|
187
|
+
var import_widget2 = require("@squeletteapp/widget");
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts", "../src/hooks.ts", "../src/components.tsx"],
|
|
4
|
+
"sourcesContent": ["// Export hooks\nexport {\n useFeedbackWidget,\n useRoadmapWidget,\n useChangelogWidget,\n useWidget,\n type WidgetOptions,\n type WidgetInstance,\n} from './hooks';\n\n// Export components\nexport {\n FeedbackWidget,\n RoadmapWidget,\n ChangelogWidget,\n type FeedbackWidgetProps,\n type RoadmapWidgetProps,\n type ChangelogWidgetProps,\n} from './components';\n\n// Re-export functions from the base widget package\nexport { \n createFeedbackWidget,\n createRoadmapWidget,\n createChangelogWidget,\n createWidget,\n} from '@squeletteapp/widget';", "import { useEffect, useRef, useCallback } from 'react';\nimport { \n createFeedbackWidget, \n createRoadmapWidget, \n createChangelogWidget,\n createWidget\n} from '@squeletteapp/widget';\n\nexport interface WidgetOptions {\n buttonSelector: string;\n position?: 'top' | 'bottom' | 'left' | 'right';\n theme?: string;\n onLoad?: () => void;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface WidgetInstance {\n destroy: () => void;\n}\n\nexport function useFeedbackWidget(\n workspaceSlug: string,\n boardSlug: string | undefined,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useRoadmapWidget(\n workspaceSlug: string,\n boardSlug: string,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useChangelogWidget(\n workspaceSlug: string,\n options: WidgetOptions\n): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createChangelogWidget(workspaceSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n\nexport function useWidget(options: {\n url: string;\n buttonSelector: string;\n position?: 'top' | 'bottom' | 'left' | 'right';\n onLoad?: () => void;\n onOpenChange?: (isOpen: boolean) => void;\n}): WidgetInstance | null {\n const widgetRef = useRef<WidgetInstance | null>(null);\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n \n widgetRef.current = createWidget(options);\n return widgetRef.current;\n }, [options]);\n\n useEffect(() => {\n const widget = initWidget();\n \n return () => {\n if (widget) {\n widget.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}", "import React, { useId } from 'react';\nimport { useFeedbackWidget, useRoadmapWidget, useChangelogWidget, WidgetOptions } from './hooks';\n\nexport interface FeedbackWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug?: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport interface RoadmapWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport interface ChangelogWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n children: React.ReactNode;\n className?: string;\n}\n\nexport function FeedbackWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n ...options\n}: FeedbackWidgetProps) {\n const buttonId = useId();\n\n const widget = useFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}\n\nexport function RoadmapWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n ...options\n}: RoadmapWidgetProps) {\n const buttonId = useId();\n\n const widget = useRoadmapWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}\n\nexport function ChangelogWidget({\n workspaceSlug,\n children,\n className,\n ...options\n}: ChangelogWidgetProps) {\n const buttonId = useId();\n\n const widget = useChangelogWidget(workspaceSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n return (\n <button\n id={buttonId}\n className={className}\n type=\"button\"\n >\n {children}\n </button>\n );\n}"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["import_react", "import_widget"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@squeletteapp/widget-react",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"description": "React components and hooks for Squelette widgets",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc && node build.js",
|
|
20
|
+
"dev": "tsc --watch",
|
|
21
|
+
"prepublishOnly": "npm run build",
|
|
22
|
+
"publish:widget-react": "npm publish --access public"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": ">=16.8.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@squeletteapp/widget": "^0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/react": "^18.0.0",
|
|
32
|
+
"react": "^18.0.0",
|
|
33
|
+
"esbuild": "^0.21.5",
|
|
34
|
+
"typescript": "^5.8.3"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"react",
|
|
38
|
+
"widget",
|
|
39
|
+
"feedback",
|
|
40
|
+
"squelette"
|
|
41
|
+
],
|
|
42
|
+
"author": "Squelette",
|
|
43
|
+
"license": "MIT"
|
|
44
|
+
}
|