@salesforcedevs/dx-components 1.31.6 → 1.31.8-alpha.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.8-alpha.1",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"luxon": "3.4.4",
|
|
45
45
|
"msw": "^2.12.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "603ae2f74f050fb351c48981ce44926b8dedb4f9"
|
|
48
48
|
}
|
|
@@ -58,12 +58,17 @@ function loadMiawUiScript(): Promise<void> {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export default class AgentMiawUi extends LightningElement {
|
|
61
|
+
private static readonly SIDEBAR_OPEN_ATTR = "data-xsf-agent-sidebar-open";
|
|
62
|
+
private static readonly AGENT_ROOT_SELECTOR = '[data-testid="agent-root"]';
|
|
63
|
+
private static readonly SIDEBAR_OPEN_CLASS = "view-sidebar";
|
|
64
|
+
|
|
61
65
|
/** Salesforce org id (15- or 18-character Id). */
|
|
62
66
|
@api orgId!: string;
|
|
63
67
|
/** Messaging endpoint host URL (e.g. https://org62.my.salesforce-scrt.com). */
|
|
64
68
|
@api messagingUrl!: string;
|
|
65
69
|
@api deploymentDevName = "page_builder_miaw_ui";
|
|
66
70
|
@api richComponentVersion = "v1-stable";
|
|
71
|
+
@api isOnDigitalDomain = "true";
|
|
67
72
|
@api routingAttributes?: string;
|
|
68
73
|
/**
|
|
69
74
|
* JSON array of suggested prompt strings for the MIAW UI (e.g.
|
|
@@ -75,6 +80,8 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
75
80
|
|
|
76
81
|
/** After first mount attempt is scheduled, we do not run it again for this instance. */
|
|
77
82
|
private hasRendered = false;
|
|
83
|
+
private sidebarStateObserver: MutationObserver | null = null;
|
|
84
|
+
private sidebarStateTargetSelector = "#main-content";
|
|
78
85
|
|
|
79
86
|
renderedCallback(): void {
|
|
80
87
|
if (!this.hasRendered) {
|
|
@@ -83,6 +90,11 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
83
90
|
}
|
|
84
91
|
}
|
|
85
92
|
|
|
93
|
+
disconnectedCallback(): void {
|
|
94
|
+
this.sidebarStateObserver?.disconnect();
|
|
95
|
+
this.sidebarStateObserver = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
86
98
|
private async mountMiawHost(): Promise<void> {
|
|
87
99
|
try {
|
|
88
100
|
await loadMiawUiScript();
|
|
@@ -95,6 +107,7 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
95
107
|
el.setAttribute("messaging-url", this.messagingUrl);
|
|
96
108
|
el.setAttribute("deployment-dev-name", this.deploymentDevName);
|
|
97
109
|
el.setAttribute("input-variant", "mini-sidebar");
|
|
110
|
+
el.setAttribute("is-on-digital-domain", this.isOnDigitalDomain);
|
|
98
111
|
el.setAttribute(
|
|
99
112
|
"rich-component-version",
|
|
100
113
|
this.richComponentVersion
|
|
@@ -112,8 +125,43 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
112
125
|
el.setAttribute("welcome-text", this.welcomeText);
|
|
113
126
|
}
|
|
114
127
|
container.appendChild(el);
|
|
128
|
+
this.bridgeSidebarState(el);
|
|
115
129
|
} catch (e) {
|
|
116
130
|
console.error(e);
|
|
117
131
|
}
|
|
118
132
|
}
|
|
133
|
+
|
|
134
|
+
private setSidebarOpenState(isOpen: boolean): void {
|
|
135
|
+
const targets = document.querySelectorAll(this.sidebarStateTargetSelector);
|
|
136
|
+
targets.forEach((target) => {
|
|
137
|
+
target.setAttribute(
|
|
138
|
+
AgentMiawUi.SIDEBAR_OPEN_ATTR,
|
|
139
|
+
isOpen ? "true" : "false"
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private bridgeSidebarState(el: Element): void {
|
|
145
|
+
const host = el as HTMLElement;
|
|
146
|
+
const root = host.shadowRoot?.querySelector(
|
|
147
|
+
AgentMiawUi.AGENT_ROOT_SELECTOR
|
|
148
|
+
) as HTMLElement | null;
|
|
149
|
+
if (!root) {
|
|
150
|
+
window.requestAnimationFrame(() => this.bridgeSidebarState(el));
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const isOpen = () =>
|
|
155
|
+
root.classList.contains(AgentMiawUi.SIDEBAR_OPEN_CLASS);
|
|
156
|
+
this.setSidebarOpenState(isOpen());
|
|
157
|
+
|
|
158
|
+
this.sidebarStateObserver?.disconnect();
|
|
159
|
+
this.sidebarStateObserver = new MutationObserver(() => {
|
|
160
|
+
this.setSidebarOpenState(isOpen());
|
|
161
|
+
});
|
|
162
|
+
this.sidebarStateObserver.observe(root, {
|
|
163
|
+
attributes: true,
|
|
164
|
+
attributeFilter: ["class"]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
119
167
|
}
|