@kelet-ai/feedback-ui 1.1.4 → 1.3.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 +70 -0
- package/dist/components/vote-feedback.d.ts +2 -1
- package/dist/contexts/kelet.d.ts +20 -0
- package/dist/feedback-ui.es.js +37 -13
- package/dist/feedback-ui.es.js.map +1 -1
- package/dist/feedback-ui.es.min.js +667 -650
- package/dist/feedback-ui.es.min.js.map +1 -1
- package/dist/feedback-ui.umd.js +35 -11
- package/dist/feedback-ui.umd.js.map +1 -1
- package/dist/feedback-ui.umd.min.js +11 -11
- package/dist/feedback-ui.umd.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/feedback-ui.umd.js
CHANGED
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
}
|
|
447
447
|
return context;
|
|
448
448
|
};
|
|
449
|
-
const
|
|
449
|
+
const useKeletSignal = () => {
|
|
450
450
|
const context = require$$0$1.useContext(KeletContext);
|
|
451
451
|
if (!context) {
|
|
452
452
|
console.warn(
|
|
@@ -458,6 +458,7 @@
|
|
|
458
458
|
return context.feedback;
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
|
+
const useDefaultFeedbackHandler = useKeletSignal;
|
|
461
462
|
const KeletProvider = ({ apiKey, project, baseUrl, children }) => {
|
|
462
463
|
require$$0$1.useEffect(() => {
|
|
463
464
|
initEventCapture();
|
|
@@ -577,6 +578,11 @@
|
|
|
577
578
|
setVote(null);
|
|
578
579
|
setTimeout(() => triggerRef.current?.focus(), 0);
|
|
579
580
|
}, [session_id, defaultText]);
|
|
581
|
+
const closePopover = require$$0$1.useCallback(() => {
|
|
582
|
+
setShowPopover(false);
|
|
583
|
+
setFeedbackText(defaultText);
|
|
584
|
+
setTimeout(() => triggerRef.current?.focus(), 0);
|
|
585
|
+
}, [defaultText]);
|
|
580
586
|
const handleUpvote = require$$0$1.useCallback(async () => {
|
|
581
587
|
setVote("upvote");
|
|
582
588
|
const data = {
|
|
@@ -675,9 +681,7 @@
|
|
|
675
681
|
const handleKeyDown = require$$0$1.useCallback(
|
|
676
682
|
(e) => {
|
|
677
683
|
if (e.key === "Escape") {
|
|
678
|
-
|
|
679
|
-
setFeedbackText(defaultText);
|
|
680
|
-
triggerRef.current?.focus();
|
|
684
|
+
closePopover();
|
|
681
685
|
} else if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
682
686
|
e.preventDefault();
|
|
683
687
|
handleSubmit().then((_) => {
|
|
@@ -700,7 +704,7 @@
|
|
|
700
704
|
}
|
|
701
705
|
}
|
|
702
706
|
},
|
|
703
|
-
[handleSubmit, showPopover, popoverId,
|
|
707
|
+
[handleSubmit, showPopover, popoverId, closePopover]
|
|
704
708
|
);
|
|
705
709
|
const contextValue = {
|
|
706
710
|
onFeedback: handler,
|
|
@@ -716,6 +720,7 @@
|
|
|
716
720
|
handleTextareaChange,
|
|
717
721
|
handleSubmit,
|
|
718
722
|
handleKeyDown,
|
|
723
|
+
closePopover,
|
|
719
724
|
textareaRef,
|
|
720
725
|
triggerRef,
|
|
721
726
|
popoverId,
|
|
@@ -805,7 +810,25 @@
|
|
|
805
810
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { ...slotProps, children: typeof children === "function" ? children({ isSelected }) : children });
|
|
806
811
|
};
|
|
807
812
|
const Popover = ({ asChild, children, ...props }) => {
|
|
808
|
-
const {
|
|
813
|
+
const {
|
|
814
|
+
showPopover,
|
|
815
|
+
closePopover,
|
|
816
|
+
handleKeyDown,
|
|
817
|
+
popoverId,
|
|
818
|
+
triggerId,
|
|
819
|
+
triggerRef
|
|
820
|
+
} = useVoteFeedbackContext();
|
|
821
|
+
const containerRef = require$$0$1.useRef(null);
|
|
822
|
+
require$$0$1.useEffect(() => {
|
|
823
|
+
if (!showPopover) return;
|
|
824
|
+
const handleMouseDown = (event) => {
|
|
825
|
+
if (containerRef.current && !containerRef.current.contains(event.target) && !triggerRef.current?.contains(event.target)) {
|
|
826
|
+
closePopover();
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
830
|
+
return () => document.removeEventListener("mousedown", handleMouseDown);
|
|
831
|
+
}, [showPopover, closePopover, triggerRef]);
|
|
809
832
|
if (!showPopover) {
|
|
810
833
|
return null;
|
|
811
834
|
}
|
|
@@ -821,14 +844,14 @@
|
|
|
821
844
|
};
|
|
822
845
|
if (asChild && require$$0$1.isValidElement(children)) {
|
|
823
846
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
824
|
-
require$$0$1.cloneElement(
|
|
825
|
-
children,
|
|
826
|
-
|
|
827
|
-
),
|
|
847
|
+
require$$0$1.cloneElement(children, {
|
|
848
|
+
...mergeProps(slotProps, children.props),
|
|
849
|
+
ref: containerRef
|
|
850
|
+
}),
|
|
828
851
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
|
|
829
852
|
] });
|
|
830
853
|
}
|
|
831
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...slotProps, children: [
|
|
854
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: containerRef, ...slotProps, children: [
|
|
832
855
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
|
|
833
856
|
children
|
|
834
857
|
] });
|
|
@@ -2278,6 +2301,7 @@
|
|
|
2278
2301
|
exports2.useDefaultFeedbackHandler = useDefaultFeedbackHandler;
|
|
2279
2302
|
exports2.useFeedbackState = useFeedbackState;
|
|
2280
2303
|
exports2.useKelet = useKelet;
|
|
2304
|
+
exports2.useKeletSignal = useKeletSignal;
|
|
2281
2305
|
Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
|
|
2282
2306
|
});
|
|
2283
2307
|
//# sourceMappingURL=feedback-ui.umd.js.map
|