@salesforcedevs/arch-components 1.20.17-alpha2 → 1.20.17-alpha3
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 +1 -1
- package/src/modules/common/context/context.ts +14 -14
- package/src/modules/common/effectAdapter/__tests__/effectAdapter.test.ts +4 -4
- package/src/modules/common/effectAdapter/effectAdapter.ts +13 -7
- package/src/modules/common/reflectedElement/__tests__/reflectedElement.test.ts +5 -5
- package/src/modules/common/reflectedElement/reflectedElement.ts +1 -1
- package/src/modules/common/slot/__tests__/slot.test.ts +12 -12
- package/src/modules/common/slot/slot.ts +4 -3
- package/src/modules/sa/coverage/coverage.ts +14 -18
- package/src/modules/sa/coverage/types.d.ts +12 -12
- package/src/modules/sa/explorer/explorer.ts +25 -25
- package/src/modules/sa/gallery/gallery.ts +11 -11
- package/src/modules/shared/a11y/a11y.ts +5 -5
- package/src/modules/shared/color/color.ts +13 -13
- package/src/modules/shared/fetch/fetch.ts +6 -6
- package/src/modules/shared/helpers/helpers.ts +6 -6
- package/src/modules/shared/i18n/i18n.ts +1 -1
- package/src/modules/shared/labels/__tests__/helpers.test.ts +3 -3
- package/src/modules/shared/labels/__tests__/pointHelpers.test.ts +3 -3
- package/src/modules/shared/labels/__tests__/timeHelpers.test.ts +8 -8
- package/src/modules/shared/labels/helpers.ts +4 -4
- package/src/modules/shared/labels/pointHelpers.ts +2 -2
- package/src/modules/shared/labels/timeHelpers.ts +3 -3
- package/src/modules/shared/menu/menu.ts +22 -22
- package/src/modules/shared/polling-request.ts +2 -2
- package/src/modules/shared/testutils.ts +4 -4
- package/src/modules/shared/useEffectAttr.ts +5 -5
- package/src/modules/tds/appLauncher/__tests__/appLauncher.test.ts +8 -8
- package/src/modules/tds/appLauncher/appLauncher.ts +6 -6
- package/src/modules/tds/avatar/__tests__/avatar.test.ts +1 -1
- package/src/modules/tds/button/__tests__/button.test.ts +5 -5
- package/src/modules/tds/buttonIcon/__tests__/buttonIcon.test.ts +1 -1
- package/src/modules/tds/buttonLink/__tests__/buttonLink.test.ts +1 -1
- package/src/modules/tds/childSummary/childSummary.ts +2 -2
- package/src/modules/tds/contentChildListItem/__tests__/contentChildListItem.test.ts +2 -2
- package/src/modules/tds/contentIcon/contentIcon.ts +1 -1
- package/src/modules/tds/footerLinks/__tests__/footerLinks.test.ts +2 -2
- package/src/modules/tds/headerAvatar/__tests__/headerAvatar.test.ts +4 -4
- package/src/modules/tds/headerAvatar/headerAvatar.ts +5 -5
- package/src/modules/tds/headerHelpButton/__tests__/headerHelpButton.test.ts +2 -2
- package/src/modules/tds/heading/__tests__/heading.test.ts +7 -7
- package/src/modules/tds/icon/icon.ts +11 -11
- package/src/modules/tds/radio/__tests__/radio.test.ts +1 -1
- package/src/modules/tds/search/__tests__/search.test.ts +17 -17
- package/src/modules/tds/search/lib/__tests__/listbox.test.ts +16 -16
- package/src/modules/tds/search/lib/listbox.ts +16 -16
- package/src/modules/tds/search/search.ts +10 -10
- package/src/modules/tds/select/__tests__/select.test.ts +1 -1
- package/src/modules/tds/summary/__tests__/summary.test.ts +16 -16
- package/src/modules/tds/summary/summary.ts +2 -2
- package/src/modules/tds/themeProvider/themeProvider.ts +4 -4
- package/src/modules/th/favoriteButton/__tests__/favoriteButton.test.ts +1 -1
- package/src/modules/th/favoriteButton/mocks/index.ts +2 -2
- package/src/modules/th/search/__tests__/search.test.ts +2 -2
- package/src/modules/th/search/mocks/index.ts +1 -1
- package/src/modules/th/search/search.ts +21 -21
- package/src/modules/tm/card/card.ts +15 -15
- package/src/modules/tm/content/content.ts +11 -11
- package/src/modules/tm/endCapA/__tests__/endCapA.test.ts +2 -2
- package/src/modules/tm/eventsA/eventsA.ts +1 -1
- package/src/modules/tm/faqA/faqA.ts +4 -4
- package/src/modules/tm/featureGridA/__tests__/featureGridA.test.ts +2 -2
- package/src/modules/tm/footnote/footnote.ts +1 -1
- package/src/modules/tm/heroA/__tests__/heroA.test.ts +2 -2
- package/src/modules/tm/heroA/heroA.ts +3 -3
- package/src/modules/tm/promoA/__tests__/promoA.test.ts +3 -3
- package/src/modules/tm/promoA/promoA.ts +4 -4
- package/src/modules/tm/sectionA/sectionA.ts +1 -1
- package/src/modules/tm/utils/utils.ts +5 -5
- package/src/modules/tm/youtube/youtube.ts +2 -2
- package/src/modules/ui/focusTrap/focusTrap.ts +7 -7
- package/src/modules/ui/focusVisible/focusVisible.ts +7 -7
- package/src/modules/th/tbid/__tests__/__snapshots__/tbid.test.ts.snap +0 -3
- package/src/modules/th/tbid/__tests__/tbid.test.ts +0 -242
- package/src/modules/th/tbid/tbid.html +0 -1
- package/src/modules/th/tbid/tbid.stories.mdx +0 -25
- package/src/modules/th/tbid/tbid.ts +0 -215
|
@@ -7,13 +7,13 @@ customElements.define('tds-summary', Summary.CustomElementConstructor);
|
|
|
7
7
|
describe('tds-content-brick', () => {
|
|
8
8
|
describe('compact (string)', () => {
|
|
9
9
|
it('shows the description ', () => {
|
|
10
|
-
|
|
10
|
+
const element = renderIntoBody(html`
|
|
11
11
|
<tds-summary description="Hello"></tds-summary>
|
|
12
12
|
`);
|
|
13
13
|
expect(element.shadowRoot!.innerHTML).toContain('Hello');
|
|
14
14
|
});
|
|
15
15
|
it('hides the description (string)', () => {
|
|
16
|
-
|
|
16
|
+
const element = renderIntoBody(html`
|
|
17
17
|
<tds-summary compact description="Hello"></tds-summary>
|
|
18
18
|
`);
|
|
19
19
|
expect(element.shadowRoot!.innerHTML).not.toContain('Hello');
|
|
@@ -21,7 +21,7 @@ describe('tds-content-brick', () => {
|
|
|
21
21
|
});
|
|
22
22
|
describe('compact (bool)', () => {
|
|
23
23
|
it('shows the description (string)', () => {
|
|
24
|
-
|
|
24
|
+
const element = renderIntoBody(html`
|
|
25
25
|
<tds-summary
|
|
26
26
|
.compact=${false}
|
|
27
27
|
description="Hello"
|
|
@@ -30,7 +30,7 @@ describe('tds-content-brick', () => {
|
|
|
30
30
|
expect(element.shadowRoot!.innerHTML).toContain('Hello');
|
|
31
31
|
});
|
|
32
32
|
it('hides the description (bool)', () => {
|
|
33
|
-
|
|
33
|
+
const element = renderIntoBody(html`
|
|
34
34
|
<tds-summary .compact=${true} description="Hello"></tds-summary>
|
|
35
35
|
`);
|
|
36
36
|
expect(element.shadowRoot!.innerHTML).not.toContain('Hello');
|
|
@@ -38,15 +38,15 @@ describe('tds-content-brick', () => {
|
|
|
38
38
|
});
|
|
39
39
|
// Skip this test as LWC in test mode doesn't support dynamic slot content with conditional rendering
|
|
40
40
|
it.skip('hides the header if no slots are filled', async () => {
|
|
41
|
-
|
|
41
|
+
const template = ({ showImage, showAction }: any = {}) => html`
|
|
42
42
|
<tds-summary>
|
|
43
43
|
${showImage ? html` <img slot="image" /> ` : null}
|
|
44
44
|
${showAction ? html` <button slot="action" /> ` : null}
|
|
45
45
|
</tds-summary>
|
|
46
46
|
`;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const element = renderIntoBody(template());
|
|
48
|
+
const header = element.shadowRoot!.querySelector('.header');
|
|
49
|
+
const isHidden = () =>
|
|
50
50
|
header!.matches(
|
|
51
51
|
'.summary:not([data-slots*="image"]):not([data-slots*="action"]) .header'
|
|
52
52
|
);
|
|
@@ -59,15 +59,15 @@ describe('tds-content-brick', () => {
|
|
|
59
59
|
expect(isHidden()).toBe(false);
|
|
60
60
|
});
|
|
61
61
|
it.skip('hides the footer if no slots are filled', async () => {
|
|
62
|
-
|
|
62
|
+
const template = ({ showMetaLeft, showMetaRight }: any = {}) => html`
|
|
63
63
|
<tds-summary>
|
|
64
64
|
${showMetaLeft ? html` <span slot="meta-left" /> ` : null}
|
|
65
65
|
${showMetaRight ? html` <span slot="meta-right" /> ` : null}
|
|
66
66
|
</tds-summary>
|
|
67
67
|
`;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
const element = renderIntoBody(template());
|
|
69
|
+
const footer = element.shadowRoot!.querySelector('.footer');
|
|
70
|
+
const isHidden = () =>
|
|
71
71
|
footer!.matches('.summary:not([data-slots*="meta"]) .footer');
|
|
72
72
|
expect(isHidden()).toBe(true);
|
|
73
73
|
render(template({ showMetaLeft: true }), element.parentElement!);
|
|
@@ -80,7 +80,7 @@ describe('tds-content-brick', () => {
|
|
|
80
80
|
describe('titleMode', () => {
|
|
81
81
|
describe('anchor', () => {
|
|
82
82
|
it('renders the correct element', () => {
|
|
83
|
-
|
|
83
|
+
const element = renderIntoBody(html`
|
|
84
84
|
<tds-summary
|
|
85
85
|
description="Hello"
|
|
86
86
|
path="/"
|
|
@@ -92,7 +92,7 @@ describe('tds-content-brick', () => {
|
|
|
92
92
|
).toBe('A');
|
|
93
93
|
});
|
|
94
94
|
it('renders a button if no path is specified', () => {
|
|
95
|
-
|
|
95
|
+
const element = renderIntoBody(
|
|
96
96
|
html`
|
|
97
97
|
<tds-summary
|
|
98
98
|
title="Hello"
|
|
@@ -107,7 +107,7 @@ describe('tds-content-brick', () => {
|
|
|
107
107
|
});
|
|
108
108
|
describe('button', () => {
|
|
109
109
|
it('renders the correct element', () => {
|
|
110
|
-
|
|
110
|
+
const element = renderIntoBody(html`
|
|
111
111
|
<tds-summary
|
|
112
112
|
description="Hello"
|
|
113
113
|
title-mode="button"
|
|
@@ -120,7 +120,7 @@ describe('tds-content-brick', () => {
|
|
|
120
120
|
});
|
|
121
121
|
describe('text', () => {
|
|
122
122
|
it('renders the correct element', () => {
|
|
123
|
-
|
|
123
|
+
const element = renderIntoBody(html`
|
|
124
124
|
<tds-summary
|
|
125
125
|
description="Hello"
|
|
126
126
|
title-mode="text"
|
|
@@ -59,10 +59,10 @@ export default class extends LightningElement {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
private onSlotChange() {
|
|
62
|
-
|
|
62
|
+
const slots = Array.from(
|
|
63
63
|
this.template.querySelectorAll('slot')
|
|
64
64
|
) as HTMLSlotElement[];
|
|
65
|
-
|
|
65
|
+
const slotNames = slots
|
|
66
66
|
.filter((slot) => slot.assignedNodes()[0])
|
|
67
67
|
.map((slot) => slot.getAttribute('name'))
|
|
68
68
|
.join(' ');
|
|
@@ -16,18 +16,18 @@ export default class extends LightningElement {
|
|
|
16
16
|
/* ROLLUP_PLATFORM
|
|
17
17
|
return;
|
|
18
18
|
*/
|
|
19
|
-
if (this.fonts) appendStyleSheet(`${this.assetsUrl}/css/tds.css`);
|
|
19
|
+
if (this.fonts) {appendStyleSheet(`${this.assetsUrl}/css/tds.css`);}
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function appendStyleSheet(href: string) {
|
|
24
|
-
|
|
24
|
+
const exists = Array.from(document.querySelectorAll('link')).some(
|
|
25
25
|
(n) => n.href === href
|
|
26
26
|
);
|
|
27
|
-
if (exists) return;
|
|
27
|
+
if (exists) {return;}
|
|
28
28
|
document.head.appendChild(
|
|
29
29
|
(() => {
|
|
30
|
-
|
|
30
|
+
const element = document.createElement('link');
|
|
31
31
|
element.href = href;
|
|
32
32
|
element.rel = 'stylesheet';
|
|
33
33
|
element.type = 'text/css';
|
|
@@ -10,7 +10,7 @@ const elementName = 'th-favorite-button';
|
|
|
10
10
|
customElements.define(elementName, FavoriteButton.CustomElementConstructor);
|
|
11
11
|
|
|
12
12
|
describe(elementName, () => {
|
|
13
|
-
|
|
13
|
+
const urls = mock.requestUrls(String(process.env.API_HOST));
|
|
14
14
|
|
|
15
15
|
afterEach(() => {
|
|
16
16
|
jest.clearAllMocks();
|
|
@@ -7,6 +7,6 @@ export function requestUrls(baseUrl: string = '') {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function mockResponse(url: string) {
|
|
10
|
-
|
|
11
|
-
if (url.includes(urls.favorites)) return JSON.stringify({});
|
|
10
|
+
const urls = requestUrls();
|
|
11
|
+
if (url.includes(urls.favorites)) {return JSON.stringify({});}
|
|
12
12
|
}
|
|
@@ -14,7 +14,7 @@ process.env.API_HOST = 'https://www.trailhead.com';
|
|
|
14
14
|
|
|
15
15
|
customElements.define('th-search', Search.CustomElementConstructor);
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
const location = {};
|
|
18
18
|
|
|
19
19
|
Object.defineProperty(window, 'location', {
|
|
20
20
|
get: () => location
|
|
@@ -27,7 +27,7 @@ Object.defineProperty(window.location, 'replace', {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
describe('th-search', () => {
|
|
30
|
-
|
|
30
|
+
const urls = mock.requestUrls(String(process.env.API_HOST));
|
|
31
31
|
|
|
32
32
|
beforeEach(() => {
|
|
33
33
|
window.location.href = '/';
|
|
@@ -37,48 +37,48 @@ export default class extends LightningElement {
|
|
|
37
37
|
private defaultCompletionTerms = '';
|
|
38
38
|
|
|
39
39
|
private getCompletions = debounce(async (terms: string) => {
|
|
40
|
-
|
|
41
|
-
if (prevController) prevController.abort();
|
|
42
|
-
if (!config) return;
|
|
40
|
+
const { completionController: prevController, config } = this;
|
|
41
|
+
if (prevController) {prevController.abort();}
|
|
42
|
+
if (!config) {return;}
|
|
43
43
|
if (!terms.length) {
|
|
44
44
|
this.completions = [];
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const controller = (this.completionController = new AbortController());
|
|
48
|
+
const accessToken = await this.getAccessToken();
|
|
49
|
+
const url = getCompletionsUrl({
|
|
50
50
|
accessToken,
|
|
51
51
|
baseUrl: config.coveo.querySuggestUrl,
|
|
52
52
|
locale: config.coveo.locale,
|
|
53
53
|
terms
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
const { completions } = await getJSON<{ completions: CoveoCompletion[] }>(
|
|
56
56
|
url,
|
|
57
57
|
{ signal: controller.signal }
|
|
58
58
|
);
|
|
59
59
|
if (this.completionTerms === terms)
|
|
60
|
-
this.completions = completions.map((c) => ({
|
|
60
|
+
{this.completions = completions.map((c) => ({
|
|
61
61
|
value: c.expression,
|
|
62
62
|
valueHighlighted: c.highlighted
|
|
63
|
-
}));
|
|
63
|
+
}));}
|
|
64
64
|
}, 250);
|
|
65
65
|
|
|
66
66
|
private recents: RecentSection[] | null = null;
|
|
67
67
|
|
|
68
68
|
private async getAccessToken() {
|
|
69
|
-
if (this.accessToken) return this.accessToken;
|
|
70
|
-
|
|
69
|
+
if (this.accessToken) {return this.accessToken;}
|
|
70
|
+
const { token } = await this.client.post<{ token: string }>(TOKEN_PATH);
|
|
71
71
|
this.accessToken = token;
|
|
72
72
|
return token;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
private async getRecents() {
|
|
76
|
-
|
|
76
|
+
const { config } = this;
|
|
77
77
|
try {
|
|
78
|
-
|
|
78
|
+
const { recents } = await this.client.get<{ recents: UserRecent[] }>(
|
|
79
79
|
RECENTS_PATH
|
|
80
80
|
);
|
|
81
|
-
|
|
81
|
+
const { recent_favorite, recent_item } = recents.reduce<
|
|
82
82
|
{
|
|
83
83
|
[type in UserRecent['type']]: UserRecent[];
|
|
84
84
|
}
|
|
@@ -102,7 +102,7 @@ export default class extends LightningElement {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
private onFocus(e: FocusEvent) {
|
|
105
|
-
if (!this.recents) this.getRecents();
|
|
105
|
+
if (!this.recents) {this.getRecents();}
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
private onChange(e: CustomEvent<{ value: string }>) {
|
|
@@ -111,10 +111,10 @@ export default class extends LightningElement {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
private onSearch(e: CustomEvent<SearchEvent>) {
|
|
114
|
-
|
|
114
|
+
const { config } = this;
|
|
115
115
|
switch (e.detail.type) {
|
|
116
116
|
case 'completion': {
|
|
117
|
-
|
|
117
|
+
const query = new URLSearchParams({
|
|
118
118
|
keywords: e.detail.value.value,
|
|
119
119
|
suggested: 'true'
|
|
120
120
|
}).toString();
|
|
@@ -122,7 +122,7 @@ export default class extends LightningElement {
|
|
|
122
122
|
break;
|
|
123
123
|
}
|
|
124
124
|
case 'input': {
|
|
125
|
-
|
|
125
|
+
const query = new URLSearchParams({
|
|
126
126
|
keywords: e.detail.value
|
|
127
127
|
}).toString();
|
|
128
128
|
window.location.href = `${config!.searchUrl}?${query}`;
|
|
@@ -136,7 +136,7 @@ export default class extends LightningElement {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
connectedCallback() {
|
|
139
|
-
|
|
139
|
+
const params = new URLSearchParams(window.location.search);
|
|
140
140
|
if (params.has('keywords')) {
|
|
141
141
|
this.defaultCompletionTerms = params.get('keywords')!;
|
|
142
142
|
}
|
|
@@ -150,8 +150,8 @@ function getCompletionsUrl(params: {
|
|
|
150
150
|
terms: string;
|
|
151
151
|
}) {
|
|
152
152
|
let { accessToken, baseUrl, locale, terms } = { ...params };
|
|
153
|
-
if (!/^http/.test(baseUrl)) baseUrl = `${process.env.API_HOST}${baseUrl}`;
|
|
154
|
-
|
|
153
|
+
if (!/^http/.test(baseUrl)) {baseUrl = `${process.env.API_HOST}${baseUrl}`;}
|
|
154
|
+
const query = new URLSearchParams({
|
|
155
155
|
access_token: accessToken,
|
|
156
156
|
count: '10',
|
|
157
157
|
enableWordCompletion: 'true',
|
|
@@ -53,12 +53,12 @@ export default class extends LightningElement {
|
|
|
53
53
|
private cardId: string = '';
|
|
54
54
|
|
|
55
55
|
private get imgStyle() {
|
|
56
|
-
if (!this.imgSrc) return '';
|
|
57
|
-
|
|
56
|
+
if (!this.imgSrc) {return '';}
|
|
57
|
+
const style: string[] = [];
|
|
58
58
|
const { imgVariantResponsive: variant, imgSrc } = this;
|
|
59
59
|
|
|
60
60
|
if (variant.includes('cover')) {
|
|
61
|
-
|
|
61
|
+
const image = imgSrc;
|
|
62
62
|
|
|
63
63
|
// Use the original image if it's a remote image or WebP
|
|
64
64
|
/* if (!this.isRemoteImage && !imgSrc.includes('webp')) {
|
|
@@ -85,29 +85,29 @@ export default class extends LightningElement {
|
|
|
85
85
|
private get imgSrcSetWebP() {
|
|
86
86
|
if (this.isRemoteImage) {
|
|
87
87
|
return this.imgSrc;
|
|
88
|
-
}
|
|
88
|
+
}
|
|
89
89
|
const imgType = this.imgSrc?.split('.').pop();
|
|
90
90
|
const imgName = this.imgSrc?.replace(`.${imgType}`, '');
|
|
91
|
-
|
|
91
|
+
const srcSet: string[] = [];
|
|
92
92
|
widths.forEach((width) => {
|
|
93
93
|
srcSet.push(`${imgName}-${width}w.webp ${width}w`);
|
|
94
94
|
});
|
|
95
95
|
return srcSet.join(',');
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
private get imgSrcSetJpg() {
|
|
100
100
|
if (this.isRemoteImage) {
|
|
101
101
|
return this.imgSrc;
|
|
102
|
-
}
|
|
102
|
+
}
|
|
103
103
|
const imgType = this.imgSrc?.split('.').pop();
|
|
104
104
|
const imgName = this.imgSrc?.replace(`.${imgType}`, '');
|
|
105
|
-
|
|
105
|
+
const srcSet: string[] = [];
|
|
106
106
|
widths.forEach((width) => {
|
|
107
107
|
srcSet.push(`${imgName}-${width}w.jpg ${width}w`);
|
|
108
108
|
});
|
|
109
109
|
return srcSet.join(',');
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
private get imgTagNoSvg() {
|
|
@@ -127,7 +127,7 @@ export default class extends LightningElement {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
private get imgVariantResponsive() {
|
|
130
|
-
if (!this.snapToTop) return this.imgVariant;
|
|
130
|
+
if (!this.snapToTop) {return this.imgVariant;}
|
|
131
131
|
return String(this.imgVariant).replace(/left|right/, 'top');
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -182,10 +182,10 @@ export default class extends LightningElement {
|
|
|
182
182
|
element
|
|
183
183
|
);
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
const { ctaHref, ctaTarget } = this;
|
|
186
186
|
if (ctaHref) {
|
|
187
|
-
if (ctaTarget) window.open(ctaHref, ctaTarget);
|
|
188
|
-
else window.location.href = ctaHref;
|
|
187
|
+
if (ctaTarget) {window.open(ctaHref, ctaTarget);}
|
|
188
|
+
else {window.location.href = ctaHref;}
|
|
189
189
|
}
|
|
190
190
|
this.trackLinkClick(e, true);
|
|
191
191
|
}
|
|
@@ -243,8 +243,8 @@ export default class extends LightningElement {
|
|
|
243
243
|
this.trackLinkClick(e as unknown as MouseEvent, false);
|
|
244
244
|
e.preventDefault();
|
|
245
245
|
if (this.ctaHref) {
|
|
246
|
-
if (this.ctaTarget) window.open(this.ctaHref, this.ctaTarget);
|
|
247
|
-
else window.location.href = this.ctaHref;
|
|
246
|
+
if (this.ctaTarget) {window.open(this.ctaHref, this.ctaTarget);}
|
|
247
|
+
else {window.location.href = this.ctaHref;}
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
}
|
|
@@ -41,7 +41,7 @@ export default class extends LightningElement {
|
|
|
41
41
|
this.setContent();
|
|
42
42
|
const that = this;
|
|
43
43
|
window.addEventListener('hashchange', function locationHashChanged() {
|
|
44
|
-
|
|
44
|
+
const heading: HTMLElement | null = that.template.querySelector(`[id="${window.location.hash.substring(1)}"]`);
|
|
45
45
|
if (heading) {
|
|
46
46
|
heading.style.scrollMarginTop = `var(--dx-g-global-header-height)`; // required adjustment for global nav
|
|
47
47
|
heading.scrollIntoView({
|
|
@@ -60,12 +60,12 @@ export default class extends LightningElement {
|
|
|
60
60
|
if (!this.didSetContent) {
|
|
61
61
|
this.didSetContent = true;
|
|
62
62
|
this.setContent();
|
|
63
|
-
if (window.location.hash) this.scrollToHash(window.location.hash);
|
|
63
|
+
if (window.location.hash) {this.scrollToHash(window.location.hash);}
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
private onHeadingClick(e: MouseEvent) {
|
|
68
|
-
|
|
68
|
+
const anchor = e.currentTarget as HTMLAnchorElement;
|
|
69
69
|
this.scrollToHash(anchor.hash);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -82,12 +82,12 @@ export default class extends LightningElement {
|
|
|
82
82
|
href || '',
|
|
83
83
|
window.location.protocol + '//' + window.location.host
|
|
84
84
|
);
|
|
85
|
-
|
|
85
|
+
const filename = url.pathname.substr(
|
|
86
86
|
url.pathname.lastIndexOf('/') + 1
|
|
87
87
|
);
|
|
88
88
|
|
|
89
89
|
if (anchorEl.hasAttribute('download') || filename.includes('.')) {
|
|
90
|
-
|
|
90
|
+
const regexImg = new RegExp(/[^\s]+(.*?).(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF|webp)$/);
|
|
91
91
|
if (regexImg.test(filename)) {
|
|
92
92
|
sendInteractionEvent('Image Click', InteractionEventTypes.IMAGE_CLICK, e, element)
|
|
93
93
|
} else {
|
|
@@ -100,7 +100,7 @@ export default class extends LightningElement {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
private scrollToHash(hash: string) {
|
|
103
|
-
|
|
103
|
+
const heading: HTMLElement | null = this.template.querySelector(`[id="${hash.split('?')[0].substring(1)}"]`);
|
|
104
104
|
if (heading) {
|
|
105
105
|
heading.style.scrollMarginTop = `var(--dx-g-global-header-height)`; // required adjustment for global nav
|
|
106
106
|
heading.scrollIntoView({
|
|
@@ -111,7 +111,7 @@ export default class extends LightningElement {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
private setContent() {
|
|
114
|
-
|
|
114
|
+
const main = this.template.querySelector('main');
|
|
115
115
|
if (main) {
|
|
116
116
|
main.innerHTML = this.template.host.innerHTML.replace(
|
|
117
117
|
/(<table>[\s\S]+?<\/table>)/g,
|
|
@@ -119,10 +119,10 @@ export default class extends LightningElement {
|
|
|
119
119
|
);
|
|
120
120
|
this.headings = Array.from(main.querySelectorAll('h2,h3')).map(
|
|
121
121
|
(n) => {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
const label = (n as HTMLElement).innerText.trim();
|
|
123
|
+
const id = label.replace(/[^a-zA-Z0-9]/g, '_');
|
|
124
|
+
const href = `#${id}`;
|
|
125
|
+
const style =
|
|
126
126
|
n.tagName === 'H3' ? 'padding-left: 1.25rem' : '';
|
|
127
127
|
// Side effects in map ftw
|
|
128
128
|
n.id = id;
|
|
@@ -6,7 +6,7 @@ customElements.define('tm-end-cap-a', EndCapA.CustomElementConstructor);
|
|
|
6
6
|
|
|
7
7
|
describe('tm-end-cap-a', () => {
|
|
8
8
|
it('works', async () => {
|
|
9
|
-
|
|
9
|
+
const element = renderIntoBody(
|
|
10
10
|
html`
|
|
11
11
|
<tm-end-cap-a
|
|
12
12
|
cta-label="Click"
|
|
@@ -22,7 +22,7 @@ describe('tm-end-cap-a', () => {
|
|
|
22
22
|
it('dispatched a trailhead track event', async () => {
|
|
23
23
|
const handler = jest.fn();
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const element = renderIntoBody(
|
|
26
26
|
html`
|
|
27
27
|
<tm-end-cap-a
|
|
28
28
|
cta-label="Click"
|
|
@@ -16,7 +16,7 @@ export type Event = {
|
|
|
16
16
|
export default class extends ChildrenElement<Event> {
|
|
17
17
|
childTagName = 'TM-EVENT-ITEM';
|
|
18
18
|
extractor = (element: Element) => {
|
|
19
|
-
|
|
19
|
+
const date = new Date(element.getAttribute('date')!);
|
|
20
20
|
return {
|
|
21
21
|
day: String(date.getDate()),
|
|
22
22
|
date: element.getAttribute('date')!,
|
|
@@ -15,16 +15,16 @@ export default class extends ChildrenElement<Item> {
|
|
|
15
15
|
|
|
16
16
|
private get faqs() {
|
|
17
17
|
return this.items.map((item, i) => {
|
|
18
|
-
|
|
18
|
+
const isExpanded = this.expanded.has(i);
|
|
19
19
|
return {
|
|
20
20
|
...item,
|
|
21
21
|
className: `item ${isExpanded ? 'item--expanded' : ''}`,
|
|
22
22
|
id: `item-${i}`,
|
|
23
23
|
expanded: isExpanded,
|
|
24
24
|
onClick: () => {
|
|
25
|
-
|
|
26
|
-
if (expanded.has(i)) expanded.delete(i);
|
|
27
|
-
else expanded.add(i);
|
|
25
|
+
const expanded = new Set(this.expanded);
|
|
26
|
+
if (expanded.has(i)) {expanded.delete(i);}
|
|
27
|
+
else {expanded.add(i);}
|
|
28
28
|
this.expanded = expanded;
|
|
29
29
|
}
|
|
30
30
|
};
|
|
@@ -23,7 +23,7 @@ describe('tm-feature-grid-a', () => {
|
|
|
23
23
|
// Skip these tests as LWC in test mode doesn't support child nodes for light DOM components
|
|
24
24
|
// The featureGridA component uses slots for tm-card children, which isn't compatible with lit-html rendering in tests
|
|
25
25
|
it.skip('works', async () => {
|
|
26
|
-
|
|
26
|
+
const element = renderIntoBody(
|
|
27
27
|
html`
|
|
28
28
|
<tm-feature-grid-a>
|
|
29
29
|
<tm-card
|
|
@@ -107,7 +107,7 @@ describe('tm-feature-grid-a', () => {
|
|
|
107
107
|
});
|
|
108
108
|
|
|
109
109
|
it('renders the component', () => {
|
|
110
|
-
|
|
110
|
+
const element = renderIntoBody(
|
|
111
111
|
html`<tm-feature-grid-a></tm-feature-grid-a>`
|
|
112
112
|
);
|
|
113
113
|
expect(element).toBeTruthy();
|
|
@@ -27,7 +27,7 @@ export default class extends LightningElement {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
private setContent() {
|
|
30
|
-
|
|
30
|
+
const section = this.template.querySelector('section');
|
|
31
31
|
if (section) {
|
|
32
32
|
section.innerHTML = this.template.host.innerHTML;
|
|
33
33
|
}
|
|
@@ -6,7 +6,7 @@ customElements.define('tm-hero-a', HeroA.CustomElementConstructor);
|
|
|
6
6
|
|
|
7
7
|
describe('tm-hero-a', () => {
|
|
8
8
|
it('works', async () => {
|
|
9
|
-
|
|
9
|
+
const element = renderIntoBody(
|
|
10
10
|
html`
|
|
11
11
|
<tm-hero-a
|
|
12
12
|
cta-label="Click"
|
|
@@ -22,7 +22,7 @@ describe('tm-hero-a', () => {
|
|
|
22
22
|
it('dispatched a trailhead track event', async () => {
|
|
23
23
|
const handler = jest.fn();
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const element = renderIntoBody(
|
|
26
26
|
html`
|
|
27
27
|
<tm-hero-a
|
|
28
28
|
cta-label="Click"
|
|
@@ -39,15 +39,15 @@ export default class extends LightningElement {
|
|
|
39
39
|
|
|
40
40
|
if(this.isRemoteImage){
|
|
41
41
|
return this.imgSrc;
|
|
42
|
-
}
|
|
42
|
+
}
|
|
43
43
|
const imgType = this.imgSrc.split('.').pop();
|
|
44
44
|
const imgName = this.imgSrc.replace(`.${imgType || ''}`, '');
|
|
45
|
-
|
|
45
|
+
const srcSet: string[] = [];
|
|
46
46
|
widths.forEach((width) => {
|
|
47
47
|
srcSet.push(`${imgName}-${width}w.webp ${width}w`);
|
|
48
48
|
});
|
|
49
49
|
return srcSet.join(',');
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
private get isRemoteImage() {
|
|
@@ -19,7 +19,7 @@ describe('tm-prom-a', () => {
|
|
|
19
19
|
open = jest.fn();
|
|
20
20
|
});
|
|
21
21
|
it('handles click on the image', async () => {
|
|
22
|
-
|
|
22
|
+
const element = renderIntoBody(
|
|
23
23
|
html`
|
|
24
24
|
<tm-prom-a
|
|
25
25
|
cta-href="/promo"
|
|
@@ -32,7 +32,7 @@ describe('tm-prom-a', () => {
|
|
|
32
32
|
expect(open).toHaveBeenCalledWith('/promo', '_blank');
|
|
33
33
|
});
|
|
34
34
|
it('stops propogation on the tds-button-link', async () => {
|
|
35
|
-
|
|
35
|
+
const element = renderIntoBody(
|
|
36
36
|
html`
|
|
37
37
|
<tm-prom-a
|
|
38
38
|
cta-href="/promo"
|
|
@@ -48,7 +48,7 @@ describe('tm-prom-a', () => {
|
|
|
48
48
|
expect(open).not.toHaveBeenCalled();
|
|
49
49
|
});
|
|
50
50
|
it('tracks survey links', async () => {
|
|
51
|
-
|
|
51
|
+
const element = renderIntoBody(
|
|
52
52
|
html`
|
|
53
53
|
<tm-prom-a
|
|
54
54
|
cta-target="_blank"
|
|
@@ -36,16 +36,16 @@ export default class extends LightningElement {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
private onClick(e: MouseEvent) {
|
|
39
|
-
|
|
39
|
+
const { ctaHref, ctaTarget } = this;
|
|
40
40
|
if (ctaHref) {
|
|
41
|
-
if (ctaTarget) window.open(ctaHref, ctaTarget);
|
|
42
|
-
else window.location.href = ctaHref;
|
|
41
|
+
if (ctaTarget) {window.open(ctaHref, ctaTarget);}
|
|
42
|
+
else {window.location.href = ctaHref;}
|
|
43
43
|
}
|
|
44
44
|
this.trackLinkClick();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
private trackLinkClick() {
|
|
48
|
-
|
|
48
|
+
const { ctaHref, ctaTitle } = this;
|
|
49
49
|
if (ctaHref === 'https://sfdc.co/arch-site-survey') {
|
|
50
50
|
track(this.template.host, 'site_survey', {
|
|
51
51
|
linkText: ctaTitle,
|
|
@@ -10,7 +10,7 @@ export default class extends LightningElement {
|
|
|
10
10
|
@api ctaTarget: string | null = null;
|
|
11
11
|
|
|
12
12
|
connectedCallback() {
|
|
13
|
-
|
|
13
|
+
const hash = window.location.hash.slice(1);
|
|
14
14
|
if (this.id && this.id === hash) {
|
|
15
15
|
// We have to restore the natural browser behavior of
|
|
16
16
|
// jumping to anchors because when DOMContentLoaded fires
|