@salesforcedevs/docs-components 0.54.0 → 0.54.7-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.
Files changed (40) hide show
  1. package/lwc.config.json +6 -2
  2. package/package.json +12 -4
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfReference/amfReference.css +5 -0
  5. package/src/modules/doc/amfReference/amfReference.html +39 -0
  6. package/src/modules/doc/amfReference/amfReference.ts +813 -0
  7. package/src/modules/doc/amfReference/route-meta.ts +22 -0
  8. package/src/modules/doc/amfReference/types.ts +93 -0
  9. package/src/modules/doc/amfReference/utils.ts +669 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +1 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
  13. package/src/modules/doc/amfTopic/types.ts +54 -0
  14. package/src/modules/doc/amfTopic/utils.ts +130 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +2 -2
  16. package/src/modules/doc/breadcrumbs/breadcrumbs.css +2 -2
  17. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +3 -3
  18. package/src/modules/doc/content/content.css +4 -4
  19. package/src/modules/doc/content/content.ts +1 -1
  20. package/src/modules/doc/contentCallout/contentCallout.css +4 -4
  21. package/src/modules/doc/contentLayout/contentLayout.css +100 -0
  22. package/src/modules/doc/contentLayout/contentLayout.html +55 -0
  23. package/src/modules/doc/contentLayout/contentLayout.ts +242 -0
  24. package/src/modules/doc/header/header.css +1 -1
  25. package/src/modules/doc/header/header.ts +5 -5
  26. package/src/modules/doc/headingAnchor/headingAnchor.css +1 -1
  27. package/src/modules/doc/headingContent/headingContent.css +1 -1
  28. package/src/modules/doc/phase/phase.css +3 -3
  29. package/src/modules/doc/phase/phase.ts +1 -1
  30. package/src/modules/doc/xmlContent/types.ts +113 -0
  31. package/src/modules/doc/xmlContent/utils.ts +158 -0
  32. package/src/modules/doc/xmlContent/xmlContent.css +25 -0
  33. package/src/modules/doc/xmlContent/xmlContent.html +34 -0
  34. package/src/modules/doc/xmlContent/xmlContent.ts +568 -0
  35. package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
  36. package/src/modules/docHelpers/amfStyle/amfStyle.css +390 -0
  37. package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
  38. package/src/modules/{helpers → docHelpers}/status/status.css +0 -0
  39. package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
  40. 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,5 +1,5 @@
1
- @import "helpers/reset";
2
- @import "helpers/text";
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
3
 
4
4
  :host {
5
5
  display: flex;
@@ -1,5 +1,5 @@
1
- @import "helpers/reset";
2
- @import "helpers/text";
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);
@@ -1,6 +1,6 @@
1
1
  import { LightningElement, api } from "lwc";
2
- import { Breadcrumb, Option } from "typings/custom";
3
- import { toJson } from "utils/normalizers";
2
+ import { Breadcrumb, OptionWithLink } from "typings/custom";
3
+ import { toJson } from "dxUtils/normalizers";
4
4
 
