@salesforcedevs/docs-components 1.34.3 → 1.34.4-scroll-1
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
2
|
+
"name": "@salesforcedevs/docs-components",
|
|
3
|
+
"version": "1.34.4-scroll-1",
|
|
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.4"
|
|
30
|
+
}
|
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.icon {
|
|
19
|
-
--dx-c-icon-size: var(--dx-g-icon-size-lg);
|
|
20
|
-
|
|
21
19
|
flex-shrink: 0;
|
|
22
20
|
margin-top: var(--dx-g-spacing-smd);
|
|
23
21
|
margin-right: var(--dx-g-spacing-sm);
|
|
@@ -73,6 +71,47 @@
|
|
|
73
71
|
cursor: pointer;
|
|
74
72
|
}
|
|
75
73
|
|
|
74
|
+
/* Centered variant: the message is centered in the banner and the icon hangs
|
|
75
|
+
to its left. The close button is taken out of the flow so it doesn't offset
|
|
76
|
+
the centering. */
|
|
77
|
+
.container_centered {
|
|
78
|
+
position: relative;
|
|
79
|
+
display: grid;
|
|
80
|
+
grid-template-columns: 1fr auto 1fr;
|
|
81
|
+
align-items: center;
|
|
82
|
+
|
|
83
|
+
/* Reserve the close button's width plus its right inset on both sides */
|
|
84
|
+
padding: 0
|
|
85
|
+
calc(
|
|
86
|
+
var(--dx-g-spacing-3xl) + var(--dx-g-spacing-xs) +
|
|
87
|
+
var(--doc-banner-padding-right)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.container_centered .icon {
|
|
92
|
+
grid-column: 1;
|
|
93
|
+
justify-self: end;
|
|
94
|
+
margin-top: 0;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.container_centered .main {
|
|
98
|
+
grid-column: 2;
|
|
99
|
+
align-items: center;
|
|
100
|
+
justify-content: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.container_centered .message {
|
|
104
|
+
text-align: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.container_centered .close {
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 50%;
|
|
110
|
+
right: var(--doc-banner-padding-right);
|
|
111
|
+
margin-left: 0;
|
|
112
|
+
transform: translateY(-50%);
|
|
113
|
+
}
|
|
114
|
+
|
|
76
115
|
@media (max-width: 1279px) {
|
|
77
116
|
:host {
|
|
78
117
|
--doc-banner-padding-left: var(--dx-g-spacing-xl);
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<template lwc:if={showBanner}>
|
|
3
|
-
<div class=
|
|
3
|
+
<div class={containerClass} part="container">
|
|
4
4
|
<dx-icon
|
|
5
5
|
class="icon"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
sprite={iconSprite}
|
|
7
|
+
symbol={iconSymbol}
|
|
8
|
+
size={iconSize}
|
|
9
|
+
color={iconColor}
|
|
9
10
|
part="icon"
|
|
10
11
|
></dx-icon>
|
|
11
12
|
<div class="main">
|
|
12
13
|
<div class="message" part="message" lwc:dom="manual"></div>
|
|
13
|
-
<div class="actions" part="actions">
|
|
14
|
+
<div lwc:if={hasActions} class="actions" part="actions">
|
|
14
15
|
<template lwc:if={hasPrimaryButton}>
|
|
15
16
|
<dx-button
|
|
16
17
|
href={buttonHref}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
|
+
import { IconSize, IconSprite, IconSymbol } from "typings/custom";
|
|
3
|
+
import { normalizeBoolean } from "dxUtils/normalizers";
|
|
2
4
|
|
|
3
5
|
const BANNER_STORAGE_PREFIX = "doc-banner-";
|
|
4
6
|
|
|
@@ -13,6 +15,24 @@ export default class Banner extends LightningElement {
|
|
|
13
15
|
|
|
14
16
|
@api dismissStorageKey = "";
|
|
15
17
|
|
|
18
|
+
@api
|
|
19
|
+
get centered(): boolean {
|
|
20
|
+
return this._centered;
|
|
21
|
+
}
|
|
22
|
+
set centered(value: boolean | string) {
|
|
23
|
+
this._centered = normalizeBoolean(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@api iconSprite: IconSprite = "utility";
|
|
27
|
+
|
|
28
|
+
@api iconSymbol: IconSymbol = "info";
|
|
29
|
+
|
|
30
|
+
@api iconColor = "gray-50";
|
|
31
|
+
|
|
32
|
+
@api iconSize: IconSize = "large";
|
|
33
|
+
|
|
34
|
+
private _centered = false;
|
|
35
|
+
|
|
16
36
|
private _dismissed = false;
|
|
17
37
|
|
|
18
38
|
connectedCallback() {
|
|
@@ -33,10 +53,18 @@ export default class Banner extends LightningElement {
|
|
|
33
53
|
}
|
|
34
54
|
}
|
|
35
55
|
|
|
56
|
+
get containerClass(): string {
|
|
57
|
+
return this._centered ? "container container_centered" : "container";
|
|
58
|
+
}
|
|
59
|
+
|
|
36
60
|
get showBanner(): boolean {
|
|
37
61
|
return !this._dismissed;
|
|
38
62
|
}
|
|
39
63
|
|
|
64
|
+
get hasActions(): boolean {
|
|
65
|
+
return this.hasPrimaryButton || this.hasSecondaryAction;
|
|
66
|
+
}
|
|
67
|
+
|
|
40
68
|
get hasPrimaryButton(): boolean {
|
|
41
69
|
return !!(this.buttonLabel && this.buttonHref);
|
|
42
70
|
}
|
|
@@ -496,8 +496,18 @@ export default class ContentLayout extends LightningElement {
|
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
if (!this.didScrollToSelectedHash) {
|
|
499
|
+
this.tryScrollToHash(headingElements);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Attempts the one-shot hash scroll and marks it complete only if scrolling succeeds,
|
|
505
|
+
* keeping both trigger points consistent.
|
|
506
|
+
*/
|
|
507
|
+
// eslint-disable-next-line no-undef
|
|
508
|
+
protected tryScrollToHash(headingElements: NodeListOf<Element>): void {
|
|
509
|
+
if (this.scrollToHash(headingElements)) {
|
|
499
510
|
this.didScrollToSelectedHash = true;
|
|
500
|
-
this.scrollToHash(headingElements);
|
|
501
511
|
}
|
|
502
512
|
}
|
|
503
513
|
|
|
@@ -585,6 +595,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
585
595
|
this.updateRNB();
|
|
586
596
|
this.updateContentActionToolbar();
|
|
587
597
|
this.contentLoaded = true;
|
|
598
|
+
|
|
599
|
+
if (this.enableSlotChange && !this.didScrollToSelectedHash) {
|
|
600
|
+
this.tryScrollToHash(this.getHeadingElements());
|
|
601
|
+
}
|
|
588
602
|
}
|
|
589
603
|
|
|
590
604
|
protected disconnectObserver(): void {
|
|
@@ -595,7 +609,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
595
609
|
}
|
|
596
610
|
|
|
597
611
|
// eslint-disable-next-line no-undef
|
|
598
|
-
protected scrollToHash(headingElements: NodeListOf<Element>):
|
|
612
|
+
protected scrollToHash(headingElements: NodeListOf<Element>): boolean {
|
|
599
613
|
let { hash } = window.location;
|
|
600
614
|
if (hash) {
|
|
601
615
|
hash = hash.substr(1);
|
|
@@ -610,14 +624,18 @@ export default class ContentLayout extends LightningElement {
|
|
|
610
624
|
"hgf-c360contextnav"
|
|
611
625
|
) as HTMLElement;
|
|
612
626
|
|
|
627
|
+
if (!docHeaderEl || !globalNavEl || !contextNavEl) {
|
|
628
|
+
return false;
|
|
629
|
+
}
|
|
630
|
+
|
|
613
631
|
const headerHeight =
|
|
614
|
-
docHeaderEl
|
|
615
|
-
globalNavEl
|
|
616
|
-
contextNavEl
|
|
632
|
+
(docHeaderEl.offsetHeight || 0) +
|
|
633
|
+
(globalNavEl.offsetHeight || 0) +
|
|
634
|
+
(contextNavEl.offsetHeight || 0);
|
|
617
635
|
|
|
618
636
|
const docPhaseEl = (
|
|
619
637
|
this.template.querySelector("[name=doc-phase]")! as any
|
|
620
|
-
)
|
|
638
|
+
)?.assignedElements?.()[0] as HTMLSlotElement | undefined;
|
|
621
639
|
|
|
622
640
|
const offset = docPhaseEl
|
|
623
641
|
? headerHeight + docPhaseEl.offsetHeight
|
|
@@ -626,10 +644,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
626
644
|
for (const headingElement of headingElements as any) {
|
|
627
645
|
if (headingElement.getAttribute("id") === hash) {
|
|
628
646
|
this.scrollIntoViewWithOffset(headingElement, offset);
|
|
629
|
-
|
|
647
|
+
return true;
|
|
630
648
|
}
|
|
631
649
|
}
|
|
632
650
|
}
|
|
651
|
+
return false;
|
|
633
652
|
}
|
|
634
653
|
|
|
635
654
|
protected scrollIntoViewWithOffset(
|
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.
|