lightning-base-components 1.21.8-alpha → 1.22.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.
Files changed (76) hide show
  1. package/metadata/raptor.json +3 -0
  2. package/package.json +3 -5
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/src/lightning/accordionSection/button.slds.css +16 -13
  5. package/src/lightning/baseComboboxFormattedText/baseComboboxFormattedText.js-meta.xml +1 -1
  6. package/src/lightning/button/button.slds.css +16 -13
  7. package/src/lightning/buttonIcon/button-icon.slds.css +16 -13
  8. package/src/lightning/buttonIconStateful/button-icon.slds.css +16 -13
  9. package/src/lightning/buttonIconStateful/button.slds.css +16 -13
  10. package/src/lightning/buttonMenu/button-icon.slds.css +16 -13
  11. package/src/lightning/buttonMenu/button.slds.css +16 -13
  12. package/src/lightning/buttonMenu/buttonMenu.js +5 -3
  13. package/src/lightning/buttonStateful/button-stateful.slds.css +23 -0
  14. package/src/lightning/buttonStateful/button.slds.css +16 -13
  15. package/src/lightning/buttonStateful/buttonStateful.js-meta.xml +3 -0
  16. package/src/lightning/calendar/keyboard.js +11 -3
  17. package/src/lightning/combobox/combobox.js +5 -13
  18. package/src/lightning/datatable/__examples__/withVirtualization/withVirtualization.js +0 -1
  19. package/src/lightning/datatable/datatable.js +35 -39
  20. package/src/lightning/datatable/keyboard.js +11 -10
  21. package/src/lightning/datatable/renderManager.js +1 -3
  22. package/src/lightning/datatable/rows.js +16 -9
  23. package/src/lightning/datatable/state.js +0 -1
  24. package/src/lightning/datatable/templates/div/div.html +8 -8
  25. package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +7 -0
  26. package/src/lightning/datatable/virtualization.js +11 -14
  27. package/src/lightning/formattedAddress/formattedAddress.js +3 -2
  28. package/src/lightning/formattedDateTime/formattedDateTime.js +3 -2
  29. package/src/lightning/formattedDateTime/formattedDateTime.js-meta.xml +1 -1
  30. package/src/lightning/formattedLocation/formattedLocation.js +3 -2
  31. package/src/lightning/formattedPhone/formattedPhone.js +3 -2
  32. package/src/lightning/formattedTime/formattedTime.js +3 -2
  33. package/src/lightning/formattedUrl/formattedUrl.js +3 -2
  34. package/src/lightning/helptext/button-icon.slds.css +16 -13
  35. package/src/lightning/helptext/helptext.js-meta.xml +3 -0
  36. package/src/lightning/inputAddress/__docs__/inputAddress.md +44 -3
  37. package/src/lightning/inputAddress/inputAddress.js +8 -6
  38. package/src/lightning/inputName/inputName.js-meta.xml +3 -0
  39. package/src/lightning/interactiveDialogBase/button.slds.css +507 -0
  40. package/src/lightning/interactiveDialogBase/interactive-dialog-base.slds.css +45 -17
  41. package/src/lightning/interactiveDialogBase/interactiveDialogBase.lbc.native.css +6 -1
  42. package/src/lightning/interactiveDialogBase/modal-base.slds.css +242 -0
  43. package/src/lightning/interactiveDialogBase/modal-body.slds.css +60 -0
  44. package/src/lightning/interactiveDialogBase/modal-footer.slds.css +79 -0
  45. package/src/lightning/interactiveDialogBase/modal-header.slds.css +76 -0
  46. package/src/lightning/lookupAddress/lookupAddress.js-meta.xml +3 -0
  47. package/src/lightning/menuDivider/menuDivider.js-meta.xml +3 -0
  48. package/src/lightning/menuItem/menuItem.js +19 -3
  49. package/src/lightning/menuSubheader/menuSubheader.js-meta.xml +3 -0
  50. package/src/lightning/modal/modal.js-meta.xml +3 -0
  51. package/src/lightning/modalBase/modalBase.js +7 -5
  52. package/src/lightning/modalBody/modalBody.js-meta.xml +3 -0
  53. package/src/lightning/modalFooter/modalFooter.js-meta.xml +3 -0
  54. package/src/lightning/modalHeader/modalHeader.js-meta.xml +3 -0
  55. package/src/lightning/picklist/picklist.js +3 -2
  56. package/src/lightning/pill/pill.js +1 -1
  57. package/src/lightning/pillContainer/button.slds.css +16 -13
  58. package/src/lightning/primitiveDatatableTooltip/primitiveDatatableTooltip.js +11 -7
  59. package/src/lightning/primitiveDatatableTooltipBubble/primitiveDatatableTooltipBubble.html +1 -1
  60. package/src/lightning/primitiveFileDroppableZone/primitiveFileDroppableZone.js +3 -2
  61. package/src/lightning/primitiveInputCheckbox/input-checkbox.slds.css +1 -1
  62. package/src/lightning/primitiveInputFile/button.slds.css +16 -13
  63. package/src/lightning/primitiveInputFile/input-file.slds.css +3 -2
  64. package/src/lightning/primitiveInputToggle/input-toggle.slds.css +13 -7
  65. package/src/lightning/progressBar/progressBar.js-meta.xml +3 -0
  66. package/src/lightning/progressRing/progressRing.js-meta.xml +3 -0
  67. package/src/lightning/prompt/form-element.slds.css +319 -0
  68. package/src/lightning/prompt/input-text.slds.css +506 -0
  69. package/src/lightning/prompt/prompt.lbc.native.css +2 -0
  70. package/src/lightning/purifyLib/purify.js +838 -586
  71. package/src/lightning/radioGroup/radioGroup.js-meta.xml +3 -0
  72. package/src/lightning/textarea/textarea.js-meta.xml +3 -0
  73. package/src/lightning/toast/button-icon.slds.css +16 -13
  74. package/src/lightning/toast/toast.js-meta.xml +3 -0
  75. package/src/lightning/toastContainer/toastContainer.js-meta.xml +3 -0
  76. package/src/lightning/verticalNavigationOverflow/button.slds.css +16 -13