5
5
  type BreadcrumbConfig = {
6
6
  minWidth: number;
@@ -62,7 +62,7 @@ export default class Breadcrumbs extends LightningElement {
62
62
  private get renderDropdown(): boolean {
63
63
  return this.hasInternalBreadcrumbs && !!this.dropdownOptionAmount;
64
64
  }
65
- private get dropdownOptions(): Option[] {
65
+ private get dropdownOptions(): OptionWithLink[] {
66
66
  return this.breadcrumbs!.slice(1, this.dropdownOptionAmount! + 1).map(
67
67
  (link) => ({
68
68
  id: link.href!,
@@ -4,10 +4,10 @@
4
4
  * pattern validation cannot be applied
5
5
  */
6
6
 
7
- @import "helpers/text";
8
- @import "helpers/reset";
9
- @import "helpers/card";
10
- @import "helpers/table";
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%;
@@ -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 "utils/highlight";
8
+ import { highlightTerms } from "dxUtils/highlight";
9
9
 
10
10
  const HIGHLIGHTABLE_SELECTOR = [
11
11
  "p",
@@ -1,6 +1,6 @@
1
- @import "helpers/reset";
2
- @import "helpers/text";
3
- @import "helpers/status";
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
+ }
@@ -0,0 +1,100 @@
1
+ :host {
2
+ --dx-c-content-vertical-spacing: var(--dx-g-spacing-lg);
3
+
4
+ display: block;
5
+ }
6
+
7
+ dx-sidebar,
8
+ dx-sidebar-old {
9
+ --dx-c-sidebar-height: 100%;
10
+ --dx-c-sidebar-vertical-padding: var(--dx-c-content-vertical-spacing);
11
+
12
+ z-index: 5;
13
+ }
14
+
15
+ dx-toc {
16
+ --dx-c-toc-width: unset;
17
+
18
+ height: calc(100% - var(--dx-c-content-vertical-spacing) * 2);
19
+ margin: var(--dx-c-content-vertical-spacing) 0;
20
+ overflow-y: auto;
21
+ }
22
+
23
+ dx-sidebar,
24
+ dx-toc {
25
+ display: block;
26
+ }
27
+
28
+ .content {
29
+ display: flex;
30
+ }
31
+
32
+ .content-body-doc-phase-container {
33
+ flex: 1;
34
+ }
35
+
36
+ .content-body-container {
37
+ display: flex;
38
+ flex-direction: row;
39
+ padding-right: var(--dx-g-page-padding-horizontal);
40
+ }
41
+
42
+ .content-body {
43
+ margin: var(--dx-g-spacing-sm) var(--dx-c-content-vertical-spacing)
44
+ var(--dx-g-spacing-xl);
45
+ flex: 1;
46
+ width: 0;
47
+ }
48
+
49
+ .is-sticky {
50
+ height: 100vh;
51
+ position: sticky;
52
+ top: 0;
53
+ }
54
+
55
+ .right-nav-bar {
56
+ max-width: 275px;
57
+ }
58
+
59
+ dx-breadcrumbs {
60
+ display: block;
61
+ margin-bottom: var(--dx-g-spacing-2xl);
62
+ }
63
+
64
+ @media screen and (max-width: 1024px) {
65
+ .right-nav-bar {
66
+ display: none;
67
+ }
68
+ }
69
+
70
+ @media screen and (max-width: 800px) {
71
+ dx-breadcrumbs {
72
+ display: none;
73
+ }
74
+
75
+ .content-body {
76
+ margin-top: var(--dx-c-content-vertical-spacing);
77
+ }
78
+ }
79
+
80
+ @media screen and (max-width: 768px) {
81
+ .content {
82
+ flex-direction: column;
83
+ }
84
+
85
+ .content-body-container {
86
+ padding-right: 0;
87
+ }
88
+
89
+ .left-nav-bar {
90
+ --dx-c-sidebar-height: 80vh;
91
+
92
+ height: unset;
93
+ z-index: 10;
94
+ }
95
+
96
+ .content-body {
97
+ margin-left: var(--dx-g-spacing-mlg, 20px);
98
+ margin-right: var(--dx-g-spacing-mlg, 20px);
99
+ }
100
+ }
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div class="content">
3
+ <template if:true={useOldSidebar}>
4
+ <dx-sidebar-old
5
+ class="is-sticky left-nav-bar"
6
+ trees={sidebarContent}
7
+ value={sidebarValue}
8
+ header={sidebarHeader}
9
+ >
10
+ <slot name="sidebar-header" slot="header"></slot>
11
+ </dx-sidebar-old>
12
+ </template>
13
+ <template if:false={useOldSidebar}>
14
+ <dx-sidebar
15
+ class="is-sticky left-nav-bar"
16
+ trees={sidebarContent}
17
+ value={sidebarValue}
18
+ header={sidebarHeader}
19
+ coveo-organization-id={coveoOrganizationId}
20
+ coveo-public-access-token={coveoPublicAccessToken}
21
+ coveo-search-hub={coveoSearchHub}
22
+ coveo-advanced-query-config={coveoAdvancedQueryConfig}
23
+ >
24
+ <slot name="sidebar-header" slot="header"></slot>
25
+ </dx-sidebar>
26
+ </template>
27
+ <div class="content-body-doc-phase-container">
28
+ <slot name="doc-phase"></slot>
29
+ <div class="content-body-container">
30
+ <div class="content-body">
31
+ <dx-breadcrumbs
32
+ if:true={breadcrumbs}
33
+ breadcrumbs={breadcrumbs}
34
+ truncate
35
+ hide-current-location
36
+ ></dx-breadcrumbs>
37
+ <dx-breadcrumbs
38
+ if:false={breadcrumbs}
39
+ pathname={pathname}
40
+ hide-current-location
41
+ ></dx-breadcrumbs>
42
+ <slot onslotchange={onSlotChange}></slot>
43
+ </div>
44
+ <div class="right-nav-bar is-sticky">
45
+ <dx-toc
46
+ if:true={showToc}
47
+ title={tocTitle}
48
+ options={tocOptions}
49
+ value={tocValue}
50
+ ></dx-toc>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </template>