@salesforcedevs/dx-components 1.18.8 → 1.18.9-add-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 CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "1.18.8",
3
+ "version": "1.18.9-add-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
- "gitHead": "e9d51d7dab7f574cbbc850c7201d3296ffd7f321"
48
+ "node": "20.19.0",
49
+ "yarn": "1.22.19"
50
+ }
50
51
  }
@@ -116,18 +116,9 @@ code[class*="shiki"] {
116
116
 
117
117
  pre[class*="shiki"] {
118
118
  border-radius: 0 0 0.3em 0.3em;
119
- padding: 1em;
119
+ padding: 1em 1.5em;
120
120
  margin: 0.5em 0;
121
121
  overflow: auto;
122
- /* stylelint-disable-next-line */
123
- .line {
124
- counter-increment: codeblock-line;
125
-
126
- &::before {
127
- content: counter(codeblock-line);
128
- margin-right: 1.3em;
129
- }
130
- }
131
122
  }
132
123
 
133
124
  @media screen and (max-width: 640px) {
@@ -176,7 +176,7 @@ export default class CodeBlock extends LightningElement {
176
176
  const preElement = tempDiv.querySelector("pre");
177
177
 
178
178
  if (preElement) {
179
- preElement.classList.add("codeblock");
179
+ preElement.classList.add("codeblock", languageForHighlighting);
180
180
 
181
181
  // Italicize anything marked as a "variable" by the docs team
182
182
  // eslint-disable-next-line
@@ -5,10 +5,13 @@ import { getSidebarSearchParams } from "dxUtils/coveo";
5
5
  import { toJson } from "dxUtils/normalizers";
6
6
  import SidebarSearch from "dx/sidebarSearch";
7
7
  import { SidebarBase } from "dxBaseElements/sidebarBase";
8
+ import { handleScroll } from 'dxUtils/handleScroll';
8
9
 
9
10
  const MOBILE_SIZE_MATCH = "768px";
10
11
 
11
12
  export default class Sidebar extends SidebarBase {
13
+ handleScroll: (e: any) => void = () => {};
14
+
12
15
  @api coveoOrganizationId!: string;
13
16
  @api coveoPublicAccessToken!: string;
14
17
  @api coveoSearchHub!: string;
@@ -142,6 +145,8 @@ export default class Sidebar extends SidebarBase {
142
145
  }
143
146
 
144
147
  connectedCallback() {
148
+ this.handleScroll = handleScroll.bind(this);
149
+
145
150
  this.matchMedia = window.matchMedia(
146
151
  `(max-width: ${MOBILE_SIZE_MATCH})`
147
152
  );
@@ -3,7 +3,7 @@
3
3
 
4
4
  .toc {
5
5
  display: flex;
6
- flex-direction: row-reverse;
6
+ flex-direction: row;
7
7
  max-width: 240px;
8
8
  min-width: 80px;
9
9
  word-break: break-word;
@@ -25,12 +25,32 @@
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 2px -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
+ max-height: calc(100vh - 200px);
42
+ overflow-y: auto;
43
+ padding-bottom: 100px;
44
+ padding-right: 10px;
45
+ }
46
+
28
47
  .dx-text-display-8 {
29
48
  padding-top: var(--dx-g-spacing-sm);
30
49
  transition: var(--dx-g-transition-hue-1x);
31
50
  }
32
51
 
33
52
  .content-button {
53
+ display: block;
34
54
  line-height: var(--dx-g-text-lg);
35
55
  color: var(--dx-g-blue-vibrant-20);
36
56
  font-family: var(--dx-g-font-sans);
@@ -1,19 +1,23 @@
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 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>
17
21
  </div>
18
22
  </div>
19
23
  <div>
@@ -3,8 +3,13 @@ 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
+ private scrolling: boolean = false;
11
+ handleScroll: (e: any) => void = () => {};
12
+
8
13
  @api header!: string;
9
14
 
10
15
  @api
@@ -38,6 +43,10 @@ export default class Toc extends LightningElement {
38
43
 
39
44
  @track _options!: Array<ContentElement>;
40
45
 
46
+ connectedCallback() {
47
+ this.handleScroll = handleScroll.bind(this);
48
+ }
49
+
41
50
  private onClick(e: Event) {
42
51
  const target = e.currentTarget as HTMLElement;
43
52
  const id = target.getAttribute("contentid");
@@ -61,29 +61,6 @@ export class SidebarBase extends LightningElement {
61
61
  return this._sidebarContent;
62
62
  }
63
63
 
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
64
  renderedCallback(): void {
88
65
  /**
89
66
  * Implementing debouncing kind of logic here to scroll to selected element once tree rendering is done
@@ -0,0 +1,8 @@
1
+ export function handleScroll(this: any, scrollEvent: any) {
2
+ console.log('calling')
3
+ const list = scrollEvent.target;
4
+
5
+ setTimeout(() => {
6
+ this.showBoxShadow = (list.scrollTop > 0 && list.scrollHeight > list.clientHeight);
7
+ }, 200);
8
+ }
@@ -1,11 +1,13 @@
1
- import { createHighlighterCore, HighlighterCore } from "shiki/core";
1
+ import * as shiki from "shiki";
2
+
2
3
  import type { BundledLanguage, BundledTheme } from "shiki";
3
- import { createOnigurumaEngine } from "shiki/engine/oniguruma";
4
4
  import { transformerColorizedBrackets } from "@shikijs/colorized-brackets";
5
+ import { getCustomLanguageGrammars } from "dxUtils/shikiGrammars";
6
+
5
7
  interface ShikiSingleton {
6
- highlighter: HighlighterCore | null;
8
+ highlighter: shiki.HighlighterCore | null;
7
9
  initialized: boolean;
8
- initPromise: Promise<HighlighterCore> | null;
10
+ initPromise: Promise<shiki.HighlighterCore> | null;
9
11
  }
10
12
 
11
13
  const shikiInstance: ShikiSingleton = {
@@ -50,58 +52,47 @@ const LANGUAGE_MAP: Record<string, BundledLanguage> = {
50
52
 
51
53
  // Core languages that should be loaded immediately for best performance
52
54
  const CORE_LANGUAGES = [
53
- // @ts-ignore
54
- () => import("@shikijs/langs/apex"),
55
- // @ts-ignore
56
- () => import("@shikijs/langs/javascript"),
57
- // @ts-ignore
58
- () => import("@shikijs/langs/html"),
59
- // @ts-ignore
60
- () => import("@shikijs/langs/css"),
61
- // @ts-ignore
62
- () => import("@shikijs/langs/json"),
63
- // @ts-ignore
64
- () => import("@shikijs/langs/sql"),
65
- // @ts-ignore
66
- () => import("@shikijs/langs/bash"),
67
- // @ts-ignore
68
- () => import("@shikijs/langs/xml"),
69
- // @ts-ignore
70
- () => import("@shikijs/langs/graphql"),
71
- // @ts-ignore
72
- () => import("@shikijs/langs/jsx"),
73
- // @ts-ignore
74
- () => import("./customLanguages/ampscript.tmLanguage.json")
55
+ "apex",
56
+ "javascript",
57
+ "html",
58
+ "css",
59
+ "json",
60
+ "sql",
61
+ "bash",
62
+ "xml",
63
+ "graphql",
64
+ "jsx",
65
+ getCustomLanguageGrammars().ampscript
75
66
  ];
76
67
 
77
68
  // Non-critical languages that can be loaded asynchronously when needed
78
- const OPTIONAL_LANGUAGES: Record<string, () => Promise<any>> = {
69
+ const OPTIONAL_LANGUAGES: Record<string, any> = {
79
70
  // @ts-ignore
80
- typescript: () => import("@shikijs/langs/typescript"),
71
+ typescript: "typescript",
81
72
  // @ts-ignore
82
- markdown: () => import("@shikijs/langs/markdown"),
73
+ markdown: "markdown",
83
74
  // @ts-ignore
84
- python: () => import("@shikijs/langs/python"),
75
+ python: "python",
85
76
  // @ts-ignore
86
- java: () => import("@shikijs/langs/java"),
77
+ java: "java",
87
78
  // @ts-ignore
88
- yaml: () => import("@shikijs/langs/yaml"),
79
+ yaml: "yaml",
89
80
  // @ts-ignore
90
- php: () => import("@shikijs/langs/php"),
81
+ php: "php",
91
82
  // @ts-ignore
92
- swift: () => import("@shikijs/langs/swift"),
83
+ swift: "swift",
93
84
  // @ts-ignore
94
- kotlin: () => import("@shikijs/langs/kotlin"),
85
+ kotlin: "kotlin",
95
86
  // @ts-ignore
96
- handlebars: () => import("@shikijs/langs/handlebars"),
87
+ handlebars: "handlebars",
97
88
  // @ts-ignore
98
- dataweave: () => import("./customLanguages/dataweave.tmLanguage.json"),
89
+ dataweave: getCustomLanguageGrammars().dataweave,
99
90
  // @ts-ignore
100
- afscript: () => import("./customLanguages/afscript.tmLanguage.json")
91
+ afscript: getCustomLanguageGrammars().afscript
101
92
  };
102
93
 
103
94
  // Initialize Shiki highlighter with fine-grained modules for better performance
104
- async function initializeShiki(): Promise<HighlighterCore> {
95
+ async function initializeShiki(): Promise<shiki.HighlighterCore> {
105
96
  if (shikiInstance.highlighter) {
106
97
  return shikiInstance.highlighter;
107
98
  }
@@ -110,15 +101,9 @@ async function initializeShiki(): Promise<HighlighterCore> {
110
101
  return shikiInstance.initPromise;
111
102
  }
112
103
 
113
- shikiInstance.initPromise = createHighlighterCore({
114
- themes: [
115
- // @ts-ignore
116
- import("@shikijs/themes/light-plus"),
117
- // @ts-ignore
118
- import("@shikijs/themes/material-theme-darker")
119
- ],
120
- langs: CORE_LANGUAGES,
121
- engine: createOnigurumaEngine(import("shiki/wasm"))
104
+ shikiInstance.initPromise = shiki.createHighlighter({
105
+ themes: ["light-plus", "material-theme-darker"],
106
+ langs: CORE_LANGUAGES
122
107
  });
123
108
 
124
109
  try {
@@ -134,7 +119,7 @@ async function initializeShiki(): Promise<HighlighterCore> {
134
119
 
135
120
  // Async function to load additional languages when needed
136
121
  async function loadLanguageIfNeeded(
137
- highlighter: HighlighterCore,
122
+ highlighter: shiki.HighlighterCore,
138
123
  language: string
139
124
  ): Promise<void> {
140
125
  const loadedLanguages = highlighter.getLoadedLanguages();
@@ -145,10 +130,7 @@ async function loadLanguageIfNeeded(
145
130
 
146
131
  if (languageLoader) {
147
132
  try {
148
- const languageModule = await languageLoader();
149
- await highlighter.loadLanguage(
150
- languageModule.default || languageModule
151
- );
133
+ await highlighter.loadLanguage(languageLoader);
152
134
  } catch (error) {
153
135
  console.warn(
154
136
  `Failed to load optional language ${language}:`,
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <!-- This is a utility module for importing custom language grammars for Shiki -->
3
+ </template>