lightning-base-components 1.13.9-alpha → 1.14.3-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 (83) hide show
  1. package/metadata/raptor.json +1 -0
  2. package/package.json +21 -1
  3. package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
  4. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsPlural.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsSingular.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningErrorMessage.validitySelectAtleastOne.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningLookup.recentItems.js +1 -0
  8. package/scopedImports/@salesforce-label-LightningMap.titleWithAddress.js +1 -0
  9. package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +103 -0
  10. package/src/lightning/ariaObserver/__docs__/ariaObserver.md +142 -0
  11. package/src/lightning/{utilsPrivate/contentMutation.js → ariaObserver/ariaObserver.js} +51 -78
  12. package/src/lightning/baseCombobox/baseCombobox.html +1 -0
  13. package/src/lightning/baseCombobox/baseCombobox.js +14 -1
  14. package/src/lightning/buttonMenu/keyboard.js +0 -10
  15. package/src/lightning/card/card.html +6 -0
  16. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  17. package/src/lightning/checkboxGroup/checkboxGroup.js +6 -1
  18. package/src/lightning/colorPickerCustom/colorPickerCustom.js +20 -1
  19. package/src/lightning/combobox/combobox.css +12 -0
  20. package/src/lightning/combobox/combobox.html +1 -0
  21. package/src/lightning/datatable/__docs__/datatable.md +55 -0
  22. package/src/lightning/datatable/__examples__/basic/basic.html +1 -1
  23. package/src/lightning/datatable/columnWidthManager.js +7 -3
  24. package/src/lightning/datatable/columns-shared.js +1 -1
  25. package/src/lightning/datatable/datatable.js +122 -40
  26. package/src/lightning/datatable/errors.js +20 -9
  27. package/src/lightning/datatable/headerActions.js +77 -49
  28. package/src/lightning/datatable/inlineEdit.js +520 -373
  29. package/src/lightning/datatable/inlineEditShared.js +24 -0
  30. package/src/lightning/datatable/keyboard.js +1077 -933
  31. package/src/lightning/datatable/renderManager.js +241 -129
  32. package/src/lightning/datatable/resizer.js +91 -108
  33. package/src/lightning/datatable/rowLevelActions.js +17 -13
  34. package/src/lightning/datatable/rowNumber.js +54 -20
  35. package/src/lightning/datatable/rowSelection.js +760 -0
  36. package/src/lightning/datatable/rowSelectionShared.js +79 -0
  37. package/src/lightning/datatable/rows.js +16 -5
  38. package/src/lightning/datatable/state.js +10 -10
  39. package/src/lightning/datatable/templates/div/div.css +23 -0
  40. package/src/lightning/datatable/templates/div/div.html +6 -5
  41. package/src/lightning/datatable/templates/table/table.html +4 -4
  42. package/src/lightning/datatable/utils.js +14 -0
  43. package/src/lightning/datatable/widthManagerShared.js +1 -1
  44. package/src/lightning/dualListbox/dualListbox.html +1 -1
  45. package/src/lightning/dualListbox/dualListbox.js +42 -0
  46. package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +2 -1
  47. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_alt.html +1 -2
  48. package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_doc.html +8 -0
  49. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +2 -1
  50. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_alt.html +1 -2
  51. package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_doc.html +8 -0
  52. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +2 -1
  53. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_alt.html +1 -2
  54. package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_doc.html +8 -0
  55. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +2 -1
  56. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_alt.html +1 -2
  57. package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_doc.html +8 -0
  58. package/src/lightning/input/input.html +0 -1
  59. package/src/lightning/input/input.js +69 -48
  60. package/src/lightning/inputUtils/validity.js +12 -1
  61. package/src/lightning/pillContainer/__docs__/pillContainer.md +45 -1
  62. package/src/lightning/primitiveCellActions/primitiveCellActions.js +69 -12
  63. package/src/lightning/primitiveCellFactory/cellWithStandardLayout.html +13 -11
  64. package/src/lightning/primitiveCellFactory/primitiveCellFactory.js +13 -8
  65. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.html +17 -14
  66. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.js +169 -80
  67. package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +97 -62
  68. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.html +4 -4
  69. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.js +4 -4
  70. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +99 -37
  71. package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +5 -4
  72. package/src/lightning/primitiveHeaderFactory/primitiveHeaderFactory.js +46 -46
  73. package/src/lightning/primitiveHeaderFactory/selectableHeader.html +25 -23
  74. package/src/lightning/primitiveHeaderFactory/sortableHeader.html +13 -9
  75. package/src/lightning/progressIndicator/progressIndicator.js +4 -6
  76. package/src/lightning/progressStep/progressStep.js +31 -22
  77. package/src/lightning/staticMap/staticMap.html +1 -0
  78. package/src/lightning/staticMap/staticMap.js +39 -2
  79. package/src/lightning/utils/classSet.js +4 -1
  80. package/src/lightning/utilsPrivate/utilsPrivate.js +12 -1
  81. package/src/lightning/datatable/inlineEdit-shared.js +0 -14
  82. package/src/lightning/datatable/selector-shared.js +0 -38
  83. package/src/lightning/datatable/selector.js +0 -527
