@salesforcedevs/arch-components 1.20.17-alpha1 → 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.
Files changed (77) hide show
  1. package/package.json +45 -2
  2. package/src/modules/common/context/context.ts +14 -14
  3. package/src/modules/common/effectAdapter/__tests__/effectAdapter.test.ts +4 -4
  4. package/src/modules/common/effectAdapter/effectAdapter.ts +13 -7
  5. package/src/modules/common/reflectedElement/__tests__/reflectedElement.test.ts +5 -5
  6. package/src/modules/common/reflectedElement/reflectedElement.ts +1 -1
  7. package/src/modules/common/slot/__tests__/slot.test.ts +12 -12
  8. package/src/modules/common/slot/slot.ts +4 -3
  9. package/src/modules/sa/coverage/coverage.ts +14 -18
  10. package/src/modules/sa/coverage/types.d.ts +12 -12
  11. package/src/modules/sa/explorer/explorer.ts +25 -25
  12. package/src/modules/sa/gallery/gallery.ts +11 -11
  13. package/src/modules/shared/a11y/a11y.ts +5 -5
  14. package/src/modules/shared/color/color.ts +13 -13
  15. package/src/modules/shared/fetch/fetch.ts +6 -6
  16. package/src/modules/shared/helpers/helpers.ts +6 -6
  17. package/src/modules/shared/i18n/i18n.ts +1 -1
  18. package/src/modules/shared/labels/__tests__/helpers.test.ts +3 -3
  19. package/src/modules/shared/labels/__tests__/pointHelpers.test.ts +3 -3
  20. package/src/modules/shared/labels/__tests__/timeHelpers.test.ts +8 -8
  21. package/src/modules/shared/labels/helpers.ts +4 -4
  22. package/src/modules/shared/labels/pointHelpers.ts +2 -2
  23. package/src/modules/shared/labels/timeHelpers.ts +3 -3
  24. package/src/modules/shared/menu/menu.ts +22 -22
  25. package/src/modules/shared/polling-request.ts +2 -2
  26. package/src/modules/shared/testutils.ts +4 -4
  27. package/src/modules/shared/useEffectAttr.ts +5 -5
  28. package/src/modules/tds/appLauncher/__tests__/appLauncher.test.ts +8 -8
  29. package/src/modules/tds/appLauncher/appLauncher.ts +6 -6
  30. package/src/modules/tds/avatar/__tests__/avatar.test.ts +1 -1
  31. package/src/modules/tds/button/__tests__/button.test.ts +5 -5
  32. package/src/modules/tds/buttonIcon/__tests__/buttonIcon.test.ts +1 -1
  33. package/src/modules/tds/buttonLink/__tests__/buttonLink.test.ts +1 -1
  34. package/src/modules/tds/childSummary/childSummary.ts +2 -2
  35. package/src/modules/tds/contentChildListItem/__tests__/contentChildListItem.test.ts +2 -2
  36. package/src/modules/tds/contentIcon/contentIcon.ts +1 -1
  37. package/src/modules/tds/footerLinks/__tests__/footerLinks.test.ts +2 -2
  38. package/src/modules/tds/headerAvatar/__tests__/headerAvatar.test.ts +4 -4
  39. package/src/modules/tds/headerAvatar/headerAvatar.ts +5 -5
  40. package/src/modules/tds/headerHelpButton/__tests__/headerHelpButton.test.ts +2 -2
  41. package/src/modules/tds/heading/__tests__/heading.test.ts +7 -7
  42. package/src/modules/tds/icon/icon.ts +11 -11
  43. package/src/modules/tds/radio/__tests__/radio.test.ts +1 -1
  44. package/src/modules/tds/search/__tests__/search.test.ts +17 -17
  45. package/src/modules/tds/search/lib/__tests__/listbox.test.ts +16 -16
  46. package/src/modules/tds/search/lib/listbox.ts +16 -16
  47. package/src/modules/tds/search/search.ts +10 -10
  48. package/src/modules/tds/select/__tests__/select.test.ts +1 -1
  49. package/src/modules/tds/summary/__tests__/summary.test.ts +16 -16
  50. package/src/modules/tds/summary/summary.ts +2 -2
  51. package/src/modules/tds/themeProvider/themeProvider.ts +4 -4
  52. package/src/modules/th/favoriteButton/__tests__/favoriteButton.test.ts +1 -1
  53. package/src/modules/th/favoriteButton/mocks/index.ts +2 -2
  54. package/src/modules/th/search/__tests__/search.test.ts +2 -2
  55. package/src/modules/th/search/mocks/index.ts +1 -1
  56. package/src/modules/th/search/search.ts +21 -21
  57. package/src/modules/tm/card/card.ts +15 -15
  58. package/src/modules/tm/content/content.ts +11 -11
  59. package/src/modules/tm/endCapA/__tests__/endCapA.test.ts +2 -2
  60. package/src/modules/tm/eventsA/eventsA.ts +1 -1
  61. package/src/modules/tm/faqA/faqA.ts +4 -4
  62. package/src/modules/tm/featureGridA/__tests__/featureGridA.test.ts +2 -2
  63. package/src/modules/tm/footnote/footnote.ts +1 -1
  64. package/src/modules/tm/heroA/__tests__/heroA.test.ts +2 -2
  65. package/src/modules/tm/heroA/heroA.ts +3 -3
  66. package/src/modules/tm/promoA/__tests__/promoA.test.ts +3 -3
  67. package/src/modules/tm/promoA/promoA.ts +4 -4
  68. package/src/modules/tm/sectionA/sectionA.ts +1 -1
  69. package/src/modules/tm/utils/utils.ts +5 -5
  70. package/src/modules/tm/youtube/youtube.ts +2 -2
  71. package/src/modules/ui/focusTrap/focusTrap.ts +7 -7
  72. package/src/modules/ui/focusVisible/focusVisible.ts +7 -7
  73. package/src/modules/th/tbid/__tests__/__snapshots__/tbid.test.ts.snap +0 -3
  74. package/src/modules/th/tbid/__tests__/tbid.test.ts +0 -242
  75. package/src/modules/th/tbid/tbid.html +0 -1
  76. package/src/modules/th/tbid/tbid.stories.mdx +0 -25
  77. package/src/modules/th/tbid/tbid.ts +0 -215
