@xapp/stentor-chat-widget 1.81.5 → 1.85.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.
@@ -0,0 +1,286 @@
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
+ */
10
+ export type ActionBarIconType = "chat" | "form" | "schedule" | "phone" | "email" | "url" | "help" | "payment";
11
+ /**
12
+ * Visibility configuration for responsive display
13
+ */
14
+ export type ActionBarButtonVisibility = "all" | "mobile-only" | "desktop-only";
15
+ /**
16
+ * Horizontal positioning for the action bar on desktop/tablet
17
+ */
18
+ export type ActionBarPosition = "left" | "center" | "right";
19
+ /**
20
+ * Base configuration shared by all button types
21
+ */
22
+ export interface ActionBarButtonBase {
23
+ /**
24
+ * Unique identifier for the button
25
+ */
26
+ readonly id: string;
27
+ /**
28
+ * The type of action this button performs
29
+ */
30
+ readonly type: ActionBarButtonType;
31
+ /**
32
+ * Optional label text to display below the icon.
33
+ * When undefined, only the icon is shown.
34
+ */
35
+ readonly label?: string;
36
+ /**
37
+ * Override the default icon with a different built-in icon.
38
+ * This allows using any icon regardless of button type.
39
+ * Takes precedence over type-based icon, but iconUrl takes precedence over this.
40
+ */
41
+ readonly icon?: ActionBarIconType;
42
+ /**
43
+ * Custom icon URL. If not provided, a default icon for the button type is used.
44
+ * Takes precedence over both `icon` and type-based icon.
45
+ */
46
+ readonly iconUrl?: string;
47
+ /**
48
+ * Control which devices show this button.
49
+ * @default "all"
50
+ */
51
+ readonly visibility?: ActionBarButtonVisibility;
52
+ /**
53
+ * Tab index for keyboard navigation accessibility.
54
+ */
55
+ readonly tabIndex?: number;
56
+ }
57
+ /**
58
+ * Chat button - opens the chat widget (existing behavior)
59
+ */
60
+ export interface ActionBarChatButton extends ActionBarButtonBase {
61
+ readonly type: "chat";
62
+ }
63
+ /**
64
+ * Form configuration for dedicated form-widget instance
65
+ */
66
+ export interface ActionBarFormConfig {
67
+ readonly api: {
68
+ readonly url: string;
69
+ readonly key?: string;
70
+ };
71
+ readonly intentId?: string;
72
+ readonly autoGreeting?: string;
73
+ readonly googleMapsApiKey?: string;
74
+ readonly mapsBaseUrl?: string;
75
+ }
76
+ /**
77
+ * Form button configuration - opens form-widget in a modal overlay.
78
+ * Supports two modes:
79
+ * 1. Dedicated form config (formConfig) - uses separate API/settings
80
+ * 2. Shared chat-widget settings (intentId) - leverages existing connection
81
+ */
82
+ export interface ActionBarFormButton extends ActionBarButtonBase {
83
+ readonly type: "form";
84
+ /**
85
+ * Dedicated form widget configuration.
86
+ * When provided, the form operates independently with its own API settings.
87
+ */
88
+ readonly formConfig?: ActionBarFormConfig;
89
+ /**
90
+ * Intent ID to trigger when using shared chat-widget connection.
91
+ * Used when formConfig is not provided.
92
+ */
93
+ readonly intentId?: string;
94
+ /**
95
+ * Auto-greeting query when using shared chat-widget connection.
96
+ * Used when formConfig is not provided.
97
+ */
98
+ readonly autoGreeting?: string;
99
+ /**
100
+ * Label of a chip to auto-select after the form loads.
101
+ * If the first step of the form contains chips, the form will
102
+ * automatically click the chip matching this label.
103
+ */
104
+ readonly preselectChipLabel?: string;
105
+ }
106
+ /**
107
+ * Schedule/Book button configuration - opens form-widget for scheduling.
108
+ * Uses the same form-widget infrastructure but with a calendar-themed icon.
109
+ * Supports two modes:
110
+ * 1. Dedicated form config (formConfig) - uses separate API/settings
111
+ * 2. Shared chat-widget settings (intentId) - leverages existing connection
112
+ */
113
+ export interface ActionBarScheduleButton extends ActionBarButtonBase {
114
+ readonly type: "schedule";
115
+ /**
116
+ * Dedicated form widget configuration.
117
+ * When provided, the form operates independently with its own API settings.
118
+ */
119
+ readonly formConfig?: ActionBarFormConfig;
120
+ /**
121
+ * Intent ID to trigger when using shared chat-widget connection.
122
+ * Used when formConfig is not provided.
123
+ */
124
+ readonly intentId?: string;
125
+ /**
126
+ * Auto-greeting query when using shared chat-widget connection.
127
+ * Used when formConfig is not provided.
128
+ */
129
+ readonly autoGreeting?: string;
130
+ /**
131
+ * Label of a chip to auto-select after the form loads.
132
+ * If the first step of the form contains chips, the form will
133
+ * automatically click the chip matching this label.
134
+ */
135
+ readonly preselectChipLabel?: string;
136
+ }
137
+ /**
138
+ * Phone button - click-to-call with tel: link
139
+ */
140
+ export interface ActionBarPhoneButton extends ActionBarButtonBase {
141
+ readonly type: "phone";
142
+ /**
143
+ * Phone number to call (will be formatted as tel: link)
144
+ */
145
+ readonly phoneNumber: string;
146
+ }
147
+ /**
148
+ * Email button - click-to-email with mailto: link
149
+ */
150
+ export interface ActionBarEmailButton extends ActionBarButtonBase {
151
+ readonly type: "email";
152
+ /**
153
+ * Email address (will be formatted as mailto: link)
154
+ */
155
+ readonly emailAddress: string;
156
+ /**
157
+ * Optional subject line for the email
158
+ */
159
+ readonly subject?: string;
160
+ /**
161
+ * Optional body text for the email
162
+ */
163
+ readonly body?: string;
164
+ }
165
+ /**
166
+ * Help button - links to documentation or help center
167
+ * Uses the URL button infrastructure with a help-themed icon
168
+ */
169
+ export interface ActionBarHelpButton extends ActionBarButtonBase {
170
+ readonly type: "help";
171
+ /**
172
+ * URL to the help center or documentation
173
+ */
174
+ readonly url: string;
175
+ /**
176
+ * How the URL should be opened
177
+ * @default "newTab"
178
+ */
179
+ readonly target?: ActionBarUrlTarget;
180
+ }
181
+ /**
182
+ * Payment button - links to payment portal
183
+ * Uses the URL button infrastructure with a payment-themed icon
184
+ */
185
+ export interface ActionBarPaymentButton extends ActionBarButtonBase {
186
+ readonly type: "payment";
187
+ /**
188
+ * URL to the payment portal
189
+ */
190
+ readonly url: string;
191
+ /**
192
+ * How the URL should be opened
193
+ * @default "newTab"
194
+ */
195
+ readonly target?: ActionBarUrlTarget;
196
+ }
197
+ /**
198
+ * URL target behavior type
199
+ */
200
+ export type ActionBarUrlTarget = "sameWindow" | "newWindow" | "newTab";
201
+ /**
202
+ * URL button - opens an arbitrary hyperlink
203
+ */
204
+ export interface ActionBarUrlButton extends ActionBarButtonBase {
205
+ readonly type: "url";
206
+ /**
207
+ * URL to open when clicked
208
+ */
209
+ readonly url: string;
210
+ /**
211
+ * How the URL should be opened
212
+ * @default "newTab"
213
+ */
214
+ readonly target?: ActionBarUrlTarget;
215
+ /**
216
+ * Window dimensions when target is "newWindow"
217
+ */
218
+ readonly windowOptions?: {
219
+ readonly width?: number;
220
+ readonly height?: number;
221
+ };
222
+ }
223
+ /**
224
+ * Union type of all button configurations
225
+ */
226
+ export type ActionBarButton = ActionBarChatButton | ActionBarFormButton | ActionBarScheduleButton | ActionBarPhoneButton | ActionBarEmailButton | ActionBarUrlButton | ActionBarHelpButton | ActionBarPaymentButton;
227
+ /**
228
+ * Main Action Bar configuration.
229
+ * When enabled, replaces the default ChatButton with a configurable dock
230
+ * of action buttons.
231
+ */
232
+ export interface ActionBarConfig {
233
+ /**
234
+ * Enable the action bar (replaces ChatButton when true)
235
+ * @default false
236
+ */
237
+ readonly enabled: boolean;
238
+ /**
239
+ * Array of buttons to display in the action bar.
240
+ * Buttons are rendered in order from left to right.
241
+ */
242
+ readonly buttons: readonly ActionBarButton[];
243
+ /**
244
+ * Horizontal position of the action bar on desktop/tablet.
245
+ * On mobile, the bar is always full-width at the bottom.
246
+ * @default "right"
247
+ */
248
+ readonly position?: ActionBarPosition;
249
+ /**
250
+ * Screen width breakpoint (in pixels) below which mobile layout is applied.
251
+ * @default 768
252
+ */
253
+ readonly mobileBreakpoint?: number;
254
+ }
255
+ /**
256
+ * Type guard for ActionBarChatButton
257
+ */
258
+ export declare function isActionBarChatButton(button: ActionBarButton): button is ActionBarChatButton;
259
+ /**
260
+ * Type guard for ActionBarFormButton
261
+ */
262
+ export declare function isActionBarFormButton(button: ActionBarButton): button is ActionBarFormButton;
263
+ /**
264
+ * Type guard for ActionBarScheduleButton
265
+ */
266
+ export declare function isActionBarScheduleButton(button: ActionBarButton): button is ActionBarScheduleButton;
267
+ /**
268
+ * Type guard for ActionBarPhoneButton
269
+ */
270
+ export declare function isActionBarPhoneButton(button: ActionBarButton): button is ActionBarPhoneButton;
271
+ /**
272
+ * Type guard for ActionBarUrlButton
273
+ */
274
+ export declare function isActionBarUrlButton(button: ActionBarButton): button is ActionBarUrlButton;
275
+ /**
276
+ * Type guard for ActionBarEmailButton
277
+ */
278
+ export declare function isActionBarEmailButton(button: ActionBarButton): button is ActionBarEmailButton;
279
+ /**
280
+ * Type guard for ActionBarHelpButton
281
+ */
282
+ export declare function isActionBarHelpButton(button: ActionBarButton): button is ActionBarHelpButton;
283
+ /**
284
+ * Type guard for ActionBarPaymentButton
285
+ */
286
+ 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;;AA2RpC,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[];
@@ -330,6 +342,12 @@ export interface WidgetMenuConfig {
330
342
  export interface WidgetInputConfig {
331
343
  readonly placeholder?: string;
332
344
  readonly tabIndex?: string;
345
+ /**
346
+ * Maximum number of characters allowed in the input field.
347
+ * When set, a character counter will be displayed showing current/max characters.
348
+ * Users will be prevented from typing beyond this limit.
349
+ */
350
+ readonly maxLength?: number;
333
351
  }
334
352
  export interface WidgetMenuItemConfig {
335
353
  readonly label: 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.81.5",
7
+ "version": "1.85.0",
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.66.41",
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.66.41",
33
- "stentor-guards": "1.66.41"
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": "46fdf2272da696e47a7dcb886bb5815d60abcc5f"
43
+ "gitHead": "7e88fa85fbd4c05a32caffe37099e72a0534b86c"
44
44
  }