@salesforcedevs/dx-components 1.19.6 → 1.20.0-rnb-scroll-2

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,10 +1,11 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.19.6",
3
+ "version": "1.20.0-rnb-scroll-2",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
7
- "node": "20.x"
7
+ "node": "20.x",
8
+ "yarn": "1.22.19"
8
9
  },
9
10
  "publishConfig": {
10
11
  "access": "public"
@@ -44,7 +45,7 @@
44
45
  "luxon": "3.4.4"
45
46
  },
46
47
  "volta": {
47
- "node": "20.19.0"
48
- },
49
- "gitHead": "693b52f254e6c2316d84b5917ceea3ccd9416549"
48
+ "node": "20.19.0",
49
+ "yarn": "1.22.19"
50
+ }
50
51
  }
@@ -72,7 +72,7 @@ export default class CodeBlock extends LightningElement {
72
72
  { label: "GTL", id: "gtl" },
73
73
  { label: "LWC", id: "lwc" },
74
74
  { label: "SQL Documentation", id: "sql_docs_template" },
75
- { label: "Agentforce Script", id: "afscript" }
75
+ { label: "Agent Script", id: "agentscript" }
76
76
  ];
77
77
 
78
78
  _codeBlock: string = "";
@@ -1,6 +1,10 @@
1
1
  @import "dxHelpers/reset";
2
2
  @import "dxHelpers/text";
3
3
 
4
+ :host {
5
+ --dx-c-toc-padding-bottom: 80px;
6
+ }
7
+
4
8
  .toc {
5
9
  display: flex;
6
10
  flex-direction: row;
@@ -25,12 +29,35 @@
25
29
  margin-bottom: var(--dx-g-spacing-md);
26
30
  }
27
31
 
32
+ .toc-content-header {
33
+ width: 100%;
34
+ }
35
+
36
+ .toc-content-header[show-shadow="true"] {
37
+ box-shadow: 0 4px 4px -2px var(--dx-g-gray-90);
38
+ }
39
+
40
+ .toc-content-header[show-shadow="true"] .toc_title {
41
+ margin-bottom: var(--dx-g-spacing-sm);
42
+ }
43
+
44
+ .toc-items {
45
+ overflow-y: auto;
46
+ padding-bottom: var(--dx-c-toc-padding-bottom);
47
+ padding-right: var(--dx-g-spacing-smd);
48
+ }
49
+
50
+ .toc-items[show-bottom-shadow="true"] {
51
+ box-shadow: 0 4px 4px -2px var(--dx-g-gray-90);
52
+ }
53
+
28
54
  .dx-text-display-8 {
29
55
  padding-top: var(--dx-g-spacing-sm);
30
56
  transition: var(--dx-g-transition-hue-1x);
31
57
  }
32
58
 
