@salesforcedevs/docs-components 0.0.0 → 0.0.1-superscript
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 +12 -2
- package/package.json +29 -27
- package/src/modules/doc/{amfReference/utils.ts → amfModelParser/amfModelParser.ts} +10 -5
- package/src/modules/doc/amfReference/amfReference.css +11 -3
- package/src/modules/doc/amfReference/amfReference.html +35 -26
- package/src/modules/doc/amfReference/amfReference.ts +239 -95
- package/src/modules/doc/amfReference/types.ts +3 -11
- package/src/modules/doc/amfTopic/amfTopic.css +20 -0
- package/src/modules/doc/amfTopic/amfTopic.ts +59 -18
- package/src/modules/doc/amfTopic/types.ts +15 -13
- package/src/modules/doc/amfTopic/utils.ts +12 -6
- package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +17 -10
- package/src/modules/doc/breadcrumbs/breadcrumbs.html +6 -9
- package/src/modules/doc/breadcrumbs/breadcrumbs.ts +30 -34
- package/src/modules/doc/componentPlayground/componentPlayground.css +30 -0
- package/src/modules/doc/componentPlayground/componentPlayground.html +20 -0
- package/src/modules/doc/componentPlayground/componentPlayground.ts +97 -0
- package/src/modules/doc/content/content.css +70 -76
- package/src/modules/doc/content/content.html +1 -0
- package/src/modules/doc/content/content.ts +24 -46
- package/src/modules/doc/contentCallout/contentCallout.css +11 -7
- package/src/modules/doc/contentCallout/contentCallout.html +11 -4
- package/src/modules/doc/contentCallout/contentCallout.ts +8 -1
- package/src/modules/doc/contentLayout/contentLayout.css +1 -98
- package/src/modules/doc/contentLayout/contentLayout.html +46 -31
- package/src/modules/doc/contentLayout/contentLayout.ts +337 -89
- package/src/modules/doc/contentMedia/contentMedia.css +1 -1
- package/src/modules/doc/doDont/doDont.css +47 -0
- package/src/modules/doc/doDont/doDont.html +27 -0
- package/src/modules/doc/doDont/doDont.ts +17 -0
- package/src/modules/doc/header/header.css +65 -36
- package/src/modules/doc/header/header.html +44 -138
- package/src/modules/doc/header/header.ts +62 -74
- package/src/modules/doc/heading/heading.css +16 -37
- package/src/modules/doc/heading/heading.html +4 -4
- package/src/modules/doc/heading/heading.ts +12 -10
- package/src/modules/doc/headingAnchor/headingAnchor.css +2 -2
- package/src/modules/doc/headingAnchor/headingAnchor.ts +2 -2
- package/src/modules/doc/headingContent/headingContent.css +1 -1
- package/src/modules/doc/headingContent/headingContent.html +2 -2
- package/src/modules/doc/headingContent/headingContent.ts +2 -2
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.css +9 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +64 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +269 -0
- package/src/modules/doc/overview/overview.css +40 -0
- package/src/modules/doc/overview/overview.html +34 -0
- package/src/modules/doc/overview/overview.ts +12 -0
- package/src/modules/doc/phase/phase.css +11 -3
- package/src/modules/doc/phase/phase.html +12 -2
- package/src/modules/doc/phase/phase.ts +44 -8
- package/src/modules/doc/redocReference/redocReference.css +7 -0
- package/src/modules/doc/redocReference/redocReference.html +13 -0
- package/src/modules/doc/redocReference/redocReference.ts +425 -0
- package/src/modules/doc/specificationContent/specificationContent.css +36 -0
- package/src/modules/doc/specificationContent/specificationContent.html +177 -0
- package/src/modules/doc/specificationContent/specificationContent.ts +166 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.html +20 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.scoped.css +16 -0
- package/src/modules/doc/sprigSurvey/sprigSurvey.ts +16 -0
- package/src/modules/doc/superscriptSubscript/superscriptSubscript.html +8 -0
- package/src/modules/doc/superscriptSubscript/superscriptSubscript.ts +16 -0
- package/src/modules/doc/toc/toc.html +1 -3
- package/src/modules/doc/toc/toc.ts +1 -1
- package/src/modules/doc/toolbar/toolbar.ts +6 -6
- package/src/modules/doc/versionPicker/versionPicker.css +64 -0
- package/src/modules/doc/versionPicker/versionPicker.html +40 -0
- package/src/modules/doc/versionPicker/versionPicker.ts +65 -0
- package/src/modules/doc/xmlContent/types.ts +9 -3
- package/src/modules/doc/xmlContent/utils.ts +3 -1
- package/src/modules/doc/xmlContent/xmlContent.css +16 -4
- package/src/modules/doc/xmlContent/xmlContent.html +36 -21
- package/src/modules/doc/xmlContent/xmlContent.ts +295 -120
- package/src/modules/docHelpers/amfStyle/amfStyle.css +6 -8
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +162 -0
- package/src/modules/docHelpers/imgStyle/imgStyle.css +59 -0
- package/src/modules/docHelpers/status/status.css +1 -1
- package/src/modules/docUtils/{SearchSyncer/SearchSyncer.ts → searchSyncer/searchSyncer.ts} +1 -0
- package/src/modules/docUtils/utils/__mocks__/coveo.analytics.ts +16 -0
- package/src/modules/docUtils/utils/coveo.analytics.d.ts +10 -0
- package/src/modules/docUtils/utils/utils.ts +32 -0
- package/LICENSE +0 -12
- package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +0 -93
- package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +0 -39
|
@@ -166,16 +166,14 @@ api-security-documentation {
|
|
|
166
166
|
--anypoint-button-emphasis-high-active-background-color: transparent;
|
|
167
167
|
|
|
168
168
|
/* api example */
|
|
169
|
-
--api-example-accent-color: rgb(250
|
|
170
|
-
--api-example-background-color: rgb(250
|
|
169
|
+
--api-example-accent-color: rgb(250 250 250);
|
|
170
|
+
--api-example-background-color: rgb(250 250 250);
|
|
171
171
|
--api-example-title-background-color: transparent;
|
|
172
172
|
|
|
173
173
|
/* code snippets */
|
|
174
|
-
--http-code-snippet-container-background-color: rgb(250
|
|
174
|
+
--http-code-snippet-container-background-color: rgb(250 250 250);
|
|
175
175
|
--http-code-snippet-container-padding: var(--dx-g-spacing-md);
|
|
176
176
|
|
|
177
|
-
/* prism */
|
|
178
|
-
|
|
179
177
|
/* --code-operator-value-background-color */
|
|
180
178
|
}
|
|
181
179
|
|
|
@@ -208,7 +206,7 @@ api-endpoint-documentation {
|
|
|
208
206
|
);
|
|
209
207
|
|
|
210
208
|
/* description */
|
|
211
|
-
--api-endpoint-documentation-description-color: rgb(24
|
|
209
|
+
--api-endpoint-documentation-description-color: rgb(24 24 24);
|
|
212
210
|
}
|
|
213
211
|
|
|
214
212
|
api-endpoint-documentation,
|
|
@@ -271,11 +269,11 @@ api-method-documentation {
|
|
|
271
269
|
--api-method-documentation-http-method-label-font-weight: var(
|
|
272
270
|
--dx-g-font-bold
|
|
273
271
|
);
|
|
274
|
-
--api-method-documentation-description-color: rgb(24
|
|
272
|
+
--api-method-documentation-description-color: rgb(24 24 24);
|
|
275
273
|
--api-method-documentation-operation-id-color: var(--dx-g-gray-50);
|
|
276
274
|
|
|
277
275
|
/* body */
|
|
278
|
-
--api-body-document-description-color: rgb(24
|
|
276
|
+
--api-body-document-description-color: rgb(24 24 24);
|
|
279
277
|
--api-body-document-media-type-selector-color: var(--dx-g-blue-vibrant-20);
|
|
280
278
|
--api-body-document-media-type-selector-font-size: var(
|
|
281
279
|
--amf-h8-mod-font-size
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--dx-c-content-vertical-spacing: var(--dx-g-spacing-lg);
|
|
3
|
+
--dx-c-content-sidebar-sticky-top: calc(
|
|
4
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
5
|
+
);
|
|
6
|
+
--dx-c-sidebar-height: calc(
|
|
7
|
+
100vh -
|
|
8
|
+
calc(
|
|
9
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height)
|
|
10
|
+
)
|
|
11
|
+
);
|
|
12
|
+
--dx-c-content-scroll-margin-top: calc(
|
|
13
|
+
var(--dx-g-global-header-height) + var(--dx-g-doc-header-height) +
|
|
14
|
+
var(--dx-g-spacing-2xl)
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
doc-breadcrumbs {
|
|
21
|
+
--dx-c-popover-z-index: 5;
|
|
22
|
+
|
|
23
|
+
display: block;
|
|
24
|
+
margin-bottom: var(--dx-g-spacing-2xl);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.read {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
gap: var(--dx-g-spacing-xs, 8px);
|
|
31
|
+
margin-bottom: var(--dx-g-spacing-lg, 16px);
|
|
32
|
+
color: var(--dx-g-gray-30, #3e3e3c);
|
|
33
|
+
font-size: var(--dx-g-font-size-sm, 14px);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.read svg {
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
dx-sidebar,
|
|
41
|
+
dx-sidebar-old {
|
|
42
|
+
--dx-c-sidebar-vertical-padding: var(--dx-g-spacing-md);
|
|
43
|
+
|
|
44
|
+
z-index: calc(var(--dx-g-z-index-100) + 5);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
dx-toc {
|
|
48
|
+
--dx-c-toc-width: unset;
|
|
49
|
+
|
|
50
|
+
height: calc(100% - var(--dx-c-content-vertical-spacing) * 2);
|
|
51
|
+
margin: var(--dx-c-content-vertical-spacing) 0;
|
|
52
|
+
overflow-y: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
dx-sidebar,
|
|
56
|
+
dx-toc {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* offset page jump link due to fixed header */
|
|
61
|
+
::slotted(doc-heading) {
|
|
62
|
+
scroll-margin-top: var(--dx-c-content-scroll-margin-top);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.content {
|
|
66
|
+
display: flex;
|
|
67
|
+
position: relative;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.content-body-doc-phase-container {
|
|
71
|
+
flex: 1;
|
|
72
|
+
border-left: 1px solid var(--dx-g-gray-90);
|
|
73
|
+
min-width: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.doc-phase-wrapper,
|
|
77
|
+
.version-wrapper {
|
|
78
|
+
/* NOTE: If you are changing z-index value here, ensure it's less than z-index of dx-sidebar in contentLayout.css */
|
|
79
|
+
z-index: var(--dx-g-z-index-100);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.doc-phase-wrapper {
|
|
83
|
+
position: sticky;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* We don't want second component to sticky */
|
|
87
|
+
.version-wrapper {
|
|
88
|
+
position: static;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.content-body-container {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: row;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
max-width: var(--dx-g-doc-content-max-width);
|
|
96
|
+
|
|
97
|
+
/* Derived this manually by substracting (topHeader, doc header, banner and the content). */
|
|
98
|
+
min-height: 62vh;
|
|
99
|
+
margin: auto;
|
|
100
|
+
padding: 0 var(--dx-g-global-header-padding-horizontal);
|
|
101
|
+
margin-bottom: calc(2 * (var(--dx-g-spacing-5xl) + 4px));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.content-body {
|
|
105
|
+
margin: var(--dx-g-spacing-md) 0 0;
|
|
106
|
+
max-width: 1000px;
|
|
107
|
+
flex: 1;
|
|
108
|
+
width: 0;
|
|
109
|
+
word-break: break-word;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.is-sticky {
|
|
113
|
+
align-self: flex-start;
|
|
114
|
+
position: sticky;
|
|
115
|
+
top: var(--dx-c-content-sidebar-sticky-top);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.right-nav-bar {
|
|
119
|
+
margin-left: var(--dx-g-spacing-2xl);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@media screen and (max-width: 1024px) {
|
|
123
|
+
.right-nav-bar {
|
|
124
|
+
display: none;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
@media screen and (max-width: 800px) {
|
|
129
|
+
.content-body {
|
|
130
|
+
margin-top: var(--dx-c-content-vertical-spacing);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.content-body-doc-phase-container {
|
|
134
|
+
border-left: 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@media screen and (max-width: 768px) {
|
|
139
|
+
.is-sticky {
|
|
140
|
+
width: 100%;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.content {
|
|
144
|
+
flex-direction: column;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.content-body-container {
|
|
148
|
+
padding-right: 0;
|
|
149
|
+
padding-left: 0;
|
|
150
|
+
overflow-x: auto;
|
|
151
|
+
margin-bottom: calc(var(--dx-g-spacing-5xl) + 4px);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.left-nav-bar {
|
|
155
|
+
height: unset;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.content-body {
|
|
159
|
+
margin-left: var(--dx-g-spacing-mlg, 20px);
|
|
160
|
+
margin-right: var(--dx-g-spacing-mlg, 20px);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
img.content-image {
|
|
2
|
+
height: auto;
|
|
3
|
+
display: unset;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.image-framed {
|
|
7
|
+
border: 1px solid black;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.image-xxl,
|
|
11
|
+
.image-full {
|
|
12
|
+
max-width: 1000px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.image-xl {
|
|
17
|
+
max-width: 750px;
|
|
18
|
+
width: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.image-lg {
|
|
22
|
+
max-width: 660px;
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.image-md {
|
|
27
|
+
max-width: 500px;
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.image-sm {
|
|
32
|
+
max-width: 330px;
|
|
33
|
+
width: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.image-xs {
|
|
37
|
+
max-width: 250px;
|
|
38
|
+
width: 100%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.image-xxs {
|
|
42
|
+
max-width: 125px;
|
|
43
|
+
width: 100%;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.image-icon-lg {
|
|
47
|
+
max-width: 32px;
|
|
48
|
+
width: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.image-icon-md {
|
|
52
|
+
max-width: 20px;
|
|
53
|
+
width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.image-icon-sm {
|
|
57
|
+
max-width: 16px;
|
|
58
|
+
width: 100%;
|
|
59
|
+
}
|
|
@@ -47,6 +47,7 @@ export class SearchSyncer {
|
|
|
47
47
|
this.handleSearchChange
|
|
48
48
|
);
|
|
49
49
|
this.target.removeEventListener("popstate", this.handlePopState);
|
|
50
|
+
// @ts-ignore
|
|
50
51
|
this.target = undefined;
|
|
51
52
|
this.callbacks.onSearchChange = undefined;
|
|
52
53
|
this.callbacks.onUrlChange = undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class CoveoAnalyticsClient {
|
|
2
|
+
private config: { token: string; endpoint: string };
|
|
3
|
+
|
|
4
|
+
constructor(config: { token: string; endpoint: string }) {
|
|
5
|
+
this.config = config;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
sendViewEvent(event: {
|
|
9
|
+
contentIdKey: string;
|
|
10
|
+
contentType?: string;
|
|
11
|
+
contentIdValue: string;
|
|
12
|
+
}): void {
|
|
13
|
+
// Mock implementation
|
|
14
|
+
console.log("Mock Coveo Analytics event:", event);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module "coveo.analytics/dist/browser.mjs" {
|
|
2
|
+
export class CoveoAnalyticsClient {
|
|
3
|
+
constructor(config: { token: string; endpoint: string });
|
|
4
|
+
sendViewEvent(event: {
|
|
5
|
+
contentIdKey: string;
|
|
6
|
+
contentType?: string;
|
|
7
|
+
contentIdValue: string;
|
|
8
|
+
}): void;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CoveoAnalyticsClient } from "coveo.analytics/dist/browser.mjs"; // This fix is required for Node 20 upgrade, so that Coveo analytics is loaded properly by LWR.
|
|
2
|
+
|
|
3
|
+
export const oldVersionDocInfo = (latestVersionLink: string) => {
|
|
4
|
+
return {
|
|
5
|
+
title: "Newer Version Available",
|
|
6
|
+
body: `This content describes an older version of this product.
|
|
7
|
+
<a style="font-weight: bold;" href="${latestVersionLink}">View Latest</a>`
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export function logCoveoPageView(
|
|
12
|
+
coveoOrganizationId: string | undefined,
|
|
13
|
+
coveoAnalyticsToken: string | undefined
|
|
14
|
+
) {
|
|
15
|
+
if (coveoOrganizationId && coveoAnalyticsToken) {
|
|
16
|
+
const ua = new CoveoAnalyticsClient({
|
|
17
|
+
token: coveoAnalyticsToken,
|
|
18
|
+
endpoint: `https://${coveoOrganizationId}.analytics.org.coveo.com`
|
|
19
|
+
});
|
|
20
|
+
const pathParts = window.location.pathname.split("/");
|
|
21
|
+
let contentType;
|
|
22
|
+
if (pathParts.length >= 2) {
|
|
23
|
+
contentType = pathParts[1];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
ua.sendViewEvent({
|
|
27
|
+
contentIdKey: "@clickableuri",
|
|
28
|
+
contentType: contentType,
|
|
29
|
+
contentIdValue: window.location.href
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
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.
|
|
@@ -1,93 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
doc-phase::part(container) {
|
|
2
|
-
margin-bottom: var(--dx-g-spacing-sm);
|
|
3
|
-
padding-left: var(--dx-g-spacing-mlg);
|
|
4
|
-
padding-right: var(--dx-g-spacing-lg);
|
|
5
|
-
width: auto;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.doc-phase-wrapper {
|
|
9
|
-
position: sticky;
|
|
10
|
-
top: 0;
|
|
11
|
-
z-index: 4;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
@media screen and (max-width: 800px) {
|
|
15
|
-
doc-phase::part(container) {
|
|
16
|
-
margin-bottom: 0;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@media screen and (min-width: 1024px) and (max-width: 1496px) {
|
|
21
|
-
doc-phase::part(container) {
|
|
22
|
-
padding-right: var(--dx-g-spacing-3xl);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
@media screen and (min-width: 1496px) {
|
|
27
|
-
doc-phase::part(container) {
|
|
28
|
-
margin-right: calc(
|
|
29
|
-
var(--dx-g-page-padding-horizontal) - var(--dx-g-spacing-lg)
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@media screen and (max-width: 768px) {
|
|
35
|
-
/* We are giving top value because there is one more sticky item(lnb) with height 40px */
|
|
36
|
-
.doc-phase-wrapper {
|
|
37
|
-
top: 40px;
|
|
38
|
-
}
|
|
39
|
-
}
|