@salesforcedevs/dx-components 1.19.6 → 1.20.0-rnb-scroll
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 +6 -5
- package/src/modules/dx/codeBlock/codeBlock.ts +1 -1
- package/src/modules/dx/toc/toc.css +28 -0
- package/src/modules/dx/toc/toc.html +18 -13
- package/src/modules/dx/toc/toc.ts +4 -0
- package/src/modules/dxBaseElements/sidebarBase/sidebarBase.ts +2 -24
- package/src/modules/dxUtils/handleScroll/handleScroll.ts +17 -0
- package/src/modules/dxUtils/shiki/shiki.ts +1 -1
- package/src/modules/dxUtils/shikiGrammars/shikiGrammars.ts +354 -217
- package/LICENSE +0 -12
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0-rnb-scroll",
|
|
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
|
-
|
|
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: "
|
|
75
|
+
{ label: "Agent Script", id: "agentscript" }
|
|
76
76
|
];
|
|
77
77
|
|
|
78
78
|
_codeBlock: string = "";
|
|
@@ -25,12 +25,40 @@
|
|
|
25
25
|
margin-bottom: var(--dx-g-spacing-md);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
.toc-content-header {
|
|
29
|
+
width: 100%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.toc-content-header[show-shadow="true"] {
|
|
33
|
+
box-shadow: 0 4px 4px -2px var(--dx-g-gray-90);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.toc-content-header[show-shadow="true"] .toc_title {
|
|
37
|
+
margin-bottom: var(--dx-g-spacing-sm);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.toc-items {
|
|
41
|
+
overflow-y: auto;
|
|
42
|
+
padding-bottom: 80px;
|
|
43
|
+
padding-right: 10px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.scroll-shadow {
|
|
47
|
+
position: sticky;
|
|
48
|
+
bottom: -80px; /* to maintain padding given to toc-items */
|
|
49
|
+
height: 5px;
|
|
50
|
+
background: linear-gradient(to bottom, transparent, var(--dx-g-gray-90));
|
|
51
|
+
transition: opacity 0.3s;
|
|
52
|
+
opacity: 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
.dx-text-display-8 {
|
|
29
56
|
padding-top: var(--dx-g-spacing-sm);
|
|
30
57
|
transition: var(--dx-g-transition-hue-1x);
|
|
31
58
|
}
|
|
32
59
|
|
|
33
60
|
.content-button {
|
|
61
|
+
display: block;
|
|
34
62
|
line-height: var(--dx-g-text-lg);
|
|
35
63
|
color: var(--dx-g-blue-vibrant-20);
|
|
36
64
|
font-family: var(--dx-g-font-sans);
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="toc" role="navigation">
|
|
3
3
|
<div class="toc toc_content">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
<div class="toc-content-header" show-shadow={showBoxShadow}>
|
|
5
|
+
<h2 class="dx-text-display-8 toc_title">{header}</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="toc-items" onscroll={handleScroll}>
|
|
8
|
+
<template for:each={options} for:item="option">
|
|
9
|
+
<a
|
|
10
|
+
href={option.anchor}
|
|
11
|
+
class={option.className}
|
|
12
|
+
onclick={onClick}
|
|
13
|
+
contentid={option.id}
|
|
14
|
+
data-text={option.label}
|
|
15
|
+
key={option.id}
|
|
16
|
+
>
|
|
17
|
+
{option.label}
|
|
18
|
+
</a>
|
|
19
|
+
</template>
|
|
20
|
+
<div class="scroll-shadow"></div>
|
|
21
|
+
</div>
|
|
17
22
|
</div>
|
|
18
23
|
</div>
|
|
19
24
|
<div>
|
|
@@ -3,8 +3,12 @@ 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
|
+
handleScroll = handleScroll.bind(this);
|
|
11
|
+
|
|
8
12
|
@api header!: string;
|
|
9
13
|
|
|
10
14
|
@api
|
|
@@ -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;
|
|
@@ -16,7 +18,6 @@ export class SidebarBase extends LightningElement {
|
|
|
16
18
|
expanded: boolean = true;
|
|
17
19
|
_value?: string = undefined;
|
|
18
20
|
showBoxShadow: boolean = false;
|
|
19
|
-
private scrolling: boolean = false;
|
|
20
21
|
_devCenter!: DevCenterConfig;
|
|
21
22
|
|
|
22
23
|
@api langValuePath: string = "id";
|
|
@@ -61,29 +62,6 @@ export class SidebarBase extends LightningElement {
|
|
|
61
62
|
return this._sidebarContent;
|
|
62
63
|
}
|
|
63
64
|
|
|
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
65
|
renderedCallback(): void {
|
|
88
66
|
/**
|
|
89
67
|
* Implementing debouncing kind of logic here to scroll to selected element once tree rendering is done
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function handleScroll(this: any, scrollEvent: any) {
|
|
2
|
+
const { scrollTop, scrollHeight, clientHeight } = scrollEvent.target;
|
|
3
|
+
|
|
4
|
+
// to show shadow box at bottom of list container
|
|
5
|
+
const shadow = this.template.querySelector(".scroll-shadow");
|
|
6
|
+
|
|
7
|
+
if (shadow) {
|
|
8
|
+
const isScrollable = scrollHeight > clientHeight;
|
|
9
|
+
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 75; //subtracting to maintain the padding given to toc-items
|
|
10
|
+
|
|
11
|
+
shadow.style.opacity = isScrollable && !isAtBottom ? 1 : 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
this.showBoxShadow = scrollTop > 0 && scrollHeight > clientHeight;
|
|
16
|
+
}, 200);
|
|
17
|
+
}
|
|
@@ -88,7 +88,7 @@ const OPTIONAL_LANGUAGES: Record<string, any> = {
|
|
|
88
88
|
// @ts-ignore
|
|
89
89
|
dataweave: getCustomLanguageGrammars().dataweave,
|
|
90
90
|
// @ts-ignore
|
|
91
|
-
|
|
91
|
+
agentscript: getCustomLanguageGrammars().agentscript
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
// Initialize Shiki highlighter with fine-grained modules for better performance
|