@salesforcedevs/docs-components 1.30.0 → 1.30.1-docs-alpha

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/contentMedia",
19
19
  "doc/docXmlContent",
20
20
  "doc/lwcContentLayout",
21
+ "doc/unifiedContentLayout",
21
22
  "doc/header",
22
23
  "doc/heading",
23
24
  "doc/headingAnchor",
package/package.json CHANGED
@@ -1,29 +1,29 @@
1
1
  {
2
- "name": "@salesforcedevs/docs-components",
3
- "version": "1.30.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": "f3e8e2c6ae6c8792b316e41021344648d4a07bec"
29
- }
2
+ "name": "@salesforcedevs/docs-components",
3
+ "version": "1.30.1-docs-alpha",
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
+ }
@@ -73,16 +73,7 @@ export default class AmfReference extends LightningElement {
73
73
  return this.isSpecBasedReference(this._currentReferenceId);
74
74
  }
75
75
 
76
- /**
77
- * Content action toolbar is only enabled for markdown-based references in the en-us locale.
78
- */
79
- get showContentActionToolbar(): boolean {
80
- if (this.showSpecBasedReference) {
81
- return false;
82
- }
83
- const locale = this.language?.toLowerCase() ?? "en-us";
84
- return locale === "en-us";
85
- }
76
+ @api showContentActionToolbar = false;
86
77
 
87
78
  @api
