@salesforcedevs/docs-components 0.17.0 → 0.17.12-search-alpha
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 +18 -3
- package/package.json +18 -7
- package/src/modules/README.md +41 -0
- package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
- package/src/modules/doc/amfReference/amfReference.css +25 -0
- package/src/modules/doc/amfReference/amfReference.html +55 -0
- package/src/modules/doc/amfReference/amfReference.ts +1467 -0
- package/src/modules/doc/amfReference/constants.ts +76 -0
- package/src/modules/doc/amfReference/types.ts +125 -0
- package/src/modules/doc/amfTopic/amfTopic.css +21 -0
- package/src/modules/doc/amfTopic/amfTopic.html +3 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
- package/src/modules/doc/amfTopic/types.ts +56 -0
- package/src/modules/doc/amfTopic/utils.ts +136 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
- 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 +89 -70
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +188 -195
- package/src/modules/doc/contentCallout/contentCallout.css +17 -23
- package/src/modules/doc/contentCallout/contentCallout.html +13 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +16 -3
- package/src/modules/doc/contentLayout/contentLayout.css +1 -0
- package/src/modules/doc/contentLayout/contentLayout.html +46 -0
- package/src/modules/doc/contentLayout/contentLayout.ts +524 -0
- 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 +70 -37
- package/src/modules/doc/header/header.html +41 -138
- package/src/modules/doc/header/header.ts +56 -78
- package/src/modules/doc/heading/heading.css +33 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +67 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +3 -3
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- package/src/modules/doc/headingContent/headingContent.css +53 -0
- package/src/modules/doc/headingContent/headingContent.html +13 -0
- package/src/modules/doc/headingContent/headingContent.ts +30 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +45 -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 +70 -0
- package/src/modules/doc/phase/phase.html +38 -0
- package/src/modules/doc/phase/phase.ts +93 -0
- 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 +120 -0
- package/src/modules/doc/xmlContent/utils.ts +163 -0
- package/src/modules/doc/xmlContent/xmlContent.css +54 -0
- package/src/modules/doc/xmlContent/xmlContent.html +54 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +763 -0
- package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
- 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 +22 -0
- package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -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/LICENSE +0 -12
- package/src/modules/doc/content/__tests__/content.test.ts +0 -312
- package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -348
- package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/content/__tests__/mockSidebar.ts +0 -81
- package/src/modules/doc/content/content.stories.ts +0 -148
- package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
- package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
- package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
- package/src/modules/doc/contentMedia/__tests__/contentMedia.test.ts +0 -97
- package/src/modules/doc/contentMedia/contentMedia.stories.ts +0 -113
- package/src/modules/doc/header/__tests__/coveoConfig.ts +0 -12
- package/src/modules/doc/header/__tests__/header.test.ts +0 -445
- package/src/modules/doc/header/__tests__/mockNavDevelopers.ts +0 -427
- package/src/modules/doc/header/__tests__/mockNavs.ts +0 -115
- package/src/modules/doc/header/__tests__/mockProps.ts +0 -152
- package/src/modules/doc/header/header.stories.ts +0 -190
- package/src/modules/doc/headingAnchor/__tests__/headingAnchor.test.ts +0 -111
- package/src/modules/doc/headingAnchor/headingAnchor.stories.ts +0 -33
- package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/nav/__tests__/nav.test.ts +0 -58
- package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
- package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
- package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
- package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
- package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
- package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
- package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const NAVIGATION_ITEMS = [
|
|
2
|
+
{
|
|
3
|
+
label: "Summary",
|
|
4
|
+
name: "summary",
|
|
5
|
+
childrenPropertyName: undefined,
|
|
6
|
+
type: "summary"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: "Endpoints",
|
|
10
|
+
name: "endpoints",
|
|
11
|
+
childrenPropertyName: "endpoints",
|
|
12
|
+
type: "endpoint"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Documentation",
|
|
16
|
+
name: "documentation",
|
|
17
|
+
childrenPropertyName: "docs",
|
|
18
|
+
type: "documentation"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "Types",
|
|
22
|
+
name: "types",
|
|
23
|
+
childrenPropertyName: "types",
|
|
24
|
+
type: "type"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: "Security",
|
|
28
|
+
name: "security",
|
|
29
|
+
childrenPropertyName: "security",
|
|
30
|
+
type: "security"
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const URL_CONFIG = {
|
|
35
|
+
summary: {
|
|
36
|
+
urlIdentifer: "label"
|
|
37
|
+
},
|
|
38
|
+
endpoint: {
|
|
39
|
+
urlIdentifer: "path"
|
|
40
|
+
},
|
|
41
|
+
method: {
|
|
42
|
+
urlIdentifer: "label"
|
|
43
|
+
},
|
|
44
|
+
documentation: {
|
|
45
|
+
urlIdentifer: "label"
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
urlIdentifer: "label",
|
|
49
|
+
prefix: "type:"
|
|
50
|
+
},
|
|
51
|
+
security: {
|
|
52
|
+
urlIdentifer: "label",
|
|
53
|
+
prefix: "security:"
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const REFERENCE_TYPES = {
|
|
58
|
+
markdown: "markdown",
|
|
59
|
+
raml: "rest-raml",
|
|
60
|
+
oa2: "rest-oa2",
|
|
61
|
+
oa3: "rest-oa3"
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const oldReferenceIdNewReferenceIdMap: Record<string, string> = {
|
|
65
|
+
"commerce-api-assignments": "assignments",
|
|
66
|
+
"commerce-api-campaigns": "campaigns",
|
|
67
|
+
"commerce-api-catalogs": "catalogs",
|
|
68
|
+
"cdn-zones": "cdn-api-process-apis",
|
|
69
|
+
"inventory-impex": "impex",
|
|
70
|
+
"inventory-reservations": "inventory-reservation-service",
|
|
71
|
+
"shopper-login-and-api-access-service": "shopper-login",
|
|
72
|
+
"shopper-login-and-api-access-service-admin": "slas-admin",
|
|
73
|
+
"einstein-recommendations": "einstein-api-quick-start-guide"
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { NAVIGATION_ITEMS, URL_CONFIG, oldReferenceIdNewReferenceIdMap };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Json, DocPhaseInfo } from "typings/custom";
|
|
2
|
+
|
|
3
|
+
export interface AmfTopicType {
|
|
4
|
+
referenceId: string;
|
|
5
|
+
parentReferencePath: string;
|
|
6
|
+
amfId: string;
|
|
7
|
+
elementId: string;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AmfMetadataTopic extends AmfTopicType {
|
|
12
|
+
meta: string;
|
|
13
|
+
identifier: string;
|
|
14
|
+
navTitle?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface AmfMetaTopicType extends AmfTopicType {
|
|
18
|
+
meta: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface NavItem {
|
|
22
|
+
name: string;
|
|
23
|
+
label: string;
|
|
24
|
+
children?: ({
|
|
25
|
+
id: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
method: string;
|
|
28
|
+
domId: string;
|
|
29
|
+
} & {
|
|
30
|
+
name: string;
|
|
31
|
+
label: string;
|
|
32
|
+
})[];
|
|
33
|
+
isExpanded?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type AmfModel = Json;
|
|
37
|
+
|
|
38
|
+
export interface AmfParser {
|
|
39
|
+
parse(): void;
|
|
40
|
+
parsedModel: any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AmfModelRecord {
|
|
44
|
+
model: AmfModel;
|
|
45
|
+
parser: AmfParser;
|
|
46
|
+
parsedModel: Json;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Represents parsed topic for the sidebar.
|
|
53
|
+
*/
|
|
54
|
+
export interface ParsedMarkdownTopic {
|
|
55
|
+
label: string;
|
|
56
|
+
name: string;
|
|
57
|
+
children: ParsedMarkdownTopic[];
|
|
58
|
+
link?: {
|
|
59
|
+
href: string;
|
|
60
|
+
target?: string;
|
|
61
|
+
};
|
|
62
|
+
isExpanded?: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface AmfConfig {
|
|
66
|
+
id: string;
|
|
67
|
+
version?: string;
|
|
68
|
+
docPhase?: DocPhaseInfo;
|
|
69
|
+
title: string;
|
|
70
|
+
href: string;
|
|
71
|
+
referenceType: ReferenceType;
|
|
72
|
+
|
|
73
|
+
// determines if a reference config is the current active and selected one.
|
|
74
|
+
isSelected: boolean;
|
|
75
|
+
|
|
76
|
+
// required for spec based references
|
|
77
|
+
amf?: string;
|
|
78
|
+
|
|
79
|
+
// required for markdown based references
|
|
80
|
+
topic?: ParsedMarkdownTopic;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ParsedTopicModel {
|
|
84
|
+
id: string;
|
|
85
|
+
label: string;
|
|
86
|
+
domId: string;
|
|
87
|
+
indent?: number;
|
|
88
|
+
methods?: {
|
|
89
|
+
id: string;
|
|
90
|
+
label?: string;
|
|
91
|
+
method: string;
|
|
92
|
+
domId: string;
|
|
93
|
+
}[];
|
|
94
|
+
}
|
|
95
|
+
export interface TopicModel {
|
|
96
|
+
id: string;
|
|
97
|
+
type: string;
|
|
98
|
+
amf: string;
|
|
99
|
+
parser: AmfParser;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ReferenceVersion {
|
|
103
|
+
id: string;
|
|
104
|
+
label: string;
|
|
105
|
+
deprecated?: boolean;
|
|
106
|
+
selected?: boolean;
|
|
107
|
+
link: {
|
|
108
|
+
href: string;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface ReferenceSetConfig {
|
|
113
|
+
refId?: string;
|
|
114
|
+
versionToRefMap?: Map<string, Array<AmfConfig>>;
|
|
115
|
+
refList: Array<AmfConfig>;
|
|
116
|
+
versions: Array<ReferenceVersion>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface RouteMeta {
|
|
120
|
+
meta: string;
|
|
121
|
+
referenceId: string;
|
|
122
|
+
topicId: string;
|
|
123
|
+
//type is only for spec based references
|
|
124
|
+
type?: string;
|
|
125
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
import { Json } from "typings/custom";
|
|
12
|
+
|
|
13
|
+
const TABLE_SIZE_MATCH = "769px";
|
|
14
|
+
|
|
15
|
+
export default class AmfTopic extends LightningElement {
|
|
16
|
+
private _model: TopicModel | undefined;
|
|
17
|
+
private amf: Json;
|
|
18
|
+
private type: string | undefined;
|
|
19
|
+
|
|
20
|
+
@api
|
|
21
|
+
get model(): TopicModel | undefined {
|
|
22
|
+
return this._model;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
set model(value: TopicModel) {
|
|
26
|
+
if (
|
|
27
|
+
!this.amf ||
|
|
28
|
+
(value && this._model && value.amf !== this._model?.amf)
|
|
29
|
+
) {
|
|
30
|
+
try {
|
|
31
|
+
this.amf = value && JSON.parse(value.amf);
|
|
32
|
+
} catch (error) {
|
|
33
|
+
console.error(`Error parsing amf model: ${error}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (
|
|
37
|
+
!this.type ||
|
|
38
|
+
(value && this._model && value.type !== this._model?.type)
|
|
39
|
+
) {
|
|
40
|
+
this.type = value && value.type;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this._model = value;
|
|
44
|
+
if (this._model) {
|
|
45
|
+
this.update();
|
|
46
|
+
}
|
|
47
|
+
// else { Remove child? No model, seems like no component should be shown. }
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
update(): void {
|
|
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")!;
|
|
56
|
+
const { id } = this.model;
|
|
57
|
+
const type = this.type;
|
|
58
|
+
const amf = this.amf;
|
|
59
|
+
const { parser } = this.model;
|
|
60
|
+
let element;
|
|
61
|
+
|
|
62
|
+
if (type === "summary") {
|
|
63
|
+
element = createSummaryElement(amf);
|
|
64
|
+
} else if (type === "endpoint") {
|
|
65
|
+
const endpointModel = parser.computeEndpointApiModel(amf, id);
|
|
66
|
+
element = createEndpointElement(amf, endpointModel, id);
|
|
67
|
+
} else if (type === "method") {
|
|
68
|
+
const endpointMethodModel = parser.computeEndpointApiMethodModel(
|
|
69
|
+
amf,
|
|
70
|
+
id
|
|
71
|
+
);
|
|
72
|
+
const methodModel = parser.computeMethodApiModel(amf, id);
|
|
73
|
+
element = createMethodElement(
|
|
74
|
+
amf,
|
|
75
|
+
endpointMethodModel,
|
|
76
|
+
methodModel
|
|
77
|
+
);
|
|
78
|
+
} else if (type === "security") {
|
|
79
|
+
const securityModel = parser.computeSecurityApiModel(amf, id);
|
|
80
|
+
element = createSecurityElement(amf, securityModel);
|
|
81
|
+
} else if (type === "type") {
|
|
82
|
+
const mediaTypes = parser.computeApiMediaTypes(amf);
|
|
83
|
+
const typeModel = parser.computeTypeApiModel(amf, id);
|
|
84
|
+
element = createTypeElement(amf, typeModel, mediaTypes);
|
|
85
|
+
} else if (type === "documentation") {
|
|
86
|
+
const docsModel = parser.computeDocsApiModel(amf, id);
|
|
87
|
+
element = createDocumentationElement(amf, docsModel);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (container?.firstChild) {
|
|
91
|
+
container.firstChild.remove();
|
|
92
|
+
}
|
|
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
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
renderedCallback(): void {
|
|
105
|
+
try {
|
|
106
|
+
this.update();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
console.error(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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";
|
|
9
|
+
|
|
10
|
+
export type ApiSummaryElement = HTMLElement & {
|
|
11
|
+
amf: Json;
|
|
12
|
+
hideToc: boolean;
|
|
13
|
+
titleLevel: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type ApiEndpointElement = HTMLElement & {
|
|
17
|
+
amf: Json;
|
|
18
|
+
inlineMethods: boolean;
|
|
19
|
+
noNavigation: boolean;
|
|
20
|
+
selected: string;
|
|
21
|
+
endpoint: EndPoint;
|
|
22
|
+
noTryIt: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type ApiMethodElement = HTMLElement & {
|
|
26
|
+
amf: Json;
|
|
27
|
+
noNavigation: boolean;
|
|
28
|
+
endpoint: EndPoint | undefined;
|
|
29
|
+
method: Operation | undefined;
|
|
30
|
+
noTryIt: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ApiSecurityElement = HTMLElement & {
|
|
34
|
+
amf: Json;
|
|
35
|
+
security: DomainElement | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ApiTypeElement = HTMLElement & {
|
|
39
|
+
amf: Json;
|
|
40
|
+
type?: Shape;
|
|
41
|
+
mediaTypes: Json;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type ApiDocElement = HTMLElement & {
|
|
45
|
+
amf: Json;
|
|
46
|
+
shape: DomainElement | undefined;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type AmfModel = Json;
|
|
50
|
+
|
|
51
|
+
export interface TopicModel {
|
|
52
|
+
id: string;
|
|
53
|
+
type: string;
|
|
54
|
+
amf: string;
|
|
55
|
+
parser: AmfModelParser;
|
|
56
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DomainElement,
|
|
3
|
+
EndPoint,
|
|
4
|
+
Operation,
|
|
5
|
+
Shape
|
|
6
|
+
} from "@api-components/amf-helper-mixin";
|
|
7
|
+
import type {
|
|
8
|
+
ApiDocElement,
|
|
9
|
+
ApiEndpointElement,
|
|
10
|
+
ApiMethodElement,
|
|
11
|
+
ApiSecurityElement,
|
|
12
|
+
ApiSummaryElement,
|
|
13
|
+
ApiTypeElement
|
|
14
|
+
} from "./types";
|
|
15
|
+
import { Json } from "typings/custom";
|
|
16
|
+
|
|
17
|
+
export function createSummaryElement(amf: Json): HTMLElement {
|
|
18
|
+
const summaryElement: ApiSummaryElement = document.createElement(
|
|
19
|
+
"api-summary"
|
|
20
|
+
) as ApiSummaryElement;
|
|
21
|
+
summaryElement.amf = amf;
|
|
22
|
+
summaryElement.hideToc = true;
|
|
23
|
+
summaryElement.titleLevel = "1";
|
|
24
|
+
summaryElement.setAttribute(
|
|
25
|
+
"exportparts",
|
|
26
|
+
[
|
|
27
|
+
"api-title",
|
|
28
|
+
"api-title-label",
|
|
29
|
+
"api-version",
|
|
30
|
+
"marked-description",
|
|
31
|
+
"info-section",
|
|
32
|
+
"info-inline-desc",
|
|
33
|
+
"license-section",
|
|
34
|
+
"separator",
|
|
35
|
+
"toc"
|
|
36
|
+
].join(",")
|
|
37
|
+
);
|
|
38
|
+
return summaryElement;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a `api-endpoint-documentation` web element from web API and current selection.
|
|
43
|
+
*/
|
|
44
|
+
export function createEndpointElement(
|
|
45
|
+
amf: Json,
|
|
46
|
+
endpointModel: EndPoint,
|
|
47
|
+
selected: string
|
|
48
|
+
): HTMLElement {
|
|
49
|
+
const el: ApiEndpointElement = document.createElement(
|
|
50
|
+
"api-endpoint-documentation"
|
|
51
|
+
) as ApiEndpointElement;
|
|
52
|
+
el.amf = amf;
|
|
53
|
+
el.inlineMethods = false;
|
|
54
|
+
el.noNavigation = true;
|
|
55
|
+
el.selected = selected;
|
|
56
|
+
el.endpoint = endpointModel;
|
|
57
|
+
el.noTryIt = true;
|
|
58
|
+
return el;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Creates a `api-method-documentation` web element from web API and current selection.
|
|
63
|
+
*/
|
|
64
|
+
export function createMethodElement(
|
|
65
|
+
amf: Json,
|
|
66
|
+
endpointMethodModel: EndPoint | undefined,
|
|
67
|
+
methodModel: Operation | undefined
|
|
68
|
+
): HTMLElement {
|
|
69
|
+
const el: ApiMethodElement = document.createElement(
|
|
70
|
+
"api-method-documentation"
|
|
71
|
+
) as ApiMethodElement;
|
|
72
|
+
el.amf = amf;
|
|
73
|
+
el.noNavigation = true;
|
|
74
|
+
el.endpoint = endpointMethodModel;
|
|
75
|
+
el.method = methodModel;
|
|
76
|
+
el.noTryIt = true;
|
|
77
|
+
el.setAttribute("renderSecurity", "");
|
|
78
|
+
el.setAttribute("renderCodeSnippets", "");
|
|
79
|
+
return el;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Creates a documentation element for Security AMF type
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
export function createSecurityElement(
|
|
87
|
+
amf: Json,
|
|
88
|
+
securityModel: DomainElement | undefined
|
|
89
|
+
): HTMLElement {
|
|
90
|
+
const el: ApiSecurityElement = document.createElement(
|
|
91
|
+
"api-security-documentation"
|
|
92
|
+
) as ApiSecurityElement;
|
|
93
|
+
el.setAttribute("exportparts", ["security-title"].join(","));
|
|
94
|
+
el.amf = amf;
|
|
95
|
+
el.security = securityModel;
|
|
96
|
+
return el;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Creates a documentation element for Type AMF type
|
|
101
|
+
*
|
|
102
|
+
* @param {string} amfId Reference ID as passed in from amfConfig
|
|
103
|
+
* @param {string} selected Currently selected `@id`.
|
|
104
|
+
*/
|
|
105
|
+
export function createTypeElement(
|
|
106
|
+
amf: Json,
|
|
107
|
+
typeModel: Shape | undefined,
|
|
108
|
+
mediaTypes: Json
|
|
109
|
+
): HTMLElement {
|
|
110
|
+
const el: ApiTypeElement = document.createElement(
|
|
111
|
+
"api-type-documentation"
|
|
112
|
+
) as ApiTypeElement;
|
|
113
|
+
el.setAttribute("exportparts", ["type-title"].join(","));
|
|
114
|
+
el.amf = amf;
|
|
115
|
+
el.type = typeModel;
|
|
116
|
+
el.mediaTypes = mediaTypes;
|
|
117
|
+
return el;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Creates a documentation element for Docs AMF type
|
|
122
|
+
*
|
|
123
|
+
* @param {string} amfId Reference ID as passed in from amfConfig
|
|
124
|
+
* @param {string} selected Currently selected `@id`.
|
|
125
|
+
*/
|
|
126
|
+
export function createDocumentationElement(
|
|
127
|
+
amf: Json,
|
|
128
|
+
docsModel: DomainElement | undefined
|
|
129
|
+
): HTMLElement {
|
|
130
|
+
const el: ApiDocElement = document.createElement(
|
|
131
|
+
"api-documentation-document"
|
|
132
|
+
) as ApiDocElement;
|
|
133
|
+
el.amf = amf;
|
|
134
|
+
el.shape = docsModel;
|
|
135
|
+
return el;
|
|
136
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
width: fit-content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host(.breadcrumb_long) {
|
|
12
|
+
/* ensure 30 character min-width */
|
|
13
|
+
min-width: 200px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:host(.breadcrumb_back-arrow) {
|
|
17
|
+
gap: var(--dx-g-spacing-sm);
|
|
18
|
+
padding: var(--dx-g-spacing-sm);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:host(.breadcrumb_back-arrow:hover) {
|
|
22
|
+
background-color: var(--dx-g-cloud-blue-vibrant-90);
|
|
23
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host(.breadcrumb_back-arrow) :is(a, dx-icon) {
|
|
27
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
a {
|
|
31
|
+
font-weight: var(--dx-g-font-bold);
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
transition: var(--dx-g-transition-hue-1x);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
a,
|
|
37
|
+
span {
|
|
38
|
+
color: var(
|
|
39
|
+
--dx-c-breadcrumbs-breadcrumb-color,
|
|
40
|
+
var(--dx-g-blue-vibrant-20)
|
|
41
|
+
);
|
|
42
|
+
font-family: var(--dx-g-font-sans);
|
|
43
|
+
font-size: var(--dx-g-text-sm);
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
text-overflow: ellipsis;
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
a:hover {
|
|
50
|
+
color: var(--dx-g-blue-vibrant-40);
|
|
51
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { track } from "dxUtils/analytics";
|
|
2
|
+
import { LightningElement, api } from "lwc";
|
|
3
|
+
import { BreadcrumbItemVariant } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
const BREADCRUMB_LONG = "breadcrumb_long";
|
|
6
|
+
const BREADCRUMB_BACK_ARROW = "breadcrumb_back-arrow";
|
|
7
|
+
|
|
8
|
+
const LONG_LABEL_NUMBER = 30;
|
|
9
|
+
export default class BreadcrumbItem extends LightningElement {
|
|
10
|
+
@api href?: string;
|
|
11
|
+
@api level?: string;
|
|
12
|
+
@api breadcrumbLabels?: string;
|
|
13
|
+
|
|
14
|
+
@api
|
|
15
|
+
get label() {
|
|
16
|
+
return this._label;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
set label(value) {
|
|
20
|
+
this._label = value;
|
|
21
|
+
this.calculateClass();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@api
|
|
25
|
+
get variant() {
|
|
26
|
+
return this._variant;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
set variant(value) {
|
|
30
|
+
this._variant = value;
|
|
31
|
+
this.calculateClass();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_label: string = "";
|
|
35
|
+
_variant: BreadcrumbItemVariant = "default";
|
|
36
|
+
|
|
37
|
+
private calculateClass(): void {
|
|
38
|
+
this.classList.remove(BREADCRUMB_LONG, BREADCRUMB_BACK_ARROW);
|
|
39
|
+
|
|
40
|
+
if (this.label?.length >= LONG_LABEL_NUMBER) {
|
|
41
|
+
this.classList.add(BREADCRUMB_LONG);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (this._variant === "back-arrow") {
|
|
45
|
+
this.classList.add(BREADCRUMB_BACK_ARROW);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private get isBackArrowVariant(): boolean {
|
|
50
|
+
return this._variant === "back-arrow";
|
|
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
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@import "dxHelpers/reset";
|
|
2
|
+
@import "dxHelpers/text";
|
|
3
|
+
|
|
4
|
+
:host {
|
|
5
|
+
--dx-c-breadcrumbs-title-color: var(--dx-g-blue-vibrant-20);
|
|
6
|
+
--dx-c-breadcrumbs-breadcrumb-color: var(--dx-g-blue-vibrant-20);
|
|
7
|
+
|
|
8
|
+
font-family: var(--dx-g-font-sans);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
nav {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
position: relative;
|
|
15
|
+
gap: var(--dx-g-spacing-sm);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.breadcrumb-item_slash {
|
|
19
|
+
min-width: fit-content;
|
|
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
|
+
}
|