@carbon/ai-chat 0.1.6 → 0.1.7-test-no-cjs
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/es/{cds-aichat-internal.js → AppContainer.js} +50756 -18310
- package/dist/es/Carousel.js +14 -8
- package/dist/es/GenesysMessengerServiceDesk.js +17 -11
- package/dist/es/HumanAgentServiceImpl.js +17 -12
- package/dist/es/NiceDFOServiceDesk.js +17 -12
- package/dist/es/PDFViewerContainer.js +15 -108
- package/dist/es/ReactPlayer.js +2 -2
- package/dist/es/SFServiceDesk.js +18 -11
- package/dist/es/ServiceDeskImpl.js +2 -2
- package/dist/es/Table.js +429 -315
- package/dist/es/ZendeskServiceDesk.js +17 -11
- package/dist/es/_node-resolve_empty.js +2 -2
- package/dist/es/aiChatEntry.js +137 -120
- package/dist/es/ar-dz.js +3 -4
- package/dist/es/ar-kw.js +3 -4
- package/dist/es/ar-ly.js +3 -4
- package/dist/es/ar-ma.js +3 -4
- package/dist/es/ar-sa.js +3 -4
- package/dist/es/ar-tn.js +3 -4
- package/dist/es/ar.js +3 -4
- package/dist/es/ar2.js +2 -2
- package/dist/es/cds-aichat-container.js +104 -18
- package/dist/es/cds-aichat-custom-element.js +31 -21
- package/dist/es/cs.js +3 -4
- package/dist/es/cs2.js +2 -2
- package/dist/es/de-at.js +3 -4
- package/dist/es/de-ch.js +3 -4
- package/dist/es/de.js +3 -4
- package/dist/es/de2.js +2 -2
- package/dist/es/en-au.js +3 -4
- package/dist/es/en-ca.js +3 -4
- package/dist/es/en-gb.js +3 -4
- package/dist/es/en-ie.js +3 -4
- package/dist/es/en-il.js +3 -4
- package/dist/es/en-nz.js +3 -4
- package/dist/es/es-do.js +3 -4
- package/dist/es/es-us.js +3 -4
- package/dist/es/es.js +3 -4
- package/dist/es/es2.js +2 -2
- package/dist/es/export.js +3 -3
- package/dist/es/export.legacy.js +3 -3
- package/dist/es/fontUtils.js +2 -2
- package/dist/es/fr-ca.js +3 -4
- package/dist/es/fr-ch.js +3 -4
- package/dist/es/fr.js +3 -4
- package/dist/es/fr2.js +2 -2
- package/dist/es/it-ch.js +3 -4
- package/dist/es/it.js +3 -4
- package/dist/es/it2.js +2 -2
- package/dist/es/ja.js +3 -4
- package/dist/es/ja2.js +2 -2
- package/dist/es/ko.js +3 -4
- package/dist/es/ko2.js +2 -2
- package/dist/es/mockServiceDesk.js +17 -11
- package/dist/es/nl.js +3 -4
- package/dist/es/nl2.js +2 -2
- package/dist/es/pt-br.js +3 -4
- package/dist/es/pt-br2.js +2 -2
- package/dist/es/pt.js +3 -4
- package/dist/es/render.js +25 -12
- package/dist/es/zh-cn.js +3 -4
- package/dist/es/zh-tw.js +3 -4
- package/dist/es/zh-tw2.js +2 -2
- package/dist/es/zh.js +2 -2
- package/dist/types/aiChatEntry.d.ts +599 -11
- package/package.json +29 -21
- package/dist/cjs/Carousel.js +0 -5711
- package/dist/cjs/Chat.js +0 -8838
- package/dist/cjs/GenesysMessengerServiceDesk.js +0 -598
- package/dist/cjs/HumanAgentServiceImpl.js +0 -1145
- package/dist/cjs/NiceDFOServiceDesk.js +0 -2116
- package/dist/cjs/PDFViewerContainer.js +0 -83227
- package/dist/cjs/ReactPlayer.js +0 -57
- package/dist/cjs/SFServiceDesk.js +0 -1031
- package/dist/cjs/ServiceDeskImpl.js +0 -74
- package/dist/cjs/Table.js +0 -3146
- package/dist/cjs/ZendeskServiceDesk.js +0 -670
- package/dist/cjs/_node-resolve_empty.js +0 -27
- package/dist/cjs/agentActions.js +0 -214
- package/dist/cjs/aiChatEntry.js +0 -354
- package/dist/cjs/anonymousUserIDStorage.js +0 -254
- package/dist/cjs/ar-dz.js +0 -57
- package/dist/cjs/ar-kw.js +0 -57
- package/dist/cjs/ar-ly.js +0 -57
- package/dist/cjs/ar-ma.js +0 -57
- package/dist/cjs/ar-sa.js +0 -57
- package/dist/cjs/ar-tn.js +0 -57
- package/dist/cjs/ar.js +0 -57
- package/dist/cjs/ar2.js +0 -763
- package/dist/cjs/cds-aichat-container.js +0 -143
- package/dist/cjs/cds-aichat-custom-element.js +0 -200
- package/dist/cjs/cds-aichat-internal.js +0 -39150
- package/dist/cjs/cs.js +0 -57
- package/dist/cjs/cs2.js +0 -763
- package/dist/cjs/de-at.js +0 -57
- package/dist/cjs/de-ch.js +0 -57
- package/dist/cjs/de.js +0 -57
- package/dist/cjs/de2.js +0 -763
- package/dist/cjs/en-au.js +0 -57
- package/dist/cjs/en-ca.js +0 -57
- package/dist/cjs/en-gb.js +0 -57
- package/dist/cjs/en-ie.js +0 -57
- package/dist/cjs/en-il.js +0 -57
- package/dist/cjs/en-nz.js +0 -57
- package/dist/cjs/es-do.js +0 -57
- package/dist/cjs/es-us.js +0 -57
- package/dist/cjs/es.js +0 -57
- package/dist/cjs/es2.js +0 -763
- package/dist/cjs/export.js +0 -27
- package/dist/cjs/export.legacy.js +0 -27
- package/dist/cjs/fontUtils.js +0 -1038
- package/dist/cjs/fr-ca.js +0 -57
- package/dist/cjs/fr-ch.js +0 -57
- package/dist/cjs/fr.js +0 -57
- package/dist/cjs/fr2.js +0 -763
- package/dist/cjs/highlight_js.js +0 -15325
- package/dist/cjs/it-ch.js +0 -57
- package/dist/cjs/it.js +0 -57
- package/dist/cjs/it2.js +0 -763
- package/dist/cjs/ja.js +0 -57
- package/dist/cjs/ja2.js +0 -763
- package/dist/cjs/jstz.min.js +0 -43
- package/dist/cjs/ko.js +0 -57
- package/dist/cjs/ko2.js +0 -763
- package/dist/cjs/markdown.js +0 -8505
- package/dist/cjs/markdown_attrs.js +0 -805
- package/dist/cjs/mockServiceDesk.js +0 -887
- package/dist/cjs/nl.js +0 -57
- package/dist/cjs/nl2.js +0 -763
- package/dist/cjs/pt-br.js +0 -57
- package/dist/cjs/pt-br2.js +0 -763
- package/dist/cjs/pt.js +0 -57
- package/dist/cjs/render.js +0 -94
- package/dist/cjs/zh-cn.js +0 -57
- package/dist/cjs/zh-tw.js +0 -57
- package/dist/cjs/zh-tw2.js +0 -763
- package/dist/cjs/zh.js +0 -763
- package/dist/es/Chat.js +0 -8836
- package/dist/es/agentActions.js +0 -186
- package/dist/es/anonymousUserIDStorage.js +0 -249
- package/dist/es/highlight_js.js +0 -15320
- package/dist/es/jstz.min.js +0 -41
- package/dist/es/markdown.js +0 -8501
- package/dist/es/markdown_attrs.js +0 -803
|
@@ -13,36 +13,42 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import { aD as WA_CONSOLE_PREFIX, E as ErrorType,
|
|
23
|
+
import { aD as WA_CONSOLE_PREFIX, E as ErrorType, aE as isConnectToAgent, aF as isEmptyObject, j as MessageResponseTypes, ab as createMessageResponseForText, N as consoleError, aj as sleep } from './AppContainer.js';
|
|
24
24
|
import { S as ServiceDeskImpl } from './ServiceDeskImpl.js';
|
|
25
|
-
import 'lit';
|
|
26
|
-
import 'lit/decorators.js';
|
|
27
25
|
import 'react';
|
|
28
|
-
import 'react-dom';
|
|
29
|
-
import './highlight_js.js';
|
|
30
|
-
import '@carbon/react';
|
|
31
26
|
import 'react-intl';
|
|
27
|
+
import 'tslib';
|
|
28
|
+
import '@carbon/icons-react';
|
|
29
|
+
import 'classnames';
|
|
30
|
+
import '@carbon/react';
|
|
32
31
|
import 'react-redux';
|
|
33
|
-
import '
|
|
34
|
-
import '
|
|
32
|
+
import 'tabbable';
|
|
33
|
+
import 'lit';
|
|
34
|
+
import 'lit/decorators.js';
|
|
35
35
|
import '@carbon/web-components/es/components/button/index.js';
|
|
36
36
|
import '@carbon/web-components/es/components/overflow-menu/index.js';
|
|
37
37
|
import 'lit/directives/unsafe-html.js';
|
|
38
|
+
import 'prop-types';
|
|
38
39
|
import '@carbon/web-components/es/components/slug/index.js';
|
|
39
40
|
import '@carbon/web-components/es/components/popover/defs.js';
|
|
40
41
|
import '@carbon/web-components/es/components/slug/defs.js';
|
|
42
|
+
import '@floating-ui/react';
|
|
43
|
+
import 'react-dom';
|
|
41
44
|
import '@carbon/web-components/es/components/slug/slug-action-button.js';
|
|
42
45
|
import '@carbon/web-components/es/components/slug/slug.js';
|
|
46
|
+
import '@carbon/web-components/es/components/inline-loading/index.js';
|
|
47
|
+
import '@carbon/icon-helpers';
|
|
48
|
+
import '@carbon/icons';
|
|
49
|
+
import 'lit/directives/unsafe-svg.js';
|
|
43
50
|
import '@carbon/web-components/es/components/textarea/index.js';
|
|
44
51
|
import '@carbon/web-components/es/components/icon-button/index.js';
|
|
45
|
-
import 'lit/directives/unsafe-svg.js';
|
|
46
52
|
import '@carbon/web-components/es/components/tag/index.js';
|
|
47
53
|
import '@carbon/web-components/es/components/chat-button/index.js';
|
|
48
54
|
import '@carbon/web-components/es/components/button/button.js';
|
|
@@ -13,9 +13,9 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
package/dist/es/aiChatEntry.js
CHANGED
|
@@ -13,36 +13,42 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
export {
|
|
25
|
-
import
|
|
26
|
-
import { LitElement,
|
|
27
|
-
import {
|
|
28
|
-
import 'react-dom';
|
|
29
|
-
import './highlight_js.js';
|
|
30
|
-
import '@carbon/react';
|
|
23
|
+
import { c as carbonElement, o, A as AppContainerExport } from './AppContainer.js';
|
|
24
|
+
export { a as AgentMessageType, b as AgentsOnlineStatus, B as BusEventType, e as ButtonItemKind, d as ButtonItemType, C as CarbonTheme, f as CatastrophicErrorType, q as ChatHeaderObjectType, g as CornersType, h as CustomEventType, E as ErrorType, F as FeedbackInteractionType, i as FileStatusValue, H as HomeScreenBackgroundType, I as IFrameItemDisplayOption, L as LauncherType, M as MessageInputType, j as MessageResponseTypes, k as MessageSendSource, l as MinimizeButtonIconType, O as OnErrorType, m as OptionItemPreference, S as ScreenShareState, T as TourEndReason, n as TourStartReason, V as ViewChangeReason, p as ViewType, W as WriteableElementName } from './AppContainer.js';
|
|
25
|
+
import { __decorate } from 'tslib';
|
|
26
|
+
import { LitElement, css } from 'lit';
|
|
27
|
+
import React__default, { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
28
|
+
import { createPortal } from 'react-dom';
|
|
31
29
|
import 'react-intl';
|
|
30
|
+
import '@carbon/icons-react';
|
|
31
|
+
import 'classnames';
|
|
32
|
+
import '@carbon/react';
|
|
32
33
|
import 'react-redux';
|
|
33
|
-
import '
|
|
34
|
-
import '
|
|
34
|
+
import 'tabbable';
|
|
35
|
+
import 'lit/decorators.js';
|
|
35
36
|
import '@carbon/web-components/es/components/button/index.js';
|
|
36
37
|
import '@carbon/web-components/es/components/overflow-menu/index.js';
|
|
37
38
|
import 'lit/directives/unsafe-html.js';
|
|
39
|
+
import 'prop-types';
|
|
38
40
|
import '@carbon/web-components/es/components/slug/index.js';
|
|
39
41
|
import '@carbon/web-components/es/components/popover/defs.js';
|
|
40
42
|
import '@carbon/web-components/es/components/slug/defs.js';
|
|
43
|
+
import '@floating-ui/react';
|
|
41
44
|
import '@carbon/web-components/es/components/slug/slug-action-button.js';
|
|
42
45
|
import '@carbon/web-components/es/components/slug/slug.js';
|
|
46
|
+
import '@carbon/web-components/es/components/inline-loading/index.js';
|
|
47
|
+
import '@carbon/icon-helpers';
|
|
48
|
+
import '@carbon/icons';
|
|
49
|
+
import 'lit/directives/unsafe-svg.js';
|
|
43
50
|
import '@carbon/web-components/es/components/textarea/index.js';
|
|
44
51
|
import '@carbon/web-components/es/components/icon-button/index.js';
|
|
45
|
-
import 'lit/directives/unsafe-svg.js';
|
|
46
52
|
import '@carbon/web-components/es/components/tag/index.js';
|
|
47
53
|
import '@carbon/web-components/es/components/chat-button/index.js';
|
|
48
54
|
import '@carbon/web-components/es/components/button/button.js';
|
|
@@ -63,105 +69,14 @@ import '@carbon/web-components/es/components/layer/index.js';
|
|
|
63
69
|
*
|
|
64
70
|
*/
|
|
65
71
|
/**
|
|
66
|
-
*
|
|
67
|
-
* into slots.
|
|
72
|
+
* Status of the chain of thought step.
|
|
68
73
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this._userDefinedElements = [];
|
|
76
|
-
/**
|
|
77
|
-
* The existing array of slot names for all writeable elements.
|
|
78
|
-
*/
|
|
79
|
-
this._writeableElementSlots = [];
|
|
80
|
-
/**
|
|
81
|
-
* Adds the slot attribute to the element for the user_defined response type and then injects it into the component by
|
|
82
|
-
* updating this._userDefinedElements;
|
|
83
|
-
*/
|
|
84
|
-
this._userDefinedHandler = (event) => {
|
|
85
|
-
// This element already has `slot` as an attribute.
|
|
86
|
-
const { element } = event.data;
|
|
87
|
-
if (!this._userDefinedElements.includes(element)) {
|
|
88
|
-
this._userDefinedElements = [...this._userDefinedElements, element];
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
this._onBeforeRenderOverride = (instance) => {
|
|
92
|
-
if (instance) {
|
|
93
|
-
this._instance = instance;
|
|
94
|
-
this._instance.on({ type: "userDefinedResponse" /* BusEventType.USER_DEFINED_RESPONSE */, handler: this._userDefinedHandler });
|
|
95
|
-
this._instance.on({ type: "chunk:userDefinedResponse" /* BusEventType.CHUNK_USER_DEFINED_RESPONSE */, handler: this._userDefinedHandler });
|
|
96
|
-
this._addWriteableElementSlots();
|
|
97
|
-
this.onBeforeRender?.(instance);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
_addWriteableElementSlots() {
|
|
102
|
-
const writeableElementSlots = [this._instance.customPanels.getPanel().hostElement];
|
|
103
|
-
Object.keys(this._instance.writeableElements).forEach(writeableElementKey => {
|
|
104
|
-
const element = this._instance.writeableElements[writeableElementKey];
|
|
105
|
-
element.setAttribute('slot', writeableElementKey);
|
|
106
|
-
writeableElementSlots.push(element);
|
|
107
|
-
});
|
|
108
|
-
this._writeableElementSlots = writeableElementSlots;
|
|
109
|
-
}
|
|
110
|
-
createRenderRoot() {
|
|
111
|
-
return this;
|
|
112
|
-
}
|
|
113
|
-
render() {
|
|
114
|
-
return html `<style>
|
|
115
|
-
cds-aichat-react {
|
|
116
|
-
width: 100%;
|
|
117
|
-
height: 100%;
|
|
118
|
-
}
|
|
119
|
-
</style>
|
|
120
|
-
<cds-aichat-internal
|
|
121
|
-
.config=${this.config}
|
|
122
|
-
.onAfterRender=${this.onAfterRender}
|
|
123
|
-
.onBeforeRender=${this._onBeforeRenderOverride}
|
|
124
|
-
.renderUserDefinedResponse=${this.renderUserDefinedResponse}
|
|
125
|
-
.renderWriteableElements=${this.renderWriteableElements}
|
|
126
|
-
isReact
|
|
127
|
-
.forceReact17Mode=${this.forceReact17Mode}
|
|
128
|
-
>
|
|
129
|
-
${this._writeableElementSlots.map(element => html `${element}`)}
|
|
130
|
-
${this._userDefinedElements.map(element => html `${element}`)}
|
|
131
|
-
</cds-aichat-internal>`;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
__decorate([
|
|
135
|
-
property({ type: Object })
|
|
136
|
-
], ChatContainerReact.prototype, "config", void 0);
|
|
137
|
-
__decorate([
|
|
138
|
-
property()
|
|
139
|
-
], ChatContainerReact.prototype, "onBeforeRender", void 0);
|
|
140
|
-
__decorate([
|
|
141
|
-
property()
|
|
142
|
-
], ChatContainerReact.prototype, "onAfterRender", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
property({ type: Boolean })
|
|
145
|
-
], ChatContainerReact.prototype, "forceReact17Mode", void 0);
|
|
146
|
-
__decorate([
|
|
147
|
-
property()
|
|
148
|
-
], ChatContainerReact.prototype, "renderUserDefinedResponse", void 0);
|
|
149
|
-
__decorate([
|
|
150
|
-
property({ type: Object })
|
|
151
|
-
], ChatContainerReact.prototype, "renderWriteableElements", void 0);
|
|
152
|
-
__decorate([
|
|
153
|
-
state()
|
|
154
|
-
], ChatContainerReact.prototype, "_userDefinedElements", void 0);
|
|
155
|
-
__decorate([
|
|
156
|
-
state()
|
|
157
|
-
], ChatContainerReact.prototype, "_writeableElementSlots", void 0);
|
|
158
|
-
__decorate([
|
|
159
|
-
state()
|
|
160
|
-
], ChatContainerReact.prototype, "_instance", void 0);
|
|
161
|
-
ChatContainerReact = __decorate([
|
|
162
|
-
carbonElement('cds-aichat-react')
|
|
163
|
-
], ChatContainerReact);
|
|
164
|
-
var ChatContainerReact$1 = ChatContainerReact;
|
|
74
|
+
var ChainOfThoughtStepStatus;
|
|
75
|
+
(function (ChainOfThoughtStepStatus) {
|
|
76
|
+
ChainOfThoughtStepStatus["PROCESSING"] = "processing";
|
|
77
|
+
ChainOfThoughtStepStatus["FAILURE"] = "failure";
|
|
78
|
+
ChainOfThoughtStepStatus["SUCCESS"] = "success";
|
|
79
|
+
})(ChainOfThoughtStepStatus || (ChainOfThoughtStepStatus = {}));
|
|
165
80
|
|
|
166
81
|
/**
|
|
167
82
|
*
|
|
@@ -178,17 +93,118 @@ var ChatContainerReact$1 = ChatContainerReact;
|
|
|
178
93
|
*
|
|
179
94
|
*/
|
|
180
95
|
/**
|
|
181
|
-
* This
|
|
182
|
-
*
|
|
96
|
+
* This component creates a custom element protected by a ShadowRoot to render the React application into. It creates
|
|
97
|
+
* slotted elements for user_defined responses and for writable elements.
|
|
98
|
+
*
|
|
99
|
+
* The corresponding slots are defined within the React application and are rendered in place.
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Create a web component to host the React application. We do this so we can provide custom elements and user_defined responses as
|
|
103
|
+
* slotted content so they maintain their own styling in a safe way.
|
|
183
104
|
*/
|
|
184
|
-
|
|
105
|
+
let ChatContainerReact = class ChatContainerReact extends LitElement {
|
|
106
|
+
static { this.styles = css `
|
|
107
|
+
:host {
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 100%;
|
|
110
|
+
}
|
|
111
|
+
`; }
|
|
112
|
+
};
|
|
113
|
+
ChatContainerReact = __decorate([
|
|
114
|
+
carbonElement('cds-aichat-react')
|
|
115
|
+
], ChatContainerReact);
|
|
116
|
+
// Wrap the custom element as a React component
|
|
117
|
+
const ReactChatContainer = React__default.memo(o({
|
|
185
118
|
tagName: 'cds-aichat-react',
|
|
186
|
-
elementClass: ChatContainerReact
|
|
119
|
+
elementClass: ChatContainerReact,
|
|
187
120
|
react: React__default,
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
|
|
121
|
+
}));
|
|
122
|
+
/**
|
|
123
|
+
* The ChatContainer controls rendering the React application into the ShadowRoot of the cds-aichat-react web component.
|
|
124
|
+
* It also injects the writeable element and user_defined response slots into said web component.
|
|
125
|
+
*/
|
|
126
|
+
function ChatContainer({ onBeforeRender, onAfterRender, config, renderUserDefinedResponse, renderWriteableElements, }) {
|
|
127
|
+
const wrapperRef = useRef(null); // Ref for the React wrapper component
|
|
128
|
+
const [wrapper, setWrapper] = useState(null);
|
|
129
|
+
const [container, setContainer] = useState(null); // Actual element we render the React Portal to in the Shadowroot.
|
|
130
|
+
const [userDefinedElements, setUserDefinedElements] = useState([]);
|
|
131
|
+
const [writeableElementSlots, setWriteableElementSlots] = useState([]);
|
|
132
|
+
const [currentInstance, setCurrentInstance] = useState(null);
|
|
133
|
+
/**
|
|
134
|
+
* Setup the DOM nodes of both the web component to be able to inject slotted content into it, and the element inside the
|
|
135
|
+
* ShadowRoot we will inject our React application into.
|
|
136
|
+
*/
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
if (wrapperRef.current) {
|
|
139
|
+
const wrapperElement = wrapperRef.current;
|
|
140
|
+
// We need to check if the element in the ShadowRoot we are render the React application to exists.
|
|
141
|
+
// If it doesn't, we need to create and append it.
|
|
142
|
+
// When the web chat is destroyed (either via a config change or by calling instance.destroy), this element is
|
|
143
|
+
// removed again. When the chat is destroyed the instance is set to null. The useEffect watches the instance
|
|
144
|
+
// value and runs if it changes, re-creating the container element if needed.
|
|
145
|
+
let reactElement = wrapperElement.shadowRoot?.querySelector('.cds--aichat-react-app');
|
|
146
|
+
if (!reactElement) {
|
|
147
|
+
reactElement = document.createElement('div');
|
|
148
|
+
reactElement.classList.add('cds--aichat-react-app');
|
|
149
|
+
wrapperElement.shadowRoot.appendChild(reactElement);
|
|
150
|
+
}
|
|
151
|
+
if (wrapperElement !== wrapper) {
|
|
152
|
+
setWrapper(wrapperElement);
|
|
153
|
+
}
|
|
154
|
+
if (reactElement !== container) {
|
|
155
|
+
setContainer(reactElement);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}, [container, wrapper, currentInstance]);
|
|
159
|
+
/**
|
|
160
|
+
* Here we write the slotted elements into the wrapper so they are passed into the application to be rendered in their slot.
|
|
161
|
+
*/
|
|
162
|
+
useEffect(() => {
|
|
163
|
+
if (wrapper) {
|
|
164
|
+
const combinedNodes = [...userDefinedElements, ...writeableElementSlots];
|
|
165
|
+
const currentNodes = Array.from(wrapper.childNodes);
|
|
166
|
+
const newNodesSet = new Set(combinedNodes);
|
|
167
|
+
// Remove nodes no longer present
|
|
168
|
+
currentNodes.forEach(node => {
|
|
169
|
+
if (!newNodesSet.has(node)) {
|
|
170
|
+
wrapper.removeChild(node);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
// Append new nodes that aren't already in the container
|
|
174
|
+
combinedNodes.forEach(node => {
|
|
175
|
+
if (!currentNodes.includes(node)) {
|
|
176
|
+
wrapper.appendChild(node);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}, [userDefinedElements, writeableElementSlots, wrapper]);
|
|
181
|
+
const userDefinedHandler = useCallback((event) => {
|
|
182
|
+
const { element } = event.data;
|
|
183
|
+
setUserDefinedElements(previousUserDefinedElements => [...previousUserDefinedElements, element]);
|
|
184
|
+
}, []);
|
|
185
|
+
const onBeforeRenderOverride = useCallback((instance) => {
|
|
186
|
+
if (instance) {
|
|
187
|
+
const addWriteableElementSlots = () => {
|
|
188
|
+
const slots = Object.entries(instance.writeableElements).map(writeableElement => {
|
|
189
|
+
const [key, element] = writeableElement;
|
|
190
|
+
element.setAttribute('slot', key); // Assign slot attributes dynamically
|
|
191
|
+
return element;
|
|
192
|
+
});
|
|
193
|
+
slots.push(instance.customPanels.getPanel().hostElement);
|
|
194
|
+
setWriteableElementSlots(slots);
|
|
195
|
+
};
|
|
196
|
+
instance.on({ type: "userDefinedResponse" /* BusEventType.USER_DEFINED_RESPONSE */, handler: userDefinedHandler });
|
|
197
|
+
instance.on({ type: "chunk:userDefinedResponse" /* BusEventType.CHUNK_USER_DEFINED_RESPONSE */, handler: userDefinedHandler });
|
|
198
|
+
addWriteableElementSlots();
|
|
199
|
+
onBeforeRender?.(instance);
|
|
200
|
+
}
|
|
201
|
+
}, [onBeforeRender, userDefinedHandler]);
|
|
202
|
+
return (React__default.createElement(React__default.Fragment, null,
|
|
203
|
+
React__default.createElement(ReactChatContainer, { ref: wrapperRef }),
|
|
204
|
+
container &&
|
|
205
|
+
createPortal(React__default.createElement(AppContainerExport, { config: config, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements, onBeforeRender: onBeforeRenderOverride, onAfterRender: onAfterRender, container: container, setParentInstance: setCurrentInstance }), container)));
|
|
191
206
|
}
|
|
207
|
+
const ChatContainerExport = React__default.memo(ChatContainer);
|
|
192
208
|
|
|
193
209
|
/**
|
|
194
210
|
*
|
|
@@ -237,7 +253,8 @@ function ChatCustomElement({ config, onBeforeRender, onAfterRender, renderUserDe
|
|
|
237
253
|
instance.on({ type: "view:change" /* BusEventType.VIEW_CHANGE */, handler: onViewChange || defaultViewChangeHandler });
|
|
238
254
|
return onBeforeRender?.(instance);
|
|
239
255
|
}, [onBeforeRender, onViewChange, customElement]);
|
|
240
|
-
return (React__default.createElement("div", { className: className, id: id, ref: setCustomElement }, customElement && (React__default.createElement(
|
|
256
|
+
return (React__default.createElement("div", { className: className, id: id, ref: setCustomElement }, customElement && (React__default.createElement(ChatContainerExport, { config: useConfig, onBeforeRender: onBeforeRenderOverride, onAfterRender: onAfterRender, renderUserDefinedResponse: renderUserDefinedResponse, renderWriteableElements: renderWriteableElements }))));
|
|
241
257
|
}
|
|
258
|
+
const ChatCustomElementExport = React__default.memo(ChatCustomElement);
|
|
242
259
|
|
|
243
|
-
export { ChatContainer, ChatCustomElement };
|
|
260
|
+
export { ChainOfThoughtStepStatus, ChatContainerExport as ChatContainer, ChatCustomElementExport as ChatCustomElement };
|
package/dist/es/ar-dz.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar-kw.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar-ly.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar-ma.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar-sa.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar-tn.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar.js
CHANGED
|
@@ -13,15 +13,14 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
*/
|
|
23
|
-
import {
|
|
24
|
-
import { e6 as dayjs_minExports } from './cds-aichat-internal.js';
|
|
23
|
+
import { al as getDefaultExportFromCjs, am as dayjs_minExports, an as commonjsGlobal } from './AppContainer.js';
|
|
25
24
|
|
|
26
25
|
function _mergeNamespaces(n, m) {
|
|
27
26
|
m.forEach(function (e) {
|
package/dist/es/ar2.js
CHANGED
|
@@ -13,9 +13,9 @@ is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND
|
|
|
13
13
|
or implied. See the License for the specific language governing permissions and limitations under
|
|
14
14
|
the License.
|
|
15
15
|
|
|
16
|
-
@carbon/ai-chat 0.1.
|
|
16
|
+
@carbon/ai-chat 0.1.7-test-no-cjs
|
|
17
17
|
|
|
18
|
-
Built: Feb
|
|
18
|
+
Built: Feb 26 2025 2:36 pm -05:00
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|