@salesforcedevs/docs-components 1.20.7 → 1.20.13-redocly

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 CHANGED
@@ -20,6 +20,7 @@
20
20
  "doc/headingAnchor",
21
21
  "doc/overview",
22
22
  "doc/phase",
23
+ "doc/redocReference",
23
24
  "doc/specificationContent",
24
25
  "doc/versionPicker",
25
26
  "doc/xmlContent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.20.7",
3
+ "version": "1.20.13-redocly",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -25,7 +25,7 @@
25
25
  "@types/lodash.orderby": "4.6.9",
26
26
  "@types/lodash.uniqby": "4.7.9"
27
27
  },
28
- "gitHead": "fffbef4d7b536a321824457c6a987e53830a78f1",
28
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
29
29
  "volta": {
30
30
  "node": "20.19.0",
31
31
  "yarn": "1.22.19"
@@ -1,10 +1,3 @@
1
- doc-phase {
2
- --doc-c-phase-top: calc(
3
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
4
- var(--dx-g-spacing-xl)
5
- );
6
- }
7
-
8
1
  /* We need to apply some borders when there are two doc phases */
9
2
  doc-phase:not(:only-of-type)::part(container) {
10
3
  border-top: 1px solid var(--dx-g-yellow-vibrant-90);
@@ -15,11 +8,6 @@ doc-phase:nth-child(2)::part(container) {
15
8
  border-bottom: 1px solid var(--dx-g-yellow-vibrant-90);
16
9
  }
17
10
 
18
- /* We don't want second component to sticky as we need to handle different cases like position */
19
- doc-phase:nth-child(2) {
20
- position: static;
21
- }
22
-
23
11
  .api-documentation {
24
12
  margin-top: 48px;
25
13
  }
@@ -17,8 +17,12 @@
17
17
  <slot name="sidebar-header" slot="version-picker"></slot>
18
18
  </dx-sidebar-old>
19
19
  <div class="content-body-doc-phase-container">
20
- <slot name="doc-phase"></slot>
21
- <slot name="version-banner"></slot>
20
+ <div class="doc-phase-wrapper">
21
+ <slot name="doc-phase"></slot>
22
+ </div>
23
+ <div class="version-wrapper">
24
+ <slot name="version-banner"></slot>
25
+ </div>
22
26
  <div class="content-body-container">
23
27
  <div class="content-body">
24
28
  <doc-breadcrumbs
@@ -223,15 +223,20 @@ export default class ContentLayout extends LightningElement {
223
223
  ".sticky-doc-header"
224
224
  ) as HTMLElement;
225
225
 
226
- let docPhaseEl = (
227
- this.template.querySelector("[name=doc-phase]")! as any
226
+ const docPhaseWrapper = this.template.querySelector(
227
+ ".doc-phase-wrapper"
228
+ ) as HTMLElement;
229
+ const versionWrapper = this.template.querySelector(
230
+ ".version-wrapper"
231
+ ) as HTMLElement;
232
+
233
+ const docPhaseEl = (
234
+ docPhaseWrapper.querySelector("[name=doc-phase]")! as any
228
235
  ).assignedElements()[0] as HTMLSlotElement;
229
236
 
230
- if (!docPhaseEl) {
231
- docPhaseEl = (
232
- this.template.querySelector("[name=version-banner]")! as any
233
- ).assignedElements()[0] as HTMLSlotElement;
234
- }
237
+ const verBannerEl = (
238
+ versionWrapper.querySelector("[name=version-banner]")! as any
239
+ ).assignedElements()[0] as HTMLSlotElement;
235
240
 
236
241
  if (!sidebarEl || !globalNavEl || !contextNavEl || !docHeaderEl) {
237
242
  console.warn("One or more required elements are missing.");
@@ -263,23 +268,21 @@ export default class ContentLayout extends LightningElement {
263
268
  `${globalNavHeight}px`
264
269
  );
265
270
 
271
+ const docPhaseElHeight =
272
+ docPhaseEl || verBannerEl
273
+ ? (docPhaseEl || verBannerEl).getBoundingClientRect().height
274
+ : 0;
275
+
266
276
  // Adjusting the doc section heading on scroll.
267
277
  docHeadingEls.forEach((docHeadingEl) => {
268
- (docHeadingEl as any).style.scrollMarginTop = docPhaseEl
269
- ? `${
270
- totalHeaderHeight +
271
- docPhaseEl.getBoundingClientRect().height +
272
- 40
273
- }px`
274
- : `${totalHeaderHeight + 40}px`;
278
+ (docHeadingEl as any).style.scrollMarginTop = `${
279
+ totalHeaderHeight + docPhaseElHeight + 40
280
+ }px`;
275
281
  });
276
282
 
277
283
  // Adjusting the right nav bar on scroll.
278
284
  // setting maxheight to make the RNB scrollable based on different parent elements
279
285
  if (rightNavBarEl) {
280
- const docPhaseElHeight = docPhaseEl
281
- ? docPhaseEl.getBoundingClientRect().height
282
- : 0;
283
286
  const viewportHeight = window.innerHeight;
284
287
  const maxHeight =
285
288
  viewportHeight -
@@ -299,18 +302,20 @@ export default class ContentLayout extends LightningElement {
299
302
  }
300
303
  }
301
304
 
305
+ const docPhaseTop =
306
+ window.innerWidth < 769
307
+ ? globalNavHeight +
308
+ docHeaderHeight +
309
+ sidebarEl.getBoundingClientRect().height
310
+ : globalNavHeight + docHeaderHeight;
311
+
302
312
  // If doc phase element exists, we need to account for its sticky position. Mobile should include the sidebar height (since it becomes sticky aswell).
313
+ // To handle sticky position for safari browser, position sticky given to wrapper class
303
314
  if (docPhaseEl) {
304
- docPhaseEl.style.setProperty(
305
- "--doc-c-phase-top",
306
- `${
307
- window.innerWidth < 769
308
- ? globalNavHeight +
309
- docHeaderHeight +
310
- sidebarEl.getBoundingClientRect().height
311
- : globalNavHeight + docHeaderHeight
312
- }px`
313
- );
315
+ docPhaseWrapper.style.top = `${docPhaseTop}px`;
316
+ } else if (verBannerEl) {
317
+ versionWrapper.style.position = "sticky";
318
+ versionWrapper.style.top = `${docPhaseTop}px`;
314
319
  }
315
320
  });
316
321
  };
@@ -16,8 +16,12 @@
16
16
  <slot name="sidebar-header" slot="version-picker"></slot>
17
17
  </dx-sidebar-old>
18
18
  <div class="content-body-doc-phase-container">
19
- <slot name="doc-phase"></slot>
20
- <slot name="version-banner"></slot>
19
+ <div class="doc-phase-wrapper">
20
+ <slot name="doc-phase"></slot>
21
+ </div>
22
+ <div class="version-wrapper">
23
+ <slot name="version-banner"></slot>
24
+ </div>
21
25
  <div class="content-body-container">
22
26
  <div class={contentBodyClasses}>
23
27
  <doc-breadcrumbs
@@ -3,14 +3,7 @@
3
3
  @import "docHelpers/status";
4
4
 
5
5
  :host {
6
- --doc-c-phase-top: 0;
7
6
  --doc-c-phase-container-align-items: flex-start;
8
-
9
- position: sticky;
10
- top: var(--doc-c-phase-top);
11
-
12
- /* NOTE: If you are changing z-index value here, ensure it's less than z-index of dx-sidebar in contentLayout.css */
13
- z-index: var(--dx-g-z-index-100);
14
7
  }
15
8
 
16
9
  .doc-phase-container {
@@ -0,0 +1,6 @@
1
+ :host {
2
+ --doc-c-redoc-sidebar-top: calc(
3
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
4
+ var(--dx-g-spacing-xl)
5
+ );
6
+ }
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <slot></slot>
3
+ <dx-error-fallback
4
+ if:true={showError}
5
+ title="API Documentation Unavailable"
6
+ description="This API reference is currently unavailable. Please try again later."
7
+ ></dx-error-fallback>
8
+ </template>
@@ -0,0 +1,256 @@
1
+ /* eslint-disable @lwc/lwc/no-document-query */
2
+ import { createElement, LightningElement, api } from "lwc";
3
+ import DocPhase from "doc/phase";
4
+ import DxFooter from "dx/footer";
5
+ import SprigSurvey from "doc/sprigSurvey";
6
+
7
+ declare global {
8
+ interface Window {
9
+ Redoc: any;
10
+ }
11
+ }
12
+
13
+ type ReferenceItem = {
14
+ source: string;
15
+ href: string;
16
+ isSelected?: boolean;
17
+ docPhase?: any;
18
+ };
19
+
20
+ type ReferenceConfig = {
21
+ refList: ReferenceItem[];
22
+ };
23
+
24
+ export default class RedocReference extends LightningElement {
25
+ private _referenceConfig: ReferenceConfig = { refList: [] };
26
+ private _parentDocPhaseInfo: string | null = null;
27
+
28
+ private layoutTimeoutId: number | null = null;
29
+ private isScrolling: boolean = false;
30
+ private previousTopValue = "";
31
+ private redocInitialized = false;
32
+
33
+ showError = false;
34
+
35
+ @api
36
+ get referenceConfig(): ReferenceConfig {
37
+ return this._referenceConfig;
38
+ }
39
+
40
+ set referenceConfig(value: string | ReferenceConfig) {
41
+ try {
42
+ const refConfig =
43
+ typeof value === "string" ? JSON.parse(value) : value;
44
+ this._referenceConfig = refConfig;
45
+ } catch (e) {
46
+ this._referenceConfig = { refList: [] };
47
+ }
48
+ }
49
+
50
+ @api
51
+ get docPhaseInfo(): string | null {
52
+ return this._parentDocPhaseInfo;
53
+ }
54
+
55
+ set docPhaseInfo(value: string) {
56
+ this._parentDocPhaseInfo = value;
57
+ }
58
+
59
+ connectedCallback(): void {
60
+ window.addEventListener("scroll", this.handleScrollWithThrottle);
61
+ window.addEventListener("resize", this.handleScrollWithThrottle);
62
+ }
63
+
64
+ renderedCallback(): void {
65
+ if (!this.redocInitialized && window.Redoc) {
66
+ this.initializeRedoc();
67
+ }
68
+ }
69
+
70
+ disconnectedCallback(): void {
71
+ if (this.layoutTimeoutId) {
72
+ clearTimeout(this.layoutTimeoutId);
73
+ this.layoutTimeoutId = null;
74
+ }
75
+
76
+ window.removeEventListener("scroll", this.handleScrollWithThrottle);
77
+ window.removeEventListener("resize", this.handleScrollWithThrottle);
78
+ }
79
+
80
+ @api
81
+ setDocPhaseInfo(docPhaseInfo: string): void {
82
+ this._parentDocPhaseInfo = docPhaseInfo;
83
+ }
84
+
85
+ private handleScrollWithThrottle = () => {
86
+ if (!this.isScrolling) {
87
+ this.isScrolling = true;
88
+
89
+ setTimeout(() => {
90
+ this.adjustPosition();
91
+ }, 200);
92
+
93
+ this.isScrolling = false;
94
+ }
95
+ };
96
+
97
+ private adjustPosition = () => {
98
+ const redocContainer = this.getRedocContainer();
99
+ const sidebarMenuElement = redocContainer?.querySelector(
100
+ ".redoc-wrap .menu-content"
101
+ ) as HTMLElement;
102
+
103
+ requestAnimationFrame(() => {
104
+ const globalNavElement = document.querySelector("hgf-c360nav");
105
+ const contextNavElement =
106
+ document.querySelector("hgf-c360contextnav");
107
+ const docHeaderElement =
108
+ document.querySelector(".sticky-doc-header");
109
+
110
+ if (sidebarMenuElement) {
111
+ const globalNavHeight =
112
+ globalNavElement?.getBoundingClientRect().height || 0;
113
+ const contextNavHeight =
114
+ contextNavElement?.getBoundingClientRect().height || 0;
115
+ const docHeaderHeight =
116
+ docHeaderElement?.getBoundingClientRect().height || 0;
117
+
118
+ const calculatedTopValue = `${
119
+ globalNavHeight + contextNavHeight + docHeaderHeight
120
+ }px`;
121
+
122
+ if (calculatedTopValue !== this.previousTopValue) {
123
+ sidebarMenuElement.style.setProperty(
124
+ "--doc-c-redoc-sidebar-top",
125
+ calculatedTopValue
126
+ );
127
+ this.previousTopValue = calculatedTopValue;
128
+ }
129
+ }
130
+ });
131
+ };
132
+
133
+ private getDocPhaseInfo(): string | null {
134
+ if (this._parentDocPhaseInfo) {
135
+ return this._parentDocPhaseInfo;
136
+ }
137
+ const selectedRef = this.getSelectedReference();
138
+ return selectedRef?.docPhase
139
+ ? JSON.stringify(selectedRef.docPhase)
140
+ : null;
141
+ }
142
+
143
+ private getSelectedReference(): ReferenceItem | null {
144
+ return this._referenceConfig?.refList?.length
145
+ ? this._referenceConfig.refList.find((ref) => ref.isSelected) ||
146
+ this._referenceConfig.refList[0]
147
+ : null;
148
+ }
149
+
150
+ private getRedocContainer(): HTMLElement | null {
151
+ return document.querySelector(".redoc-container");
152
+ }
153
+
154
+ private updateUrlWithReference(selectedRef: ReferenceItem): void {
155
+ if (selectedRef?.href) {
156
+ const parentReferencePath = selectedRef.href;
157
+ const currentUrl = window.location;
158
+ const existingParams = currentUrl.search + currentUrl.hash;
159
+
160
+ window.history.pushState(
161
+ {},
162
+ "",
163
+ `${parentReferencePath}${existingParams}`
164
+ );
165
+ }
166
+ }
167
+
168
+ private initializeRedoc(): void {
169
+ try {
170
+ const selectedRef = this.getSelectedReference();
171
+ if (selectedRef) {
172
+ this.updateUrlWithReference(selectedRef);
173
+
174
+ const specUrl = selectedRef.source;
175
+ const redocContainer = this.getRedocContainer();
176
+ if (specUrl && redocContainer) {
177
+ this.redocInitialized = true;
178
+ window.Redoc.init(
179
+ specUrl,
180
+ {
181
+ expandResponses: "200,400"
182
+ },
183
+ redocContainer,
184
+ () => {
185
+ this.insertCustomLayoutElements();
186
+ }
187
+ );
188
+ } else {
189
+ this.showError = true;
190
+ }
191
+ }
192
+ } catch (error) {
193
+ this.showError = true;
194
+ console.error("Failed to load data:", error);
195
+ }
196
+ }
197
+
198
+ private insertCustomLayoutElements(): void {
199
+ const redocContainer = this.getRedocContainer();
200
+ const apiContentDiv = redocContainer?.querySelector(".api-content");
201
+ if (apiContentDiv) {
202
+ (apiContentDiv as HTMLElement).setAttribute("lwc:dom", "manual");
203
+
204
+ try {
205
+ const docPhaseInfo = this.getDocPhaseInfo();
206
+ if (docPhaseInfo) {
207
+ this.insertDocPhase(
208
+ apiContentDiv as HTMLElement,
209
+ docPhaseInfo
210
+ );
211
+ }
212
+ this.insertSprigSurvey(apiContentDiv as HTMLElement);
213
+ this.insertFooter(apiContentDiv as HTMLElement);
214
+ } catch (error) {
215
+ console.error(
216
+ "Error showing banner and footer elements",
217
+ error
218
+ );
219
+ }
220
+ } else {
221
+ this.layoutTimeoutId = window.setTimeout(
222
+ () => this.insertCustomLayoutElements(),
223
+ 100
224
+ );
225
+ }
226
+ }
227
+
228
+ private insertDocPhase(container: HTMLElement, docPhaseInfo: string): void {
229
+ const docPhaseElement = createElement("doc-phase", { is: DocPhase });
230
+ Object.assign(docPhaseElement, { docPhaseInfo });
231
+
232
+ const wrapper = document.createElement("div");
233
+ wrapper.className = "doc-phase-wrapper";
234
+ wrapper.appendChild(docPhaseElement);
235
+
236
+ container.insertBefore(wrapper, container.firstChild);
237
+ }
238
+
239
+ private insertFooter(container: HTMLElement): void {
240
+ const footerElement = createElement("dx-footer", { is: DxFooter });
241
+ Object.assign(footerElement, { variant: "no-signup" });
242
+ container.appendChild(footerElement);
243
+ }
244
+
245
+ private insertSprigSurvey(container: HTMLElement): void {
246
+ const feedbackElement = createElement("doc-sprig-survey", {
247
+ is: SprigSurvey
248
+ });
249
+
250
+ const wrapper = document.createElement("div");
251
+ wrapper.className = "feedback-wrapper";
252
+ wrapper.appendChild(feedbackElement);
253
+
254
+ container.appendChild(wrapper);
255
+ }
256
+ }
@@ -31,10 +31,6 @@ dx-dropdown > dx-button:hover {
31
31
  --border-color: var(--button-primary-color-hover);
32
32
  }
33
33
 
34
- doc-phase {
35
- --doc-c-phase-top: var(--dx-g-global-header-height);
36
- }
37
-
38
34
  @media screen and (max-width: 768px) {
39
35
  doc-content-layout {
40
36
  --dx-g-doc-header-main-nav-height: 41px;
@@ -45,10 +41,4 @@ doc-phase {
45
41
  var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
46
42
  );
47
43
  }
48
-
49
- doc-phase {
50
- --doc-c-phase-top: calc(
51
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
52
- );
53
- }
54
44
  }
@@ -24,7 +24,7 @@
24
24
  <div lwc:if={showVersionPicker} slot="sidebar-header">
25
25
  <doc-version-picker
26
26
  data-type="version"
27
- analytics-event="custEv_ctaLinkClick"
27
+ analytics-event="custEv_linkClick"
28
28
  analytics-payload={ANALYTICS_PAYLOAD}
29
29
  versions={versionOptions}
30
30
  selected-version={version}
@@ -355,7 +355,7 @@ export default class DocXmlContent extends LightningElementWithState<{
355
355
  );
356
356
  this.pageReference.docId = this.language!.url;
357
357
 
358
- trackGTM(event.target!, "custEv_ctaLinkClick", {
358
+ trackGTM(event.target!, "custEv_linkClick", {
359
359
  click_text: event.detail,
360
360
  element_title: "language selector",
361
361
  click_url: `${window.location.origin}${this.pageReferenceToString(
@@ -59,6 +59,21 @@ dx-toc {
59
59
  border-left: 1px solid var(--dx-g-gray-90);
60
60
  }
61
61
 
62
+ .doc-phase-wrapper,
63
+ .version-wrapper {
64
+ /* NOTE: If you are changing z-index value here, ensure it's less than z-index of dx-sidebar in contentLayout.css */
65
+ z-index: var(--dx-g-z-index-100);
66
+ }
67
+
68
+ .doc-phase-wrapper {
69
+ position: sticky;
70
+ }
71
+
72
+ /* We don't want second component to sticky */
73
+ .version-wrapper {
74
+ position: static;
75
+ }
76
+
62
77
  .content-body-container {
63
78
  display: flex;
64
79
  flex-direction: row;
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.