@salesforcedevs/docs-components 1.3.344-spage → 1.3.345-spPage-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/package.json +1 -1
- package/src/modules/doc/contentLayout/contentLayout.ts +21 -4
- package/src/modules/doc/specificationContent/specificationContent.css +3 -0
- package/src/modules/doc/specificationContent/specificationContent.html +90 -34
- package/src/modules/doc/specificationContent/specificationContent.ts +48 -25
package/package.json
CHANGED
|
@@ -124,8 +124,14 @@ export default class ContentLayout extends LightningElement {
|
|
|
124
124
|
const headingElements = this.getHeadingElements();
|
|
125
125
|
headingElements.forEach((headingElement: any) => {
|
|
126
126
|
// Sometimes elements hash and header is not being set when slot content is wrapped with div
|
|
127
|
-
headingElement.hash
|
|
128
|
-
|
|
127
|
+
if (!headingElement.hash) {
|
|
128
|
+
headingElement.hash = headingElement.attributes.hash?.nodeValue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (!headingElement.header) {
|
|
132
|
+
headingElement.header =
|
|
133
|
+
headingElement.attributes.header?.nodeValue;
|
|
134
|
+
}
|
|
129
135
|
});
|
|
130
136
|
this.updateTocItems(headingElements);
|
|
131
137
|
};
|
|
@@ -138,8 +144,19 @@ export default class ContentLayout extends LightningElement {
|
|
|
138
144
|
tabPanelListItem?.querySelectorAll("dx-tab-panel");
|
|
139
145
|
for (const tabPanelItem of tabPanels) {
|
|
140
146
|
if (tabPanelItem.active) {
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
// This is needed for Specification tab content
|
|
148
|
+
const specificationElement = tabPanelItem.querySelector(
|
|
149
|
+
"doc-specification-content"
|
|
150
|
+
);
|
|
151
|
+
if (specificationElement) {
|
|
152
|
+
headingElements =
|
|
153
|
+
specificationElement.shadowRoot.querySelectorAll(
|
|
154
|
+
TOC_HEADER_TAG
|
|
155
|
+
);
|
|
156
|
+
} else {
|
|
157
|
+
headingElements =
|
|
158
|
+
tabPanelItem.querySelectorAll(TOC_HEADER_TAG);
|
|
159
|
+
}
|
|
143
160
|
break;
|
|
144
161
|
}
|
|
145
162
|
}
|
|
@@ -1,46 +1,102 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<!-- Display Attributes if they exist -->
|
|
2
|
+
<div class="specification-properties">
|
|
4
3
|
<template if:true={hasAttributes}>
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
<doc-heading
|
|
5
|
+
header="Attributes"
|
|
6
|
+
hash="attributes"
|
|
7
|
+
aria-level="2"
|
|
8
|
+
id="attributes"
|
|
9
|
+
></doc-heading>
|
|
10
|
+
<table>
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<th>Name</th>
|
|
14
|
+
<th>Description</th>
|
|
15
|
+
</tr>
|
|
16
|
+
</thead>
|
|
17
|
+
<tbody>
|
|
18
|
+
<template for:each={attributes} for:item="attribute">
|
|
19
|
+
<tr key={attribute.name}>
|
|
20
|
+
<td>{attribute.nameInKebabCase}</td>
|
|
21
|
+
<td>{attribute.description}</td>
|
|
22
|
+
</tr>
|
|
23
|
+
</template>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
14
26
|
</template>
|
|
15
27
|
|
|
16
|
-
<!-- Display Methods if they exist -->
|
|
17
28
|
<template if:true={hasMethods}>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
<doc-heading
|
|
30
|
+
header="Methods"
|
|
31
|
+
hash="methods"
|
|
32
|
+
aria-level="2"
|
|
33
|
+
id="methods"
|
|
34
|
+
></doc-heading>
|
|
35
|
+
<table>
|
|
36
|
+
<thead>
|
|
37
|
+
<tr>
|
|
38
|
+
<th>Name</th>
|
|
39
|
+
<th>Description</th>
|
|
40
|
+
</tr>
|
|
41
|
+
</thead>
|
|
42
|
+
<tbody>
|
|
43
|
+
<template for:each={methods} for:item="method">
|
|
44
|
+
<tr key={method.name}>
|
|
45
|
+
<td>{method.nameInKebabCase}</td>
|
|
46
|
+
<td>{method.description}</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</template>
|
|
49
|
+
</tbody>
|
|
50
|
+
</table>
|
|
27
51
|
</template>
|
|
28
52
|
|
|
29
|
-
<!-- Display Slots if they exist -->
|
|
30
53
|
<template if:true={hasSlots}>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
<doc-heading
|
|
55
|
+
header="Slots"
|
|
56
|
+
hash="slots"
|
|
57
|
+
aria-level="2"
|
|
58
|
+
id="slots"
|
|
59
|
+
></doc-heading>
|
|
60
|
+
<table>
|
|
61
|
+
<thead>
|
|
62
|
+
<tr>
|
|
63
|
+
<th>Name</th>
|
|
64
|
+
<th>Description</th>
|
|
65
|
+
</tr>
|
|
66
|
+
</thead>
|
|
67
|
+
<tbody>
|
|
68
|
+
<template for:each={slots} for:item="slot">
|
|
69
|
+
<tr key={slot.name}>
|
|
70
|
+
<td>{slot.nameInKebabCase}</td>
|
|
71
|
+
<td>{slot.description}</td>
|
|
72
|
+
</tr>
|
|
73
|
+
</template>
|
|
74
|
+
</tbody>
|
|
75
|
+
</table>
|
|
40
76
|
</template>
|
|
41
77
|
|
|
42
|
-
<template if:true={
|
|
43
|
-
<
|
|
78
|
+
<template if:true={hasEvents}>
|
|
79
|
+
<doc-heading
|
|
80
|
+
header="Events"
|
|
81
|
+
hash="events"
|
|
82
|
+
aria-level="2"
|
|
83
|
+
></doc-heading>
|
|
84
|
+
<table>
|
|
85
|
+
<thead>
|
|
86
|
+
<tr>
|
|
87
|
+
<th>Name</th>
|
|
88
|
+
<th>Description</th>
|
|
89
|
+
</tr>
|
|
90
|
+
</thead>
|
|
91
|
+
<tbody>
|
|
92
|
+
<template for:each={events} for:item="event">
|
|
93
|
+
<tr key={event.name}>
|
|
94
|
+
<td>{event.nameInKebabCase}</td>
|
|
95
|
+
<td>{event.description}</td>
|
|
96
|
+
</tr>
|
|
97
|
+
</template>
|
|
98
|
+
</tbody>
|
|
99
|
+
</table>
|
|
44
100
|
</template>
|
|
45
|
-
</
|
|
101
|
+
</div>
|
|
46
102
|
</template>
|
|
@@ -1,41 +1,64 @@
|
|
|
1
|
-
import { LightningElement, track } from "lwc";
|
|
2
|
-
import { toJson } from "dxUtils/normalizers";
|
|
1
|
+
import { LightningElement, track, api } from "lwc";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/* The actual URL is as follows:
|
|
4
|
+
* http://api.salesforce.com/doc-platform/developer/v1-alpha/components/{type}/{component-name}
|
|
5
|
+
* Until the API integration is ready, we will go ahead with localhost.
|
|
6
|
+
*/
|
|
7
|
+
const localURL: string = "https://cx-mock-router-f02597c1b3da.herokuapp.com";
|
|
8
|
+
const ROUTER_URL: string =
|
|
9
|
+
localURL || "https://api.salesforce.com/doc-platform/developer/v1";
|
|
10
|
+
|
|
11
|
+
export default class SpecificationContent extends LightningElement {
|
|
12
|
+
@track data: any;
|
|
13
|
+
@api component: string = "button";
|
|
14
|
+
@api type: string = "lightning";
|
|
15
|
+
|
|
16
|
+
private attributes = [];
|
|
17
|
+
private methods = [];
|
|
18
|
+
private slots = [];
|
|
19
|
+
private events = [];
|
|
7
20
|
|
|
8
|
-
// Lifecycle method to fetch data when the component is inserted into the DOM
|
|
9
21
|
connectedCallback() {
|
|
10
|
-
this.
|
|
22
|
+
this.fetchComponentMetadata();
|
|
11
23
|
}
|
|
12
24
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
async fetchComponentMetadata() {
|
|
26
|
+
const url = `${ROUTER_URL}/components/${this.type}/${this.component}`;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const response = await fetch(url);
|
|
30
|
+
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(`Failed to fetch: ${response.statusText}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const result = await response.json();
|
|
36
|
+
this.data = result;
|
|
37
|
+
({
|
|
38
|
+
attributes: this.attributes,
|
|
39
|
+
methods: this.methods,
|
|
40
|
+
slots: this.slots,
|
|
41
|
+
events: this.events
|
|
42
|
+
} = this.data);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
this.data = {};
|
|
45
|
+
console.error("fetchComponentMetadata() failed for:" + url);
|
|
46
|
+
}
|
|
25
47
|
}
|
|
26
48
|
|
|
27
|
-
// Helper to check if attributes exist
|
|
28
49
|
get hasAttributes() {
|
|
29
|
-
return this.
|
|
50
|
+
return this.attributes?.length > 0;
|
|
30
51
|
}
|
|
31
52
|
|
|
32
|
-
// Helper to check if methods exist
|
|
33
53
|
get hasMethods() {
|
|
34
|
-
return this.
|
|
54
|
+
return this.methods?.length > 0;
|
|
35
55
|
}
|
|
36
56
|
|
|
37
|
-
// Helper to check if slots exist
|
|
38
57
|
get hasSlots() {
|
|
39
|
-
return this.
|
|
58
|
+
return this.slots?.length > 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get hasEvents() {
|
|
62
|
+
return this.events?.length > 0;
|
|
40
63
|
}
|
|
41
64
|
}
|