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.
Files changed (169) hide show
  1. package/metadata/raptor.json +31 -4
  2. package/package.json +13 -2
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningMap.defaultTitle.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
  6. package/src/lightning/alert/__docs__/alert.md +99 -0
  7. package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
  8. package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
  9. package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
  10. package/src/lightning/alert/alert.html +3 -0
  11. package/src/lightning/alert/alert.js +78 -0
  12. package/src/lightning/alert/alert.js-meta.xml +6 -0
  13. package/src/lightning/baseCombobox/baseCombobox.html +2 -1
  14. package/src/lightning/baseCombobox/baseCombobox.js +41 -6
  15. package/src/lightning/button/__wdio__/utam/utam.html +3 -0
  16. package/src/lightning/button/__wdio__/utam/utam.js +3 -0
  17. package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
  18. package/src/lightning/button/button.js +22 -1
  19. package/src/lightning/buttonMenu/buttonMenu.js +12 -0
  20. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  21. package/src/lightning/checkboxGroup/checkboxGroup.js +9 -5
  22. package/src/lightning/combobox/__docs__/combobox.md +3 -1
  23. package/src/lightning/combobox/combobox.js +0 -1
  24. package/src/lightning/confirm/__docs__/confirm.md +98 -0
  25. package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
  26. package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
  27. package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
  28. package/src/lightning/confirm/confirm.html +3 -0
  29. package/src/lightning/confirm/confirm.js +80 -0
  30. package/src/lightning/confirm/confirm.js-meta.xml +6 -0
  31. package/src/lightning/datatable/__docs__/datatable.md +45 -0
  32. package/src/lightning/datatable/__wdio__/utam/utam.html +32 -0
  33. package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
  34. package/src/lightning/datatable/__wdio__/utam/utam.spec.js +214 -0
  35. package/src/lightning/datatable/columns.js +166 -71
  36. package/src/lightning/datatable/datatable.js +103 -20
  37. package/src/lightning/datatable/headerActions.js +2 -2
  38. package/src/lightning/datatable/inlineEdit.js +0 -5
  39. package/src/lightning/datatable/inlineEditShared.js +4 -2
  40. package/src/lightning/datatable/keyboard.js +17 -13
  41. package/src/lightning/datatable/renderManager.js +45 -13
  42. package/src/lightning/datatable/resizeSensor.js +11 -3
  43. package/src/lightning/datatable/rowSelection.js +9 -3
  44. package/src/lightning/datatable/rowSelectionShared.js +33 -20
  45. package/src/lightning/datatable/rows.js +3 -2
  46. package/src/lightning/datatable/sort.js +8 -8
  47. package/src/lightning/datatable/state.js +9 -1
  48. package/src/lightning/datatable/templates/div/div.html +6 -2
  49. package/src/lightning/datatable/templates/table/table.html +7 -4
  50. package/src/lightning/datatable/tree.js +25 -0
  51. package/src/lightning/datatable/types.js +77 -9
  52. package/src/lightning/datatable/utils.js +51 -24
  53. package/src/lightning/datatable/virtualization.js +319 -0
  54. package/src/lightning/datatable/wrapText.js +54 -16
  55. package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
  56. package/src/lightning/datepicker/datepicker.html +1 -0
  57. package/src/lightning/datepicker/datepicker.js +10 -0
  58. package/src/lightning/datetimepicker/datetimepicker.html +2 -0
  59. package/src/lightning/datetimepicker/datetimepicker.js +8 -0
  60. package/src/lightning/dualListbox/dualListbox.js +2 -1
  61. package/src/lightning/formattedAddress/__docs__/formattedAddress.md +3 -0
  62. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.html +22 -0
  63. package/src/lightning/formattedAddress/__examples__/customLocale/customLocale.js +3 -0
  64. package/src/lightning/formattedAddress/formattedAddress.js +7 -1
  65. package/src/lightning/groupedCombobox/groupedCombobox.html +2 -1
  66. package/src/lightning/groupedCombobox/groupedCombobox.js +16 -2
  67. package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
  68. package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
  69. package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
  70. package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
  71. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
  72. package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
  73. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
  74. package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
  75. package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
  76. package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
  77. package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
  78. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
  79. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
  80. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
  81. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
  82. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
  83. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
  84. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
  85. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  86. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
  87. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
  88. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
  89. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
  90. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
  91. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
  92. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
  93. package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
  94. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
  95. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
  96. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
  97. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
  98. package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
  99. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
  100. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
  101. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
  102. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
  103. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
  104. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
  105. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
  106. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
  107. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
  108. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
  109. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
  110. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
  111. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
  112. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
  113. package/src/lightning/input/__docs__/input.md +2 -0
  114. package/src/lightning/input/input.html +6 -0
  115. package/src/lightning/input/input.js +2 -1
  116. package/src/lightning/inputAddress/__docs__/inputAddress.md +5 -0
  117. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.html +12 -0
  118. package/src/lightning/inputAddress/__examples__/customLocale/customLocale.js +3 -0
  119. package/src/lightning/inputAddress/inputAddress.html +2 -0
  120. package/src/lightning/inputAddress/inputAddress.js +26 -3
  121. package/src/lightning/inputName/__docs__/inputName.md +2 -0
  122. package/src/lightning/inputName/inputName.html +4 -1
  123. package/src/lightning/inputUtils/inputUtils.js +11 -0
  124. package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
  125. package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
  126. package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
  127. package/src/lightning/menuItem/menuItem.js +4 -1
  128. package/src/lightning/modalBase/modalBase.css +20 -0
  129. package/src/lightning/modalBase/modalBase.html +54 -0
  130. package/src/lightning/modalBase/modalBase.js +1039 -0
  131. package/src/lightning/overlay/__docs__/overlay.md +90 -0
  132. package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
  133. package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
  134. package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
  135. package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
  136. package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
  137. package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
  138. package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
  139. package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
  140. package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
  141. package/src/lightning/overlay/overlay.html +3 -0
  142. package/src/lightning/overlay/overlay.js +45 -0
  143. package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
  144. package/src/lightning/overlayContainer/overlayContainer.html +3 -0
  145. package/src/lightning/overlayContainer/overlayContainer.js +138 -0
  146. package/src/lightning/overlayManager/overlayManager.js +54 -0
  147. package/src/lightning/overlayUtils/overlayUtils.js +17 -0
  148. package/src/lightning/picklist/picklist.js +6 -1
  149. package/src/lightning/progressBar/progressBar.html +2 -1
  150. package/src/lightning/progressBar/progressBar.js +18 -1
  151. package/src/lightning/prompt/__docs__/prompt.md +100 -0
  152. package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
  153. package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
  154. package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
  155. package/src/lightning/prompt/prompt.css +81 -0
  156. package/src/lightning/prompt/prompt.html +8 -0
  157. package/src/lightning/prompt/prompt.js +92 -0
  158. package/src/lightning/prompt/prompt.js-meta.xml +6 -0
  159. package/src/lightning/radioGroup/radioGroup.js +9 -0
  160. package/src/lightning/select/select.html +3 -1
  161. package/src/lightning/select/select.js +5 -1
  162. package/src/lightning/textarea/textarea.html +1 -0
  163. package/src/lightning/textarea/textarea.js +5 -0
  164. package/src/lightning/timepicker/timepicker.html +3 -1
  165. package/src/lightning/timepicker/timepicker.js +8 -0
  166. package/src/lightning/utilsPrivate/aria.js +26 -0
  167. package/src/lightning/utilsPrivate/linkify.js +1 -1
  168. package/src/lightning/utilsPrivate/utilsPrivate.js +7 -1
  169. package/src/lightning/icon/__component__/icon-spirite.spec.js +0 -59
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <fieldset aria-describedby={computearaiDescriedBy}>
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 input component. To hide a label from view and make it
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`**
@@ -300,7 +300,6 @@ export default class LightningCombobox extends LightningElement {
300
300
  /**
301
301
  * Represents the validity states that an element can be in, with respect to constraint validation.
302
302
  * @type {object}
303
- * @required
304
303
  */
305
304
  @api
306
305
  get validity() {
@@ -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,7 @@
1
+ .example {
2
+ margin: 0.5rem;
3
+ border-radius: 0.5rem;
4
+ background: #FFF;
5
+ box-shadow: 0 1px 0.25rem rgba(0, 0, 0, 0.2);
6
+ padding: 1rem;
7
+ }
@@ -0,0 +1,8 @@
1
+ <template>
2
+ <div class="example">
3
+ <button
4
+ aria-haspopup="modal"
5
+ onclick={handleConfirmModal}
6
+ >Open the Confirm Modal</button>
7
+ </div>
8
+ </template>
@@ -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,3 @@
1
+ <template>
2
+ <p>{message}</p>
3
+ </template>
@@ -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
+ }
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <isExposed>true</isExposed>
4
+ <minApiVersion>54.0</minApiVersion>
5
+ <support>GA</support>
6
+ </LightningComponentBundle>
@@ -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
+ }