@salesforcedevs/dx-components 1.32.1-alpha.0 → 1.32.1-alpha.2
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.32.1-alpha.
|
|
3
|
+
"version": "1.32.1-alpha.2",
|
|
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": "4288b70a2675c017c7107686bace5802189e9d44"
|
|
48
48
|
}
|
|
@@ -1,83 +1,85 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-document-query */
|
|
2
2
|
import { LightningElement, api } from "lwc";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const HOSTED_MIAW_UI_TAG = "page-builder-miaw-ui";
|
|
5
5
|
const SCRIPT_SRC =
|
|
6
6
|
"https://a.sfdcstatic.com/digital/@sfdc-www-emu/page-builder-miaw-ui/v1-stable/page-builder-miaw-ui.js";
|
|
7
|
-
const DEFINE_TIMEOUT_MS =
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
const DEFINE_TIMEOUT_MS = 60000;
|
|
8
|
+
|
|
9
|
+
let miawInitPromise: Promise<void> | null = null;
|
|
10
|
+
|
|
11
|
+
function waitUntilHostedMiawUiDefined(): Promise<void> {
|
|
12
|
+
const message =
|
|
13
|
+
`MIAW UI embed (${HOSTED_MIAW_UI_TAG}) did not register within ${
|
|
14
|
+
DEFINE_TIMEOUT_MS / 1000
|
|
15
|
+
}s. ` +
|
|
16
|
+
"Confirm the script loads (network tab), your origin is allowed, and CSP permits this script.";
|
|
17
|
+
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const timeoutId = window.setTimeout(() => {
|
|
20
|
+
reject(new Error(message));
|
|
21
|
+
}, DEFINE_TIMEOUT_MS);
|
|
22
|
+
|
|
23
|
+
customElements.whenDefined(HOSTED_MIAW_UI_TAG).then(
|
|
24
|
+
() => {
|
|
25
|
+
window.clearTimeout(timeoutId);
|
|
26
|
+
resolve();
|
|
27
|
+
},
|
|
28
|
+
(err: unknown) => {
|
|
29
|
+
window.clearTimeout(timeoutId);
|
|
30
|
+
reject(err);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
22
34
|
}
|
|
23
35
|
|
|
24
|
-
function
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
36
|
+
async function ensureMiawScriptAndDefinition(): Promise<void> {
|
|
37
|
+
if (customElements.get(HOSTED_MIAW_UI_TAG)) {
|
|
38
|
+
return;
|
|
27
39
|
}
|
|
28
40
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
) as HTMLScriptElement | null;
|
|
33
|
-
|
|
34
|
-
const awaitDefinition = () =>
|
|
35
|
-
withTimeout(
|
|
36
|
-
customElements.whenDefined(PAGE_BUILDER_TAG),
|
|
37
|
-
DEFINE_TIMEOUT_MS,
|
|
38
|
-
`${PAGE_BUILDER_TAG} did not register within ${
|
|
39
|
-
DEFINE_TIMEOUT_MS / 1000
|
|
40
|
-
}s. ` +
|
|
41
|
-
"Confirm the script loads (network tab), your origin is allowed, and CSP permits this script."
|
|
42
|
-
).then(() => undefined);
|
|
43
|
-
|
|
44
|
-
if (customElements.get(PAGE_BUILDER_TAG)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
41
|
+
let script = document.querySelector(
|
|
42
|
+
`script[src="${SCRIPT_SRC}"]`
|
|
43
|
+
) as HTMLScriptElement | null;
|
|
47
44
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (script) {
|
|
46
|
+
await waitUntilHostedMiawUiDefined();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
50
|
+
script = document.createElement("script");
|
|
51
|
+
script.type = "module";
|
|
52
|
+
script.src = SCRIPT_SRC;
|
|
53
|
+
|
|
54
|
+
await new Promise<void>((resolve, reject) => {
|
|
55
|
+
script!.addEventListener("load", () => resolve(), { once: true });
|
|
56
|
+
script!.addEventListener(
|
|
57
|
+
"error",
|
|
58
|
+
() =>
|
|
59
|
+
reject(
|
|
60
|
+
new Error(
|
|
61
|
+
`Failed to load MIAW UI embed script (${SCRIPT_SRC}). Check status code and referrer rules.`
|
|
62
|
+
)
|
|
63
|
+
),
|
|
64
|
+
{ once: true }
|
|
65
|
+
);
|
|
66
|
+
document.head.appendChild(script!);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await waitUntilHostedMiawUiDefined();
|
|
70
|
+
}
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
function loadMiawUi(): Promise<void> {
|
|
73
|
+
if (miawInitPromise) {
|
|
74
|
+
return miawInitPromise;
|
|
75
|
+
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
miawInitPromise = ensureMiawScriptAndDefinition().catch((e) => {
|
|
78
|
+
miawInitPromise = null;
|
|
77
79
|
throw e;
|
|
78
80
|
});
|
|
79
81
|
|
|
80
|
-
return
|
|
82
|
+
return miawInitPromise;
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
export default class AgentMiawUi extends LightningElement {
|
|
@@ -87,53 +89,93 @@ export default class AgentMiawUi extends LightningElement {
|
|
|
87
89
|
@api messagingUrl!: string;
|
|
88
90
|
@api deploymentDevName = "page_builder_miaw_ui";
|
|
89
91
|
@api richComponentVersion = "v1-stable";
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
@api routingAttributes?: string;
|
|
93
|
+
/**
|
|
94
|
+
* When set, bar gradient start (CSS color); sets `--wes-color-af-bar-gradient-from` on the
|
|
95
|
+
* `.miaw-host` container and on the embed when present (LWC may reset `this.style` on the host).
|
|
96
|
+
*/
|
|
97
|
+
@api gradientFrom?: string;
|
|
98
|
+
/**
|
|
99
|
+
* When set, bar gradient end (CSS color); sets `--wes-color-af-bar-gradient-to` the same way.
|
|
100
|
+
*/
|
|
101
|
+
@api gradientTo?: string;
|
|
92
102
|
|
|
93
103
|
renderedCallback(): void {
|
|
94
|
-
|
|
104
|
+
this.syncGradientToMiawSubtree();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Applies gradient custom properties where the embed can see them (not on `this` — LWC can clear host inline styles). */
|
|
108
|
+
private syncGradientToMiawSubtree(): void {
|
|
109
|
+
const from = this.gradientFrom?.trim();
|
|
110
|
+
const to = this.gradientTo?.trim();
|
|
111
|
+
if (!from && !to) {
|
|
95
112
|
return;
|
|
96
113
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
) {
|
|
114
|
+
|
|
115
|
+
const container = this.template.querySelector(
|
|
116
|
+
".miaw-host"
|
|
117
|
+
) as HTMLElement | null;
|
|
118
|
+
if (!container) {
|
|
102
119
|
return;
|
|
103
120
|
}
|
|
104
121
|
|
|
105
|
-
|
|
106
|
-
|
|
122
|
+
const embed = container.querySelector(
|
|
123
|
+
HOSTED_MIAW_UI_TAG
|
|
124
|
+
) as HTMLElement | null;
|
|
125
|
+
const targets = embed ? [container, embed] : [container];
|
|
107
126
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
127
|
+
for (const node of targets) {
|
|
128
|
+
if (from) {
|
|
129
|
+
node.style.setProperty(
|
|
130
|
+
"--wes-color-af-bar-gradient-from",
|
|
131
|
+
from
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
if (to) {
|
|
135
|
+
node.style.setProperty("--wes-color-af-bar-gradient-to", to);
|
|
136
|
+
}
|
|
111
137
|
}
|
|
138
|
+
}
|
|
112
139
|
|
|
113
|
-
|
|
140
|
+
connectedCallback(): void {
|
|
141
|
+
// Past the connect flush so `this.template` includes `.miaw-host`; parent supplies `@api` in markup.
|
|
142
|
+
queueMicrotask(() => {
|
|
143
|
+
this.mountMiawHost();
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private mountMiawHost(): void {
|
|
148
|
+
if (!this.orgId || !this.messagingUrl) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
(async () => {
|
|
114
152
|
try {
|
|
115
153
|
await loadMiawUi();
|
|
116
154
|
const container = this.template.querySelector(".miaw-host");
|
|
117
|
-
if (!container || container.querySelector(
|
|
155
|
+
if (!container || container.querySelector(HOSTED_MIAW_UI_TAG)) {
|
|
118
156
|
return;
|
|
119
157
|
}
|
|
120
158
|
|
|
121
|
-
const el = document.createElement(
|
|
159
|
+
const el = document.createElement(HOSTED_MIAW_UI_TAG);
|
|
122
160
|
el.setAttribute("org-id", this.orgId);
|
|
123
161
|
el.setAttribute("messaging-url", this.messagingUrl);
|
|
124
162
|
el.setAttribute("deployment-dev-name", this.deploymentDevName);
|
|
163
|
+
el.setAttribute("input-variant", "mini-sidebar");
|
|
125
164
|
el.setAttribute(
|
|
126
165
|
"rich-component-version",
|
|
127
166
|
this.richComponentVersion
|
|
128
167
|
);
|
|
168
|
+
if (this.routingAttributes) {
|
|
169
|
+
el.setAttribute(
|
|
170
|
+
"routing-attributes",
|
|
171
|
+
this.routingAttributes
|
|
172
|
+
);
|
|
173
|
+
}
|
|
129
174
|
container.appendChild(el);
|
|
175
|
+
this.syncGradientToMiawSubtree();
|
|
130
176
|
} catch (e) {
|
|
131
177
|
console.error(e);
|
|
132
|
-
} finally {
|
|
133
|
-
this.ensureMountedPromise = null;
|
|
134
178
|
}
|
|
135
179
|
})();
|
|
136
|
-
|
|
137
|
-
return this.ensureMountedPromise;
|
|
138
180
|
}
|
|
139
181
|
}
|
|
@@ -4,20 +4,28 @@ import { LightningElement, api } from "lwc";
|
|
|
4
4
|
const defaultDomain = "https://developer.salesforce.com";
|
|
5
5
|
const defaultLocale = "en-us";
|
|
6
6
|
const defaultHeaderSettingsBasePath = "/c/public/header-settings";
|
|
7
|
-
const headerSettingsJsonKeys = [
|
|
7
|
+
const headerSettingsJsonKeys = [
|
|
8
|
+
"regionSelectorOverride",
|
|
9
|
+
"contactLinksOverride"
|
|
10
|
+
];
|
|
8
11
|
|
|
9
12
|
export default class DevExNavigation extends LightningElement {
|
|
13
|
+
static renderMode = "light";
|
|
14
|
+
|
|
10
15
|
@api locale: string = defaultLocale;
|
|
11
16
|
@api path: string = defaultHeaderSettingsBasePath;
|
|
12
17
|
@api domain: string = defaultDomain;
|
|
13
18
|
|
|
14
19
|
async connectedCallback(): Promise<void> {
|
|
15
20
|
try {
|
|
16
|
-
const headerSettingsResponse = await fetch(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
const headerSettingsResponse = await fetch(
|
|
22
|
+
`${this.domain}${this.path}/${this.locale}.json`,
|
|
23
|
+
{
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
);
|
|
21
29
|
if (headerSettingsResponse.ok) {
|
|
22
30
|
this.createFullNav(await headerSettingsResponse.json());
|
|
23
31
|
} else {
|
|
@@ -59,15 +67,15 @@ export default class DevExNavigation extends LightningElement {
|
|
|
59
67
|
private createBarebonesNav(): void {
|
|
60
68
|
const hgfNav = this.createGlobalNav({
|
|
61
69
|
origin: "",
|
|
62
|
-
contextNavEnabled: "true"
|
|
70
|
+
contextNavEnabled: "true"
|
|
63
71
|
});
|
|
64
72
|
const hgfNavContext = this.createContextNav({
|
|
65
73
|
variation: "static",
|
|
66
74
|
propertyTitle: {
|
|
67
75
|
label: "Developers",
|
|
68
|
-
url: "/"
|
|
76
|
+
url: "/"
|
|
69
77
|
},
|
|
70
|
-
menuGroup: {}
|
|
78
|
+
menuGroup: {}
|
|
71
79
|
});
|
|
72
80
|
const containerEl = this.refs.globalNavContainer as Element;
|
|
73
81
|
containerEl.appendChild(hgfNav);
|