lightning-base-components 1.14.6-alpha → 1.15.2-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 +31 -4
- package/package.json +13 -2
- package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
- package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
- package/src/lightning/alert/__docs__/alert.md +99 -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/baseCombobox/baseCombobox.html +2 -1
- package/src/lightning/baseCombobox/baseCombobox.js +41 -6
- 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/button/button.js +22 -1
- package/src/lightning/buttonMenu/buttonMenu.js +12 -0
- package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
- package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
- package/src/lightning/combobox/__docs__/combobox.md +3 -1
- package/src/lightning/combobox/combobox.js +0 -1
- package/src/lightning/confirm/__docs__/confirm.md +98 -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/__docs__/datatable.md +45 -0
- package/src/lightning/datatable/__wdio__/utam/utam.html +32 -0
- package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
- package/src/lightning/datatable/__wdio__/utam/utam.spec.js +214 -0
- package/src/lightning/datatable/columns.js +166 -71
- package/src/lightning/datatable/datatable.js +103 -20
- package/src/lightning/datatable/headerActions.js +2 -2
- package/src/lightning/datatable/inlineEdit.js +0 -5
- package/src/lightning/datatable/inlineEditShared.js +4 -2
- package/src/lightning/datatable/keyboard.js +17 -13
- package/src/lightning/datatable/renderManager.js +45 -13
- package/src/lightning/datatable/resizeSensor.js +11 -3
- package/src/lightning/datatable/rowSelection.js +9 -3
- package/src/lightning/datatable/rowSelectionShared.js +33 -20
- package/src/lightning/datatable/rows.js +3 -2
- package/src/lightning/datatable/sort.js +8 -8
- package/src/lightning/datatable/state.js +9 -1
- package/src/lightning/datatable/templates/div/div.html +6 -2
- package/src/lightning/datatable/templates/table/table.html +7 -4
- 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/wrapText.js +54 -16
- package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
- package/src/lightning/datepicker/datepicker.html +1 -0
- package/src/lightning/datepicker/datepicker.js +10 -0
- package/src/lightning/datetimepicker/datetimepicker.html +2 -0
- package/src/lightning/datetimepicker/datetimepicker.js +8 -0
- package/src/lightning/dualListbox/dualListbox.js +2 -1
- package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
- package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/formattedAddress/formattedAddress.js +7 -1
- package/src/lightning/groupedCombobox/groupedCombobox.html +2 -1
- package/src/lightning/groupedCombobox/groupedCombobox.js +16 -2
- 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 +6 -0
- package/src/lightning/input/input.js +2 -1
- package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
- package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
- package/src/lightning/inputAddress/inputAddress.html +2 -0
- package/src/lightning/inputAddress/inputAddress.js +26 -3
- package/src/lightning/inputName/__docs__/inputName.md +2 -0
- package/src/lightning/inputName/inputName.html +4 -1
- package/src/lightning/inputUtils/inputUtils.js +11 -0
- 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/picklist/picklist.js +6 -1
- package/src/lightning/progressBar/progressBar.html +2 -1
- package/src/lightning/progressBar/progressBar.js +18 -1
- package/src/lightning/prompt/__docs__/prompt.md +100 -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/radioGroup/radioGroup.js +9 -0
- package/src/lightning/select/select.html +3 -1
- package/src/lightning/select/select.js +5 -1
- package/src/lightning/textarea/textarea.html +1 -0
- package/src/lightning/textarea/textarea.js +5 -0
- package/src/lightning/timepicker/timepicker.html +3 -1
- package/src/lightning/timepicker/timepicker.js +8 -0
- package/src/lightning/utilsPrivate/aria.js +26 -0
- package/src/lightning/utilsPrivate/linkify.js +1 -1
- package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
- package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<fieldset
|
|
2
|
+
<fieldset>
|
|
3
3
|
|
|
4
4
|
<legend class={computedLegendClass}>
|
|
5
5
|
<template if:true={required}>
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
<template if:true={_helpMessage}>
|
|
33
33
|
<div id="helptext" data-helptext class="slds-form-element__help">{_helpMessage}</div>
|
|
34
34
|
</template>
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
</fieldset>
|
|
37
37
|
</template>
|
|
@@ -97,8 +97,17 @@ export default class LightningCheckboxGroup extends LightningElement {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
get fieldsetElement() {
|
|
101
|
+
return this.template.querySelector('fieldset');
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
renderedCallback() {
|
|
101
105
|
this.synchronizeA11y();
|
|
106
|
+
synchronizeAttrs(this.fieldsetElement, {
|
|
107
|
+
'aria-describedby': getRealDOMId(
|
|
108
|
+
this.template.querySelector('[data-helptext]')
|
|
109
|
+
),
|
|
110
|
+
});
|
|
102
111
|
}
|
|
103
112
|
|
|
104
113
|
/**
|
|
@@ -313,9 +322,4 @@ export default class LightningCheckboxGroup extends LightningElement {
|
|
|
313
322
|
})
|
|
314
323
|
.toString();
|
|
315
324
|
}
|
|
316
|
-
|
|
317
|
-
computearaiDescriedBy() {
|
|
318
|
-
const helpMessage = this.template.querySelector('[data-helptext]');
|
|
319
|
-
return getRealDOMId(helpMessage);
|
|
320
|
-
}
|
|
321
325
|
}
|
|
@@ -118,9 +118,11 @@ We recommend using the HTML `<select>` element on mobile instead.
|
|
|
118
118
|
|
|
119
119
|
You must provide a text label for accessibility to make the information
|
|
120
120
|
available to assistive technology. The `label` attribute creates an HTML label
|
|
121
|
-
element for your
|
|
121
|
+
element for your component. To hide a label from view and make it
|
|
122
122
|
available to assistive technology, use the `label-hidden` variant.
|
|
123
123
|
|
|
124
|
+
This component uses `button` elements for select-only comboboxes to comply with the [Lightning Design System combobox blueprint](https://www.lightningdesignsystem.com/components/combobox/#%22Input%22-markup).
|
|
125
|
+
|
|
124
126
|
#### Custom Events
|
|
125
127
|
|
|
126
128
|
**`change`**
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
The `lightning/confirm` module lets you create a confirm modal within your component. Use `LightningConfirm` on your component to ask the user to respond before they continue.
|
|
2
|
+
|
|
3
|
+
Use `LightningConfirm.open()` instead of the native `window.confirm()` for a more consistent user experience. They have similar functions, but `LightningConfirm.open()` works in cross-origin iframes, where the `.confirm()` method is no longer supported in Chrome and Safari. Unlike `window.confirm()`, `LightningConfirm.open()` doesn't halt execution on the page, it returns a Promise. Use `async`/`await` or `.then()` for any code you want to execute after the confirm has closed.
|
|
4
|
+
|
|
5
|
+
Import `LightningConfirm` from the `lightning/confirm` module in the component that will launch the confirm modal, and call `LightningConfirm.open()` with your desired attributes.
|
|
6
|
+
|
|
7
|
+
This example creates a headerless confirm modal with two buttons, **OK** and **Cancel**. The `.open()` function returns a promise that resolves to true when you click **OK** and false when you click **Cancel**.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<!-- c/myApp.html -->
|
|
11
|
+
<template>
|
|
12
|
+
<lightning-button onclick="{handleConfirmClick}" label="Open Confirm Modal">
|
|
13
|
+
</lightning-button>
|
|
14
|
+
</template>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
import { LightningElement } from 'lwc';
|
|
19
|
+
import LightningConfirm from 'lightning/confirm';
|
|
20
|
+
|
|
21
|
+
export default class MyApp extends LightningElement {
|
|
22
|
+
async handleConfirmClick() {
|
|
23
|
+
const result = await LightningConfirm.open({
|
|
24
|
+
message: 'this is the prompt message',
|
|
25
|
+
variant: 'headerless',
|
|
26
|
+
label: 'this is the aria-label value',
|
|
27
|
+
// setting theme would have no effect
|
|
28
|
+
});
|
|
29
|
+
//Confirm has been closed
|
|
30
|
+
//result is true if OK was clicked
|
|
31
|
+
//and false if cancel was clicked
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
#### Component Styling
|
|
37
|
+
|
|
38
|
+
This component uses the Salesforce Lightning Design System (SLDS) [`prompt` blueprint](https://www.lightningdesignsystem.com/components/prompt/#site-main-content).
|
|
39
|
+
|
|
40
|
+
`LightningConfirm` supports the following attributes:
|
|
41
|
+
|
|
42
|
+
- `message`: Message text that displays in the confirm.
|
|
43
|
+
- `label`: Header text, also used as the `aria-label`. Default string is `Confirm`.
|
|
44
|
+
- `variant`: Two values, `header` and `headerless`. Default value is `header`.
|
|
45
|
+
- `theme`: Color theme for the header. The `theme` attribute supports the following [options](https://www.lightningdesignsystem.com/utilities/themes/#site-main-content) from SLDS:
|
|
46
|
+
- `default`: white
|
|
47
|
+
- `shade`: gray
|
|
48
|
+
- `inverse`: dark blue
|
|
49
|
+
- `alt-inverse`: darker blue
|
|
50
|
+
- `success`: green
|
|
51
|
+
- `info`: gray-ish blue
|
|
52
|
+
- `warning`: yellow
|
|
53
|
+
- `error`: red
|
|
54
|
+
- `offline`: black
|
|
55
|
+
|
|
56
|
+
If an invalid value is provided, `LightningConfirm` uses the `default` theme.
|
|
57
|
+
|
|
58
|
+
#### Testing Your Component's Confirm
|
|
59
|
+
|
|
60
|
+
Code using `LightningConfirm` can be tested by mocking the `LightningConfirm.open()` method.
|
|
61
|
+
|
|
62
|
+
The example below uses a button to open a confirm dialog and sets the result in a template.
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<button data-button onclick="{handleClick}">Open Confirm</button>
|
|
66
|
+
<div data-result>{result}</div>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import LightningConfirm from 'lightning/confirm';
|
|
71
|
+
jest.mock('lightning/confirm');
|
|
72
|
+
|
|
73
|
+
test(() => {
|
|
74
|
+
// Create and appendChild(element)
|
|
75
|
+
|
|
76
|
+
const buttonEle = element.shadowRoot.querySelector('[data-button]');
|
|
77
|
+
const resultEle = element.shadowRoot.querySelector('[data-result]');
|
|
78
|
+
|
|
79
|
+
// Mock .open()
|
|
80
|
+
// Pass true if testing when user clicks "OK"
|
|
81
|
+
// Pass false if testing when user clicks "Cancel"
|
|
82
|
+
LightningConfirm.open = jest.fn().mockResolvedValue(true);
|
|
83
|
+
// Initial value
|
|
84
|
+
expect(resultEle.textContent).toBe('unknown');
|
|
85
|
+
// Click modal open button
|
|
86
|
+
buttonEle.click();
|
|
87
|
+
|
|
88
|
+
// Click handler render cycle
|
|
89
|
+
await Promise.resolve();
|
|
90
|
+
// Render cycle triggered by tracked value {result}
|
|
91
|
+
await Promise.resolve();
|
|
92
|
+
|
|
93
|
+
// Verify result is set in the template
|
|
94
|
+
expect(resultEle.textContent).toBe('true');
|
|
95
|
+
// Open triggered once
|
|
96
|
+
expect(LightningConfirm.open.mock.calls).toHaveLength(1);
|
|
97
|
+
})
|
|
98
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LightningElement } from 'lwc';
|
|
2
|
+
import LightningConfirm from 'lightning/confirm';
|
|
3
|
+
|
|
4
|
+
export default class ConfirmBasic extends LightningElement {
|
|
5
|
+
handleConfirmModal() {
|
|
6
|
+
LightningConfirm.open({
|
|
7
|
+
message: 'this is the confirm message',
|
|
8
|
+
label: 'Please Confirm',
|
|
9
|
+
theme: 'warning',
|
|
10
|
+
}).then((result) => {
|
|
11
|
+
console.log('confirm result', result);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { api } from 'lwc';
|
|
2
|
+
import LightningInteractiveDialogBase from 'lightning/interactiveDialogBase';
|
|
3
|
+
import { parent, instanceName, secure } from 'lightning/overlayUtils';
|
|
4
|
+
import LightningOverlay from 'lightning/overlay';
|
|
5
|
+
import labelDefault from '@salesforce/label/LightningConfirm.defaultLabel';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a confirm modal within your component that asks the user
|
|
9
|
+
* to respond before they continue.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export default class LightningConfirm extends LightningOverlay {
|
|
13
|
+
static [instanceName] = 'lightning-confirm';
|
|
14
|
+
static [parent] = LightningInteractiveDialogBase;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* value to use for header text in "header" variant
|
|
18
|
+
* or aria-label in "headerless" variant
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @default "Confirm" (translated accordingly)
|
|
21
|
+
*/
|
|
22
|
+
@api label = labelDefault;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* text to display in body of modal
|
|
26
|
+
*/
|
|
27
|
+
@api message = '';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* variant to use for alert; may be
|
|
31
|
+
* set to "header" or "headerless"
|
|
32
|
+
*/
|
|
33
|
+
@api variant = 'header';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* theme to use when variant is "header"
|
|
37
|
+
* valid values are based on SLDS themes and are
|
|
38
|
+
* listed in "themeOptions" of interactiveDialogBase.js
|
|
39
|
+
*/
|
|
40
|
+
@api theme = 'default';
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Dispatches privateclose event
|
|
44
|
+
* and closes dialog
|
|
45
|
+
*/
|
|
46
|
+
close(result) {
|
|
47
|
+
const promise = new Promise((resolve) => {
|
|
48
|
+
this.dispatchEvent(
|
|
49
|
+
new CustomEvent('privateclose', {
|
|
50
|
+
detail: {
|
|
51
|
+
resolve,
|
|
52
|
+
[secure]: true,
|
|
53
|
+
},
|
|
54
|
+
bubbles: true,
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
super.close(result, promise);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Dispatches privatechildrender event
|
|
63
|
+
* with data parent needs to correctly render
|
|
64
|
+
*/
|
|
65
|
+
renderedCallback() {
|
|
66
|
+
const evt = new CustomEvent('privatechildrender', {
|
|
67
|
+
bubbles: true,
|
|
68
|
+
detail: {
|
|
69
|
+
message: this.message,
|
|
70
|
+
label: this.label,
|
|
71
|
+
hideCancel: false,
|
|
72
|
+
showDescription: true,
|
|
73
|
+
getOkValue: () => true,
|
|
74
|
+
getCancelValue: () => false,
|
|
75
|
+
role: 'alertdialog',
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
this.dispatchEvent(evt);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -30,6 +30,7 @@ include:
|
|
|
30
30
|
|
|
31
31
|
- Displaying and formatting of columns with appropriate data types
|
|
32
32
|
- Infinite scrolling of rows
|
|
33
|
+
- Virtualized rendering
|
|
33
34
|
- Inline editing for some data types
|
|
34
35
|
- Header actions
|
|
35
36
|
- Row-level actions
|
|
@@ -606,6 +607,50 @@ the `totalNumberOfRows` attribute during initialization.
|
|
|
606
607
|
SELECT COUNT(Id) FROM Contact
|
|
607
608
|
```
|
|
608
609
|
|
|
610
|
+
#### Virtualize Rendering
|
|
611
|
+
|
|
612
|
+
A virtualized datatable only renders the rows that are visible and a buffer of a few rows above and below them. This makes scrolling a lot smoother for datatables with more than 200 rows. This example shows how to enable virtualization for a datatable.
|
|
613
|
+
|
|
614
|
+
In the JavaScript file of your component, create a `renderConfig` object with the attribute `virtualize` set to `vertical`.
|
|
615
|
+
|
|
616
|
+
```
|
|
617
|
+
import { LightningElement } from 'lwc';
|
|
618
|
+
|
|
619
|
+
export default class DataTable extends LightningElement {
|
|
620
|
+
// set data
|
|
621
|
+
// set columns
|
|
622
|
+
renderConfig = {
|
|
623
|
+
virtualize: 'vertical',
|
|
624
|
+
// additional customization
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
In your `lightning-datatable` component file, set the `render-config` attribute to the `renderConfig` object you created. Set the component’s `render-mode` attribute to `role-based` and set the `lightning-datatable` component’s parent container to an explicit height. This can be a pixel value, a percentage, or an inherited height.
|
|
630
|
+
|
|
631
|
+
```
|
|
632
|
+
<template>
|
|
633
|
+
<div style="height: 300px;">
|
|
634
|
+
<lightning-datatable
|
|
635
|
+
key-field="id"
|
|
636
|
+
data={data}
|
|
637
|
+
columns={columns}
|
|
638
|
+
render-mode="role-based"
|
|
639
|
+
render-config={renderConfig}>
|
|
640
|
+
</lightning-datatable>
|
|
641
|
+
</div>
|
|
642
|
+
</template>
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
The `render-config` attribute supports these properties.
|
|
646
|
+
Property|Type|Default Value|Description
|
|
647
|
+
-----|-----|-----|-----
|
|
648
|
+
`bufferSize`|Number|`5`|Sets the number of additional rows that the component renders before and after the rows displayed in the viewport.
|
|
649
|
+
`fixedHeight`|Boolean|`false`|Makes every row the same height to reduce the load time that's spent caching the height of each row separately. If column wrapping is also enabled, rows can be positioned improperly.
|
|
650
|
+
`rowHeight`|Number|`30.5`|Height in pixels of a table row with one line of text.
|
|
651
|
+
`virtualize`|String|Empty string|Enables virtualization when set to `vertical`.
|
|
652
|
+
|
|
653
|
+
|
|
609
654
|
#### Creating Header Actions
|
|
610
655
|
|
|
611
656
|
Header actions refer to tasks you can perform on a column of data, such
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="height:160px">
|
|
3
|
+
<lightning-datatable
|
|
4
|
+
data-render-mode="default"
|
|
5
|
+
key-field="id"
|
|
6
|
+
columns={columns}
|
|
7
|
+
data={data}
|
|
8
|
+
default-sort-direction={defaultSortDirection}
|
|
9
|
+
sorted-direction={sortDirection}
|
|
10
|
+
sorted-by={sortedBy}
|
|
11
|
+
onsort={onHandleSort}
|
|
12
|
+
is-loading={loading}>
|
|
13
|
+
</lightning-datatable>
|
|
14
|
+
</div>
|
|
15
|
+
<div style="height:160px">
|
|
16
|
+
<lightning-datatable
|
|
17
|
+
data-render-mode="role-based"
|
|
18
|
+
key-field="id"
|
|
19
|
+
columns={columns}
|
|
20
|
+
data={data}
|
|
21
|
+
default-sort-direction={defaultSortDirection}
|
|
22
|
+
sorted-direction={sortDirection}
|
|
23
|
+
sorted-by={sortedBy}
|
|
24
|
+
onsort={onHandleSort}
|
|
25
|
+
is-loading={loading}
|
|
26
|
+
render-mode="role-based">
|
|
27
|
+
</lightning-datatable>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<lightning-button label="Enable Loading State" onclick={handleLoadingClick}></lightning-button>
|
|
31
|
+
<lightning-button label="Add More Rows" onclick={handleMoreRowsClick}></lightning-button>
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { LightningElement } from 'lwc';
|
|
2
|
+
|
|
3
|
+
const data = [
|
|
4
|
+
{ id: 1, name: 'Billy Simmons', age: 40, email: 'billy@salesforce.com' },
|
|
5
|
+
{ id: 2, name: 'Kelsey Denesik', age: 35, email: 'kelsey@salesforce.com' },
|
|
6
|
+
{ id: 3, name: 'Kyle Ruecker', age: 50, email: 'kyle@salesforce.com' },
|
|
7
|
+
{
|
|
8
|
+
id: 4,
|
|
9
|
+
name: 'Krystina Kerluke',
|
|
10
|
+
age: 37,
|
|
11
|
+
email: 'krystina@salesforce.com',
|
|
12
|
+
},
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
const actions = [
|
|
16
|
+
{ label: 'Show details', name: 'show_details' },
|
|
17
|
+
{ label: 'Delete', name: 'delete' },
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const columns = [
|
|
21
|
+
{ label: 'Name', fieldName: 'name' },
|
|
22
|
+
{
|
|
23
|
+
label: 'Age',
|
|
24
|
+
fieldName: 'age',
|
|
25
|
+
type: 'number',
|
|
26
|
+
sortable: true,
|
|
27
|
+
cellAttributes: { alignment: 'left' },
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: 'Email',
|
|
31
|
+
fieldName: 'email',
|
|
32
|
+
type: 'email',
|
|
33
|
+
hideDefaultActions: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: 'action',
|
|
37
|
+
typeAttributes: { rowActions: actions, menuAlignment: 'right' },
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
export default class DemoApp extends LightningElement {
|
|
42
|
+
data = data;
|
|
43
|
+
columns = columns;
|
|
44
|
+
defaultSortDirection = 'asc';
|
|
45
|
+
sortDirection = 'asc';
|
|
46
|
+
sortedBy;
|
|
47
|
+
loading = false;
|
|
48
|
+
|
|
49
|
+
// Used to sort the 'Age' column
|
|
50
|
+
sortBy(field, reverse, primer) {
|
|
51
|
+
const key = primer
|
|
52
|
+
? function (x) {
|
|
53
|
+
return primer(x[field]);
|
|
54
|
+
}
|
|
55
|
+
: function (x) {
|
|
56
|
+
return x[field];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return function (a, b) {
|
|
60
|
+
a = key(a);
|
|
61
|
+
b = key(b);
|
|
62
|
+
return reverse * ((a > b) - (b > a));
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onHandleSort(event) {
|
|
67
|
+
const { fieldName: sortedBy, sortDirection } = event.detail;
|
|
68
|
+
const cloneData = [...this.data];
|
|
69
|
+
|
|
70
|
+
cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1));
|
|
71
|
+
this.data = cloneData;
|
|
72
|
+
this.sortDirection = sortDirection;
|
|
73
|
+
this.sortedBy = sortedBy;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
handleLoadingClick() {
|
|
77
|
+
this.loading = !this.loading;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
handleMoreRowsClick() {
|
|
81
|
+
const control = [
|
|
82
|
+
{
|
|
83
|
+
id: 20,
|
|
84
|
+
name: 'Jacqueline Palmer',
|
|
85
|
+
age: 60,
|
|
86
|
+
email: 'jacqueline@salesforce.com',
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
this.data = this.data.concat(this.data).concat(control);
|
|
90
|
+
}
|
|
91
|
+
}
|