@salesforcedevs/docs-components 1.30.1-docs-alpha → 1.30.1-locale-picker
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.30.1-
|
|
3
|
+
"version": "1.30.1-locale-picker",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,5 +25,6 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
|
|
29
|
+
"stableVersion": "1.30.1"
|
|
29
30
|
}
|
|
@@ -3,9 +3,12 @@ import { createElement, LightningElement, api } from "lwc";
|
|
|
3
3
|
import DocPhase from "doc/phase";
|
|
4
4
|
import DxFooter from "dx/footer";
|
|
5
5
|
import DxIcon from "dx/icon";
|
|
6
|
+
import SidebarFooterNav from "dx/sidebarFooterNav";
|
|
6
7
|
import SprigSurvey from "doc/sprigSurvey";
|
|
7
8
|
import { throttle } from "throttle-debounce";
|
|
8
9
|
import { pollUntil } from "dxUtils/async";
|
|
10
|
+
import { toJson } from "dxUtils/normalizers";
|
|
11
|
+
import type { OptionWithLink } from "typings/custom";
|
|
9
12
|
|
|
10
13
|
declare global {
|
|
11
14
|
interface Window {
|
|
@@ -47,6 +50,8 @@ export default class RedocReference extends LightningElement {
|
|
|
47
50
|
private docHeaderElement: Element | null = null;
|
|
48
51
|
private docPhaseWrapperElement: Element | null = null;
|
|
49
52
|
private lastSidebarTop = 0;
|
|
53
|
+
private _languages: OptionWithLink[] = [];
|
|
54
|
+
private langValuePath: string = "id";
|
|
50
55
|
|
|
51
56
|
/**
|
|
52
57
|
* History length captured at mount (pre-Redoc), used by `onBackClick` to
|
|
@@ -118,6 +123,17 @@ export default class RedocReference extends LightningElement {
|
|
|
118
123
|
}
|
|
119
124
|
private _contentType: string = "";
|
|
120
125
|
|
|
126
|
+
@api
|
|
127
|
+
get languages(): OptionWithLink[] {
|
|
128
|
+
return this._languages;
|
|
129
|
+
}
|
|
130
|
+
set languages(value: string | OptionWithLink[]) {
|
|
131
|
+
this._languages = toJson(value) || [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Currently selected locale, matched against `langValuePath`. */
|
|
135
|
+
@api language: string | null = null;
|
|
136
|
+
|
|
121
137
|
get specTitle(): string | null {
|
|
122
138
|
return this.getSelectedReference()?.title ?? null;
|
|
123
139
|
}
|
|
@@ -135,6 +151,14 @@ export default class RedocReference extends LightningElement {
|
|
|
135
151
|
return refCount > 1;
|
|
136
152
|
}
|
|
137
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Only for the docs content type and when more than one localized
|
|
156
|
+
* spec is available
|
|
157
|
+
*/
|
|
158
|
+
get hasLocalePicker(): boolean {
|
|
159
|
+
return this.isDocContentType && this.languages.length > 1;
|
|
160
|
+
}
|
|
161
|
+
|
|
138
162
|
/**
|
|
139
163
|
* Whether to show the project header. Shown for multi-spec reference
|
|
140
164
|
* sets, and for any docs-content spec topic so it always has a back
|
|
@@ -450,6 +474,33 @@ export default class RedocReference extends LightningElement {
|
|
|
450
474
|
target.firstChild
|
|
451
475
|
);
|
|
452
476
|
});
|
|
477
|
+
|
|
478
|
+
// Locale picker
|
|
479
|
+
if (this.hasLocalePicker) {
|
|
480
|
+
const menuContent = redocContainer.querySelector(".menu-content");
|
|
481
|
+
menuContent?.appendChild(this.buildLocalePickerDom());
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Builds the locale picker DOM by reusing `dx-sidebar-footer-nav`
|
|
487
|
+
*/
|
|
488
|
+
private buildLocalePickerDom(): HTMLElement {
|
|
489
|
+
const wrapper = document.createElement("div");
|
|
490
|
+
wrapper.className = "redoc-footer-nav";
|
|
491
|
+
|
|
492
|
+
const picker = createElement("dx-sidebar-footer-nav", {
|
|
493
|
+
is: SidebarFooterNav
|
|
494
|
+
});
|
|
495
|
+
|
|
496
|
+
Object.assign(picker, {
|
|
497
|
+
languages: this.languages,
|
|
498
|
+
language: this.language,
|
|
499
|
+
langValuePath: this.langValuePath
|
|
500
|
+
});
|
|
501
|
+
wrapper.appendChild(picker);
|
|
502
|
+
|
|
503
|
+
return wrapper;
|
|
453
504
|
}
|
|
454
505
|
|
|
455
506
|
/**
|
|
@@ -44,8 +44,6 @@ export default class UnifiedContentLayout extends LightningElement {
|
|
|
44
44
|
@api tocAriaLevel?: string;
|
|
45
45
|
@api languages?: OptionWithLink[];
|
|
46
46
|
@api language?: string;
|
|
47
|
-
@api devCenter: any = null;
|
|
48
|
-
@api brand: any = null;
|
|
49
47
|
|
|
50
48
|
/** Optional origin URL for the footer MFE (e.g. wp-json endpoint). */
|
|
51
49
|
@api origin: string | null = null;
|