@xapp/stentor-chat-widget 1.82.1 → 1.85.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.
@@ -0,0 +1,287 @@
1
+ /*! Copyright (c) 2021, XAPPmedia */
2
+ /**
3
+ * Types of buttons available in the Action Bar
4
+ */
5
+ export type ActionBarButtonType = "chat" | "form" | "schedule" | "phone" | "email" | "url" | "help" | "payment";
6
+ /**
7
+ * Available built-in icons for Action Bar buttons.
8
+ * Can be used independently of button type via the `icon` property.
9
+ * Matches the GraphQL schema ActionBarIconType enum.
10
+ */
11
+ export type ActionBarIconType = "calendar" | "chat" | "custom" | "email" | "help" | "link" | "payment" | "phone" | "form" | "schedule" | "url";
12
+ /**
13
+ * Visibility configuration for responsive display
14
+ */
15
+ export type ActionBarButtonVisibility = "all" | "mobile-only" | "desktop-only";
16
+ /**
17
+ * Horizontal positioning for the action bar on desktop/tablet
18
+ */
19
+ export type ActionBarPosition = "left" | "center" | "right";
20
+ /**
21
+ * Base configuration shared by all button types
22
+ */
23
+ export interface ActionBarButtonBase {
24
+ /**
25
+ * Unique identifier for the button
26
+ */
27
+ readonly id: string;
28
+ /**
29
+ * The type of action this button performs
30
+ */
31
+ readonly type: ActionBarButtonType;
32
+ /**
33
+ * Optional label text to display below the icon.
34
+ * When undefined, only the icon is shown.
35
+ */
36
+ readonly label?: string;
37
+ /**
38
+ * Override the default icon with a different built-in icon.
39
+ * This allows using any icon regardless of button type.
40
+ * Takes precedence over type-based icon, but iconUrl takes precedence over this.
41
+ */
42
+ readonly icon?: ActionBarIconType;
43
+ /**
44
+ * Custom icon URL. If not provided, a default icon for the button type is used.
45
+ * Takes precedence over both `icon` and type-based icon.
46
+ */
47
+ readonly iconUrl?: string;
48
+ /**
49
+ * Control which devices show this button.
50
+ * @default "all"
51
+ */
52
+ readonly visibility?: ActionBarButtonVisibility;
53
+ /**
54
+ * Tab index for keyboard navigation accessibility.
55
+ */
56
+ readonly tabIndex?: number;
57
+ }
58
+ /**
59
+ * Chat button - opens the chat widget (existing behavior)
60
+ */
61
+ export interface ActionBarChatButton extends ActionBarButtonBase {
62
+ readonly type: "chat";
63
+ }
64
+ /**
65
+ * Form configuration for dedicated form-widget instance
66
+ */
67
+ export interface ActionBarFormConfig {
68
+ readonly api: {
69
+ readonly url: string;
70
+ readonly key?: string;
71
+ };
72
+ readonly intentId?: string;
73
+ readonly autoGreeting?: string;
74
+ readonly googleMapsApiKey?: string;
75
+ readonly mapsBaseUrl?: string;
76
+ }
77
+ /**
78
+ * Form button configuration - opens form-widget in a modal overlay.
79
+ * Supports two modes:
80
+ * 1. Dedicated form config (formConfig) - uses separate API/settings
81
+ * 2. Shared chat-widget settings (intentId) - leverages existing connection
82
+ */
83
+ export interface ActionBarFormButton extends ActionBarButtonBase {
84
+ readonly type: "form";
85
+ /**
86
+ * Dedicated form widget configuration.
87
+ * When provided, the form operates independently with its own API settings.
88
+ */
89
+ readonly formConfig?: ActionBarFormConfig;
90
+ /**
91
+ * Intent ID to trigger when using shared chat-widget connection.
92
+ * Used when formConfig is not provided.
93
+ */
94
+ readonly intentId?: string;
95
+ /**
96
+ * Auto-greeting query when using shared chat-widget connection.
97
+ * Used when formConfig is not provided.
98
+ */
99
+ readonly autoGreeting?: string;
100
+ /**
101
+ * Label of a chip to auto-select after the form loads.
102
+ * If the first step of the form contains chips, the form will
103
+ * automatically click the chip matching this label.
104
+ */
105
+ readonly preselectChipLabel?: string;
106
+ }
107
+ /**
108
+ * Schedule/Book button configuration - opens form-widget for scheduling.
109
+ * Uses the same form-widget infrastructure but with a calendar-themed icon.
110
+ * Supports two modes:
111
+ * 1. Dedicated form config (formConfig) - uses separate API/settings
112
+ * 2. Shared chat-widget settings (intentId) - leverages existing connection
113
+ */
114
+ export interface ActionBarScheduleButton extends ActionBarButtonBase {
115
+ readonly type: "schedule";
116
+ /**
117
+ * Dedicated form widget configuration.
118
+ * When provided, the form operates independently with its own API settings.
119
+ */
120
+ readonly formConfig?: ActionBarFormConfig;
121
+ /**
122
+ * Intent ID to trigger when using shared chat-widget connection.
123
+ * Used when formConfig is not provided.
124
+ */
125
+ readonly intentId?: string;
126
+ /**
127
+ * Auto-greeting query when using shared chat-widget connection.
128
+ * Used when formConfig is not provided.
129
+ */
130
+ readonly autoGreeting?: string;
131
+ /**
132
+ * Label of a chip to auto-select after the form loads.
133
+ * If the first step of the form contains chips, the form will
134
+ * automatically click the chip matching this label.
135
+ */
136
+ readonly preselectChipLabel?: string;
137
+ }
138
+ /**
139
+ * Phone button - click-to-call with tel: link
140
+ */
141
+ export interface ActionBarPhoneButton extends ActionBarButtonBase {
142
+ readonly type: "phone";
143
+ /**
144
+ * Phone number to call (will be formatted as tel: link)
145
+ */
146
+ readonly phoneNumber: string;
147
+ }
148
+ /**
149
+ * Email button - click-to-email with mailto: link
150
+ */
151
+ export interface ActionBarEmailButton extends ActionBarButtonBase {
152
+ readonly type: "email";
153
+ /**
154
+ * Email address (will be formatted as mailto: link)
155
+ */
156
+ readonly emailAddress: string;
157
+ /**
158
+ * Optional subject line for the email
159
+ */
160
+ readonly subject?: string;
161
+ /**
162
+ * Optional body text for the email
163
+ */
164
+ readonly body?: string;
165
+ }
166
+ /**
167
+ * Help button - links to documentation or help center
168
+ * Uses the URL button infrastructure with a help-themed icon
169
+ */
170
+ export interface ActionBarHelpButton extends ActionBarButtonBase {
171
+ readonly type: "help";
172
+ /**
173
+ * URL to the help center or documentation
174
+ */
175
+ readonly url: string;
176
+ /**
177
+ * How the URL should be opened
178
+ * @default "newTab"
179
+ */
180
+ readonly target?: ActionBarUrlTarget;
181
+ }
182
+ /**
183
+ * Payment button - links to payment portal
184
+ * Uses the URL button infrastructure with a payment-themed icon
185
+ */
186
+ export interface ActionBarPaymentButton extends ActionBarButtonBase {
187
+ readonly type: "payment";
188
+ /**
189
+ * URL to the payment portal
190
+ */
191
+ readonly url: string;
192
+ /**
193
+ * How the URL should be opened
194
+ * @default "newTab"
195
+ */
196
+ readonly target?: ActionBarUrlTarget;
197
+ }
198
+ /**
199
+ * URL target behavior type
200
+ */
201
+ export type ActionBarUrlTarget = "sameWindow" | "newWindow" | "newTab";
202
+ /**
203
+ * URL button - opens an arbitrary hyperlink
204
+ */
205
+ export interface ActionBarUrlButton extends ActionBarButtonBase {
206
+ readonly type: "url";
207
+ /**
208
+ * URL to open when clicked
209
+ */
210
+ readonly url: string;
211
+ /**
212
+ * How the URL should be opened
213
+ * @default "newTab"
214
+ */
215
+ readonly target?: ActionBarUrlTarget;
216
+ /**
217
+ * Window dimensions when target is "newWindow"
218
+ */
219
+ readonly windowOptions?: {
220
+ readonly width?: number;
221
+ readonly height?: number;
222
+ };
223
+ }
224
+ /**
225
+ * Union type of all button configurations
226
+ */
227
+ export type ActionBarButton = ActionBarChatButton | ActionBarFormButton | ActionBarScheduleButton | ActionBarPhoneButton | ActionBarEmailButton | ActionBarUrlButton | ActionBarHelpButton | ActionBarPaymentButton;
228
+ /**
229
+ * Main Action Bar configuration.
230
+ * When enabled, replaces the default ChatButton with a configurable dock
231
+ * of action buttons.
232
+ */
233
+ export interface ActionBarConfig {
234
+ /**
235
+ * Enable the action bar (replaces ChatButton when true)
236
+ * @default false
237
+ */
238
+ readonly enabled: boolean;
239
+ /**
240
+ * Array of buttons to display in the action bar.
241
+ * Buttons are rendered in order from left to right.
242
+ */
243
+ readonly buttons: readonly ActionBarButton[];
244
+ /**
245
+ * Horizontal position of the action bar on desktop/tablet.
246
+ * On mobile, the bar is always full-width at the bottom.
247
+ * @default "right"
248
+ */
249
+ readonly position?: ActionBarPosition;
250
+ /**
251
+ * Screen width breakpoint (in pixels) below which mobile layout is applied.
252
+ * @default 768
253
+ */
254
+ readonly mobileBreakpoint?: number;
255
+ }
256
+ /**
257
+ * Type guard for ActionBarChatButton
258
+ */
259
+ export declare function isActionBarChatButton(button: ActionBarButton): button is ActionBarChatButton;
260
+ /**
261
+ * Type guard for ActionBarFormButton
262
+ */
263
+ export declare function isActionBarFormButton(button: ActionBarButton): button is ActionBarFormButton;
264
+ /**
265
+ * Type guard for ActionBarScheduleButton
266
+ */
267
+ export declare function isActionBarScheduleButton(button: ActionBarButton): button is ActionBarScheduleButton;
268
+ /**
269
+ * Type guard for ActionBarPhoneButton
270
+ */
271
+ export declare function isActionBarPhoneButton(button: ActionBarButton): button is ActionBarPhoneButton;
272
+ /**
273
+ * Type guard for ActionBarUrlButton
274
+ */
275
+ export declare function isActionBarUrlButton(button: ActionBarButton): button is ActionBarUrlButton;
276
+ /**
277
+ * Type guard for ActionBarEmailButton
278
+ */
279
+ export declare function isActionBarEmailButton(button: ActionBarButton): button is ActionBarEmailButton;
280
+ /**
281
+ * Type guard for ActionBarHelpButton
282
+ */
283
+ export declare function isActionBarHelpButton(button: ActionBarButton): button is ActionBarHelpButton;
284
+ /**
285
+ * Type guard for ActionBarPaymentButton
286
+ */
287
+ export declare function isActionBarPaymentButton(button: ActionBarButton): button is ActionBarPaymentButton;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*! Copyright (c) 2021, XAPPmedia */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.isActionBarChatButton = isActionBarChatButton;
5
+ exports.isActionBarFormButton = isActionBarFormButton;
6
+ exports.isActionBarScheduleButton = isActionBarScheduleButton;
7
+ exports.isActionBarPhoneButton = isActionBarPhoneButton;
8
+ exports.isActionBarUrlButton = isActionBarUrlButton;
9
+ exports.isActionBarEmailButton = isActionBarEmailButton;
10
+ exports.isActionBarHelpButton = isActionBarHelpButton;
11
+ exports.isActionBarPaymentButton = isActionBarPaymentButton;
12
+ /**
13
+ * Type guard for ActionBarChatButton
14
+ */
15
+ function isActionBarChatButton(button) {
16
+ return button.type === "chat";
17
+ }
18
+ /**
19
+ * Type guard for ActionBarFormButton
20
+ */
21
+ function isActionBarFormButton(button) {
22
+ return button.type === "form";
23
+ }
24
+ /**
25
+ * Type guard for ActionBarScheduleButton
26
+ */
27
+ function isActionBarScheduleButton(button) {
28
+ return button.type === "schedule";
29
+ }
30
+ /**
31
+ * Type guard for ActionBarPhoneButton
32
+ */
33
+ function isActionBarPhoneButton(button) {
34
+ return button.type === "phone";
35
+ }
36
+ /**
37
+ * Type guard for ActionBarUrlButton
38
+ */
39
+ function isActionBarUrlButton(button) {
40
+ return button.type === "url";
41
+ }
42
+ /**
43
+ * Type guard for ActionBarEmailButton
44
+ */
45
+ function isActionBarEmailButton(button) {
46
+ return button.type === "email";
47
+ }
48
+ /**
49
+ * Type guard for ActionBarHelpButton
50
+ */
51
+ function isActionBarHelpButton(button) {
52
+ return button.type === "help";
53
+ }
54
+ /**
55
+ * Type guard for ActionBarPaymentButton
56
+ */
57
+ function isActionBarPaymentButton(button) {
58
+ return button.type === "payment";
59
+ }
60
+ //# sourceMappingURL=ActionBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionBar.js","sourceRoot":"","sources":["../src/ActionBar.ts"],"names":[],"mappings":";AAAA,oCAAoC;;AAwSpC,sDAEC;AAKD,sDAEC;AAKD,8DAEC;AAKD,wDAEC;AAKD,oDAEC;AAKD,wDAEC;AAKD,sDAEC;AAKD,4DAEC;AAtDD;;GAEG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IACzD,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IACzD,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB,CAAC,MAAuB;IAC7D,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,MAAuB;IACxD,OAAO,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,MAAuB;IAC1D,OAAO,MAAM,CAAC,IAAI,KAAK,OAAO,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CAAC,MAAuB;IACzD,OAAO,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CAAC,MAAuB;IAC5D,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACrC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  /*! Copyright (c) 2021, XAPPmedia */
2
2
  import type { ReactNode } from "react";
