@kelet-ai/feedback-ui 1.2.0 → 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/dist/components/vote-feedback.d.ts +2 -1
- package/dist/feedback-ui.es.js +33 -11
- package/dist/feedback-ui.es.js.map +1 -1
- package/dist/feedback-ui.es.min.js +617 -601
- package/dist/feedback-ui.es.min.js.map +1 -1
- package/dist/feedback-ui.umd.js +32 -10
- package/dist/feedback-ui.umd.js.map +1 -1
- package/dist/feedback-ui.umd.min.js +10 -10
- package/dist/feedback-ui.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/feedback-ui.umd.js
CHANGED
|
@@ -578,6 +578,11 @@
|
|
|
578
578
|
setVote(null);
|
|
579
579
|
setTimeout(() => triggerRef.current?.focus(), 0);
|
|
580
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]);
|
|
581
586
|
const handleUpvote = require$$0$1.useCallback(async () => {
|
|
582
587
|
setVote("upvote");
|
|
583
588
|
const data = {
|
|
@@ -676,9 +681,7 @@
|
|
|
676
681
|
const handleKeyDown = require$$0$1.useCallback(
|
|
677
682
|
(e) => {
|
|
678
683
|
if (e.key === "Escape") {
|
|
679
|
-
|
|
680
|
-
setFeedbackText(defaultText);
|
|
681
|
-
triggerRef.current?.focus();
|
|
684
|
+
closePopover();
|
|
682
685
|
} else if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
683
686
|
e.preventDefault();
|
|
684
687
|
handleSubmit().then((_) => {
|
|
@@ -701,7 +704,7 @@
|
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
706
|
},
|
|
704
|
-
[handleSubmit, showPopover, popoverId,
|
|
707
|
+
[handleSubmit, showPopover, popoverId, closePopover]
|
|
705
708
|
);
|
|
706
709
|
const contextValue = {
|
|
707
710
|
onFeedback: handler,
|
|
@@ -717,6 +720,7 @@
|
|
|
717
720
|
handleTextareaChange,
|
|
718
721
|
handleSubmit,
|
|
719
722
|
handleKeyDown,
|
|
723
|
+
closePopover,
|
|
720
724
|
textareaRef,
|
|
721
725
|
triggerRef,
|
|
722
726
|
popoverId,
|
|
@@ -806,7 +810,25 @@
|
|
|
806
810
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { ...slotProps, children: typeof children === "function" ? children({ isSelected }) : children });
|
|
807
811
|
};
|
|
808
812
|
const Popover = ({ asChild, children, ...props }) => {
|
|
809
|
-
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]);
|
|
810
832
|
if (!showPopover) {
|
|
811
833
|
return null;
|
|
812
834
|
}
|
|
@@ -822,14 +844,14 @@
|
|
|
822
844
|
};
|
|
823
845
|
if (asChild && require$$0$1.isValidElement(children)) {
|
|
824
846
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
825
|
-
require$$0$1.cloneElement(
|
|
826
|
-
children,
|
|
827
|
-
|
|
828
|
-
),
|
|
847
|
+
require$$0$1.cloneElement(children, {
|
|
848
|
+
...mergeProps(slotProps, children.props),
|
|
849
|
+
ref: containerRef
|
|
850
|
+
}),
|
|
829
851
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
|
|
830
852
|
] });
|
|
831
853
|
}
|
|
832
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...slotProps, children: [
|
|
854
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: containerRef, ...slotProps, children: [
|
|
833
855
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
|
|
834
856
|
children
|
|
835
857
|
] });
|