@wallavi/widget 1.4.2 → 1.4.3
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/index.js +15 -3
- package/dist/index.mjs +15 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -850,9 +850,21 @@ function BubbleWidget({
|
|
|
850
850
|
const [internalOpen, setInternalOpen] = react.useState(false);
|
|
851
851
|
const open = isControlled ? isOpenProp : internalOpen;
|
|
852
852
|
const setOpen = react.useCallback((valueOrUpdater) => {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
853
|
+
if (!isControlled) {
|
|
854
|
+
if (typeof valueOrUpdater === "function") {
|
|
855
|
+
setInternalOpen((prev) => {
|
|
856
|
+
const next = valueOrUpdater(prev);
|
|
857
|
+
onOpenChange?.(next);
|
|
858
|
+
return next;
|
|
859
|
+
});
|
|
860
|
+
} else {
|
|
861
|
+
setInternalOpen(valueOrUpdater);
|
|
862
|
+
onOpenChange?.(valueOrUpdater);
|
|
863
|
+
}
|
|
864
|
+
} else {
|
|
865
|
+
const next = typeof valueOrUpdater === "function" ? valueOrUpdater(open) : valueOrUpdater;
|
|
866
|
+
onOpenChange?.(next);
|
|
867
|
+
}
|
|
856
868
|
}, [isControlled, open, onOpenChange]);
|
|
857
869
|
const [expanded, setExpanded] = react.useState(false);
|
|
858
870
|
const panelRef = react.useRef(null);
|
package/dist/index.mjs
CHANGED
|
@@ -824,9 +824,21 @@ function BubbleWidget({
|
|
|
824
824
|
const [internalOpen, setInternalOpen] = useState(false);
|
|
825
825
|
const open = isControlled ? isOpenProp : internalOpen;
|
|
826
826
|
const setOpen = useCallback((valueOrUpdater) => {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
827
|
+
if (!isControlled) {
|
|
828
|
+
if (typeof valueOrUpdater === "function") {
|
|
829
|
+
setInternalOpen((prev) => {
|
|
830
|
+
const next = valueOrUpdater(prev);
|
|
831
|
+
onOpenChange?.(next);
|
|
832
|
+
return next;
|
|
833
|
+
});
|
|
834
|
+
} else {
|
|
835
|
+
setInternalOpen(valueOrUpdater);
|
|
836
|
+
onOpenChange?.(valueOrUpdater);
|
|
837
|
+
}
|
|
838
|
+
} else {
|
|
839
|
+
const next = typeof valueOrUpdater === "function" ? valueOrUpdater(open) : valueOrUpdater;
|
|
840
|
+
onOpenChange?.(next);
|
|
841
|
+
}
|
|
830
842
|
}, [isControlled, open, onOpenChange]);
|
|
831
843
|
const [expanded, setExpanded] = useState(false);
|
|
832
844
|
const panelRef = useRef(null);
|