lightning-base-components 1.14.2-alpha → 1.14.6-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 (82) hide show
  1. package/metadata/raptor.json +33 -1
  2. package/package.json +20 -4
  3. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsPlural.js +1 -0
  4. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsSingular.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningErrorMessage.validitySelectAtleastOne.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningMap.titleWithAddress.js +1 -0
  7. package/scopedImports/@salesforce-label-LightningModalBase.cancelandclose.js +1 -0
  8. package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +9 -0
  9. package/src/lightning/ariaObserver/__docs__/ariaObserver.md +142 -0
  10. package/src/lightning/ariaObserver/ariaObserver.js +24 -35
  11. package/src/lightning/baseFormattedText/baseFormattedText.html +6 -1
  12. package/src/lightning/baseFormattedText/baseFormattedText.js +5 -0
  13. package/src/lightning/buttonMenu/keyboard.js +0 -10
  14. package/src/lightning/card/card.html +6 -0
  15. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  16. package/src/lightning/checkboxGroup/checkboxGroup.js +6 -1
  17. package/src/lightning/colorPickerCustom/colorPickerCustom.js +20 -1
  18. package/src/lightning/datatable/__docs__/datatable.md +55 -0
  19. package/src/lightning/datatable/__examples__/basic/basic.html +1 -1
  20. package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +21 -0
  21. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.html +13 -0
  22. package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +42 -0
  23. package/src/lightning/datatable/autoWidthStrategy.js +170 -61
  24. package/src/lightning/datatable/{resizer.js → columnResizer.js} +0 -0
  25. package/src/lightning/datatable/columnWidthManager.js +226 -44
  26. package/src/lightning/datatable/columns-shared.js +1 -1
  27. package/src/lightning/datatable/datatable.js +104 -33
  28. package/src/lightning/datatable/errors.js +20 -9
  29. package/src/lightning/datatable/fixedWidthStrategy.js +43 -8
  30. package/src/lightning/datatable/headerActions.js +77 -49
  31. package/src/lightning/datatable/infiniteLoading.js +100 -28
  32. package/src/lightning/datatable/inlineEdit.js +505 -379
  33. package/src/lightning/datatable/inlineEditShared.js +24 -0
  34. package/src/lightning/datatable/keyboard.js +162 -127
  35. package/src/lightning/datatable/renderManager.js +208 -133
  36. package/src/lightning/datatable/{datatableResizeObserver.js → resizeObserver.js} +46 -29
  37. package/src/lightning/datatable/resizeSensor.js +8 -0
  38. package/src/lightning/datatable/rowLevelActions.js +17 -13
  39. package/src/lightning/datatable/rowNumber.js +54 -20
  40. package/src/lightning/datatable/rowSelection.js +760 -0
  41. package/src/lightning/datatable/rowSelectionShared.js +79 -0
  42. package/src/lightning/datatable/rows.js +17 -6
  43. package/src/lightning/datatable/state.js +16 -2
  44. package/src/lightning/datatable/templates/div/div.css +4 -0
  45. package/src/lightning/datatable/templates/div/div.html +128 -117
  46. package/src/lightning/datatable/templates/table/table.html +5 -0
  47. package/src/lightning/datatable/utils.js +14 -0
  48. package/src/lightning/datatable/widthManagerShared.js +27 -3
  49. package/src/lightning/datatable/wrapText.js +77 -47
  50. package/src/lightning/dualListbox/dualListbox.html +1 -1
  51. package/src/lightning/dualListbox/dualListbox.js +42 -0
  52. package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +36 -3
  53. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.html +2 -2
  54. package/src/lightning/formattedDateTime/__examples__/datetime/datetime.js +3 -1
  55. package/src/lightning/formattedDateTime/__examples__/time/time.html +1 -1
  56. package/src/lightning/formattedDateTime/__examples__/time/time.js +3 -1
  57. package/src/lightning/formattedDateTime/formattedDateTime.js +1 -0
  58. package/src/lightning/input/input.html +2 -5
  59. package/src/lightning/inputUtils/validity.js +12 -1
  60. package/src/lightning/pillContainer/__docs__/pillContainer.md +45 -1
  61. package/src/lightning/positionLibrary/positionLibrary.js +31 -43
  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 +167 -98
  67. package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +94 -69
  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/progressIndicator/progressIndicator.js +1 -1
  72. package/src/lightning/progressStep/progressStep.js +1 -1
  73. package/src/lightning/spinner/spinner.html +1 -1
  74. package/src/lightning/spinner/spinner.js +12 -0
  75. package/src/lightning/staticMap/staticMap.html +1 -0
  76. package/src/lightning/staticMap/staticMap.js +39 -2
  77. package/src/lightning/utils/classSet.js +4 -1
  78. package/src/lightning/utilsPrivate/phonify.js +1 -1
  79. package/scopedImports/@salesforce-label-LightningModalBase.close.js +0 -1
  80. package/src/lightning/datatable/inlineEdit-shared.js +0 -14
  81. package/src/lightning/datatable/selector-shared.js +0 -38
  82. package/src/lightning/datatable/selector.js +0 -527
