@salesforcedevs/docs-components 0.0.7 → 0.0.9-edit

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 (141) hide show
  1. package/lwc.config.json +25 -2
  2. package/package.json +17 -6
  3. package/src/modules/README.md +41 -0
  4. package/src/modules/doc/amfModelParser/amfModelParser.ts +674 -0
  5. package/src/modules/doc/amfReference/amfReference.css +25 -0
  6. package/src/modules/doc/amfReference/amfReference.html +60 -0
  7. package/src/modules/doc/amfReference/amfReference.ts +1494 -0
  8. package/src/modules/doc/amfReference/constants.ts +76 -0
  9. package/src/modules/doc/amfReference/types.ts +125 -0
  10. package/src/modules/doc/amfTopic/amfTopic.css +21 -0
  11. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  12. package/src/modules/doc/amfTopic/amfTopic.ts +111 -0
  13. package/src/modules/doc/amfTopic/types.ts +56 -0
  14. package/src/modules/doc/amfTopic/utils.ts +136 -0
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +71 -0
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.html +58 -0
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +183 -0
  21. package/src/modules/doc/chat/README.md +179 -0
  22. package/src/modules/doc/chat/chat.css +821 -0
  23. package/src/modules/doc/chat/chat.html +241 -0
  24. package/src/modules/doc/chat/chat.ts +586 -0
  25. package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
  26. package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
  27. package/src/modules/doc/componentPlayground/componentPlayground.ts +29 -0
  28. package/src/modules/doc/content/content.css +249 -87
  29. package/src/modules/doc/content/content.html +3 -2
  30. package/src/modules/doc/content/content.ts +272 -152
  31. package/src/modules/doc/contentCallout/contentCallout.css +25 -26
  32. package/src/modules/doc/contentCallout/contentCallout.html +13 -4
  33. package/src/modules/doc/contentCallout/contentCallout.ts +21 -10
  34. package/src/modules/doc/contentLayout/contentLayout.css +1 -0
  35. package/src/modules/doc/contentLayout/contentLayout.html +68 -0
  36. package/src/modules/doc/contentLayout/contentLayout.ts +531 -0
  37. package/src/modules/doc/contentMedia/contentMedia.css +49 -0
  38. package/src/modules/doc/contentMedia/contentMedia.html +23 -0
  39. package/src/modules/doc/contentMedia/contentMedia.ts +34 -0
  40. package/src/modules/doc/doDont/doDont.css +47 -0
  41. package/src/modules/doc/doDont/doDont.html +27 -0
  42. package/src/modules/doc/doDont/doDont.ts +17 -0
  43. package/src/modules/doc/editFile/editFile.css +511 -0
  44. package/src/modules/doc/editFile/editFile.html +163 -0
  45. package/src/modules/doc/editFile/editFile.ts +238 -0
  46. package/src/modules/doc/header/header.css +132 -0
  47. package/src/modules/doc/header/header.html +55 -0
  48. package/src/modules/doc/header/header.ts +120 -0
  49. package/src/modules/doc/heading/heading.css +33 -0
  50. package/src/modules/doc/heading/heading.html +14 -0
  51. package/src/modules/doc/heading/heading.ts +67 -0
  52. package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
  53. package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
  54. package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
  55. package/src/modules/doc/headingContent/headingContent.css +53 -0
  56. package/src/modules/doc/headingContent/headingContent.html +13 -0
  57. package/src/modules/doc/headingContent/headingContent.ts +30 -0
  58. package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
  59. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
  60. package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +168 -0
  61. package/src/modules/doc/nav/nav.css +4 -2
  62. package/src/modules/doc/nav/nav.ts +1 -1
  63. package/src/modules/doc/overview/overview.css +40 -0
  64. package/src/modules/doc/overview/overview.html +34 -0
  65. package/src/modules/doc/overview/overview.ts +12 -0
  66. package/src/modules/doc/phase/phase.css +70 -0
  67. package/src/modules/doc/phase/phase.html +38 -0
  68. package/src/modules/doc/phase/phase.ts +93 -0
  69. package/src/modules/doc/specificationContent/specificationContent.css +36 -0
  70. package/src/modules/doc/specificationContent/specificationContent.html +171 -0
  71. package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
  72. package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
  73. package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
  74. package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
  75. package/src/modules/doc/toc/toc.html +11 -6
  76. package/src/modules/doc/toc/toc.ts +1 -1
  77. package/src/modules/doc/toolbar/toolbar.html +8 -1
  78. package/src/modules/doc/versionPicker/versionPicker.css +64 -0
  79. package/src/modules/doc/versionPicker/versionPicker.html +38 -0
  80. package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
  81. package/src/modules/doc/xmlContent/types.ts +120 -0
  82. package/src/modules/doc/xmlContent/utils.ts +163 -0
  83. package/src/modules/doc/xmlContent/xmlContent.css +54 -0
  84. package/src/modules/doc/xmlContent/xmlContent.html +52 -0
  85. package/src/modules/doc/xmlContent/xmlContent.ts +792 -0
  86. package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
  87. package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
  88. package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
  89. package/src/modules/docHelpers/status/status.css +22 -0
  90. package/src/modules/docUtils/searchSyncer/searchSyncer.ts +86 -0
  91. package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
  92. package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
  93. package/src/modules/docUtils/utils/utils.ts +32 -0
  94. package/src/modules/doc/container/__benchmarks__/container.benchmark.js +0 -43
  95. package/src/modules/doc/container/__mocks__/mockAvailableLanguages.js +0 -8
  96. package/src/modules/doc/container/__mocks__/mockAvailableVersions.js +0 -122
  97. package/src/modules/doc/container/__mocks__/mockContentFetchResponse.json +0 -5
  98. package/src/modules/doc/container/__mocks__/mockDocContent.js +0 -29
  99. package/src/modules/doc/container/__mocks__/mockNavigationFetchResponse.json +0 -4061
  100. package/src/modules/doc/container/__mocks__/mockPageReference.js +0 -8
  101. package/src/modules/doc/container/__mocks__/mockPdfUrl.js +0 -1
  102. package/src/modules/doc/container/__mocks__/mockSelectedLanguage.js +0 -8
  103. package/src/modules/doc/container/__mocks__/mockSelectedVersion.js +0 -8
  104. package/src/modules/doc/container/__mocks__/mockToc.js +0 -146
  105. package/src/modules/doc/container/__tests__/container.test.ts +0 -82
  106. package/src/modules/doc/container/container.css +0 -34
  107. package/src/modules/doc/container/container.html +0 -23
  108. package/src/modules/doc/container/container.stories.ts +0 -18
  109. package/src/modules/doc/container/container.ts +0 -356
  110. package/src/modules/doc/content/__tests__/content.test.ts +0 -30
  111. package/src/modules/doc/content/__tests__/mockDocContent.ts +0 -29
  112. package/src/modules/doc/content/__tests__/mockPageReference.ts +0 -8
  113. package/src/modules/doc/contentCallout/__tests__/contentCallout.test.ts +0 -80
  114. package/src/modules/doc/contentCallout/__tests__/mockProps.ts +0 -14
  115. package/src/modules/doc/contentCallout/contentCallout.stories.ts +0 -29
  116. package/src/modules/doc/landing/__tests__/landing.test.ts +0 -32
  117. package/src/modules/doc/landing/__tests__/mockFetch.json +0 -370
  118. package/src/modules/doc/landing/landing.css +0 -66
  119. package/src/modules/doc/landing/landing.html +0 -109
  120. package/src/modules/doc/landing/landing.stories.ts +0 -10
  121. package/src/modules/doc/landing/landing.ts +0 -225
  122. package/src/modules/doc/nav/__tests__/mockAvailableLanguages.ts +0 -8
  123. package/src/modules/doc/nav/__tests__/mockAvailableVersions.ts +0 -122
  124. package/src/modules/doc/nav/__tests__/mockPageReference.ts +0 -8
  125. package/src/modules/doc/nav/__tests__/mockPdfUrl.ts +0 -1
  126. package/src/modules/doc/nav/__tests__/mockSelectedLanguage.ts +0 -8
  127. package/src/modules/doc/nav/__tests__/mockSelectedVersion.ts +0 -8
  128. package/src/modules/doc/nav/__tests__/mockToc.ts +0 -146
  129. package/src/modules/doc/nav/__tests__/nav.test.ts +0 -62
  130. package/src/modules/doc/search/__tests__/search.test.ts +0 -20
  131. package/src/modules/doc/search/search.html +0 -1
  132. package/src/modules/doc/search/search.ts +0 -3
  133. package/src/modules/doc/toc/__tests__/mockPageReference.ts +0 -8
  134. package/src/modules/doc/toc/__tests__/mockToc.ts +0 -146
  135. package/src/modules/doc/toc/__tests__/toc.test.ts +0 -29
  136. package/src/modules/doc/toolbar/__tests__/mockAvailableLanguages.ts +0 -8
  137. package/src/modules/doc/toolbar/__tests__/mockAvailableVersions.ts +0 -122
  138. package/src/modules/doc/toolbar/__tests__/mockPdfUrl.ts +0 -1
  139. package/src/modules/doc/toolbar/__tests__/mockSelectedLanguage.ts +0 -8
  140. package/src/modules/doc/toolbar/__tests__/mockSelectedVersion.ts +0 -8
  141. package/src/modules/doc/toolbar/__tests__/toolbar.test.ts +0 -44
