@salesforcedevs/dx-components 0.24.1 → 0.25.2-alpha.30
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/lwc.config.json +3 -1
- package/package.json +2 -3
- package/src/.DS_Store +0 -0
- package/src/modules/.DS_Store +0 -0
- package/src/modules/dx/.DS_Store +0 -0
- package/src/modules/dx/banner/__tests__/banner.test.ts +11 -9
- package/src/modules/dx/brandThemeProvider/__tests__/brandThemeProvider.test.ts +1 -1
- package/src/modules/dx/breadcrumbs/__tests__/breadcrumbs.test.ts +7 -10
- package/src/modules/dx/button/__tests__/button.test.ts +2 -2
- package/src/modules/dx/cardBlogPost/__tests__/cardBlogPost.test.ts +3 -4
- package/src/modules/dx/cardBlogPostProvider/__tests__/cardBlogPostProvider.test.ts +1 -1
- package/src/modules/dx/cardBlogPostProvider/cardBlogPostProvider.ts +1 -1
- package/src/modules/dx/cardCallout/__tests__/cardCallout.test.ts +4 -7
- package/src/modules/dx/cardCallout/cardCallout.ts +1 -1
- package/src/modules/dx/cardContent/__tests__/cardContent.test.ts +27 -39
- package/src/modules/dx/cardContent/cardContent.ts +2 -2
- package/src/modules/dx/cardDocs/__tests__/cardDocs.test.ts +3 -3
- package/src/modules/dx/cardDocs/cardDocs.ts +1 -1
- package/src/modules/dx/cardEvent/__tests__/cardEvent.test.ts +9 -13
- package/src/modules/dx/cardExpanded/__tests__/cardExpanded.test.ts +2 -2
- package/src/modules/dx/cardExpanded/cardExpanded.ts +1 -1
- package/src/modules/dx/cardMinimal/__tests__/cardMinimal.test.ts +2 -2
- package/src/modules/dx/cardMinimal/cardMinimal.ts +1 -1
- package/src/modules/dx/cardNews/__tests__/cardNews.test.ts +3 -4
- package/src/modules/dx/cardNews/cardNews.ts +1 -1
- package/src/modules/dx/cardPodcastEpisode/__tests__/cardPodcastEpisode.test.ts +5 -7
- package/src/modules/dx/cardPodcastEpisodeProvider/__tests__/cardPodcastEpisodeProvider.test.ts +1 -1
- package/src/modules/dx/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +1 -1
- package/src/modules/dx/cardSmall/__tests__/cardSmall.test.ts +10 -14
- package/src/modules/dx/cardSmall/cardSmall.ts +1 -1
- package/src/modules/dx/cardTitle/__tests__/cardTitle.test.ts +1 -1
- package/src/modules/dx/cardTrailheadModule/__tests__/cardTrailheadModule.test.ts +1 -1
- package/src/modules/dx/cardVideoPreview/__tests__/cardVideoPreview.test.ts +1 -1
- package/src/modules/dx/checkbox/__tests__/checkbox.test.ts +3 -4
- package/src/modules/dx/checkboxGroup/__tests__/checkboxGroup.test.ts +1 -1
- package/src/modules/dx/codeBlock/__tests__/codeBlock.test.ts +3 -3
- package/src/modules/dx/codeBlock/codeBlock.ts +1 -1
- package/src/modules/dx/dropdown/__tests__/dropdown.test.ts +16 -23
- package/src/modules/dx/dropdown/dropdown.ts +6 -6
- package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +1 -1
- package/src/modules/dx/emptyState/__tests__/emptyState.test.ts +1 -1
- package/src/modules/dx/feature/__tests__/feature.test.ts +6 -5
- package/src/modules/dx/featureGrid/__tests__/featureGrid.test.ts +2 -2
- package/src/modules/dx/featuredContentHeader/__tests__/featuredContentHeader.test.ts +27 -40
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +1 -1
- package/src/modules/dx/featuresList/__tests__/featuresList.test.ts +9 -13
- package/src/modules/dx/footer/__tests__/footer.test.ts +1 -1
- package/src/modules/dx/footerOption/__tests__/footerOption.test.ts +1 -1
- package/src/modules/dx/formattedDateTime/__tests__/formattedDateTime.test.ts +1 -1
- package/src/modules/dx/grid/__tests__/grid.test.ts +1 -1
- package/src/modules/dx/groupBio/__tests__/groupBio.test.ts +1 -1
- package/src/modules/dx/groupText/__tests__/groupText.test.ts +9 -13
- package/src/modules/dx/groupText/groupText.stories.ts +1 -1
- package/src/modules/dx/groupText/groupText.ts +1 -1
- package/src/modules/dx/header/__tests__/header.test.ts +3 -3
- package/src/modules/dx/header/__tests__/mockProps.ts +1 -1
- package/src/modules/dx/header/header.ts +1 -1
- package/src/modules/dx/headerMobileNavMenu/__tests__/headerMobileNavMenu.test.ts +2 -2
- package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.ts +1 -1
- package/src/modules/dx/headerMobileNavMenuOption/__tests__/headerMobileNavMenuOption.test.ts +1 -1
- package/src/modules/dx/headerNav/__tests__/headerNav.test.ts +1 -1
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +2 -2
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +1 -1
- package/src/modules/dx/headerSearch/headerSearch.ts +1 -1
- package/src/modules/dx/helmet/__tests__/helmet.test.ts +3 -4
- package/src/modules/dx/hr/__tests__/hr.test.ts +1 -1
- package/src/modules/dx/icon/__tests__/icon.test.ts +1 -1
- package/src/modules/dx/icon/icon.ts +1 -1
- package/src/modules/dx/iconBadge/__tests__/iconBadge.test.ts +1 -1
- package/src/modules/dx/iconBadge/iconBadge.ts +1 -1
- package/src/modules/dx/imageAndLabel/__tests__/imageAndLabel.test.ts +1 -1
- package/src/modules/dx/input/__tests__/input.test.ts +23 -34
- package/src/modules/dx/input/input.ts +1 -1
- package/src/modules/dx/instrumentation/__tests__/instrumentation.test.ts +2 -2
- package/src/modules/dx/interactiveImage/__tests__/interactiveImage.test.ts +7 -10
- package/src/modules/dx/lazy/__tests__/lazy.test.ts +1 -1
- package/src/modules/dx/pagination/__tests__/pagination.test.ts +1 -1
- package/src/modules/dx/podcastHost/__tests__/podcastHost.test.ts +1 -1
- package/src/modules/dx/podcastPlayer/__tests__/podcastPlayer.test.ts +1 -1
- package/src/modules/dx/podcastSubscription/__tests__/podcastSubscription.test.ts +1 -1
- package/src/modules/dx/popover/__tests__/popover.test.ts +5 -2
- package/src/modules/dx/popover/popover.ts +1 -1
- package/src/modules/dx/radioGroup/__tests__/radioGroup.test.ts +1 -1
- package/src/modules/dx/relativeDateTime/__tests__/relativeDateTime.test.ts +1 -1
- package/src/modules/dx/section/__tests__/section.test.ts +1 -1
- package/src/modules/dx/section/section.ts +1 -1
- package/src/modules/dx/sectionSignup/__tests__/sectionSignup.test.ts +1 -1
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +3 -3
- package/src/modules/dx/sidebar/sidebar.stories.ts +4 -1
- package/src/modules/dx/sidebar/sidebar.ts +1 -1
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +2 -2
- package/src/modules/dx/sidebarOld/sidebarOld.ts +22 -7
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +3 -60
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +48 -23
- package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +1 -1
- package/src/modules/dx/slackButton/__tests__/slackButton.test.ts +1 -1
- package/src/modules/dx/slackCta/__tests__/slackCta.test.ts +1 -1
- package/src/modules/dx/socials/__tests__/socials.test.ts +1 -1
- package/src/modules/dx/spinner/__tests__/spinner.test.ts +1 -1
- package/src/modules/dx/tab/__tests__/tab.test.ts +1 -1
- package/src/modules/dx/toc/__tests__/mockProps.ts +6 -0
- package/src/modules/dx/toc/__tests__/toc.test.ts +13 -19
- package/src/modules/dx/toc/toc.css +1 -0
- package/src/modules/dx/tooltip/__tests__/tooltip.test.ts +3 -4
- package/src/modules/dx/topics/__tests__/topics.test.ts +1 -1
- package/src/modules/dx/tree/__tests__/tree.test.ts +1 -1
- package/src/modules/dx/treeItem/__tests__/treeItem.test.ts +1 -1
- package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +1 -1
- package/src/modules/dx/typeBadge/__tests__/typeBadge.test.ts +1 -1
- package/src/modules/dx/typeBadge/typeBadge.ts +1 -1
- package/src/modules/dx/typeBadgeGroup/__tests__/typeBadgeGroup.test.ts +9 -13
- package/src/modules/{tests → test-components}/buttonTest/buttonTest.html +0 -0
- package/src/modules/{tests → test-components}/buttonTest/buttonTest.ts +0 -0
- package/src/modules/{tests → test-components}/codeBlockTest/codeBlockTest.js +0 -0
- package/src/modules/{tests → test-components}/featureGridTest/featureGridTest.html +0 -0
- package/src/modules/{tests → test-components}/featureGridTest/featureGridTest.ts +0 -0
- package/src/modules/{tests → test-components}/instrumentationTest/instrumentationTest.html +0 -0
- package/src/modules/{tests → test-components}/instrumentationTest/instrumentationTest.ts +0 -0
- package/src/modules/{tests → test-components}/popoverTest/popoverTest.html +0 -0
- package/src/modules/{tests → test-components}/popoverTest/popoverTest.ts +0 -0
- package/src/modules/utils/highlight/__tests__/highlight.test.ts +45 -43
- package/src/modules/utils/highlight/highlight.ts +28 -15
- package/src/modules/{utils → utils-internal}/archiveCard/archiveCard.ts +0 -0
- package/src/modules/{utils → utils-internal}/coveo/coveo.ts +0 -0
- package/src/modules/{utils → utils-internal}/css/css.ts +0 -0
- package/src/modules/{utils → utils-internal}/devices/devices.ts +0 -0
- package/src/modules/{utils → utils-internal}/headerBase/headerBase.ts +1 -2
- package/src/modules/{utils → utils-internal}/jest/jest.ts +0 -0
- package/src/modules/{utils → utils-internal}/options/options.ts +0 -0
- package/src/modules/{utils → utils-internal}/prismjs/prismjs.html +0 -0
- package/src/modules/{utils → utils-internal}/prismjs/prismjs.ts +220 -124
- package/src/modules/{utils → utils-internal}/recentSearches/__tests__/recentSearches.test.ts +5 -1
- package/src/modules/{utils → utils-internal}/recentSearches/recentSearches.ts +0 -0
- package/src/modules/utils-internal/regexps/regexps.ts +12 -0
- package/src/modules/{utils → utils-internal}/seo/seo.ts +0 -0
- package/src/modules/{utils → utils-internal}/slot/slot.ts +0 -0
- package/src/modules/utils-internal/storybook/storybook.ts +32 -0
- package/src/modules/{utils → utils-internal}/tests/tests.ts +0 -0
- package/src/modules/{utils → utils-internal}/wordpress/__tests__/wordpress.test.ts +0 -0
- package/src/modules/{utils → utils-internal}/wordpress/wordpress.ts +0 -0
- package/LICENSE +0 -12
- package/src/modules/utils/regexps/regexps.ts +0 -5
- package/src/modules/utils/storybook/storybook.ts +0 -33
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { IconSprite, IconSymbol, IconBadgeShape } from "typings/custom";
|
|
4
|
-
import { toDxColor } from "utils/css";
|
|
4
|
+
import { toDxColor } from "utils-internal/css";
|
|
5
5
|
|
|
6
6
|
const validShapes = ["square", "circle"];
|
|
7
7
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Input from "dx/input";
|
|
2
|
-
import { createRenderComponent } from "utils/tests";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
3
|
|
|
4
4
|
const TAG = "dx-input";
|
|
5
5
|
const render = createRenderComponent(TAG, Input);
|
|
@@ -22,23 +22,20 @@ const mockUserAgent = (userAgent: string) => {
|
|
|
22
22
|
|
|
23
23
|
const assertErrorRender = (element: any, errorMessage: string) =>
|
|
24
24
|
Promise.resolve().then(() => {
|
|
25
|
-
const inputContainer: HTMLElement =
|
|
26
|
-
".input-container"
|
|
27
|
-
);
|
|
25
|
+
const inputContainer: HTMLElement =
|
|
26
|
+
element.shadowRoot.querySelector(".input-container");
|
|
28
27
|
expect(inputContainer.classList).toHaveLength(2);
|
|
29
28
|
expect(inputContainer.classList).toContain("has-error");
|
|
30
29
|
|
|
31
|
-
const errorBox: HTMLElement =
|
|
32
|
-
".error-message-box"
|
|
33
|
-
);
|
|
30
|
+
const errorBox: HTMLElement =
|
|
31
|
+
element.shadowRoot.querySelector(".error-message-box");
|
|
34
32
|
expect(errorBox).not.toBeNull();
|
|
35
33
|
expect(errorBox.textContent).toBe(errorMessage);
|
|
36
34
|
});
|
|
37
35
|
|
|
38
36
|
const assertErrorMissing = (element: any) => {
|
|
39
|
-
const inputContainer: HTMLElement =
|
|
40
|
-
".input-container"
|
|
41
|
-
);
|
|
37
|
+
const inputContainer: HTMLElement =
|
|
38
|
+
element.shadowRoot.querySelector(".input-container");
|
|
42
39
|
expect(inputContainer.classList).toHaveLength(1);
|
|
43
40
|
expect(element.shadowRoot.querySelector(".error-message-box")).toBeNull();
|
|
44
41
|
};
|
|
@@ -242,9 +239,8 @@ describe(TAG, () => {
|
|
|
242
239
|
label: "Test label"
|
|
243
240
|
});
|
|
244
241
|
|
|
245
|
-
const inputEl: HTMLInputElement =
|
|
246
|
-
"input"
|
|
247
|
-
);
|
|
242
|
+
const inputEl: HTMLInputElement =
|
|
243
|
+
element.shadowRoot.querySelector("input");
|
|
248
244
|
inputEl.value = "not_valid_email";
|
|
249
245
|
inputEl.dispatchEvent(new Event("input"));
|
|
250
246
|
|
|
@@ -269,9 +265,8 @@ describe(TAG, () => {
|
|
|
269
265
|
|
|
270
266
|
assertErrorMissing(element);
|
|
271
267
|
|
|
272
|
-
const inputEl: HTMLInputElement =
|
|
273
|
-
"input"
|
|
274
|
-
);
|
|
268
|
+
const inputEl: HTMLInputElement =
|
|
269
|
+
element.shadowRoot.querySelector("input");
|
|
275
270
|
expect(inputEl).not.toBeNull();
|
|
276
271
|
inputEl.dispatchEvent(new Event("blur"));
|
|
277
272
|
|
|
@@ -285,9 +280,8 @@ describe(TAG, () => {
|
|
|
285
280
|
label: "Test label"
|
|
286
281
|
});
|
|
287
282
|
|
|
288
|
-
const inputEl: HTMLInputElement =
|
|
289
|
-
"input"
|
|
290
|
-
);
|
|
283
|
+
const inputEl: HTMLInputElement =
|
|
284
|
+
element.shadowRoot.querySelector("input");
|
|
291
285
|
inputEl.value = "I'm a value";
|
|
292
286
|
inputEl.dispatchEvent(new Event("input"));
|
|
293
287
|
|
|
@@ -307,9 +301,8 @@ describe(TAG, () => {
|
|
|
307
301
|
validityOnBlur: true
|
|
308
302
|
});
|
|
309
303
|
|
|
310
|
-
const inputEl: HTMLInputElement =
|
|
311
|
-
"input"
|
|
312
|
-
);
|
|
304
|
+
const inputEl: HTMLInputElement =
|
|
305
|
+
element.shadowRoot.querySelector("input");
|
|
313
306
|
expect(inputEl).not.toBeNull();
|
|
314
307
|
inputEl.value = "email@email.com";
|
|
315
308
|
inputEl.dispatchEvent(new Event("input"));
|
|
@@ -327,9 +320,8 @@ describe(TAG, () => {
|
|
|
327
320
|
clearable: true
|
|
328
321
|
});
|
|
329
322
|
|
|
330
|
-
const clearButton: HTMLButtonElement =
|
|
331
|
-
".clear-button"
|
|
332
|
-
);
|
|
323
|
+
const clearButton: HTMLButtonElement =
|
|
324
|
+
element.shadowRoot.querySelector(".clear-button");
|
|
333
325
|
expect(clearButton).not.toBeNull();
|
|
334
326
|
});
|
|
335
327
|
|
|
@@ -339,9 +331,8 @@ describe(TAG, () => {
|
|
|
339
331
|
clearable: true
|
|
340
332
|
});
|
|
341
333
|
|
|
342
|
-
const clearButton: HTMLButtonElement =
|
|
343
|
-
".clear-button"
|
|
344
|
-
);
|
|
334
|
+
const clearButton: HTMLButtonElement =
|
|
335
|
+
element.shadowRoot.querySelector(".clear-button");
|
|
345
336
|
expect(clearButton).toBeNull();
|
|
346
337
|
});
|
|
347
338
|
|
|
@@ -351,14 +342,12 @@ describe(TAG, () => {
|
|
|
351
342
|
clearable: true
|
|
352
343
|
});
|
|
353
344
|
|
|
354
|
-
const input: HTMLInputElement =
|
|
355
|
-
"input"
|
|
356
|
-
);
|
|
345
|
+
const input: HTMLInputElement =
|
|
346
|
+
element.shadowRoot.querySelector("input");
|
|
357
347
|
expect(input.value).toEqual("test");
|
|
358
348
|
|
|
359
|
-
const clearButton: HTMLButtonElement =
|
|
360
|
-
".clear-button"
|
|
361
|
-
);
|
|
349
|
+
const clearButton: HTMLButtonElement =
|
|
350
|
+
element.shadowRoot.querySelector(".clear-button");
|
|
362
351
|
clearButton.dispatchEvent(new MouseEvent("click"));
|
|
363
352
|
|
|
364
353
|
await Promise.resolve();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { IconSize, IconSymbol } from "typings/custom";
|
|
4
|
-
import { isMac } from "utils/devices";
|
|
4
|
+
import { isMac } from "utils-internal/devices";
|
|
5
5
|
import { isValidEmail } from "./validators";
|
|
6
6
|
|
|
7
7
|
type ValidatorMap = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { track, developerwebTrackEventListener } from "dx/instrumentation";
|
|
2
|
-
import InstrumentationTest from "
|
|
3
|
-
import { createRenderComponent } from "utils/tests";
|
|
2
|
+
import InstrumentationTest from "test-components/instrumentationTest";
|
|
3
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
4
4
|
|
|
5
5
|
const TAG = "dx-instrumentation";
|
|
6
6
|
const render = createRenderComponent(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Dropdown from "dx/dropdown";
|
|
2
2
|
import InteractiveImage from "dx/interactiveImage";
|
|
3
|
-
import { createRenderComponent } from "utils/tests";
|
|
3
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
4
4
|
import {
|
|
5
5
|
mockSingleDownloadPropsAsArray,
|
|
6
6
|
mockSingleDownloadPropsAsString,
|
|
@@ -26,9 +26,8 @@ describe(TAG, () => {
|
|
|
26
26
|
|
|
27
27
|
const dropdownEl = element.shadowRoot.querySelector("dx-dropdown");
|
|
28
28
|
expect(dropdownEl).toBeNull();
|
|
29
|
-
const buttonEl =
|
|
30
|
-
"header dx-button"
|
|
31
|
-
);
|
|
29
|
+
const buttonEl =
|
|
30
|
+
element.shadowRoot.querySelector("header dx-button");
|
|
32
31
|
expect(buttonEl).not.toBeNull();
|
|
33
32
|
expect(buttonEl.href).toBe(
|
|
34
33
|
mockSingleDownloadPropsAsString.downloadUrls
|
|
@@ -42,9 +41,8 @@ describe(TAG, () => {
|
|
|
42
41
|
|
|
43
42
|
const dropdownEl = element.shadowRoot.querySelector("dx-dropdown");
|
|
44
43
|
expect(dropdownEl).toBeNull();
|
|
45
|
-
const buttonEl =
|
|
46
|
-
"header dx-button"
|
|
47
|
-
);
|
|
44
|
+
const buttonEl =
|
|
45
|
+
element.shadowRoot.querySelector("header dx-button");
|
|
48
46
|
expect(buttonEl).not.toBeNull();
|
|
49
47
|
expect(buttonEl.href).toBe(
|
|
50
48
|
mockSingleDownloadPropsAsArray.downloadUrls[0]
|
|
@@ -66,9 +64,8 @@ describe(TAG, () => {
|
|
|
66
64
|
it("renders a dropdown", () => {
|
|
67
65
|
const element = render(mockMultipleDownloadProps);
|
|
68
66
|
|
|
69
|
-
const dropdownEl: Dropdown =
|
|
70
|
-
"dx-dropdown"
|
|
71
|
-
);
|
|
67
|
+
const dropdownEl: Dropdown =
|
|
68
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
72
69
|
expect(dropdownEl).not.toBeNull();
|
|
73
70
|
const { options } = dropdownEl;
|
|
74
71
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import podcastSubscription from "dx/podcastSubscription";
|
|
2
|
-
import { createRenderComponent } from "utils/tests";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
3
|
|
|
4
4
|
const TAG = "dx-podcast-subscription";
|
|
5
5
|
const render = createRenderComponent(TAG, podcastSubscription);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import Popover from "dx/popover";
|
|
2
|
-
import PopoverTest from "
|
|
3
|
-
import {
|
|
2
|
+
import PopoverTest from "test-components/popoverTest";
|
|
3
|
+
import {
|
|
4
|
+
createRenderComponent,
|
|
5
|
+
mockSlottedElement
|
|
6
|
+
} from "utils-internal/tests";
|
|
4
7
|
import mockProps from "./mockProps";
|
|
5
8
|
|
|
6
9
|
const TAG = "dx-popover";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { createPopper } from "@popperjs/core";
|
|
9
9
|
import cx from "classnames";
|
|
10
10
|
import debounce from "debounce";
|
|
11
|
-
import { isPrerender } from "utils/seo";
|
|
11
|
+
import { isPrerender } from "utils-internal/seo";
|
|
12
12
|
|
|
13
13
|
const isEventOutsideElements = (
|
|
14
14
|
e: Event,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable jest/no-mocks-import */
|
|
2
2
|
import RelativeDateTime from "dx/relativeDateTime";
|
|
3
|
-
import { createRenderComponent } from "utils/tests";
|
|
3
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
4
4
|
import mockProps from "./mockProps";
|
|
5
5
|
|
|
6
6
|
const TAG = "dx-relative-date-time";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import { toDxColor } from "utils/css";
|
|
3
|
+
import { toDxColor } from "utils-internal/css";
|
|
4
4
|
|
|
5
5
|
export default class Section extends LightningElement {
|
|
6
6
|
@api backgroundColor?: string | null = "transparent";
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
createMediaMock,
|
|
8
8
|
mockQueryParameter,
|
|
9
9
|
unmockQueryParameter
|
|
10
|
-
} from "utils/jest";
|
|
11
|
-
import { createRenderComponent } from "utils/tests";
|
|
12
|
-
import { coveoXMLDocsConfig } from "utils/coveo";
|
|
10
|
+
} from "utils-internal/jest";
|
|
11
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
12
|
+
import { coveoXMLDocsConfig } from "utils-internal/coveo";
|
|
13
13
|
import mockSearchChangeEvent from "./mockSearchChangeEvent";
|
|
14
14
|
import mockSearchChangeEmptyEvent from "./mockSearchChangeEmptyEvent";
|
|
15
15
|
import { SAMPLE_TREES } from "./mockProps";
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { html } from "lit-html";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
coveoXMLDocsConfig,
|
|
4
|
+
coveoSFDocsConfig
|
|
5
|
+
} from "../../utils-internal/coveo/coveo";
|
|
3
6
|
import { SAMPLE_TREES, SAMPLE_TREES_WITH_METHODS } from "./__tests__/mockProps";
|
|
4
7
|
|
|
5
8
|
export default {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
SidebarGtmAction,
|
|
7
7
|
SidebarSearchResult
|
|
8
8
|
} from "typings/custom";
|
|
9
|
-
import { getSidebarSearchParams } from "utils/coveo";
|
|
9
|
+
import { getSidebarSearchParams } from "utils-internal/coveo";
|
|
10
10
|
import { toJson } from "utils/normalizers";
|
|
11
11
|
import SidebarSearch from "dx/sidebarSearch";
|
|
12
12
|
|
|
@@ -4,8 +4,8 @@ import { track } from "dx/instrumentation";
|
|
|
4
4
|
import SidebarOld from "dx/sidebarOld";
|
|
5
5
|
import Tree from "dx/tree";
|
|
6
6
|
import { TreeNode } from "typings/custom";
|
|
7
|
-
import { createMediaMock } from "utils/jest";
|
|
8
|
-
import { createRenderComponent } from "utils/tests";
|
|
7
|
+
import { createMediaMock } from "utils-internal/jest";
|
|
8
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
9
9
|
import { SAMPLE_TREES } from "./mockProps";
|
|
10
10
|
|
|
11
11
|
jest.mock("dx/instrumentation");
|
|
@@ -78,10 +78,18 @@ export default class Sidebar extends LightningElement {
|
|
|
78
78
|
this.expanded = !this.matchMedia.matches;
|
|
79
79
|
this.onMediaChange(this.matchMedia);
|
|
80
80
|
this.matchMedia.addEventListener("change", this.onMediaChange);
|
|
81
|
+
window.addEventListener(
|
|
82
|
+
"referencecontentloaded",
|
|
83
|
+
this.dispatchHighlightedTermChange
|
|
84
|
+
);
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
disconnectedCallback() {
|
|
84
88
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
89
|
+
window.removeEventListener(
|
|
90
|
+
"referencecontentloaded",
|
|
91
|
+
this.dispatchHighlightedTermChange
|
|
92
|
+
);
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
private onMediaChange = (event: MediaQueryListEvent | MediaQueryList) =>
|
|
@@ -120,16 +128,23 @@ export default class Sidebar extends LightningElement {
|
|
|
120
128
|
window.clearTimeout(this._searchTimeout);
|
|
121
129
|
this._searchTimeout = window.setTimeout(() => {
|
|
122
130
|
this.assignFilteredTrees();
|
|
123
|
-
this.
|
|
124
|
-
new CustomEvent("highlightedtermchange", {
|
|
125
|
-
detail: this.searchText,
|
|
126
|
-
composed: true,
|
|
127
|
-
bubbles: true
|
|
128
|
-
})
|
|
129
|
-
);
|
|
131
|
+
this.dispatchHighlightedTermChange();
|
|
130
132
|
}, WAIT_TIME);
|
|
131
133
|
}
|
|
132
134
|
|
|
135
|
+
private dispatchHighlightedTermChange = () => {
|
|
136
|
+
this.dispatchEvent(
|
|
137
|
+
new CustomEvent("highlightedtermchange", {
|
|
138
|
+
detail: {
|
|
139
|
+
query: this.searchText,
|
|
140
|
+
termsToHighlight: [this.searchText]
|
|
141
|
+
},
|
|
142
|
+
composed: true,
|
|
143
|
+
bubbles: true
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
};
|
|
147
|
+
|
|
133
148
|
private assignFilteredTrees() {
|
|
134
149
|
this.filteredTrees = this._trees
|
|
135
150
|
.map((singleTree) => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { createElement } from "lwc";
|
|
2
1
|
import SidebarSearch from "dx/sidebarSearch";
|
|
3
|
-
import { createRenderComponent
|
|
4
|
-
import { coveoXMLDocsConfig } from "utils/coveo";
|
|
5
|
-
import { mockQueryParameter, unmockQueryParameter } from "utils/jest";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
|
+
import { coveoXMLDocsConfig } from "utils-internal/coveo";
|
|
4
|
+
import { mockQueryParameter, unmockQueryParameter } from "utils-internal/jest";
|
|
6
5
|
import { SESSION_KEY } from "dx/sidebarSearch";
|
|
7
6
|
import mockPreloadedState from "./mockPreloadedState";
|
|
8
7
|
|
|
@@ -69,62 +68,6 @@ describe(TAG, () => {
|
|
|
69
68
|
return expect(element).toBeAccessible();
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
describe("highlighting", () => {
|
|
73
|
-
afterEach(unmockQueryParameter);
|
|
74
|
-
|
|
75
|
-
it("triggers on initial render when a search value exists", () => {
|
|
76
|
-
mockQueryParameter(QUERY);
|
|
77
|
-
const element = createElement(TAG, { is: SidebarSearch });
|
|
78
|
-
const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
|
|
79
|
-
renderLightningElement(element, PROPS);
|
|
80
|
-
expect(dispatchEventSpy).toHaveBeenCalledWith(
|
|
81
|
-
expect.objectContaining({
|
|
82
|
-
type: "highlightedtermchange",
|
|
83
|
-
detail: QUERY
|
|
84
|
-
})
|
|
85
|
-
);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it("does not trigger on initial render when a search value does not exist", () => {
|
|
89
|
-
const element = createElement(TAG, { is: SidebarSearch });
|
|
90
|
-
const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
|
|
91
|
-
renderLightningElement(element, PROPS);
|
|
92
|
-
expect(dispatchEventSpy).not.toHaveBeenCalledWith(
|
|
93
|
-
expect.objectContaining({ type: "highlightedtermchange" })
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("triggers on input change with non-empty value", () => {
|
|
98
|
-
const element = render(PROPS);
|
|
99
|
-
const dxInput = element.shadowRoot.querySelector("dx-input");
|
|
100
|
-
const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
|
|
101
|
-
|
|
102
|
-
dxInput.dispatchEvent(new CustomEvent("change", { detail: QUERY }));
|
|
103
|
-
|
|
104
|
-
expect(dispatchEventSpy).toHaveBeenCalledWith(
|
|
105
|
-
expect.objectContaining({
|
|
106
|
-
type: "highlightedtermchange",
|
|
107
|
-
detail: QUERY
|
|
108
|
-
})
|
|
109
|
-
);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("triggers on input change with empty value", () => {
|
|
113
|
-
const element = render(PROPS);
|
|
114
|
-
const dxInput = element.shadowRoot.querySelector("dx-input");
|
|
115
|
-
const dispatchEventSpy = jest.spyOn(element, "dispatchEvent");
|
|
116
|
-
|
|
117
|
-
dxInput.dispatchEvent(new CustomEvent("change", { detail: "" }));
|
|
118
|
-
|
|
119
|
-
expect(dispatchEventSpy).toHaveBeenCalledWith(
|
|
120
|
-
expect.objectContaining({
|
|
121
|
-
type: "highlightedtermchange",
|
|
122
|
-
detail: ""
|
|
123
|
-
})
|
|
124
|
-
);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
71
|
it("correctly consumes a valid session storage object", () => {
|
|
129
72
|
mockQueryParameter(mockPreloadedState.state.query.q);
|
|
130
73
|
|
|
@@ -14,8 +14,11 @@ import {
|
|
|
14
14
|
SearchAppState,
|
|
15
15
|
loadQueryActions
|
|
16
16
|
} from "@coveo/headless";
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import {
|
|
18
|
+
buildSearchEngine,
|
|
19
|
+
getSidebarSearchParams
|
|
20
|
+
} from "utils-internal/coveo";
|
|
21
|
+
import { RecentSearches } from "utils-internal/recentSearches";
|
|
19
22
|
import { toJson } from "utils/normalizers";
|
|
20
23
|
import {
|
|
21
24
|
Option,
|
|
@@ -51,9 +54,12 @@ export default class SidebarSearch extends LightningElement {
|
|
|
51
54
|
);
|
|
52
55
|
this._coveoAdvancedQueryConfig = jsonValue;
|
|
53
56
|
|
|
57
|
+
if (hasChanged && this.engine && this.value !== "") {
|
|
58
|
+
this.dispatchOnLoading(true);
|
|
59
|
+
}
|
|
60
|
+
|
|
54
61
|
if (hasChanged && this.engine) {
|
|
55
62
|
// set advanced filters needs access to the latest coveoAdvancedQueryConfig
|
|
56
|
-
this.dispatchOnLoading(true);
|
|
57
63
|
this.setAdvancedFilters(this.engine);
|
|
58
64
|
this.submitSearch(true);
|
|
59
65
|
}
|
|
@@ -88,6 +94,30 @@ export default class SidebarSearch extends LightningElement {
|
|
|
88
94
|
private fetchingMoreResults: boolean = false;
|
|
89
95
|
private didRender = false;
|
|
90
96
|
|
|
97
|
+
private get termsToHighlight(): string[] | null {
|
|
98
|
+
const { termsToHighlight, phrasesToHighlight } =
|
|
99
|
+
this.engine?.state?.search?.response;
|
|
100
|
+
if (!termsToHighlight || !phrasesToHighlight) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const flattenTerms = (terms: Object): string[] =>
|
|
105
|
+
Object.entries(terms).reduce((acc, [key, value]) => {
|
|
106
|
+
if (Array.isArray(value)) {
|
|
107
|
+
return [...acc, key, ...value];
|
|
108
|
+
}
|
|
109
|
+
const values = flattenTerms(value);
|
|
110
|
+
return [...acc, key, ...values];
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
const terms = flattenTerms({
|
|
114
|
+
...termsToHighlight,
|
|
115
|
+
...phrasesToHighlight
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
return Array.from(new Set([this.value, ...terms].flat(2))) as string[];
|
|
119
|
+
}
|
|
120
|
+
|
|
91
121
|
private get hasCorrectCoveoConfig(): boolean {
|
|
92
122
|
const coveoConfigurations = [
|
|
93
123
|
this.coveoOrganizationId,
|
|
@@ -141,12 +171,6 @@ export default class SidebarSearch extends LightningElement {
|
|
|
141
171
|
);
|
|
142
172
|
}
|
|
143
173
|
|
|
144
|
-
// If this is the first render and there is a search value, trigger
|
|
145
|
-
// term highlighting
|
|
146
|
-
if (!this.didRender && this.value) {
|
|
147
|
-
this.dispatchHighlightedTermChange();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
174
|
this.didRender = true;
|
|
151
175
|
}
|
|
152
176
|
|
|
@@ -221,10 +245,6 @@ export default class SidebarSearch extends LightningElement {
|
|
|
221
245
|
this.onResultListChange
|
|
222
246
|
);
|
|
223
247
|
|
|
224
|
-
if (this.value) {
|
|
225
|
-
this.dispatchHighlightedTermChange();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
248
|
if (!this.preloadedState) {
|
|
229
249
|
if (this.value) {
|
|
230
250
|
this.submitSearch();
|
|
@@ -327,6 +347,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
327
347
|
|
|
328
348
|
private dispatchOnChangeEvent(results: Result[]) {
|
|
329
349
|
this.updateSessionStorage();
|
|
350
|
+
this.dispatchHighlightedTermChange();
|
|
330
351
|
this.dispatchEvent(
|
|
331
352
|
new CustomEvent("change", {
|
|
332
353
|
detail: {
|
|
@@ -341,15 +362,20 @@ export default class SidebarSearch extends LightningElement {
|
|
|
341
362
|
this.dispatchEvent(new CustomEvent("loading", { detail: loading }));
|
|
342
363
|
}
|
|
343
364
|
|
|
344
|
-
private dispatchHighlightedTermChange() {
|
|
345
|
-
this.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
365
|
+
private dispatchHighlightedTermChange = () => {
|
|
366
|
+
if (this.termsToHighlight) {
|
|
367
|
+
this.dispatchEvent(
|
|
368
|
+
new CustomEvent("highlightedtermchange", {
|
|
369
|
+
detail: {
|
|
370
|
+
query: this.value,
|
|
371
|
+
termsToHighlight: this.termsToHighlight
|
|
372
|
+
},
|
|
373
|
+
composed: true,
|
|
374
|
+
bubbles: true
|
|
375
|
+
})
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
353
379
|
|
|
354
380
|
private updateRecentSearches = () =>
|
|
355
381
|
(this.recentSearches = UserRecentSearches.get().map((item: string) => ({
|
|
@@ -404,7 +430,6 @@ export default class SidebarSearch extends LightningElement {
|
|
|
404
430
|
this.value = e.detail;
|
|
405
431
|
|
|
406
432
|
this.handleValueChange(false);
|
|
407
|
-
this.dispatchHighlightedTermChange();
|
|
408
433
|
}
|
|
409
434
|
|
|
410
435
|
private onInputFocus() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SidebarSearchResult from "dx/sidebarSearchResult";
|
|
2
|
-
import { createRenderComponent } from "utils/tests";
|
|
2
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
3
3
|
|
|
4
4
|
const TAG = "dx-sidebar-search-result";
|
|
5
5
|
const render = createRenderComponent(TAG, SidebarSearchResult);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Socials from "dx/socials";
|
|
2
2
|
import IconBadge from "dx/iconBadge";
|
|
3
|
-
import { createRenderComponent } from "utils/tests";
|
|
3
|
+
import { createRenderComponent } from "utils-internal/tests";
|
|
4
4
|
|
|
5
5
|
const TAG = "dx-socials";
|
|
6
6
|
const render = createRenderComponent(TAG, Socials);
|