@salesforcedevs/dx-components 1.3.355 → 1.3.357
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 +1 -0
- package/package.json +2 -2
- package/src/modules/dx/codeBlock/codeBlock.css +2 -1
- package/src/modules/dx/codeBlock/codeBlock.ts +3 -3
- package/src/modules/dx/footerOption/footerOption.css +1 -1
- package/src/modules/dx/tabPanelItem/tabPanelItem.css +1 -1
- package/src/modules/dx/tabbedCodeBlock/tabbedCodeBlock.css +8 -0
- package/src/modules/dx/tabbedCodeBlock/tabbedCodeBlock.html +16 -0
- package/src/modules/dx/tabbedCodeBlock/tabbedCodeBlock.ts +44 -0
- package/src/modules/dxUtils/normalizers/normalizers.ts +12 -0
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.357",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"volta": {
|
|
47
47
|
"node": "18.18.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "568e719998db5e10c4601b1fcd3a184aa9a380c0"
|
|
50
50
|
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
pre {
|
|
11
11
|
margin: 0 !important;
|
|
12
|
+
height: var(--dx-code-block-height, unset);
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
.copyta {
|
|
@@ -19,7 +20,7 @@ pre {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
.toolbar {
|
|
22
|
-
border-radius: 0.3em 0.3em 0 0;
|
|
23
|
+
border-radius: var(--dx-code-block-toolbar-border-radius, 0.3em 0.3em 0 0);
|
|
23
24
|
opacity: 1;
|
|
24
25
|
display: flex;
|
|
25
26
|
align-items: center;
|
|
@@ -39,14 +39,14 @@ prism.languages.sql_docs_template = sqlDocsTemplate;
|
|
|
39
39
|
// Used for remove enclosing <pre> tag's (if occurs)
|
|
40
40
|
const preTagRegexp: RegExp = /^<pre.*?>(.*)<\/pre>$/is;
|
|
41
41
|
|
|
42
|
-
const LIGHT = "light";
|
|
43
|
-
const DARK = "dark";
|
|
42
|
+
export const LIGHT = "light";
|
|
43
|
+
export const DARK = "dark";
|
|
44
44
|
const themes: CodeBlockTheme[] = [LIGHT, DARK];
|
|
45
45
|
const LOCAL_STORAGE_KEY = "dx-codeblock-theme";
|
|
46
46
|
|
|
47
47
|
export default class CodeBlock extends LightningElement {
|
|
48
48
|
@api defaultTheme: CodeBlockTheme = LIGHT;
|
|
49
|
-
@api header: string = "
|
|
49
|
+
@api header: string = "";
|
|
50
50
|
@api sourceLink: string = "";
|
|
51
51
|
@api language: string = "";
|
|
52
52
|
// if it is true, it renders code as is coming instead of wrapping it into html/xml comments tags.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
font-size: var(--dx-g-text-base);
|
|
7
7
|
font-weight: var(--dx-g-font-normal);
|
|
8
8
|
line-height: var(--dx-g-spacing-lg);
|
|
9
|
-
padding: var(--dx-g-spacing-
|
|
9
|
+
padding: var(--dx-g-spacing-sm) var(--dx-g-spacing-lg);
|
|
10
10
|
border-top-left-radius: var(--dx-g-spacing-sm);
|
|
11
11
|
border-top-right-radius: var(--dx-g-spacing-sm);
|
|
12
12
|
border-bottom: var(--dx-g-spacing-xs) solid transparent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dx-tab-panel-list tabs={tabs}>
|
|
3
|
+
<template for:each={_codeBlocks} for:item="codeBlockItem">
|
|
4
|
+
<dx-tab-panel key={codeBlockItem.header}>
|
|
5
|
+
<!-- The header attribute is not passed intentionally because the tab title uses the header value. -->
|
|
6
|
+
<dx-code-block
|
|
7
|
+
default-theme={defaultTheme}
|
|
8
|
+
code-block={codeBlockItem.codeBlock}
|
|
9
|
+
language={codeBlockItem.language}
|
|
10
|
+
source-link={codeBlockItem.sourceLink}
|
|
11
|
+
is-encoded={codeBlockItem.isEncoded}
|
|
12
|
+
></dx-code-block>
|
|
13
|
+
</dx-tab-panel>
|
|
14
|
+
</template>
|
|
15
|
+
</dx-tab-panel-list>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { CodeBlockItem } from "typings/custom";
|
|
3
|
+
import { safeDecodeURI, toJson } from "dxUtils/normalizers";
|
|
4
|
+
import { DARK } from "dx/codeBlock";
|
|
5
|
+
|
|
6
|
+
export default class TabbedCodeBlock extends LightningElement {
|
|
7
|
+
_codeBlocks: CodeBlockItem[] = [];
|
|
8
|
+
|
|
9
|
+
// By default, we want a dark theme for the tabbed code block; however, if the user changes the theme of any code block, it updates the same across the entire website.
|
|
10
|
+
@api defaultTheme = DARK;
|
|
11
|
+
|
|
12
|
+
get tabs(): string {
|
|
13
|
+
// Use the code block headers to create a tabs array as a JSON string
|
|
14
|
+
return JSON.stringify(
|
|
15
|
+
this._codeBlocks.map((codeBlock) => ({ label: codeBlock.header }))
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// We need to pass the attribute as decodedURI(JSON.stringify(codeBlocksArray)) to avoid issues with single and double quotes in the code block content.
|
|
20
|
+
@api
|
|
21
|
+
set codeBlocks(value: string) {
|
|
22
|
+
if (value) {
|
|
23
|
+
// Decode the encoded code block JSON string
|
|
24
|
+
const decodeCodeBlockJson = safeDecodeURI(value);
|
|
25
|
+
try {
|
|
26
|
+
const codeBlockItems = toJson(decodeCodeBlockJson);
|
|
27
|
+
this._codeBlocks = codeBlockItems.map(
|
|
28
|
+
(codeBlock: CodeBlockItem) => {
|
|
29
|
+
return {
|
|
30
|
+
...codeBlock,
|
|
31
|
+
defaultTheme: this.defaultTheme
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
} catch (exception) {
|
|
36
|
+
console.log("Invalid codeblock items json", exception);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
get codeBlocks(): CodeBlockItem[] {
|
|
42
|
+
return this._codeBlocks;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -76,3 +76,15 @@ export const normalizeBoolean = (
|
|
|
76
76
|
export const normalizeDomId = (id: string): string => {
|
|
77
77
|
return id.replace(/^[^a-z]+|[^\w.-]+/gi, "");
|
|
78
78
|
};
|
|
79
|
+
|
|
80
|
+
export const safeDecodeURI = (value: string): string => {
|
|
81
|
+
try {
|
|
82
|
+
// Check if the value contains URI encoding patterns
|
|
83
|
+
return typeof value === "string" && value.includes("%")
|
|
84
|
+
? decodeURIComponent(value)
|
|
85
|
+
: value;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
// In case of any errors, return the original value
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
};
|