@salesforcedevs/docs-components 0.56.2-comp-flex-ref-1 → 0.56.2-example
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 +10 -2
- package/package.json +18 -12
- package/src/modules/doc/{amfReference/utils.ts → amfModelParser/amfModelParser.ts} +10 -5
- package/src/modules/doc/amfReference/amfReference.css +23 -3
- package/src/modules/doc/amfReference/amfReference.html +34 -21
- package/src/modules/doc/amfReference/amfReference.ts +386 -102
- package/src/modules/doc/amfReference/types.ts +5 -12
- package/src/modules/doc/amfTopic/amfTopic.css +20 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +35 -18
- package/src/modules/doc/amfTopic/types.ts +15 -13
- package/src/modules/doc/amfTopic/utils.ts +12 -6
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +2 -1
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +1 -1
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +22 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +9 -1
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +44 -34
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +62 -23
- package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +42 -0
- package/src/modules/doc/content/content.css +70 -76
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +26 -47
- package/src/modules/doc/contentCallout/contentCallout.css +15 -7
- package/src/modules/doc/contentCallout/contentCallout.html +13 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +14 -2
- package/src/modules/doc/contentLayout/contentLayout.css +1 -100
- package/src/modules/doc/contentLayout/contentLayout.html +30 -17
- package/src/modules/doc/contentLayout/contentLayout.ts +315 -70
- package/src/modules/doc/doDont/doDont.css +47 -0
- package/src/modules/doc/doDont/doDont.html +27 -0
- package/src/modules/doc/doDont/doDont.ts +17 -0
- package/src/modules/doc/header/header.css +65 -36
- package/src/modules/doc/header/header.html +41 -139
- package/src/modules/doc/header/header.ts +54 -76
- package/src/modules/doc/heading/heading.css +16 -37
- package/src/modules/doc/heading/heading.html +4 -4
- package/src/modules/doc/heading/heading.ts +12 -10
- package/src/modules/doc/headingAnchor/headingAnchor.css +2 -2
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- package/src/modules/doc/headingContent/headingContent.css +6 -8
- package/src/modules/doc/headingContent/headingContent.html +9 -15
- package/src/modules/doc/headingContent/headingContent.ts +2 -14
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +256 -0
- package/src/modules/doc/overview/overview.css +40 -0
- package/src/modules/doc/overview/overview.html +34 -0
- package/src/modules/doc/overview/overview.ts +12 -0
- package/src/modules/doc/phase/phase.css +18 -3
- package/src/modules/doc/phase/phase.html +15 -3
- package/src/modules/doc/phase/phase.ts +44 -8
- package/src/modules/doc/specificationContent/specificationContent.css +36 -0
- package/src/modules/doc/specificationContent/specificationContent.html +167 -0
- package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/toc/toc.ts +1 -1
- package/src/modules/doc/versionPicker/versionPicker.css +64 -0
- package/src/modules/doc/versionPicker/versionPicker.html +38 -0
- package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
- package/src/modules/doc/xmlContent/types.ts +12 -3
- package/src/modules/doc/xmlContent/utils.ts +17 -12
- package/src/modules/doc/xmlContent/xmlContent.css +32 -3
- package/src/modules/doc/xmlContent/xmlContent.html +41 -15
- package/src/modules/doc/xmlContent/xmlContent.ts +310 -96
- package/src/modules/docHelpers/amfStyle/amfStyle.css +10 -45
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
- package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
- package/src/modules/docHelpers/status/status.css +1 -1
- package/src/modules/docUtils/{SearchSyncer/SearchSyncer.ts → searchSyncer/searchSyncer.ts} +1 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +32 -0
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +0 -93
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +0 -39
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Json } from "typings/custom";
|
|
1
|
+
import { Json, DocPhaseInfo } from "typings/custom";
|
|
2
2
|
|
|
3
3
|
export interface AmfTopicType {
|
|
4
4
|
referenceId: string;
|
|
@@ -11,6 +11,7 @@ export interface AmfTopicType {
|
|
|
11
11
|
export interface AmfMetadataTopic extends AmfTopicType {
|
|
12
12
|
meta: string;
|
|
13
13
|
identifier: string;
|
|
14
|
+
navTitle?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface AmfMetaTopicType extends AmfTopicType {
|
|
@@ -20,7 +21,6 @@ export interface AmfMetaTopicType extends AmfTopicType {
|
|
|
20
21
|
export interface NavItem {
|
|
21
22
|
name: string;
|
|
22
23
|
label: string;
|
|
23
|
-
// TODO: Better type here
|
|
24
24
|
children?: ({
|
|
25
25
|
id: string;
|
|
26
26
|
label?: string;
|
|
@@ -46,14 +46,6 @@ export interface AmfModelRecord {
|
|
|
46
46
|
parsedModel: Json;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export type DocPhase = "pilot" | "dev-preview" | "beta";
|
|
50
|
-
|
|
51
|
-
export type DocPhaseEntry = {
|
|
52
|
-
phase: DocPhase;
|
|
53
|
-
title: string;
|
|
54
|
-
body: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
49
|
export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
|
|
58
50
|
|
|
59
51
|
/**
|
|
@@ -67,12 +59,13 @@ export interface ParsedMarkdownTopic {
|
|
|
67
59
|
href: string;
|
|
68
60
|
target?: string;
|
|
69
61
|
};
|
|
62
|
+
isExpanded?: boolean;
|
|
70
63
|
}
|
|
71
64
|
|
|
72
65
|
export interface AmfConfig {
|
|
73
66
|
id: string;
|
|
74
67
|
version?: string;
|
|
75
|
-
docPhase?:
|
|
68
|
+
docPhase?: DocPhaseInfo;
|
|
76
69
|
title: string;
|
|
77
70
|
href: string;
|
|
78
71
|
referenceType: ReferenceType;
|
|
@@ -102,7 +95,7 @@ export interface ParsedTopicModel {
|
|
|
102
95
|
export interface TopicModel {
|
|
103
96
|
id: string;
|
|
104
97
|
type: string;
|
|
105
|
-
amf:
|
|
98
|
+
amf: string;
|
|
106
99
|
parser: AmfParser;
|
|
107
100
|
}
|
|
108
101
|
|
|
@@ -1 +1,21 @@
|
|
|
1
1
|
@import "docHelpers/amfStyle";
|
|
2
|
+
|
|
3
|
+
:host {
|
|
4
|
+
--reference-container-margin-top: var(--dx-g-spacing-sm);
|
|
5
|
+
--api-documentation-margin-top: var(--dx-g-spacing-3xl);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 1. We need to scroll to top from the tablet size as side nav bar and content in side by side from tablet size
|
|
10
|
+
* 2. Consider global nav height, doc header height and content margins to scroll to the right position
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
@media screen and (min-width: 769px) {
|
|
14
|
+
.topic-container {
|
|
15
|
+
scroll-margin-top: calc(
|
|
16
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
17
|
+
var(--reference-container-margin-top) +
|
|
18
|
+
var(--api-documentation-margin-top)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -8,14 +8,17 @@ import {
|
|
|
8
8
|
createTypeElement
|
|
9
9
|
} from "./utils";
|
|
10
10
|
import type { TopicModel } from "./types";
|
|
11
|
+
import { Json } from "typings/custom";
|
|
12
|
+
|
|
13
|
+
const TABLE_SIZE_MATCH = "769px";
|
|
11
14
|
|
|
12
15
|
export default class AmfTopic extends LightningElement {
|
|
13
|
-
private _model;
|
|
14
|
-
private amf;
|
|
15
|
-
private type;
|
|
16
|
+
private _model: TopicModel | undefined;
|
|
17
|
+
private amf: Json;
|
|
18
|
+
private type: string | undefined;
|
|
16
19
|
|
|
17
20
|
@api
|
|
18
|
-
get model(): TopicModel {
|
|
21
|
+
get model(): TopicModel | undefined {
|
|
19
22
|
return this._model;
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -24,13 +27,17 @@ export default class AmfTopic extends LightningElement {
|
|
|
24
27
|
!this.amf ||
|
|
25
28
|
(value && this._model && value.amf !== this._model?.amf)
|
|
26
29
|
) {
|
|
27
|
-
|
|
30
|
+
try {
|
|
31
|
+
this.amf = value && JSON.parse(value.amf);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`Error parsing amf model: ${error}`);
|
|
34
|
+
}
|
|
28
35
|
}
|
|
29
36
|
if (
|
|
30
37
|
!this.type ||
|
|
31
38
|
(value && this._model && value.type !== this._model?.type)
|
|
32
39
|
) {
|
|
33
|
-
this.type = value &&
|
|
40
|
+
this.type = value && value.type;
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
this._model = value;
|
|
@@ -41,7 +48,11 @@ export default class AmfTopic extends LightningElement {
|
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
update(): void {
|
|
44
|
-
|
|
51
|
+
if (!this.model) {
|
|
52
|
+
throw new Error("Amf TopicModel undefined when trying to update");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const container = this.template.querySelector(".topic-container")!;
|
|
45
56
|
const { id } = this.model;
|
|
46
57
|
const type = this.type;
|
|
47
58
|
const amf = this.amf;
|
|
@@ -76,19 +87,25 @@ export default class AmfTopic extends LightningElement {
|
|
|
76
87
|
element = createDocumentationElement(amf, docsModel);
|
|
77
88
|
}
|
|
78
89
|
|
|
79
|
-
if (container
|
|
90
|
+
if (container?.firstChild) {
|
|
80
91
|
container.firstChild.remove();
|
|
81
92
|
}
|
|
82
|
-
container
|
|
93
|
+
container?.appendChild(element as Node);
|
|
94
|
+
|
|
95
|
+
const isTabletOrDesktop = window.matchMedia(
|
|
96
|
+
`(min-width: ${TABLE_SIZE_MATCH})`
|
|
97
|
+
).matches;
|
|
98
|
+
|
|
99
|
+
if (isTabletOrDesktop) {
|
|
100
|
+
window.scrollTo(0, 0);
|
|
101
|
+
}
|
|
83
102
|
}
|
|
84
|
-
}
|
|
85
103
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return JSON.parse(JSON.stringify(value));
|
|
104
|
+
renderedCallback(): void {
|
|
105
|
+
try {
|
|
106
|
+
this.update();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
94
111
|
}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Json } from "typings/custom";
|
|
2
|
+
import { AmfModelParser } from "doc/amfModelParser";
|
|
3
|
+
import {
|
|
4
|
+
DomainElement,
|
|
5
|
+
EndPoint,
|
|
6
|
+
Operation,
|
|
7
|
+
Shape
|
|
8
|
+
} from "@api-components/amf-helper-mixin";
|
|
2
9
|
|
|
3
10
|
export type ApiSummaryElement = HTMLElement & {
|
|
4
11
|
amf: Json;
|
|
@@ -11,44 +18,39 @@ export type ApiEndpointElement = HTMLElement & {
|
|
|
11
18
|
inlineMethods: boolean;
|
|
12
19
|
noNavigation: boolean;
|
|
13
20
|
selected: string;
|
|
14
|
-
endpoint:
|
|
21
|
+
endpoint: EndPoint;
|
|
15
22
|
noTryIt: boolean;
|
|
16
23
|
};
|
|
17
24
|
|
|
18
25
|
export type ApiMethodElement = HTMLElement & {
|
|
19
26
|
amf: Json;
|
|
20
27
|
noNavigation: boolean;
|
|
21
|
-
endpoint:
|
|
22
|
-
method:
|
|
28
|
+
endpoint: EndPoint | undefined;
|
|
29
|
+
method: Operation | undefined;
|
|
23
30
|
noTryIt: boolean;
|
|
24
31
|
};
|
|
25
32
|
|
|
26
33
|
export type ApiSecurityElement = HTMLElement & {
|
|
27
34
|
amf: Json;
|
|
28
|
-
security:
|
|
35
|
+
security: DomainElement | undefined;
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
export type ApiTypeElement = HTMLElement & {
|
|
32
39
|
amf: Json;
|
|
33
|
-
type
|
|
40
|
+
type?: Shape;
|
|
34
41
|
mediaTypes: Json;
|
|
35
42
|
};
|
|
36
43
|
|
|
37
44
|
export type ApiDocElement = HTMLElement & {
|
|
38
45
|
amf: Json;
|
|
39
|
-
shape:
|
|
46
|
+
shape: DomainElement | undefined;
|
|
40
47
|
};
|
|
41
48
|
|
|
42
49
|
export type AmfModel = Json;
|
|
43
50
|
|
|
44
|
-
export interface AmfParser {
|
|
45
|
-
parse(): void;
|
|
46
|
-
parsedModel: any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
51
|
export interface TopicModel {
|
|
50
52
|
id: string;
|
|
51
53
|
type: string;
|
|
52
|
-
amf:
|
|
53
|
-
parser:
|
|
54
|
+
amf: string;
|
|
55
|
+
parser: AmfModelParser;
|
|
54
56
|
}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DomainElement,
|
|
3
|
+
EndPoint,
|
|
4
|
+
Operation,
|
|
5
|
+
Shape
|
|
6
|
+
} from "@api-components/amf-helper-mixin";
|
|
1
7
|
import type {
|
|
2
8
|
ApiDocElement,
|
|
3
9
|
ApiEndpointElement,
|
|
@@ -37,7 +43,7 @@ export function createSummaryElement(amf: Json): HTMLElement {
|
|
|
37
43
|
*/
|
|
38
44
|
export function createEndpointElement(
|
|
39
45
|
amf: Json,
|
|
40
|
-
endpointModel:
|
|
46
|
+
endpointModel: EndPoint,
|
|
41
47
|
selected: string
|
|
42
48
|
): HTMLElement {
|
|
43
49
|
const el: ApiEndpointElement = document.createElement(
|
|
@@ -57,8 +63,8 @@ export function createEndpointElement(
|
|
|
57
63
|
*/
|
|
58
64
|
export function createMethodElement(
|
|
59
65
|
amf: Json,
|
|
60
|
-
endpointMethodModel:
|
|
61
|
-
methodModel:
|
|
66
|
+
endpointMethodModel: EndPoint | undefined,
|
|
67
|
+
methodModel: Operation | undefined
|
|
62
68
|
): HTMLElement {
|
|
63
69
|
const el: ApiMethodElement = document.createElement(
|
|
64
70
|
"api-method-documentation"
|
|
@@ -79,7 +85,7 @@ export function createMethodElement(
|
|
|
79
85
|
*/
|
|
80
86
|
export function createSecurityElement(
|
|
81
87
|
amf: Json,
|
|
82
|
-
securityModel:
|
|
88
|
+
securityModel: DomainElement | undefined
|
|
83
89
|
): HTMLElement {
|
|
84
90
|
const el: ApiSecurityElement = document.createElement(
|
|
85
91
|
"api-security-documentation"
|
|
@@ -98,7 +104,7 @@ export function createSecurityElement(
|
|
|
98
104
|
*/
|
|
99
105
|
export function createTypeElement(
|
|
100
106
|
amf: Json,
|
|
101
|
-
typeModel:
|
|
107
|
+
typeModel: Shape | undefined,
|
|
102
108
|
mediaTypes: Json
|
|
103
109
|
): HTMLElement {
|
|
104
110
|
const el: ApiTypeElement = document.createElement(
|
|
@@ -119,7 +125,7 @@ export function createTypeElement(
|
|
|
119
125
|
*/
|
|
120
126
|
export function createDocumentationElement(
|
|
121
127
|
amf: Json,
|
|
122
|
-
docsModel:
|
|
128
|
+
docsModel: DomainElement | undefined
|
|
123
129
|
): HTMLElement {
|
|
124
130
|
const el: ApiDocElement = document.createElement(
|
|
125
131
|
"api-documentation-document"
|
|
@@ -4,12 +4,13 @@
|
|
|
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,3 +1,4 @@
|
|
|
1
|
+
import { track } from "dxUtils/analytics";
|
|
1
2
|
import { LightningElement, api } from "lwc";
|
|
2
3
|
import { BreadcrumbItemVariant } from "typings/custom";
|
|
3
4
|
|
|
@@ -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 level?: string;
|
|
12
|
+
@api breadcrumbLabels?: string;
|
|
10
13
|
|
|
11
14
|
@api
|
|
12
15
|
get label() {
|
|
@@ -46,4 +49,23 @@ 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
|
+
track(event.target!, "custEv_breadcrumbClick", {
|
|
55
|
+
click_text: this.label,
|
|
56
|
+
click_url: `${window.location.origin}${this.href}`,
|
|
57
|
+
element_type: "link",
|
|
58
|
+
nav_type: "breadcrumb",
|
|
59
|
+
nav_level: this.level ? this.level + 1 : 1,
|
|
60
|
+
nav_item: this.breadcrumbLabels
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
track(event.target!, "custEv_linkClick", {
|
|
64
|
+
click_text: this.label,
|
|
65
|
+
click_url: `${window.location.origin}${this.href}`,
|
|
66
|
+
element_title: this.label,
|
|
67
|
+
element_type: "link",
|
|
68
|
+
content_category: "cta"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
49
71
|
}
|
|
@@ -4,12 +4,13 @@
|
|
|
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
|
+
}
|
|
@@ -1,48 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<nav role="navigation" aria-label={ariaLabel}>
|
|
3
|
-
<template if:
|
|
4
|
-
<template if:
|
|
3
|
+
<template if:true={displayCrumbs}>
|
|
4
|
+
<template if:false={renderSmallVariant}>
|
|
5
5
|
<doc-breadcrumb-item
|
|
6
6
|
href={firstCrumb.href}
|
|
7
7
|
label={firstCrumb.label}
|
|
8
|
+
breadcrumb-labels={breadcrumbLabels}
|
|
8
9
|
></doc-breadcrumb-item>
|
|
9
10
|
<span class="breadcrumb-item_slash">/</span>
|
|
11
|
+
<template if:true={renderDropdown}>
|
|
12
|
+
<dx-dropdown
|
|
13
|
+
analytics-event="custEv_breadcrumbClick"
|
|
14
|
+
analytics-payload={ANALYTICS_PAYLOAD}
|
|
15
|
+
if:true={renderDropdown}
|
|
16
|
+
options={dropdownOptions}
|
|
17
|
+
open-on-hover
|
|
18
|
+
placement="bottom"
|
|
19
|
+
variant="indented"
|
|
20
|
+
width="fit-content"
|
|
21
|
+
>
|
|
22
|
+
<dx-button
|
|
23
|
+
aria-label="Open Breadcrumbs Dropdown"
|
|
24
|
+
icon-size="large"
|
|
25
|
+
icon-symbol="threedots"
|
|
26
|
+
variant="tertiary"
|
|
27
|
+
></dx-button>
|
|
28
|
+
</dx-dropdown>
|
|
29
|
+
<span class="breadcrumb-item_slash">/</span>
|
|
30
|
+
</template>
|
|
31
|
+
<template for:each={breadcrumbItems} for:item="breadcrumb">
|
|
32
|
+
<doc-breadcrumb-item
|
|
33
|
+
href={breadcrumb.href}
|
|
34
|
+
key={breadcrumb.id}
|
|
35
|
+
label={breadcrumb.label}
|
|
36
|
+
level={breadcrumb.level}
|
|
37
|
+
breadcrumb-labels={breadcrumbLabels}
|
|
38
|
+
></doc-breadcrumb-item>
|
|
39
|
+
<span class="breadcrumb-item_slash" key={breadcrumb.label}>
|
|
40
|
+
/
|
|
41
|
+
</span>
|
|
42
|
+
</template>
|
|
43
|
+
<doc-breadcrumb-item
|
|
44
|
+
label={lastCrumb.label}
|
|
45
|
+
breadcrumb-labels={breadcrumbLabels}
|
|
46
|
+
></doc-breadcrumb-item>
|
|
10
47
|
</template>
|
|
11
|
-
<template if:true={
|
|
12
|
-
<dx-dropdown
|
|
13
|
-
if:true={renderDropdown}
|
|
14
|
-
options={dropdownOptions}
|
|
15
|
-
open-on-hover
|
|
16
|
-
placement="bottom"
|
|
17
|
-
width="200px"
|
|
18
|
-
>
|
|
19
|
-
<dx-button
|
|
20
|
-
aria-label="Open Breadcrumbs Dropdown"
|
|
21
|
-
icon-size="large"
|
|
22
|
-
icon-symbol="threedots"
|
|
23
|
-
variant="tertiary"
|
|
24
|
-
></dx-button>
|
|
25
|
-
</dx-dropdown>
|
|
26
|
-
<span class="breadcrumb-item_slash">/</span>
|
|
27
|
-
</template>
|
|
28
|
-
<template for:each={breadcrumbItems} for:item="breadcrumb">
|
|
48
|
+
<template if:true={renderSmallVariant}>
|
|
29
49
|
<doc-breadcrumb-item
|
|
30
|
-
href={
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
href={lastLinkCrump.href}
|
|
51
|
+
label={lastLinkCrump.label}
|
|
52
|
+
breadcrumb-labels={breadcrumbLabels}
|
|
53
|
+
variant="back-arrow"
|
|
33
54
|
></doc-breadcrumb-item>
|
|
34
|
-
<span class="breadcrumb-item_slash" key={breadcrumb.label}>
|
|
35
|
-
/
|
|
36
|
-
</span>
|
|
37
55
|
</template>
|
|
38
|
-
<doc-breadcrumb-item label={lastCrumb.label}></doc-breadcrumb-item>
|
|
39
|
-
</template>
|
|
40
|
-
<template if:true={renderSmallVariant}>
|
|
41
|
-
<doc-breadcrumb-item
|
|
42
|
-
href={lastLinkCrump.href}
|
|
43
|
-
label={lastLinkCrump.label}
|
|
44
|
-
variant="back-arrow"
|
|
45
|
-
></doc-breadcrumb-item>
|
|
46
56
|
</template>
|
|
47
57
|
</nav>
|
|
48
58
|
</template>
|
|
@@ -8,10 +8,12 @@ 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
|
|
|
@@ -22,19 +24,30 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
22
24
|
get breadcrumbs(): Breadcrumb[] {
|
|
23
25
|
return this._breadcrumbs;
|
|
24
26
|
}
|
|
27
|
+
|
|
25
28
|
set breadcrumbs(value) {
|
|
26
|
-
this.
|
|
29
|
+
this.normalizeAndAssignBreadcrumbs(value);
|
|
27
30
|
this.calculateBreadcrumbsConfigs();
|
|
28
|
-
if (this.
|
|
29
|
-
this.
|
|
31
|
+
if (this.isRendered) {
|
|
32
|
+
this.onWidthOrContentChange();
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
|
|
36
|
+
@api
|
|
37
|
+
get pixelPerCharacter(): number {
|
|
38
|
+
return this._pixelPerCharacter;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
set pixelPerCharacter(value: number | string) {
|
|
42
|
+
this._pixelPerCharacter = +value;
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
private _breadcrumbs: Breadcrumb[] = [];
|
|
46
|
+
private _pixelPerCharacter = CONSTANTS.pixelPerCharacter;
|
|
34
47
|
private navWidth = 0;
|
|
35
|
-
private observer: ResizeObserver | null = null;
|
|
36
48
|
private breadcrumbConfigs: BreadcrumbConfig[] = [];
|
|
37
49
|
private dropdownOptionAmount? = 0;
|
|
50
|
+
private isRendered = false;
|
|
38
51
|
|
|
39
52
|
private get renderSmallVariant(): boolean {
|
|
40
53
|
return (
|
|
@@ -65,14 +78,14 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
65
78
|
private get dropdownOptions(): OptionWithLink[] {
|
|
66
79
|
return this.breadcrumbs!.slice(1, this.dropdownOptionAmount! + 1).map(
|
|
67
80
|
(link) => ({
|
|
68
|
-
id: link.
|
|
81
|
+
id: link.id!,
|
|
69
82
|
label: link.label,
|
|
70
83
|
link: { href: link.href! }
|
|
71
84
|
})
|
|
72
85
|
);
|
|
73
86
|
}
|
|
74
87
|
|
|
75
|
-
private get
|
|
88
|
+
private get displayCrumbs(): boolean {
|
|
76
89
|
return this.breadcrumbs.length > 1;
|
|
77
90
|
}
|
|
78
91
|
|
|
@@ -80,27 +93,52 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
80
93
|
return this.breadcrumbs[0];
|
|
81
94
|
}
|
|
82
95
|
|
|
96
|
+
private get breadcrumbLabels(): string {
|
|
97
|
+
return this.breadcrumbs.map((crumb) => crumb.label).join(":");
|
|
98
|
+
}
|
|
99
|
+
|
|
83
100
|
private get lastCrumb(): Breadcrumb {
|
|
84
101
|
return this.breadcrumbs[this.breadcrumbs.length - 1];
|
|
85
102
|
}
|
|
86
103
|
|
|
104
|
+
// this payload is only used for breadcrumb dropdown
|
|
105
|
+
private get ANALYTICS_PAYLOAD() {
|
|
106
|
+
return {
|
|
107
|
+
element_type: "link",
|
|
108
|
+
nav_type: "breadcrumb",
|
|
109
|
+
nav_level: 1
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private onWidthOrContentChange = () => {
|
|
114
|
+
this.navWidth = this.template
|
|
115
|
+
.querySelector("nav")!
|
|
116
|
+
.getBoundingClientRect().width;
|
|
117
|
+
this.updateDropdownOptionAmount();
|
|
118
|
+
};
|
|
119
|
+
|
|
87
120
|
renderedCallback(): void {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (this.navWidth === nav.contentRect.width) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.navWidth = nav.contentRect.width;
|
|
95
|
-
this.updateDropdownOptionAmount();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
this.observer.observe(this.template.querySelector("nav")!);
|
|
99
|
-
}
|
|
121
|
+
this.isRendered = true;
|
|
122
|
+
this.onWidthOrContentChange();
|
|
123
|
+
window.addEventListener("resize", this.onWidthOrContentChange);
|
|
100
124
|
}
|
|
101
125
|
|
|
102
126
|
disconnectedCallback(): void {
|
|
103
|
-
this.
|
|
127
|
+
window.removeEventListener("resize", this.onWidthOrContentChange);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private normalizeAndAssignBreadcrumbs(breadcrumbs?: Breadcrumb[] | string) {
|
|
131
|
+
if (!breadcrumbs) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._breadcrumbs = toJson(breadcrumbs).map(
|
|
136
|
+
(crumb: Breadcrumb, index: number) => ({
|
|
137
|
+
...crumb,
|
|
138
|
+
id: crumb.id || crumb.href,
|
|
139
|
+
level: index
|
|
140
|
+
})
|
|
141
|
+
);
|
|
104
142
|
}
|
|
105
143
|
|
|
106
144
|
private updateDropdownOptionAmount(): void {
|
|
@@ -135,7 +173,8 @@ export default class Breadcrumbs extends LightningElement {
|
|
|
135
173
|
(previousValue, element) =>
|
|
136
174
|
previousValue +
|
|
137
175
|
Math.min(
|
|
138
|
-
element.label.length *
|
|
176
|
+
element.label.length *
|
|
177
|
+
(this.pixelPerCharacter || CONSTANTS.pixelPerCharacter),
|
|
139
178
|
CONSTANTS.minWidthPerCrumb
|
|
140
179
|
),
|
|
141
180
|
(breadcrumbs.length - 1) * CONSTANTS.pixelPerCrumbSpace + offset
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Designs link - https://www.figma.com/design/9SalRPlJmtRDZHq03o8dL1/One-Doc-Site-Visionary-Mocks?node-id=9968-366397&m=dev
|
|
5
|
+
* Preview padding: 24px
|
|
6
|
+
* Example Selector height: 122px
|
|
7
|
+
* Example Preview min height: 150px
|
|
8
|
+
* Tab height with border: 46px(45px height and 1px border)
|
|
9
|
+
* Codeblock height: 264px(224px for codeblock and 40px for panel)
|
|
10
|
+
* Total: 606px
|
|
11
|
+
**/
|
|
12
|
+
|
|
13
|
+
iframe {
|
|
14
|
+
width: 100%;
|
|
15
|
+
height: 606px;
|
|
16
|
+
border-radius: var(--dx-g-spacing-sm);
|
|
17
|
+
border: 1px solid var(--dx-g-gray-90);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.playground-container {
|
|
21
|
+
position: relative;
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="playground-container" lwc:if={playgroundAvailable}>
|
|
3
|
+
<dx-spinner
|
|
4
|
+
size="large"
|
|
5
|
+
variant="brand"
|
|
6
|
+
if:true={isLoading}
|
|
7
|
+
></dx-spinner>
|
|
8
|
+
<iframe
|
|
9
|
+
src={playgroundSrc}
|
|
10
|
+
onload={handleIframeLoad}
|
|
11
|
+
title={playgroundTitle}
|
|
12
|
+
allow="clipboard-write"
|
|
13
|
+
></iframe>
|
|
14
|
+
</div>
|
|
15
|
+
<dx-error-fallback
|
|
16
|
+
lwc:else
|
|
17
|
+
title="Code Examples Unavailable"
|
|
18
|
+
description="This component's code examples are currently unavailable. Please check again later."
|
|
19
|
+
></dx-error-fallback>
|
|
20
|
+
</template>
|