@@ -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,27 +128,17 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
119
128
  return dateValue.toISOString();
120
129
  }
121
130
 
122
- handleComponentFocus() {
123
- this.dispatchEvent(new CustomEvent('focus'));
124
- }
125
-
126
- handleComponentBlur() {
127
- this.dispatchEvent(new CustomEvent('blur'));
128
- }
129
-
130
- handleComponentChange() {
131
- this.showHelpMessageIfInvalid();
132
- }
133
-
134
131
  /**
135
- * Returns editTemplate defined for custom type template
132
+ * Checks this custom type is editable and has editTemplate defined
136
133
  */
137
- get customEditTemplate() {
138
- return this._columnDef.editTemplate;
134
+ get isValidCustomType() {
135
+ return (
136
+ this._columnDef.editableCustomType && this._columnDef.editTemplate
137
+ );
139
138
  }
140
139
 
141
140
  /**
142
- * for percent, currency types use if step passed in, if not fallback to default
141
+ * For percent, currency types use if step passed in, if not fallback to default
143
142
  * @returns {*|string}
144
143
  */
145
144
  get typeAttributeStep() {
@@ -151,22 +150,48 @@ export default class LightningPrimitiveDatatableIeditTypeFactory extends Lightni
151
150
  );
152
151
  }
153
152
 
153
+ /***************************** EVENT HANDLERS *****************************/
154
+
155
+ handleComponentFocus() {
156
+ this.dispatchEvent(new CustomEvent('focus'));
157
+ }
158
+
159
+ handleComponentBlur() {
160
+ this.dispatchEvent(new CustomEvent('blur'));
161
+ }
162
+
163
+ handleComponentChange() {
164
+ this.showHelpMessageIfInvalid();
165
+ }
166
+
167
+ /***************************** LIFECYCLE HOOKS *****************************/
168
+
154
169
  /**
155
- * Checks this custom type is editable and has editTemplate defined
170
+ * Renders the appropriate template based on the column type
156
171
  */
157
- get isValidCustomType() {
158
- return (
159
- this._columnDef.editableCustomType && this._columnDef.editTemplate
160
- );
172
+ render() {
173
+ return this.isValidCustomType
174
+ ? this.customEditTemplate
175
+ : TYPE_TEMPLATE_MAPPINGS[this.columnType] || DefaultTpl;
161
176
  }
162
177
 
163
178
  /**
164
- * Checks if type is an custom type that is editable and
165
- * has an editTemplate that contains [data-inputable="true"]
166
- * Used when checking if cell can actually be edited
179
+ * Attaches event handlers for `focus`, `blur` and `change` events
167
180
  */
168
- @api
169
- get isEditableCustomValid() {
170
- return this.isValidCustomType && this.concreteComponent;
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
+ }
171
196
  }
172
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.
@@ -10,24 +10,28 @@ const i18n = {
10
10
  wrapText: labelWrapText,
11
11
  };
12
12
 
