@salesforcedevs/docs-components 0.17.0 → 0.17.12-search-alpha

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 (114) hide show
  1. package/lwc.config.json +18 -3
  2. package/package.json +18 -7
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
  5. package/src/modules/doc/amfReference/amfReference.css +25 -0
  6. package/src/modules/doc/amfReference/amfReference.html +55 -0
  7. package/src/modules/doc/amfReference/amfReference.ts +1467 -0
  8. package/src/modules/doc/amfReference/constants.ts +76 -0
  9. package/src/modules/doc/amfReference/types.ts +125 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +21 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
  13. package/src/modules/doc/amfTopic/types.ts +56 -0
  14. package/src/modules/doc/amfTopic/utils.ts +136 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
  21. package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
  22. package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
  23. package/src/modules/doc/componentPlayground/componentPlayground.ts +42 -0
  24. package/src/modules/doc/content/content.css +89 -70
  25. package/src/modules/doc/content/content.html +1 -0
  26. package/src/modules/doc/content/content.ts +188 -195
  27. package/src/modules/doc/contentCallout/contentCallout.css +17 -23
  28. package/src/modules/doc/contentCallout/contentCallout.html +13 -4
  29. package/src/modules/doc/contentCallout/contentCallout.ts +16 -3
  30. package/src/modules/doc/contentLayout/contentLayout.css +1 -0
  31. package/src/modules/doc/contentLayout/contentLayout.html +46 -0
  32. package/src/modules/doc/contentLayout/contentLayout.ts +524 -0
  33. package/src/modules/doc/doDont/doDont.css +47 -0
  34. package/src/modules/doc/doDont/doDont.html +27 -0
  35. package/src/modules/doc/doDont/doDont.ts +17 -0
  36. package/src/modules/doc/header/header.css +70 -37
  37. package/src/modules/doc/header/header.html +41 -138
  38. package/src/modules/doc/header/header.ts +56 -78
  39. package/src/modules/doc/heading/heading.css +33 -0
  40. package/src/modules/doc/heading/heading.html +14 -0
  41. package/src/modules/doc/heading/heading.ts +67 -0
  42. package/src/modules/doc/headingAnchor/headingAnchor.css +3 -3
  43. package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
  44. package/src/modules/doc/headingContent/headingContent.css +53 -0
  45. package/src/modules/doc/headingContent/headingContent.html +13 -0
  46. package/src/modules/doc/headingContent/headingContent.ts +30 -0
  47. package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
  48. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +45 -0
  49. package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +256 -0
  50. package/src/modules/doc/overview/overview.css +40 -0
  51. package/src/modules/doc/overview/overview.html +34 -0
  52. package/src/modules/doc/overview/overview.ts +12 -0
  53. package/src/modules/doc/phase/phase.css +70 -0
  54. package/src/modules/doc/phase/phase.html +38 -0
  55. package/src/modules/doc/phase/phase.ts +93 -0
  56. package/src/modules/doc/specificationContent/specificationContent.css +36 -0
  57. package/src/modules/doc/specificationContent/specificationContent.html +167 -0
  58. package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
  59. package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
  60. package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
  61. package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
  62. package/src/modules/doc/toc/toc.ts +1 -1
  63. package/src/modules/doc/versionPicker/versionPicker.css +64 -0
  64. package/src/modules/doc/versionPicker/versionPicker.html +38 -0
  65. package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
  66. package/src/modules/doc/xmlContent/types.ts +120 -0
  67. package/src/modules/doc/xmlContent/utils.ts +163 -0
  68. package/src/modules/doc/xmlContent/xmlContent.css +54 -0
  69. package/src/modules/doc/xmlContent/xmlContent.html +54 -0
  70. package/src/modules/doc/xmlContent/xmlContent.ts +763 -0
  71. package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
  72. package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
  73. package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
  74. package/src/modules/docHelpers/status/status.css +22 -0
  75. package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
  76. package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
  77. package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
  78. package/src/modules/docUtils/utils/utils.ts +32 -0
  79. package/LICENSE +0 -12
  80. package/src/modules/doc/content/__tests__/content.test.ts +0 -312
  81. package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -348
  82. package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
  83. package/src/modules/doc/content/__tests__/mockSidebar.ts +0 -81
  84. package/src/modules/doc/content/content.stories.ts +0 -148
  85. package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
  86. package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
  87. package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
  88. package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -97
  89. package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
  90. package/src/modules/doc/header/__tests__/coveoConfig.ts +0 -12
  91. package/src/modules/doc/header/__tests__/header.test.ts +0 -445
  92. package/src/modules/doc/header/__tests__/mockNavDevelopers.ts +0 -427
  93. package/src/modules/doc/header/__tests__/mockNavs.ts +0 -115
  94. package/src/modules/doc/header/__tests__/mockProps.ts +0 -152
  95. package/src/modules/doc/header/header.stories.ts +0 -190
  96. package/src/modules/doc/headingAnchor/__tests__/headingAnchor.test.ts +0 -111
  97. package/src/modules/doc/headingAnchor/headingAnchor.stories.ts +0 -33
  98. package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
  99. package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
  100. package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
  101. package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
  102. package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
  103. package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
  104. package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
  105. package/src/modules/doc/nav/__tests__/nav.test.ts +0 -58
  106. package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
  107. package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
  108. package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
  109. package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
  110. package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
  111. package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
  112. package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
  113. package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
  114. package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
