@salesforcedevs/docs-components 1.3.344-fix-alpha → 1.3.344-spage

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 CHANGED
@@ -18,6 +18,7 @@
18
18
  "doc/headingAnchor",
19
19
  "doc/overview",
20
20
  "doc/phase",
21
+ "doc/specificationContent",
21
22
  "doc/versionPicker",
22
23
  "doc/xmlContent",
23
24
  "docUtils/utils"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.3.344-fix-alpha",
3
+ "version": "1.3.344-spage",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <lightning-card title="Fetched Data">
3
+ <!-- Display Attributes if they exist -->
4
+ <template if:true={hasAttributes}>
5
+ <h3>Attributes</h3>
6
+ <ul>
7
+ <template for:each={data.attribute} for:item="attr">
8
+ <li key={attr.name}>
9
+ <strong>{attr.name}:</strong>
10
+ {attr.desc}
11
+ </li>
12
+ </template>
13
+ </ul>
14
+ </template>
15
+
16
+ <!-- Display Methods if they exist -->
17
+ <template if:true={hasMethods}>
18
+ <h3>Methods</h3>
19
+ <ul>
20
+ <template for:each={data.method} for:item="method">
21
+ <li key={method.name}>
22
+ <strong>{method.name}:</strong>
23
+ {method.desc}
24
+ </li>
25
+ </template>
26
+ </ul>
27
+ </template>
28
+
29
+ <!-- Display Slots if they exist -->
30
+ <template if:true={hasSlots}>
31
+ <h3>Slots</h3>
32
+ <ul>
33
+ <template for:each={data.slots} for:item="slot">
34
+ <li key={slot.name}>
35
+ <strong>{slot.name}:</strong>
36
+ {slot.desc}
37
+ </li>
38
+ </template>
39
+ </ul>
40
+ </template>
41
+
42
+ <template if:true={error}>
43
+ <p>Error fetching data: {error}</p>
44
+ </template>
45
+ </lightning-card>
46
+ </template>
@@ -0,0 +1,41 @@
1
+ import { LightningElement, track } from "lwc";
2
+ import { toJson } from "dxUtils/normalizers";
3
+
4
+ export default class specificationContent extends LightningElement {
5
+ @track data: any; // Reactive property to store fetched data
6
+ @track error: any; // To track any errors
7
+
8
+ // Lifecycle method to fetch data when the component is inserted into the DOM
9
+ connectedCallback() {
10
+ this.loadData();
11
+ }
12
+
13
+ // Method to make the API call
14
+ loadData() {
15
+ fetch("http://localhost:3002/card") // Sample API URL
16
+ .then((response) => response.json()) // Convert response to JSON
17
+ .then((result) => {
18
+ this.data = toJson(result); // Store data to update UI
19
+ this.error = undefined; // Clear any previous errors
20
+ })
21
+ .catch((error) => {
22
+ this.error = error; // Capture any errors
23
+ this.data = {}; // Clear data on error
24
+ });
25
+ }
26
+
27
+ // Helper to check if attributes exist
28
+ get hasAttributes() {
29
+ return this.data?.attribute;
30
+ }
31
+
32
+ // Helper to check if methods exist
33
+ get hasMethods() {
34
+ return this.data?.method;
35
+ }
36
+
37
+ // Helper to check if slots exist
38
+ get hasSlots() {
39
+ return this.data?.slots;
40
+ }
41
+ }