@salesforcedevs/dx-components 1.3.241 → 1.3.242-alpha2
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 +2 -3
- package/src/assets/icons/salesforcebrand-sprite/svg/symbols.svg +2 -2
- package/src/modules/dx/codeBlock/codeBlock.html +1 -1
- package/src/modules/dx/codeBlock/codeBlock.ts +60 -6
- package/src/modules/dxBaseElements/headerBase/headerBase.ts +1 -1
- package/src/modules/dxConstants/brands/brands.ts +1 -1
- package/LICENSE +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.242-alpha2",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -43,6 +43,5 @@
|
|
|
43
43
|
},
|
|
44
44
|
"volta": {
|
|
45
45
|
"node": "16.19.1"
|
|
46
|
-
}
|
|
47
|
-
"gitHead": "ba302a7ca83b2a7dbbcdb3b7dcb8a34b50ccf7e2"
|
|
46
|
+
}
|
|
48
47
|
}
|
|
@@ -272,7 +272,7 @@
|
|
|
272
272
|
</g>
|
|
273
273
|
</g>
|
|
274
274
|
</symbol>
|
|
275
|
-
<symbol id="data
|
|
275
|
+
<symbol id="data" viewBox="0 0 56 56" xmlns="http://www.w3.org/2000/svg" style="fill:#fff">
|
|
276
276
|
<defs>
|
|
277
277
|
<style>.acls-2,.acls-4{stroke-width:0}.acls-2{fill:#8a8ed1}.acls-4{fill:#fff}</style>
|
|
278
278
|
</defs>
|
|
@@ -927,7 +927,7 @@
|
|
|
927
927
|
</clipPath>
|
|
928
928
|
</defs>
|
|
929
929
|
</symbol>
|
|
930
|
-
<symbol fill="none" id="data
|
|
930
|
+
<symbol fill="none" id="data" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 56 56">
|
|
931
931
|
<path fill="#8a8ed1" d="m28,4C14.77,4,4,14.77,4,28c0,7.9,3.84,14.93,9.76,19.3.7-4.58,3.55-8.46,7.5-10.56-2.61-2.02-4.29-5.17-4.29-8.71,0-6.08,4.95-11.03,11.03-11.03s11.03,4.95,11.03,11.03c0,3.54-1.69,6.69-4.29,8.71,3.95,2.1,6.8,5.98,7.5,10.56,5.92-4.37,9.77-11.4,9.77-19.31,0-13.23-10.77-24-24-24Z"/>
|
|
932
932
|
<path fill="#8a8ed1" d="m11.07,18.3c.69-1.2,2.21-1.61,3.41-.92,1.2.68,1.61,2.21.93,3.41h0c-.46.81-1.3,1.26-2.17,1.26-.42,0-.85-.11-1.24-.34-1.2-.68-1.61-2.21-.92-3.41Z"/>
|
|
933
933
|
<path fill="#8a8ed1" d="m8.49,28.06c0-1.38,1.11-2.5,2.49-2.51,1.38,0,2.51,1.11,2.51,2.5s-1.11,2.5-2.49,2.5h-.01c-1.38,0-2.5-1.11-2.5-2.49Z"/>
|
|
@@ -44,11 +44,12 @@ export default class CodeBlock extends LightningElement {
|
|
|
44
44
|
@api language: string = "";
|
|
45
45
|
// if it is true, it renders code as is coming instead of wrapping it into html/xml comments tags.
|
|
46
46
|
@api isEncoded = false;
|
|
47
|
+
@api showLanguageDropdown!: boolean;
|
|
48
|
+
private codeWithLanguages: { id: string; value: string }[] = [];
|
|
47
49
|
|
|
48
50
|
private markupLangs = ["visualforce", "html", "xml"];
|
|
49
51
|
private _codeBlockRendered: boolean = false;
|
|
50
52
|
private componentLoaded: boolean = false;
|
|
51
|
-
private showLanguageDropdown: boolean = false;
|
|
52
53
|
private copyBtnText: string = "Click to copy";
|
|
53
54
|
private selectedLanguageLabel: string = "";
|
|
54
55
|
private selectedLanguageId: string = "";
|
|
@@ -98,17 +99,62 @@ export default class CodeBlock extends LightningElement {
|
|
|
98
99
|
set codeBlock(value: string) {
|
|
99
100
|
this._codeBlockRendered = false;
|
|
100
101
|
let match;
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
if (this.showLanguageDropdown) {
|
|
103
|
+
let selectedLangBasedCode = "";
|
|
104
|
+
try {
|
|
105
|
+
const parsedValue = value && JSON.parse(value);
|
|
106
|
+
this.codeWithLanguages = parsedValue;
|
|
107
|
+
if (typeof parsedValue === "object" && parsedValue !== null) {
|
|
108
|
+
this.selectedLanguageId = this.language;
|
|
109
|
+
if (this.selectedLanguageId) {
|
|
110
|
+
const selectedCode = this.codeWithLanguages.filter(
|
|
111
|
+
(obj) => obj.id === this.selectedLanguageId
|
|
112
|
+
);
|
|
113
|
+
if (selectedCode.length > 0) {
|
|
114
|
+
selectedLangBasedCode = selectedCode[0].value;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const supportedLanguages = parsedValue.map(
|
|
118
|
+
(obj: { id: string }) => obj.id
|
|
119
|
+
);
|
|
120
|
+
this._supportedLanguages = this.allLanguages.filter(
|
|
121
|
+
(lang) => supportedLanguages.includes(lang.id)
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
//console.log('Value is not a valid JSON string:', value);
|
|
126
|
+
}
|
|
127
|
+
this._codeBlock = (
|
|
128
|
+
(match = preTagRegexp.exec(selectedLangBasedCode.trim())) ===
|
|
129
|
+
null
|
|
130
|
+
? selectedLangBasedCode.trim()
|
|
131
|
+
: match[1]
|
|
132
|
+
).trim();
|
|
133
|
+
} else {
|
|
134
|
+
this._codeBlock = (
|
|
135
|
+
(match = preTagRegexp.exec(value.trim())) === null
|
|
136
|
+
? value.trim()
|
|
137
|
+
: match[1]
|
|
138
|
+
).trim();
|
|
139
|
+
}
|
|
106
140
|
}
|
|
107
141
|
|
|
108
142
|
get codeBlock(): string {
|
|
109
143
|
return this._codeBlock;
|
|
110
144
|
}
|
|
111
145
|
|
|
146
|
+
_supportedLanguages: CodeBlockLanguage[] = [];
|
|
147
|
+
@api
|
|
148
|
+
get supportedLanguages(): CodeBlockLanguage[] {
|
|
149
|
+
return this._supportedLanguages;
|
|
150
|
+
}
|
|
151
|
+
set supportedLanguages(value: string) {
|
|
152
|
+
const codeblockSupportedLanguages = JSON.parse(value);
|
|
153
|
+
this._supportedLanguages = this.allLanguages.filter((lang) =>
|
|
154
|
+
codeblockSupportedLanguages.includes(lang.id)
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
112
158
|
@track private theme: CodeBlockTheme | null = null;
|
|
113
159
|
|
|
114
160
|
@wire(getLocalStorageData, { key: "dx-codeblock-theme" })
|
|
@@ -223,6 +269,14 @@ export default class CodeBlock extends LightningElement {
|
|
|
223
269
|
) || this.allLanguages[0];
|
|
224
270
|
this.selectedLanguageLabel = this.selectedLanguage.label;
|
|
225
271
|
this.selectedLanguageId = this.selectedLanguage.id;
|
|
272
|
+
if (this.showLanguageDropdown) {
|
|
273
|
+
const selectedCode = this.codeWithLanguages.filter(
|
|
274
|
+
(codeObj) => codeObj.id === this.selectedLanguageId
|
|
275
|
+
);
|
|
276
|
+
if (selectedCode.length > 0) {
|
|
277
|
+
this._codeBlock = selectedCode[0].value;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
226
280
|
this.formatCodeBlock();
|
|
227
281
|
|
|
228
282
|
gtmTrack(newLang, "custEv_ctaLinkClick", {
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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.
|