@squeletteapp/widget-react 0.1.0 → 0.1.1
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/components.d.ts +10 -5
- package/dist/components.js +26 -14
- package/dist/hooks.js +83 -18
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +248 -64
- package/dist/index.esm.js.map +4 -4
- package/dist/index.js +249 -57
- package/dist/index.js.map +4 -4
- package/package.json +5 -4
package/dist/components.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { WidgetOptions } from './hooks';
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type WidgetOptions } from './hooks';
|
|
3
3
|
export interface FeedbackWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
4
4
|
workspaceSlug: string;
|
|
5
5
|
boardSlug?: string;
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
className?: string;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
8
10
|
}
|
|
9
11
|
export interface RoadmapWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
10
12
|
workspaceSlug: string;
|
|
11
13
|
boardSlug: string;
|
|
12
14
|
children: React.ReactNode;
|
|
13
15
|
className?: string;
|
|
16
|
+
asChild?: boolean;
|
|
14
17
|
}
|
|
15
18
|
export interface ChangelogWidgetProps extends Omit<WidgetOptions, 'buttonSelector'> {
|
|
16
19
|
workspaceSlug: string;
|
|
17
20
|
children: React.ReactNode;
|
|
18
21
|
className?: string;
|
|
22
|
+
asChild?: boolean;
|
|
23
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
19
24
|
}
|
|
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;
|
|
25
|
+
export declare function FeedbackWidget({ workspaceSlug, boardSlug, children, className, asChild, onOpenChange, ...options }: FeedbackWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function RoadmapWidget({ workspaceSlug, boardSlug, children, className, asChild, ...options }: RoadmapWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare function ChangelogWidget({ workspaceSlug, children, className, asChild, onOpenChange, ...options }: ChangelogWidgetProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/components.js
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useChangelogWidget, useFeedbackWidget, useRoadmapWidget, } from './hooks';
|
|
5
|
+
export function FeedbackWidget({ workspaceSlug, boardSlug, children, className, asChild = false, onOpenChange, ...options }) {
|
|
6
|
+
const buttonId = React.useId();
|
|
7
|
+
useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
7
8
|
...options,
|
|
8
9
|
buttonSelector: `#${buttonId}`,
|
|
10
|
+
onOpenChange,
|
|
9
11
|
});
|
|
10
|
-
|
|
12
|
+
if (asChild) {
|
|
13
|
+
return React.createElement(Slot, { className, id: buttonId }, children);
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("button", { className: className, id: buttonId, type: "button", children: children }));
|
|
11
16
|
}
|
|
12
|
-
export function RoadmapWidget({ workspaceSlug, boardSlug, children, className, ...options }) {
|
|
13
|
-
const buttonId = useId();
|
|
14
|
-
|
|
17
|
+
export function RoadmapWidget({ workspaceSlug, boardSlug, children, className, asChild = false, ...options }) {
|
|
18
|
+
const buttonId = React.useId();
|
|
19
|
+
useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
15
20
|
...options,
|
|
16
21
|
buttonSelector: `#${buttonId}`,
|
|
17
22
|
});
|
|
18
|
-
|
|
23
|
+
if (asChild) {
|
|
24
|
+
return React.createElement(Slot, { className, id: buttonId }, children);
|
|
25
|
+
}
|
|
26
|
+
return (_jsx("button", { className: className, id: buttonId, type: "button", children: children }));
|
|
19
27
|
}
|
|
20
|
-
export function ChangelogWidget({ workspaceSlug, children, className, ...options }) {
|
|
21
|
-
const buttonId = useId();
|
|
22
|
-
|
|
28
|
+
export function ChangelogWidget({ workspaceSlug, children, className, asChild = false, onOpenChange, ...options }) {
|
|
29
|
+
const buttonId = React.useId();
|
|
30
|
+
useChangelogWidget(workspaceSlug, {
|
|
23
31
|
...options,
|
|
24
32
|
buttonSelector: `#${buttonId}`,
|
|
33
|
+
onOpenChange,
|
|
25
34
|
});
|
|
26
|
-
|
|
35
|
+
if (asChild) {
|
|
36
|
+
return React.createElement(Slot, { className, id: buttonId }, children);
|
|
37
|
+
}
|
|
38
|
+
return (_jsx("button", { className: className, id: buttonId, type: "button", children: children }));
|
|
27
39
|
}
|
package/dist/hooks.js
CHANGED
|
@@ -1,19 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createChangelogWidget, createFeedbackWidget, createRoadmapWidget, createWidget, } from '@squeletteapp/widget';
|
|
2
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
3
3
|
export function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
4
4
|
const widgetRef = useRef(null);
|
|
5
|
+
const onOpenChangeRef = useRef(options.onOpenChange);
|
|
6
|
+
// Always keep the latest onOpenChange callback
|
|
7
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
5
8
|
const initWidget = useCallback(() => {
|
|
6
9
|
if (widgetRef.current) {
|
|
7
10
|
widgetRef.current.destroy();
|
|
8
11
|
}
|
|
9
|
-
|
|
12
|
+
const element = document.querySelector(options.buttonSelector);
|
|
13
|
+
if (!element) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, {
|
|
17
|
+
...options,
|
|
18
|
+
onOpenChange: onOpenChangeRef.current
|
|
19
|
+
? (isOpen) => { var _a; return (_a = onOpenChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenChangeRef, isOpen); }
|
|
20
|
+
: undefined,
|
|
21
|
+
});
|
|
10
22
|
return widgetRef.current;
|
|
11
|
-
}, [
|
|
23
|
+
}, [
|
|
24
|
+
workspaceSlug,
|
|
25
|
+
boardSlug,
|
|
26
|
+
options.buttonSelector,
|
|
27
|
+
options.position,
|
|
28
|
+
options.theme,
|
|
29
|
+
options.onLoad,
|
|
30
|
+
]);
|
|
12
31
|
useEffect(() => {
|
|
13
|
-
|
|
32
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
33
|
+
const frame = requestAnimationFrame(() => {
|
|
34
|
+
const widget = initWidget();
|
|
35
|
+
widgetRef.current = widget;
|
|
36
|
+
});
|
|
14
37
|
return () => {
|
|
15
|
-
|
|
16
|
-
|
|
38
|
+
cancelAnimationFrame(frame);
|
|
39
|
+
if (widgetRef.current) {
|
|
40
|
+
widgetRef.current.destroy();
|
|
17
41
|
}
|
|
18
42
|
};
|
|
19
43
|
}, [initWidget]);
|
|
@@ -25,14 +49,23 @@ export function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
|
25
49
|
if (widgetRef.current) {
|
|
26
50
|
widgetRef.current.destroy();
|
|
27
51
|
}
|
|
52
|
+
const element = document.querySelector(options.buttonSelector);
|
|
53
|
+
if (!element) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
28
56
|
widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);
|
|
29
57
|
return widgetRef.current;
|
|
30
58
|
}, [workspaceSlug, boardSlug, options]);
|
|
31
59
|
useEffect(() => {
|
|
32
|
-
|
|
60
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
61
|
+
const frame = requestAnimationFrame(() => {
|
|
62
|
+
const widget = initWidget();
|
|
63
|
+
widgetRef.current = widget;
|
|
64
|
+
});
|
|
33
65
|
return () => {
|
|
34
|
-
|
|
35
|
-
|
|
66
|
+
cancelAnimationFrame(frame);
|
|
67
|
+
if (widgetRef.current) {
|
|
68
|
+
widgetRef.current.destroy();
|
|
36
69
|
}
|
|
37
70
|
};
|
|
38
71
|
}, [initWidget]);
|
|
@@ -40,18 +73,41 @@ export function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
|
40
73
|
}
|
|
41
74
|
export function useChangelogWidget(workspaceSlug, options) {
|
|
42
75
|
const widgetRef = useRef(null);
|
|
76
|
+
const onOpenChangeRef = useRef(options.onOpenChange);
|
|
77
|
+
// Always keep the latest onOpenChange callback
|
|
78
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
43
79
|
const initWidget = useCallback(() => {
|
|
44
80
|
if (widgetRef.current) {
|
|
45
81
|
widgetRef.current.destroy();
|
|
46
82
|
}
|
|
47
|
-
|
|
83
|
+
const element = document.querySelector(options.buttonSelector);
|
|
84
|
+
if (!element) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
widgetRef.current = createChangelogWidget(workspaceSlug, {
|
|
88
|
+
...options,
|
|
89
|
+
onOpenChange: onOpenChangeRef.current
|
|
90
|
+
? (isOpen) => { var _a; return (_a = onOpenChangeRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenChangeRef, isOpen); }
|
|
91
|
+
: undefined,
|
|
92
|
+
});
|
|
48
93
|
return widgetRef.current;
|
|
49
|
-
}, [
|
|
94
|
+
}, [
|
|
95
|
+
workspaceSlug,
|
|
96
|
+
options.buttonSelector,
|
|
97
|
+
options.position,
|
|
98
|
+
options.theme,
|
|
99
|
+
options.onLoad,
|
|
100
|
+
]);
|
|
50
101
|
useEffect(() => {
|
|
51
|
-
|
|
102
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
103
|
+
const frame = requestAnimationFrame(() => {
|
|
104
|
+
const widget = initWidget();
|
|
105
|
+
widgetRef.current = widget;
|
|
106
|
+
});
|
|
52
107
|
return () => {
|
|
53
|
-
|
|
54
|
-
|
|
108
|
+
cancelAnimationFrame(frame);
|
|
109
|
+
if (widgetRef.current) {
|
|
110
|
+
widgetRef.current.destroy();
|
|
55
111
|
}
|
|
56
112
|
};
|
|
57
113
|
}, [initWidget]);
|
|
@@ -63,14 +119,23 @@ export function useWidget(options) {
|
|
|
63
119
|
if (widgetRef.current) {
|
|
64
120
|
widgetRef.current.destroy();
|
|
65
121
|
}
|
|
122
|
+
const element = document.querySelector(options.buttonSelector);
|
|
123
|
+
if (!element) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
66
126
|
widgetRef.current = createWidget(options);
|
|
67
127
|
return widgetRef.current;
|
|
68
128
|
}, [options]);
|
|
69
129
|
useEffect(() => {
|
|
70
|
-
|
|
130
|
+
// Use requestAnimationFrame to ensure DOM is ready
|
|
131
|
+
const frame = requestAnimationFrame(() => {
|
|
132
|
+
const widget = initWidget();
|
|
133
|
+
widgetRef.current = widget;
|
|
134
|
+
});
|
|
71
135
|
return () => {
|
|
72
|
-
|
|
73
|
-
|
|
136
|
+
cancelAnimationFrame(frame);
|
|
137
|
+
if (widgetRef.current) {
|
|
138
|
+
widgetRef.current.destroy();
|
|
74
139
|
}
|
|
75
140
|
};
|
|
76
141
|
}, [initWidget]);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
export { createChangelogWidget, createFeedbackWidget, createRoadmapWidget, createWidget, } from '@squeletteapp/widget';
|
|
2
|
+
export { ChangelogWidget, type ChangelogWidgetProps, FeedbackWidget, type FeedbackWidgetProps, RoadmapWidget, type RoadmapWidgetProps, } from './components';
|
|
3
|
+
export { useChangelogWidget, useFeedbackWidget, useRoadmapWidget, useWidget, type WidgetInstance, type WidgetOptions, } from './hooks';
|
package/dist/index.esm.js
CHANGED
|
@@ -1,25 +1,179 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
createChangelogWidget as createChangelogWidget2,
|
|
4
|
+
createFeedbackWidget as createFeedbackWidget2,
|
|
5
|
+
createRoadmapWidget as createRoadmapWidget2,
|
|
6
|
+
createWidget as createWidget2
|
|
7
|
+
} from "@squeletteapp/widget";
|
|
8
|
+
|
|
9
|
+
// ../../node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
10
|
+
import * as React2 from "react";
|
|
11
|
+
|
|
12
|
+
// ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
function setRef(ref, value) {
|
|
15
|
+
if (typeof ref === "function") {
|
|
16
|
+
return ref(value);
|
|
17
|
+
} else if (ref !== null && ref !== void 0) {
|
|
18
|
+
ref.current = value;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function composeRefs(...refs) {
|
|
22
|
+
return (node) => {
|
|
23
|
+
let hasCleanup = false;
|
|
24
|
+
const cleanups = refs.map((ref) => {
|
|
25
|
+
const cleanup = setRef(ref, node);
|
|
26
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
27
|
+
hasCleanup = true;
|
|
28
|
+
}
|
|
29
|
+
return cleanup;
|
|
30
|
+
});
|
|
31
|
+
if (hasCleanup) {
|
|
32
|
+
return () => {
|
|
33
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
34
|
+
const cleanup = cleanups[i];
|
|
35
|
+
if (typeof cleanup == "function") {
|
|
36
|
+
cleanup();
|
|
37
|
+
} else {
|
|
38
|
+
setRef(refs[i], null);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ../../node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
47
|
+
import { Fragment as Fragment2, jsx } from "react/jsx-runtime";
|
|
48
|
+
// @__NO_SIDE_EFFECTS__
|
|
49
|
+
function createSlot(ownerName) {
|
|
50
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
51
|
+
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
52
|
+
const { children, ...slotProps } = props;
|
|
53
|
+
const childrenArray = React2.Children.toArray(children);
|
|
54
|
+
const slottable = childrenArray.find(isSlottable);
|
|
55
|
+
if (slottable) {
|
|
56
|
+
const newElement = slottable.props.children;
|
|
57
|
+
const newChildren = childrenArray.map((child) => {
|
|
58
|
+
if (child === slottable) {
|
|
59
|
+
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
60
|
+
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
61
|
+
} else {
|
|
62
|
+
return child;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
66
|
+
}
|
|
67
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
68
|
+
});
|
|
69
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
70
|
+
return Slot2;
|
|
71
|
+
}
|
|
72
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
73
|
+
// @__NO_SIDE_EFFECTS__
|
|
74
|
+
function createSlotClone(ownerName) {
|
|
75
|
+
const SlotClone = React2.forwardRef((props, forwardedRef) => {
|
|
76
|
+
const { children, ...slotProps } = props;
|
|
77
|
+
if (React2.isValidElement(children)) {
|
|
78
|
+
const childrenRef = getElementRef(children);
|
|
79
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
80
|
+
if (children.type !== React2.Fragment) {
|
|
81
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
82
|
+
}
|
|
83
|
+
return React2.cloneElement(children, props2);
|
|
84
|
+
}
|
|
85
|
+
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
86
|
+
});
|
|
87
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
88
|
+
return SlotClone;
|
|
89
|
+
}
|
|
90
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
91
|
+
function isSlottable(child) {
|
|
92
|
+
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
93
|
+
}
|
|
94
|
+
function mergeProps(slotProps, childProps) {
|
|
95
|
+
const overrideProps = { ...childProps };
|
|
96
|
+
for (const propName in childProps) {
|
|
97
|
+
const slotPropValue = slotProps[propName];
|
|
98
|
+
const childPropValue = childProps[propName];
|
|
99
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
100
|
+
if (isHandler) {
|
|
101
|
+
if (slotPropValue && childPropValue) {
|
|
102
|
+
overrideProps[propName] = (...args) => {
|
|
103
|
+
const result = childPropValue(...args);
|
|
104
|
+
slotPropValue(...args);
|
|
105
|
+
return result;
|
|
106
|
+
};
|
|
107
|
+
} else if (slotPropValue) {
|
|
108
|
+
overrideProps[propName] = slotPropValue;
|
|
109
|
+
}
|
|
110
|
+
} else if (propName === "style") {
|
|
111
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
112
|
+
} else if (propName === "className") {
|
|
113
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { ...slotProps, ...overrideProps };
|
|
117
|
+
}
|
|
118
|
+
function getElementRef(element) {
|
|
119
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
120
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
121
|
+
if (mayWarn) {
|
|
122
|
+
return element.ref;
|
|
123
|
+
}
|
|
124
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
125
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
126
|
+
if (mayWarn) {
|
|
127
|
+
return element.props.ref;
|
|
128
|
+
}
|
|
129
|
+
return element.props.ref || element.ref;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/components.tsx
|
|
133
|
+
import * as React3 from "react";
|
|
134
|
+
|
|
1
135
|
// src/hooks.ts
|
|
2
|
-
import { useEffect, useRef, useCallback } from "react";
|
|
3
136
|
import {
|
|
137
|
+
createChangelogWidget,
|
|
4
138
|
createFeedbackWidget,
|
|
5
139
|
createRoadmapWidget,
|
|
6
|
-
createChangelogWidget,
|
|
7
140
|
createWidget
|
|
8
141
|
} from "@squeletteapp/widget";
|
|
142
|
+
import { useCallback as useCallback2, useEffect, useRef } from "react";
|
|
9
143
|
function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
10
144
|
const widgetRef = useRef(null);
|
|
11
|
-
const
|
|
145
|
+
const onOpenChangeRef = useRef(options.onOpenChange);
|
|
146
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
147
|
+
const initWidget = useCallback2(() => {
|
|
12
148
|
if (widgetRef.current) {
|
|
13
149
|
widgetRef.current.destroy();
|
|
14
150
|
}
|
|
15
|
-
|
|
151
|
+
const element = document.querySelector(options.buttonSelector);
|
|
152
|
+
if (!element) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, {
|
|
156
|
+
...options,
|
|
157
|
+
onOpenChange: onOpenChangeRef.current ? (isOpen) => onOpenChangeRef.current?.(isOpen) : void 0
|
|
158
|
+
});
|
|
16
159
|
return widgetRef.current;
|
|
17
|
-
}, [
|
|
160
|
+
}, [
|
|
161
|
+
workspaceSlug,
|
|
162
|
+
boardSlug,
|
|
163
|
+
options.buttonSelector,
|
|
164
|
+
options.position,
|
|
165
|
+
options.theme,
|
|
166
|
+
options.onLoad
|
|
167
|
+
]);
|
|
18
168
|
useEffect(() => {
|
|
19
|
-
const
|
|
169
|
+
const frame = requestAnimationFrame(() => {
|
|
170
|
+
const widget = initWidget();
|
|
171
|
+
widgetRef.current = widget;
|
|
172
|
+
});
|
|
20
173
|
return () => {
|
|
21
|
-
|
|
22
|
-
|
|
174
|
+
cancelAnimationFrame(frame);
|
|
175
|
+
if (widgetRef.current) {
|
|
176
|
+
widgetRef.current.destroy();
|
|
23
177
|
}
|
|
24
178
|
};
|
|
25
179
|
}, [initWidget]);
|
|
@@ -27,18 +181,26 @@ function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
|
27
181
|
}
|
|
28
182
|
function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
29
183
|
const widgetRef = useRef(null);
|
|
30
|
-
const initWidget =
|
|
184
|
+
const initWidget = useCallback2(() => {
|
|
31
185
|
if (widgetRef.current) {
|
|
32
186
|
widgetRef.current.destroy();
|
|
33
187
|
}
|
|
188
|
+
const element = document.querySelector(options.buttonSelector);
|
|
189
|
+
if (!element) {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
34
192
|
widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);
|
|
35
193
|
return widgetRef.current;
|
|
36
194
|
}, [workspaceSlug, boardSlug, options]);
|
|
37
195
|
useEffect(() => {
|
|
38
|
-
const
|
|
196
|
+
const frame = requestAnimationFrame(() => {
|
|
197
|
+
const widget = initWidget();
|
|
198
|
+
widgetRef.current = widget;
|
|
199
|
+
});
|
|
39
200
|
return () => {
|
|
40
|
-
|
|
41
|
-
|
|
201
|
+
cancelAnimationFrame(frame);
|
|
202
|
+
if (widgetRef.current) {
|
|
203
|
+
widgetRef.current.destroy();
|
|
42
204
|
}
|
|
43
205
|
};
|
|
44
206
|
}, [initWidget]);
|
|
@@ -46,18 +208,37 @@ function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
|
46
208
|
}
|
|
47
209
|
function useChangelogWidget(workspaceSlug, options) {
|
|
48
210
|
const widgetRef = useRef(null);
|
|
49
|
-
const
|
|
211
|
+
const onOpenChangeRef = useRef(options.onOpenChange);
|
|
212
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
213
|
+
const initWidget = useCallback2(() => {
|
|
50
214
|
if (widgetRef.current) {
|
|
51
215
|
widgetRef.current.destroy();
|
|
52
216
|
}
|
|
53
|
-
|
|
217
|
+
const element = document.querySelector(options.buttonSelector);
|
|
218
|
+
if (!element) {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
widgetRef.current = createChangelogWidget(workspaceSlug, {
|
|
222
|
+
...options,
|
|
223
|
+
onOpenChange: onOpenChangeRef.current ? (isOpen) => onOpenChangeRef.current?.(isOpen) : void 0
|
|
224
|
+
});
|
|
54
225
|
return widgetRef.current;
|
|
55
|
-
}, [
|
|
226
|
+
}, [
|
|
227
|
+
workspaceSlug,
|
|
228
|
+
options.buttonSelector,
|
|
229
|
+
options.position,
|
|
230
|
+
options.theme,
|
|
231
|
+
options.onLoad
|
|
232
|
+
]);
|
|
56
233
|
useEffect(() => {
|
|
57
|
-
const
|
|
234
|
+
const frame = requestAnimationFrame(() => {
|
|
235
|
+
const widget = initWidget();
|
|
236
|
+
widgetRef.current = widget;
|
|
237
|
+
});
|
|
58
238
|
return () => {
|
|
59
|
-
|
|
60
|
-
|
|
239
|
+
cancelAnimationFrame(frame);
|
|
240
|
+
if (widgetRef.current) {
|
|
241
|
+
widgetRef.current.destroy();
|
|
61
242
|
}
|
|
62
243
|
};
|
|
63
244
|
}, [initWidget]);
|
|
@@ -65,18 +246,26 @@ function useChangelogWidget(workspaceSlug, options) {
|
|
|
65
246
|
}
|
|
66
247
|
function useWidget(options) {
|
|
67
248
|
const widgetRef = useRef(null);
|
|
68
|
-
const initWidget =
|
|
249
|
+
const initWidget = useCallback2(() => {
|
|
69
250
|
if (widgetRef.current) {
|
|
70
251
|
widgetRef.current.destroy();
|
|
71
252
|
}
|
|
253
|
+
const element = document.querySelector(options.buttonSelector);
|
|
254
|
+
if (!element) {
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
72
257
|
widgetRef.current = createWidget(options);
|
|
73
258
|
return widgetRef.current;
|
|
74
259
|
}, [options]);
|
|
75
260
|
useEffect(() => {
|
|
76
|
-
const
|
|
261
|
+
const frame = requestAnimationFrame(() => {
|
|
262
|
+
const widget = initWidget();
|
|
263
|
+
widgetRef.current = widget;
|
|
264
|
+
});
|
|
77
265
|
return () => {
|
|
78
|
-
|
|
79
|
-
|
|
266
|
+
cancelAnimationFrame(frame);
|
|
267
|
+
if (widgetRef.current) {
|
|
268
|
+
widgetRef.current.destroy();
|
|
80
269
|
}
|
|
81
270
|
};
|
|
82
271
|
}, [initWidget]);
|
|
@@ -84,81 +273,76 @@ function useWidget(options) {
|
|
|
84
273
|
}
|
|
85
274
|
|
|
86
275
|
// src/components.tsx
|
|
87
|
-
import {
|
|
88
|
-
import { jsx } from "react/jsx-runtime";
|
|
276
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
89
277
|
function FeedbackWidget({
|
|
90
278
|
workspaceSlug,
|
|
91
279
|
boardSlug,
|
|
92
280
|
children,
|
|
93
281
|
className,
|
|
282
|
+
asChild = false,
|
|
283
|
+
onOpenChange,
|
|
94
284
|
...options
|
|
95
285
|
}) {
|
|
96
|
-
const buttonId = useId();
|
|
97
|
-
|
|
286
|
+
const buttonId = React3.useId();
|
|
287
|
+
useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
98
288
|
...options,
|
|
99
|
-
buttonSelector: `#${buttonId}
|
|
289
|
+
buttonSelector: `#${buttonId}`,
|
|
290
|
+
onOpenChange
|
|
100
291
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
id: buttonId,
|
|
105
|
-
className,
|
|
106
|
-
type: "button",
|
|
292
|
+
if (asChild) {
|
|
293
|
+
return React3.createElement(
|
|
294
|
+
Slot,
|
|
295
|
+
{ className, id: buttonId },
|
|
107
296
|
children
|
|
108
|
-
|
|
109
|
-
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
return /* @__PURE__ */ jsx2("button", { className, id: buttonId, type: "button", children });
|
|
110
300
|
}
|
|
111
301
|
function RoadmapWidget({
|
|
112
302
|
workspaceSlug,
|
|
113
303
|
boardSlug,
|
|
114
304
|
children,
|
|
115
305
|
className,
|
|
306
|
+
asChild = false,
|
|
116
307
|
...options
|
|
117
308
|
}) {
|
|
118
|
-
const buttonId = useId();
|
|
119
|
-
|
|
309
|
+
const buttonId = React3.useId();
|
|
310
|
+
useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
120
311
|
...options,
|
|
121
312
|
buttonSelector: `#${buttonId}`
|
|
122
313
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
id: buttonId,
|
|
127
|
-
className,
|
|
128
|
-
type: "button",
|
|
314
|
+
if (asChild) {
|
|
315
|
+
return React3.createElement(
|
|
316
|
+
Slot,
|
|
317
|
+
{ className, id: buttonId },
|
|
129
318
|
children
|
|
130
|
-
|
|
131
|
-
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
return /* @__PURE__ */ jsx2("button", { className, id: buttonId, type: "button", children });
|
|
132
322
|
}
|
|
133
323
|
function ChangelogWidget({
|
|
134
324
|
workspaceSlug,
|
|
135
325
|
children,
|
|
136
326
|
className,
|
|
327
|
+
asChild = false,
|
|
328
|
+
onOpenChange,
|
|
137
329
|
...options
|
|
138
330
|
}) {
|
|
139
|
-
const buttonId = useId();
|
|
140
|
-
|
|
331
|
+
const buttonId = React3.useId();
|
|
332
|
+
useChangelogWidget(workspaceSlug, {
|
|
141
333
|
...options,
|
|
142
|
-
buttonSelector: `#${buttonId}
|
|
334
|
+
buttonSelector: `#${buttonId}`,
|
|
335
|
+
onOpenChange
|
|
143
336
|
});
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
id: buttonId,
|
|
148
|
-
className,
|
|
149
|
-
type: "button",
|
|
337
|
+
if (asChild) {
|
|
338
|
+
return React3.createElement(
|
|
339
|
+
Slot,
|
|
340
|
+
{ className, id: buttonId },
|
|
150
341
|
children
|
|
151
|
-
|
|
152
|
-
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
return /* @__PURE__ */ jsx2("button", { className, id: buttonId, type: "button", children });
|
|
153
345
|
}
|
|
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
346
|
export {
|
|
163
347
|
ChangelogWidget,
|
|
164
348
|
FeedbackWidget,
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/
|
|
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,
|
|
6
|
-
"names": ["createFeedbackWidget", "createRoadmapWidget", "
|
|
3
|
+
"sources": ["../src/index.ts", "../../../node_modules/@radix-ui/react-slot/src/slot.tsx", "../../../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx", "../src/components.tsx", "../src/hooks.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n createChangelogWidget,\n createFeedbackWidget,\n createRoadmapWidget,\n createWidget,\n} from '@squeletteapp/widget';\n\nexport {\n ChangelogWidget,\n type ChangelogWidgetProps,\n FeedbackWidget,\n type FeedbackWidgetProps,\n RoadmapWidget,\n type RoadmapWidgetProps,\n} from './components';\nexport {\n useChangelogWidget,\n useFeedbackWidget,\n useRoadmapWidget,\n useWidget,\n type WidgetInstance,\n type WidgetOptions,\n} from './hooks';\n", "import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n", "import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n", "import { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport {\n useChangelogWidget,\n useFeedbackWidget,\n useRoadmapWidget,\n type WidgetOptions,\n} from './hooks';\n\nexport interface FeedbackWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug?: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface RoadmapWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n}\n\nexport interface ChangelogWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport function FeedbackWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n asChild = false,\n onOpenChange,\n ...options\n}: FeedbackWidgetProps) {\n const buttonId = React.useId();\n\n useFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n onOpenChange,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n\nexport function RoadmapWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n asChild = false,\n ...options\n}: RoadmapWidgetProps) {\n const buttonId = React.useId();\n\n useRoadmapWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n\nexport function ChangelogWidget({\n workspaceSlug,\n children,\n className,\n asChild = false,\n onOpenChange,\n ...options\n}: ChangelogWidgetProps) {\n const buttonId = React.useId();\n\n useChangelogWidget(workspaceSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n onOpenChange,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n", "import {\n createChangelogWidget,\n createFeedbackWidget,\n createRoadmapWidget,\n createWidget,\n} from '@squeletteapp/widget';\nimport { useCallback, useEffect, useRef } from 'react';\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 const onOpenChangeRef = useRef(options.onOpenChange);\n\n // Always keep the latest onOpenChange callback\n onOpenChangeRef.current = options.onOpenChange;\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n\n const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n onOpenChange: onOpenChangeRef.current\n ? (isOpen: boolean) => onOpenChangeRef.current?.(isOpen)\n : undefined,\n });\n return widgetRef.current;\n }, [\n workspaceSlug,\n boardSlug,\n options.buttonSelector,\n options.position,\n options.theme,\n options.onLoad,\n ]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const onOpenChangeRef = useRef(options.onOpenChange);\n\n // Always keep the latest onOpenChange callback\n onOpenChangeRef.current = options.onOpenChange;\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n\n const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createChangelogWidget(workspaceSlug, {\n ...options,\n onOpenChange: onOpenChangeRef.current\n ? (isOpen: boolean) => onOpenChangeRef.current?.(isOpen)\n : undefined,\n });\n return widgetRef.current;\n }, [\n workspaceSlug,\n options.buttonSelector,\n options.position,\n options.theme,\n options.onLoad,\n ]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createWidget(options);\n return widgetRef.current;\n }, [options]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACE,yBAAAA;AAAA,EACA,wBAAAC;AAAA,EACA,uBAAA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AAE7B,qBAAmB,eAAe;AAAA,IAChC,GAAG;AAAA,IACH,gBAAgB,IAAI,QAAQ;AAAA,IAC5B;AAAA,EACF,CAAC;AAED,MAAI,SAAS;AACX,WAAa;AAAA,MACX;AAAA,MACA,EAAE,WAAW,IAAI,SAAS;AAAA,MAC1B;AAAA,IACF;AAAA,EACF;AAEA,SACE,gBAAAA,KAAC,YAAO,WAAsB,IAAI,UAAU,MAAK,UAC9C,UACH;AAEJ;",
|
|
6
|
+
"names": ["createChangelogWidget", "createFeedbackWidget", "createRoadmapWidget", "createWidget", "React", "Fragment", "Slot", "props", "React", "useCallback", "jsx"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,11 +17,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
23
33
|
ChangelogWidget: () => ChangelogWidget,
|
|
24
34
|
FeedbackWidget: () => FeedbackWidget,
|
|
25
35
|
RoadmapWidget: () => RoadmapWidget,
|
|
@@ -32,25 +42,172 @@ __export(src_exports, {
|
|
|
32
42
|
useRoadmapWidget: () => useRoadmapWidget,
|
|
33
43
|
useWidget: () => useWidget
|
|
34
44
|
});
|
|
35
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(index_exports);
|
|
46
|
+
var import_widget2 = require("@squeletteapp/widget");
|
|
47
|
+
|
|
48
|
+
// ../../node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
49
|
+
var React2 = __toESM(require("react"), 1);
|
|
50
|
+
|
|
51
|
+
// ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
52
|
+
var React = __toESM(require("react"), 1);
|
|
53
|
+
function setRef(ref, value) {
|
|
54
|
+
if (typeof ref === "function") {
|
|
55
|
+
return ref(value);
|
|
56
|
+
} else if (ref !== null && ref !== void 0) {
|
|
57
|
+
ref.current = value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function composeRefs(...refs) {
|
|
61
|
+
return (node) => {
|
|
62
|
+
let hasCleanup = false;
|
|
63
|
+
const cleanups = refs.map((ref) => {
|
|
64
|
+
const cleanup = setRef(ref, node);
|
|
65
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
66
|
+
hasCleanup = true;
|
|
67
|
+
}
|
|
68
|
+
return cleanup;
|
|
69
|
+
});
|
|
70
|
+
if (hasCleanup) {
|
|
71
|
+
return () => {
|
|
72
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
73
|
+
const cleanup = cleanups[i];
|
|
74
|
+
if (typeof cleanup == "function") {
|
|
75
|
+
cleanup();
|
|
76
|
+
} else {
|
|
77
|
+
setRef(refs[i], null);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ../../node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
86
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
87
|
+
// @__NO_SIDE_EFFECTS__
|
|
88
|
+
function createSlot(ownerName) {
|
|
89
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
90
|
+
const Slot2 = React2.forwardRef((props, forwardedRef) => {
|
|
91
|
+
const { children, ...slotProps } = props;
|
|
92
|
+
const childrenArray = React2.Children.toArray(children);
|
|
93
|
+
const slottable = childrenArray.find(isSlottable);
|
|
94
|
+
if (slottable) {
|
|
95
|
+
const newElement = slottable.props.children;
|
|
96
|
+
const newChildren = childrenArray.map((child) => {
|
|
97
|
+
if (child === slottable) {
|
|
98
|
+
if (React2.Children.count(newElement) > 1) return React2.Children.only(null);
|
|
99
|
+
return React2.isValidElement(newElement) ? newElement.props.children : null;
|
|
100
|
+
} else {
|
|
101
|
+
return child;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children: React2.isValidElement(newElement) ? React2.cloneElement(newElement, void 0, newChildren) : null });
|
|
105
|
+
}
|
|
106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
107
|
+
});
|
|
108
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
109
|
+
return Slot2;
|
|
110
|
+
}
|
|
111
|
+
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
112
|
+
// @__NO_SIDE_EFFECTS__
|
|
113
|
+
function createSlotClone(ownerName) {
|
|
114
|
+
const SlotClone = React2.forwardRef((props, forwardedRef) => {
|
|
115
|
+
const { children, ...slotProps } = props;
|
|
116
|
+
if (React2.isValidElement(children)) {
|
|
117
|
+
const childrenRef = getElementRef(children);
|
|
118
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
119
|
+
if (children.type !== React2.Fragment) {
|
|
120
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
121
|
+
}
|
|
122
|
+
return React2.cloneElement(children, props2);
|
|
123
|
+
}
|
|
124
|
+
return React2.Children.count(children) > 1 ? React2.Children.only(null) : null;
|
|
125
|
+
});
|
|
126
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
127
|
+
return SlotClone;
|
|
128
|
+
}
|
|
129
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
130
|
+
function isSlottable(child) {
|
|
131
|
+
return React2.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
132
|
+
}
|
|
133
|
+
function mergeProps(slotProps, childProps) {
|
|
134
|
+
const overrideProps = { ...childProps };
|
|
135
|
+
for (const propName in childProps) {
|
|
136
|
+
const slotPropValue = slotProps[propName];
|
|
137
|
+
const childPropValue = childProps[propName];
|
|
138
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
139
|
+
if (isHandler) {
|
|
140
|
+
if (slotPropValue && childPropValue) {
|
|
141
|
+
overrideProps[propName] = (...args) => {
|
|
142
|
+
const result = childPropValue(...args);
|
|
143
|
+
slotPropValue(...args);
|
|
144
|
+
return result;
|
|
145
|
+
};
|
|
146
|
+
} else if (slotPropValue) {
|
|
147
|
+
overrideProps[propName] = slotPropValue;
|
|
148
|
+
}
|
|
149
|
+
} else if (propName === "style") {
|
|
150
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
151
|
+
} else if (propName === "className") {
|
|
152
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { ...slotProps, ...overrideProps };
|
|
156
|
+
}
|
|
157
|
+
function getElementRef(element) {
|
|
158
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
159
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
160
|
+
if (mayWarn) {
|
|
161
|
+
return element.ref;
|
|
162
|
+
}
|
|
163
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
164
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
165
|
+
if (mayWarn) {
|
|
166
|
+
return element.props.ref;
|
|
167
|
+
}
|
|
168
|
+
return element.props.ref || element.ref;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/components.tsx
|
|
172
|
+
var React3 = __toESM(require("react"), 1);
|
|
36
173
|
|
|
37
174
|
// src/hooks.ts
|
|
38
|
-
var import_react = require("react");
|
|
39
175
|
var import_widget = require("@squeletteapp/widget");
|
|
176
|
+
var import_react = require("react");
|
|
40
177
|
function useFeedbackWidget(workspaceSlug, boardSlug, options) {
|
|
41
178
|
const widgetRef = (0, import_react.useRef)(null);
|
|
179
|
+
const onOpenChangeRef = (0, import_react.useRef)(options.onOpenChange);
|
|
180
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
42
181
|
const initWidget = (0, import_react.useCallback)(() => {
|
|
43
182
|
if (widgetRef.current) {
|
|
44
183
|
widgetRef.current.destroy();
|
|
45
184
|
}
|
|
46
|
-
|
|
185
|
+
const element = document.querySelector(options.buttonSelector);
|
|
186
|
+
if (!element) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
widgetRef.current = (0, import_widget.createFeedbackWidget)(workspaceSlug, boardSlug, {
|
|
190
|
+
...options,
|
|
191
|
+
onOpenChange: onOpenChangeRef.current ? (isOpen) => onOpenChangeRef.current?.(isOpen) : void 0
|
|
192
|
+
});
|
|
47
193
|
return widgetRef.current;
|
|
48
|
-
}, [
|
|
194
|
+
}, [
|
|
195
|
+
workspaceSlug,
|
|
196
|
+
boardSlug,
|
|
197
|
+
options.buttonSelector,
|
|
198
|
+
options.position,
|
|
199
|
+
options.theme,
|
|
200
|
+
options.onLoad
|
|
201
|
+
]);
|
|
49
202
|
(0, import_react.useEffect)(() => {
|
|
50
|
-
const
|
|
203
|
+
const frame = requestAnimationFrame(() => {
|
|
204
|
+
const widget = initWidget();
|
|
205
|
+
widgetRef.current = widget;
|
|
206
|
+
});
|
|
51
207
|
return () => {
|
|
52
|
-
|
|
53
|
-
|
|
208
|
+
cancelAnimationFrame(frame);
|
|
209
|
+
if (widgetRef.current) {
|
|
210
|
+
widgetRef.current.destroy();
|
|
54
211
|
}
|
|
55
212
|
};
|
|
56
213
|
}, [initWidget]);
|
|
@@ -62,14 +219,22 @@ function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
|
62
219
|
if (widgetRef.current) {
|
|
63
220
|
widgetRef.current.destroy();
|
|
64
221
|
}
|
|
222
|
+
const element = document.querySelector(options.buttonSelector);
|
|
223
|
+
if (!element) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
65
226
|
widgetRef.current = (0, import_widget.createRoadmapWidget)(workspaceSlug, boardSlug, options);
|
|
66
227
|
return widgetRef.current;
|
|
67
228
|
}, [workspaceSlug, boardSlug, options]);
|
|
68
229
|
(0, import_react.useEffect)(() => {
|
|
69
|
-
const
|
|
230
|
+
const frame = requestAnimationFrame(() => {
|
|
231
|
+
const widget = initWidget();
|
|
232
|
+
widgetRef.current = widget;
|
|
233
|
+
});
|
|
70
234
|
return () => {
|
|
71
|
-
|
|
72
|
-
|
|
235
|
+
cancelAnimationFrame(frame);
|
|
236
|
+
if (widgetRef.current) {
|
|
237
|
+
widgetRef.current.destroy();
|
|
73
238
|
}
|
|
74
239
|
};
|
|
75
240
|
}, [initWidget]);
|
|
@@ -77,18 +242,37 @@ function useRoadmapWidget(workspaceSlug, boardSlug, options) {
|
|
|
77
242
|
}
|
|
78
243
|
function useChangelogWidget(workspaceSlug, options) {
|
|
79
244
|
const widgetRef = (0, import_react.useRef)(null);
|
|
245
|
+
const onOpenChangeRef = (0, import_react.useRef)(options.onOpenChange);
|
|
246
|
+
onOpenChangeRef.current = options.onOpenChange;
|
|
80
247
|
const initWidget = (0, import_react.useCallback)(() => {
|
|
81
248
|
if (widgetRef.current) {
|
|
82
249
|
widgetRef.current.destroy();
|
|
83
250
|
}
|
|
84
|
-
|
|
251
|
+
const element = document.querySelector(options.buttonSelector);
|
|
252
|
+
if (!element) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
widgetRef.current = (0, import_widget.createChangelogWidget)(workspaceSlug, {
|
|
256
|
+
...options,
|
|
257
|
+
onOpenChange: onOpenChangeRef.current ? (isOpen) => onOpenChangeRef.current?.(isOpen) : void 0
|
|
258
|
+
});
|
|
85
259
|
return widgetRef.current;
|
|
86
|
-
}, [
|
|
260
|
+
}, [
|
|
261
|
+
workspaceSlug,
|
|
262
|
+
options.buttonSelector,
|
|
263
|
+
options.position,
|
|
264
|
+
options.theme,
|
|
265
|
+
options.onLoad
|
|
266
|
+
]);
|
|
87
267
|
(0, import_react.useEffect)(() => {
|
|
88
|
-
const
|
|
268
|
+
const frame = requestAnimationFrame(() => {
|
|
269
|
+
const widget = initWidget();
|
|
270
|
+
widgetRef.current = widget;
|
|
271
|
+
});
|
|
89
272
|
return () => {
|
|
90
|
-
|
|
91
|
-
|
|
273
|
+
cancelAnimationFrame(frame);
|
|
274
|
+
if (widgetRef.current) {
|
|
275
|
+
widgetRef.current.destroy();
|
|
92
276
|
}
|
|
93
277
|
};
|
|
94
278
|
}, [initWidget]);
|
|
@@ -100,14 +284,22 @@ function useWidget(options) {
|
|
|
100
284
|
if (widgetRef.current) {
|
|
101
285
|
widgetRef.current.destroy();
|
|
102
286
|
}
|
|
287
|
+
const element = document.querySelector(options.buttonSelector);
|
|
288
|
+
if (!element) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
103
291
|
widgetRef.current = (0, import_widget.createWidget)(options);
|
|
104
292
|
return widgetRef.current;
|
|
105
293
|
}, [options]);
|
|
106
294
|
(0, import_react.useEffect)(() => {
|
|
107
|
-
const
|
|
295
|
+
const frame = requestAnimationFrame(() => {
|
|
296
|
+
const widget = initWidget();
|
|
297
|
+
widgetRef.current = widget;
|
|
298
|
+
});
|
|
108
299
|
return () => {
|
|
109
|
-
|
|
110
|
-
|
|
300
|
+
cancelAnimationFrame(frame);
|
|
301
|
+
if (widgetRef.current) {
|
|
302
|
+
widgetRef.current.destroy();
|
|
111
303
|
}
|
|
112
304
|
};
|
|
113
305
|
}, [initWidget]);
|
|
@@ -115,74 +307,74 @@ function useWidget(options) {
|
|
|
115
307
|
}
|
|
116
308
|
|
|
117
309
|
// src/components.tsx
|
|
118
|
-
var
|
|
119
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
310
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
120
311
|
function FeedbackWidget({
|
|
121
312
|
workspaceSlug,
|
|
122
313
|
boardSlug,
|
|
123
314
|
children,
|
|
124
315
|
className,
|
|
316
|
+
asChild = false,
|
|
317
|
+
onOpenChange,
|
|
125
318
|
...options
|
|
126
319
|
}) {
|
|
127
|
-
const buttonId =
|
|
128
|
-
|
|
320
|
+
const buttonId = React3.useId();
|
|
321
|
+
useFeedbackWidget(workspaceSlug, boardSlug, {
|
|
129
322
|
...options,
|
|
130
|
-
buttonSelector: `#${buttonId}
|
|
323
|
+
buttonSelector: `#${buttonId}`,
|
|
324
|
+
onOpenChange
|
|
131
325
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
id: buttonId,
|
|
136
|
-
className,
|
|
137
|
-
type: "button",
|
|
326
|
+
if (asChild) {
|
|
327
|
+
return React3.createElement(
|
|
328
|
+
Slot,
|
|
329
|
+
{ className, id: buttonId },
|
|
138
330
|
children
|
|
139
|
-
|
|
140
|
-
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className, id: buttonId, type: "button", children });
|
|
141
334
|
}
|
|
142
335
|
function RoadmapWidget({
|
|
143
336
|
workspaceSlug,
|
|
144
337
|
boardSlug,
|
|
145
338
|
children,
|
|
146
339
|
className,
|
|
340
|
+
asChild = false,
|
|
147
341
|
...options
|
|
148
342
|
}) {
|
|
149
|
-
const buttonId =
|
|
150
|
-
|
|
343
|
+
const buttonId = React3.useId();
|
|
344
|
+
useRoadmapWidget(workspaceSlug, boardSlug, {
|
|
151
345
|
...options,
|
|
152
346
|
buttonSelector: `#${buttonId}`
|
|
153
347
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
id: buttonId,
|
|
158
|
-
className,
|
|
159
|
-
type: "button",
|
|
348
|
+
if (asChild) {
|
|
349
|
+
return React3.createElement(
|
|
350
|
+
Slot,
|
|
351
|
+
{ className, id: buttonId },
|
|
160
352
|
children
|
|
161
|
-
|
|
162
|
-
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className, id: buttonId, type: "button", children });
|
|
163
356
|
}
|
|
164
357
|
function ChangelogWidget({
|
|
165
358
|
workspaceSlug,
|
|
166
359
|
children,
|
|
167
360
|
className,
|
|
361
|
+
asChild = false,
|
|
362
|
+
onOpenChange,
|
|
168
363
|
...options
|
|
169
364
|
}) {
|
|
170
|
-
const buttonId =
|
|
171
|
-
|
|
365
|
+
const buttonId = React3.useId();
|
|
366
|
+
useChangelogWidget(workspaceSlug, {
|
|
172
367
|
...options,
|
|
173
|
-
buttonSelector: `#${buttonId}
|
|
368
|
+
buttonSelector: `#${buttonId}`,
|
|
369
|
+
onOpenChange
|
|
174
370
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
id: buttonId,
|
|
179
|
-
className,
|
|
180
|
-
type: "button",
|
|
371
|
+
if (asChild) {
|
|
372
|
+
return React3.createElement(
|
|
373
|
+
Slot,
|
|
374
|
+
{ className, id: buttonId },
|
|
181
375
|
children
|
|
182
|
-
|
|
183
|
-
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className, id: buttonId, type: "button", children });
|
|
184
379
|
}
|
|
185
|
-
|
|
186
|
-
// src/index.ts
|
|
187
|
-
var import_widget2 = require("@squeletteapp/widget");
|
|
188
380
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "
|
|
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": "
|
|
6
|
-
"names": ["
|
|
3
|
+
"sources": ["../src/index.ts", "../../../node_modules/@radix-ui/react-slot/src/slot.tsx", "../../../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx", "../src/components.tsx", "../src/hooks.ts"],
|
|
4
|
+
"sourcesContent": ["export {\n createChangelogWidget,\n createFeedbackWidget,\n createRoadmapWidget,\n createWidget,\n} from '@squeletteapp/widget';\n\nexport {\n ChangelogWidget,\n type ChangelogWidgetProps,\n FeedbackWidget,\n type FeedbackWidgetProps,\n RoadmapWidget,\n type RoadmapWidgetProps,\n} from './components';\nexport {\n useChangelogWidget,\n useFeedbackWidget,\n useRoadmapWidget,\n useWidget,\n type WidgetInstance,\n type WidgetOptions,\n} from './hooks';\n", "import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n", "import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n", "import { Slot } from '@radix-ui/react-slot';\nimport * as React from 'react';\nimport {\n useChangelogWidget,\n useFeedbackWidget,\n useRoadmapWidget,\n type WidgetOptions,\n} from './hooks';\n\nexport interface FeedbackWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug?: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport interface RoadmapWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n boardSlug: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n}\n\nexport interface ChangelogWidgetProps\n extends Omit<WidgetOptions, 'buttonSelector'> {\n workspaceSlug: string;\n children: React.ReactNode;\n className?: string;\n asChild?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n}\n\nexport function FeedbackWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n asChild = false,\n onOpenChange,\n ...options\n}: FeedbackWidgetProps) {\n const buttonId = React.useId();\n\n useFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n onOpenChange,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n\nexport function RoadmapWidget({\n workspaceSlug,\n boardSlug,\n children,\n className,\n asChild = false,\n ...options\n}: RoadmapWidgetProps) {\n const buttonId = React.useId();\n\n useRoadmapWidget(workspaceSlug, boardSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n\nexport function ChangelogWidget({\n workspaceSlug,\n children,\n className,\n asChild = false,\n onOpenChange,\n ...options\n}: ChangelogWidgetProps) {\n const buttonId = React.useId();\n\n useChangelogWidget(workspaceSlug, {\n ...options,\n buttonSelector: `#${buttonId}`,\n onOpenChange,\n });\n\n if (asChild) {\n return React.createElement(\n Slot as any,\n { className, id: buttonId },\n children\n );\n }\n\n return (\n <button className={className} id={buttonId} type=\"button\">\n {children}\n </button>\n );\n}\n", "import {\n createChangelogWidget,\n createFeedbackWidget,\n createRoadmapWidget,\n createWidget,\n} from '@squeletteapp/widget';\nimport { useCallback, useEffect, useRef } from 'react';\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 const onOpenChangeRef = useRef(options.onOpenChange);\n\n // Always keep the latest onOpenChange callback\n onOpenChangeRef.current = options.onOpenChange;\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n\n const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createFeedbackWidget(workspaceSlug, boardSlug, {\n ...options,\n onOpenChange: onOpenChangeRef.current\n ? (isOpen: boolean) => onOpenChangeRef.current?.(isOpen)\n : undefined,\n });\n return widgetRef.current;\n }, [\n workspaceSlug,\n boardSlug,\n options.buttonSelector,\n options.position,\n options.theme,\n options.onLoad,\n ]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createRoadmapWidget(workspaceSlug, boardSlug, options);\n return widgetRef.current;\n }, [workspaceSlug, boardSlug, options]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const onOpenChangeRef = useRef(options.onOpenChange);\n\n // Always keep the latest onOpenChange callback\n onOpenChangeRef.current = options.onOpenChange;\n\n const initWidget = useCallback(() => {\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n\n const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createChangelogWidget(workspaceSlug, {\n ...options,\n onOpenChange: onOpenChangeRef.current\n ? (isOpen: boolean) => onOpenChangeRef.current?.(isOpen)\n : undefined,\n });\n return widgetRef.current;\n }, [\n workspaceSlug,\n options.buttonSelector,\n options.position,\n options.theme,\n options.onLoad,\n ]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.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 const element = document.querySelector(options.buttonSelector);\n if (!element) {\n return null;\n }\n\n widgetRef.current = createWidget(options);\n return widgetRef.current;\n }, [options]);\n\n useEffect(() => {\n // Use requestAnimationFrame to ensure DOM is ready\n const frame = requestAnimationFrame(() => {\n const widget = initWidget();\n widgetRef.current = widget;\n });\n\n return () => {\n cancelAnimationFrame(frame);\n if (widgetRef.current) {\n widgetRef.current.destroy();\n }\n };\n }, [initWidget]);\n\n return widgetRef.current;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,iBAKO;;;ACLP,IAAAC,SAAuB;;;ACAvB,YAAuB;AAQvB,SAAS,OAAU,KAAqB,OAAU;AAChD,MAAI,OAAO,QAAQ,YAAY;AAC7B,WAAO,IAAI,KAAK;EAClB,WAAW,QAAQ,QAAQ,QAAQ,QAAW;AAC5C,QAAI,UAAU;EAChB;AACF;AAMA,SAAS,eAAkB,MAA8C;AACvE,SAAO,CAAC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.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@squeletteapp/widget-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "React components and hooks for Squelette widgets",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -17,20 +17,21 @@
|
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc && node build.js",
|
|
20
|
-
"dev": "
|
|
20
|
+
"dev": "node dev.js",
|
|
21
21
|
"prepublishOnly": "npm run build",
|
|
22
|
+
"publish": "npm publish --access public",
|
|
22
23
|
"publish:widget-react": "npm publish --access public"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
26
|
"react": ">=16.8.0"
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@squeletteapp/widget": "
|
|
29
|
+
"@squeletteapp/widget": "workspace:*"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/react": "^18.0.0",
|
|
32
33
|
"react": "^18.0.0",
|
|
33
|
-
"esbuild": "^0.
|
|
34
|
+
"esbuild": "^0.25.8",
|
|
34
35
|
"typescript": "^5.8.3"
|
|
35
36
|
},
|
|
36
37
|
"keywords": [
|