@salesforcedevs/docs-components 1.3.151 → 1.3.155-lnb-expand1

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
@@ -15,6 +15,7 @@
15
15
  "doc/header",
16
16
  "doc/heading",
17
17
  "doc/headingAnchor",
18
+ "doc/lwcReferenceLayout",
18
19
  "doc/overview",
19
20
  "doc/phase",
20
21
  "doc/xmlContent"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.151",
3
+ "version": "1.3.155-lnb-expand1",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -24,5 +24,5 @@
24
24
  "@types/lodash.orderby": "^4.6.7",
25
25
  "@types/lodash.uniqby": "^4.7.7"
26
26
  },
27
- "gitHead": "a18da1e5151467020122ee365fef9f8f189768dd"
27
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
28
28
  }
@@ -35,6 +35,7 @@ export default class ContentLayout extends LightningElement {
35
35
  @api coveoSearchHub!: string;
36
36
  @api coveoAdvancedQueryConfig!: string;
37
37
  @api useOldSidebar?: boolean = false;
38
+ @api rnbByTabId?: string = "lwc-doc-tab";
38
39
 
39
40
  @api
40
41
  get breadcrumbs() {
@@ -118,6 +119,10 @@ export default class ContentLayout extends LightningElement {
118
119
  return window.location.pathname;
119
120
  }
120
121
 
122
+ get showTabBasedRNB() {
123
+ return this.rnbByTabId ? true : false;
124
+ }
125
+
121
126
  get showBreadcrumbs(): boolean {
122
127
  return (
123
128
  this.breadcrumbs != null && (this.breadcrumbs as any[]).length > 1
@@ -136,8 +141,24 @@ export default class ContentLayout extends LightningElement {
136
141
  );
137
142
  this.searchSyncer.init();
138
143
  }
144
+
145
+ if (this.showTabBasedRNB) {
146
+ window.addEventListener("tabchanged", this.onTabChanged);
147
+ }
139
148
  }
140
149
 
150
+ onTabChanged = () => {
151
+ this.updateRNB();
152
+ };
153
+
154
+ updateRNB = () => {
155
+ const headingElements = this.getHeadingElements();
156
+ headingElements.forEach((headingElement) => {
157
+ headingElement.hash = headingElement.attributes.hash?.nodeValue;
158
+ });
159
+ this.updateTocItems(headingElements);
160
+ };
161
+
141
162
  renderedCallback(): void {
142
163
  /**
143
164
  * Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
@@ -165,6 +186,10 @@ export default class ContentLayout extends LightningElement {
165
186
  "highlightedtermchange",
166
187
  this.updateHighlighted
167
188
  );
189
+
190
+ if (this.showTabBasedRNB) {
191
+ window.removeEventListener("tabchanged", this.onTabChanged);
192
+ }
168
193
  window.removeEventListener("scroll", this.adjustNavPosition);
169
194
  window.removeEventListener("resize", this.adjustNavPosition);
170
195
  this.searchSyncer.dispose();
@@ -184,6 +209,29 @@ export default class ContentLayout extends LightningElement {
184
209
  }
185
210
  };
186
211
 
212
+ private getHeadingElements() {
213
+ let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
214
+ if (this.showTabBasedRNB) {
215
+ const tabPanelListItems =
216
+ document.querySelectorAll("dx-tab-panel-list");
217
+ for (const tabPanelListItem of tabPanelListItems) {
218
+ if (tabPanelListItem.id === this.rnbByTabId) {
219
+ const tabPanelItems =
220
+ tabPanelListItem.querySelectorAll("dx-tab-panel");
221
+ for (const tabPanelItem of tabPanelItems) {
222
+ if (tabPanelItem.active) {
223
+ headingElements =
224
+ tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
225
+ break;
226
+ }
227
+ }
228
+ break;
229
+ }
230
+ }
231
+ }
232
+ return headingElements;
233
+ }
234
+
187
235
  /*
188
236
  This is a workaround for the global nav sticky header being decoupled from the doc header & doc phase.
189
237
  We have to account for the global nav changing height due to animations.
@@ -243,9 +291,7 @@ export default class ContentLayout extends LightningElement {
243
291
  );
244
292
 
245
293
  // Adjust scroll margin for doc headings when doc phase is present
246
- const docHeadingEls = Array.from(
247
- document.querySelectorAll("doc-heading")
248
- );
294
+ const docHeadingEls = this.getHeadingElements();
249
295
  docHeadingEls.forEach((docHeadingEl) => {
250
296
  docHeadingEl.style.scrollMarginTop = `${
251
297
  globalNavHeight +
@@ -301,7 +347,7 @@ export default class ContentLayout extends LightningElement {
301
347
  );
302
348
 
303
349
  // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
304
- const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
350
+ const headingElements = this.getHeadingElements();
305
351
  for (const headingElement of headingElements) {
306
352
  // Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
307
353
  const id = headingElement.getAttribute("id");
@@ -317,47 +363,34 @@ export default class ContentLayout extends LightningElement {
317
363
  }
318
364
  };
319
365
 
320
- onSlotChange(event: Event): void {
321
- const slotElements = (
322
- event.target as HTMLSlotElement
323
- ).assignedElements();
324
-
325
- if (slotElements.length) {
326
- this.contentLoaded = true;
327
- const slotContentElement = slotElements[0];
328
- const headingElements =
329
- slotContentElement.ownerDocument?.getElementsByTagName(
330
- TOC_HEADER_TAG
331
- );
332
-
333
- for (const headingElement of headingElements) {
334
- // Sometimes elements hash is not being set when slot content is wrapped with div
335
- headingElement.hash = headingElement.attributes.hash?.nodeValue;
336
- }
366
+ onSlotChange(): void {
367
+ this.updateRNB();
368
+ }
337
369
 
338
- const tocOptions = [];
370
+ // eslint-disable-next-line no-undef
371
+ private updateTocItems(headingElements: NodeListOf<Element>): void {
372
+ const tocOptions = [];
339
373
 
340
- for (const headingElement of headingElements) {
341
- headingElement.id = headingElement.hash;
342
-
343
- // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
344
- const headingAriaLevel =
345
- headingElement.attributes["aria-level"]?.nodeValue || "2";
346
- const isH2 = headingAriaLevel === "2";
347
-
348
- if (isH2) {
349
- const tocItem = {
350
- anchor: `#${headingElement.hash}`,
351
- id: headingElement.id,
352
- label: headingElement.title
353
- };
354
- tocOptions.push(tocItem);
355
- this.tocOptionIdsSet.add(headingElement.id);
356
- }
374
+ for (const headingElement of headingElements) {
375
+ headingElement.id = headingElement.hash;
376
+
377
+ // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
378
+ const headingAriaLevel =
379
+ headingElement.attributes["aria-level"]?.nodeValue || "2";
380
+ const isH2 = headingAriaLevel === "2";
381
+
382
+ if (isH2) {
383
+ const tocItem = {
384
+ anchor: `#${headingElement.hash}`,
385
+ id: headingElement.id,
386
+ label: headingElement.title
387
+ };
388
+ tocOptions.push(tocItem);
389
+ this.tocOptionIdsSet.add(headingElement.id);
357
390
  }
358
-
359
- this._tocOptions = tocOptions;
360
391
  }
392
+
393
+ this._tocOptions = tocOptions;
361
394
  }
362
395
 
363
396
  private disconnectObserver(): void {
@@ -0,0 +1 @@
1
+ @import "doc/contentLayout/contentLayout.css";
@@ -0,0 +1 @@
1
+ <template></template>
@@ -0,0 +1,8 @@
1
+ import ContentLayout from "doc/contentLayout";
2
+ import contentLayoutHTML from 'doc/contentLayout/contentLayout.html'
3
+
4
+ export default class LWCReferenceLayout extends ContentLayout {
5
+ render(){
6
+ return contentLayoutHTML
7
+ }
8
+ }
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.