88
79
  get referenceSetConfig(): ReferenceSetConfig {
@@ -37,7 +37,7 @@ type ReferenceConfig = {
37
37
  const SCROLL_THROTTLE_DELAY = 50;
38
38
  const ELEMENT_TIMEOUT = 10000;
39
39
  const ELEMENT_CHECK_INTERVAL = 100;
40
- const REFERENCES_SEGMENT = "/references/";
40
+ const DEFAULT_PROJECT_TITLE = "All Reference";
41
41
 
42
42
  export default class RedocReference extends LightningElement {
43
43
  private _referenceConfig: ReferenceConfig = { refList: [] };
@@ -91,19 +91,60 @@ export default class RedocReference extends LightningElement {
91
91
  * Project title (same value passed to `<doc-header>` as `subtitle`). Used
92
92
  * inside the Redoc-rendered UI to label the parent project.
93
93
  */
94
- @api projectTitle: string | null = "All Reference";
94
+ @api
95
+ get projectTitle(): string | null {
96
+ return this.isDocContentType
97
+ ? this._projectTitle
98
+ : DEFAULT_PROJECT_TITLE;
99
+ }
100
+ set projectTitle(value: string | null) {
101
+ this._projectTitle = value;
102
+ }
103
+ private _projectTitle: string | null = null;
104
+
105
+ /**
106
+ * Href to navigate to when the back link is clicked AND there is no
107
+ * usable referrer (e.g. the user opened the page directly in a fresh
108
+ * tab).
109
+ */
110
+ @api headerHref: string | null = null;
111
+
112
+ @api
113
+ get contentType(): string {
114
+ return this._contentType;
115
+ }
116
+ set contentType(value: string) {
117
+ this._contentType = value;
118
+ }
119
+ private _contentType: string = "";
95
120
 
96
121
  get specTitle(): string | null {
97
122
  return this.getSelectedReference()?.title ?? null;
98
123
  }
99
124
 
125
+ get isDocContentType(): boolean {
126
+ return this.contentType === "docs";
127
+ }
128
+
129
+ get isReferenceContentType(): boolean {
130
+ return this.contentType === "references";
131
+ }
132
+
133
+ get isMultiSpecSet(): boolean {
134
+ const refCount = this.referenceConfig?.refList?.length ?? 0;
135
+ return refCount > 1;
136
+ }
137
+
100
138
  /**
101
- * Whether to show the project header (only for multi-spec reference sets).
139
+ * Whether to show the project header. Shown for multi-spec reference
140
+ * sets, and for any docs-content spec topic so it always has a back
141
+ * link.
102
142
  */
103
143
  get showRedocHeader(): boolean {
104
- const refCount = this._referenceConfig?.refList?.length ?? 0;
105
- const isMultiSpecSet = refCount > 1;
106
- return isMultiSpecSet && !!(this.projectTitle || this.specTitle);
144
+ return (
145
+ (this.isReferenceContentType && this.isMultiSpecSet) ||
146
+ this.isDocContentType
147
+ );
107
148
  }
108
149
 
109
150
  /**
@@ -114,11 +155,8 @@ export default class RedocReference extends LightningElement {
114
155
  const referrerHref = this.getSameOriginReferrerHref();
115
156
  if (referrerHref) {
116
157
  window.location.href = referrerHref;
117
- return;
118
- }
119
- const fallbackHref = this.getReferencesRootHref();
120
- if (fallbackHref) {
121
- window.location.href = fallbackHref;
158
+ } else if (this.headerHref) {
159
+ window.location.href = this.headerHref;
122
160
  }
123
161
  };
124
162
 
@@ -143,19 +181,6 @@ export default class RedocReference extends LightningElement {
143
181
  }
144
182
  }
145
183
 
146
- /**
147
- * Derives the project's `.../references` root from the current URL by
148
- * trimming any trailing reference id (and deeper segments). Returns null
149
- * when the URL doesn't contain a `/references` segment.
150
- */
151
- private getReferencesRootHref(): string | null {
152
- const { pathname } = window.location;
153
- const idx = pathname.lastIndexOf(REFERENCES_SEGMENT);
154
- return idx === -1
155
- ? null
156
- : pathname.slice(0, idx + REFERENCES_SEGMENT.length);
157
- }
158
-
159
184
  /** When origin is provided, pass it to the footer; otherwise use dx-footer's default. */
160
185
  get effectiveFooterOrigin(): string {
161
186
  return (
@@ -0,0 +1,19 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ .content-type-docs doc-phase {
6
+ --doc-c-phase-top: calc(
7
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
8
+ var(--dx-g-spacing-xl)
9
+ );
10
+ }
11
+
12
+ @media screen and (max-width: 768px) {
13
+ .content-type-docs doc-phase {
14
+ --doc-c-phase-top: calc(
15
+ var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
16
+ 40px
17
+ );
18
+ }
19
+ }
@@ -0,0 +1,28 @@
1
+ <template>
2
+ <doc-content-layout
3
+ class="content-type content-type-markdown content-type-docs"
4
+ breadcrumbs={breadcrumbs}
5
+ share-title={shareTitle}
6
+ share-twitter-via={twitterVia}
7
+ sidebar-header={sidebarHeader}
8
+ sidebar-value={sidebarValue}
9
+ sidebar-content={sidebarContent}
10
+ toc-title={tocTitle}
11
+ toc-options={tocOptions}
12
+ toc-aria-level={tocAriaLevel}
13
+ enable-slot-change="true"
14
+ languages={languages}
15
+ language={language}
16
+ show-footer={enableFooter}
17
+ origin={origin}
18
+ dev-center={devCenter}
19
+ brand={brand}
20
+ >
21
+ <doc-phase
22
+ slot="doc-phase"
23
+ lwc:if={docPhaseInfo}
24
+ doc-phase-info={docPhaseInfo}
25
+ ></doc-phase>
26
+ <slot></slot>
27
+ </doc-content-layout>
28
+ </template>
@@ -0,0 +1,87 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { toJson } from "dxUtils/normalizers";
3
+ import type { OptionWithLink, TreeNode } from "typings/custom";
4
+
5
+ /**
6
+ * Per-topic type emitted by the docs content-type parser
7
+ * (see @salesforcedevs/sfdocs-doc-framework: `TopicTypeEnum`). Only `spec`
8
+ * is meaningful inside this component; everything else renders as a plain
9
+ * markdown-style tile.
10
+ */
11
+ const TOPIC_TYPE_SPEC = "spec";
12
+
13
+ /**
14
+ * Translates per-topic `topicType` into the generic `showForwardArrow` flag
15
+ * that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
16
+ */
17
+ function decorateTopicsWithForwardArrow(
18
+ topics: Array<TreeNode & { topicType?: string }> | undefined
19
+ ): TreeNode[] | undefined {
20
+ return topics?.map((topic) => {
21
+ const { topicType, ...decorated } = topic;
22
+ if (topicType === TOPIC_TYPE_SPEC) {
23
+ decorated.showForwardArrow = true;
24
+ }
25
+ if (decorated.children) {
26
+ decorated.children = decorateTopicsWithForwardArrow(
27
+ decorated.children
28
+ );
29
+ }
30
+ return decorated;
31
+ });
32
+ }
33
+
34
+ /**
35
+ * Wrapper around `doc-content-layout` for the "docs" content type emitted by
36
+ * the `DocsContentTypeParser`.
37
+ */
38
+ export default class UnifiedContentLayout extends LightningElement {
39
+ @api breadcrumbs: string | null = null;
40
+ @api sidebarHeader?: string;
41
+ @api sidebarValue?: string;
42
+ @api tocTitle?: string;
43
+ @api tocOptions?: string;
44
+ @api tocAriaLevel?: string;
45
+ @api languages?: OptionWithLink[];
46
+ @api language?: string;
47
+ @api devCenter: any = null;
48
+ @api brand: any = null;
49
+
50
+ /** Optional origin URL for the footer MFE (e.g. wp-json endpoint). */
51
+ @api origin: string | null = null;
52
+
53
+ /** Article name from breadcrumbs, used as share title (e.g. for social share). */
54
+ @api shareTitle: string | null = null;
55
+
56
+ /** Optional Twitter "via" handle (e.g. SalesforceDevs) for social share. */
57
+ @api twitterVia: string | null = null;
58
+
59
+ @api hideFooter = false;
60
+
61
+ private _docPhaseInfo: string | null = null;
62
+ private _sidebarContent: unknown = null;
63
+
64
+ @api
65
+ get docPhaseInfo(): string | null {
66
+ return this._docPhaseInfo;
67
+ }
68
+
69
+ set docPhaseInfo(value: string | null) {
70
+ this._docPhaseInfo = value || null;
71
+ }
72
+
73
+ @api
74
+ get sidebarContent(): unknown {
75
+ return this._sidebarContent;
76
+ }
77
+
78
+ set sidebarContent(value: string) {
79
+ this._sidebarContent = decorateTopicsWithForwardArrow(
80
+ toJson(value)?.topics
81
+ );
82
+ }
83
+
84
+ private get enableFooter(): boolean {
85
+ return !this.hideFooter;
86
+ }
87
+ }
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.