@@ -1,4 +1,5 @@
1
1
  import { LightningElement, api } from 'lwc';
2
+ import labelEdit from '@salesforce/label/LightningDatatable.edit';
2
3
  import labelUpdateSelectedItems from '@salesforce/label/LightningDatatable.updateSelectedItems';
3
4
  import labelCancel from '@salesforce/label/LightningDatatable.cancel';
4
5
  import labelApply from '@salesforce/label/LightningDatatable.apply';
@@ -6,12 +7,15 @@ import { InteractingState } from 'lightning/inputUtils';
6
7
  import { formatLabel } from 'lightning/utils';
7
8
 
8
9
  const i18n = {
10
+ edit: labelEdit,
9
11
  updateSelectedItems: labelUpdateSelectedItems,
10
12
  cancel: labelCancel,
11
13
  apply: labelApply,
12
14
  };
13
15
 
14
16
  export default class PrimitiveDatatableIeditPanel extends LightningElement {
17
+ /************************* PUBLIC PROPERTIES *************************/
18
+
15
19
  @api visible;
16
20
  @api rowKeyValue;
17
21
  @api colKeyValue;
@@ -21,14 +25,80 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
21
25
  @api numberOfSelectedRows;
22
26
  @api resolvedTypeAttributes;
23
27
 
24
- connectedCallback() {
25
- this.interactingState = new InteractingState({
26
- duration: 10,
27
- debounceInteraction: true,
28
- });
29
- this.interactingState.onleave(() => this.handlePanelLoosedFocus());
28
+ /**
29
+ * Checked when opening an edit panel to see if it's valid
30
+ * Logs an error if type is custom but does not have the
31
+ * required editTemplate with [data-inputable="true"] element
32
+ */
33
+ @api
34
+ get isEditableValid() {
35
+ if (
36
+ !this.columnDef.editableCustomType ||
37
+ this.inputableElement.isEditableCustomValid
38
+ ) {
39
+ return true;
40
+ } else if (this.columnDef.editableCustomType) {
41
+ console.error(
42
+ 'Editable custom types must define an editTemplate that includes an element with attribute data-inputable set to "true"'
43
+ );
44
+ }
45
+ return false;
46
+ }
47
+
48
+ /**
49
+ * Returns whether or not the mass edit update checkbox is selected
50
+ */
51
+ @api
52
+ get isMassEditChecked() {
53
+ return (
54
+ this.isMassEditEnabled &&
55
+ this.template.querySelector('[data-mass-selection="true"]').checked
56
+ );
30
57
  }
31
58
 
59
+ /**
60
+ * Returns the value of the input in the inline edit panel
61
+ * This is retrieved typically when processing inline edit completion
62
+ */
63
+ @api
64
+ get value() {
65
+ return this.inputableElement ? this.inputableElement.value : null;
66
+ }
67
+
68
+ /**
69
+ * Returns the validity state object of the input in the inline edit panel
70
+ */
71
+ @api
72
+ get validity() {
73
+ return this.inputableElement.validity;
74
+ }
75
+
76
+ /************************* PUBLIC METHODS *************************/
77
+
78
+ /**
79
+ * Focuses on the input element in the inline edit panel
80
+ */
81
+ @api
82
+ focus() {
83
+ const elem = this.inputableElement;
84
+ this.interactingState.enter();
85
+
86
+ if (elem) {
87
+ elem.focus();
88
+ }
89
+ }
90
+
91
+ /**
92
+ * Returns the <section> element which is the container of the
93
+ * positioned inline edit panel
94
+ */
95
+ @api
96
+ getPositionedElement() {
97
+ return this.template.querySelector('section');
98
+ }
99
+
100
+ /************************* PRIVATE GETTERS *************************/
101
+
32
102
  get computedStyle() {
33
103
  const styleHash = {
34
104
  'z-index': 1000,
@@ -43,29 +113,41 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
43
113
  .join(';');
44
114
  }
45
115
 
116
+ get inputableElement() {
117
+ return this.template.querySelector('.dt-type-edit-factory');
118
+ }
119
+
46
120
  get inputKey() {
47
121
  return this.rowKeyValue + this.colKeyValue;
48
122
  }
49
123
 
124
+ get required() {
125
+ return (
126
+ this.columnDef.typeAttributes &&
127
+ this.columnDef.typeAttributes.required
128
+ );
129
+ }
130
+
50
131
  get massEditCheckboxLabel() {
51
132
  return formatLabel(i18n.updateSelectedItems, this.numberOfSelectedRows);
52
133
  }
53
134
 
54
- get applyLabel() {
55
- return i18n.apply;
135
+ get dialogAriaLabel() {
136
+ const columnName = this.columnDef.label;
137
+ return `${i18n.edit} ${columnName}`;
56
138
  }
57
139
 
58
- get cancelLabel() {
59
- return i18n.cancel;
140
+ get i18n() {
141
+ return i18n;
60
142
  }
61
143
 
62
- get required() {
63
- return (
64
- this.columnDef.typeAttributes &&
65
- this.columnDef.typeAttributes.required
66
- );
67
- }
144
+ /************************* EVENT HANDLERS *************************/
68
145
 
146
+ /**
147
+ * Handles tabbing backwards out of the inline edit panel from the first form element.
148
+ * If mass edit is enabled, this will set the focus on the last element in the panel - traps focus.
149
+ * If mass edit is not enabled, it will process completion of inline edit
150
+ */
69
151
  handleFormStartFocus() {
70
152
  this.interactingState.enter();
71
153
 
@@ -79,6 +161,11 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
79
161
  }
80
162
  }
81
163
 
164
+ /**
165
+ * Handles tabbing forwards out of the inline edit panel from the last form element.
166
+ * If mass edit is enabled, this will set focus on the first element in the panel - traps focus.
167
+ * If mass edit is not enabled, it will process the completion of inline edit
168
+ */
82
169
  handleFormEndsFocus() {
83
170
  this.interactingState.enter();
84
171
 
@@ -92,51 +179,20 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
92
179
  }
93
180
  }
94
181
 
95
- triggerEditFinished(detail) {
96
- detail.rowKeyValue = detail.rowKeyValue || this.rowKeyValue;
97
- detail.colKeyValue = detail.colKeyValue || this.colKeyValue;
98
-
99
- const event = new CustomEvent('ieditfinished', {
100
- detail,
101
- });
102
- this.dispatchEvent(event);
103
- }
104
-
105
- @api
106
- focus() {
107
- const elem = this.inputableElement;
108
- this.interactingState.enter();
109
-
110
- if (elem) {
111
- elem.focus();
182
+ /**
183
+ * This is executed when interactingState.leave is triggered
184
+ * which happens when the inline edit panel loses focus
185
+ */
186
+ handlePanelLostFocus() {
187
+ if (this.visible) {
188
+ this.triggerEditFinished({
189
+ reason: 'lost-focus',
190
+ });
112
191
  }
113
192
  }
114
193
 
115
- get inputableElement() {
116
- return this.template.querySelector('.dt-type-edit-factory');
117
- }
118
-
119
- @api
120
- get value() {
121
- return this.inputableElement ? this.inputableElement.value : null;
122
- }
123
-
124
- @api
125
- get validity() {
126
- return this.inputableElement.validity;
127
- }
128
-
129
- @api
130
- get isMassEditChecked() {
131
- return (
132
- this.isMassEditEnabled &&
133
- this.template.querySelector('[data-mass-selection="true"]').checked
134
- );
135
- }
136
-
137
- @api
138
- getPositionedElement() {
139
- return this.template.querySelector('section');
194
+ handleTypeElemFocus() {
195
+ this.interactingState.enter();
140
196
  }
141
197
 
142
198
  handleTypeElemBlur() {
@@ -145,10 +201,6 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
145
201
  }
146
202
  }
147
203
 
148
- handleTypeElemFocus() {
149
- this.interactingState.enter();
150
- }
151
-
152
204
  handleEditFormSubmit(event) {
153
205
  event.preventDefault();
154
206
  event.stopPropagation();
@@ -160,24 +212,71 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
160
212
  return false;
161
213
  }
162
214
 
215
+ /**
216
+ * If the Escape key is pressed on the inline edit panel,
217
+ * we prevent default action, stop propagation of the event
218
+ * and close the inline edit panel
219
+ *
220
+ * @param {KeyboardEvent} event - keydown
221
+ */
163
222
  handleCellKeydown(event) {
164
223
  const { keyCode } = event;
165
224
 
166
225
  if (keyCode === 27) {
167
226
  // Esc key
227
+ event.preventDefault();
168
228
  event.stopPropagation();
169
- this.cancelEdition();
229
+ this.cancelEditing();
170
230
  }
171
231
  }
172
232
 
173
- handlePanelLoosedFocus() {
174
- if (this.visible) {
175
- this.triggerEditFinished({
176
- reason: 'loosed-focus',
177
- });
178
- }
233
+ /************************* EVENT DISPATCHERS *************************/
234
+
235
+ /**
236
+ * Change handler for the mass edit checkbox.
237
+ * Dispatches the `masscheckboxchange` event along with the new checked value
238
+ *
239
+ * @param {CustomEvent} event - `change` event from lightning-input
240
+ */
241
+ handleMassCheckboxChange(event) {
242
+ const customEvent = new CustomEvent('masscheckboxchange', {
243
+ detail: {
244
+ checked: event.detail.checked,
245
+ },
246
+ });
247
+
248
+ this.dispatchEvent(customEvent);
249
+ }
250
+
251
+ /**
252
+ * Dispatches the `ieditfinished` event with the detail object containing
253
+ * the reason for inline edit finishing and the rowKeyValue and colKeyValue
254
+ * with which the particular cell which was edited can be identified.
255
+ *
256
+ * @param {Object} detail - typically contains the reason for inline edit finishing
257
+ */
258
+ triggerEditFinished(detail) {
259
+ detail.rowKeyValue = detail.rowKeyValue || this.rowKeyValue;
260
+ detail.colKeyValue = detail.colKeyValue || this.colKeyValue;
261
+
262
+ const event = new CustomEvent('ieditfinished', {
263
+ detail,
264
+ });
265
+ this.dispatchEvent(event);
179
266
  }
180
267
 
268
+ /************************* LIFECYCLE HOOKS *************************/
269
+
270
+ connectedCallback() {
271
+ this.interactingState = new InteractingState({
272
+ duration: 10,
273
+ debounceInteraction: true,
274
+ });
275
+ this.interactingState.onleave(() => this.handlePanelLostFocus());
276
+ }
277
+
278
+ /************************* HELPER FUNCTIONS *************************/
279
+
181
280
  focusLastElement() {
182
281
  this.template.querySelector('[data-form-last-element="true"]').focus();
183
282
  }
@@ -190,19 +289,9 @@ export default class PrimitiveDatatableIeditPanel extends LightningElement {
190
289
  }
191
290
  }
192
291
 
193
- cancelEdition() {
292
+ cancelEditing() {
194
293
  this.triggerEditFinished({
195
294
  reason: 'edit-canceled',
196
295
  });
197
296
  }
198
-
199
- handleMassCheckboxChange(event) {
200
- const customEvent = new CustomEvent('masscheckboxchange', {
201
- detail: {
202
- checked: event.detail.checked,
203
- },
204
- });
205
-
206
- this.dispatchEvent(customEvent);
207
- }
208
297
  }
@@ -13,7 +13,7 @@ import DateLocalTpl from './dateLocal.html';
13
13
  import DateTpl from './date.html';
14
14
  import DefaultTpl from './default.html';
15
15
 
16
- const TYPE_TPL_MAPPINGS = {
16
+ const TYPE_TEMPLATE_MAPPINGS = {
17
17
  text: TextTpl,
18
18
  phone: PhoneTpl,
19
19
  email: EmailTpl,
@@ -25,10 +25,14 @@ const TYPE_TPL_MAPPINGS = {
25
25
  'date-local': DateLocalTpl,
26
26
  date: DateTpl,
27
27
  };
28
- const INVALID_TYPE_FOR_EDIT = 'column type not supported for inline edit';
28
+ const INVALID_TYPE_MESSAGE = 'column type not supported for inline edit';
29
29
 
30
30
  export default class LightningPrimitiveDatatableIeditTypeFactory extends LightningElement {
31
+ // Private Variables
31
32
  columnLabel;
33
+
34
+ /***************************** PUBLIC PROPERTIES *****************************/
35
+
32
36
  @api editedValue;
33
37
  @api required;
34
38
  @api typeAttributes;
@@ -41,54 +45,23 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
41
45
  set columnDef(value) {
42
46
  assert(
43
47
  // eslint-disable-next-line no-prototype-builtins
44
- TYPE_TPL_MAPPINGS.hasOwnProperty(value.type) ||
48
+ TYPE_TEMPLATE_MAPPINGS.hasOwnProperty(value.type) ||
45
49
  value.editableCustomType,
46
- INVALID_TYPE_FOR_EDIT
50
+ INVALID_TYPE_MESSAGE
47
51
  );
48
52
 
49
53
  this._columnDef = value;
50
54
  this.columnLabel = value.label;
51
55
  }
52
56
 
53
- get columnType() {
54
- return this._columnDef.type;
55
- }
56
-
57
- render() {
58
- return this.isValidCustomType
59
- ? this.customEditTemplate
60
- : TYPE_TPL_MAPPINGS[this.columnType] || DefaultTpl;
61
- }
62
-
63
- connectedCallback() {
64
- this._blurHandler = this.handleComponentBlur.bind(this);
65
- this._focusHandler = this.handleComponentFocus.bind(this);
66
- this._changeHandler = this.handleComponentChange.bind(this);
67
- }
68
-
69
- renderedCallback() {
70
- if (this.concreteComponent) {
71
- this.concreteComponent.addEventListener('blur', this._blurHandler);
72
- this.concreteComponent.addEventListener(
73
- 'focus',
74
- this._focusHandler
75
- );
76
- this.concreteComponent.addEventListener(
77
- 'change',
78
- this._changeHandler
79
- );
80
- }
81
- }
82
-
83
- get concreteComponent() {
84
- return this.template.querySelector('[data-inputable="true"]');
85
- }
86
-
57
+ /**
58
+ * Checks if type is an custom type that is editable and
59
+ * has an editTemplate that contains [data-inputable="true"]
60
+ * Used when checking if cell can actually be edited
61
+ */
87
62
  @api
88
- focus() {
89
- if (this.concreteComponent) {
90
- this.concreteComponent.focus();
91
- }
63
+ get isEditableCustomValid() {
64
+ return this.isValidCustomType && this.concreteComponent;
92
65
  }
93
66
 
94
67
  @api
@@ -104,11 +77,47 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
104
77
  return this.concreteComponent.validity;
105
78
  }
106
79
 
80
+ /***************************** PUBLIC METHODS *****************************/
81
+
82
+ /**
83
+ * Focuses on the input component that is rendered by the type factory
84
+ */
85
+ @api
86
+ focus() {
87
+ if (this.concreteComponent) {
88
+ this.concreteComponent.focus();
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Displays error message if the input is invalid
94
+ */
107
95
  @api
108
96
  showHelpMessageIfInvalid() {
109
97
  this.concreteComponent.showHelpMessageIfInvalid();
110
98
  }
111
99
 
100
+ /***************************** PRIVATE GETTERS *****************************/
101
+
102
+ get columnType() {
103
+ return this._columnDef.type;
104
+ }
105
+
106
+ get concreteComponent() {
107
+ return this.template.querySelector('[data-inputable="true"]');
108
+ }
109
+
110
+ /**
111
+ * Returns editTemplate defined for custom type template
112
+ */
113
+ get customEditTemplate() {
114
+ return this._columnDef.editTemplate;
115
+ }
116
+
117
+ /**
118
+ * Retrieves the date set in the column and converts it to a value
119
+ * that can be passed into lightning-input type="datetime"
120
+ */
112
121
  get editedDateValue() {
113
122
  const dateValue = new Date(this.editedValue);
114
123
 
@@ -119,6 +128,30 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
119
128
  return dateValue.toISOString();
120
129
  }
121
130
 
131
+ /**
132
+ * Checks this custom type is editable and has editTemplate defined
133
+ */
134
+ get isValidCustomType() {
135
+ return (
136
+ this._columnDef.editableCustomType && this._columnDef.editTemplate
137
+ );
138
+ }
139
+
140
+ /**
141
+ * For percent, currency types use if step passed in, if not fallback to default
142
+ * @returns {*|string}
143
+ */
144
+ get typeAttributeStep() {
145
+ return (
146
+ (this._columnDef &&
147
+ this._columnDef.typeAttributes &&
148
+ this._columnDef.typeAttributes.step) ||
149
+ '0.01'
150
+ );
151
+ }
152
+
153
+ /***************************** EVENT HANDLERS *****************************/
154
+
122
155
  handleComponentFocus() {
123
156
  this.dispatchEvent(new CustomEvent('focus'));
124
157
  }
@@ -131,32 +164,34 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
131
164
  this.showHelpMessageIfInvalid();
132
165
  }
133
166
 
134
- /**
135
- * Returns editTemplate defined for custom type template
136
- */
137
- get customEditTemplate() {
138
- return this._columnDef.editTemplate;
139
- }
167
+ /***************************** LIFECYCLE HOOKS *****************************/
140
168
 
141
169
  /**
142
- * for percent, currency types use if step passed in, if not fallback to default
143
- * @returns {*|string}
170
+ * Renders the appropriate template based on the column type
144
171
  */
145
- get typeAttributeStep() {
146
- return (
147
- (this._columnDef &&
148
- this._columnDef.typeAttributes &&
149
- this._columnDef.typeAttributes.step) ||
150
- '0.01'
151
- );
172
+ render() {
173
+ return this.isValidCustomType
174
+ ? this.customEditTemplate
175
+ : TYPE_TEMPLATE_MAPPINGS[this.columnType] || DefaultTpl;
152
176
  }
153
177
 
154
178
  /**
155
- * Checks this custom type is editable and has editTemplate defined
179
+ * Attaches event handlers for `focus`, `blur` and `change` events
156
180
  */
157
- get isValidCustomType() {
158
- return (
159
- this._columnDef.editableCustomType && this._columnDef.editTemplate
160
- );
181
+ renderedCallback() {
182
+ if (this.concreteComponent) {
183
+ this.concreteComponent.addEventListener(
184
+ 'focus',
185
+ this.handleComponentFocus.bind(this)
186
+ );
187
+ this.concreteComponent.addEventListener(
188
+ 'blur',
189
+ this.handleComponentBlur.bind(this)
190
+ );
191
+ this.concreteComponent.addEventListener(
192
+ 'change',
193
+ this.handleComponentChange.bind(this)
194
+ );
195
+ }
161
196
  }
162
197
  }
@@ -2,6 +2,7 @@
2
2
  <div class="slds-docked-form-footer slds-is-absolute">
3
3
  <div class="slds-grid slds-grid_align-center">
4
4
  <template if:true={showError}>
5
+ <!-- Error Tooltip -->
5
6
  <lightning-primitive-datatable-tooltip
6
7
  class="slds-button"
7
8
  size="small"
@@ -12,18 +13,17 @@
12
13
  offset={bubbleOffset}
13
14
  ></lightning-primitive-datatable-tooltip>
14
15
  </template>
16
+ <!-- Cancel and Save Buttons -->
15
17
  <button
16
18
  type="button"
17
19
  class="slds-button slds-button_neutral"
18
- onclick={handleCancelButtonClick}
19
- >
20
+ onclick={handleCancelButtonClick}>
20
21
  {i18n.cancel}
21
22
  </button>
22
23
  <button
23
24
  type="button"
24
25
  class="slds-button slds-button_brand save-btn"
25
- onclick={handleSaveButtonClick}
26
- >
26
+ onclick={handleSaveButtonClick}>
27
27
  {i18n.save}
28
28
  </button>
29
29
  </div>
@@ -47,6 +47,10 @@ export default class LightningPrimitiveDatatableStatusBar extends LightningEleme
47
47
  };
48
48
  }
49
49
 
50
+ isSaveBtnFocused() {
51
+ return this.template.querySelector('button.save-btn:focus') !== null;
52
+ }
53
+
50
54
  handleCancelButtonClick(event) {
51
55
  event.preventDefault();
52
56
  event.stopPropagation();
@@ -78,10 +82,6 @@ export default class LightningPrimitiveDatatableStatusBar extends LightningEleme
78
82
  );
79
83
  }
80
84
 
81
- isSaveBtnFocused() {
82
- return this.template.querySelector('button.save-btn:focus') !== null;
83
- }
84
-
85
85
  /**
86
86
  * Handling between displaying/focusing tooltip icon and/or error bubble
87
87
  * If showBubble property is set within error object, display/focus the error bubble.