@salesforcedevs/docs-components 0.54.0 → 0.54.1-a01
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 +6 -2
- package/package.json +12 -4
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfReference/amfReference.css +5 -0
- package/src/modules/doc/amfReference/amfReference.html +47 -0
- package/src/modules/doc/amfReference/amfReference.ts +1309 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +133 -0
- package/src/modules/doc/amfReference/utils.ts +669 -0
- package/src/modules/doc/amfTopic/amfTopic.css +1 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
- package/src/modules/doc/amfTopic/types.ts +54 -0
- package/src/modules/doc/amfTopic/utils.ts +130 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +4 -3
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +1 -1
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +17 -1
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +11 -3
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +12 -2
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +50 -9
- package/src/modules/doc/content/content.css +35 -11
- package/src/modules/doc/content/content.ts +18 -3
- package/src/modules/doc/contentCallout/contentCallout.css +4 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +5 -0
- package/src/modules/doc/contentLayout/contentLayout.css +98 -0
- package/src/modules/doc/contentLayout/contentLayout.html +48 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +287 -0
- package/src/modules/doc/header/header.css +1 -1
- package/src/modules/doc/header/header.ts +5 -5
- package/src/modules/doc/headingAnchor/headingAnchor.css +1 -1
- package/src/modules/doc/headingContent/headingContent.css +5 -1
- package/src/modules/doc/phase/phase.css +3 -3
- package/src/modules/doc/phase/phase.ts +1 -1
- package/src/modules/doc/xmlContent/types.ts +114 -0
- package/src/modules/doc/xmlContent/utils.ts +161 -0
- package/src/modules/doc/xmlContent/xmlContent.css +32 -0
- package/src/modules/doc/xmlContent/xmlContent.html +39 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +651 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +390 -0
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
- package/src/modules/{helpers → docHelpers}/status/status.css +0 -0
- package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
- package/LICENSE +0 -12
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import {
|
|
3
|
+
createDocumentationElement,
|
|
4
|
+
createEndpointElement,
|
|
5
|
+
createMethodElement,
|
|
6
|
+
createSecurityElement,
|
|
7
|
+
createSummaryElement,
|
|
8
|
+
createTypeElement
|
|
9
|
+
} from "./utils";
|
|
10
|
+
import type { TopicModel } from "./types";
|
|
11
|
+
|
|
12
|
+
export default class AmfTopic extends LightningElement {
|
|
13
|
+
private _model;
|
|
14
|
+
private amf;
|
|
15
|
+
private type;
|
|
16
|
+
|
|
17
|
+
@api
|
|
18
|
+
get model(): TopicModel {
|
|
19
|
+
return this._model;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
set model(value: TopicModel) {
|
|
23
|
+
if (
|
|
24
|
+
!this.amf ||
|
|
25
|
+
(value && this._model && value.amf !== this._model?.amf)
|
|
26
|
+
) {
|
|
27
|
+
this.amf = value && clone(value.amf);
|
|
28
|
+
}
|
|
29
|
+
if (
|
|
30
|
+
!this.type ||
|
|
31
|
+
(value && this._model && value.type !== this._model?.type)
|
|
32
|
+
) {
|
|
33
|
+
this.type = value && clone(value.type);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this._model = value;
|
|
37
|
+
if (this._model) {
|
|
38
|
+
this.update();
|
|
39
|
+
}
|
|
40
|
+
// else { Remove child? No model, seems like no component should be shown. }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update(): void {
|
|
44
|
+
const container = this.template.querySelector("div.topic-container");
|
|
45
|
+
const { id } = this.model;
|
|
46
|
+
const type = this.type;
|
|
47
|
+
const amf = this.amf;
|
|
48
|
+
const { parser } = this.model;
|
|
49
|
+
let element;
|
|
50
|
+
|
|
51
|
+
if (type === "summary") {
|
|
52
|
+
element = createSummaryElement(amf);
|
|
53
|
+
} else if (type === "endpoint") {
|
|
54
|
+
const endpointModel = parser.computeEndpointApiModel(amf, id);
|
|
55
|
+
element = createEndpointElement(amf, endpointModel, id);
|
|
56
|
+
} else if (type === "method") {
|
|
57
|
+
const endpointMethodModel = parser.computeEndpointApiMethodModel(
|
|
58
|
+
amf,
|
|
59
|
+
id
|
|
60
|
+
);
|
|
61
|
+
const methodModel = parser.computeMethodApiModel(amf, id);
|
|
62
|
+
element = createMethodElement(
|
|
63
|
+
amf,
|
|
64
|
+
endpointMethodModel,
|
|
65
|
+
methodModel
|
|
66
|
+
);
|
|
67
|
+
} else if (type === "security") {
|
|
68
|
+
const securityModel = parser.computeSecurityApiModel(amf, id);
|
|
69
|
+
element = createSecurityElement(amf, securityModel);
|
|
70
|
+
} else if (type === "type") {
|
|
71
|
+
const mediaTypes = parser.computeApiMediaTypes(amf);
|
|
72
|
+
const typeModel = parser.computeTypeApiModel(amf, id);
|
|
73
|
+
element = createTypeElement(amf, typeModel, mediaTypes);
|
|
74
|
+
} else if (type === "documentation") {
|
|
75
|
+
const docsModel = parser.computeDocsApiModel(amf, id);
|
|
76
|
+
element = createDocumentationElement(amf, docsModel);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (container.firstChild) {
|
|
80
|
+
container.firstChild.remove();
|
|
81
|
+
}
|
|
82
|
+
container.appendChild(element);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The underlying web components we use from api-console mutate their models we pass in.
|
|
88
|
+
* Since LWC makes them Read Only, we need to copy them before passing to the Web Component.
|
|
89
|
+
* @param value JSON Serializable object to clone.
|
|
90
|
+
* @returns A copy of Value. One that has been serialized and parsed via JSON. (Functions, Regex, etc are not preserved.)
|
|
91
|
+
*/
|
|
92
|
+
function clone(value): object {
|
|
93
|
+
return JSON.parse(JSON.stringify(value));
|
|
94
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Json } from "typings/custom";
|
|
2
|
+
|
|
3
|
+
export type ApiSummaryElement = HTMLElement & {
|
|
4
|
+
amf: Json;
|
|
5
|
+
hideToc: boolean;
|
|
6
|
+
titleLevel: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type ApiEndpointElement = HTMLElement & {
|
|
10
|
+
amf: Json;
|
|
11
|
+
inlineMethods: boolean;
|
|
12
|
+
noNavigation: boolean;
|
|
13
|
+
selected: string;
|
|
14
|
+
endpoint: Json;
|
|
15
|
+
noTryIt: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type ApiMethodElement = HTMLElement & {
|
|
19
|
+
amf: Json;
|
|
20
|
+
noNavigation: boolean;
|
|
21
|
+
endpoint: Json;
|
|
22
|
+
method: Json;
|
|
23
|
+
noTryIt: boolean;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ApiSecurityElement = HTMLElement & {
|
|
27
|
+
amf: Json;
|
|
28
|
+
security: Json;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type ApiTypeElement = HTMLElement & {
|
|
32
|
+
amf: Json;
|
|
33
|
+
type: Json;
|
|
34
|
+
mediaTypes: Json;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type ApiDocElement = HTMLElement & {
|
|
38
|
+
amf: Json;
|
|
39
|
+
shape: Json;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export type AmfModel = Json;
|
|
43
|
+
|
|
44
|
+
export interface AmfParser {
|
|
45
|
+
parse(): void;
|
|
46
|
+
parsedModel: any;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface TopicModel {
|
|
50
|
+
id: string;
|
|
51
|
+
type: string;
|
|
52
|
+
amf: AmfModel;
|
|
53
|
+
parser: AmfParser;
|
|
54
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ApiDocElement,
|
|
3
|
+
ApiEndpointElement,
|
|
4
|
+
ApiMethodElement,
|
|
5
|
+
ApiSecurityElement,
|
|
6
|
+
ApiSummaryElement,
|
|
7
|
+
ApiTypeElement
|
|
8
|
+
} from "./types";
|
|
9
|
+
import { Json } from "typings/custom";
|
|
10
|
+
|
|
11
|
+
export function createSummaryElement(amf: Json): HTMLElement {
|
|
12
|
+
const summaryElement: ApiSummaryElement = document.createElement(
|
|
13
|
+
"api-summary"
|
|
14
|
+
) as ApiSummaryElement;
|
|
15
|
+
summaryElement.amf = amf;
|
|
16
|
+
summaryElement.hideToc = true;
|
|
17
|
+
summaryElement.titleLevel = "1";
|
|
18
|
+
summaryElement.setAttribute(
|
|
19
|
+
"exportparts",
|
|
20
|
+
[
|
|
21
|
+
"api-title",
|
|
22
|
+
"api-title-label",
|
|
23
|
+
"api-version",
|
|
24
|
+
"marked-description",
|
|
25
|
+
"info-section",
|
|
26
|
+
"info-inline-desc",
|
|
27
|
+
"license-section",
|
|
28
|
+
"separator",
|
|
29
|
+
"toc"
|
|
30
|
+
].join(",")
|
|
31
|
+
);
|
|
32
|
+
return summaryElement;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a `api-endpoint-documentation` web element from web API and current selection.
|
|
37
|
+
*/
|
|
38
|
+
export function createEndpointElement(
|
|
39
|
+
amf: Json,
|
|
40
|
+
endpointModel: Json,
|
|
41
|
+
selected: string
|
|
42
|
+
): HTMLElement {
|
|
43
|
+
const el: ApiEndpointElement = document.createElement(
|
|
44
|
+
"api-endpoint-documentation"
|
|
45
|
+
) as ApiEndpointElement;
|
|
46
|
+
el.amf = amf;
|
|
47
|
+
el.inlineMethods = false;
|
|
48
|
+
el.noNavigation = true;
|
|
49
|
+
el.selected = selected;
|
|
50
|
+
el.endpoint = endpointModel;
|
|
51
|
+
el.noTryIt = true;
|
|
52
|
+
return el;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Creates a `api-method-documentation` web element from web API and current selection.
|
|
57
|
+
*/
|
|
58
|
+
export function createMethodElement(
|
|
59
|
+
amf: Json,
|
|
60
|
+
endpointMethodModel: Json,
|
|
61
|
+
methodModel: Json
|
|
62
|
+
): HTMLElement {
|
|
63
|
+
const el: ApiMethodElement = document.createElement(
|
|
64
|
+
"api-method-documentation"
|
|
65
|
+
) as ApiMethodElement;
|
|
66
|
+
el.amf = amf;
|
|
67
|
+
el.noNavigation = true;
|
|
68
|
+
el.endpoint = endpointMethodModel;
|
|
69
|
+
el.method = methodModel;
|
|
70
|
+
el.noTryIt = true;
|
|
71
|
+
el.setAttribute("renderSecurity", "");
|
|
72
|
+
el.setAttribute("renderCodeSnippets", "");
|
|
73
|
+
return el;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Creates a documentation element for Security AMF type
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
export function createSecurityElement(
|
|
81
|
+
amf: Json,
|
|
82
|
+
securityModel: Json
|
|
83
|
+
): HTMLElement {
|
|
84
|
+
const el: ApiSecurityElement = document.createElement(
|
|
85
|
+
"api-security-documentation"
|
|
86
|
+
) as ApiSecurityElement;
|
|
87
|
+
el.setAttribute("exportparts", ["security-title"].join(","));
|
|
88
|
+
el.amf = amf;
|
|
89
|
+
el.security = securityModel;
|
|
90
|
+
return el;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Creates a documentation element for Type AMF type
|
|
95
|
+
*
|
|
96
|
+
* @param {string} amfId Reference ID as passed in from amfConfig
|
|
97
|
+
* @param {string} selected Currently selected `@id`.
|
|
98
|
+
*/
|
|
99
|
+
export function createTypeElement(
|
|
100
|
+
amf: Json,
|
|
101
|
+
typeModel: Json,
|
|
102
|
+
mediaTypes: Json
|
|
103
|
+
): HTMLElement {
|
|
104
|
+
const el: ApiTypeElement = document.createElement(
|
|
105
|
+
"api-type-documentation"
|
|
106
|
+
) as ApiTypeElement;
|
|
107
|
+
el.setAttribute("exportparts", ["type-title"].join(","));
|
|
108
|
+
el.amf = amf;
|
|
109
|
+
el.type = typeModel;
|
|
110
|
+
el.mediaTypes = mediaTypes;
|
|
111
|
+
return el;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Creates a documentation element for Docs AMF type
|
|
116
|
+
*
|
|
117
|
+
* @param {string} amfId Reference ID as passed in from amfConfig
|
|
118
|
+
* @param {string} selected Currently selected `@id`.
|
|
119
|
+
*/
|
|
120
|
+
export function createDocumentationElement(
|
|
121
|
+
amf: Json,
|
|
122
|
+
docsModel: Json
|
|
123
|
+
): HTMLElement {
|
|
124
|
+
const el: ApiDocElement = document.createElement(
|
|
125
|
+
"api-documentation-document"
|
|
126
|
+
) as ApiDocElement;
|
|
127
|
+
el.amf = amf;
|
|
128
|
+
el.shape = docsModel;
|
|
129
|
+
return el;
|
|
130
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
@import "
|
|
2
|
-
@import "
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
3
|
|
|
4
4
|
:host {
|
|
5
5
|
display: flex;
|
|
6
6
|
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
7
8
|
width: fit-content;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
:host(.breadcrumb_long) {
|
|
11
12
|
/* ensure 30 character min-width */
|
|
12
|
-
min-width:
|
|
13
|
+
min-width: 200px;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
:host(.breadcrumb_back-arrow) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { track } from "dxUtils/analytics";
|
|
1
2
|
import { LightningElement, api } from "lwc";
|
|
2
|
-
import { BreadcrumbItemVariant } from "typings/custom";
|
|
3
|
+
import { AnalyticsPayload, BreadcrumbItemVariant } from "typings/custom";
|
|
3
4
|
|
|
4
5
|
const BREADCRUMB_LONG = "breadcrumb_long";
|
|
5
6
|
const BREADCRUMB_BACK_ARROW = "breadcrumb_back-arrow";
|
|
@@ -7,6 +8,8 @@ const BREADCRUMB_BACK_ARROW = "breadcrumb_back-arrow";
|
|
|
7
8
|
const LONG_LABEL_NUMBER = 30;
|
|
8
9
|
export default class BreadcrumbItem extends LightningElement {
|
|
9
10
|
@api href?: string;
|
|
11
|
+
@api analyticsEvent!: string;
|
|
12
|
+
@api analyticsBasePayload!: AnalyticsPayload;
|
|
10
13
|
|
|
11
14
|
@api
|
|
12
15
|
get label() {
|
|
@@ -46,4 +49,17 @@ export default class BreadcrumbItem extends LightningElement {
|
|
|
46
49
|
private get isBackArrowVariant(): boolean {
|
|
47
50
|
return this._variant === "back-arrow";
|
|
48
51
|
}
|
|
52
|
+
|
|
53
|
+
private onLinkClick(event: Event): void {
|
|
54
|
+
if (!this.analyticsEvent) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
track(event.target!, this.analyticsEvent, {
|
|
59
|
+
...this.analyticsBasePayload,
|
|
60
|
+
clickText: this.label,
|
|
61
|
+
itemTitle: this.label,
|
|
62
|
+
pageLocation: window.location.pathname
|
|
63
|
+
});
|
|
64
|
+
}
|
|
49
65
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
@import "
|
|
2
|
-
@import "
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
3
|
|
|
4
4
|
:host {
|
|
5
5
|
--dx-c-breadcrumbs-title-color: var(--dx-g-blue-vibrant-20);
|
|
6
6
|
--dx-c-breadcrumbs-breadcrumb-color: var(--dx-g-blue-vibrant-20);
|
|
7
|
+
|
|
8
|
+
font-family: var(--dx-g-font-sans);
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
nav {
|
|
10
12
|
display: flex;
|
|
11
13
|
align-items: center;
|
|
12
|
-
height: 100%;
|
|
13
14
|
position: relative;
|
|
14
15
|
gap: var(--dx-g-spacing-sm);
|
|
15
16
|
}
|
|
@@ -17,3 +18,10 @@ nav {
|
|
|
17
18
|
.breadcrumb-item_slash {
|
|
18
19
|
min-width: fit-content;
|
|
19
20
|
}
|
|
21
|
+
|
|
22
|
+
dx-dropdown {
|
|
23
|
+
--dx-c-dropdown-option-font-size: var(--dx-g-text-sm);
|
|
24
|
+
--dx-c-dropdown-option-label-color: var(
|
|
25
|
+
--dx-c-breadcrumbs-breadcrumb-color
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
<template if:false={renderSmallVariant}>
|
|
4
4
|
<template if:true={renderFirstCrumb}>
|
|
5
5
|
<doc-breadcrumb-item
|
|
6
|
+
analytics-event={analyticsEventName}
|
|
7
|
+
analytics-base-payload={analyticsBasePayload}
|
|
6
8
|
href={firstCrumb.href}
|
|
7
9
|
label={firstCrumb.label}
|
|
8
10
|
></doc-breadcrumb-item>
|
|
@@ -11,10 +13,14 @@
|
|
|
11
13
|
<template if:true={renderDropdown}>
|
|
12
14
|
<dx-dropdown
|
|
13
15
|
if:true={renderDropdown}
|
|
16
|
+
analytics-event={analyticsEventName}
|
|
17
|
+
analytics-base-payload={analyticsBasePayload}
|
|
14
18
|
options={dropdownOptions}
|
|
15
19
|
open-on-hover
|
|
16
20
|
placement="bottom"
|
|
17
|
-
|
|
21
|
+
suppress-gtm-nav-headings
|
|
22
|
+
variant="indented"
|
|
23
|
+
width="fit-content"
|
|
18
24
|
>
|
|
19
25
|
<dx-button
|
|
20
26
|
aria-label="Open Breadcrumbs Dropdown"
|
|
@@ -27,8 +33,10 @@
|
|
|
27
33
|
</template>
|
|
28
34
|
<template for:each={breadcrumbItems} for:item="breadcrumb">
|
|
29
35
|
<doc-breadcrumb-item
|
|
36
|
+
analytics-event={analyticsEventName}
|
|
37
|
+
analytics-base-payload={analyticsBasePayload}
|
|
30
38
|
href={breadcrumb.href}
|
|
31
|
-
key={breadcrumb.
|
|
39
|
+
key={breadcrumb.id}
|
|
32
40
|
label={breadcrumb.label}
|
|
33
41
|
></doc-breadcrumb-item>
|
|
34
42
|
<span class="breadcrumb-item_slash" key={breadcrumb.label}>
|
|
@@ -39,6 +47,8 @@
|
|
|
39
47
|
</template>
|
|
40
48
|
<template if:true={renderSmallVariant}>
|
|
41
49
|
<doc-breadcrumb-item
|
|
50
|
+
analytics-event={analyticsEventName}
|
|
51
|
+
analytics-base-payload={analyticsBasePayload}
|
|
42
52
|
href={lastLinkCrump.href}
|
|
43
53
|
label={lastLinkCrump.label}
|
|
44
54
|
variant="back-arrow"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
|
-
import { Breadcrumb,
|
|
3
|
-
import { toJson } from "
|
|
2
|
+
import { Breadcrumb, OptionWithLink } from "typings/custom";
|
|
3
|
+
import { toJson } from "dxUtils/normalizers";
|
|
4
4
|
|
|
5
5
|
type BreadcrumbConfig = {
|
|
6
6
|
minWidth: number;
|
|
@@ -8,13 +8,23 @@ type BreadcrumbConfig = {
|
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
const GAP = 8;
|
|
11
|
+
|
|
12
|
+
// Unit in pixels based on Salesforce Sans font-family.
|
|
11
13
|
const CONSTANTS = {
|
|
12
|
-
pixelPerCharacter: 7.
|
|
13
|
-
pixelPerCrumbSpace: GAP * 2 +
|
|
14
|
-
minWidthPerCrumb:
|
|
14
|
+
pixelPerCharacter: 7.7,
|
|
15
|
+
pixelPerCrumbSpace: GAP * 2 + 8.6,
|
|
16
|
+
minWidthPerCrumb: 200,
|
|
15
17
|
dropdownWidth: 32
|
|
16
18
|
};
|
|
17
19
|
|
|
20
|
+
export const ANALYTICS_EVENT_NAME = "custEv_breadcrumbClick";
|
|
21
|
+
export const ANALYTICS_BASE_PAYLOAD = {
|
|
22
|
+
elementType: "breadcrumb",
|
|
23
|
+
locationOnPage: "breadcrumb",
|
|
24
|
+
ctaClick: true,
|
|
25
|
+
pageLocation: window.location.pathname
|
|
26
|
+
};
|
|
27
|
+
|
|
18
28
|
export default class Breadcrumbs extends LightningElement {
|
|
19
29
|
@api ariaLabel: string = "Documentation Breadcrumbs";
|
|
20
30
|
|
|
@@ -22,15 +32,26 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
22
32
|
get breadcrumbs(): Breadcrumb[] {
|
|
23
33
|
return this._breadcrumbs;
|
|
24
34
|
}
|
|
35
|
+
|
|
25
36
|
set breadcrumbs(value) {
|
|
26
|
-
this.
|
|
37
|
+
this.normalizeAndAssignBreadcrumbs(value);
|
|
27
38
|
this.calculateBreadcrumbsConfigs();
|
|
28
39
|
if (this.observer) {
|
|
29
40
|
this.updateDropdownOptionAmount();
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
|
|
44
|
+
@api
|
|
45
|
+
get pixelPerCharacter(): number {
|
|
46
|
+
return this._pixelPerCharacter;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set pixelPerCharacter(value: number | string) {
|
|
50
|
+
this._pixelPerCharacter = +value;
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
private _breadcrumbs: Breadcrumb[] = [];
|
|
54
|
+
private _pixelPerCharacter = CONSTANTS.pixelPerCharacter;
|
|
34
55
|
private navWidth = 0;
|
|
35
56
|
private observer: ResizeObserver | null = null;
|
|
36
57
|
private breadcrumbConfigs: BreadcrumbConfig[] = [];
|
|
@@ -62,10 +83,10 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
62
83
|
private get renderDropdown(): boolean {
|
|
63
84
|
return this.hasInternalBreadcrumbs && !!this.dropdownOptionAmount;
|
|
64
85
|
}
|
|
65
|
-
private get dropdownOptions():
|
|
86
|
+
private get dropdownOptions(): OptionWithLink[] {
|
|
66
87
|
return this.breadcrumbs!.slice(1, this.dropdownOptionAmount! + 1).map(
|
|
67
88
|
(link) => ({
|
|
68
|
-
id: link.
|
|
89
|
+
id: link.id!,
|
|
69
90
|
label: link.label,
|
|
70
91
|
link: { href: link.href! }
|
|
71
92
|
})
|
|
@@ -84,6 +105,14 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
84
105
|
return this.breadcrumbs[this.breadcrumbs.length - 1];
|
|
85
106
|
}
|
|
86
107
|
|
|
108
|
+
private get analyticsEventName() {
|
|
109
|
+
return ANALYTICS_EVENT_NAME;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private get analyticsBasePayload() {
|
|
113
|
+
return ANALYTICS_BASE_PAYLOAD;
|
|
114
|
+
}
|
|
115
|
+
|
|
87
116
|
renderedCallback(): void {
|
|
88
117
|
if (!this.observer) {
|
|
89
118
|
this.observer = new ResizeObserver((entries) => {
|
|
@@ -103,6 +132,17 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
103
132
|
this.observer?.disconnect();
|
|
104
133
|
}
|
|
105
134
|
|
|
135
|
+
private normalizeAndAssignBreadcrumbs(breadcrumbs?: Breadcrumb[] | string) {
|
|
136
|
+
if (!breadcrumbs) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
this._breadcrumbs = toJson(breadcrumbs).map((crumb: Breadcrumb) => ({
|
|
141
|
+
...crumb,
|
|
142
|
+
id: crumb.id || crumb.href
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
|
|
106
146
|
private updateDropdownOptionAmount(): void {
|
|
107
147
|
this.dropdownOptionAmount = this.breadcrumbConfigs.find(
|
|
108
148
|
({ minWidth }) => minWidth <= this.navWidth
|
|
@@ -135,7 +175,8 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
135
175
|
(previousValue, element) =>
|
|
136
176
|
previousValue +
|
|
137
177
|
Math.min(
|
|
138
|
-
element.label.length *
|
|
178
|
+
element.label.length *
|
|
179
|
+
(this.pixelPerCharacter || CONSTANTS.pixelPerCharacter),
|
|
139
180
|
CONSTANTS.minWidthPerCrumb
|
|
140
181
|
),
|
|
141
182
|
(breadcrumbs.length - 1) * CONSTANTS.pixelPerCrumbSpace + offset
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* pattern validation cannot be applied
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
@import "
|
|
8
|
-
@import "
|
|
9
|
-
@import "
|
|
10
|
-
@import "
|
|
7
|
+
@import "dxHelpers/text";
|
|
8
|
+
@import "dxHelpers/reset";
|
|
9
|
+
@import "dxHelpers/card";
|
|
10
|
+
@import "dxHelpers/table";
|
|
11
11
|
|
|
12
12
|
.doc-content {
|
|
13
13
|
width: 100%;
|
|
@@ -66,31 +66,47 @@ td > img.content-image:first-child:last-child[alt="No"] {
|
|
|
66
66
|
|
|
67
67
|
h1 {
|
|
68
68
|
font-family: var(--dx-g-font-display);
|
|
69
|
-
font-size:
|
|
69
|
+
font-size: var(--dx-g-text-4xl);
|
|
70
70
|
|
|
71
71
|
/* not registered */
|
|
72
72
|
color: var(--dx-g-blue-vibrant-20);
|
|
73
73
|
letter-spacing: -0.4px;
|
|
74
|
-
line-height:
|
|
74
|
+
line-height: 56px;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
h2 {
|
|
78
78
|
font-family: var(--dx-g-font-display);
|
|
79
|
-
font-size: var(--dx-g-text-
|
|
79
|
+
font-size: var(--dx-g-text-3xl);
|
|
80
80
|
color: var(--dx-g-blue-vibrant-20);
|
|
81
81
|
letter-spacing: -0.1px;
|
|
82
|
-
line-height: var(--dx-g-spacing-
|
|
82
|
+
line-height: var(--dx-g-spacing-3xl);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
h3 {
|
|
86
86
|
font-family: var(--dx-g-font-display);
|
|
87
|
-
font-size:
|
|
87
|
+
font-size: 32px;
|
|
88
88
|
color: var(--dx-g-blue-vibrant-20);
|
|
89
89
|
letter-spacing: -0.1px;
|
|
90
|
-
line-height: var(--dx-g-spacing-
|
|
90
|
+
line-height: var(--dx-g-spacing-2xl);
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
h4 {
|
|
94
|
+
font-family: var(--dx-g-font-display);
|
|
95
|
+
font-size: var(--dx-g-text-xl);
|
|
96
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
97
|
+
letter-spacing: 0;
|
|
98
|
+
line-height: var(--dx-g-spacing-xl);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
h5 {
|
|
102
|
+
font-family: var(--dx-g-font-display);
|
|
103
|
+
font-size: var(--dx-g-text-lg);
|
|
104
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
105
|
+
letter-spacing: 0;
|
|
106
|
+
line-height: 28px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
h6 {
|
|
94
110
|
font-family: var(--dx-g-font-display);
|
|
95
111
|
font-size: var(--dx-g-text-base);
|
|
96
112
|
color: var(--dx-g-blue-vibrant-20);
|
|
@@ -116,6 +132,12 @@ p,
|
|
|
116
132
|
margin-bottom: var(--dx-g-spacing-md);
|
|
117
133
|
}
|
|
118
134
|
|
|
135
|
+
dd > p,
|
|
136
|
+
dd > .p {
|
|
137
|
+
margin-top: 0;
|
|
138
|
+
margin-bottom: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
119
141
|
.li {
|
|
120
142
|
font-family: var(--dx-g-font-sans);
|
|
121
143
|
font-size: var(--dx-g-text-base);
|
|
@@ -175,7 +197,8 @@ a,
|
|
|
175
197
|
margin-right: var(--dx-g-spacing-lg);
|
|
176
198
|
}
|
|
177
199
|
|
|
178
|
-
.codeph
|
|
200
|
+
.codeph,
|
|
201
|
+
.filepath {
|
|
179
202
|
font-family: var(--dx-g-font-mono);
|
|
180
203
|
font-size: var(--dx-g-text-sm);
|
|
181
204
|
line-height: var(--dx-g-text-lg);
|
|
@@ -239,6 +262,7 @@ dd {
|
|
|
239
262
|
letter-spacing: 0;
|
|
240
263
|
line-height: var(--dx-g-spacing-lg);
|
|
241
264
|
margin-left: var(--dx-g-spacing-smd);
|
|
265
|
+
margin-bottom: var(--dx-g-spacing-md);
|
|
242
266
|
}
|
|
243
267
|
|
|
244
268
|
li {
|
|
@@ -5,7 +5,7 @@ import ContentCallout from "doc/contentCallout";
|
|
|
5
5
|
import CodeBlock from "dx/codeBlock";
|
|
6
6
|
import ContentMedia from "doc/contentMedia";
|
|
7
7
|
import Button from "dx/button";
|
|
8
|
-
import { highlightTerms } from "
|
|
8
|
+
import { highlightTerms } from "dxUtils/highlight";
|
|
9
9
|
|
|
10
10
|
const HIGHLIGHTABLE_SELECTOR = [
|
|
11
11
|
"p",
|
|
@@ -150,11 +150,26 @@ export default class Content extends LightningElement {
|
|
|
150
150
|
is: ContentCallout
|
|
151
151
|
});
|
|
152
152
|
const detailEls = calloutEl.querySelectorAll(
|
|
153
|
-
"p, div.data, ol, ul,
|
|
153
|
+
"p, div.data, ol, ul, p+.codeSection, .mediaBd > span.ph"
|
|
154
154
|
);
|
|
155
155
|
detailEls.forEach((detailEl) => {
|
|
156
|
-
|
|
156
|
+
if (detailEl.innerHTML.trim() !== "") {
|
|
157
|
+
calloutCompEl.appendChild(detailEl);
|
|
158
|
+
}
|
|
157
159
|
});
|
|
160
|
+
|
|
161
|
+
let flag = 1;
|
|
162
|
+
for (let i = 0; i < detailEls.length; i++) {
|
|
163
|
+
flag &= detailEls[i].innerHTML.trim() === "";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (flag) {
|
|
167
|
+
const codeEls = calloutEl.querySelectorAll(".codeSection");
|
|
168
|
+
codeEls.forEach((codeEl) => {
|
|
169
|
+
calloutCompEl.appendChild(codeEl);
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
158
173
|
const type = calloutEl.querySelector("h4").textContent;
|
|
159
174
|
const typeLower = type.toLowerCase();
|
|
160
175
|
Object.assign(calloutCompEl, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
@import "
|
|
2
|
-
@import "
|
|
3
|
-
@import "
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
@import "docHelpers/status";
|
|
4
4
|
|
|
5
5
|
.dx-callout {
|
|
6
6
|
border-radius: 4px;
|
|
@@ -48,4 +48,4 @@
|
|
|
48
48
|
|
|
49
49
|
.dx-callout-base_column > dx-type-badge-group {
|
|
50
50
|
margin-bottom: var(--dx-g-spacing-sm);
|
|
51
|
-
}
|
|
51
|
+
}
|