@salesforcedevs/docs-components 1.34.0 → 1.40.0-docs-feedback-3

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 CHANGED
@@ -1,29 +1,30 @@
1
1
  {
2
- "name": "@salesforcedevs/docs-components",
3
- "version": "1.34.0",
4
- "description": "Docs Lightning web components for DSC",
5
- "license": "MIT",
6
- "main": "index.js",
7
- "engines": {
8
- "node": "22.x"
9
- },
10
- "publishConfig": {
11
- "access": "public"
12
- },
13
- "dependencies": {
14
- "@api-components/amf-helper-mixin": "4.5.29",
15
- "classnames": "2.5.1",
16
- "dompurify": "3.2.4",
17
- "kagekiri": "1.4.2",
18
- "lodash.orderby": "4.6.0",
19
- "lodash.uniqby": "4.7.0",
20
- "query-string": "7.1.3",
21
- "sentence-case": "3.0.4"
22
- },
23
- "devDependencies": {
24
- "@types/classnames": "2.3.1",
25
- "@types/lodash.orderby": "4.6.9",
26
- "@types/lodash.uniqby": "4.7.9"
27
- },
28
- "gitHead": "db75cd19dd7a77fe4e09856439c4905c32e64d1f"
29
- }
2
+ "name": "@salesforcedevs/docs-components",
3
+ "version": "1.40.0-docs-feedback-3",
4
+ "description": "Docs Lightning web components for DSC",
5
+ "license": "MIT",
6
+ "main": "index.js",
7
+ "engines": {
8
+ "node": "22.x"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "dependencies": {
14
+ "@api-components/amf-helper-mixin": "4.5.29",
15
+ "classnames": "2.5.1",
16
+ "dompurify": "3.2.4",
17
+ "kagekiri": "1.4.2",
18
+ "lodash.orderby": "4.6.0",
19
+ "lodash.uniqby": "4.7.0",
20
+ "query-string": "7.1.3",
21
+ "sentence-case": "3.0.4"
22
+ },
23
+ "devDependencies": {
24
+ "@types/classnames": "2.3.1",
25
+ "@types/lodash.orderby": "4.6.9",
26
+ "@types/lodash.uniqby": "4.7.9"
27
+ },
28
+ "gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
29
+ "stableVersion": "1.34.0"
30
+ }
@@ -74,6 +74,13 @@ export default class Header extends HeaderBase {
74
74
  return (this.hideDocHeader && !this.mobile) || this.showDocDivider;
75
75
  }
76
76
 
77
+ private get isDocsPath(): boolean {
78
+ return (
79
+ window.location.pathname.includes("/docs/") &&
80
+ window.location.pathname !== "/docs/apis"
81
+ );
82
+ }
83
+
77
84
  connectedCallback(): void {
78
85
  super.connectedCallback();
79
86
  this.tabletMatchMedia = window.matchMedia(
@@ -83,9 +90,7 @@ export default class Header extends HeaderBase {
83
90
  this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
84
91
 
85
92
  if (
86
- (!this.shouldHideHeader &&
87
- window.location.pathname.includes("/docs/") &&
88
- window.location.pathname !== "/docs/apis") ||
93
+ (!this.shouldHideHeader && this.isDocsPath) ||
89
94
  window.location.pathname ===
90
95
  "/tableau/embedding-playground/overview" ||
91
96
  isStorybook()
@@ -109,6 +114,12 @@ export default class Header extends HeaderBase {
109
114
  );
110
115
  }
111
116
 
117
+ renderedCallback(): void {
118
+ if (this.hideDocHeader) {
119
+ this.shouldRender = !this.shouldHideHeader && this.isDocsPath;
120
+ }
121
+ }
122
+
112
123
  private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
113
124
  (this.tablet = e.matches);
114
125
 
@@ -10,11 +10,38 @@ import type { OptionWithLink, TreeNode } from "typings/custom";
10
10
  */
11
11
  const TOPIC_TYPE_SPEC = "spec";
12
12
 
13
+ /**
14
+ * Walks down the first-child chain and returns the first markdown content
15
+ * page found, descending through nested content-less parents. Returns
16
+ * undefined if the chain breaks on a spec or external link before reaching a
17
+ * content page.
18
+ */
19
+ function firstChildContentPage(node: TreeNode): TreeNode | undefined {
20
+ const firstChild = node.children?.[0];
21
+ if (!firstChild) {
22
+ return undefined;
23
+ }
24
+
25
+ const isSpec =
26
+ (firstChild as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
27
+ const isExternal = firstChild.link?.target === "_blank";
28
+ if (isSpec || isExternal) {
29
+ return undefined;
30
+ }
31
+
32
+ if (firstChild.link?.href) {
33
+ return firstChild;
34
+ }
35
+
36
+ return firstChildContentPage(firstChild);
37
+ }
38
+
13
39
  /**
14
40
  * Translates per-topic `topicType` into the generic `showForwardArrow` flag
15
- * that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
41
+ * that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc),
42
+ * and redirects content-less parent topics whose first child is a content page
16
43
  */
17
- function decorateTopicsWithForwardArrow(
44
+ function decorateTopics(
18
45
  topics: Array<TreeNode & { topicType?: string }> | undefined
19
46
  ): TreeNode[] | undefined {
20
47
  return topics?.map((topic) => {
@@ -23,10 +50,23 @@ function decorateTopicsWithForwardArrow(
23
50
  decorated.showForwardArrow = true;
24
51
  }
25
52
  if (decorated.children) {
26
- decorated.children = decorateTopicsWithForwardArrow(
27
- decorated.children
28
- );
53
+ decorated.children = decorateTopics(decorated.children);
29
54
  }
55
+
56
+ /** Redirect a parent that has no content of its own to its first child
57
+ * but only when that first child is itself a content page
58
+ */
59
+ const isContentlessParent =
60
+ !!decorated.children?.length && !decorated.link?.href;
61
+
62
+ if (isContentlessParent) {
63
+ decorated.redirectToChild = true;
64
+ const firstChild = firstChildContentPage(topic);
65
+ if (firstChild?.link) {
66
+ decorated.link = { ...firstChild.link };
67
+ }
68
+ }
69
+
30
70
  return decorated;
31
71
  });
32
72
  }
@@ -77,9 +117,7 @@ export default class UnifiedContentLayout extends LightningElement {
77
117
  }
78
118
 
79
119
  set sidebarContent(value: string) {
80
- this._sidebarContent = decorateTopicsWithForwardArrow(
81
- toJson(value)?.topics
82
- );
120
+ this._sidebarContent = decorateTopics(toJson(value)?.topics);
83
121
  }
84
122
 
85
123
  private get enableFooter(): boolean {
package/LICENSE DELETED
@@ -1,12 +0,0 @@
1
- Copyright (c) 2020, Salesforce.com, Inc.
2
- All rights reserved.
3
-
4
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
-
6
- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
-
8
- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
-
10
- * Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
-
12
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.