@salesforcedevs/docs-components 0.56.2 → 0.56.3-example

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 (80) hide show
  1. package/lwc.config.json +10 -2
  2. package/package.json +19 -13
  3. package/src/modules/doc/{amfReference/utils.ts → amfModelParser/amfModelParser.ts} +10 -5
  4. package/src/modules/doc/amfReference/amfReference.css +23 -3
  5. package/src/modules/doc/amfReference/amfReference.html +42 -21
  6. package/src/modules/doc/amfReference/amfReference.ts +1022 -341
  7. package/src/modules/doc/amfReference/constants.ts +76 -0
  8. package/src/modules/doc/amfReference/types.ts +45 -13
  9. package/src/modules/doc/amfTopic/amfTopic.css +20 -0
  10. package/src/modules/doc/amfTopic/amfTopic.ts +35 -18
  11. package/src/modules/doc/amfTopic/types.ts +15 -13
  12. package/src/modules/doc/amfTopic/utils.ts +12 -6
  13. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +2 -1
  14. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +1 -1
  15. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +22 -0
  16. package/src/modules/doc/breadcrumbs/breadcrumbs.css +9 -1
  17. package/src/modules/doc/breadcrumbs/breadcrumbs.html +44 -34
  18. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +62 -23
  19. package/src/modules/doc/componentPlayground/componentPlayground.css +22 -0
  20. package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
  21. package/src/modules/doc/componentPlayground/componentPlayground.ts +42 -0
  22. package/src/modules/doc/content/content.css +70 -76
  23. package/src/modules/doc/content/content.html +1 -0
  24. package/src/modules/doc/content/content.ts +26 -47
  25. package/src/modules/doc/contentCallout/contentCallout.css +15 -7
  26. package/src/modules/doc/contentCallout/contentCallout.html +13 -4
  27. package/src/modules/doc/contentCallout/contentCallout.ts +14 -2
  28. package/src/modules/doc/contentLayout/contentLayout.css +1 -100
  29. package/src/modules/doc/contentLayout/contentLayout.html +30 -17
  30. package/src/modules/doc/contentLayout/contentLayout.ts +354 -65
  31. package/src/modules/doc/doDont/doDont.css +47 -0
  32. package/src/modules/doc/doDont/doDont.html +27 -0
  33. package/src/modules/doc/doDont/doDont.ts +17 -0
  34. package/src/modules/doc/header/header.css +65 -36
  35. package/src/modules/doc/header/header.html +41 -139
  36. package/src/modules/doc/header/header.ts +54 -76
  37. package/src/modules/doc/heading/heading.css +16 -37
  38. package/src/modules/doc/heading/heading.html +4 -4
  39. package/src/modules/doc/heading/heading.ts +12 -10
  40. package/src/modules/doc/headingAnchor/headingAnchor.css +2 -2
  41. package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
  42. package/src/modules/doc/headingContent/headingContent.css +6 -8
  43. package/src/modules/doc/headingContent/headingContent.html +9 -15
  44. package/src/modules/doc/headingContent/headingContent.ts +2 -14
  45. package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +1 -0
  46. package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +68 -0
  47. package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +256 -0
  48. package/src/modules/doc/overview/overview.css +40 -0
  49. package/src/modules/doc/overview/overview.html +34 -0
  50. package/src/modules/doc/overview/overview.ts +12 -0
  51. package/src/modules/doc/phase/phase.css +18 -3
  52. package/src/modules/doc/phase/phase.html +15 -3
  53. package/src/modules/doc/phase/phase.ts +44 -8
  54. package/src/modules/doc/specificationContent/specificationContent.css +36 -0
  55. package/src/modules/doc/specificationContent/specificationContent.html +167 -0
  56. package/src/modules/doc/specificationContent/specificationContent.ts +127 -0
  57. package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
  58. package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
  59. package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
  60. package/src/modules/doc/toc/toc.ts +1 -1
  61. package/src/modules/doc/versionPicker/versionPicker.css +64 -0
  62. package/src/modules/doc/versionPicker/versionPicker.html +38 -0
  63. package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
  64. package/src/modules/doc/xmlContent/types.ts +12 -3
  65. package/src/modules/doc/xmlContent/utils.ts +17 -12
  66. package/src/modules/doc/xmlContent/xmlContent.css +32 -3
  67. package/src/modules/doc/xmlContent/xmlContent.html +41 -15
  68. package/src/modules/doc/xmlContent/xmlContent.ts +295 -95
  69. package/src/modules/docHelpers/amfStyle/amfStyle.css +10 -45
  70. package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +131 -0
  71. package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
  72. package/src/modules/docHelpers/status/status.css +1 -1
  73. package/src/modules/docUtils/{SearchSyncer/SearchSyncer.ts → searchSyncer/searchSyncer.ts} +1 -0
  74. package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
  75. package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
  76. package/src/modules/docUtils/utils/utils.ts +32 -0
  77. package/LICENSE +0 -12
  78. package/src/modules/doc/amfReference/route-meta.ts +0 -22
  79. package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +0 -93
  80. package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +0 -39