13
+ /**
14
+ * A header-level action.
15
+ */
13
16
  export default class PrimitiveHeaderActions extends LightningElement {
14
- static delegatesFocus = true;
15
- @api colKeyValue;
16
-
17
+ // Tracked objects
17
18
  @track containerRect;
18
19
  @track _internalActions = [];
19
20
  @track _customerActions = [];
21
+
22
+ // Private variables
23
+ static delegatesFocus = true;
20
24
  _actionMenuAlignment;
21
25
 
22
- @api
23
- focus() {
24
- const btnMenu = this.template.querySelector('lightning-button-menu');
26
+ /************************** PUBLIC ATTRIBUTES ***************************/
25
27
 
26
- if (btnMenu) {
27
- btnMenu.focus();
28
- }
29
- }
28
+ @api colKeyValue;
30
29
 
30
+ /**
31
+ * Defines the actions on a header cell
32
+ *
33
+ * @type {Object}
34
+ */
31
35
  @api
32
36
  get actions() {
33
37
  return this._actions;
@@ -38,49 +42,60 @@ export default class PrimitiveHeaderActions extends LightningElement {
38
42
  this.updateActions();
39
43
  }
40
44
 
41
- get i18n() {
42
- return i18n;
43
- }
44
-
45
- updateActions() {
46
- const actionTypeReducer = (type) => (actions, action) => {
47
- const overrides = { _type: type, _action: action };
48
- actions.push(Object.assign({}, action, overrides));
45
+ /************************** PUBLIC METHODS ***************************/
49
46
 
50
- return actions;
51
- };
47
+ /**
48
+ * Sets focus on a lightning-button-menu
49
+ */
50
+ @api
51
+ focus() {
52
+ const btnMenu = this.template.querySelector('lightning-button-menu');
52
53
 
53
- this._internalActions = this.getActionsByType('internalActions').reduce(
54
- actionTypeReducer('internal'),
55
- []
56
- );
54
+ if (btnMenu) {
55
+ btnMenu.focus();
56
+ }
57
+ }
57
58
 
58
- this._customerActions = this.getActionsByType('customerActions').reduce(
59
- actionTypeReducer('customer'),
60
- []
61
- );
59
+ /************************** PRIVATE GETTERS **************************/
62
60
 
63
- // ToDo: W-8389508 Refactor so menu is outside of header
64
- this._actionMenuAlignment =
65
- this._actions.menuAlignment &&
66
- this._actions.menuAlignment.replace('auto-', '');
61
+ /**
62
+ * Returns the internationalization definition object
63
+ *
64
+ * @return {Object} The i18n definition object
65
+ */
66
+ get i18n() {
67
+ return i18n;
67
68
  }
68
69
 
70
+ /**
71
+ * Determines whether or not a header has actions
72
+ *
73
+ * @return {Boolean}
74
+ */
69
75
  get hasActions() {
70
76
  return (
71
77
  this._internalActions.length > 0 || this._customerActions.length > 0
72
78
  );
73
79
  }
80
+
81
+ /**
82
+ * Determines whether or not a header has an action divider
83
+ *
84
+ * @return {Boolean}
85
+ */
74
86
  get hasActionsDivider() {
75
87
  return (
76
88
  this._internalActions.length > 0 && this._customerActions.length > 0
77
89
  );
78
90
  }
79
91
 
80
- getActionsByType(type) {
81
- return Array.isArray(this._actions[type]) ? this._actions[type] : [];
82
- }
92
+ /************************ EVENT DISPATCHERS **************************/
83
93
 
94
+ /**
95
+ * Handles opening a menu
96
+ *
97
+ * @param {Event} event
98
+ */
84
99
  handleMenuOpen(event) {
85
100
  event.preventDefault();
86
101
  event.stopPropagation();
@@ -107,6 +122,9 @@ export default class PrimitiveHeaderActions extends LightningElement {
107
122
  );
108
123
  }
109
124
 
125
+ /**
126
+ * Handles closing a menu
127
+ */
110
128
  handleMenuClose() {
111
129
  this.dispatchEvent(
112
130
  new CustomEvent('privatecellheaderactionmenuclosed', {
@@ -117,8 +135,13 @@ export default class PrimitiveHeaderActions extends LightningElement {
117
135
  );
118
136
  }
119
137
 
120
- handleActionSelect(evt) {
121
- const action = evt.detail.value;
138
+ /**
139
+ * Handles selecting an action
140
+ *
141
+ * @param {Event} event
142
+ */
143
+ handleActionSelect(event) {
144
+ const action = event.detail.value;
122
145
 
123
146
  this.dispatchEvent(
124
147
  new CustomEvent('privatecellheaderactiontriggered', {
@@ -133,4 +156,43 @@ export default class PrimitiveHeaderActions extends LightningElement {
133
156
  })
134
157
  );
135
158
  }
159
+
160
+ /************************* HELPER FUNCTIONS **************************/
161
+
162
+ /**
163
+ * Updates the actions object
164
+ */
165
+ updateActions() {
166
+ const actionTypeReducer = (type) => (actions, action) => {
167
+ const overrides = { _type: type, _action: action };
168
+ actions.push(Object.assign({}, action, overrides));
169
+
170
+ return actions;
171
+ };
172
+
173
+ this._internalActions = this.getActionsByType('internalActions').reduce(
174
+ actionTypeReducer('internal'),
175
+ []
176
+ );
177
+
178
+ this._customerActions = this.getActionsByType('customerActions').reduce(
179
+ actionTypeReducer('customer'),
180
+ []
181
+ );
182
+
183
+ // TODO: W-8389508 Refactor so menu is outside of header
184
+ this._actionMenuAlignment =
185
+ this._actions.menuAlignment &&
186
+ this._actions.menuAlignment.replace('auto-', '');
187
+ }
188
+
189
+ /**
190
+ * Returns actions by action type
191
+ *
192
+ * @param {String} type The action type to filter by
193
+ * @return {Array} An array of actions that match the provided type
194
+ */
195
+ getActionsByType(type) {
196
+ return Array.isArray(this._actions[type]) ? this._actions[type] : [];
197
+ }
136
198
  }
@@ -53,7 +53,7 @@ export default class LightningProgressIndicator extends LightningElement {
53
53
  set currentStep(value) {
54
54
  this.privateCurrentStep = value;
55
55
  if (this.privateRendered) {
56
- this.updateSteps();
56
+ this.updateSteps(value);
57
57
  }
58
58
  }
59
59
 
@@ -72,7 +72,7 @@ export default class LightningProgressStep extends LightningElement {
72
72
  'slds-is-completed': !isPath && status === 'completed',
73
73
  'slds-has-error': !isPath && status === 'error',
74
74
  'slds-is-active':
75
- (type !== 'base' && isActive === true) ||
75
+ (isPath && isActive === true) ||
76
76
  (type === 'base' && status === 'current'),
77
77
  'slds-path__item': isPath,
78
78
  'slds-is-complete': isPath && status === 'completed',
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div role="status" class={computedClass}>
3
- <span if:true={validAlternativeText} class="slds-assistive-text">{alternativeText}</span>
3
+ <span if:true={validAlternativeText} class="slds-assistive-text">{_altText}</span>
4
4
  <div class="slds-spinner__dot-a"></div>
5
5
  <div class="slds-spinner__dot-b"></div>
6
6
  </div>
@@ -27,12 +27,24 @@ export default class LightningSpinner extends LightningElement {
27
27
  */
28
28
  @api variant;
29
29
 
30
+ _altText = '';
31
+
30
32
  connectedCallback() {
31
33
  this.classList.add('slds-spinner_container');
32
34
  this.template.addEventListener('mousewheel', this.stopScrolling);
33
35
  this.template.addEventListener('touchmove', this.stopScrolling);
34
36
  }
35
37
 
38
+ renderedCallback() {
39
+ // [W-10320761] We set the _altText in the next tick because screen readers are not reading out
40
+ // the text when the text along the aria-live container is inserted into the DOM together.
41
+ // It is only working when only aria-live container is setup on load and later the content changes
42
+ // eslint-disable-next-line @lwc/lwc/no-async-operation
43
+ setTimeout(() => {
44
+ this._altText = this.alternativeText;
45
+ }, 0);
46
+ }
47
+
36
48
  get normalizedVariant() {
37
49
  return normalize(this.variant, {
38
50
  fallbackValue: 'base',
@@ -6,6 +6,7 @@
6
6
  oniframeload={handleIframeLoad}
7
7
  width={width}
8
8
  height={height}
9
+ title={mapTitle}
9
10
  frame-style={mapStyle}>
10
11
  </lightning-primitive-iframe>
11
12
  <div class="slds-iframe-cover"></div>
@@ -1,5 +1,7 @@
1
1
  import lang from '@salesforce/i18n/lang';
2
2
  import formFactor from '@salesforce/client/formFactor';
3
+ import labelTitleWithAddress from '@salesforce/label/LightningMap.titleWithAddress';
4
+ import labelTitleWithoutAddress from '@salesforce/label/LightningMap.iframeTitle';
3
5
  import { LightningElement, api, track } from 'lwc';
4
6
  import { ratioToScale, calculateSize } from './util';
5
7
  import {
@@ -9,12 +11,19 @@ import {
9
11
  postMessage,
10
12
  } from 'lightning/messageDispatcher';
11
13
  import { buildMapSourceUrl } from 'lightning/mapUtils';
14
+ import { isEmptyString } from 'lightning/inputUtils';
15
+ import { formatLabel } from 'lightning/utils';
12
16
 
13
17
  const EVENT_NAME = {
14
18
  LOADING_MAP: 'loadingMap',
15
19
  STATIC_MAP_LOADED: 'lightning:staticMapLoaded',
16
20
  };
17
21
 
22
+ const i18n = {
23
+ titleWithAddress: labelTitleWithAddress,
24
+ titleWithoutAddress: labelTitleWithoutAddress,
25
+ };
26
+
18
27
  export default class LightningStaticMap extends LightningElement {
19
28
  @api width;
20
29
  @api height;
@@ -23,6 +32,7 @@ export default class LightningStaticMap extends LightningElement {
23
32
  @api province;
24
33
  @api postalCode;
25
34
  @api country;
35
+ @api title;
26
36
 
27
37
  _zoom = 14;
28
38
  _scale = 1;
@@ -109,8 +119,7 @@ export default class LightningStaticMap extends LightningElement {
109
119
  return '';
110
120
  }
111
121
 
112
- get address() {
113
- // if latitude/longitude specified use that to avoid expensive Google geo-coding processing
122
+ get latLongString() {
114
123
  if (
115
124
  this.latitude != null &&
116
125
  this.latitude >= -90.0 &&
@@ -121,12 +130,40 @@ export default class LightningStaticMap extends LightningElement {
121
130
  ) {
122
131
  return `${this.latitude},${this.longitude}`;
123
132
  }
133
+ return null;
134
+ }
124
135
 
136
+ get addressString() {
125
137
  return `${this.street || ''} ${this.city || ''} ${
126
138
  this.province || ''
127
139
  } ${this.postalCode || ''} ${this.country || ''}`;
128
140
  }
129
141
 
142
+ get address() {
143
+ // if latitude/longitude specified use that to avoid expensive Google geo-coding processing
144
+ return this.latLongString || this.addressString;
145
+ }
146
+
147
+ /**
148
+ * getter for the i18 constant containing the localized strings
149
+ */
150
+ get i18n() {
151
+ return i18n;
152
+ }
153
+
154
+ get mapTitle() {
155
+ if (isEmptyString(this.title)) {
156
+ let titleAddress =
157
+ (this.addressString && this.addressString.trim()) ||
158
+ (this.latLongString && this.latLongString.trim());
159
+ if (isEmptyString(titleAddress)) {
160
+ return this.i18n.titleWithoutAddress;
161
+ }
162
+ return formatLabel(this.i18n.titleWithAddress, titleAddress);
163
+ }
164
+ return this.title;
165
+ }
166
+
130
167
  handleMessage(data) {
131
168
  if (data.event === EVENT_NAME.STATIC_MAP_LOADED) {
132
169
  this._mapLoaded = true;
@@ -3,7 +3,10 @@ const classNamesHash = (classes) => {
3
3
  ? classes
4
4
  .trim()
5
5
  .split(/\s+/)
6
- .reduce((acc, cn) => ({ ...acc, [cn]: true }), {})
6
+ .reduce((acc, cn) => {
7
+ acc[cn] = true;
8
+ return acc;
9
+ }, {})
7
10
  : classes;
8
11
  };
9
12
 
@@ -3,7 +3,7 @@ import locale from '@salesforce/i18n/locale';
3
3
  const NA_PHONE_NUMBER = '($1) $2-$3';
4
4
  const IS_TEN_DIGITS = /^\d{10}$/;
5
5
  const TEN_TO_NA = /(\d{3})(\d{3})(\d{4})/;
6
- const IS_ELEVEN_DIGITS = /^1\d{10}/;
6
+ const IS_ELEVEN_DIGITS = /^1\d{10}$/;
7
7
  const ELEVEN_TO_NA = /1(\d{3})(\d{3})(\d{4})$/;
8
8
 
9
9
  // The locale argument has been added for tests since there's currently no clean way of mocking the locale
@@ -1 +0,0 @@
1
- export default 'Close';
@@ -1,14 +0,0 @@
1
- export function getDirtyValue(state, rowKeyValue, colKeyValue) {
2
- const dirtyValues = state.inlineEdit.dirtyValues;
3
-
4
- if (
5
- // eslint-disable-next-line no-prototype-builtins
6
- dirtyValues.hasOwnProperty(rowKeyValue) &&
7
- // eslint-disable-next-line no-prototype-builtins
8
- dirtyValues[rowKeyValue].hasOwnProperty(colKeyValue)
9
- ) {
10
- return dirtyValues[rowKeyValue][colKeyValue];
11
- }
12
-
13
- return undefined;
14
- }