@@ -0,0 +1,40 @@
1
+ doc-phase {
2
+ --doc-c-phase-top: calc(
3
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
4
+ );
5
+ }
6
+
7
+ dx-section {
8
+ --dx-c-section-padding-top: 0;
9
+ --dx-c-section-padding-bottom: var(--dx-g-spacing-2xl);
10
+ }
11
+
12
+ dx-section::part(content) {
13
+ max-width: 1280px;
14
+ margin: auto;
15
+ }
16
+
17
+ dx-group-text:first-of-type {
18
+ margin-top: var(--dx-g-spacing-2xl);
19
+ }
20
+
21
+ dx-group-text.features {
22
+ margin-top: var(--dx-g-spacing-xl);
23
+ margin-bottom: var(--dx-g-spacing-xl);
24
+ }
25
+
26
+ .content {
27
+ padding-right: var(--dx-g-spacing-xl);
28
+ }
29
+
30
+ @media (max-width: 1024px) {
31
+ .content {
32
+ padding-right: 0;
33
+ }
34
+ }
35
+
36
+ @media (max-width: 800px) {
37
+ dx-group-text.description {
38
+ margin-top: var(--dx-g-spacing-lg);
39
+ }
40
+ }
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <div class="container">
3
+ <doc-phase
4
+ if:true={docPhaseInfo}
5
+ doc-phase-info={docPhaseInfo}
6
+ ></doc-phase>
7
+
8
+ <dx-section>
9
+ <dx-grid columns="two-slim-right">
10
+ <div class="content">
11
+ <dx-group-text
12
+ class="description"
13
+ header={header}
14
+ body={description}
15
+ size="large"
16
+ title-aria-level="1"
17
+ primary-link={primaryLink}
18
+ secondary-link={secondaryLink}
19
+ ></dx-group-text>
20
+ </div>
21
+ <div>
22
+ <dx-group-text
23
+ header={featuresListTitle}
24
+ size="medium"
25
+ class="features"
26
+ ></dx-group-text>
27
+ <dx-features-list
28
+ options={featuresListOptions}
29
+ ></dx-features-list>
30
+ </div>
31
+ </dx-grid>
32
+ </dx-section>
33
+ </div>
34
+ </template>
@@ -0,0 +1,12 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { DocPhaseInfo, FeatureItem, Link } from "typings/custom";
3
+
4
+ export default class Overview extends LightningElement {
5
+ @api docPhaseInfo!: DocPhaseInfo;
6
+ @api header!: string;
7
+ @api description!: string;
8
+ @api primaryLink!: Link;
9
+ @api secondaryLink!: Link;
10
+ @api featuresListTitle!: string;
11
+ @api featuresListOptions!: FeatureItem[];
12
+ }
@@ -0,0 +1,70 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "docHelpers/status";
4
+
5
+ :host {
6
+ --doc-c-phase-top: 0;
7
+ --doc-c-phase-container-align-items: flex-start;
8
+
9
+ position: sticky;
10
+ top: var(--doc-c-phase-top);
11
+
12
+ /* NOTE: If you are changing z-index value here, ensure it's less than z-index of dx-sidebar in contentLayout.css */
13
+ z-index: var(--dx-g-z-index-100);
14
+ }
15
+
16
+ .doc-phase-container {
17
+ display: flex;
18
+ flex-direction: column;
19
+ align-items: var(--doc-c-phase-container-align-items);
20
+ padding-left: var(--dx-g-global-header-padding-horizontal);
21
+ padding-right: var(--dx-g-global-header-padding-horizontal);
22
+ width: 100%;
23
+ border: none;
24
+ }
25
+
26
+ .doc-phase-title-container {
27
+ display: flex;
28
+ flex-direction: row;
29
+ align-items: center;
30
+ width: 100%;
31
+ }
32
+
33
+ dx-button {
34
+ margin-left: auto;
35
+ }
36
+
37
+ /*
38
+ NOTE: Here we are assuming that indicator height won't go beyond 1000px.
39
+
40
+ It's one of the suggested way to achieve the expand/collapse animation
41
+ Ref: https://stackoverflow.com/a/41164095
42
+
43
+ Otherwise we need to change the height when user clicks on button
44
+ Ref: https://stackoverflow.com/a/11837673
45
+ */
46
+
47
+ .doc-phase-body {
48
+ display: block;
49
+ max-height: 1000px;
50
+ overflow: hidden;
51
+ padding-top: var(--dx-g-spacing-smd);
52
+ transition: max-height 0.25s ease, padding 0.25s ease;
53
+ }
54
+
55
+ .doc-phase-body-hidden {
56
+ max-height: 0;
57
+ padding-top: 0;
58
+ transition: max-height 0.1s ease-out, padding 0.25s ease-out;
59
+ }
60
+
61
+ .doc-phase-body a {
62
+ color: var(--dx-g-blue-vibrant-50);
63
+ }
64
+
65
+ /* Small Devices */
66
+ @media screen and (max-width: 480px) {
67
+ .doc-phase-container {
68
+ padding: var(--doc-status-vertical-padding);
69
+ }
70
+ }
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <div class={className} part="container">
3
+ <div class="doc-phase-title-container">
4
+ <dx-icon
5
+ class="doc-status-icon doc-phase-icon"
6
+ symbol={iconName}
7
+ size="large"
8
+ color="status-icon-color"
9
+ ></dx-icon>
10
+ <p class="doc-status-title doc-phase-title dx-text-body-3">
11
+ {docPhaseTitle}
12
+ </p>
13
+ <dx-button
14
+ lwc:if={dismissible}
15
+ aria-label="Dismiss"
16
+ icon-color="status-icon-color"
17
+ icon-size="large"
18
+ icon-symbol="close"
19
+ variant="icon-only"
20
+ onclick={onDismiss}
21
+ ></dx-button>
22
+ <dx-button
23
+ lwc:else
24
+ variant="inline"
25
+ onclick={onShowHide}
26
+ aria-label={hideBodyText}
27
+ >
28
+ {hideBodyText}
29
+ </dx-button>
30
+ </div>
31
+ <!--
32
+ NOTE: Here we are rendering mark up using lwc:dom & innerHTML
33
+ option instead of slots because the html markup will come as a
34
+ property to the component from a configuration
35
+ -->
36
+ <span lwc:dom="manual" class={bodyClassName}></span>
37
+ </div>
38
+ </template>
@@ -0,0 +1,93 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import cx from "classnames";
3
+
4
+ import { DocPhaseInfo } from "typings/custom";
5
+ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
+
7
+ export default class Phase extends LightningElement {
8
+ _docPhaseInfo: DocPhaseInfo | null = null;
9
+ _dismissible = false;
10
+ _iconName = "recipe";
11
+
12
+ @api
13
+ get docPhaseInfo(): DocPhaseInfo | null {
14
+ return this._docPhaseInfo;
15
+ }
16
+
17
+ set docPhaseInfo(value) {
18
+ this._docPhaseInfo = toJson(value);
19
+ }
20
+
21
+ @api
22
+ get dismissible(): boolean {
23
+ return this._dismissible;
24
+ }
25
+
26
+ set dismissible(value) {
27
+ if (value) {
28
+ this._dismissible = normalizeBoolean(value);
29
+ }
30
+ }
31
+
32
+ @api
33
+ get iconName(): string {
34
+ return this._iconName;
35
+ }
36
+
37
+ set iconName(value) {
38
+ if (value) {
39
+ this._iconName = value;
40
+ }
41
+ }
42
+
43
+ isBodyHidden = false;
44
+
45
+ get docPhaseTitle() {
46
+ return this.docPhaseInfo?.title;
47
+ }
48
+
49
+ get hideBodyText() {
50
+ return this.isBodyHidden ? "Show" : "Hide";
51
+ }
52
+
53
+ get className() {
54
+ return cx(
55
+ "doc-status-base",
56
+ "doc-status-container",
57
+ "doc-phase-container"
58
+ );
59
+ }
60
+
61
+ get bodyClassName() {
62
+ return cx(
63
+ "doc-phase-body",
64
+ "dx-text-body-3",
65
+ this.isBodyHidden && "doc-phase-body-hidden"
66
+ );
67
+ }
68
+
69
+ renderedCallback() {
70
+ const phaseBodyContainer =
71
+ this.template.querySelector(".doc-phase-body");
72
+ if (phaseBodyContainer && this.docPhaseInfo) {
73
+ // eslint-disable-next-line @lwc/lwc/no-inner-html
74
+ phaseBodyContainer.innerHTML = this.docPhaseInfo.body;
75
+ }
76
+ }
77
+
78
+ onShowHide() {
79
+ this.isBodyHidden = !this.isBodyHidden;
80
+ }
81
+
82
+ onDismiss() {
83
+ this.dispatchEvent(
84
+ new CustomEvent("dismissphase", {
85
+ detail: {
86
+ docPhaseInfo: this.docPhaseInfo
87
+ },
88
+ composed: true,
89
+ bubbles: true
90
+ })
91
+ );
92
+ }
93
+ }
@@ -0,0 +1,36 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "dxHelpers/table";
4
+
5
+ .code {
6
+ color: #181818;
7
+ font-family: Courier, var(--dx-g-font-mono);
8
+ font-size: var(--dx-g-text-sm);
9
+ line-height: 150%;
10
+ background-color: #f4f4f4;
11
+ }
12
+
13
+ table {
14
+ width: 100%;
15
+ }
16
+
17
+ .specification-properties table {
18
+ display: table;
19
+ }
20
+
21
+ .left-border {
22
+ border-left: 1px solid var(--dx-g-gray-90);
23
+ }
24
+
25
+ .icon-cell {
26
+ text-align: center;
27
+ }
28
+
29
+ .icon {
30
+ display: inline-block;
31
+ }
32
+
33
+ .loader {
34
+ pointer-events: none;
35
+ bottom: 30%;
36
+ }
@@ -0,0 +1,171 @@
1
+ <template>
2
+ <div class="specification-properties">
3
+ <dx-spinner
4
+ size="large"
5
+ variant="brand"
6
+ class="loader"
7
+ if:true={isLoading}
8
+ ></dx-spinner>
9
+ <dx-error-fallback lwc:if={showError}></dx-error-fallback>
10
+ <template lwc:if={hasAttributes}>
11
+ <doc-heading
12
+ header="Attributes"
13
+ hash="attributes"
14
+ aria-level="2"
15
+ id="attributes"
16
+ ></doc-heading>
17
+ <table>
18
+ <thead>
19
+ <tr>
20
+ <th>Name</th>
21
+ <th>Description</th>
22
+ <th>Type</th>
23
+ <th>Default</th>
24
+ <th>Required</th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <template for:each={attributes} for:item="attribute">
29
+ <tr key={attribute.name}>
30
+ <td>
31
+ <span class="code">
32
+ {attribute.nameInKebabCase}
33
+ </span>
34
+ </td>
35
+ <td>{attribute.description}</td>
36
+ <td>{attribute.type}</td>
37
+ <td>{attribute.default}</td>
38
+ <td class="icon-cell">
39
+ <template lwc:if={attribute.required}>
40
+ <dx-icon
41
+ symbol="success"
42
+ size="large"
43
+ color="green-vibrant-65"
44
+ class="icon"
45
+ ></dx-icon>
46
+ </template>
47
+ </td>
48
+ </tr>
49
+ </template>
50
+ </tbody>
51
+ </table>
52
+ </template>
53
+
54
+ <template lwc:if={hasMethods}>
55
+ <doc-heading
56
+ header="Methods"
57
+ hash="methods"
58
+ aria-level="2"
59
+ id="methods"
60
+ ></doc-heading>
61
+ <table>
62
+ <thead>
63
+ <tr>
64
+ <th>Name</th>
65
+ <th>Description</th>
66
+ <th>Argument Name</th>
67
+ <th>Argument Type</th>
68
+ <th>Argument Description</th>
69
+ </tr>
70
+ </thead>
71
+ <tbody>
72
+ <template for:each={processedMethods} for:item="method">
73
+ <template lwc:if={method.firstArgument}>
74
+ <tr key={method.name}>
75
+ <td rowspan={method.arguments.length}>
76
+ <span class="code">
77
+ {method.nameInKebabCase}
78
+ </span>
79
+ </td>
80
+ <td rowspan={method.arguments.length}>
81
+ {method.description}
82
+ </td>
83
+ <td class={method.cssForMultipleArguments}>
84
+ {method.firstArgument.name}
85
+ </td>
86
+ <td>{method.firstArgument.type}</td>
87
+ <td>{method.firstArgument.description}</td>
88
+ </tr>
89
+ <template
90
+ for:each={method.remainingArguments}
91
+ for:item="arg"
92
+ >
93
+ <tr key={arg.name}>
94
+ <td>{arg.name}</td>
95
+ <td>{arg.type}</td>
96
+ <td>{arg.description}</td>
97
+ </tr>
98
+ </template>
99
+ </template>
100
+ <template lwc:else>
101
+ <tr key={method.name}>
102
+ <td>
103
+ <span class="code">
104
+ {method.nameInKebabCase}
105
+ </span>
106
+ </td>
107
+ <td>{method.description}</td>
108
+ <td colspan="3"></td>
109
+ </tr>
110
+ </template>
111
+ </template>
112
+ </tbody>
113
+ </table>
114
+ </template>
115
+
116
+ <template lwc:if={hasSlots}>
117
+ <doc-heading
118
+ header="Slots"
119
+ hash="slots"
120
+ aria-level="2"
121
+ id="slots"
122
+ ></doc-heading>
123
+ <table>
124
+ <thead>
125
+ <tr>
126
+ <th>Name</th>
127
+ <th>Description</th>
128
+ </tr>
129
+ </thead>
130
+ <tbody>
131
+ <template for:each={slots} for:item="slot">
132
+ <tr key={slot.name}>
133
+ <td>
134
+ <span class="code">{slot.nameInKebabCase}</span>
135
+ </td>
136
+ <td>{slot.description}</td>
137
+ </tr>
138
+ </template>
139
+ </tbody>
140
+ </table>
141
+ </template>
142
+
143
+ <template lwc:if={hasEvents}>
144
+ <doc-heading
145
+ header="Events"
146
+ hash="events"
147
+ aria-level="2"
148
+ ></doc-heading>
149
+ <table>
150
+ <thead>
151
+ <tr>
152
+ <th>Name</th>
153
+ <th>Description</th>
154
+ </tr>
155
+ </thead>
156
+ <tbody>
157
+ <template for:each={events} for:item="event">
158
+ <tr key={event.name}>
159
+ <td>
160
+ <span class="code">
161
+ {event.nameInKebabCase}
162
+ </span>
163
+ </td>
164
+ <td>{event.description}</td>
165
+ </tr>
166
+ </template>
167
+ </tbody>
168
+ </table>
169
+ </template>
170
+ </div>
171
+ </template>
@@ -0,0 +1,127 @@
1
+ import { LightningElement, track, api } from "lwc";
2
+ import { Method, Specification } from "typings/custom";
3
+ import debounce from "debounce";
4
+
5
+ const CX_ROUTER_API: string = "/cx-router/components";
6
+ export default class SpecificationContent extends LightningElement {
7
+ @track data: any;
8
+
9
+ @api component!: string;
10
+ @api model!: string;
11
+ @api namespace!: string;
12
+
13
+ isLoading: boolean = true;
14
+ showError: boolean = false;
15
+
16
+ private attributes: Specification[] = [];
17
+ private methods: Method[] = [];
18
+ private slots: Specification[] = [];
19
+ private events: Specification[] = [];
20
+
21
+ /* TODO: For now setting the timeout to 300ms,
22
+ * post integration with CX-Router API will test and change if required.
23
+ */
24
+ private debouncedNotifyDataRendered = debounce(() => {
25
+ this.notifySpecificationDataRendered();
26
+ }, 300);
27
+
28
+ connectedCallback() {
29
+ this.fetchComponentMetadata();
30
+ }
31
+
32
+ async fetchComponentMetadata() {
33
+ const componentQueryParams = {
34
+ model: this.model,
35
+ namespace: this.namespace,
36
+ component: this.component
37
+ };
38
+
39
+ const queryString = new URLSearchParams(
40
+ componentQueryParams
41
+ ).toString();
42
+ const url = `${CX_ROUTER_API}?${queryString}`;
43
+
44
+ try {
45
+ const response = await fetch(url);
46
+
47
+ if (!response.ok) {
48
+ // TODO: Will add loader and show error as follow-up
49
+ throw new Error(`Failed to fetch: ${response.statusText}`);
50
+ }
51
+
52
+ const result = await response.json();
53
+
54
+ // Due to middleware the data is sent as part of response now.
55
+ this.data = result?.response;
56
+ if (this.data) {
57
+ ({
58
+ attributes: this.attributes,
59
+ methods: this.methods,
60
+ slots: this.slots,
61
+ events: this.events
62
+ } = this.data);
63
+ }
64
+ } catch (error) {
65
+ this.data = {};
66
+ this.showError = true;
67
+ console.error("fetchComponentMetadata() failed:", error);
68
+ } finally {
69
+ this.isLoading = false;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * This getter is to preprocess the methods for easier rendering in the template.
75
+ * Each method is augmented with additional properties:
76
+ * - `firstArgument`: The first argument (if any).
77
+ * - `remainingArguments`: All other arguments (if any).
78
+ * - `hasArguments`: A boolean indicating whether the method has arguments or not.
79
+ */
80
+ get processedMethods(): Method[] {
81
+ return this.methods.map((method) => {
82
+ const [firstArgument, ...remainingArguments] =
83
+ method.arguments || [];
84
+ return {
85
+ ...method,
86
+ firstArgument,
87
+ remainingArguments,
88
+ hasArguments: method.arguments && method.arguments.length > 0,
89
+ cssForMultipleArguments:
90
+ remainingArguments.length > 0 ? "left-border" : ""
91
+ };
92
+ });
93
+ }
94
+
95
+ get hasAttributes() {
96
+ return this.attributes?.length > 0;
97
+ }
98
+
99
+ get hasMethods() {
100
+ return this.methods?.length > 0;
101
+ }
102
+
103
+ get hasSlots() {
104
+ return this.slots?.length > 0;
105
+ }
106
+
107
+ get hasEvents() {
108
+ return this.events?.length > 0;
109
+ }
110
+
111
+ renderedCallback(): void {
112
+ if (this.data) {
113
+ this.debouncedNotifyDataRendered();
114
+ }
115
+ }
116
+
117
+ notifySpecificationDataRendered() {
118
+ // Dispatch a custom event to notify the specification tab has rendered.
119
+ this.dispatchEvent(
120
+ new CustomEvent("specificationdatarendered", {
121
+ detail: { name: "doc-specification-content" },
122
+ bubbles: true,
123
+ composed: true
124
+ })
125
+ );
126
+ }
127
+ }
@@ -0,0 +1,20 @@
1
+ <template lwc:render-mode="light">
2
+ <dx-hr no-padding spacing="md"></dx-hr>
3
+ <div class="survey-container">
4
+ <div class="text-container">
5
+ <b>DID THIS ARTICLE SOLVE YOUR ISSUE?</b>
6
+ <br />
7
+ Let us know so we can improve!
8
+ </div>
9
+ <div class="btn-container">
10
+ <dx-button
11
+ variant="secondary"
12
+ aria-label="Share Your Feedback"
13
+ onclick={openSurvey}
14
+ >
15
+ Share your feedback
16
+ </dx-button>
17
+ </div>
18
+ </div>
19
+ <dx-hr no-padding spacing="md"></dx-hr>
20
+ </template>
@@ -0,0 +1,16 @@
1
+ :host .survey-container {
2
+ align-items: center;
3
+ align-content: center;
4
+ width: 100%;
5
+ display: flex;
6
+ flex-direction: row;
7
+ margin: 20px 0;
8
+ }
9
+
10
+ dx-hr:first-of-type::part(hr) {
11
+ margin-top: var(--dx-g-spacing-2xl);
12
+ }
13
+
14
+ .text-container {
15
+ width: 100%;
16
+ }
@@ -0,0 +1,16 @@
1
+ import { LightningElement } from "lwc";
2
+ import cx from "classnames";
3
+
4
+ declare const Sprig: (eventType: string, eventNme: string) => void;
5
+
6
+ export default class Phase extends LightningElement {
7
+ static renderMode = "light";
8
+
9
+ get className() {
10
+ return cx("container");
11
+ }
12
+
13
+ openSurvey() {
14
+ Sprig("track", "ProvideFeedback");
15
+ }
16
+ }