3
3
  import { Response } from "stentor-models";
4
+ import { ActionBarConfig } from "./ActionBar";
4
5
  import { WidgetTheme } from "./WidgetTheme";
5
6
  import { ChatUserInfo } from "./UserInfo";
6
7
  export interface CtaConfig {
@@ -223,6 +224,17 @@ export interface WidgetEnv extends WidgetEnvDeprecated {
223
224
  * In React Native, defaults to true in development mode (__DEV__).
224
225
  */
225
226
  readonly enableErrorOverlay?: boolean;
227
+ /**
228
+ * Optional key for the form-widget. When provided, the form-widget script
229
+ * will be pre-loaded from https://form.xapp.ai/xapp-form-widget.js?key={formWidgetKey}
230
+ * This enables the Form and Schedule buttons in the ActionBar to open the form widget.
231
+ */
232
+ readonly formWidgetKey?: string;
233
+ /**
234
+ * Action Bar configuration. When enabled, replaces the default ChatButton
235
+ * with a configurable dock of action buttons (Chat, Form, Phone, URL).
236
+ */
237
+ readonly actionBar?: ActionBarConfig;
226
238
  }
227
239
  export interface WidgetAutoOpenOnPattern {
228
240
  readonly patterns?: string[];
@@ -40,6 +40,8 @@ export interface WidgetTheme {
40
40
  readonly border?: WidgetBorderTheme;
41
41
  /** Widget call-to-action styling */
42
42
  readonly cta?: WidgetCtaTheme;
43
+ /** Widget action bar styling */
44
+ readonly actionBar?: WidgetActionBarTheme;
43
45
  }
44
46
  export interface WidgetMenuTheme {
45
47
  readonly item?: WidgetMenuItemTheme;
@@ -163,3 +165,43 @@ export interface WidgetBrandingTheme {
163
165
  export interface WidgetTextTypingStatusTheme {
164
166
  readonly text?: WidgetTextTheme;
165
167
  }
168
+ /**
169
+ * Action bar container theme
170
+ */
171
+ export interface WidgetActionBarTheme {
172
+ /** Background color/style of the action bar container */
173
+ readonly background?: WidgetBackgroundTheme;
174
+ /** Border styling for the action bar */
175
+ readonly border?: WidgetBorderTheme;
176
+ /** Padding around the action bar */
177
+ readonly padding?: WidgetPaddingsTheme;
178
+ /** Margin around the action bar (desktop only) */
179
+ readonly margin?: WidgetMarginsTheme;
180
+ /** Box shadow for elevation effect */
181
+ readonly boxShadow?: string;
182
+ /** Border radius for the action bar */
183
+ readonly borderRadius?: string;
184
+ /** Button styling within the action bar */
185
+ readonly button?: WidgetActionBarButtonTheme;
186
+ }
187
+ /**
188
+ * Action bar button theme
189
+ */
190
+ export interface WidgetActionBarButtonTheme {
191
+ /** Background color/style for buttons */
192
+ readonly background?: WidgetBackgroundTheme;
193
+ /** Background on hover */
194
+ readonly hoverBackground?: WidgetBackgroundTheme;
195
+ /** Icon size */
196
+ readonly iconSize?: WidgetSizeTheme;
197
+ /** Icon color */
198
+ readonly iconColor?: string;
199
+ /** Label text styling */
200
+ readonly label?: WidgetTextTheme;
201
+ /** Spacing between buttons */
202
+ readonly gap?: string;
203
+ /** Button border radius */
204
+ readonly borderRadius?: string;
205
+ /** Button padding */
206
+ readonly padding?: WidgetPaddingsTheme;
207
+ }
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /*! Copyright (c) 2021, XAPPmedia */
2
+ export * from "./ActionBar";
2
3
  export * from "./ChannelData";
3
4
  export * from "./Constants";
4
5
  export * from "./Types";
package/lib/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  /*! Copyright (c) 2021, XAPPmedia */
18
+ __exportStar(require("./ActionBar"), exports);
18
19
  __exportStar(require("./ChannelData"), exports);
19
20
  __exportStar(require("./Constants"), exports);
20
21
  __exportStar(require("./Types"), exports);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oCAAoC;AACpC,gDAA8B;AAC9B,8CAA4B;AAC5B,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,2CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oCAAoC;AACpC,8CAA4B;AAC5B,gDAA8B;AAC9B,8CAA4B;AAC5B,0CAAwB;AACxB,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,2CAAyB"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.82.1",
7
+ "version": "1.85.1",
8
8
  "description": "Chat Widget channel for stentor",
9
9
  "types": "lib/index",
10
10
  "main": "lib/index",
@@ -24,13 +24,13 @@
24
24
  "mocha": "9.2.2",
25
25
  "sinon": "13.0.2",
26
26
  "sinon-chai": "3.7.0",
27
- "stentor-models": "1.67.0",
27
+ "stentor-models": "1.68.6",
28
28
  "ts-node": "10.9.2",
29
29
  "typescript": "5.9.3"
30
30
  },
31
31
  "dependencies": {
32
- "stentor-constants": "1.67.0",
33
- "stentor-guards": "1.67.0"
32
+ "stentor-constants": "1.68.6",
33
+ "stentor-guards": "1.68.6"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^18.0.0 || ^19.0.0",
@@ -40,5 +40,5 @@
40
40
  "build": "tsc -d true -p .",
41
41
  "clean": "rm -rf ./lib/*"
42
42
  },
43
- "gitHead": "568eaf1518bfe2aa4dc0f8f14effd0616c2cb63a"
43
+ "gitHead": "5c99ab44e56acebb675aede84a8cc5a42a37f051"
44
44
  }