@salesforcedevs/docs-components 1.28.5-redoc-alpha1 → 1.28.5-redoc-alpha3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.28.5-redoc-alpha1",
3
+ "version": "1.28.5-redoc-alpha3",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -533,32 +533,32 @@ export default class AmfReference extends LightningElement {
533
533
  for (const [index, amfConfig] of this._amfConfigList.entries()) {
534
534
  let navItemChildren = [] as ParsedMarkdownTopic[];
535
535
  let isChildrenLoading = false;
536
- if (amfConfig.renderWith === RENDER_WITH.redoc) {
537
- // Redoc-rendered specs have no AMF model and no sub-tree; they
538
- // appear as leaf items in the sidebar and open the Redoc UI on
539
- // selection.
540
- } else if (amfConfig.referenceType !== REFERENCE_TYPES.markdown) {
541
- if (amfConfig.isSelected) {
542
- const amfPromise = this.fetchAmf(amfConfig).then(
543
- (amfJson) => {
544
- this.updateModel(amfConfig.id, amfJson);
545
- this.assignNavigationItemsFromAmf(amfConfig, index);
546
- }
547
- );
548
- this.amfFetchPromiseMap[amfConfig.id] = amfPromise;
549
- }
550
- isChildrenLoading = true;
551
- } else {
552
- const isExpandChildrenEnabled = this.isExpandChildrenEnabled(
553
- amfConfig.id
554
- );
555
- // check whether we should expand all the child nodes, this is required for Coveo to crawl.
556
- if (isExpandChildrenEnabled) {
557
- this.expandChildrenForMarkdownReferences(
558
- amfConfig.topic!.children
559
- );
536
+ if (amfConfig.renderWith !== RENDER_WITH.redoc) {
537
+ if (amfConfig.referenceType !== REFERENCE_TYPES.markdown) {
538
+ if (amfConfig.isSelected) {
539
+ const amfPromise = this.fetchAmf(amfConfig).then(
540
+ (amfJson) => {
541
+ this.updateModel(amfConfig.id, amfJson);
542
+ this.assignNavigationItemsFromAmf(
543
+ amfConfig,
544
+ index
545
+ );
546
+ }
547
+ );
548
+ this.amfFetchPromiseMap[amfConfig.id] = amfPromise;
549
+ }
550
+ isChildrenLoading = true;
551
+ } else {
552
+ const isExpandChildrenEnabled =
553
+ this.isExpandChildrenEnabled(amfConfig.id);
554
+ // check whether we should expand all the child nodes, this is required for Coveo to crawl.
555
+ if (isExpandChildrenEnabled) {
556
+ this.expandChildrenForMarkdownReferences(
557
+ amfConfig.topic!.children
558
+ );
559
+ }
560
+ navItemChildren = amfConfig.topic!.children;
560
561
  }
561
- navItemChildren = amfConfig.topic!.children;
562
562
  }
563
563
  // store nav items for each spec in order
564
564
  navAmfOrder[index] = {
@@ -80,15 +80,12 @@ export interface AmfConfig {
80
80
  topic?: ParsedMarkdownTopic;
81
81
 
82
82
  /**
83
- * Optional renderer override sent by the backend.
84
- * When "redoc", spec-based references are rendered with Redoc instead of
85
- * the AMF-based topic view. Other values fall back to the default pipeline.
83
+ * Required for rendering the arrow on LNB
86
84
  */
87
85
  renderWith?: string;
88
86
 
89
87
  /**
90
- * Spec URL consumed by alternate renderers (e.g. Redoc). For redoc-rendered
91
- * references this is the OpenAPI document URL.
88
+ * Spec URL consumed by alternate renderers (e.g. Redoc, Mulesoft).
92
89
  */
93
90
  source?: string;
94
91
  }
@@ -15,12 +15,19 @@ declare global {
15
15
 
16
16
  declare const Sprig: (eventType: string, eventName: string) => void;
17
17
 
18
+ type ReferenceTopic = {
19
+ link?: { href?: string };
20
+ children?: ReferenceTopic[];
21
+ };
22
+
18
23
  type ReferenceItem = {
19
24
  source: string;
20
25
  href: string;
21
26
  title?: string;
22
27
  isSelected?: boolean;
23
28
  docPhase?: string | null;
29
+ referenceType?: string;
30
+ topic?: ReferenceTopic;
24
31
  };
25
32
 
26
33
  type ReferenceConfig = {
@@ -84,14 +91,11 @@ export default class RedocReference extends LightningElement {
84
91
  /** Title of the currently selected spec, shown beneath the project title. */
85
92
  @api
86
93
  get specTitle(): string | null {
87
- if (this._specTitle) {
88
- return this._specTitle;
89
- }
90
- return this.getSelectedReference()?.title ?? null;
94
+ return this._specTitle || this.getSelectedReference()?.title || null;
91
95
  }
92
96
 
93
97
  set specTitle(value: string | null) {
94
- this._specTitle = value;
98
+ this._specTitle = value || null;
95
99
  }
96
100
 
97
101
  /**
@@ -104,13 +108,12 @@ export default class RedocReference extends LightningElement {
104
108
  }
105
109
 
106
110
  /**
107
- * Navigates back to the previous history entry when the user clicks the
108
- * project-title back link rendered above the Redoc UI.
111
+ * Navigates back to reference doc.
109
112
  */
110
- private onBackClick(event: Event): void {
113
+ private onBackClick = (event: Event): void => {
111
114
  event.preventDefault();
112
115
  window.history.back();
113
- }
116
+ };
114
117
 
115
118
  /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
116
119
  get effectiveFooterOrigin(): string {
@@ -149,13 +152,7 @@ export default class RedocReference extends LightningElement {
149
152
  }
150
153
 
151
154
  private getRedocContainer(): HTMLElement | null {
152
- // Prefer the slotted container in the consumer's light DOM so this
153
- // component composes inside shadow trees; fall back to a global
154
- // `.redoc-container` for legacy page-level integrations.
155
- return (
156
- this.querySelector<HTMLElement>(".redoc-container") ||
157
- document.querySelector<HTMLElement>(".redoc-container")
158
- );
155
+ return document.querySelector(".redoc-container");
159
156
  }
160
157
 
161
158
  private getSelectedReference(): ReferenceItem | null {
@@ -373,27 +370,18 @@ export default class RedocReference extends LightningElement {
373
370
  if (!this.showRedocHeader) {
374
371
  return;
375
372
  }
376
- const menuContent =
377
- redocContainer.querySelector<HTMLElement>(".menu-content");
378
- if (
379
- menuContent &&
380
- !menuContent.querySelector(":scope > .redoc-project-header")
381
- ) {
382
- menuContent.insertBefore(
383
- this.buildProjectHeaderDom(),
384
- menuContent.firstChild
385
- );
386
- }
387
373
 
388
- const apiContent =
389
- redocContainer.querySelector<HTMLElement>(".api-content");
390
- if (
391
- apiContent &&
392
- !apiContent.querySelector(":scope > .redoc-project-header")
393
- ) {
394
- apiContent.insertBefore(
374
+ for (const selector of [".menu-content", ".api-content"]) {
375
+ const target = redocContainer.querySelector<HTMLElement>(selector);
376
+ if (
377
+ !target ||
378
+ target.querySelector(":scope > .redoc-project-header")
379
+ ) {
380
+ continue;
381
+ }
382
+ target.insertBefore(
395
383
  this.buildProjectHeaderDom(),
396
- apiContent.firstChild
384
+ target.firstChild
397
385
  );
398
386
  }
399
387
  }
@@ -405,37 +393,40 @@ export default class RedocReference extends LightningElement {
405
393
  const wrapper = document.createElement("div");
406
394
  wrapper.className = "redoc-project-header";
407
395
 
408
- if (this.projectTitle) {
396
+ /* TODO:
397
+ * Uncomment when doc-header is dropped with Vision state UX.
398
+ * if(this.projectTitle) {
399
+ */
400
+ if (this.specTitle) {
409
401
  const backLink = document.createElement("a");
410
402
  backLink.className = "redoc-project-back";
411
403
  backLink.href = "#";
412
- backLink.addEventListener("click", (event) => {
413
- event.preventDefault();
414
- window.history.back();
415
- });
416
- // 16x16 utility/back icon. dx-icon size="medium" maps to
417
- // --dx-g-icon-size-md (16px).
418
- const iconEl = createElement("dx-icon", { is: DxIcon });
419
- Object.assign(iconEl, {
404
+ backLink.addEventListener("click", this.onBackClick);
405
+
406
+ const icon = createElement("dx-icon", { is: DxIcon });
407
+ Object.assign(icon, {
420
408
  sprite: "utility",
421
409
  symbol: "back",
422
410
  size: "medium"
423
411
  });
424
- iconEl.classList.add("redoc-project-back-arrow");
412
+ icon.classList.add("redoc-project-back-arrow");
413
+
425
414
  const label = document.createElement("span");
426
415
  label.className = "redoc-project-title";
427
- label.textContent = this.projectTitle;
428
- backLink.appendChild(iconEl);
416
+ label.textContent = this.specTitle;
417
+
418
+ backLink.appendChild(icon);
429
419
  backLink.appendChild(label);
430
420
  wrapper.appendChild(backLink);
431
421
  }
432
422
 
433
- if (this.specTitle) {
434
- const specEl = document.createElement("h2");
435
- specEl.className = "redoc-spec-title";
436
- specEl.textContent = this.specTitle;
437
- wrapper.appendChild(specEl);
438
- }
423
+ // TODO: Uncomment when we we have vision state UX with no doc-header
424
+ // if (this.specTitle) {
425
+ // const specEl = document.createElement("h2");
426
+ // specEl.className = "redoc-spec-title";
427
+ // specEl.textContent = this.specTitle;
428
+ // wrapper.appendChild(specEl);
429
+ // }
439
430
 
440
431
  return wrapper;
441
432
  }