@@ -280,7 +280,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
280
280
 
281
281
  /* Text color */
282
282
  --sds-c-button-text-color: var(--slds-c-button-neutral-text-color, var(--slds-g-color-accent-2));
283
- --sds-c-button-text-color-hover: var(--slds-c-button-neutral-text-color-hover, var(--slds-g-color-accent-3));
283
+ --sds-c-button-text-color-hover: var(--slds-c-button-neutral-text-color-hover, var(--slds-s-button-color-hover, var(--slds-g-color-accent-3)));
284
284
  --sds-c-button-text-color-focus: var(--slds-c-button-neutral-text-color-focus, var(--slds-g-color-accent-3));
285
285
  --sds-c-button-text-color-active: var(
286
286
  --slds-c-button-neutral-text-color-active,
@@ -315,36 +315,36 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
315
315
  :host([data-render-mode="shadow"][variant='brand']) [part~='button'] {
316
316
  --slds-c-button-neutral-color-background: var(
317
317
  --slds-c-button-brand-color-background,
318
- var(--slds-g-color-accent-container-2)
318
+ var(--slds-g-color-accent-container-1)
319
319
  );
320
320
  --slds-c-button-neutral-color-background-hover: var(
321
321
  --slds-c-button-brand-color-background-hover,
322
- var(--slds-g-color-accent-container-3)
322
+ var(--slds-g-color-accent-container-2)
323
323
  );
324
324
  --slds-c-button-neutral-color-background-focus: var(
325
325
  --slds-c-button-brand-color-background-focus,
326
- var(--slds-g-color-accent-container-3)
326
+ var(--slds-g-color-accent-container-2)
327
327
  );
328
328
  --slds-c-button-neutral-color-background-active: var(
329
329
  --slds-c-button-brand-color-background-active,
330
- var(--slds-g-color-accent-container-3)
330
+ var(--slds-g-color-accent-container-2)
331
331
  );
332
332
 
333
333
  --slds-c-button-neutral-color-border: var(
334
334
  --slds-c-button-brand-color-border,
335
- var(--slds-g-color-border-accent-2)
335
+ var(--slds-g-color-border-accent-1)
336
336
  );
337
337
  --slds-c-button-neutral-color-border-hover: var(
338
338
  --slds-c-button-brand-color-border-hover,
339
- var(--slds-g-color-border-accent-3)
339
+ var(--slds-g-color-border-accent-2)
340
340
  );
341
341
  --slds-c-button-neutral-color-border-focus: var(
342
342
  --slds-c-button-brand-color-border-focus,
343
- var(--slds-g-color-border-accent-3)
343
+ var(--slds-g-color-border-accent-2)
344
344
  );
345
345
  --slds-c-button-neutral-color-border-active: var(
346
346
  --slds-c-button-brand-color-border-active,
347
- var(--slds-g-color-border-accent-3)
347
+ var(--slds-g-color-border-accent-2)
348
348
  );
349
349
 
350
350
  /* Since the text color is white for all states, bypassing inheritence and setting the color value from SDS */
@@ -396,7 +396,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
396
396
  --slds-c-button-neutral-color-border-hover: var(--slds-g-color-border-success-2);
397
397
  --slds-c-button-neutral-color-border-focus: var(--slds-g-color-border-success-2);
398
398
  --slds-c-button-neutral-color-border-active: var(--slds-g-color-border-success-2);
399
- --slds-c-button-neutral-text-color: var(--slds-g-color-on-success-2);
399
+ --slds-c-button-neutral-text-color: var(--slds-g-color-on-success-1);
400
400
  --slds-c-button-neutral-text-color-hover: var(--slds-g-color-on-success-1);
401
401
  --slds-c-button-neutral-text-color-focus: var(--slds-g-color-on-success-1);
402
402
  --slds-c-button-neutral-text-color-active: var(--slds-g-color-on-success-1);
@@ -424,8 +424,11 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
424
424
  * SLDS light DOM.
425
425
  *
426
426
  * E.g. --slds-c-button-color-background
427
- */
428
- :host([data-render-mode="shadow"][variant='base']) [part~='button'] {
427
+ */
428
+ /**
429
+ * text variant is for button-stateful
430
+ */
431
+ :host([data-render-mode="shadow"][variant='base']) [part~='button'],:host([data-render-mode="shadow"][variant='text']) [part~='button']{
429
432
  --sds-c-button-spacing-inline: 0;
430
433
  --slds-c-button-neutral-text-color: var(--slds-g-color-accent-2);
431
434
  --slds-c-button-neutral-color-border: transparent;
@@ -437,7 +440,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
437
440
  --slds-c-button-neutral-color-background-focus: transparent;
438
441
  --slds-c-button-neutral-color-background-active: transparent;
439
442
  }
440
- :host([data-render-mode="shadow"][variant='base']) [part~='button']:disabled {
443
+ :host([data-render-mode="shadow"][variant='base']) [part~='button']:disabled,:host([data-render-mode="shadow"][variant='text']) [part~='button']:disabled {
441
444
  --sds-c-button-color-background: transparent;
442
445
  --sds-c-button-color-border: transparent;
443
446
  }
@@ -571,13 +571,15 @@ export default class LightningButtonMenu extends LightningShadowBaseClass {
571
571
  this.toggleMenuVisibility();
572
572
  this.focusOnButton();
573
573
  }
574
-
575
574
  event.stopPropagation();
576
- this.dispatchSelect(event);
575
+ const cancelled = !this.dispatchSelect(event);
576
+ if (cancelled) {
577
+ event.preventDefault();
578
+ }
577
579
  }
578
580
 
579
581
  dispatchSelect(event) {
580
- this.dispatchEvent(
582
+ return this.dispatchEvent(
581
583
  new CustomEvent('select', {
582
584
  cancelable: true,
583
585
  detail: {
@@ -32,6 +32,29 @@
32
32
  --slds-c-buttonstateful-shadow-focus,
33
33
  var(--slds-g-color-accent-2) 0 0 3px
34
34
  );
35
+
36
+ /* Pressed/Selected State */
37
+ --sds-c-button-text-color-pressed: var(--slds-g-color-accent-2);
38
+ --sds-c-button-color-background-pressed: transparent;
39
+ }
40
+
41
+ /* Hover state when button is pressed/selected */
42
+
43
+ :host([data-render-mode="shadow"]) .slds-button_stateful:hover {
44
+ --sds-c-button-color-background-pressed: var(--slds-g-color-surface-container-2);
45
+ --sds-c-button-text-color-pressed: var(--slds-s-button-color-hover);
46
+ --sds-c-button-color-border-pressed: var(--slds-g-color-border-1);
47
+ }
48
+
49
+ :host([data-render-mode="shadow"]) .slds-is-selected-clicked {
50
+ --sds-c-button-color-background-pressed: var(--slds-g-color-surface-container-1);
51
+ --sds-c-button-text-color-pressed: var(--slds-g-color-accent-2);
52
+ }
53
+
54
+ :host([data-render-mode="shadow"]) .slds-is-selected-clicked:focus {
55
+ --sds-c-button-color-background-pressed: var(--slds-g-color-surface-container-2);
56
+ --sds-c-button-text-color-pressed: var(--slds-g-color-accent-3);
57
+ --sds-c-button-shadow-pressed: var(--slds-s-button-shadow-focus);
35
58
  }
36
59
 
37
60
  /* vertical alignment for icon and text */
@@ -280,7 +280,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
280
280
 
281
281
  /* Text color */
282
282
  --sds-c-button-text-color: var(--slds-c-button-neutral-text-color, var(--slds-g-color-accent-2));
283
- --sds-c-button-text-color-hover: var(--slds-c-button-neutral-text-color-hover, var(--slds-g-color-accent-3));
283
+ --sds-c-button-text-color-hover: var(--slds-c-button-neutral-text-color-hover, var(--slds-s-button-color-hover, var(--slds-g-color-accent-3)));
284
284
  --sds-c-button-text-color-focus: var(--slds-c-button-neutral-text-color-focus, var(--slds-g-color-accent-3));
285
285
  --sds-c-button-text-color-active: var(
286
286
  --slds-c-button-neutral-text-color-active,
@@ -315,36 +315,36 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
315
315
  :host([data-render-mode="shadow"][variant='brand']) [part~='button'] {
316
316
  --slds-c-button-neutral-color-background: var(
317
317
  --slds-c-button-brand-color-background,
318
- var(--slds-g-color-accent-container-2)
318
+ var(--slds-g-color-accent-container-1)
319
319
  );
320
320
  --slds-c-button-neutral-color-background-hover: var(
321
321
  --slds-c-button-brand-color-background-hover,
322
- var(--slds-g-color-accent-container-3)
322
+ var(--slds-g-color-accent-container-2)
323
323
  );
324
324
  --slds-c-button-neutral-color-background-focus: var(
325
325
  --slds-c-button-brand-color-background-focus,
326
- var(--slds-g-color-accent-container-3)
326
+ var(--slds-g-color-accent-container-2)
327
327
  );
328
328
  --slds-c-button-neutral-color-background-active: var(
329
329
  --slds-c-button-brand-color-background-active,
330
- var(--slds-g-color-accent-container-3)
330
+ var(--slds-g-color-accent-container-2)
331
331
  );
332
332
 
333
333
  --slds-c-button-neutral-color-border: var(
334
334
  --slds-c-button-brand-color-border,
335
- var(--slds-g-color-border-accent-2)
335
+ var(--slds-g-color-border-accent-1)
336
336
  );
337
337
  --slds-c-button-neutral-color-border-hover: var(
338
338
  --slds-c-button-brand-color-border-hover,
339
- var(--slds-g-color-border-accent-3)
339
+ var(--slds-g-color-border-accent-2)
340
340
  );
341
341
  --slds-c-button-neutral-color-border-focus: var(
342
342
  --slds-c-button-brand-color-border-focus,
343
- var(--slds-g-color-border-accent-3)
343
+ var(--slds-g-color-border-accent-2)
344
344
  );
345
345
  --slds-c-button-neutral-color-border-active: var(
346
346
  --slds-c-button-brand-color-border-active,
347
- var(--slds-g-color-border-accent-3)
347
+ var(--slds-g-color-border-accent-2)
348
348
  );
349
349
 
350
350
  /* Since the text color is white for all states, bypassing inheritence and setting the color value from SDS */
@@ -396,7 +396,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
396
396
  --slds-c-button-neutral-color-border-hover: var(--slds-g-color-border-success-2);
397
397
  --slds-c-button-neutral-color-border-focus: var(--slds-g-color-border-success-2);
398
398
  --slds-c-button-neutral-color-border-active: var(--slds-g-color-border-success-2);
399
- --slds-c-button-neutral-text-color: var(--slds-g-color-on-success-2);
399
+ --slds-c-button-neutral-text-color: var(--slds-g-color-on-success-1);
400
400
  --slds-c-button-neutral-text-color-hover: var(--slds-g-color-on-success-1);
401
401
  --slds-c-button-neutral-text-color-focus: var(--slds-g-color-on-success-1);
402
402
  --slds-c-button-neutral-text-color-active: var(--slds-g-color-on-success-1);
@@ -424,8 +424,11 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
424
424
  * SLDS light DOM.
425
425
  *
426
426
  * E.g. --slds-c-button-color-background
427
- */
428
- :host([data-render-mode="shadow"][variant='base']) [part~='button'] {
427
+ */
428
+ /**
429
+ * text variant is for button-stateful
430
+ */
431
+ :host([data-render-mode="shadow"][variant='base']) [part~='button'],:host([data-render-mode="shadow"][variant='text']) [part~='button']{
429
432
  --sds-c-button-spacing-inline: 0;
430
433
  --slds-c-button-neutral-text-color: var(--slds-g-color-accent-2);
431
434
  --slds-c-button-neutral-color-border: transparent;
@@ -437,7 +440,7 @@ Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
437
440
  --slds-c-button-neutral-color-background-focus: transparent;
438
441
  --slds-c-button-neutral-color-background-active: transparent;
439
442
  }
440
- :host([data-render-mode="shadow"][variant='base']) [part~='button']:disabled {
443
+ :host([data-render-mode="shadow"][variant='base']) [part~='button']:disabled,:host([data-render-mode="shadow"][variant='text']) [part~='button']:disabled {
441
444
  --sds-c-button-color-background: transparent;
442
445
  --sds-c-button-color-border: transparent;
443
446
  }
@@ -3,4 +3,7 @@
3
3
  <isExposed>true</isExposed>
4
4
  <minApiVersion>0.0</minApiVersion>
5
5
  <support>GA</support>
6
+ <capabilities>
7
+ <capability>lightning__ServerRenderableWithHydration</capability>
8
+ </capabilities>
6
9
  </LightningComponentBundle>
@@ -1,4 +1,4 @@
1
- import { normalizeKeyValue } from 'lightning/utilsPrivate';
1
+ import { normalizeKeyValue, isRTL } from 'lightning/utilsPrivate';
2
2
 
3
3
  export function handleKeyDownOnCalendar(event, date, calendarInterface) {
4
4
  const tdElement = event.target;
@@ -16,12 +16,20 @@ export function handleKeyDownOnCalendar(event, date, calendarInterface) {
16
16
  break;
17
17
  case 'ArrowRight':
18
18
  preventDefaultAndStopPropagation(event);
19
- date.setDate(date.getDate() + 1);
19
+ if (isRTL()) {
20
+ date.setDate(date.getDate() - 1);
21
+ } else {
22
+ date.setDate(date.getDate() + 1);
23
+ }
20
24
  calendarInterface.focusDate(date);
21
25
  break;
22
26
  case 'ArrowLeft':
23
27
  preventDefaultAndStopPropagation(event);
24
- date.setDate(date.getDate() - 1);
28
+ if (isRTL()) {
29
+ date.setDate(date.getDate() + 1);
30
+ } else {
31
+ date.setDate(date.getDate() - 1);
32
+ }
25
33
  calendarInterface.focusDate(date);
26
34
  break;
27
35
  case 'Enter':
@@ -388,7 +388,8 @@ export default class LightningCombobox extends LightningShadowBaseClass {
388
388
  'lightning-base-combobox'
389
389
  );
390
390
  baseCombobox.inputLabelledByElement = this.ariaLabelledBy;
391
- baseCombobox.inputDescribedByElements = this.computedAriaDescribedBy;
391
+ baseCombobox.inputDescribedByElements = this.ariaDescribedBy;
392
+ baseCombobox.ariaErrorMessageElements = this.ariaErrorMessageElements;
392
393
  }
393
394
 
394
395
  get templateRootNode() {
@@ -409,19 +410,10 @@ export default class LightningCombobox extends LightningShadowBaseClass {
409
410
  .toString();
410
411
  }
411
412
 
412
- get computedAriaDescribedBy() {
413
- const describedByElements = [];
413
+ get ariaErrorMessageElements() {
414
+ if (!this._helpMessage) return null;
414
415
 
415
- if (this._helpMessage) {
416
- const helpText = this.template.querySelector('[data-help-text]');
417
- describedByElements.push(helpText);
418
- }
419
-
420
- if (typeof this.ariaDescribedBy === 'string') {
421
- describedByElements.push(this.ariaDescribedBy);
422
- }
423
-
424
- return describedByElements;
416
+ return this.template.querySelector('[data-help-text]');
425
417
  }
426
418
 
427
419
  handleSelect(event) {
@@ -17,7 +17,6 @@ export default class DatatableWithVirtualization extends LightningElement {
17
17
  renderConfig = {
18
18
  virtualize: 'vertical',
19
19
  bufferSize: 10,
20
- fixedHeight: true,
21
20
  };
22
21
 
23
22
  connectedCallback() {
@@ -131,7 +131,6 @@ import {
131
131
  } from './sort';
132
132
  import {
133
133
  getGridContainerFromScrollerY,
134
- getRowDataSelector,
135
134
  getScrollerX,
136
135
  getScrollerY,
137
136
  isLoadMore,
@@ -297,20 +296,18 @@ export default class LightningDatatable extends LightningElement {
297
296
  }
298
297
 
299
298
  // do necessary updates since rows have changed
300
- if (this.hasValidKeyField) {
301
- if (this.isConnected) {
302
- this.updateRows();
303
- }
304
- if (isInfiniteLoading) {
305
- addTableHeight(state, previousData, data);
306
- } else {
307
- // if data is new, reset all virtualization data
308
- state.heightCache = {};
309
- state.offsets = [0];
310
- state.offsetRanges = [{ start: 0, end: 0 }];
311
- state.firstVisibleIndex = 0;
312
- state.tableHeight = state.rowHeight * state.rows.length;
313
- }
299
+ if (this.hasValidKeyField && this.isConnected) {
300
+ this.updateRows();
301
+ }
302
+ if (isInfiniteLoading) {
303
+ addTableHeight(state, previousData, data);
304
+ } else {
305
+ // if data is new, reset all virtualization data
306
+ state.heightCache = {};
307
+ state.offsets = [0];
308
+ state.offsetRanges = [{ start: 0, end: 0 }];
309
+ state.firstVisibleIndex = 0;
310
+ state.tableHeight = state.rowHeight * state.rows.length;
314
311
  }
315
312
  if (_customerSelectedRows) {
316
313
  this.setSelectedRows(_customerSelectedRows);
@@ -609,7 +606,7 @@ export default class LightningDatatable extends LightningElement {
609
606
 
610
607
  /**
611
608
  * Enables and configures advanced rendering modes.
612
- * It supports properties 'bufferSize', 'fixedHeight', and 'rowHeight'.
609
+ * It supports properties 'bufferSize' and 'rowHeight'.
613
610
  *
614
611
  * @type {RenderManagerConfig} value - config object for datatable rendering
615
612
  */
@@ -1216,6 +1213,10 @@ export default class LightningDatatable extends LightningElement {
1216
1213
  ? divTemplate
1217
1214
  : tableTemplate;
1218
1215
  if (templateToRender !== this._renderedTemplate) {
1216
+ // if private types present, don't reset custom types since template
1217
+ // change will trigger slotchange event without types actually changing
1218
+ this._shouldResetCustomTypes =
1219
+ !this._privateTypes.privateCustomTypes.size;
1219
1220
  const { _widthObserver } = this;
1220
1221
  if (_widthObserver) {
1221
1222
  _widthObserver.disconnect();
@@ -1240,6 +1241,14 @@ export default class LightningDatatable extends LightningElement {
1240
1241
  if (!this._hasSetInitialCustomTypes) {
1241
1242
  this.setCustomTypes();
1242
1243
  this._hasSetInitialCustomTypes = true;
1244
+ // Return here since a re-render will occur on auto width
1245
+ // tables for column updates if custom types added
1246
+ if (
1247
+ this._privateTypes.privateCustomTypes.size &&
1248
+ widthsData.columnWidthsMode === 'auto'
1249
+ ) {
1250
+ return;
1251
+ }
1243
1252
  }
1244
1253
 
1245
1254
  // This keeps underlying table element up to date if the aria-* properties on this element is dynamically changed.
@@ -1425,8 +1434,8 @@ export default class LightningDatatable extends LightningElement {
1425
1434
  if (this._shouldResetCustomTypes) {
1426
1435
  this.setCustomTypes();
1427
1436
  } else {
1428
- // On first call, custom types have already been set
1429
- // in renderedCallback. Subsequent calls
1437
+ // Event was triggered by the initial render or template change
1438
+ // after already setting custom types, so we ignore this call
1430
1439
  this._shouldResetCustomTypes = true;
1431
1440
  }
1432
1441
  }
@@ -2064,28 +2073,8 @@ export default class LightningDatatable extends LightningElement {
2064
2073
  if (this.state.shouldResetHeights) {
2065
2074
  resetRowHeights(state);
2066
2075
  this.state.shouldResetHeights = false;
2067
- } else if (virtualizedRows && !state.fixedHeight) {
2068
- // if row heights aren't fixed, we need to update items
2069
- // in state to know where rows should be positioned
2076
+ } else if (virtualizedRows) {
2070
2077
  handleVariableRowHeights(this.template, state, this.renderedRows);
2071
- } else if (virtualizedRows && state.fixedHeight) {
2072
- // if heights are fixed, we only need to check height of first row
2073
- const rowElement = this.template.querySelector(
2074
- getRowDataSelector(this.renderedRows[0].key)
2075
- );
2076
- // increase height by 1 since first rendered row is missing an extra 1px border
2077
- if (rowElement) {
2078
- const height = rowElement.getBoundingClientRect().height + 1;
2079
- if (state.rowHeight !== height) {
2080
- state.rowHeight = height;
2081
- state.tableHeight = state.rowHeight * state.rows.length;
2082
- state.rows.forEach((row) => {
2083
- row.style = `position:absolute;top:${
2084
- row.rowIndex * height
2085
- }px;`;
2086
- });
2087
- }
2088
- }
2089
2078
  }
2090
2079
  }
2091
2080
 
@@ -2125,7 +2114,14 @@ export default class LightningDatatable extends LightningElement {
2125
2114
  provider.getDataTypes()
2126
2115
  );
2127
2116
  this.updateColumns(this._rawColumns);
2117
+ this._columnWidthManager.handleColumnsChange(
2118
+ this.state.columns
2119
+ );
2128
2120
  }
2121
+ } else {
2122
+ // If no assigned nodes, there will be no extra slotchange event
2123
+ // We need to set this var so we don't ignore the call
2124
+ this._shouldResetCustomTypes = true;
2129
2125
  }
2130
2126
  }
2131
2127
  }
@@ -920,7 +920,7 @@ export function handlePrimitiveDatatableCellFocus(event) {
920
920
  cellElement.parentElement.dataset.rowKeyValue,
921
921
  cellElement.dataset.colKeyValue
922
922
  );
923
- if (cell.mode === KEYBOARD_ACTION_MODE) {
923
+ if (cell.keyboardMode === KEYBOARD_ACTION_MODE) {
924
924
  // Tracked state change.
925
925
  setFocusToActionableElement(
926
926
  cell,
@@ -933,12 +933,13 @@ export function handlePrimitiveDatatableCellFocus(event) {
933
933
 
934
934
  export function handlePrimitiveDatatableCellKeydown(event) {
935
935
  const { state } = this;
936
- // Don't continue if clicking on a "lightning" element
936
+ const { target } = event;
937
+ // Don't continue if clicking on a cell factory
937
938
  // Or the outer td/th element and div equivalent
938
939
  const cellElement =
939
940
  state.renderModeInline &&
940
- !event.target.shadowRoot &&
941
- !event.target.getAttribute('role')
941
+ target.tagName !== 'LIGHTNING-PRIMITIVE-CELL-FACTORY' &&
942
+ !target.getAttribute('role')
942
943
  ? getCellElementFromEventTarget(event.target)
943
944
  : undefined;
944
945
 
@@ -948,18 +949,18 @@ export function handlePrimitiveDatatableCellKeydown(event) {
948
949
 
949
950
  const cellElementChild = getCellElementChild(cellElement);
950
951
  const cell = getCellByKeys(
951
- this.state,
952
+ state,
952
953
  cellElement.parentElement.dataset.rowKeyValue,
953
954
  cellElement.dataset.colKeyValue
954
955
  );
955
- const { mode } = cell;
956
+ const { keyboardMode } = cell;
956
957
  const { keyCode, shiftKey } = event;
957
958
 
958
959
  // if it is in Action mode, then traverse to the next or previous
959
960
  // focusable element.
960
961
  // if there is no focusable element, or reach outside of the range, then move to
961
962
  // previous or next cell.
962
- if (mode === KEYBOARD_ACTION_MODE) {
963
+ if (keyboardMode === KEYBOARD_ACTION_MODE) {
963
964
  let passThroughEvent = keyCode !== keyCodes.shift;
964
965
  if (keyCode === keyCodes.left) {
965
966
  if (canMoveLeft(cell)) {
@@ -1013,7 +1014,7 @@ export function handlePrimitiveDatatableCellKeydown(event) {
1013
1014
  if (passThroughEvent) {
1014
1015
  fireCellKeydown(cell, cellElementChild, event);
1015
1016
  }
1016
- } else if (mode === KEYBOARD_NAVIGATION_MODE) {
1017
+ } else if (keyboardMode === KEYBOARD_NAVIGATION_MODE) {
1017
1018
  // click the header, press enter, it does not go to action mode without this code.
1018
1019
  if (
1019
1020
  keyCode === keyCodes.left ||
@@ -1090,7 +1091,7 @@ function resetCurrentInputIndex(
1090
1091
  // it moves focus out of table
1091
1092
  if (
1092
1093
  incomingMode === KEYBOARD_ACTION_MODE &&
1093
- cell.mode === KEYBOARD_ACTION_MODE
1094
+ cell.keyboardMode === KEYBOARD_ACTION_MODE
1094
1095
  ) {
1095
1096
  // Tracked state change.
1096
1097
  setFocusToActionableElement(
@@ -1127,7 +1128,7 @@ function setFocusToActionableElement(cell, cellElementChild, activeInputIndex) {
1127
1128
  function setMode(cell, cellElementChild, keyboardMode, info) {
1128
1129
  const normalizedInfo = info || { action: 'none' };
1129
1130
  // Tracked state changes.
1130
- cell.mode = keyboardMode;
1131
+ cell.keyboardMode = keyboardMode;
1131
1132
  if (keyboardMode === KEYBOARD_ACTION_MODE) {
1132
1133
  cell.internalTabIndex = 0;
1133
1134
  // focus without changing tabIndex doesn't work W-6185168
@@ -79,7 +79,6 @@ export class RenderManager {
79
79
  'non-negative',
80
80
  DEFAULT_BUFFER_SIZE
81
81
  );
82
- state.fixedHeight = normalizeBoolean(config.fixedHeight);
83
82
  if (typeof rowHeight === 'number') {
84
83
  state.rowHeight = rowHeight;
85
84
  this.threshold = ROW_THRESHOLD * rowHeight;
@@ -149,7 +148,6 @@ export class RenderManager {
149
148
  bufferSize,
150
149
  renderedRowCount,
151
150
  rows,
152
- fixedHeight,
153
151
  rowHeight,
154
152
  heightCache,
155
153
  } = state;
@@ -161,7 +159,7 @@ export class RenderManager {
161
159
 
162
160
  // if using variable heights, see if we can get more
163
161
  // accurate estimate based on known row heights
164
- if (!fixedHeight && heightCache[firstVisibleKey]) {
162
+ if (heightCache[firstVisibleKey]) {
165
163
  let i = firstVisibleIndex;
166
164
  let currentHeight = 0;
167
165
  let knownRowHeight = rows[i] && heightCache[rows[i].key];
@@ -404,13 +404,13 @@ export function updateCell(state, rowIndex, colIndex) {
404
404
  cell.typeAttribute0 = getRowNumberError(rowErrors, cell.scopeColValue);
405
405
  }
406
406
 
407
- let cellClass = cell.class;
407
+ let cellClass = cell.class || '';
408
+ if (cell.hasTreeData && !cellClass) {
409
+ cellClass += (cellClass.length ? ' ' : '') + TREE__ITEM_CLASS;
410
+ }
408
411
  if (cell.displayReadOnlyIcon || cell.editable) {
409
412
  cellClass += (cellClass.length ? ' ' : '') + CELL_EDIT_CLASS;
410
413
  }
411
- if (cell.hasTreeData) {
412
- cellClass += (cellClass.length ? ' ' : '') + TREE__ITEM_CLASS;
413
- }
414
414
  if (hasError) {
415
415
  cellClass += (cellClass.length ? ' ' : '') + HAS_ERROR_CLASS;
416
416
  }
@@ -423,7 +423,7 @@ export function updateCell(state, rowIndex, colIndex) {
423
423
  }
424
424
 
425
425
  cell.class = cellClass;
426
- cell.style = computeCellStyles(cell, col, renderModeRoleBased);
426
+ cell.style = computeCellStyles(cell, col, renderModeRoleBased, cell.style);
427
427
 
428
428
  if (cell.isInlined) {
429
429
  updateInlineCell(cell);
@@ -442,14 +442,19 @@ export function updateCell(state, rowIndex, colIndex) {
442
442
  * @param {Object} types - instance of DatatableTypes from `./types.js`
443
443
  * @param {Object} col - column definition
444
444
  * @param {Boolean} renderModeRoleBased - render mode of datatable (div || table)
445
+ * @param {String} initValue - default value for cell styles
445
446
  * @returns {String} - styles to be set on the cell
446
447
  */
447
- function computeCellStyles(cell, col, renderModeRoleBased) {
448
- let cellStyle = '';
448
+ function computeCellStyles(cell, col, renderModeRoleBased, initValue = '') {
449
+ let cellStyle = initValue;
450
+ if (cellStyle && !cellStyle.endsWith(';')) {
451
+ cellStyle += ';';
452
+ }
453
+
449
454
  if (cell.isCustomBareLayout) {
450
455
  // When a custom type is not using the standard layout,
451
456
  // remove the padding that comes with the standard layout
452
- cellStyle = 'padding: 0;';
457
+ cellStyle += 'padding: 0;';
453
458
  }
454
459
 
455
460
  // Width needs to be managed when rendering as divs
@@ -475,7 +480,9 @@ export function recomputeCellStyles(state) {
475
480
  state.rows.forEach((row) => {
476
481
  row.cells.forEach((cell, colIndex) => {
477
482
  const colData = columns[colIndex];
478
- cell.style = computeCellStyles(cell, colData, true);
483
+ const cellAttrs = getCellAttributesValues(colData);
484
+ const style = resolveAttributeValue(cellAttrs.style, row) || '';
485
+ cell.style = computeCellStyles(cell, colData, true, style);
479
486
  });
480
487
  });
481
488
  }
@@ -74,7 +74,6 @@ export function getDefaultState() {
74
74
  rowHeight: 30.5,
75
75
  renderedRowCount: 0,
76
76
  firstVisibleIndex: 0, // first row that should be visible in viewport
77
- fixedHeight: false, // by default, assume that not all rows are same height
78
77
  heightCache: {}, // cache of row heights
79
78
  offsets: [0],
80
79
  offsetRanges: [],
@@ -996,14 +996,14 @@
996
996
  </template>
997
997
  </div>
998
998
  </template>
999
- <!-- Loading Indicator -->
1000
- <template if:true={isLoading}>
1001
- <div>
1002
- <div colspan={state.columns.length} class="slds-is-relative">
1003
- <lightning-primitive-datatable-loading-indicator></lightning-primitive-datatable-loading-indicator>
1004
- </div>
1005
- </div>
1006
- </template>
999
+ </div>
1000
+ </template>
1001
+ <!-- Loading Indicator -->
1002
+ <template if:true={isLoading}>
1003
+ <div>
1004
+ <div colspan={state.columns.length} part="spinner" class="slds-is-relative">
1005
+ <lightning-primitive-datatable-loading-indicator></lightning-primitive-datatable-loading-indicator>
1006
+ </div>
1007
1007
  </div>
1008
1008
  </template>
1009
1009
  </div>
@@ -104,3 +104,10 @@ div[role='grid'][data-render-mode-inline='true']
104
104
  direction: ltr;
105
105
  unicode-bidi: embed;
106
106
  }
107
+
108
+ /* Spinner */
109
+
110
+ [part="spinner"] {
111
+ padding: var(--slds-g-sizing-2, 0.25rem) var(--slds-g-sizing-3, 0.5rem);
112
+ border-top: var(--slds-g-sizing-border-1, 1px) solid var(--slds-g-color-border-1);
113
+ }