lightning-base-components 1.14.3-alpha → 1.15.1-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/metadata/raptor.json +37 -4
- package/package.json +11 -4
- package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
- package/scopedImports/@salesforce-label-LightningModalBase.cancelandclose.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
- package/src/lightning/alert/__docs__/alert.md +101 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/alert/alert.html +3 -0
- package/src/lightning/alert/alert.js +78 -0
- package/src/lightning/alert/alert.js-meta.xml +6 -0
- package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +9 -0
- package/src/lightning/ariaObserver/ariaObserver.js +24 -35
- package/src/lightning/baseFormattedText/baseFormattedText.html +6 -1
- package/src/lightning/baseFormattedText/baseFormattedText.js +5 -0
- package/src/lightning/button/__wdio__/utam/utam.html +3 -0
- package/src/lightning/button/__wdio__/utam/utam.js +3 -0
- package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
- package/src/lightning/buttonMenu/buttonMenu.js +12 -0
- package/src/lightning/confirm/__docs__/confirm.md +100 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/confirm/confirm.html +3 -0
- package/src/lightning/confirm/confirm.js +80 -0
- package/src/lightning/confirm/confirm.js-meta.xml +6 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +21 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.html +13 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +42 -0
- package/src/lightning/datatable/__wdio__/utam/utam.html +17 -0
- package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
- package/src/lightning/datatable/__wdio__/utam/utam.spec.js +189 -0
- package/src/lightning/datatable/autoWidthStrategy.js +170 -61
- package/src/lightning/datatable/{resizer.js → columnResizer.js} +0 -0
- package/src/lightning/datatable/columnWidthManager.js +226 -44
- package/src/lightning/datatable/columns.js +166 -71
- package/src/lightning/datatable/datatable.js +136 -60
- package/src/lightning/datatable/fixedWidthStrategy.js +43 -8
- package/src/lightning/datatable/headerActions.js +2 -2
- package/src/lightning/datatable/infiniteLoading.js +100 -28
- package/src/lightning/datatable/inlineEdit.js +21 -30
- package/src/lightning/datatable/keyboard.js +166 -131
- package/src/lightning/datatable/renderManager.js +117 -122
- package/src/lightning/datatable/{datatableResizeObserver.js → resizeObserver.js} +46 -29
- package/src/lightning/datatable/resizeSensor.js +19 -3
- package/src/lightning/datatable/rowSelection.js +1 -1
- package/src/lightning/datatable/rowSelectionShared.js +33 -20
- package/src/lightning/datatable/rows.js +9 -8
- package/src/lightning/datatable/sort.js +8 -8
- package/src/lightning/datatable/state.js +14 -2
- package/src/lightning/datatable/templates/div/div.html +133 -119
- package/src/lightning/datatable/templates/table/table.html +10 -2
- package/src/lightning/datatable/tree.js +25 -0
- package/src/lightning/datatable/types.js +77 -9
- package/src/lightning/datatable/utils.js +51 -24
- package/src/lightning/datatable/virtualization.js +319 -0
- package/src/lightning/datatable/widthManagerShared.js +27 -3
- package/src/lightning/datatable/wrapText.js +115 -48
- package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
- package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +36 -3
- package/src/lightning/formattedDateTime/__examples__/datetime/datetime.html +2 -2
- package/src/lightning/formattedDateTime/__examples__/datetime/datetime.js +3 -1
- package/src/lightning/formattedDateTime/__examples__/time/time.html +1 -1
- package/src/lightning/formattedDateTime/__examples__/time/time.js +3 -1
- package/src/lightning/formattedDateTime/formattedDateTime.js +1 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/input/__docs__/input.md +2 -0
- package/src/lightning/input/input.html +2 -5
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
- package/src/lightning/menuItem/menuItem.js +4 -1
- package/src/lightning/modalBase/modalBase.css +20 -0
- package/src/lightning/modalBase/modalBase.html +54 -0
- package/src/lightning/modalBase/modalBase.js +1039 -0
- package/src/lightning/overlay/__docs__/overlay.md +90 -0
- package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
- package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
- package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
- package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
- package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
- package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
- package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
- package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
- package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
- package/src/lightning/overlay/overlay.html +3 -0
- package/src/lightning/overlay/overlay.js +45 -0
- package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
- package/src/lightning/overlayContainer/overlayContainer.html +3 -0
- package/src/lightning/overlayContainer/overlayContainer.js +138 -0
- package/src/lightning/overlayManager/overlayManager.js +54 -0
- package/src/lightning/overlayUtils/overlayUtils.js +17 -0
- package/src/lightning/progressBar/progressBar.html +2 -1
- package/src/lightning/progressBar/progressBar.js +18 -1
- package/src/lightning/prompt/__docs__/prompt.md +102 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
- package/src/lightning/prompt/prompt.css +81 -0
- package/src/lightning/prompt/prompt.html +8 -0
- package/src/lightning/prompt/prompt.js +92 -0
- package/src/lightning/prompt/prompt.js-meta.xml +6 -0
- package/src/lightning/spinner/spinner.html +1 -1
- package/src/lightning/spinner/spinner.js +12 -0
- package/src/lightning/utilsPrivate/phonify.js +1 -1
- package/scopedImports/@salesforce-label-LightningModalBase.close.js +0 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Overlay
|
|
2
|
+
|
|
3
|
+
> Note: This component is not exposed for use by internal or external developers.
|
|
4
|
+
|
|
5
|
+
This is as low level in the overlay library as one can get. For this reason the documentation below is aimed at primarily `Lightning*` developers or those creating new overlay types. The overview examples would need much more to be fully accessible.
|
|
6
|
+
|
|
7
|
+
- Simple: Contains no wrapping HTML only a host element.
|
|
8
|
+
- `<c-custom-overlay>`
|
|
9
|
+
- Advanced: Contains a wrapping Component. Example: `LightningModal`.
|
|
10
|
+
|
|
11
|
+
## Creating a Simple Overlay
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import LightningOverlay from 'lightning/overlay';
|
|
15
|
+
import { instanceName } from 'lightning/overlayUtils';
|
|
16
|
+
|
|
17
|
+
class MyOverlay extends LightningOverlay {
|
|
18
|
+
static [instanceName] = 'my-overlay';
|
|
19
|
+
|
|
20
|
+
@api customProperty = 'Default';
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Usage for the `MyOverlay` in a custom app would like like below.
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import { LightningElement } from 'lwc';
|
|
28
|
+
import MyOverlay from 'my/overlay';
|
|
29
|
+
|
|
30
|
+
class MyApp extends LightningElement {
|
|
31
|
+
async handleClick() {
|
|
32
|
+
const result = await MyOverlay.open({
|
|
33
|
+
customProperty: 'Hello World!';
|
|
34
|
+
});
|
|
35
|
+
console.log(result);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Creating an Wrapping Component
|
|
41
|
+
|
|
42
|
+
Other scenarios require wrapping HTML around the overlay component. Most commonly this is used to position an element. A common example is `LightningModal`, but alternatively this can be used for writing a shared `LightningMenu`.
|
|
43
|
+
|
|
44
|
+
The `LightningMenuBase` component works as a wrapper.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<template>
|
|
48
|
+
<ul data-slot lwc:dom="manual"></ul>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The `LightningMenu` now looks like...
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Usage for the `MyMenu` in a custom app would like like below.
|
|
67
|
+
|
|
68
|
+
```html
|
|
69
|
+
<template>
|
|
70
|
+
<button click="{handleClick}">{label}</button>
|
|
71
|
+
</template>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```js
|
|
75
|
+
import { LightningElement, api } from 'lwc';
|
|
76
|
+
import MyMenu from 'my/overlay';
|
|
77
|
+
|
|
78
|
+
class MyButtonMenu extends LightningElement {
|
|
79
|
+
@api label = 'Dropdown';
|
|
80
|
+
|
|
81
|
+
async handleClick(e) {
|
|
82
|
+
const result = await MyMenu.open({
|
|
83
|
+
source: e.target,
|
|
84
|
+
options: ['Item 1'];
|
|
85
|
+
});
|
|
86
|
+
// The selected item
|
|
87
|
+
console.log(result);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<lightning-focus-trap>
|
|
3
|
+
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
|
|
4
|
+
aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open slds-modal_small">
|
|
5
|
+
<div class="slds-modal__container">
|
|
6
|
+
<header class="slds-modal__header">
|
|
7
|
+
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse"
|
|
8
|
+
title="Close" onclick={handleDismiss}>
|
|
9
|
+
<svg class="slds-button__icon slds-button__icon_large" aria-hidden="true">
|
|
10
|
+
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
|
|
11
|
+
</svg>
|
|
12
|
+
<span class="slds-assistive-text">Close</span>
|
|
13
|
+
</button>
|
|
14
|
+
<h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">{header}</h2>
|
|
15
|
+
</header>
|
|
16
|
+
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
|
|
17
|
+
<p>{body}</p>
|
|
18
|
+
</div>
|
|
19
|
+
<footer class="slds-modal__footer">
|
|
20
|
+
<button class="slds-button slds-button_neutral" onclick={handleCancel}>{cancelText}</button>
|
|
21
|
+
<button class="slds-button slds-button_brand" onclick={handleOkay}>{okayText}</button>
|
|
22
|
+
</footer>
|
|
23
|
+
</div>
|
|
24
|
+
</section>
|
|
25
|
+
</lightning-focus-trap>
|
|
26
|
+
<div class="slds-backdrop slds-backdrop_open"></div>
|
|
27
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { api } from 'lwc';
|
|
2
|
+
import LightningOverlay from 'lightning/overlay';
|
|
3
|
+
|
|
4
|
+
export default class OverlayAlert extends LightningOverlay {
|
|
5
|
+
@api header = 'Header';
|
|
6
|
+
|
|
7
|
+
@api body = 'Body';
|
|
8
|
+
|
|
9
|
+
@api okayText = 'Okay';
|
|
10
|
+
|
|
11
|
+
@api cancelText = 'Cancel';
|
|
12
|
+
|
|
13
|
+
handleOkay() {
|
|
14
|
+
this.close('okay');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
handleCancel() {
|
|
18
|
+
this.close('cancel');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
handleDismiss() {
|
|
22
|
+
this.close('dismiss');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
hasFocus = false;
|
|
26
|
+
renderedCallback() {
|
|
27
|
+
if (!this.hasFocus) {
|
|
28
|
+
const close = this.template.querySelector('header > button');
|
|
29
|
+
close.focus();
|
|
30
|
+
this.hasFocus = true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="example">
|
|
3
|
+
<button onclick={handleConfirmModal}>Open a Confirm Modal</button>
|
|
4
|
+
<p>Result: <code>{confirmResult}</code></p>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="example">
|
|
7
|
+
<button onclick={handleConfirmAltModal}>Open a Confirm Modal Alt</button>
|
|
8
|
+
<p>Result: <code>{confirmAltResult}</code></p>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="example">
|
|
11
|
+
<button onclick={handleDemoModal}>Open a Demo Modal</button>
|
|
12
|
+
<p>Result: <code>{demoResult}</code></p>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="example">
|
|
15
|
+
<button onclick={handlePanel}>Open a Panel</button>
|
|
16
|
+
<p>Result: <code>{panelResult}</code></p>
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { LightningElement } from 'lwc';
|
|
2
|
+
|
|
3
|
+
import OverlayAlert from 'overlay/alert';
|
|
4
|
+
import OverlayDemo from 'overlay/demo';
|
|
5
|
+
import OverlayPanel from 'overlay/panel';
|
|
6
|
+
|
|
7
|
+
export default class OverlayBasic extends LightningElement {
|
|
8
|
+
confirmResult = 'unset';
|
|
9
|
+
|
|
10
|
+
handleConfirmModal() {
|
|
11
|
+
OverlayAlert.open({
|
|
12
|
+
header: 'Are you sure?',
|
|
13
|
+
body: 'Click cancel or okay below to get a string result.',
|
|
14
|
+
}).then((result) => {
|
|
15
|
+
this.confirmResult = result;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
confirmAltResult = 'unset';
|
|
20
|
+
|
|
21
|
+
handleConfirmAltModal() {
|
|
22
|
+
OverlayAlert.open({
|
|
23
|
+
header: 'Do you like this demo?',
|
|
24
|
+
body: '...',
|
|
25
|
+
okayText: 'Yes',
|
|
26
|
+
cancelText: 'Also Yes',
|
|
27
|
+
}).then((result) => {
|
|
28
|
+
this.confirmAltResult = result;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
demoResult = 'unset';
|
|
33
|
+
|
|
34
|
+
handleDemoModal() {
|
|
35
|
+
OverlayDemo.open({
|
|
36
|
+
header: 'Select an Option',
|
|
37
|
+
body: 'From the list below select an item',
|
|
38
|
+
options: [
|
|
39
|
+
{ id: 1, label: 'Option 1' },
|
|
40
|
+
{ id: 2, label: 'Option 2' },
|
|
41
|
+
],
|
|
42
|
+
}).then((result) => {
|
|
43
|
+
if (result === 0) {
|
|
44
|
+
this.demoResult = 'dismiss';
|
|
45
|
+
} else {
|
|
46
|
+
this.demoResult = result;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
panelResult = 'unset';
|
|
52
|
+
|
|
53
|
+
handlePanel() {
|
|
54
|
+
OverlayPanel.open({
|
|
55
|
+
header: 'Select an Option',
|
|
56
|
+
body: 'From the list below select an item',
|
|
57
|
+
}).then((result) => {
|
|
58
|
+
this.demoResult = result;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true"
|
|
3
|
+
aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
|
|
4
|
+
<div class="slds-modal__container">
|
|
5
|
+
<header class="slds-modal__header">
|
|
6
|
+
<button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={handleDismiss}>
|
|
7
|
+
<svg class="slds-button__icon slds-button__icon_large" aria-hidden="true">
|
|
8
|
+
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
|
|
9
|
+
</svg>
|
|
10
|
+
<span class="slds-assistive-text">Close</span>
|
|
11
|
+
</button>
|
|
12
|
+
<h2 id="modal-heading-01" class="slds-modal__title slds-hyphenate">{header}</h2>
|
|
13
|
+
</header>
|
|
14
|
+
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
|
|
15
|
+
<p>{body}</p>
|
|
16
|
+
<ul>
|
|
17
|
+
<template for:each={options} for:item="option">
|
|
18
|
+
<li key={option.id}>
|
|
19
|
+
<button onclick={handleOptionClick} data-id={option.id}>
|
|
20
|
+
{option.label}
|
|
21
|
+
</button>
|
|
22
|
+
</li>
|
|
23
|
+
</template>
|
|
24
|
+
</ul>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
</section>
|
|
28
|
+
<div class="slds-backdrop slds-backdrop_open"></div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { api } from 'lwc';
|
|
2
|
+
|
|
3
|
+
import LightningOverlay from 'lightning/overlay';
|
|
4
|
+
import OverlayAlert from 'overlay/alert';
|
|
5
|
+
|
|
6
|
+
export default class OverlayDemo extends LightningOverlay {
|
|
7
|
+
@api header = 'Header';
|
|
8
|
+
|
|
9
|
+
@api body = 'Body';
|
|
10
|
+
|
|
11
|
+
@api options = [];
|
|
12
|
+
|
|
13
|
+
handleOptionClick(e) {
|
|
14
|
+
const { target } = e;
|
|
15
|
+
const id = parseInt(target.dataset.id, 10);
|
|
16
|
+
const option = this.options.find((x) => x.id === id);
|
|
17
|
+
OverlayAlert.open({
|
|
18
|
+
header: 'Are you sure?',
|
|
19
|
+
body: `You selected "${option.label}".`,
|
|
20
|
+
okayText: `Yes, ${option.label}`,
|
|
21
|
+
}).then((result) => {
|
|
22
|
+
if (result === 'okay') {
|
|
23
|
+
this.close(parseInt(target.dataset.id, 10));
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
handleDismiss() {
|
|
29
|
+
this.close(0);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
hasFocus = false;
|
|
33
|
+
renderedCallback() {
|
|
34
|
+
if (!this.hasFocus) {
|
|
35
|
+
const close = this.template.querySelector('header > button');
|
|
36
|
+
close.focus();
|
|
37
|
+
this.hasFocus = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<lightning-focus-trap>
|
|
3
|
+
<div class="slds-panel slds-size_medium slds-panel_docked slds-panel_docked-left slds-is-open" aria-hidden="false">
|
|
4
|
+
<div class="slds-panel__header">
|
|
5
|
+
<h2 class="slds-panel__header-title slds-text-heading_small slds-truncate" title="Panel Header">{header}</h2>
|
|
6
|
+
<button class="slds-button slds-button_icon slds-button_icon-small slds-panel__close" title="Collapse Panel Header" onclick={handleDismiss}>
|
|
7
|
+
<svg class="slds-button__icon" aria-hidden="true">
|
|
8
|
+
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#close"></use>
|
|
9
|
+
</svg>
|
|
10
|
+
<span class="slds-assistive-text">Collapse Panel Header</span>
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="slds-panel__body">{body}</div>
|
|
14
|
+
</div>
|
|
15
|
+
</lightning-focus-trap>
|
|
16
|
+
<!-- <div class="slds-backdrop slds-backdrop_open"></div>-->
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { api } from 'lwc';
|
|
2
|
+
import LightningOverlay from 'lightning/overlay';
|
|
3
|
+
|
|
4
|
+
export default class OverlayPanel extends LightningOverlay {
|
|
5
|
+
@api header = 'Header';
|
|
6
|
+
|
|
7
|
+
@api body = 'Body';
|
|
8
|
+
|
|
9
|
+
handleDismiss() {
|
|
10
|
+
this.close('dismiss');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
hasFocus = false;
|
|
14
|
+
renderedCallback() {
|
|
15
|
+
if (!this.hasFocus) {
|
|
16
|
+
const close = this.template.querySelector('div > button');
|
|
17
|
+
close.focus();
|
|
18
|
+
this.hasFocus = true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LightningElement, createElement, api } from 'lwc';
|
|
2
|
+
import { instanceName } from 'lightning/overlayUtils';
|
|
3
|
+
import OverlayContainer from 'lightning/overlayContainer';
|
|
4
|
+
|
|
5
|
+
const ROOT = 'body';
|
|
6
|
+
const OVERLAY_CONTAINER = 'lightning-overlay-container';
|
|
7
|
+
|
|
8
|
+
function container() {
|
|
9
|
+
// eslint-disable-next-line @lwc/lwc/no-document-query
|
|
10
|
+
let element = document.querySelector(`${ROOT} > ${OVERLAY_CONTAINER}`);
|
|
11
|
+
if (!element) {
|
|
12
|
+
element = createElement(OVERLAY_CONTAINER, { is: OverlayContainer });
|
|
13
|
+
document.body.appendChild(element);
|
|
14
|
+
}
|
|
15
|
+
return element;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Extend this component for open/close apis.
|
|
20
|
+
*/
|
|
21
|
+
export default class LightningOverlay extends LightningElement {
|
|
22
|
+
/**
|
|
23
|
+
* Easier to debug when dynamically created.
|
|
24
|
+
*/
|
|
25
|
+
static [instanceName] = 'lightning-overlay';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Open a modal instance
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} apis Set apis directly on the modal instance
|
|
31
|
+
*/
|
|
32
|
+
static open(apis) {
|
|
33
|
+
return container().push(this, apis);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The close api is public for testing only.
|
|
38
|
+
*
|
|
39
|
+
* @param {any} result Returned in the promise.
|
|
40
|
+
*/
|
|
41
|
+
@api
|
|
42
|
+
close(result, promise) {
|
|
43
|
+
container().pop(this.template.host, result, promise);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { LightningElement, api, createElement } from 'lwc';
|
|
2
|
+
import { parent, instanceName } from 'lightning/overlayUtils';
|
|
3
|
+
import {
|
|
4
|
+
addOverlay,
|
|
5
|
+
LwcOverlayType,
|
|
6
|
+
subscribeOverlay,
|
|
7
|
+
} from 'lightning/overlayManager';
|
|
8
|
+
|
|
9
|
+
export default class LightningOverlayContainer extends LightningElement {
|
|
10
|
+
// [{ element, parentElement, resolve }, ...]
|
|
11
|
+
stack = [];
|
|
12
|
+
|
|
13
|
+
get root() {
|
|
14
|
+
return this.template.querySelector('div');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate a new modal with params and return promise.
|
|
19
|
+
*
|
|
20
|
+
* @param {LightningModal} scope LightningOverlay extended class
|
|
21
|
+
* @param {Object} apis key value pair of apis to assign
|
|
22
|
+
*/
|
|
23
|
+
@api
|
|
24
|
+
push(scope, apis) {
|
|
25
|
+
apis = apis || {};
|
|
26
|
+
|
|
27
|
+
if (typeof apis !== 'object') {
|
|
28
|
+
throw new Error('Invalid .open() or .open({}) argument.');
|
|
29
|
+
}
|
|
30
|
+
const { [instanceName]: overlayInstanceName, [parent]: overlayParent } =
|
|
31
|
+
scope;
|
|
32
|
+
const element = createElement(overlayInstanceName, { is: scope });
|
|
33
|
+
|
|
34
|
+
Object.entries(apis).forEach(([key, value]) => {
|
|
35
|
+
const keyLower = key.toLowerCase();
|
|
36
|
+
const match = keyLower.match(/^on(.+)/);
|
|
37
|
+
if (match) {
|
|
38
|
+
const eventName = match[1];
|
|
39
|
+
element.addEventListener(eventName, value);
|
|
40
|
+
} else {
|
|
41
|
+
element[key] = value;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
let promise = null;
|
|
46
|
+
if (overlayParent) {
|
|
47
|
+
// Ex: extends LightningModal with wrapping LightningModalBase
|
|
48
|
+
const parentElement = createElement(overlayParent[instanceName], {
|
|
49
|
+
is: overlayParent,
|
|
50
|
+
});
|
|
51
|
+
this.root.appendChild(parentElement);
|
|
52
|
+
parentElement.defaultSlot.appendChild(element);
|
|
53
|
+
promise = new Promise((resolve) => {
|
|
54
|
+
this.stack.push({ resolve, element, parentElement });
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
this.root.appendChild(element);
|
|
58
|
+
promise = new Promise((resolve) => {
|
|
59
|
+
this.stack.push({ resolve, element });
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
// Aura Compatability
|
|
63
|
+
addOverlay(LwcOverlayType);
|
|
64
|
+
return promise;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Remove the last added popover.
|
|
69
|
+
*/
|
|
70
|
+
@api
|
|
71
|
+
pop(ele, result, promise) {
|
|
72
|
+
// element = `extends LightningOverlay`
|
|
73
|
+
// parentElement = Ex: LightningModalBase
|
|
74
|
+
const { element, parentElement, resolve } = this.stack.find(
|
|
75
|
+
({ element: e }) => e === ele
|
|
76
|
+
);
|
|
77
|
+
// Resolve immediately
|
|
78
|
+
resolve(result);
|
|
79
|
+
// Animate out. Ex: LightningModal slide up animation
|
|
80
|
+
if (promise) {
|
|
81
|
+
promise.then(() => {
|
|
82
|
+
this.removeOverlay(element, parentElement);
|
|
83
|
+
});
|
|
84
|
+
} else {
|
|
85
|
+
this.removeOverlay(element, parentElement);
|
|
86
|
+
}
|
|
87
|
+
// Remove from stack
|
|
88
|
+
this.stack = this.stack.filter(({ element: e }) => e !== ele);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Remove overlay (with IE11 support)
|
|
93
|
+
*
|
|
94
|
+
* @param {LightningModal} element Required
|
|
95
|
+
* @param {LightningElement} parentElement Optional
|
|
96
|
+
*/
|
|
97
|
+
removeOverlay(element, parentElement) {
|
|
98
|
+
if (parentElement && parentElement.remove) {
|
|
99
|
+
parentElement.remove();
|
|
100
|
+
} else if (parentElement) {
|
|
101
|
+
parentElement.parentNode.removeChild(parentElement);
|
|
102
|
+
} else if (element.remove) {
|
|
103
|
+
element.remove();
|
|
104
|
+
} else {
|
|
105
|
+
element.parentNode.removeChild(element);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
connectedCallback() {
|
|
110
|
+
// Notified anytime a overlay is added/removed
|
|
111
|
+
// zIndex assumes aura modals stack every other
|
|
112
|
+
subscribeOverlay((stack) => {
|
|
113
|
+
// LWC Overlays are always on odd zIndexes, aura even
|
|
114
|
+
let zIndex = 9001;
|
|
115
|
+
let modalCount = 0;
|
|
116
|
+
|
|
117
|
+
stack.forEach((overlayType) => {
|
|
118
|
+
if (overlayType === LwcOverlayType) {
|
|
119
|
+
const overlay = this.root.childNodes[modalCount];
|
|
120
|
+
if (overlay) {
|
|
121
|
+
overlay.style.zIndex = zIndex;
|
|
122
|
+
// ToDo: Refactor for LightningPanel
|
|
123
|
+
overlay.style.position = 'absolute';
|
|
124
|
+
}
|
|
125
|
+
modalCount += 1;
|
|
126
|
+
} else {
|
|
127
|
+
zIndex += 2;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// After this is fixed jest tests do not need clearOverlays()
|
|
134
|
+
// https://github.com/salesforce/lwc/issues/1102
|
|
135
|
+
// disconnectedCallback() {
|
|
136
|
+
// clearOverlays();
|
|
137
|
+
// }
|
|
138
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Track order of modals opening
|
|
2
|
+
const state = {
|
|
3
|
+
stack: [],
|
|
4
|
+
callback: null,
|
|
5
|
+
hasAura: false,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const LwcOverlayType = 'lwc';
|
|
9
|
+
export const AuraOverlayType = 'aura';
|
|
10
|
+
|
|
11
|
+
function triggerCallback() {
|
|
12
|
+
// Not triggered in pure LWC environment
|
|
13
|
+
if (state.callback) {
|
|
14
|
+
state.callback(state.stack);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Add an overlay to the stack
|
|
20
|
+
*/
|
|
21
|
+
export function addOverlay(overlayType) {
|
|
22
|
+
// Prevent unnecessary z-index in pure LWC
|
|
23
|
+
if (overlayType === AuraOverlayType) {
|
|
24
|
+
state.hasAura = true;
|
|
25
|
+
}
|
|
26
|
+
state.stack.push(overlayType);
|
|
27
|
+
triggerCallback();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Remove overlay from the stack
|
|
32
|
+
*/
|
|
33
|
+
export function removeOverlay() {
|
|
34
|
+
state.stack.pop();
|
|
35
|
+
triggerCallback();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* LightningOverlayContainer listener
|
|
40
|
+
*
|
|
41
|
+
* Only for LightningContainer usage
|
|
42
|
+
*/
|
|
43
|
+
export function subscribeOverlay(callback) {
|
|
44
|
+
state.callback = callback;
|
|
45
|
+
triggerCallback();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* TEST ONLY! Clear stack and reset hasAura
|
|
50
|
+
*/
|
|
51
|
+
export function clearOverlays() {
|
|
52
|
+
state.stack = [];
|
|
53
|
+
state.hasAura = false;
|
|
54
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional static parent definition on extended LightningOverlay
|
|
3
|
+
* Ex: static [parent] = CustomOverlayBase;
|
|
4
|
+
*/
|
|
5
|
+
export const parent = Symbol('parent');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Optional static instanceName for CustomOverlayBase;
|
|
9
|
+
* Ex: static [instanceName] = 'custom-overlay';
|
|
10
|
+
* This makes it easier to debug in the dom.
|
|
11
|
+
*/
|
|
12
|
+
export const instanceName = Symbol('instanceName');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Secure access to events
|
|
16
|
+
*/
|
|
17
|
+
export const secure = Symbol('secure event');
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
aria-valuemax="100"
|
|
5
5
|
aria-valuenow={percentValue}
|
|
6
6
|
aria-busy={ariaBusy}
|
|
7
|
-
role="progressbar"
|
|
7
|
+
role="progressbar"
|
|
8
|
+
aria-label={computeAriaLabel}>
|
|
8
9
|
<span class="slds-progress-bar__value" style={computedStyle}>
|
|
9
10
|
<span class="slds-assistive-text">{assistiveText}</span>
|
|
10
11
|
</span>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import labelProgress from '@salesforce/label/LightningProgressBar.progress';
|
|
2
|
+
import labelProgressBar from '@salesforce/label/LightningProgressBar.progressBar';
|
|
2
3
|
|
|
3
4
|
import { LightningElement, track, api } from 'lwc';
|
|
4
5
|
import { classSet } from 'lightning/utils';
|
|
5
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
normalizeString as normalize,
|
|
8
|
+
isUndefinedOrNull,
|
|
9
|
+
} from 'lightning/utilsPrivate';
|
|
6
10
|
import { numberFormat } from 'lightning/internationalizationLibrary';
|
|
7
11
|
|
|
8
12
|
// Temporary workaround until we get real label support. New label entries must
|
|
@@ -10,6 +14,7 @@ import { numberFormat } from 'lightning/internationalizationLibrary';
|
|
|
10
14
|
// https://git.soma.salesforce.com/raptor/raptor/issues/196
|
|
11
15
|
const i18n = {
|
|
12
16
|
progress: labelProgress,
|
|
17
|
+
progressBar: labelProgressBar,
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
const DEFAULT_SIZE = 'medium';
|
|
@@ -29,6 +34,12 @@ export default class LightningProgressBar extends LightningElement {
|
|
|
29
34
|
*/
|
|
30
35
|
@api value = 0;
|
|
31
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Describes the input to assistive technologies.
|
|
39
|
+
* @type {string}
|
|
40
|
+
*/
|
|
41
|
+
@api ariaLabel;
|
|
42
|
+
|
|
32
43
|
/**
|
|
33
44
|
* The variant changes the appearance of the progress bar.
|
|
34
45
|
* Accepted variants include base or circular.
|
|
@@ -109,4 +120,10 @@ export default class LightningProgressBar extends LightningElement {
|
|
|
109
120
|
|
|
110
121
|
return `${i18n.progress} ${formattedPercent}`;
|
|
111
122
|
}
|
|
123
|
+
|
|
124
|
+
get computeAriaLabel() {
|
|
125
|
+
return isUndefinedOrNull(this.ariaLabel)
|
|
126
|
+
? i18n.progressBar
|
|
127
|
+
: this.ariaLabel;
|
|
128
|
+
}
|
|
112
129
|
}
|