@wallavi/widget 1.3.9 → 1.4.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/index.d.mts +25 -1
- package/dist/index.d.ts +25 -1
- package/dist/index.js +15 -3
- package/dist/index.mjs +15 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -119,8 +119,32 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
|
|
|
119
119
|
* @default true
|
|
120
120
|
*/
|
|
121
121
|
autoConfig?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Hide the floating bubble button. The panel can still be opened via:
|
|
124
|
+
* - Keyboard shortcut (keyboardShortcut + shortcutKey)
|
|
125
|
+
* - Controlled mode (isOpen + onOpenChange) — connect your own button or trigger
|
|
126
|
+
* Useful when you want a custom-placed button or a purely keyboard-driven widget.
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
hideBubble?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Controlled open state. When provided the widget becomes fully controlled —
|
|
132
|
+
* the parent is responsible for managing open/close. Pair with onOpenChange.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const [chatOpen, setChatOpen] = useState(false);
|
|
136
|
+
* <button onClick={() => setChatOpen(v => !v)}>Support</button>
|
|
137
|
+
* <BubbleWidget isOpen={chatOpen} onOpenChange={setChatOpen} hideBubble ... />
|
|
138
|
+
*/
|
|
139
|
+
isOpen?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Called whenever the widget wants to change its open state
|
|
142
|
+
* (bubble click, header close button, Cmd+K, autoOpen).
|
|
143
|
+
* Use together with isOpen to fully control open/close from outside.
|
|
144
|
+
*/
|
|
145
|
+
onOpenChange?: (open: boolean) => void;
|
|
122
146
|
}
|
|
123
|
-
declare function BubbleWidget({ position: positionProp, width, height, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize, panelClassName, autoConfig, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
|
|
147
|
+
declare function BubbleWidget({ position: positionProp, width, height, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
|
|
124
148
|
|
|
125
149
|
declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
126
150
|
|
package/dist/index.d.ts
CHANGED
|
@@ -119,8 +119,32 @@ interface BubbleWidgetProps extends ChatWidgetConfig {
|
|
|
119
119
|
* @default true
|
|
120
120
|
*/
|
|
121
121
|
autoConfig?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Hide the floating bubble button. The panel can still be opened via:
|
|
124
|
+
* - Keyboard shortcut (keyboardShortcut + shortcutKey)
|
|
125
|
+
* - Controlled mode (isOpen + onOpenChange) — connect your own button or trigger
|
|
126
|
+
* Useful when you want a custom-placed button or a purely keyboard-driven widget.
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
hideBubble?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Controlled open state. When provided the widget becomes fully controlled —
|
|
132
|
+
* the parent is responsible for managing open/close. Pair with onOpenChange.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* const [chatOpen, setChatOpen] = useState(false);
|
|
136
|
+
* <button onClick={() => setChatOpen(v => !v)}>Support</button>
|
|
137
|
+
* <BubbleWidget isOpen={chatOpen} onOpenChange={setChatOpen} hideBubble ... />
|
|
138
|
+
*/
|
|
139
|
+
isOpen?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Called whenever the widget wants to change its open state
|
|
142
|
+
* (bubble click, header close button, Cmd+K, autoOpen).
|
|
143
|
+
* Use together with isOpen to fully control open/close from outside.
|
|
144
|
+
*/
|
|
145
|
+
onOpenChange?: (open: boolean) => void;
|
|
122
146
|
}
|
|
123
|
-
declare function BubbleWidget({ position: positionProp, width, height, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize, panelClassName, autoConfig, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
|
|
147
|
+
declare function BubbleWidget({ position: positionProp, width, height, expandedWidth, expandedHeight, keyboardShortcut: keyboardShortcutProp, shortcutKey, autoOpen: autoOpenProp, bubbleIconUrl: bubbleIconUrlProp, bubbleSize, panelClassName, autoConfig, hideBubble, isOpen: isOpenProp, onOpenChange, ...chatProps }: BubbleWidgetProps): react_jsx_runtime.JSX.Element;
|
|
124
148
|
|
|
125
149
|
declare function ChatWidget({ agentId, workspaceId, agentName, displayName, profilePicture, userMessageColor, initialMessages, suggestedMessages, messagePlaceholder, watermark, watermarkLogoUrl, footer, theme, showThinking, regenerateMessage, persist, onNavigate, hideCloseButton, source, userContext, playgroundOverrides, className, onClose, onReset, onExpand, expanded, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
126
150
|
|
package/dist/index.js
CHANGED
|
@@ -835,9 +835,19 @@ function BubbleWidget({
|
|
|
835
835
|
bubbleSize = 52,
|
|
836
836
|
panelClassName,
|
|
837
837
|
autoConfig = true,
|
|
838
|
+
hideBubble = false,
|
|
839
|
+
isOpen: isOpenProp,
|
|
840
|
+
onOpenChange,
|
|
838
841
|
...chatProps
|
|
839
842
|
}) {
|
|
840
|
-
const
|
|
843
|
+
const isControlled = isOpenProp !== void 0;
|
|
844
|
+
const [internalOpen, setInternalOpen] = react.useState(false);
|
|
845
|
+
const open = isControlled ? isOpenProp : internalOpen;
|
|
846
|
+
const setOpen = react.useCallback((valueOrUpdater) => {
|
|
847
|
+
const next = typeof valueOrUpdater === "function" ? valueOrUpdater(open) : valueOrUpdater;
|
|
848
|
+
if (!isControlled) setInternalOpen(next);
|
|
849
|
+
onOpenChange?.(next);
|
|
850
|
+
}, [isControlled, open, onOpenChange]);
|
|
841
851
|
const [expanded, setExpanded] = react.useState(false);
|
|
842
852
|
const panelRef = react.useRef(null);
|
|
843
853
|
const autoOpenedRef = react.useRef(false);
|
|
@@ -906,7 +916,9 @@ function BubbleWidget({
|
|
|
906
916
|
}, [open]);
|
|
907
917
|
const handleClose = () => {
|
|
908
918
|
setOpen(false);
|
|
909
|
-
|
|
919
|
+
if (!isControlled) {
|
|
920
|
+
localStorage.setItem(KEY_DISMISSED, String(Date.now() + 24 * 60 * 60 * 1e3));
|
|
921
|
+
}
|
|
910
922
|
};
|
|
911
923
|
const toggleExpanded = () => setExpanded((v) => {
|
|
912
924
|
const next = !v;
|
|
@@ -953,7 +965,7 @@ function BubbleWidget({
|
|
|
953
965
|
)
|
|
954
966
|
}
|
|
955
967
|
),
|
|
956
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
968
|
+
!hideBubble && /* @__PURE__ */ jsxRuntime.jsx(
|
|
957
969
|
"button",
|
|
958
970
|
{
|
|
959
971
|
onClick: () => setOpen((v) => !v),
|
package/dist/index.mjs
CHANGED
|
@@ -809,9 +809,19 @@ function BubbleWidget({
|
|
|
809
809
|
bubbleSize = 52,
|
|
810
810
|
panelClassName,
|
|
811
811
|
autoConfig = true,
|
|
812
|
+
hideBubble = false,
|
|
813
|
+
isOpen: isOpenProp,
|
|
814
|
+
onOpenChange,
|
|
812
815
|
...chatProps
|
|
813
816
|
}) {
|
|
814
|
-
const
|
|
817
|
+
const isControlled = isOpenProp !== void 0;
|
|
818
|
+
const [internalOpen, setInternalOpen] = useState(false);
|
|
819
|
+
const open = isControlled ? isOpenProp : internalOpen;
|
|
820
|
+
const setOpen = useCallback((valueOrUpdater) => {
|
|
821
|
+
const next = typeof valueOrUpdater === "function" ? valueOrUpdater(open) : valueOrUpdater;
|
|
822
|
+
if (!isControlled) setInternalOpen(next);
|
|
823
|
+
onOpenChange?.(next);
|
|
824
|
+
}, [isControlled, open, onOpenChange]);
|
|
815
825
|
const [expanded, setExpanded] = useState(false);
|
|
816
826
|
const panelRef = useRef(null);
|
|
817
827
|
const autoOpenedRef = useRef(false);
|
|
@@ -880,7 +890,9 @@ function BubbleWidget({
|
|
|
880
890
|
}, [open]);
|
|
881
891
|
const handleClose = () => {
|
|
882
892
|
setOpen(false);
|
|
883
|
-
|
|
893
|
+
if (!isControlled) {
|
|
894
|
+
localStorage.setItem(KEY_DISMISSED, String(Date.now() + 24 * 60 * 60 * 1e3));
|
|
895
|
+
}
|
|
884
896
|
};
|
|
885
897
|
const toggleExpanded = () => setExpanded((v) => {
|
|
886
898
|
const next = !v;
|
|
@@ -927,7 +939,7 @@ function BubbleWidget({
|
|
|
927
939
|
)
|
|
928
940
|
}
|
|
929
941
|
),
|
|
930
|
-
/* @__PURE__ */ jsx(
|
|
942
|
+
!hideBubble && /* @__PURE__ */ jsx(
|
|
931
943
|
"button",
|
|
932
944
|
{
|
|
933
945
|
onClick: () => setOpen((v) => !v),
|