33
59
  .content-button {
60
+ display: block;
34
61
  line-height: var(--dx-g-text-lg);
35
62
  color: var(--dx-g-blue-vibrant-20);
36
63
  font-family: var(--dx-g-font-sans);
@@ -1,19 +1,27 @@
1
1
  <template>
2
2
  <div class="toc" role="navigation">
3
3
  <div class="toc toc_content">
4
- <h2 class="dx-text-display-8 toc_title">{header}</h2>
5
- <template for:each={options} for:item="option">
6
- <a
7
- href={option.anchor}
8
- class={option.className}
9
- onclick={onClick}
10
- contentid={option.id}
11
- data-text={option.label}
12
- key={option.id}
13
- >
14
- {option.label}
15
- </a>
16
- </template>
4
+ <div class="toc-content-header" show-shadow={showBoxShadow}>
5
+ <h2 class="dx-text-display-8 toc_title">{header}</h2>
6
+ </div>
7
+ <div
8
+ class="toc-items"
9
+ show-bottom-shadow={showBoxShadowBottom}
10
+ onscroll={handleScroll}
11
+ >
12
+ <template for:each={options} for:item="option">
13
+ <a
14
+ href={option.anchor}
15
+ class={option.className}
16
+ onclick={onClick}
17
+ contentid={option.id}
18
+ data-text={option.label}
19
+ key={option.id}
20
+ >
21
+ {option.label}
22
+ </a>
23
+ </template>
24
+ </div>
17
25
  </div>
18
26
  </div>
19
27
  <div>
@@ -3,8 +3,15 @@ import cx from "classnames";
3
3
  import { ContentElement } from "typings/custom";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
  import { track as sendGtm } from "dxUtils/analytics";
6
+ import { handleScroll } from "dxUtils/handleScroll";
6
7
 
7
8
  export default class Toc extends LightningElement {
9
+ showBoxShadow: boolean = false;
10
+ showBoxShadowBottom: boolean = false;
11
+ private scrolling: boolean = false;
12
+ private scrollToBottom: boolean = false;
13
+ handleScroll = handleScroll.bind(this);
14
+
8
15
  @api header!: string;
9
16
 
10
17
  @api
@@ -38,6 +45,37 @@ export default class Toc extends LightningElement {
38
45
 
39
46
  @track _options!: Array<ContentElement>;
40
47
 
48
+ // to show shadow box at bottom of list container
49
+ private showShadowAtBottom = (event: any) => {
50
+ const list = event.target;
51
+
52
+ if (!this.scrollToBottom) {
53
+ this.scrollToBottom = true;
54
+ // Set a timeout to handle scroll event after a delay
55
+ setTimeout(() => {
56
+ const isScrollable = list.scrollHeight > list.clientHeight;
57
+ const isAtBottom =
58
+ list.scrollTop + list.clientHeight >=
59
+ list.scrollHeight - 75;
60
+
61
+ this.showBoxShadowBottom = isScrollable && !isAtBottom;
62
+
63
+ // Reset scrolling back to false after handling the scroll
64
+ this.scrollToBottom = false;
65
+ }, 100);
66
+ }
67
+ };
68
+
69
+ renderedCallback(): void {
70
+ const list = this.template.querySelector(".toc-items");
71
+ list?.addEventListener("scroll", this.showShadowAtBottom);
72
+ }
73
+
74
+ disconnectedCallback(): void {
75
+ const list = this.template.querySelector(".toc-items");
76
+ list?.removeEventListener("scroll", this.showShadowAtBottom);
77
+ }
78
+
41
79
  private onClick(e: Event) {
42
80
  const target = e.currentTarget as HTMLElement;
43
81
  const id = target.getAttribute("contentid");
@@ -2,12 +2,14 @@ import { LightningElement, api } from "lwc";
2
2
  import type { OptionWithLink } from "typings/custom";
3
3
  import { toJson } from "dxUtils/normalizers";
4
4
  import { Brand, DevCenterConfig } from "typings/custom";
5
+ import { handleScroll } from "dxUtils/handleScroll";
5
6
 
6
7
  export const HEIGHT_OF_SIDEBAR_ITEM = 32;
7
8
  export const WAIT_TIME_BEFORE_SCROLL_IN_MS = 500;
8
9
 
9
10
  export class SidebarBase extends LightningElement {
10
11
  _sidebarContent: HTMLElement | null = null;
12
+ handleScroll = handleScroll.bind(this);
11
13
 
12
14
  selectedElement: HTMLElement | null = null;
13
15
  timerId: ReturnType<typeof setTimeout> | null = null;
@@ -61,29 +63,6 @@ export class SidebarBase extends LightningElement {
61
63
  return this._sidebarContent;
62
64
  }
63
65
 
64
- /**
65
- * This method is to handle the scroll event for LNB and show box shadow
66
- * @param scrollEvent
67
- */
68
- handleScroll(scrollEvent: any) {
69
- const lnb = scrollEvent.target;
70
-
71
- if (!this.scrolling) {
72
- this.scrolling = true;
73
- // Set a timeout to handle scroll event after a delay
74
- setTimeout(() => {
75
- // Check if lnb is scrolled
76
- if (lnb.scrollTop > 0 && lnb.scrollHeight > lnb.clientHeight) {
77
- this.showBoxShadow = true;
78
- } else {
79
- this.showBoxShadow = false;
80
- }
81
- // Reset scrolling back to false after handling the scroll
82
- this.scrolling = false;
83
- }, 200);
84
- }
85
- }
86
-
87
66
  renderedCallback(): void {
88
67
  /**
89
68
  * Implementing debouncing kind of logic here to scroll to selected element once tree rendering is done
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This generic method is to handle the scroll event and show box shadow below header
3
+ * @param scrollEvent
4
+ */
5
+ export function handleScroll(this: any, scrollEvent: any) {
6
+ const listContainer = scrollEvent.target;
7
+
8
+ if (!this.scrolling) {
9
+ this.scrolling = true;
10
+ // Set a timeout to handle scroll event after a delay
11
+ setTimeout(() => {
12
+ // Check if scrolled
13
+ this.showBoxShadow =
14
+ listContainer.scrollTop > 0 &&
15
+ listContainer.scrollHeight > listContainer.clientHeight;
16
+ // Reset scrolling back to false after handling the scroll
17
+ this.scrolling = false;
18
+ }, 200);
19
+ }
20
+ }
@@ -88,7 +88,7 @@ const OPTIONAL_LANGUAGES: Record<string, any> = {
88
88
  // @ts-ignore
89
89
  dataweave: getCustomLanguageGrammars().dataweave,
90
90
  // @ts-ignore
91
- afscript: getCustomLanguageGrammars().afscript
91
+ agentscript: getCustomLanguageGrammars().agentscript
92
92
  };
93
93
 
94
94
  // Initialize Shiki highlighter with fine-grained modules for better performance