@salesforcedevs/docs-components 1.3.325-rnbtab-alpha1 → 1.3.326

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
@@ -9,6 +9,7 @@
9
9
  "doc/breadcrumbs",
10
10
  "doc/content",
11
11
  "doc/contentCallout",
12
+ "doc/doDont",
12
13
  "doc/contentLayout",
13
14
  "doc/contentMedia",
14
15
  "doc/docXmlContent",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.325-rnbtab-alpha1",
3
+ "version": "1.3.326",
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": "4629fdd9ca18a13480044ad43515b91945d16aad"
27
+ "gitHead": "cf39ccca12fbfe7bf200eb0bd02c5101af21ca19"
28
28
  }
@@ -11,7 +11,6 @@ type AnchorMap = { [key: string]: { intersect: boolean; id: string } };
11
11
  declare const Sprig: (eventType: string, eventNme: string) => void;
12
12
 
13
13
  const TOC_HEADER_TAG = "doc-heading";
14
- const RNB_BY_TAB = "docs-tab";
15
14
  const HIGHLIGHTABLE_SELECTOR = [
16
15
  "p",
17
16
  "h1",
@@ -42,7 +41,6 @@ export default class ContentLayout extends LightningElement {
42
41
  @api language!: string;
43
42
  @api bailHref!: string;
44
43
  @api bailLabel!: string;
45
- @track initialIndex: number = 0;
46
44
 
47
45
  // This is needed for now to prevent failing snapshot tests due to links in the footer
48
46
  @api showFooter = false;
@@ -103,68 +101,6 @@ export default class ContentLayout extends LightningElement {
103
101
  return this.contentLoaded && typeof Sprig !== "undefined";
104
102
  }
105
103
 
106
- get showTabBasedRNB() {
107
- const tabPanelListItem: any = this.selectTabElement();
108
- return tabPanelListItem?.id === RNB_BY_TAB ? true : false;
109
- }
110
-
111
- onTabChanged = () => {
112
- this.updateRNB();
113
- };
114
-
115
- private selectTabElement() {
116
- return document.querySelector("dx-tab-panel-list");
117
- }
118
-
119
- updateRNB = () => {
120
- const headingElements = this.getHeadingElements();
121
- headingElements.forEach((headingElement: any) => {
122
- headingElement.hash = headingElement.attributes.hash?.nodeValue;
123
- });
124
- this.updateTocItems(headingElements);
125
- };
126
-
127
- private getHeadingElements() {
128
- let headingElements = document.querySelectorAll(TOC_HEADER_TAG);
129
- if (this.showTabBasedRNB) {
130
- const tabPanelListItem: any = this.selectTabElement();
131
- const tabPanels =
132
- tabPanelListItem?.querySelectorAll("dx-tab-panel");
133
- for (const tabPanelItem of tabPanels) {
134
- if (tabPanelItem.active) {
135
- headingElements =
136
- tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
137
- break;
138
- }
139
- }
140
- }
141
- return headingElements;
142
- }
143
-
144
- private updateURL() {
145
- const tabPanelListItem: any = this.selectTabElement();
146
- if (tabPanelListItem?.shadowRoot) {
147
- const tabPanelItems =
148
- tabPanelListItem.shadowRoot.querySelectorAll(
149
- "dx-tab-panel-item"
150
- );
151
- if (tabPanelItems) {
152
- tabPanelItems.forEach((tabPanelItem: any) => {
153
- const tab = tabPanelItem.shadowRoot.querySelector("button");
154
- if (tab?.getAttribute("aria-selected") === "true") {
155
- const tabID = tab?.getAttribute("aria-label");
156
- const url = new URL(window.location.href);
157
- if (url.searchParams.get("type") !== tabID) {
158
- url.searchParams.set("type", tabID);
159
- url.hash = "";
160
- window.history.pushState({}, "", url.toString());
161
- }
162
- }
163
- });
164
- }
165
- }
166
- }
167
-
168
104
  private searchSyncer = new SearchSyncer({
169
105
  callbacks: {
170
106
  onSearchChange: (nextSearchString: string): void => {
@@ -212,41 +148,6 @@ export default class ContentLayout extends LightningElement {
212
148
  );
213
149
  this.searchSyncer.init();
214
150
  }
215
-
216
- if (this.showTabBasedRNB) {
217
- window.addEventListener("tabchanged", this.onTabChanged);
218
- this.restoreTabSelection();
219
- }
220
- }
221
-
222
- private restoreTabSelection() {
223
- const urlParams = new URLSearchParams(window.location.search);
224
- const selectedTabId = urlParams.get("type");
225
-
226
- if (selectedTabId) {
227
- this.selectTabById(selectedTabId);
228
- }
229
- }
230
-
231
- private selectTabById(tabId: string) {
232
- requestAnimationFrame(() => {
233
- const tabPanelListItem: any = this.selectTabElement();
234
- if (tabPanelListItem?.shadowRoot) {
235
- const tabPanelItems =
236
- tabPanelListItem.shadowRoot.querySelectorAll(
237
- "dx-tab-panel-item"
238
- );
239
- if (tabPanelItems) {
240
- tabPanelItems.forEach((tabPanelItem: any) => {
241
- const tab =
242
- tabPanelItem.shadowRoot.querySelector("button");
243
- if (tab?.getAttribute("aria-label") === tabId) {
244
- tab?.click();
245
- }
246
- });
247
- }
248
- }
249
- });
250
151
  }
251
152
 
252
153
  renderedCallback(): void {
@@ -423,13 +324,7 @@ export default class ContentLayout extends LightningElement {
423
324
  );
424
325
 
425
326
  // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
426
- const headingElements = this.getHeadingElements();
427
-
428
- // We only need to update URL in case of /docs and ignore if tabs are used anywhere else in DSC
429
- if (this.showTabBasedRNB) {
430
- this.updateURL();
431
- }
432
-
327
+ const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
433
328
  for (const headingElement of headingElements as any) {
434
329
  // Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
435
330
  const id = headingElement.getAttribute("id")!;
@@ -445,43 +340,49 @@ export default class ContentLayout extends LightningElement {
445
340
  }
446
341
  };
447
342
 
448
- onSlotChange(e): void {
449
- const slot = e.target;
450
- const child = slot.assignedElements();
451
- const tabComponent = child.find(
452
- (element: any) =>
453
- element.tagName.toLowerCase() === "dx-tab-panel-list"
454
- );
455
- if (tabComponent) {
456
- tabComponent.initialIndex = this.initialIndex; // Set the index value on the child component
457
- }
458
- this.updateRNB();
459
- }
343
+ onSlotChange(event: Event): void {
344
+ const slotElements = (
345
+ event.target as HTMLSlotElement
346
+ ).assignedElements();
347
+
348
+ if (slotElements.length) {
349
+ this.contentLoaded = true;
350
+ const slotContentElement = slotElements[0];
351
+ const headingElements =
352
+ slotContentElement.ownerDocument?.getElementsByTagName(
353
+ TOC_HEADER_TAG
354
+ );
460
355
 
461
- // eslint-disable-next-line no-undef
462
- private updateTocItems(headingElements: NodeListOf<Element>): void {
463
- const tocOptions = [];
356
+ for (const headingElement of headingElements as any) {
357
+ // Sometimes elements hash and header is not being set when slot content is wrapped with div
358
+ headingElement.hash = headingElement.attributes.hash?.nodeValue;
359
+ headingElement.header =
360
+ headingElement.attributes.header?.nodeValue;
361
+ }
464
362
 
465
- for (const headingElement of headingElements as any) {
466
- headingElement.id = headingElement.hash;
467
-
468
- // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
469
- const headingAriaLevel =
470
- headingElement.attributes["aria-level"]?.nodeValue || "2";
471
- const isH2 = headingAriaLevel === "2";
472
-
473
- if (isH2) {
474
- const tocItem = {
475
- anchor: `#${headingElement.hash}`,
476
- id: headingElement.id,
477
- label: headingElement.header
478
- };
479
- tocOptions.push(tocItem);
480
- this.tocOptionIdsSet.add(headingElement.id);
363
+ const tocOptions = [];
364
+
365
+ for (const headingElement of headingElements as any) {
366
+ headingElement.id = headingElement.hash;
367
+
368
+ // Update tocOptions from anchorTags only for H2, consider default as 2 as per component
369
+ const headingAriaLevel =
370
+ headingElement.attributes["aria-level"]?.nodeValue || "2";
371
+ const isH2 = headingAriaLevel === "2";
372
+
373
+ if (isH2) {
374
+ const tocItem = {
375
+ anchor: `#${headingElement.hash}`,
376
+ id: headingElement.id,
377
+ label: headingElement.header
378
+ };
379
+ tocOptions.push(tocItem);
380
+ this.tocOptionIdsSet.add(headingElement.id);
381
+ }
481
382
  }
482
- }
483
383
 
484
- this._tocOptions = tocOptions;
384
+ this._tocOptions = tocOptions;
385
+ }
485
386
  }
486
387
 
487
388
  private disconnectObserver(): void {
@@ -0,0 +1,47 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+
4
+ .container {
5
+ display: flex;
6
+ flex-direction: column;
7
+ gap: var(--dx-g-spacing-md);
8
+ flex: 1;
9
+ }
10
+
11
+ .doc-do-dont-header {
12
+ display: flex;
13
+ align-items: center;
14
+ gap: var(--dx-g-spacing-sm);
15
+ }
16
+
17
+ .doc-do-dont-label {
18
+ font-family: var(--dx-g-font-display);
19
+ font-size: var(--dx-g-spacing-md);
20
+ font-weight: var(--dx-g-font-demi);
21
+ line-height: var(--dx-g-spacing-lg);
22
+ }
23
+
24
+ .doc-do-color {
25
+ color: var(--dx-g-green-vibrant-50);
26
+ }
27
+
28
+ .doc-dont-color {
29
+ color: var(--dx-g-red-vibrant-30);
30
+ }
31
+
32
+ .do-dont-image-container {
33
+ display: flex;
34
+ max-height: 480px;
35
+ min-height: 140px;
36
+ padding: var(--dx-g-spacing-3xl) var(--dx-g-spacing-2xl);
37
+ flex-direction: column;
38
+ justify-content: center;
39
+ align-items: center;
40
+ flex: 1;
41
+ border-radius: var(--dx-g-spacing-sm);
42
+ border: 1px solid var(--dx-g-brand-default-color-border-2);
43
+ }
44
+
45
+ .doc-do-dont-img {
46
+ object-fit: contain;
47
+ }
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div class="container">
3
+ <div class="doc-do-dont-header">
4
+ <template lwc:if={isDo}>
5
+ <dx-icon
6
+ symbol="success"
7
+ size="large"
8
+ color="green-vibrant-50"
9
+ ></dx-icon>
10
+ <div class="doc-do-dont-label doc-do-color">Do</div>
11
+ </template>
12
+ <template lwc:else>
13
+ <dx-icon
14
+ symbol="clear"
15
+ size="large"
16
+ color="red-vibrant-30"
17
+ class="doc-do-dont-icon"
18
+ ></dx-icon>
19
+ <div class="doc-do-dont-label doc-dont-color">Don't</div>
20
+ </template>
21
+ </div>
22
+ <div class="do-dont-image-container">
23
+ <img class="doc-do-dont-img" src={src} alt={caption} />
24
+ </div>
25
+ <div class="dx-text-body-4">{caption}</div>
26
+ </div>
27
+ </template>
@@ -0,0 +1,17 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { normalizeBoolean } from "dxUtils/normalizers";
3
+
4
+ export default class DoDont extends LightningElement {
5
+ @api caption: string = "";
6
+ @api src!: string;
7
+ _isDo: boolean = false;
8
+
9
+ @api
10
+ get isDo(): boolean {
11
+ return this._isDo;
12
+ }
13
+
14
+ set isDo(value) {
15
+ this._isDo = normalizeBoolean(value);
16
+ }
17
+ }