@@ -18,7 +18,7 @@ export default class extends LightningElement {
18
18
  this.listboxState = state;
19
19
  },
20
20
  onSelect: (index) => {
21
- let { completions, hasCompletions, hasRecents, recents } = this;
21
+ const { completions, hasCompletions, hasRecents, recents } = this;
22
22
  if (hasCompletions) {
23
23
  this.dispatchSearchEvent({
24
24
  type: 'completion',
@@ -32,8 +32,8 @@ export default class extends LightningElement {
32
32
  }
33
33
  },
34
34
  onSubmit: () => {
35
- let { completionTerms } = this;
36
- if (!completionTerms) return;
35
+ const { completionTerms } = this;
36
+ if (!completionTerms) {return;}
37
37
  this.dispatchSearchEvent({ type: 'input', value: completionTerms });
38
38
  },
39
39
  shadowRoot: this.template
@@ -71,7 +71,7 @@ export default class extends LightningElement {
71
71
  }
72
72
 
73
73
  private onInput(e: InputEvent) {
74
- let { value } = e.currentTarget as HTMLInputElement;
74
+ const { value } = e.currentTarget as HTMLInputElement;
75
75
  if ((e as any).key === 'Enter') {
76
76
  const search = encodeURIComponent(value);
77
77
  window.location.replace(`/search/?keywords=${search}`);
@@ -79,16 +79,16 @@ export default class extends LightningElement {
79
79
  }
80
80
 
81
81
  private get showRecents() {
82
- let { completionTerms, hasCompletions, hasRecents, listboxState } =
82
+ const { completionTerms, hasCompletions, hasRecents, listboxState } =
83
83
  this;
84
- if (!listboxState) return false;
85
- if (completionTerms && completionTerms.length) return false;
84
+ if (!listboxState) {return false;}
85
+ if (completionTerms && completionTerms.length) {return false;}
86
86
  return listboxState.active && hasRecents && !hasCompletions;
87
87
  }
88
88
 
89
89
  private get showCompletions() {
90
- let { hasCompletions, listboxState } = this;
91
- if (!listboxState) return false;
90
+ const { hasCompletions, listboxState } = this;
91
+ if (!listboxState) {return false;}
92
92
  return listboxState.active && hasCompletions;
93
93
  }
94
94
 
@@ -96,7 +96,7 @@ export default class extends LightningElement {
96
96
  if (!this.setup) {
97
97
  this.setup = true;
98
98
  if (this.defaultValue) {
99
- let input = this.template.querySelector(
99
+ const input = this.template.querySelector(
100
100
  'input'
101
101
  ) as HTMLInputElement;
102
102
  input.value = this.defaultValue;
@@ -69,7 +69,7 @@ describe('tds-select', () => {
69
69
  await nextTick();
70
70
  await new Promise((resolve) => setTimeout(resolve, 50));
71
71
 
72
- let getSelect = () =>
72
+ const getSelect = () =>
73
73
  element.shadowRoot!.querySelector('select') as HTMLSelectElement;
74
74
 
75
75
  const selectValue = getSelect().value;
@@ -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
- let element = renderIntoBody(html`
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
- let element = renderIntoBody(html`
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
- let element = renderIntoBody(html`
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
- let element = renderIntoBody(html`
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
- let template = ({ showImage, showAction }: any = {}) => html`
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
- let element = renderIntoBody(template());
48
- let header = element.shadowRoot!.querySelector('.header');
49
- let isHidden = () =>
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
- let template = ({ showMetaLeft, showMetaRight }: any = {}) => html`
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
- let element = renderIntoBody(template());
69
- let footer = element.shadowRoot!.querySelector('.footer');
70
- let isHidden = () =>
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
- let element = renderIntoBody(html`
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
- let element = renderIntoBody(
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
- let element = renderIntoBody(html`
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
- let element = renderIntoBody(html`
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
- let slots = Array.from(
62
+ const slots = Array.from(
63
63
  this.template.querySelectorAll('slot')
64
64
  ) as HTMLSlotElement[];
65
- let slotNames = slots
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
- let exists = Array.from(document.querySelectorAll('link')).some(
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
- let element = document.createElement('link');
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
- let urls = mock.requestUrls(String(process.env.API_HOST));
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
- let urls = requestUrls();
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
- let location = {};
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
- let urls = mock.requestUrls(String(process.env.API_HOST));
30
+ const urls = mock.requestUrls(String(process.env.API_HOST));
31
31
 
32
32
  beforeEach(() => {
33
33
  window.location.href = '/';
@@ -17,7 +17,7 @@ export function shouldMockResponse(url: string) {
17
17
  }
18
18
 
19
19
  export function mockResponse(url: string) {
20
- let urls = requestUrls();
20
+ const urls = requestUrls();
21
21
  if (url.includes(urls.recents)) {
22
22
  return JSON.stringify(responses.recents);
23
23
  }
@@ -37,48 +37,48 @@ export default class extends LightningElement {
37
37
  private defaultCompletionTerms = '';
38
38
 
39
39
  private getCompletions = debounce(async (terms: string) => {
40
- let { completionController: prevController, config } = this;
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
- let controller = (this.completionController = new AbortController());
48
- let accessToken = await this.getAccessToken();
49
- let url = getCompletionsUrl({
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
- let { completions } = await getJSON<{ completions: CoveoCompletion[] }>(
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
- let { token } = await this.client.post<{ token: string }>(TOKEN_PATH);
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
- let { config } = this;
76
+ const { config } = this;
77
77
  try {
78
- let { recents } = await this.client.get<{ recents: UserRecent[] }>(
78
+ const { recents } = await this.client.get<{ recents: UserRecent[] }>(
79
79
  RECENTS_PATH
80
80
  );
81
- let { recent_favorite, recent_item } = recents.reduce<
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
- let { config } = this;
114
+ const { config } = this;
115
115
  switch (e.detail.type) {
116
116
  case 'completion': {
117
- let query = new URLSearchParams({
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
- let query = new URLSearchParams({
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
- let params = new URLSearchParams(window.location.search);
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
- let query = new URLSearchParams({
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
- let style: string[] = [];
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
- let image = imgSrc;
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
- } else {
88
+ }
89
89
  const imgType = this.imgSrc?.split('.').pop();
90
90
  const imgName = this.imgSrc?.replace(`.${imgType}`, '');
91
- let srcSet: string[] = [];
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
- } else {
102
+ }
103
103
  const imgType = this.imgSrc?.split('.').pop();
104
104
  const imgName = this.imgSrc?.replace(`.${imgType}`, '');
105
- let srcSet: string[] = [];
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
- let { ctaHref, ctaTarget } = this;
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
- let heading: HTMLElement | null = that.template.querySelector(`[id="${window.location.hash.substring(1)}"]`);
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
- let anchor = e.currentTarget as HTMLAnchorElement;
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
- let filename = url.pathname.substr(
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
- let regexImg = new RegExp(/[^\s]+(.*?).(jpg|jpeg|png|gif|JPG|JPEG|PNG|GIF|webp)$/);
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
- let heading: HTMLElement | null = this.template.querySelector(`[id="${hash.split('?')[0].substring(1)}"]`);
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
- let main = this.template.querySelector('main');
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
- let label = (n as HTMLElement).innerText.trim();
123
- let id = label.replace(/[^a-zA-Z0-9]/g, '_');
124
- let href = `#${id}`;
125
- let style =
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
- let element = renderIntoBody(
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
- let element = renderIntoBody(
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
- let date = new Date(element.getAttribute('date')!);
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
- let isExpanded = this.expanded.has(i);
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
- let expanded = new Set(this.expanded);
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
- let element = renderIntoBody(
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
- let element = renderIntoBody(
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
- let section = this.template.querySelector('section');
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
- let element = renderIntoBody(
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
- let element = renderIntoBody(
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
- } else {
42
+ }
43
43
  const imgType = this.imgSrc.split('.').pop();
44
44
  const imgName = this.imgSrc.replace(`.${imgType || ''}`, '');
45
- let srcSet: string[] = [];
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() {