@salesforcedevs/docs-components 0.56.2-seo-test16 → 0.57.0

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.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Represents the URL reference meta on Reference page.
3
+ * Contains information on selected Reference ID, Topic ID, and Topic Type
4
+ * separated by ":"
5
+ */
6
+ export class RouteMeta {
7
+ meta: string;
8
+ referenceId = "";
9
+ topicId = "";
10
+ type = "";
11
+
12
+ constructor(meta: string) {
13
+ this.meta = meta;
14
+
15
+ if (meta && meta.includes(":")) {
16
+ const [referenceId, type, topicId] = meta.split(":");
17
+ this.referenceId = referenceId;
18
+ this.topicId = topicId || type;
19
+ this.type = type;
20
+ }
21
+ }
22
+ }
@@ -2,7 +2,6 @@ import { Json } from "typings/custom";
2
2
 
3
3
  export interface AmfTopicType {
4
4
  referenceId: string;
5
- parentReferencePath: string;
6
5
  amfId: string;
7
6
  elementId: string;
8
7
  type: string;
@@ -11,7 +10,6 @@ export interface AmfTopicType {
11
10
  export interface AmfMetadataTopic extends AmfTopicType {
12
11
  meta: string;
13
12
  identifier: string;
14
- navTitle?: string;
15
13
  }
16
14
 
17
15
  export interface AmfMetaTopicType extends AmfTopicType {
@@ -55,37 +53,11 @@ export type DocPhaseEntry = {
55
53
  body: string;
56
54
  };
57
55
 
58
- export type ReferenceType = "markdown" | "rest-raml" | "rest-oa2" | "rest-oa3";
59
-
60
- /**
61
- * Represents parsed topic for the sidebar.
62
- */
63
- export interface ParsedMarkdownTopic {
64
- label: string;
65
- name: string;
66
- children: ParsedMarkdownTopic[];
67
- link?: {
68
- href: string;
69
- target?: string;
70
- };
71
- }
72
-
73
- export interface AmfConfig {
56
+ export interface AmfConfig extends AmfModelRecord {
74
57
  id: string;
58
+ amf: string;
75
59
  version?: string;
76
60
  docPhase?: DocPhaseEntry;
77
- title: string;
78
- href: string;
79
- referenceType: ReferenceType;
80
-
81
- // determines if a reference config is the current active and selected one.
82
- isSelected: boolean;
83
-
84
- // required for spec based references
85
- amf?: string;
86
-
87
- // required for markdown based references
88
- topic?: ParsedMarkdownTopic;
89
61
  }
90
62
 
91
63
  export interface ParsedTopicModel {
@@ -112,22 +84,10 @@ export interface ReferenceVersion {
112
84
  label: string;
113
85
  deprecated?: boolean;
114
86
  selected?: boolean;
115
- link: {
116
- href: string;
117
- };
118
87
  }
119
88
 
120
89
  export interface ReferenceSetConfig {
121
- refId?: string;
122
90
  versionToRefMap?: Map<string, Array<AmfConfig>>;
123
91
  refList: Array<AmfConfig>;
124
- versions: Array<ReferenceVersion>;
125
- }
126
-
127
- export interface RouteMeta {
128
- meta: string;
129
- referenceId: string;
130
- topicId: string;
131
- //type is only for spec based references
132
- type?: string;
92
+ versions?: Array<ReferenceVersion>;
133
93
  }
@@ -1,5 +1,5 @@
1
1
  <template>
2
2
  <dx-icon if:true={isBackArrowVariant} symbol="back"></dx-icon>
3
- <a if:true={href} href={href}>{label}</a>
3
+ <a if:true={href} href={href} onclick={onLinkClick}>{label}</a>
4
4
  <span if:false={href}>{label}</span>
5
5
  </template>
@@ -1,5 +1,6 @@
1
+ import { track } from "dxUtils/analytics";
1
2
  import { LightningElement, api } from "lwc";
2
- import { BreadcrumbItemVariant } from "typings/custom";
3
+ import { AnalyticsPayload, BreadcrumbItemVariant } from "typings/custom";
3
4
 
4
5
  const BREADCRUMB_LONG = "breadcrumb_long";
5
6
  const BREADCRUMB_BACK_ARROW = "breadcrumb_back-arrow";
@@ -7,6 +8,8 @@ const BREADCRUMB_BACK_ARROW = "breadcrumb_back-arrow";
7
8
  const LONG_LABEL_NUMBER = 30;
8
9
  export default class BreadcrumbItem extends LightningElement {
9
10
  @api href?: string;
11
+ @api analyticsEvent!: string;
12
+ @api analyticsBasePayload!: AnalyticsPayload;
10
13
 
11
14
  @api
12
15
  get label() {
@@ -46,4 +49,17 @@ export default class BreadcrumbItem extends LightningElement {
46
49
  private get isBackArrowVariant(): boolean {
47
50
  return this._variant === "back-arrow";
48
51
  }
52
+
53
+ private onLinkClick(event: Event): void {
54
+ if (!this.analyticsEvent) {
55
+ return;
56
+ }
57
+
58
+ track(event.target!, this.analyticsEvent, {
59
+ ...this.analyticsBasePayload,
60
+ clickText: this.label,
61
+ itemTitle: this.label,
62
+ pageLocation: window.location.pathname
63
+ });
64
+ }
49
65
  }
@@ -9,7 +9,6 @@
9
9
  nav {
10
10
  display: flex;
11
11
  align-items: center;
12
- height: 100%;
13
12
  position: relative;
14
13
  gap: var(--dx-g-spacing-sm);
15
14
  }
@@ -17,3 +16,10 @@ nav {
17
16
  .breadcrumb-item_slash {
18
17
  min-width: fit-content;
19
18
  }
19
+
20
+ dx-dropdown {
21
+ --dx-c-dropdown-option-font-size: var(--dx-g-text-sm);
22
+ --dx-c-dropdown-option-label-color: var(
23
+ --dx-c-breadcrumbs-breadcrumb-color
24
+ );
25
+ }
@@ -3,6 +3,8 @@
3
3
  <template if:false={renderSmallVariant}>
4
4
  <template if:true={renderFirstCrumb}>
5
5
  <doc-breadcrumb-item
6
+ analytics-event={analyticsEventName}
7
+ analytics-base-payload={analyticsBasePayload}
6
8
  href={firstCrumb.href}
7
9
  label={firstCrumb.label}
8
10
  ></doc-breadcrumb-item>
@@ -11,10 +13,14 @@
11
13
  <template if:true={renderDropdown}>
12
14
  <dx-dropdown
13
15
  if:true={renderDropdown}
16
+ analytics-event={analyticsEventName}
17
+ analytics-base-payload={analyticsBasePayload}
14
18
  options={dropdownOptions}
15
19
  open-on-hover
16
20
  placement="bottom"
17
- width="200px"
21
+ suppress-gtm-nav-headings
22
+ variant="indented"
23
+ width="fit-content"
18
24
  >
19
25
  <dx-button
20
26
  aria-label="Open Breadcrumbs Dropdown"
@@ -27,6 +33,8 @@
27
33
  </template>
28
34
  <template for:each={breadcrumbItems} for:item="breadcrumb">
29
35
  <doc-breadcrumb-item
36
+ analytics-event={analyticsEventName}
37
+ analytics-base-payload={analyticsBasePayload}
30
38
  href={breadcrumb.href}
31
39
  key={breadcrumb.label}
32
40
  label={breadcrumb.label}
@@ -39,6 +47,8 @@
39
47
  </template>
40
48
  <template if:true={renderSmallVariant}>
41
49
  <doc-breadcrumb-item
50
+ analytics-event={analyticsEventName}
51
+ analytics-base-payload={analyticsBasePayload}
42
52
  href={lastLinkCrump.href}
43
53
  label={lastLinkCrump.label}
44
54
  variant="back-arrow"
@@ -15,6 +15,13 @@ const CONSTANTS = {
15
15
  dropdownWidth: 32
16
16
  };
17
17
 
18
+ export const ANALYTICS_EVENT_NAME = "custEv_breadcrumbClick";
19
+ export const ANALYTICS_BASE_PAYLOAD = {
20
+ elementType: "breadcrumb",
21
+ locationOnPage: "breadcrumb",
22
+ ctaClick: true
23
+ };
24
+
18
25
  export default class Breadcrumbs extends LightningElement {
19
26
  @api ariaLabel: string = "Documentation Breadcrumbs";
20
27
 
@@ -84,6 +91,14 @@ export default class Breadcrumbs extends LightningElement {
84
91
  return this.breadcrumbs[this.breadcrumbs.length - 1];
85
92
  }
86
93
 
94
+ private get analyticsEventName() {
95
+ return ANALYTICS_EVENT_NAME;
96
+ }
97
+
98
+ private get analyticsBasePayload() {
99
+ return ANALYTICS_BASE_PAYLOAD;
100
+ }
101
+
87
102
  renderedCallback(): void {
88
103
  if (!this.observer) {
89
104
  this.observer = new ResizeObserver((entries) => {
@@ -20,7 +20,6 @@ const HIGHLIGHTABLE_SELECTOR = [
20
20
  "th",
21
21
  "td"
22
22
  ].join(",");
23
- const OBSERVER_ATTACH_WAIT_TIME = 500;
24
23
 
25
24
  export default class ContentLayout extends LightningElement {
26
25
  @api sidebarValue: string;
@@ -96,8 +95,6 @@ export default class ContentLayout extends LightningElement {
96
95
  target: window
97
96
  });
98
97
  private tocValue?: string = undefined;
99
- private observerTimerId = null;
100
- private didScrollToSelectedHash = false;
101
98
 
102
99
  get showToc(): boolean {
103
100
  return this.tocOptions && this.tocOptions.length > 0;
@@ -122,18 +119,6 @@ export default class ContentLayout extends LightningElement {
122
119
  }
123
120
  }
124
121
 
125
- renderedCallback(): void {
126
- /**
127
- * Note: We are adding timeout because chrome is optimizing and not triggering recent renderedCallback though elements reference is changed
128
- * Also we are considering recent renderedCallback
129
- */
130
- this.clearRenderObserverTimer();
131
- this.observerTimerId = setTimeout(
132
- this.attachInteractionObserver,
133
- OBSERVER_ATTACH_WAIT_TIME
134
- );
135
- }
136
-
137
122
  disconnectedCallback(): void {
138
123
  this.disconnectObserver();
139
124
  window.removeEventListener(
@@ -141,25 +126,19 @@ export default class ContentLayout extends LightningElement {
141
126
  this.updateHighlighted
142
127
  );
143
128
  this.searchSyncer.dispose();
144
- this.clearRenderObserverTimer();
145
129
  }
146
130
 
147
- clearRenderObserverTimer = () => {
148
- if (this.observerTimerId) {
149
- clearTimeout(this.observerTimerId);
150
- }
151
- };
152
-
153
131
  updateHighlighted = (event: Event): void =>
154
132
  highlightTerms(
155
133
  this.querySelectorAll(HIGHLIGHTABLE_SELECTOR),
156
134
  (event as CustomEvent<string>).detail
157
135
  );
158
136
 
159
- attachInteractionObserver = (): void => {
137
+ onSlotChange(event: Event): void {
160
138
  if (!this.enableSlotChange) {
161
139
  return;
162
140
  }
141
+
163
142
  this.disconnectObserver();
164
143
  this.observer = new IntersectionObserver((entries) => {
165
144
  entries.forEach(
@@ -171,54 +150,30 @@ export default class ContentLayout extends LightningElement {
171
150
  this.calculateActualSection();
172
151
  });
173
152
 
174
- // Note: We are doing document.querySelectorAll as a quick fix as we are not getting heading elements reference this.querySelectorAll
175
- const headingElements = document.querySelectorAll(TOC_HEADER_TAG);
176
- for (const headingElement of headingElements) {
177
- // Add headingElements to intersectionObserver for highlighting respective RNB item when user scroll
178
- const id = headingElement.getAttribute("id");
153
+ const anchoredTags = (event.target as HTMLSlotElement)
154
+ .assignedElements()
155
+ .filter(({ tagName }) => tagName === TOC_HEADER_TAG)
156
+ .map((tag) => {
157
+ tag.id = tag.hash;
158
+ return tag;
159
+ });
160
+
161
+ this._tocOptions = anchoredTags.map((tag) => ({
162
+ anchor: `#${tag.hash}`,
163
+ id: tag.id,
164
+ label: tag.title
165
+ }));
166
+
167
+ this.scrollToHash(anchoredTags);
168
+
169
+ anchoredTags.forEach((section) => {
170
+ const id = section.getAttribute("id");
179
171
  this.anchoredElements[id] = {
180
172
  id,
181
173
  intersect: false
182
174
  };
183
- this.observer.observe(headingElement);
184
- }
185
- if (!this.didScrollToSelectedHash) {
186
- this.didScrollToSelectedHash = true;
187
- this.scrollToHash(headingElements);
188
- }
189
- };
190
-
191
- onSlotChange(event: Event): void {
192
- const slotElements = (
193
- event.target as HTMLSlotElement
194
- ).assignedElements();
195
-
196
- if (slotElements.length) {
197
- const slotContentElement = slotElements[0];
198
- const headingElements =
199
- slotContentElement.ownerDocument?.getElementsByTagName(
200
- TOC_HEADER_TAG
201
- );
202
- for (const headingElement of headingElements) {
203
- // Sometimes elements hash is not being set when slot content is wrapped with div
204
- headingElement.hash =
205
- headingElement.attributes.hash?.nodeValue;
206
- }
207
- const tocOptions = [];
208
- for (const headingElement of headingElements) {
209
- headingElement.id = headingElement.hash;
210
-
211
- // Update tocOptions from anchorTags
212
- const tocItem = {
213
- anchor: `#${headingElement.hash}`,
214
- id: headingElement.id,
215
- label: headingElement.title
216
- };
217
- tocOptions.push(tocItem);
218
- }
219
-
220
- this._tocOptions = tocOptions;
221
- }
175
+ this.observer.observe(section);
176
+ });
222
177
  }
223
178
 
224
179
  private disconnectObserver(): void {
@@ -228,16 +183,16 @@ export default class ContentLayout extends LightningElement {
228
183
  }
229
184
  }
230
185
 
231
- // eslint-disable-next-line no-undef
232
- private scrollToHash(headingElements: NodeListOf<Element>): void {
186
+ private scrollToHash(anchoredTags: Array<Element>): void {
233
187
  let { hash } = window.location;
188
+
234
189
  if (hash) {
235
190
  hash = hash.substr(1);
236
- for (const headingElement of headingElements) {
237
- if (headingElement.getAttribute("id") === hash) {
238
- headingElement.scrollIntoView({ behavior: "auto" });
239
- break;
240
- }
191
+ const toScrollElement = anchoredTags.find(
192
+ (element) => element.getAttribute("id") === hash
193
+ );
194
+ if (toScrollElement) {
195
+ toScrollElement.scrollIntoView({ behavior: "auto" });
241
196
  }
242
197
  }
243
198
  }
@@ -1,76 +0,0 @@
1
- const NAVIGATION_ITEMS = [
2
- {
3
- label: "Summary",
4
- name: "summary",
5
- childrenPropertyName: undefined,
6
- type: "summary"
7
- },
8
- {
9
- label: "Endpoints",
10
- name: "endpoints",
11
- childrenPropertyName: "endpoints",
12
- type: "endpoint"
13
- },
14
- {
15
- label: "Documentation",
16
- name: "documentation",
17
- childrenPropertyName: "docs",
18
- type: "documentation"
19
- },
20
- {
21
- label: "Types",
22
- name: "types",
23
- childrenPropertyName: "types",
24
- type: "type"
25
- },
26
- {
27
- label: "Security",
28
- name: "security",
29
- childrenPropertyName: "security",
30
- type: "security"
31
- }
32
- ];
33
-
34
- const URL_CONFIG = {
35
- summary: {
36
- urlIdentifer: "label"
37
- },
38
- endpoint: {
39
- urlIdentifer: "path"
40
- },
41
- method: {
42
- urlIdentifer: "label"
43
- },
44
- documentation: {
45
- urlIdentifer: "label"
46
- },
47
- type: {
48
- urlIdentifer: "label",
49
- prefix: "type:"
50
- },
51
- security: {
52
- urlIdentifer: "label",
53
- prefix: "security:"
54
- }
55
- };
56
-
57
- export const REFERENCE_TYPES = {
58
- markdown: "markdown",
59
- raml: "rest-raml",
60
- oa2: "rest-oa2",
61
- oa3: "rest-oa3"
62
- };
63
-
64
- const oldReferenceIdNewReferenceIdMap: Record<string, string> = {
65
- "commerce-api-assignments": "assignments",
66
- "commerce-api-campaigns": "campaigns",
67
- "commerce-api-catalogs": "catalogs",
68
- "cdn-zones": "cdn-api-process-apis",
69
- "inventory-impex": "impex",
70
- "inventory-reservations": "inventory-reservation-service",
71
- "shopper-login-and-api-access-service": "shopper-login",
72
- "shopper-login-and-api-access-service-admin": "slas-admin",
73
- "einstein-recommendations": "einstein-api-quick-start-guide"
74
- };
75
-
76
- export { NAVIGATION_ITEMS, URL_CONFIG, oldReferenceIdNewReferenceIdMap };