@xapp/chat-widget 1.78.0 → 1.78.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/ChatButton/ChatButton.stories.d.ts +7 -0
- package/dist/components/CtaBubble/CtaBubble.d.ts +0 -0
- package/dist/components/CtaBubble/CtaBubble.stories.d.ts +2 -0
- package/dist/components/CtaBubble/CtaBubbleContainer.d.ts +0 -0
- package/dist/index.css +1 -1
- package/dist/index.es.js +24 -6
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +24 -6
- package/dist/index.js.map +1 -1
- package/dist/xapp-chat-widget.css +1 -1
- package/dist/xapp-chat-widget.js +1 -1
- package/dist/xapp-chat-widget.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -680,6 +680,12 @@ var CtaBubble = function (props) {
|
|
|
680
680
|
var _e = useDimensions(), ref = _e[0], rect = _e[1];
|
|
681
681
|
var animate = props.animate || false;
|
|
682
682
|
var animation = animate && props.buttonAnimation === "bounce" ? "bounce" : "none";
|
|
683
|
+
var handleDismiss = function (e) {
|
|
684
|
+
e.stopPropagation();
|
|
685
|
+
if (props.onDismiss) {
|
|
686
|
+
props.onDismiss();
|
|
687
|
+
}
|
|
688
|
+
};
|
|
683
689
|
return (React$1.createElement("div", { ref: ref, style: {
|
|
684
690
|
border: props.borderStyle ? 'solid' : 'none',
|
|
685
691
|
borderWidth: ((_a = props.borderStyle) === null || _a === void 0 ? void 0 : _a.width) || '0px',
|
|
@@ -687,11 +693,14 @@ var CtaBubble = function (props) {
|
|
|
687
693
|
animation: "".concat(animation, " 1s infinite"),
|
|
688
694
|
}, className: "cta-bubble", onClick: props.onClick },
|
|
689
695
|
React$1.createElement(CtaBubbleTail, { width: (_c = rect === null || rect === void 0 ? void 0 : rect.width) !== null && _c !== void 0 ? _c : 0, height: (_d = rect === null || rect === void 0 ? void 0 : rect.height) !== null && _d !== void 0 ? _d : 0, direction: 60, angle: 45, length: 16 }),
|
|
690
|
-
React$1.createElement("div", { className: "cta-bubble__content" }, props.children)
|
|
696
|
+
React$1.createElement("div", { className: "cta-bubble__content" }, props.children),
|
|
697
|
+
props.dismissible && (React$1.createElement("button", { className: "cta-bubble__dismiss", onClick: handleDismiss, "aria-label": "Dismiss" },
|
|
698
|
+
React$1.createElement("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
|
|
699
|
+
React$1.createElement("path", { d: "M11 1L1 11M1 1L11 11", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }))))));
|
|
691
700
|
};
|
|
692
701
|
|
|
693
702
|
var CtaBubbleContainer = function (props) {
|
|
694
|
-
var visible = props.visible, timeout = props.timeout, delay = props.delay, animate = props.animate, buttonAnimation = props.buttonAnimation, onClick = props.onClick, children = props.children;
|
|
703
|
+
var visible = props.visible, timeout = props.timeout, delay = props.delay, animate = props.animate, buttonAnimation = props.buttonAnimation, dismissible = props.dismissible, onClick = props.onClick, onDismiss = props.onDismiss, children = props.children;
|
|
695
704
|
var startTime = React$1.useMemo(function () {
|
|
696
705
|
return visible ? new Date().valueOf() : undefined;
|
|
697
706
|
}, [visible]);
|
|
@@ -728,7 +737,13 @@ var CtaBubbleContainer = function (props) {
|
|
|
728
737
|
isMounted.current = false;
|
|
729
738
|
};
|
|
730
739
|
}, [startTime, timeout, delay]);
|
|
731
|
-
|
|
740
|
+
var handleDismiss = function () {
|
|
741
|
+
setShowBubble(false);
|
|
742
|
+
if (onDismiss) {
|
|
743
|
+
onDismiss();
|
|
744
|
+
}
|
|
745
|
+
};
|
|
746
|
+
return (React$1.createElement(React$1.Fragment, null, visible && showBubble && (React$1.createElement(CtaBubble, { onClick: onClick, animate: animate, buttonAnimation: buttonAnimation, dismissible: dismissible, onDismiss: handleDismiss }, children))));
|
|
732
747
|
};
|
|
733
748
|
|
|
734
749
|
var ChatButton = function (_a) {
|
|
@@ -749,9 +764,12 @@ var ChatButton = function (_a) {
|
|
|
749
764
|
};
|
|
750
765
|
var configToApply = getConfigToApply();
|
|
751
766
|
React$1.useEffect(function () {
|
|
767
|
+
var _a;
|
|
752
768
|
var delayTimer;
|
|
753
769
|
var timeoutTimer;
|
|
754
|
-
|
|
770
|
+
// Use animationDelay if provided, otherwise fall back to delay for backwards compatibility
|
|
771
|
+
var animationDelayToUse = (_a = configToApply === null || configToApply === void 0 ? void 0 : configToApply.animationDelay) !== null && _a !== void 0 ? _a : configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay;
|
|
772
|
+
if (animationDelayToUse) {
|
|
755
773
|
// Set a delay for the animation to start
|
|
756
774
|
delayTimer = setTimeout(function () {
|
|
757
775
|
setAnimate(true);
|
|
@@ -761,7 +779,7 @@ var ChatButton = function (_a) {
|
|
|
761
779
|
setAnimate(false);
|
|
762
780
|
}, configToApply.animationTimeout);
|
|
763
781
|
}
|
|
764
|
-
},
|
|
782
|
+
}, animationDelayToUse);
|
|
765
783
|
}
|
|
766
784
|
else if (configToApply === null || configToApply === void 0 ? void 0 : configToApply.animationTimeout) {
|
|
767
785
|
// Start animation immediately and set a timeout to stop it
|
|
@@ -815,7 +833,7 @@ var ChatButton = function (_a) {
|
|
|
815
833
|
React$1.createElement("svg", { width: svgSize, height: svgSize, viewBox: "0 0 22 22" },
|
|
816
834
|
React$1.createElement("path", { d: "M13 22l-4-6H2c-1.11-.043-2-.935-2-2V2C0 .89.89 0 2 0h18c1.11 0 2 .892 2 2v12c0 1.067-.89 1.957-2 2h-3l-4 6zm3-8h4c-.005.3-.01-12 0-12-.01.004-18 .006-18 0 .005.006 0 12 0 12h8l3 5 3-5z", fill: "#FFF", fillRule: "evenodd" })))),
|
|
817
835
|
configToApply && configToApply.message && (React$1.createElement("div", { className: "xapp-chat-button__cta" },
|
|
818
|
-
React$1.createElement(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, visible: !visible /** Why is this !visible */ }, configToApply === null || configToApply === void 0 ? void 0 : configToApply.message)))));
|
|
836
|
+
React$1.createElement(CtaBubbleContainer, { timeout: configToApply === null || configToApply === void 0 ? void 0 : configToApply.timeout, delay: configToApply === null || configToApply === void 0 ? void 0 : configToApply.delay, animate: animate, buttonAnimation: animation, dismissible: configToApply === null || configToApply === void 0 ? void 0 : configToApply.dismissible, visible: !visible /** Why is this !visible */ }, configToApply === null || configToApply === void 0 ? void 0 : configToApply.message)))));
|
|
819
837
|
};
|
|
820
838
|
|
|
821
839
|
var ChatCard = function (props) {
|