@salesforcedevs/dx-components 1.28.6-alpha.1 → 1.28.7-alpha.0
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.ts +6 -6
- package/src/modules/dx/sidebar/sidebar.html +0 -1
- package/src/modules/dx/sidebar/sidebar.ts +0 -1
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +0 -22
- package/src/modules/dx/socials/socials.css +36 -0
- package/src/modules/dx/socials/socials.html +22 -0
- package/src/modules/dx/socials/socials.ts +76 -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.28.
|
|
3
|
+
"version": "1.28.7-alpha.0",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"luxon": "3.4.4",
|
|
45
45
|
"msw": "^2.12.4"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "fd19dde09113f8458a649b7f5e27fac4db3d2bb5"
|
|
48
48
|
}
|
|
@@ -34,6 +34,7 @@ export default class CodeBlock extends LightningElement {
|
|
|
34
34
|
private _codeBlockRendered: boolean = false;
|
|
35
35
|
private _showLoadingIndicator: boolean = false;
|
|
36
36
|
private _isCbHeightCalculated: boolean = false;
|
|
37
|
+
private _plainCodeForCopy: string = "";
|
|
37
38
|
private markupLangs = ["visualforce", "html", "xml"];
|
|
38
39
|
private componentLoaded: boolean = false;
|
|
39
40
|
private showLanguageDropdown: boolean = false;
|
|
@@ -290,6 +291,9 @@ export default class CodeBlock extends LightningElement {
|
|
|
290
291
|
);
|
|
291
292
|
}
|
|
292
293
|
}
|
|
294
|
+
// Get the plain code for copy functionality
|
|
295
|
+
const codeElement = this.template.querySelector("code");
|
|
296
|
+
this._plainCodeForCopy = codeElement?.textContent?.trim() ?? "";
|
|
293
297
|
// Add line numbers to each line
|
|
294
298
|
this.addLineNumbers();
|
|
295
299
|
}
|
|
@@ -328,12 +332,8 @@ export default class CodeBlock extends LightningElement {
|
|
|
328
332
|
});
|
|
329
333
|
|
|
330
334
|
try {
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
if (snippetContainer && snippetContainer.textContent) {
|
|
334
|
-
await navigator.clipboard.writeText(
|
|
335
|
-
snippetContainer.textContent
|
|
336
|
-
);
|
|
335
|
+
if (this._plainCodeForCopy) {
|
|
336
|
+
await navigator.clipboard.writeText(this._plainCodeForCopy);
|
|
337
337
|
this.copyBtnText = "Copied!";
|
|
338
338
|
setTimeout(() => {
|
|
339
339
|
this.copyBtnText = "Click to copy";
|
|
@@ -15,10 +15,6 @@ const UserRecentSearches = new RecentSearches();
|
|
|
15
15
|
const getSearchQueryParam = (): string =>
|
|
16
16
|
new URLSearchParams(window.location.search).get("q") ?? "";
|
|
17
17
|
|
|
18
|
-
/** Data Cloud Search API base URL derived from current origin */
|
|
19
|
-
const getDataCloudSearchBaseUrl = (): string =>
|
|
20
|
-
`${window.location.origin}${DATA_CLOUD_SEARCH_PATH}`;
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* Returns the current page base URL without the last path segment.
|
|
24
20
|
* e.g. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm
|
|
@@ -38,8 +34,6 @@ interface DataCloudSearchResultItem {
|
|
|
38
34
|
}
|
|
39
35
|
|
|
40
36
|
export default class SidebarSearch extends LightningElement {
|
|
41
|
-
@api enableDataCloudSearch: boolean | string = false;
|
|
42
|
-
|
|
43
37
|
@api
|
|
44
38
|
public fetchMoreResults() {
|
|
45
39
|
// Data Cloud Search API does not expose pagination in the same way; no-op
|
|
@@ -78,23 +72,7 @@ export default class SidebarSearch extends LightningElement {
|
|
|
78
72
|
this.value = getSearchQueryParam();
|
|
79
73
|
}
|
|
80
74
|
|
|
81
|
-
private get isDataCloudSearchEnabled(): boolean {
|
|
82
|
-
return (
|
|
83
|
-
this.enableDataCloudSearch === true ||
|
|
84
|
-
this.enableDataCloudSearch === "true"
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private get searchApiBaseUrl(): string | null {
|
|
89
|
-
return this.isDataCloudSearchEnabled
|
|
90
|
-
? getDataCloudSearchBaseUrl()
|
|
91
|
-
: null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
75
|
renderedCallback() {
|
|
95
|
-
if (!this.isDataCloudSearchEnabled) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
76
|
if (!this.dataCloudSearchInitialized) {
|
|
99
77
|
this.dataCloudSearchInitialized = true;
|
|
100
78
|
if (!this.didRender && this.value) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.details-section {
|
|
6
|
+
color: var(--dx-g-text-label-color);
|
|
7
|
+
font-family: var(--dx-g-font-display);
|
|
8
|
+
font-size: var(--dx-g-text-xs);
|
|
9
|
+
letter-spacing: 0.7px;
|
|
10
|
+
margin-bottom: var(--dx-g-spacing-sm);
|
|
11
|
+
text-transform: uppercase;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.details-section span {
|
|
15
|
+
display: block;
|
|
16
|
+
line-height: var(--dx-g-spacing-md);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.socials-group {
|
|
20
|
+
display: flex;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.socials-group a:not(:last-child) {
|
|
24
|
+
margin-right: var(--dx-g-spacing-md);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
dx-icon-badge {
|
|
28
|
+
--dx-c-icon-badge-background-color: var(--dx-g-social-svg-background-color);
|
|
29
|
+
--dx-c-icon-badge-color: var(--dx-g-social-svg-icon-color);
|
|
30
|
+
--dx-c-icon-badge-size: 34px;
|
|
31
|
+
--dx-c-icon-badge-icon-size: 18px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
dx-icon-badge:hover {
|
|
35
|
+
--dx-c-icon-badge-background-color: var(--dx-g-social-svg-hover-color);
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="details-section" if:true={hasDetails}>
|
|
3
|
+
<template for:each={details} for:item="detail">
|
|
4
|
+
<span key={detail}>{detail}</span>
|
|
5
|
+
</template>
|
|
6
|
+
</div>
|
|
7
|
+
<div class="socials-group">
|
|
8
|
+
<template for:each={socials} for:item="social">
|
|
9
|
+
<a
|
|
10
|
+
href={social.href}
|
|
11
|
+
key={social.name}
|
|
12
|
+
target={linksTarget}
|
|
13
|
+
title={social.name}
|
|
14
|
+
>
|
|
15
|
+
<dx-icon-badge
|
|
16
|
+
sprite={spriteName}
|
|
17
|
+
symbol={social.symbol}
|
|
18
|
+
></dx-icon-badge>
|
|
19
|
+
</a>
|
|
20
|
+
</template>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { normalizeToArray } from "dxUtils/normalizers";
|
|
3
|
+
|
|
4
|
+
type Icon = { name: string; symbol: string; baseShareUrl: string };
|
|
5
|
+
|
|
6
|
+
const URL_TOKEN = "{url}";
|
|
7
|
+
const TEXT_TOKEN = "{text}";
|
|
8
|
+
|
|
9
|
+
const SOCIAL_ICONS: Array<Icon> = [
|
|
10
|
+
{
|
|
11
|
+
name: "Twitter",
|
|
12
|
+
symbol: "twitter",
|
|
13
|
+
baseShareUrl: `https://twitter.com/intent/tweet?url=${URL_TOKEN}&text=${TEXT_TOKEN}`
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "Linkedin",
|
|
17
|
+
symbol: "linkedin-in",
|
|
18
|
+
baseShareUrl: `http://www.linkedin.com/sharing/share-offsite/?url=${URL_TOKEN}`
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const SPRITE_NAME = "brand";
|
|
23
|
+
|
|
24
|
+
const VALID_TARGETS = ["_self", "_blank", "_parent", "_top", "framename"];
|
|
25
|
+
|
|
26
|
+
export default class Socials extends LightningElement {
|
|
27
|
+
private _linksTarget: string = "_blank";
|
|
28
|
+
private _details: Array<string> = [];
|
|
29
|
+
|
|
30
|
+
@api
|
|
31
|
+
get details() {
|
|
32
|
+
return this._details;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
set details(value) {
|
|
36
|
+
this._details = normalizeToArray(value, "|") as Array<string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@api
|
|
40
|
+
get linksTarget(): string {
|
|
41
|
+
return this._linksTarget;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
set linksTarget(value: string) {
|
|
45
|
+
if (value && !VALID_TARGETS.includes(value)) {
|
|
46
|
+
console.error(
|
|
47
|
+
`Invalid links target, valid options are: ${VALID_TARGETS.join(
|
|
48
|
+
", "
|
|
49
|
+
)}`
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this._linksTarget = value;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
get socials() {
|
|
57
|
+
const url = encodeURIComponent(document.location.href);
|
|
58
|
+
const text = encodeURIComponent(document.title);
|
|
59
|
+
return SOCIAL_ICONS.map(({ baseShareUrl, ...value }: Icon) => {
|
|
60
|
+
return {
|
|
61
|
+
...value,
|
|
62
|
+
href: baseShareUrl
|
|
63
|
+
.replace(URL_TOKEN, url)
|
|
64
|
+
.replace(TEXT_TOKEN, text)
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get spriteName() {
|
|
70
|
+
return SPRITE_NAME;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
get hasDetails() {
|
|
74
|
+
return this.details && this.details.length > 0;
|
|
75
|
+
}
|
|
76
|
+
}
|