@salesforcedevs/dx-components 1.3.150-canary.7 → 1.3.150
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/LICENSE +12 -0
- package/lwc.config.json +0 -5
- package/package.json +5 -3
- package/src/modules/dx/button/button.ts +0 -15
- package/src/modules/dx/checkbox/checkbox.ts +2 -25
- package/src/modules/dx/faq/faq.html +1 -1
- package/src/modules/dx/featuresListHeader/featuresListHeader.css +0 -5
- package/src/modules/dx/imageAndLabel/imageAndLabel.css +1 -4
- package/src/modules/dx/input/input.ts +5 -36
- package/src/modules/dx/popover/popover.ts +17 -5
- package/src/modules/dx/scrollManager/scrollManager.ts +0 -1
- package/src/modules/dx/select/select.ts +1 -11
- package/src/modules/dx/stepSequence/stepSequence.css +4 -0
- package/src/modules/dx/stepSequence/stepSequence.html +0 -1
- package/src/modules/dx/stepSequence/stepSequence.ts +33 -114
- package/src/modules/dx/alert/alert.css +0 -108
- package/src/modules/dx/alert/alert.html +0 -36
- package/src/modules/dx/alert/alert.ts +0 -137
- package/src/modules/dx/cardStep/cardStep.css +0 -90
- package/src/modules/dx/cardStep/cardStep.html +0 -31
- package/src/modules/dx/cardStep/cardStep.ts +0 -55
- package/src/modules/dx/htmlRenderer/htmlRenderer.html +0 -3
- package/src/modules/dx/htmlRenderer/htmlRenderer.ts +0 -10
- package/src/modules/dxBaseElements/lightningElementWithState/lightningElementWithState.ts +0 -93
- package/src/modules/dxUtils/list/list.ts +0 -11
- package/yarn-error.log +0 -18466
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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.
|
package/lwc.config.json
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
{ "npm": "@salesforcedevs/dw-components" }
|
|
5
5
|
],
|
|
6
6
|
"expose": [
|
|
7
|
-
"dx/alert",
|
|
8
7
|
"dx/audio",
|
|
9
8
|
"dx/banner",
|
|
10
9
|
"dx/brandThemeProvider",
|
|
@@ -23,7 +22,6 @@
|
|
|
23
22
|
"dx/cardNews",
|
|
24
23
|
"dx/cardPodcastEpisode",
|
|
25
24
|
"dx/cardSmall",
|
|
26
|
-
"dx/cardStep",
|
|
27
25
|
"dx/cardTrailheadModule",
|
|
28
26
|
"dx/cardTrial",
|
|
29
27
|
"dx/cardTrialExpanded",
|
|
@@ -51,7 +49,6 @@
|
|
|
51
49
|
"dx/headerSearch",
|
|
52
50
|
"dx/helmet",
|
|
53
51
|
"dx/hr",
|
|
54
|
-
"dx/htmlRenderer",
|
|
55
52
|
"dx/icon",
|
|
56
53
|
"dx/iconBadge",
|
|
57
54
|
"dx/imageAndLabel",
|
|
@@ -92,7 +89,6 @@
|
|
|
92
89
|
"dx/typeBadge",
|
|
93
90
|
"dx/vimeoPlayer",
|
|
94
91
|
"dxBaseElements/headerBase",
|
|
95
|
-
"dxBaseElements/lightningElementWithState",
|
|
96
92
|
"dxBaseElements/matchMediaElement",
|
|
97
93
|
"dxConstants/brands",
|
|
98
94
|
"dxConstants/colors",
|
|
@@ -114,7 +110,6 @@
|
|
|
114
110
|
"dxUtils/dates",
|
|
115
111
|
"dxUtils/highlight",
|
|
116
112
|
"dxUtils/language",
|
|
117
|
-
"dxUtils/list",
|
|
118
113
|
"dxUtils/lwc",
|
|
119
114
|
"dxUtils/normalizers",
|
|
120
115
|
"dxUtils/queryCoordinator",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.150
|
|
3
|
+
"version": "1.3.150",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@coveo/headless": "^2.16.5",
|
|
14
|
-
"@floating-ui/dom": "
|
|
14
|
+
"@floating-ui/dom": "1.5.1",
|
|
15
15
|
"@sfdocs-internal/wires": "^0.6.3",
|
|
16
16
|
"@types/throttle-debounce": "^5.0.0",
|
|
17
17
|
"@vimeo/player": "^2.16.4",
|
|
18
18
|
"classnames": "^2.2.6",
|
|
19
|
+
"composed-offset-position": "^0.0.4",
|
|
19
20
|
"coveo-search-ui": "^2.10109.0",
|
|
20
21
|
"debounce": "^1.2.0",
|
|
21
22
|
"js-cookie": "^3.0.1",
|
|
@@ -39,5 +40,6 @@
|
|
|
39
40
|
"@types/vimeo__player": "^2.16.2",
|
|
40
41
|
"eventsourcemock": "^2.0.0",
|
|
41
42
|
"luxon": "^3.1.0"
|
|
42
|
-
}
|
|
43
|
+
},
|
|
44
|
+
"gitHead": "ca1041e6f13585f85b24a5ca48804f20e040d405"
|
|
43
45
|
}
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from "typings/custom";
|
|
11
11
|
|
|
12
12
|
export default class Button extends LightningElement {
|
|
13
|
-
private _didSetFormAttribute = false;
|
|
14
13
|
@api ariaLabel: string = "";
|
|
15
14
|
@api disabled: boolean | null = null;
|
|
16
15
|
@api iconSize?: IconSize = "small";
|
|
@@ -22,7 +21,6 @@ export default class Button extends LightningElement {
|
|
|
22
21
|
@api variant: ButtonVariant = "primary";
|
|
23
22
|
@api inlineTextColor: ButtonTextColor = "dark";
|
|
24
23
|
@api font: "display" | "sans" = "display";
|
|
25
|
-
@api form: string | undefined;
|
|
26
24
|
@api name?: string;
|
|
27
25
|
@api value?: any;
|
|
28
26
|
|
|
@@ -63,19 +61,6 @@ export default class Button extends LightningElement {
|
|
|
63
61
|
);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
renderedCallback() {
|
|
67
|
-
if (
|
|
68
|
-
!this.href &&
|
|
69
|
-
typeof this.form !== "undefined" &&
|
|
70
|
-
!this._didSetFormAttribute
|
|
71
|
-
) {
|
|
72
|
-
this._didSetFormAttribute = true;
|
|
73
|
-
this.template
|
|
74
|
-
.querySelector("button")
|
|
75
|
-
?.setAttribute("form", this.form);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
64
|
private onSlotChange(e: LightningSlotElement) {
|
|
80
65
|
const slot = e.target;
|
|
81
66
|
this.isSlotEmpty = slot.assignedElements().length !== 0;
|
|
@@ -5,12 +5,12 @@ export default class Checkbox extends LightningElement {
|
|
|
5
5
|
@api disabled: boolean = false;
|
|
6
6
|
@api errorMessage?: string = "Please check this box if you want to proceed";
|
|
7
7
|
@api label?: string;
|
|
8
|
+
@api name: string | null = null;
|
|
9
|
+
@api required: boolean = false;
|
|
8
10
|
@api type: "checkbox" | "radio" = "checkbox";
|
|
9
11
|
@api value!: string;
|
|
10
12
|
|
|
11
13
|
private _checked: boolean = false;
|
|
12
|
-
private _required: boolean = false;
|
|
13
|
-
private _name: string | null = null;
|
|
14
14
|
|
|
15
15
|
@api
|
|
16
16
|
get checked(): boolean {
|
|
@@ -20,24 +20,6 @@ export default class Checkbox extends LightningElement {
|
|
|
20
20
|
this._checked = value;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
@api
|
|
24
|
-
get name(): string | null {
|
|
25
|
-
return this._name;
|
|
26
|
-
}
|
|
27
|
-
set name(value: string | null) {
|
|
28
|
-
this._name = value;
|
|
29
|
-
this.setAttribute("name", value); // reflect to HTML
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
@api
|
|
33
|
-
get required(): boolean {
|
|
34
|
-
return this._required;
|
|
35
|
-
}
|
|
36
|
-
set required(value: boolean) {
|
|
37
|
-
this._required = value;
|
|
38
|
-
this.setAttribute("required", value); // reflect to HTML
|
|
39
|
-
}
|
|
40
|
-
|
|
41
23
|
private showValidity = false;
|
|
42
24
|
|
|
43
25
|
private get valid(): boolean {
|
|
@@ -58,11 +40,6 @@ export default class Checkbox extends LightningElement {
|
|
|
58
40
|
return this.valid;
|
|
59
41
|
}
|
|
60
42
|
|
|
61
|
-
@api
|
|
62
|
-
checkValidity(): boolean {
|
|
63
|
-
return this.valid;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
43
|
private onChange(e: InputEvent) {
|
|
67
44
|
this._checked = ((e.currentTarget as HTMLInputElement) || {}).checked;
|
|
68
45
|
this.dispatchEvent(
|
|
@@ -16,10 +16,6 @@ img {
|
|
|
16
16
|
margin-right: var(--dx-g-spacing-sm);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
span {
|
|
20
|
-
white-space: nowrap;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
19
|
a img {
|
|
24
20
|
transition: var(--dx-g-transition-filter-2x);
|
|
25
21
|
}
|
|
@@ -50,4 +46,5 @@ img.size-large {
|
|
|
50
46
|
|
|
51
47
|
.dx-text-label-1-dark {
|
|
52
48
|
color: var(--dx-c-image-and-label-text-color);
|
|
49
|
+
text-align: left;
|
|
53
50
|
}
|
|
@@ -30,7 +30,9 @@ export default class Input extends LightningElement {
|
|
|
30
30
|
@api loading: boolean = false;
|
|
31
31
|
@api missingErrorMessage: string = "Complete this field";
|
|
32
32
|
@api formatErrorMessage?: string;
|
|
33
|
+
@api name?: string;
|
|
33
34
|
@api placeholder!: string;
|
|
35
|
+
@api required = false;
|
|
34
36
|
@api role: string | null = null;
|
|
35
37
|
@api shortcutKey: string | null = null;
|
|
36
38
|
@api size: "small" | "large" | "override" = "small";
|
|
@@ -46,24 +48,6 @@ export default class Input extends LightningElement {
|
|
|
46
48
|
this._value = value || "";
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
@api
|
|
50
|
-
get name() {
|
|
51
|
-
return this._name;
|
|
52
|
-
}
|
|
53
|
-
set name(name: string | undefined) {
|
|
54
|
-
this._name = name;
|
|
55
|
-
this.setAttribute("name", name); // reflect to HTML
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@api
|
|
59
|
-
get required(): boolean {
|
|
60
|
-
return this._required;
|
|
61
|
-
}
|
|
62
|
-
set required(value: boolean) {
|
|
63
|
-
this._required = value;
|
|
64
|
-
this.setAttribute("required", value); // reflect to HTML
|
|
65
|
-
}
|
|
66
|
-
|
|
67
51
|
@api
|
|
68
52
|
get errorMessage() {
|
|
69
53
|
return this._errorMessage;
|
|
@@ -81,7 +65,7 @@ export default class Input extends LightningElement {
|
|
|
81
65
|
|
|
82
66
|
@api
|
|
83
67
|
reportValidity(): boolean {
|
|
84
|
-
if (this.
|
|
68
|
+
if (this.isRequiredAndFilled) {
|
|
85
69
|
this._errorMessage = this.missingErrorMessage;
|
|
86
70
|
return false;
|
|
87
71
|
}
|
|
@@ -97,25 +81,10 @@ export default class Input extends LightningElement {
|
|
|
97
81
|
return true;
|
|
98
82
|
}
|
|
99
83
|
|
|
100
|
-
@api checkValidity(): boolean {
|
|
101
|
-
if (this.isRequiredButEmpty) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const typeValidator = typeValidatorMap[this.type];
|
|
106
|
-
if (typeValidator && !typeValidator.validator(this.value)) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
84
|
private _errorMessage: string = "";
|
|
114
85
|
private focused: boolean = false;
|
|
115
86
|
private input: HTMLInputElement | null = null;
|
|
116
87
|
private _value: string | null = null;
|
|
117
|
-
private _name?: string;
|
|
118
|
-
private _required: boolean = false;
|
|
119
88
|
private _loading: boolean = false;
|
|
120
89
|
private isMac: boolean = false;
|
|
121
90
|
|
|
@@ -138,7 +107,7 @@ export default class Input extends LightningElement {
|
|
|
138
107
|
private get inputInvalid() {
|
|
139
108
|
const typeValidator = typeValidatorMap[this.type];
|
|
140
109
|
return (
|
|
141
|
-
this.
|
|
110
|
+
this.isRequiredAndFilled &&
|
|
142
111
|
typeValidator &&
|
|
143
112
|
!typeValidator.validator(this.value)
|
|
144
113
|
);
|
|
@@ -182,7 +151,7 @@ export default class Input extends LightningElement {
|
|
|
182
151
|
return `${this.commandKey}-${this.shortcutKey} is the search shortcut`;
|
|
183
152
|
}
|
|
184
153
|
|
|
185
|
-
private get
|
|
154
|
+
private get isRequiredAndFilled() {
|
|
186
155
|
return this.required && (!this.value || !this.value.trim());
|
|
187
156
|
}
|
|
188
157
|
|
|
@@ -5,7 +5,15 @@ import {
|
|
|
5
5
|
PopperPlacement
|
|
6
6
|
} from "typings/custom";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
computePosition,
|
|
10
|
+
flip,
|
|
11
|
+
size,
|
|
12
|
+
shift,
|
|
13
|
+
arrow,
|
|
14
|
+
platform
|
|
15
|
+
} from "@floating-ui/dom";
|
|
16
|
+
import { offsetParent } from "composed-offset-position";
|
|
9
17
|
import cx from "classnames";
|
|
10
18
|
import debounce from "debounce";
|
|
11
19
|
import { isPrerender } from "dxUtils/seo";
|
|
@@ -246,9 +254,9 @@ export default class Popover extends LightningElement {
|
|
|
246
254
|
const elements = slot.assignedElements();
|
|
247
255
|
const slotted = elements.length === 0 ? null : elements[0];
|
|
248
256
|
// allows dropdown/select to compose popover
|
|
249
|
-
const slotElement = (
|
|
250
|
-
|
|
251
|
-
|
|
257
|
+
const slotElement = (slotted?.tagName === "SLOT"
|
|
258
|
+
? slotted.firstChild
|
|
259
|
+
: slotted) as HTMLElement | null;
|
|
252
260
|
const isWorkToDo =
|
|
253
261
|
slotElement &&
|
|
254
262
|
(!this.control || !slotElement.isSameNode(this.control));
|
|
@@ -310,7 +318,11 @@ export default class Popover extends LightningElement {
|
|
|
310
318
|
|
|
311
319
|
computePosition(this.control, popoverEl, {
|
|
312
320
|
placement: this.placement,
|
|
313
|
-
|
|
321
|
+
platform: {
|
|
322
|
+
...platform,
|
|
323
|
+
getOffsetParent: (element) =>
|
|
324
|
+
platform.getOffsetParent(element, offsetParent)
|
|
325
|
+
},
|
|
314
326
|
middleware
|
|
315
327
|
}).then(({ x, y, placement, middlewareData }) => {
|
|
316
328
|
Object.assign(popoverEl.style, {
|
|
@@ -166,7 +166,6 @@ export default class ScrollManager extends LightningElement {
|
|
|
166
166
|
saveScroll = throttle(100, () => {
|
|
167
167
|
window.history.replaceState(
|
|
168
168
|
{
|
|
169
|
-
...window.history.state,
|
|
170
169
|
scroll: {
|
|
171
170
|
value: document.body.scrollTop,
|
|
172
171
|
docSize: document.body.scrollHeight
|
|
@@ -10,6 +10,7 @@ export default class Select extends LightningElement {
|
|
|
10
10
|
@api autocomplete?: string;
|
|
11
11
|
@api label?: string;
|
|
12
12
|
@api messageWhenValueMissing: string = DEFAULT_MISSING_MESSAGE;
|
|
13
|
+
@api name?: string;
|
|
13
14
|
@api placeholder?: string;
|
|
14
15
|
@api size?: string;
|
|
15
16
|
|
|
@@ -50,22 +51,11 @@ export default class Select extends LightningElement {
|
|
|
50
51
|
this.updateSelectValue();
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
@api
|
|
54
|
-
get name() {
|
|
55
|
-
return this._name;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
set name(name) {
|
|
59
|
-
this._name = name;
|
|
60
|
-
this.setAttribute("name", name); // reflect to HTML
|
|
61
|
-
}
|
|
62
|
-
|
|
63
54
|
_disabled = false;
|
|
64
55
|
_size = "";
|
|
65
56
|
_required = false;
|
|
66
57
|
_options: Array<SelectOption> = [];
|
|
67
58
|
_value: string = "";
|
|
68
|
-
_name?: string;
|
|
69
59
|
_selectElement: HTMLSelectElement | null = null;
|
|
70
60
|
helpMessage?: string = "";
|
|
71
61
|
|
|
@@ -7,18 +7,12 @@ import cx from "classnames";
|
|
|
7
7
|
// forward/back buttons and via any action buttons defined in the dx-step-sequence-step components (see that
|
|
8
8
|
// component for details on the action buttons).
|
|
9
9
|
export default class StepSequence extends LightningElement {
|
|
10
|
-
@api animateTransitions = false;
|
|
11
|
-
@api communicateStepChanges = false;
|
|
12
10
|
@api initialStepIndex: string | undefined;
|
|
13
|
-
@api
|
|
14
|
-
@api useHistory = false;
|
|
11
|
+
@api animateTransitions = false;
|
|
15
12
|
|
|
16
13
|
private currentStepIndex = 0;
|
|
17
|
-
private defaultScrollRestorationValue = history.scrollRestoration;
|
|
18
|
-
private isHiddenForInitialAnimation = true;
|
|
19
|
-
private numPendingInitialTransitions = 0;
|
|
20
|
-
private slotClassName = "step-sequence-steps-slot";
|
|
21
14
|
private steps: Array<HTMLElement> = [];
|
|
15
|
+
private isHiddenForInitialAnimation = true;
|
|
22
16
|
|
|
23
17
|
private get containerClassName() {
|
|
24
18
|
return cx("step-sequence-container", {
|
|
@@ -29,33 +23,16 @@ export default class StepSequence extends LightningElement {
|
|
|
29
23
|
|
|
30
24
|
connectedCallback() {
|
|
31
25
|
const initialStepIndex = parseInt(this.initialStepIndex as string, 10);
|
|
32
|
-
|
|
33
26
|
if (!isNaN(initialStepIndex)) {
|
|
34
27
|
this.currentStepIndex = initialStepIndex;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
currentStepIndex: this.currentStepIndex
|
|
44
|
-
},
|
|
45
|
-
""
|
|
46
|
-
);
|
|
47
|
-
window.addEventListener("popstate", this.handleHistoryPopstate);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (this.sessionStorageId) {
|
|
51
|
-
sessionStorage.setItem(
|
|
52
|
-
this.sessionStorageId,
|
|
53
|
-
JSON.stringify({
|
|
54
|
-
currentStepIndex: this.currentStepIndex
|
|
55
|
-
})
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
29
|
+
history.replaceState(
|
|
30
|
+
{
|
|
31
|
+
currentStepIndex: this.currentStepIndex
|
|
32
|
+
},
|
|
33
|
+
""
|
|
34
|
+
);
|
|
35
|
+
window.addEventListener("popstate", this.handleHistoryPopstate);
|
|
59
36
|
if (this.animateTransitions) {
|
|
60
37
|
this.addEventListener("transitionend", this.handleTransitionEnd);
|
|
61
38
|
} else {
|
|
@@ -66,11 +43,6 @@ export default class StepSequence extends LightningElement {
|
|
|
66
43
|
disconnectedCallback() {
|
|
67
44
|
window.removeEventListener("popstate", this.handleHistoryPopstate);
|
|
68
45
|
this.removeEventListener("transitionend", this.handleTransitionEnd);
|
|
69
|
-
history.scrollRestoration = this.defaultScrollRestorationValue;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private scrollToStepTop() {
|
|
73
|
-
this.template.host.scrollIntoView();
|
|
74
46
|
}
|
|
75
47
|
|
|
76
48
|
// Used only if this.animateTransitions is truthy
|
|
@@ -83,6 +55,10 @@ export default class StepSequence extends LightningElement {
|
|
|
83
55
|
return;
|
|
84
56
|
}
|
|
85
57
|
|
|
58
|
+
if (this.isHiddenForInitialAnimation) {
|
|
59
|
+
this.isHiddenForInitialAnimation = false;
|
|
60
|
+
}
|
|
61
|
+
|
|
86
62
|
// Ensure subsequent steps are no longer visible:
|
|
87
63
|
const prevStep = this.steps[this.currentStepIndex - 1];
|
|
88
64
|
const nextStep = this.steps[this.currentStepIndex + 1];
|
|
@@ -95,38 +71,18 @@ export default class StepSequence extends LightningElement {
|
|
|
95
71
|
|
|
96
72
|
// Mark the current step as fully active:
|
|
97
73
|
this.steps[this.currentStepIndex].classList.add("active-step");
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
this.isHiddenForInitialAnimation &&
|
|
101
|
-
this.numPendingInitialTransitions > 0
|
|
102
|
-
) {
|
|
103
|
-
// Initial animation; allow subsequent animations to be visible when ready
|
|
104
|
-
this.numPendingInitialTransitions =
|
|
105
|
-
this.numPendingInitialTransitions - 1;
|
|
106
|
-
if (this.numPendingInitialTransitions === 0) {
|
|
107
|
-
this.isHiddenForInitialAnimation = false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
74
|
};
|
|
111
75
|
|
|
112
76
|
private changeActiveStep(nextStepIndex: number, updateHistory = true) {
|
|
113
|
-
if (
|
|
114
|
-
nextStepIndex === this.currentStepIndex ||
|
|
115
|
-
!this.isStepIndexWithinBounds(nextStepIndex)
|
|
116
|
-
) {
|
|
77
|
+
if (nextStepIndex === this.currentStepIndex) {
|
|
117
78
|
// Should never happen, but covering all logical bases. Nothing to do here.
|
|
118
79
|
return;
|
|
119
80
|
}
|
|
120
81
|
|
|
121
|
-
this.scrollToStepTop();
|
|
122
|
-
|
|
123
82
|
if (!this.animateTransitions) {
|
|
124
83
|
this.steps[this.currentStepIndex].className = "";
|
|
125
84
|
this.steps[nextStepIndex].className = "visible active-step";
|
|
126
85
|
} else {
|
|
127
|
-
this.template.querySelector(
|
|
128
|
-
".step-sequence-container"
|
|
129
|
-
)!.style.minHeight = `${this.steps[nextStepIndex].clientHeight}px`;
|
|
130
86
|
// If animations are enabled, we need to animate in the correct directions:
|
|
131
87
|
if (nextStepIndex > this.currentStepIndex) {
|
|
132
88
|
this.steps[this.currentStepIndex].className =
|
|
@@ -139,7 +95,7 @@ export default class StepSequence extends LightningElement {
|
|
|
139
95
|
}
|
|
140
96
|
}
|
|
141
97
|
|
|
142
|
-
if (
|
|
98
|
+
if (updateHistory) {
|
|
143
99
|
history.pushState(
|
|
144
100
|
{
|
|
145
101
|
currentStepIndex: nextStepIndex
|
|
@@ -147,29 +103,7 @@ export default class StepSequence extends LightningElement {
|
|
|
147
103
|
""
|
|
148
104
|
);
|
|
149
105
|
}
|
|
150
|
-
|
|
151
|
-
if (this.sessionStorageId) {
|
|
152
|
-
sessionStorage.setItem(
|
|
153
|
-
this.sessionStorageId,
|
|
154
|
-
JSON.stringify({
|
|
155
|
-
currentStepIndex: nextStepIndex
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
106
|
this.currentStepIndex = nextStepIndex;
|
|
161
|
-
|
|
162
|
-
if (this.communicateStepChanges) {
|
|
163
|
-
this.dispatchEvent(
|
|
164
|
-
new CustomEvent("stepsequencechange", {
|
|
165
|
-
detail: {
|
|
166
|
-
stepIndex: this.currentStepIndex
|
|
167
|
-
},
|
|
168
|
-
composed: true,
|
|
169
|
-
bubbles: true
|
|
170
|
-
})
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
107
|
}
|
|
174
108
|
|
|
175
109
|
private initializeStepAnimationClasses(
|
|
@@ -189,15 +123,10 @@ export default class StepSequence extends LightningElement {
|
|
|
189
123
|
}
|
|
190
124
|
}
|
|
191
125
|
|
|
192
|
-
@api
|
|
193
|
-
public getCurrentStepIndex(): number {
|
|
194
|
-
return this.currentStepIndex;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
126
|
// This method is available in case there are scenarios where a sequence needs to "jump" in some cases
|
|
198
127
|
@api
|
|
199
128
|
public jumpToStep(stepIndex: number) {
|
|
200
|
-
if (
|
|
129
|
+
if (stepIndex < 0 || stepIndex >= this.steps.length) {
|
|
201
130
|
// illegal value; ignore
|
|
202
131
|
return;
|
|
203
132
|
}
|
|
@@ -211,10 +140,6 @@ export default class StepSequence extends LightningElement {
|
|
|
211
140
|
}
|
|
212
141
|
}
|
|
213
142
|
|
|
214
|
-
private isStepIndexWithinBounds(stepIndex: number) {
|
|
215
|
-
return stepIndex >= 0 && stepIndex < this.steps.length;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
143
|
handleHistoryPopstate = ({ state }: PopStateEvent) => {
|
|
219
144
|
if (typeof state.currentStepIndex === "number") {
|
|
220
145
|
this.changeActiveStep(state.currentStepIndex, false);
|
|
@@ -244,35 +169,29 @@ export default class StepSequence extends LightningElement {
|
|
|
244
169
|
// change it).
|
|
245
170
|
handleSlotChange(e: Event) {
|
|
246
171
|
const slot = e.target as HTMLSlotElement;
|
|
247
|
-
|
|
248
|
-
if (slot.className !== this.slotClassName) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
172
|
this.steps = slot.assignedElements() as HTMLElement[];
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
173
|
+
if (!this.animateTransitions) {
|
|
174
|
+
this.steps[this.currentStepIndex].className = "visible active-step";
|
|
175
|
+
} else {
|
|
176
|
+
// For transition animations to be visible, the container must have a height that will
|
|
177
|
+
// keep the components visible as they transition in and out. Currently this component
|
|
178
|
+
// will have at least the height of the "tallest" slotted element.
|
|
179
|
+
let minHeight = 0;
|
|
180
|
+
this.steps.forEach((step, index) => {
|
|
181
|
+
if (step.clientHeight > minHeight) {
|
|
182
|
+
minHeight = step.clientHeight;
|
|
183
|
+
}
|
|
257
184
|
this.initializeStepAnimationClasses(
|
|
258
185
|
this.currentStepIndex,
|
|
259
186
|
step,
|
|
260
187
|
index
|
|
261
188
|
);
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
numPendingInitialTransitions =
|
|
268
|
-
numPendingInitialTransitions +
|
|
269
|
-
numTransitionsForStep;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
189
|
+
});
|
|
190
|
+
if (minHeight > 0) {
|
|
191
|
+
this.template.querySelector(
|
|
192
|
+
".step-sequence-container"
|
|
193
|
+
)!.style.minHeight = `${minHeight}px`;
|
|
272
194
|
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
this.numPendingInitialTransitions = numPendingInitialTransitions;
|
|
276
|
-
this.steps[this.currentStepIndex].className = "visible active-step";
|
|
195
|
+
}
|
|
277
196
|
}
|
|
278
197
|
}
|