@salesforcedevs/dx-components 1.31.7 → 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,6 +58,10 @@ 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). */
|
|
@@ -76,6 +80,8 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
76
80
|
|
|
77
81
|
/** After first mount attempt is scheduled, we do not run it again for this instance. */
|
|
78
82
|
private hasRendered = false;
|
|
83
|
+
private sidebarStateObserver: MutationObserver | null = null;
|
|
84
|
+
private sidebarStateTargetSelector = "#main-content";
|
|
79
85
|
|
|
80
86
|
renderedCallback(): void {
|
|
81
87
|
if (!this.hasRendered) {
|
|
@@ -84,6 +90,11 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
disconnectedCallback(): void {
|
|
94
|
+
this.sidebarStateObserver?.disconnect();
|
|
95
|
+
this.sidebarStateObserver = null;
|
|
96
|
+
}
|
|
97
|
+
|
|
87
98
|
private async mountMiawHost(): Promise<void> {
|
|
88
99
|
try {
|
|
89
100
|
await loadMiawUiScript();
|
|
@@ -114,8 +125,43 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
114
125
|
el.setAttribute("welcome-text", this.welcomeText);
|
|
115
126
|
}
|
|
116
127
|
container.appendChild(el);
|
|
128
|
+
this.bridgeSidebarState(el);
|
|
117
129
|
} catch (e) {
|
|
118
130
|
console.error(e);
|
|
119
131
|
}
|
|
120
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
|
+
}
|
|
121
167
|
}
|