@salesforcedevs/docs-components 1.20.18-redocly3 → 1.21.0

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/LICENSE ADDED
@@ -0,0 +1,12 @@
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.
package/lwc.config.json CHANGED
@@ -20,7 +20,6 @@
20
20
  "doc/headingAnchor",
21
21
  "doc/overview",
22
22
  "doc/phase",
23
- "doc/redocReference",
24
23
  "doc/specificationContent",
25
24
  "doc/versionPicker",
26
25
  "doc/xmlContent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.20.18-redocly3",
3
+ "version": "1.21.0",
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": "4629fdd9ca18a13480044ad43515b91945d16aad",
28
+ "gitHead": "3825e51e8056c0366f640f2c526801bc9d1b37bc",
29
29
  "volta": {
30
30
  "node": "20.19.0",
31
31
  "yarn": "1.22.19"
@@ -23,13 +23,6 @@ iframe {
23
23
  height: 606px;
24
24
  min-height: var(--playground-iframe-min-height);
25
25
  max-height: var(--playground-iframe-max-height);
26
- transition: height 0.3s ease, min-height 0.3s ease;
27
- }
28
-
29
- @media (prefers-reduced-motion: reduce) {
30
- iframe {
31
- transition: none;
32
- }
33
26
  }
34
27
 
35
28
  .playground-container {
@@ -1,7 +0,0 @@
1
- :host {
2
- --dx-footer-margin-top: 142px;
3
- --doc-c-redoc-sidebar-top: calc(
4
- var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
5
- var(--dx-g-spacing-xl)
6
- );
7
- }
@@ -1,13 +0,0 @@
1
- <template>
2
- <template lwc:if={showError}>
3
- <dx-error
4
- header="We lost communication with the space station."
5
- subtitle="We encountered a server-related issue. (Don't worry, we're on it.) Refresh your browser or try again later."
6
- image=""
7
- code="500"
8
- ></dx-error>
9
- </template>
10
- <template lwc:else>
11
- <slot></slot>
12
- </template>
13
- </template>
@@ -1,327 +0,0 @@
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
- import { throttle } from "throttle-debounce";
7
-
8
- declare global {
9
- interface Window {
10
- Redoc: any;
11
- }
12
- }
13
-
14
- declare const Sprig: (eventType: string, eventName: string) => void;
15
-
16
- type ReferenceItem = {
17
- source: string;
18
- href: string;
19
- isSelected?: boolean;
20
- docPhase?: string | null;
21
- };
22
-
23
- type ReferenceConfig = {
24
- refList: ReferenceItem[];
25
- };
26
-
27
- const SCROLL_THROTTLE_DELAY = 50;
28
- const ELEMENT_TIMEOUT = 10000;
29
- const ELEMENT_CHECK_INTERVAL = 100;
30
-
31
- export default class RedocReference extends LightningElement {
32
- private _referenceConfig: ReferenceConfig = { refList: [] };
33
- private _parentDocPhaseInfo: string | null = null;
34
- private redocInitialized = false;
35
-
36
- showError = false;
37
-
38
- @api
39
- get referenceConfig(): ReferenceConfig {
40
- return this._referenceConfig;
41
- }
42
-
43
- set referenceConfig(value: string | ReferenceConfig) {
44
- try {
45
- const refConfig =
46
- typeof value === "string" ? JSON.parse(value) : value;
47
- this._referenceConfig = refConfig;
48
- } catch (error) {
49
- this.showError = true;
50
- console.error(
51
- "Failed to parse reference configuration data",
52
- error
53
- );
54
- this._referenceConfig = { refList: [] };
55
- }
56
- }
57
-
58
- @api
59
- get docPhaseInfo(): string | null {
60
- return this._parentDocPhaseInfo;
61
- }
62
-
63
- set docPhaseInfo(value: string) {
64
- this._parentDocPhaseInfo = value;
65
- }
66
-
67
- connectedCallback(): void {
68
- window.addEventListener("scroll", this.handleScrollAndResize);
69
- window.addEventListener("resize", this.handleScrollAndResize);
70
- }
71
-
72
- renderedCallback(): void {
73
- if (!this.redocInitialized) {
74
- this.initializeRedoc();
75
- }
76
- }
77
-
78
- disconnectedCallback(): void {
79
- window.removeEventListener("scroll", this.handleScrollAndResize);
80
- window.removeEventListener("resize", this.handleScrollAndResize);
81
- }
82
-
83
- @api
84
- setDocPhaseInfo(docPhaseInfo: string): void {
85
- this._parentDocPhaseInfo = docPhaseInfo;
86
- }
87
-
88
- private handleLayoutChange = () => {
89
- requestAnimationFrame(() => {
90
- const redocContainer = this.getRedocContainer();
91
- if (!redocContainer) {
92
- return;
93
- }
94
-
95
- const globalNavElement = document.querySelector("hgf-c360nav");
96
- const contextNavElement =
97
- document.querySelector("hgf-c360contextnav");
98
- const docHeaderElement =
99
- document.querySelector(".sticky-doc-header");
100
-
101
- const globalNavHeight =
102
- globalNavElement?.getBoundingClientRect().height || 0;
103
- const contextNavHeight =
104
- contextNavElement?.getBoundingClientRect().height || 0;
105
- const docHeaderHeight =
106
- docHeaderElement?.getBoundingClientRect().height || 0;
107
-
108
- const calculatedTopValue = `${
109
- globalNavHeight + contextNavHeight + docHeaderHeight
110
- }px`;
111
-
112
- // Set updated top value for the sidebar and doc phase
113
- this.template.host.style.setProperty(
114
- "--doc-c-redoc-sidebar-top",
115
- calculatedTopValue
116
- );
117
-
118
- // Update thirdColumnContainer bottom positioning
119
- const footer = redocContainer.querySelector(
120
- ".redoc-wrap .api-content dx-footer"
121
- ) as HTMLElement;
122
- const thirdColumnContainer = redocContainer.querySelector(
123
- ".redoc-wrap > div:last-child"
124
- ) as HTMLElement;
125
-
126
- if (thirdColumnContainer && footer) {
127
- const footerHeight = footer.getBoundingClientRect().height || 0;
128
- const footerMarginTop = parseInt(
129
- getComputedStyle(this.template.host).getPropertyValue(
130
- "--dx-footer-margin-top"
131
- ) || "142",
132
- 10
133
- );
134
- thirdColumnContainer.style.setProperty(
135
- "bottom",
136
- `${footerHeight + footerMarginTop}px`
137
- );
138
- }
139
- });
140
- };
141
-
142
- private handleScrollAndResize = throttle(
143
- SCROLL_THROTTLE_DELAY,
144
- () => !this.showError && this.handleLayoutChange()
145
- );
146
-
147
- private getDocPhaseInfo(): string | null {
148
- if (this._parentDocPhaseInfo) {
149
- return this._parentDocPhaseInfo;
150
- }
151
- const selectedRef = this.getSelectedReference();
152
- return selectedRef?.docPhase
153
- ? JSON.stringify(selectedRef.docPhase)
154
- : null;
155
- }
156
-
157
- private getSelectedReference(): ReferenceItem | null {
158
- return this._referenceConfig?.refList?.length
159
- ? this._referenceConfig.refList.find((ref) => ref.isSelected) ||
160
- this._referenceConfig.refList[0]
161
- : null;
162
- }
163
-
164
- private getRedocContainer(): HTMLElement | null {
165
- return document.querySelector(".redoc-container");
166
- }
167
-
168
- private updateUrlWithReference(selectedRef: ReferenceItem): void {
169
- if (selectedRef?.href) {
170
- const parentReferencePath = selectedRef.href;
171
- const currentUrl = window.location;
172
- const existingParams = currentUrl.search + currentUrl.hash;
173
-
174
- window.history.pushState(
175
- {},
176
- "",
177
- `${parentReferencePath}${existingParams}`
178
- );
179
- }
180
- }
181
-
182
- private async initializeRedoc(): Promise<void> {
183
- try {
184
- this.redocInitialized = true;
185
-
186
- await this.waitForRedoc();
187
- const selectedRef = this.getSelectedReference();
188
- if (selectedRef) {
189
- this.updateUrlWithReference(selectedRef);
190
-
191
- const specUrl = selectedRef.source;
192
- const redocContainer = this.getRedocContainer();
193
- if (specUrl && redocContainer) {
194
- try {
195
- window.Redoc.init(
196
- specUrl,
197
- {
198
- expandResponses: "200,400"
199
- },
200
- redocContainer,
201
- () => {
202
- this.insertCustomLayoutElements();
203
- }
204
- );
205
- } catch (error) {
206
- this.showError = true;
207
- console.error(
208
- "Failed to show Reference UI using Redoc:",
209
- error
210
- );
211
- }
212
- } else {
213
- this.showError = true;
214
- }
215
- }
216
- } catch (error) {
217
- this.showError = true;
218
- console.error("Failed to load Redoc library:", error);
219
- }
220
- }
221
-
222
- /**
223
- * Waits until a condition is ready/satisfied within a timeout period
224
- * @param readinessCheck - Function that returns truthy when condition is satisfied
225
- * @param timeoutErrorMessage - Error message if timeout occurs
226
- * @param maxWaitTime - Maximum time to wait in milliseconds
227
- */
228
- private waitUntilReady(
229
- readinessCheck: () => boolean | HTMLElement | null,
230
- timeoutErrorMessage: string,
231
- maxWaitTime = ELEMENT_TIMEOUT
232
- ): Promise<void> {
233
- return new Promise((resolve, reject) => {
234
- const pollingStartTime = Date.now();
235
-
236
- const performReadinessCheck = () => {
237
- if (readinessCheck()) {
238
- resolve();
239
- return;
240
- }
241
-
242
- const elapsedTime = Date.now() - pollingStartTime;
243
- if (elapsedTime > maxWaitTime) {
244
- reject(new Error(timeoutErrorMessage));
245
- return;
246
- }
247
-
248
- setTimeout(performReadinessCheck, ELEMENT_CHECK_INTERVAL);
249
- };
250
-
251
- performReadinessCheck();
252
- });
253
- }
254
-
255
- private waitForRedoc(timeout = ELEMENT_TIMEOUT): Promise<void> {
256
- return this.waitUntilReady(
257
- () => !!window.Redoc,
258
- "Redoc library failed to load within timeout period",
259
- timeout
260
- );
261
- }
262
-
263
- private async insertCustomLayoutElements(): Promise<void> {
264
- try {
265
- const redocContainer = this.getRedocContainer();
266
-
267
- if (redocContainer) {
268
- const apiContentDiv = await this.waitForApiContent(
269
- redocContainer
270
- );
271
- apiContentDiv.setAttribute("lwc:dom", "manual");
272
-
273
- const docPhaseInfo = this.getDocPhaseInfo();
274
- if (docPhaseInfo) {
275
- this.insertDocPhase(apiContentDiv, docPhaseInfo);
276
- }
277
-
278
- if (typeof Sprig !== "undefined") {
279
- this.insertSprigSurvey(apiContentDiv);
280
- }
281
-
282
- this.insertFooter(apiContentDiv);
283
- }
284
- } catch (error) {
285
- this.showError = true;
286
- console.error("Failed to insert layout elements:", error);
287
- }
288
- }
289
-
290
- private async waitForApiContent(
291
- container: HTMLElement
292
- ): Promise<HTMLElement> {
293
- await this.waitUntilReady(
294
- () => container.querySelector<HTMLElement>(".api-content"),
295
- "Redoc API content element not found within timeout period"
296
- );
297
- return container.querySelector<HTMLElement>(".api-content")!;
298
- }
299
-
300
- private insertDocPhase(container: HTMLElement, docPhaseInfo: string): void {
301
- const docPhaseElement = createElement("doc-phase", { is: DocPhase });
302
- Object.assign(docPhaseElement, { docPhaseInfo });
303
-
304
- const wrapper = document.createElement("div");
305
- wrapper.className = "doc-phase-wrapper";
306
- wrapper.appendChild(docPhaseElement);
307
-
308
- container.insertBefore(wrapper, container.firstChild);
309
- }
310
-
311
- private insertFooter(container: HTMLElement): void {
312
- const footerElement = createElement("dx-footer", { is: DxFooter });
313
- Object.assign(footerElement, { variant: "no-signup" });
314
- container.appendChild(footerElement);
315
- }
316
-
317
- private insertSprigSurvey(container: HTMLElement): void {
318
- const feedbackElement = createElement("doc-sprig-survey", {
319
- is: SprigSurvey
320
- });
321
-
322
- const wrapper = document.createElement("div");
323
- wrapper.className = "sprig-survey-wrapper";
324
- wrapper.appendChild(feedbackElement);
325
- container.appendChild(wrapper);
326
- }
327
- }