@@ -2,16 +2,12 @@ import { LightningElement, api } from "lwc";
2
2
  import cx from "classnames";
3
3
 
4
4
  import { DocPhaseInfo } from "typings/custom";
5
- import { toJson } from "dxUtils/normalizers";
5
+ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
6
 
7
7
  export default class Phase extends LightningElement {
8
8
  _docPhaseInfo: DocPhaseInfo | null = null;
9
-
10
- isBodyHidden = false;
11
-
12
- get docPhaseTitle() {
13
- return this.docPhaseInfo?.title;
14
- }
9
+ _dismissible = false;
10
+ _iconName = "recipe";
15
11
 
16
12
  @api
17
13
  get docPhaseInfo(): DocPhaseInfo | null {
@@ -22,6 +18,34 @@ export default class Phase extends LightningElement {
22
18
  this._docPhaseInfo = toJson(value);
23
19
  }
24
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
+
25
49
  get hideBodyText() {
26
50
  return this.isBodyHidden ? "Show" : "Hide";
27
51
  }
@@ -51,7 +75,19 @@ export default class Phase extends LightningElement {
51
75
  }
52
76
  }
53
77
 
54
- onButtonClick() {
78
+ onShowHide() {
55
79
  this.isBodyHidden = !this.isBodyHidden;
56
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
+ }
57
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,167 @@
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">{method.name}</span>
77
+ </td>
78
+ <td rowspan={method.arguments.length}>
79
+ {method.description}
80
+ </td>
81
+ <td class={method.cssForMultipleArguments}>
82
+ {method.firstArgument.name}
83
+ </td>
84
+ <td>{method.firstArgument.type}</td>
85
+ <td>{method.firstArgument.description}</td>
86
+ </tr>
87
+ <template
88
+ for:each={method.remainingArguments}
89
+ for:item="arg"
90
+ >
91
+ <tr key={arg.name}>
92
+ <td>{arg.name}</td>
93
+ <td>{arg.type}</td>
94
+ <td>{arg.description}</td>
95
+ </tr>
96
+ </template>
97
+ </template>
98
+ <template lwc:else>
99
+ <tr key={method.name}>
100
+ <td>
101
+ <span class="code">{method.name}</span>
102
+ </td>
103
+ <td>{method.description}</td>
104
+ <td colspan="3"></td>
105
+ </tr>
106
+ </template>
107
+ </template>
108
+ </tbody>
109
+ </table>
110
+ </template>
111
+
112
+ <template lwc:if={hasSlots}>
113
+ <doc-heading
114
+ header="Slots"
115
+ hash="slots"
116
+ aria-level="2"
117
+ id="slots"
118
+ ></doc-heading>
119
+ <table>
120
+ <thead>
121
+ <tr>
122
+ <th>Name</th>
123
+ <th>Description</th>
124
+ </tr>
125
+ </thead>
126
+ <tbody>
127
+ <template for:each={slots} for:item="slot">
128
+ <tr key={slot.name}>
129
+ <td>
130
+ <span class="code">{slot.nameInKebabCase}</span>
131
+ </td>
132
+ <td>{slot.description}</td>
133
+ </tr>
134
+ </template>
135
+ </tbody>
136
+ </table>
137
+ </template>
138
+
139
+ <template lwc:if={hasEvents}>
140
+ <doc-heading
141
+ header="Events"
142
+ hash="events"
143
+ aria-level="2"
144
+ ></doc-heading>
145
+ <table>
146
+ <thead>
147
+ <tr>
148
+ <th>Name</th>
149
+ <th>Description</th>
150
+ </tr>
151
+ </thead>
152
+ <tbody>
153
+ <template for:each={events} for:item="event">
154
+ <tr key={event.name}>
155
+ <td>
156
+ <span class="code">
157
+ {event.nameInKebabCase}
158
+ </span>
159
+ </td>
160
+ <td>{event.description}</td>
161
+ </tr>
162
+ </template>
163
+ </tbody>
164
+ </table>
165
+ </template>
166
+ </div>
167
+ </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
+ }
@@ -11,7 +11,7 @@ export default class Toc extends LightningElement {
11
11
  const newPageReference = { ...this.pageReference };
12
12
  // When moving to the new navigation component
13
13
  //const target = event.detail.name.split('-')
14
- const target = event.currentTarget.dataset.id.split("-");
14
+ const target = (event.currentTarget as any).dataset.id.split("-");
15
15
  newPageReference.contentDocumentId = target[0] + ".htm";
16
16
  newPageReference.hash = target[1];
17
17
  this.dispatchEvent(
@@ -0,0 +1,64 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ /* NOTE: doc-version-picker-width width variable is used by both dx-button and dx-dropdown to maintain a consistent width. */
4
+ :host {
5
+ --dx-c-dropdown-option-font-weight: normal;
6
+ --dx-c-dropdown-option-label-color: var(--dx-g-gray-10);
7
+ --popover-container-open-transform: translateY(4px);
8
+ }
9
+
10
+ .version-picker-container {
11
+ padding: 8px var(--dx-g-spacing-lg) 8px
12
+ var(--dx-g-global-header-padding-horizontal);
13
+ border-top: 1px solid var(--dx-g-gray-90);
14
+ border-bottom: 1px solid var(--dx-g-gray-90);
15
+ }
16
+
17
+ .version-picker-button {
18
+ display: flex;
19
+ width: var(--doc-version-picker-width, 296px);
20
+ }
21
+
22
+ .version-picker-button:hover,
23
+ .version-picker-button:active,
24
+ .version-picker-button:focus {
25
+ --dx-c-button-secondary-color-hover: var(--dx-g-cloud-blue-vibrant-95);
26
+ --dx-c-button-primary-color: var(--dx-g-blue-vibrant-40);
27
+ }
28
+
29
+ /**
30
+ * NOTE: This CSS ensures the span inside the button stays within the parent's width, avoiding overflow.
31
+ * Not keeping this in common component to ensure that existing functionality works as it is.
32
+ */
33
+ dx-button::part(content) {
34
+ width: inherit;
35
+ overflow: hidden;
36
+ }
37
+
38
+ .selected-version {
39
+ display: flex;
40
+ flex-direction: row;
41
+ align-items: center;
42
+ }
43
+
44
+ .selected-version-label {
45
+ flex: 1;
46
+ overflow: hidden;
47
+ text-align: left;
48
+ text-overflow: ellipsis;
49
+ white-space: nowrap;
50
+ }
51
+
52
+ dx-type-badge.latest-badge {
53
+ --dx-c-type-badge-color: var(--dx-g-green-vibrant-40);
54
+ --dx-c-type-badge-background: var(--dx-g-green-vibrant-95);
55
+
56
+ margin-left: var(--dx-g-spacing-sm);
57
+ }
58
+
59
+ dx-type-badge.not-latest-badge {
60
+ --dx-c-type-badge-color: var(--dx-g-red-vibrant-40);
61
+ --dx-c-type-badge-background: var(--dx-g-red-vibrant-95);
62
+
63
+ margin-left: var(--dx-g-spacing-sm);
64
+ }
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <div lwc:if={showVersionPicker} class="version-picker-container">
3
+ <dx-dropdown
4
+ options={versions}
5
+ value={selectedVersion.id}
6
+ width="var(--doc-version-picker-width)"
7
+ onchange={onVersionChange}
8
+ >
9
+ <dx-button
10
+ class="version-picker-button"
11
+ variant="tertiary"
12
+ size="small"
13
+ icon-symbol="chevrondown"
14
+ icon-size="medium"
15
+ >
16
+ <div class="selected-version">
17
+ <p class="selected-version-label">
18
+ {selectedVersion.label}
19
+ </p>
20
+ <template lwc:if={showLatestTag}>
21
+ <dx-type-badge
22
+ class="latest-badge"
23
+ lwc:if={latestVersion}
24
+ value="Latest"
25
+ size="small"
26
+ ></dx-type-badge>
27
+ <dx-type-badge
28
+ class="not-latest-badge"
29
+ lwc:else
30
+ value="Not Latest"
31
+ size="small"
32
+ ></dx-type-badge>
33
+ </template>
34
+ </div>
35
+ </dx-button>
36
+ </dx-dropdown>
37
+ </div>
38
+ </template>
@@ -0,0 +1,65 @@
1
+ import { LightningElement, api, track } from "lwc";
2
+
3
+ import { AnalyticsPayload, OptionWithNested } from "typings/custom";
4
+
5
+ import { toJson, normalizeBoolean } from "dxUtils/normalizers";
6
+
7
+ export default class VersionPicker extends LightningElement {
8
+ @api analyticsEvent?: string;
9
+ @api analyticsPayload?: AnalyticsPayload;
10
+
11
+ @track private _versions!: OptionWithNested[];
12
+ private _selectedVersion?: OptionWithNested;
13
+ private _latestVersion: boolean = false;
14
+ private _hideBadge: boolean = false;
15
+
16
+ @api
17
+ get versions() {
18
+ return this._versions;
19
+ }
20
+
21
+ set versions(value: OptionWithNested[]) {
22
+ this._versions = toJson(value);
23
+ }
24
+
25
+ @api
26
+ get selectedVersion(): OptionWithNested | undefined {
27
+ return this._selectedVersion || this.versions[0];
28
+ }
29
+
30
+ set selectedVersion(value: OptionWithNested) {
31
+ if (value) {
32
+ this._selectedVersion = toJson(value);
33
+ }
34
+ }
35
+
36
+ @api
37
+ get latestVersion() {
38
+ return this._latestVersion;
39
+ }
40
+
41
+ set latestVersion(value) {
42
+ this._latestVersion = normalizeBoolean(value);
43
+ }
44
+
45
+ @api
46
+ get hideBadge() {
47
+ return this._hideBadge;
48
+ }
49
+
50
+ set hideBadge(value) {
51
+ this._hideBadge = normalizeBoolean(value);
52
+ }
53
+
54
+ private get showVersionPicker() {
55
+ return this._versions && this._versions.length !== 0;
56
+ }
57
+
58
+ private get showLatestTag(): boolean {
59
+ return !this.hideBadge;
60
+ }
61
+
62
+ private onVersionChange(e: CustomEvent) {
63
+ this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
64
+ }
65
+ }
@@ -24,6 +24,7 @@ export type TreeNode = {
24
24
  name: string;
25
25
  children?: Array<TreeNode>;
26
26
  isExpanded?: boolean;
27
+ parent?: TreeNode;
27
28
  };
28
29
 
29
30
  type DropdownOption = {
@@ -34,6 +35,9 @@ type DropdownOption = {
34
35
  export type DocVersion = DropdownOption & {
35
36
  releaseVersion: string;
36
37
  url: string;
38
+ link?: {
39
+ href: string;
40
+ };
37
41
  };
38
42
 
39
43
  export type DocLanguage = DropdownOption & {
@@ -57,12 +61,15 @@ export type ApiDocLanguage = {
57
61
 
58
62
  export interface Header extends Element {
59
63
  subtitle: string;
64
+ headerHref: string;
65
+ }
66
+
67
+ export type SiderbarFooter = {
60
68
  bailHref: string;
61
69
  bailLabel: string;
62
70
  languages: Array<DocLanguage>;
63
- language: string;
64
- headerHref: string;
65
- }
71
+ language?: string;
72
+ };
66
73
 
67
74
  export type ApiNavItem = {
68
75
  children: Array<ApiNavItem>;
@@ -109,3 +116,5 @@ export type ContentApiOptions = {
109
116
  version: string;
110
117
  language: string;
111
118
  };
119
+
120
+ export type TocMap = { [key: string]: TreeNode };