@salesforcedevs/docs-components 1.3.149-canary.1 → 1.3.150-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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.150-alpha",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"kagekiri": "^1.4.1",
|
|
17
17
|
"lodash.orderby": "^4.6.0",
|
|
18
18
|
"lodash.uniqby": "^4.7.0",
|
|
19
|
-
"query-string": "^7.1.
|
|
19
|
+
"query-string": "^7.1.3",
|
|
20
20
|
"sentence-case": "^3.0.4"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -1242,14 +1242,18 @@ export default class AmfReference extends LightningElement {
|
|
|
1242
1242
|
}
|
|
1243
1243
|
if (!isRedirecting) {
|
|
1244
1244
|
const currentReferenceUrl = window.location.href;
|
|
1245
|
+
console.log("currentReferenceUrl", currentReferenceUrl);
|
|
1245
1246
|
const referenceMeta =
|
|
1246
1247
|
this.getMarkdownReferenceMeta(currentReferenceUrl);
|
|
1248
|
+
console.log("referenceMeta", referenceMeta);
|
|
1247
1249
|
const selectedItemRefId =
|
|
1248
1250
|
this.getReferenceIdFromUrl(currentReferenceUrl);
|
|
1251
|
+
console.log("selectedItemRefId", selectedItemRefId);
|
|
1249
1252
|
const referenceDetails = this.getRefDetailsForGivenTopicMeta(
|
|
1250
1253
|
selectedItemRefId,
|
|
1251
1254
|
referenceMeta
|
|
1252
1255
|
);
|
|
1256
|
+
console.log("referenceDtails", referenceDetails);
|
|
1253
1257
|
if (referenceDetails) {
|
|
1254
1258
|
this.updateNavTitleMetaTag(referenceDetails.topicTitle);
|
|
1255
1259
|
}
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
TocMap
|
|
14
14
|
} from "./types";
|
|
15
15
|
import { SearchSyncer } from "docUtils/SearchSyncer";
|
|
16
|
-
import { LightningElementWithState } from "
|
|
16
|
+
import { LightningElementWithState } from "docBaseElements/lightningElementWithState";
|
|
17
17
|
import { oldVersionDocInfo } from "docUtils/utils";
|
|
18
18
|
import { Breadcrumb, DocPhaseInfo, Language } from "typings/custom";
|
|
19
19
|
import { track as trackGTM } from "dxUtils/analytics";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { LightningElement, track } from "lwc";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This is a helper class for when you want your LWC component to have state
|
|
5
|
+
* that is automatically tracked _along with_ its previous state, in a React-
|
|
6
|
+
* like fashion, so that you can compare current state with previous state
|
|
7
|
+
* after a render (like React's `commponentDidUpdate`). One benefit of doing
|
|
8
|
+
* things this way is that you can put all of your reactions to state changes
|
|
9
|
+
* in one place, in `renderedCallback`, rather than having them in various
|
|
10
|
+
* places throughout the component.
|
|
11
|
+
*
|
|
12
|
+
* The API consists in `this.prevState`, `this.state`, and `this.setState`.
|
|
13
|
+
*
|
|
14
|
+
* Usage:
|
|
15
|
+
*
|
|
16
|
+
* ```
|
|
17
|
+
* type MyState = {
|
|
18
|
+
* isFetchingContent: boolean;
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* class MyFetchingComponent extends LightningElementWithState<MyState> {
|
|
22
|
+
* constructor() {
|
|
23
|
+
* // `this.state` can only be initialized once
|
|
24
|
+
* this.state = {
|
|
25
|
+
* isFetchingContent: false
|
|
26
|
+
* };
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* // Queued for execution whenever a `setState` call completes
|
|
30
|
+
* renderedCallback() {
|
|
31
|
+
* if (this.prevState.isFetchingContent && !this.state.isFetchingContent) {
|
|
32
|
+
* // Do something knowing that we just finished fetching.
|
|
33
|
+
* notifyFetchSuccessful();
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
*
|
|
37
|
+
* fetchSomething() {
|
|
38
|
+
* this.setState({
|
|
39
|
+
* isFetchingContent: true
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* fetch(whatever).then(() => {
|
|
43
|
+
* this.setState({
|
|
44
|
+
* isFetching: false
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
* }
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export abstract class LightningElementWithState<
|
|
52
|
+
T extends { [key: string]: unknown }
|
|
53
|
+
> extends LightningElement {
|
|
54
|
+
private _prevState = {} as T;
|
|
55
|
+
@track private _state = {} as T;
|
|
56
|
+
|
|
57
|
+
private _didInitializeState = false;
|
|
58
|
+
|
|
59
|
+
protected get prevState(): T {
|
|
60
|
+
return Object.freeze({
|
|
61
|
+
...this._prevState
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
protected get state(): T {
|
|
66
|
+
return Object.freeze({
|
|
67
|
+
...this._state
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected set state(initialState: T) {
|
|
72
|
+
if (!this._didInitializeState) {
|
|
73
|
+
this._state = {
|
|
74
|
+
...initialState
|
|
75
|
+
};
|
|
76
|
+
this._didInitializeState = true;
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"To mutate state after initialization, use `this.setState`."
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
protected setState = (state: Partial<T>): void => {
|
|
85
|
+
this._prevState = {
|
|
86
|
+
...this._state
|
|
87
|
+
};
|
|
88
|
+
this._state = {
|
|
89
|
+
...this._state,
|
|
90
|
+
...state
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
}
|