@@ -0,0 +1,32 @@
1
+ import { CoveoAnalyticsClient } from "coveo.analytics/dist/browser.mjs"; // This fix is required for Node 20 upgrade, so that Coveo analytics is loaded properly by LWR.
2
+
3
+ export const oldVersionDocInfo = (latestVersionLink: string) => {
4
+ return {
5
+ title: "Newer Version Available",
6
+ body: `This content describes an older version of this product.
7
+ <a style="font-weight: bold;" href="${latestVersionLink}">View Latest</a>`
8
+ };
9
+ };
10
+
11
+ export function logCoveoPageView(
12
+ coveoOrganizationId: string | undefined,
13
+ coveoAnalyticsToken: string | undefined
14
+ ) {
15
+ if (coveoOrganizationId && coveoAnalyticsToken) {
16
+ const ua = new CoveoAnalyticsClient({
17
+ token: coveoAnalyticsToken,
18
+ endpoint: `https://${coveoOrganizationId}.analytics.org.coveo.com`
19
+ });
20
+ const pathParts = window.location.pathname.split("/");
21
+ let contentType;
22
+ if (pathParts.length >= 2) {
23
+ contentType = pathParts[1];
24
+ }
25
+
26
+ ua.sendViewEvent({
27
+ contentIdKey: "@clickableuri",
28
+ contentType: contentType,
29
+ contentIdValue: window.location.href
30
+ });
31
+ }
32
+ }
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1,312 +0,0 @@
1
- import CodeBlock from "dx/codeBlock";
2
- import { createRenderComponent } from "utils/tests";
3
- import Content from "../content";
4
- import * as mockContent from "./mockDocContent";
5
- import mockPageReference from "./mockPageReference";
6
-
7
- const TAG = "doc-content";
8
- const render = createRenderComponent(TAG, Content);
9
-
10
- describe("doc-content", () => {
11
- it("renders the content", () => {
12
- const component = render({
13
- docsData: mockContent.content,
14
- pageReference: mockPageReference,
15
- _isStorybook: false
16
- });
17
- const contentEl = component.shadowRoot.querySelector(
18
- '[data-name="content"]'
19
- );
20
- expect(contentEl).not.toBeNull();
21
- });
22
-
23
- it("renders both with and wothout pagination buttons", () => {
24
- const c_buttons = render({
25
- docsData: mockContent.withButtons,
26
- pageReference: mockPageReference,
27
- showPaginationButtons: true,
28
- _isStorybook: false
29
- });
30
- const dx_buttons = c_buttons.shadowRoot.querySelectorAll("dx-button");
31
- expect(dx_buttons.length).toEqual(2);
32
-
33
- const c_no_buttons = render({
34
- docsData: mockContent.withButtons,
35
- pageReference: mockPageReference,
36
- _isStorybook: false
37
- });
38
- const empty_dx_buttons =
39
- c_no_buttons.shadowRoot.querySelectorAll("dx-button");
40
- expect(empty_dx_buttons.length).toEqual(0);
41
- });
42
-
43
- it("swaps out images", () => {
44
- const component = render({
45
- docsData: mockContent.withImages,
46
- pageReference: mockPageReference,
47
- _isStorybook: false
48
- });
49
- const contentEl = component.shadowRoot.querySelector(
50
- '[data-name="content"]'
51
- );
52
- expect(contentEl).not.toBeNull();
53
- const images = component.shadowRoot.querySelectorAll("img");
54
- expect(images.length).toEqual(3);
55
- const contentMediaEls =
56
- component.shadowRoot.querySelectorAll("doc-content-media");
57
- expect(contentMediaEls.length).toEqual(0);
58
- });
59
-
60
- it("swaps out iframes", () => {
61
- const component = render({
62
- docsData: mockContent.withVideos,
63
- pageReference: mockPageReference,
64
- _isStorybook: false
65
- });
66
- const contentEl = component.shadowRoot.querySelector(
67
- '[data-name="content"]'
68
- );
69
- expect(contentEl).not.toBeNull();
70
- const images = component.shadowRoot.querySelectorAll("iframe");
71
- expect(images.length).toEqual(0);
72
- const contentMediaEls =
73
- component.shadowRoot.querySelectorAll("doc-content-media");
74
- expect(contentMediaEls.length).toEqual(2);
75
- contentMediaEls.forEach((contentMedia) => {
76
- expect(contentMedia.contentType).toEqual("iframe");
77
- expect(contentMedia.mediaTitle).not.toBeUndefined();
78
- expect(contentMedia.contentSrc).toMatch(
79
- "https://play.vidyard.com/"
80
- );
81
- });
82
- });
83
-
84
- it("swaps out notes", () => {
85
- const component = render({
86
- docsData: mockContent.withNotes,
87
- pageReference: mockPageReference,
88
- _isStorybook: false
89
- });
90
- const contentEl = component.shadowRoot.querySelector(
91
- '[data-name="content"]'
92
- );
93
- expect(contentEl).not.toBeNull();
94
- const notes = component.shadowRoot.querySelectorAll(".message");
95
- expect(notes).toHaveLength(4);
96
- notes.forEach((note) => {
97
- const noteHeader = note.querySelector("doc-content-callout");
98
- expect(noteHeader).not.toBeNull();
99
- });
100
- });
101
-
102
- it("includes tables, lists, and code blocks in notes", () => {
103
- const component = render({
104
- docsData: mockContent.withNotes,
105
- pageReference: mockPageReference,
106
- _isStorybook: false
107
- });
108
- const contentEl = component.shadowRoot.querySelector(
109
- '[data-name="content"]'
110
- );
111
- expect(contentEl).not.toBeNull();
112
- const notes = component.shadowRoot.querySelectorAll(".message");
113
- expect(notes[0].querySelector("table")).not.toBeNull();
114
- expect(notes[1].querySelector("ul")).not.toBeNull();
115
- expect(notes[2].querySelector("ol")).not.toBeNull();
116
- expect(notes[3].querySelector("dx-code-block")).not.toBeNull();
117
- });
118
-
119
- it("highlights text that matches search criteria", () => {
120
- const component = render({
121
- docsData: mockContent.content,
122
- pageReference: mockPageReference,
123
- isStorybook: true
124
- });
125
-
126
- const contentEl = component.shadowRoot.querySelector(
127
- '[data-name="content"]'
128
- );
129
-
130
- expect(contentEl.querySelectorAll("mark")).toHaveLength(0);
131
-
132
- contentEl.dispatchEvent(
133
- new CustomEvent("highlightedtermchange", {
134
- detail: "apex",
135
- composed: true,
136
- bubbles: true
137
- })
138
- );
139
-
140
- expect(contentEl.querySelectorAll("mark")).toHaveLength(14);
141
- });
142
-
143
- it("doesn't highlight elements that contains dx/docs components", () => {
144
- const searchTerm = "customreport";
145
-
146
- const component = render({
147
- docsData: mockContent.sampleCodeBlockAndNote,
148
- pageReference: mockPageReference,
149
- isStorybook: true
150
- });
151
-
152
- const contentEl = component.shadowRoot.querySelector(
153
- '[data-name="content"]'
154
- );
155
-
156
- expect(contentEl.querySelectorAll("mark")).toHaveLength(0);
157
-
158
- contentEl.dispatchEvent(
159
- new CustomEvent("highlightedtermchange", {
160
- detail: searchTerm,
161
- composed: true,
162
- bubbles: true
163
- })
164
- );
165
-
166
- const marks: Array<HTMLElement> = contentEl.querySelectorAll("mark");
167
-
168
- expect(marks).toHaveLength(0);
169
-
170
- const code: CodeBlock = contentEl.querySelector("dx-code-block");
171
- expect(code).not.toBeNull();
172
- expect(code.codeBlock).toBeTruthy();
173
- expect(contentEl.querySelector("doc-content-callout")).not.toBeNull();
174
- });
175
-
176
- it("doesn't highlight terms separated by html tags", () => {
177
- const searchTerm = "loadData within";
178
-
179
- const component = render({
180
- docsData: mockContent.sampleCodeBlockAndNote,
181
- pageReference: mockPageReference,
182
- isStorybook: true
183
- });
184
-
185
- const contentEl = component.shadowRoot.querySelector(
186
- '[data-name="content"]'
187
- );
188
-
189
- contentEl.dispatchEvent(
190
- new CustomEvent("highlightedtermchange", {
191
- detail: searchTerm,
192
- composed: true,
193
- bubbles: true
194
- })
195
- );
196
-
197
- const marks: Array<HTMLElement> =
198
- component.shadowRoot.querySelectorAll("mark");
199
- expect(marks).toHaveLength(0);
200
- });
201
-
202
- it("escapes regex especial characters", () => {
203
- const searchTerm = "used.+";
204
-
205
- const component = render({
206
- docsData: mockContent.sampleCodeBlockAndNote,
207
- pageReference: mockPageReference,
208
- isStorybook: true
209
- });
210
-
211
- const contentEl = component.shadowRoot.querySelector(
212
- '[data-name="content"]'
213
- );
214
-
215
- contentEl.dispatchEvent(
216
- new CustomEvent("highlightedtermchange", {
217
- detail: searchTerm,
218
- composed: true,
219
- bubbles: true
220
- })
221
- );
222
-
223
- const marks: Array<HTMLElement> =
224
- component.shadowRoot.querySelectorAll("mark");
225
- expect(marks).toHaveLength(0);
226
- });
227
-
228
- it("cleans previous search result before searching for a new term", () => {
229
- const firstSearch = "verify";
230
- const secondSearch = "sObject";
231
-
232
- const component = render({
233
- docsData: mockContent.sampleCodeBlockAndNote,
234
- pageReference: mockPageReference,
235
- isStorybook: true
236
- });
237
-
238
- const contentEl = component.shadowRoot.querySelector(
239
- '[data-name="content"]'
240
- );
241
-
242
- contentEl.dispatchEvent(
243
- new CustomEvent("highlightedtermchange", {
244
- detail: firstSearch,
245
- composed: true,
246
- bubbles: true
247
- })
248
- );
249
-
250
- const firstMarks: Array<HTMLElement> =
251
- component.shadowRoot.querySelectorAll("mark");
252
- expect(firstMarks).toHaveLength(2);
253
- firstMarks.forEach(({ textContent }) =>
254
- expect(textContent).toBe(firstSearch)
255
- );
256
-
257
- contentEl.dispatchEvent(
258
- new CustomEvent("highlightedtermchange", {
259
- detail: secondSearch,
260
- composed: true,
261
- bubbles: true
262
- })
263
- );
264
-
265
- const secondMarks: Array<HTMLElement> =
266
- component.shadowRoot.querySelectorAll("mark");
267
- expect(secondMarks).toHaveLength(1);
268
- secondMarks.forEach(({ textContent }) =>
269
- expect(textContent).toBe(secondSearch)
270
- );
271
- });
272
-
273
- it("cleans all marks if the search term is empty string", () => {
274
- const firstSearch = "verify";
275
- const secondSearch = "";
276
-
277
- const component = render({
278
- docsData: mockContent.sampleCodeBlockAndNote,
279
- pageReference: mockPageReference,
280
- isStorybook: true
281
- });
282
-
283
- const contentEl = component.shadowRoot.querySelector(
284
- '[data-name="content"]'
285
- );
286
-
287
- contentEl.dispatchEvent(
288
- new CustomEvent("highlightedtermchange", {
289
- detail: firstSearch,
290
- composed: true,
291
- bubbles: true
292
- })
293
- );
294
-
295
- const firstMarks: Array<HTMLElement> =
296
- component.shadowRoot.querySelectorAll("mark");
297
- expect(firstMarks).toHaveLength(2);
298
- firstMarks.forEach(({ textContent }) =>
299
- expect(textContent).toBe(firstSearch)
300
- );
301
-
302
- contentEl.dispatchEvent(
303
- new CustomEvent("highlightedtermchange", {
304
- detail: secondSearch,
305
- composed: true,
306
- bubbles: true
307
- })
308
- );
309
-
310
- expect(component.shadowRoot.querySelectorAll("mark")).toHaveLength(0);
311
- });
312
- });