@salesforcedevs/docs-components 1.20.9 → 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.9",
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": "f059ed735a63a7da1639c89388548ff6ff351c8a",
28
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
29
29
  "volta": {
30
30
  "node": "20.19.0",
31
31
  "yarn": "1.22.19"
@@ -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
+ }
@@ -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(
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.