lightning-base-components 1.21.3-alpha → 1.21.4-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/metadata/raptor.json +49 -0
- package/package.json +88 -21
- package/scopedImports/@salesforce-label-LightningDatatable.showActions.js +1 -1
- package/scopedImports/@salesforce-label-LightningForm.controllerFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsHeader.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.generalDependentFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.learnMore.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.okButton.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalCancel.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalSelect.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.currentStage.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.errorStage.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageComplete.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageNotStarted.js +1 -1
- package/src/lightning/avatar/avatar.html +1 -0
- package/src/lightning/badge/badge.html +3 -3
- package/src/lightning/baseCombobox/baseCombobox.html +4 -1
- package/src/lightning/baseCombobox/baseCombobox.js +3 -16
- package/src/lightning/button/__docs__/button.md +2 -1
- package/src/lightning/button/button.js +3 -4
- package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -0
- package/src/lightning/buttonIcon/buttonIcon.html +1 -1
- package/src/lightning/buttonIcon/buttonIcon.js +18 -17
- package/src/lightning/buttonMenu/buttonMenu.css +5 -0
- package/src/lightning/buttonMenu/buttonMenu.js +2 -0
- package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
- package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
- package/src/lightning/combobox/combobox.html +1 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.html +11 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.js +25 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/generateData.js +15 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/customInput.html +4 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js +17 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/nestedSimpleComponentParent.html +7 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.html +9 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.js +6 -0
- package/src/lightning/datatable/autoWidthStrategy.js +8 -36
- package/src/lightning/datatable/columnResizer.js +51 -161
- package/src/lightning/datatable/columnWidthManager.js +25 -81
- package/src/lightning/datatable/columns.js +180 -302
- package/src/lightning/datatable/datatable.js +455 -441
- package/src/lightning/datatable/errors.js +17 -29
- package/src/lightning/datatable/fixedWidthStrategy.js +7 -22
- package/src/lightning/datatable/headerActions.js +8 -38
- package/src/lightning/datatable/indexes.js +42 -0
- package/src/lightning/datatable/infiniteLoading.js +16 -35
- package/src/lightning/datatable/inlineEdit.js +125 -156
- package/src/lightning/datatable/keyboard.js +226 -282
- package/src/lightning/datatable/renderManager.js +0 -4
- package/src/lightning/datatable/resizeObserver.js +4 -13
- package/src/lightning/datatable/rowLevelActions.js +2 -2
- package/src/lightning/datatable/rowNumber.js +21 -59
- package/src/lightning/datatable/rowSelection.js +95 -178
- package/src/lightning/datatable/rowSelectionShared.js +13 -27
- package/src/lightning/datatable/rows.js +171 -418
- package/src/lightning/datatable/sort.js +16 -75
- package/src/lightning/datatable/templates/div/div.html +12 -4
- package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +10 -16
- package/src/lightning/datatable/templates/table/table.html +15 -5
- package/src/lightning/datatable/tree.js +17 -35
- package/src/lightning/datatable/types.js +10 -31
- package/src/lightning/datatable/utils.js +49 -24
- package/src/lightning/datatable/virtualization.js +2 -5
- package/src/lightning/datatable/widthManagerShared.js +0 -20
- package/src/lightning/datatable/wrapText.js +29 -60
- package/src/lightning/dualListbox/dualListbox.js +7 -8
- package/src/lightning/formattedName/formattedName.js +3 -2
- package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
- package/src/lightning/formattedNumber/formattedNumber.js +3 -2
- package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
- package/src/lightning/formattedRichText/richTextConfig.js +1 -0
- package/src/lightning/helptext/helptext.css +7 -0
- package/src/lightning/helptext/helptext.js +3 -4
- package/src/lightning/icon/icon.html +1 -1
- package/src/lightning/input/input.html +5 -0
- package/src/lightning/inputAddress/addressFormat.js +31 -4
- package/src/lightning/inputAddress/fieldsLayout.js +6 -0
- package/src/lightning/inputAddress/inputAddress.html +19 -1
- package/src/lightning/inputAddress/inputAddress.js +74 -3
- package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
- package/src/lightning/lookupAddress/lookupAddress.html +6 -1
- package/src/lightning/lookupAddress/lookupAddress.js +25 -0
- package/src/lightning/modal/__docs__/modal.md +10 -1
- package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +3 -7
- package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +39 -133
- package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
- package/src/lightning/modal/modal.js +1 -1
- package/src/lightning/modalBase/modalBase.html +15 -10
- package/src/lightning/modalBase/modalBase.js +131 -146
- package/src/lightning/modalBody/modalBody.css +6 -0
- package/src/lightning/modalHeader/modalHeader.html +16 -4
- package/src/lightning/modalHeader/modalHeader.js +61 -14
- package/src/lightning/pill/link.html +1 -0
- package/src/lightning/pill/plain.html +1 -0
- package/src/lightning/pill/plainLink.html +1 -0
- package/src/lightning/primitiveBubble/primitiveBubble.js +42 -0
- package/src/lightning/primitiveDatatableCell/primitiveDatatableCell.js +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.html +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +13 -0
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +19 -6
- package/src/lightning/primitiveHeaderFactory/sortableHeader.html +3 -1
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.css +11 -0
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.html +2 -1
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.js +1 -0
- package/src/lightning/progressStep/base.html +5 -6
- package/src/lightning/progressStep/progressStep.js +14 -9
- package/src/lightning/prompt/__docs__/prompt.md +1 -1
- package/src/lightning/shadowBaseClassPrivate/shadowBaseClassPrivate.js +0 -2
- package/src/lightning/sldsCommon/sldsCommon.css +134 -98
- package/src/lightning/sldsUtilsAlignment/sldsUtilsAlignment.css +1 -1
- package/src/lightning/sldsUtilsBox/sldsUtilsBox.css +14 -13
- package/src/lightning/sldsUtilsGrid/sldsUtilsGrid.css +95 -92
- package/src/lightning/sldsUtilsHyphenation/sldsUtilsHyphenation.css +1 -1
- package/src/lightning/sldsUtilsMargin/sldsUtilsMargin.css +77 -75
- package/src/lightning/sldsUtilsPadding/sldsUtilsPadding.css +73 -73
- package/src/lightning/sldsUtilsSizing/sldsUtilsSizing.css +552 -558
- package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +2 -2
- package/src/lightning/staticMap/staticMap.js +3 -2
- package/src/lightning/tab/tab.js +6 -3
- package/src/lightning/tab/tab.js-meta.xml +3 -0
- package/src/lightning/tabBar/tabBar.js +10 -5
- package/src/lightning/tabset/tabset.html +2 -0
- package/src/lightning/tabset/tabset.js-meta.xml +3 -0
- package/src/lightning/textarea/textarea.js +6 -1
- package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +24 -15
- package/src/lightning/verticalNavigation/vertical-navigation.slds.css +14 -0
- package/src/lightning/verticalNavigation/verticalNavigation.css +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.js +66 -28
- package/src/lightning/verticalNavigation/verticalNavigation.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.css +2 -3
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js +29 -15
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.native.css +2 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemBadge/badge.slds.css +76 -0
- package/src/lightning/verticalNavigationItemBadge/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.css +2 -3
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.html +1 -1
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js +28 -15
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.css +2 -3
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js +29 -15
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.native.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationOverflow/button.slds.css +503 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-section.slds.css +17 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.css +2 -1
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.html +2 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js +18 -13
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +14 -14
- package/src/lightning/verticalNavigationSection/verticalNavigationSection.js-meta.xml +3 -0
- package/src/lightning/datatable/inlineEditShared.js +0 -26
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customDatatypeTable.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customLink.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customName.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumber.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumberEdit.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/deleteRow.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/iconPill.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/orderingButtons.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.js +0 -0
|
@@ -1,41 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startPositioning,
|
|
3
3
|
stopPositioning,
|
|
4
|
-
Direction,
|
|
4
|
+
Direction as DIRECTION,
|
|
5
5
|
} from 'lightning/positionLibrary';
|
|
6
6
|
import {
|
|
7
7
|
setFocusActiveCell,
|
|
8
8
|
reactToTabBackward,
|
|
9
9
|
reactToTabForward,
|
|
10
10
|
getActiveCellElement,
|
|
11
|
-
updateActiveCell,
|
|
12
11
|
isActiveCellEditable,
|
|
12
|
+
NAVIGATION_DIR,
|
|
13
13
|
isValidCell,
|
|
14
14
|
} from './keyboard';
|
|
15
|
+
import { updateRowsAndCellIndexes, isCellEditable } from './rows';
|
|
16
|
+
import { getStateColumnIndex } from './columns';
|
|
17
|
+
import { resetErrors } from './errors';
|
|
18
|
+
import { setAriaSelectedOnCell, unsetAriaSelectedOnCell } from './rowSelection';
|
|
15
19
|
import {
|
|
16
|
-
updateRowsAndCellIndexes,
|
|
17
|
-
getRowByKey,
|
|
18
|
-
getKeyField,
|
|
19
|
-
getUserRowByCellKeys,
|
|
20
|
-
isCellEditable,
|
|
21
|
-
} from './rows';
|
|
22
|
-
import {
|
|
23
|
-
getColumnIndexByColumnKey,
|
|
24
|
-
getColumns,
|
|
25
|
-
getStateColumnIndex,
|
|
26
|
-
getEditableColumns,
|
|
27
|
-
} from './columns';
|
|
28
|
-
import { setErrors } from './errors';
|
|
29
|
-
import {
|
|
30
|
-
setAriaSelectedOnCell,
|
|
31
|
-
unsetAriaSelectedOnCell,
|
|
32
|
-
isSelectedRow,
|
|
33
20
|
getCurrentSelectionLength,
|
|
34
21
|
getSelectedRowsKeys,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
isSelectedRow,
|
|
23
|
+
} from './rowSelectionShared';
|
|
24
|
+
import { hasOwnProperties } from 'lightning/utilsPrivate';
|
|
25
|
+
import { getRowByKey, getUserRowByCellKeys } from './indexes';
|
|
39
26
|
|
|
40
27
|
const IEDIT_PANEL_SELECTOR = '[data-iedit-panel="true"]';
|
|
41
28
|
const HIDE_PANEL_THRESHOLD = 5; // hide panel on scroll
|
|
@@ -62,6 +49,8 @@ export function handleInlineEditFinish(event) {
|
|
|
62
49
|
stopPanelPositioning(this);
|
|
63
50
|
const { reason, rowKeyValue, colKeyValue } = event.detail;
|
|
64
51
|
processInlineEditFinish(this, reason, rowKeyValue, colKeyValue);
|
|
52
|
+
// Set private draftValues var to new value
|
|
53
|
+
this._draftValues = this.draftValues;
|
|
65
54
|
}
|
|
66
55
|
|
|
67
56
|
/**
|
|
@@ -108,22 +97,22 @@ export function handleInlineEditPanelScroll(event) {
|
|
|
108
97
|
let delta = 0;
|
|
109
98
|
const { target: scroller } = event;
|
|
110
99
|
|
|
111
|
-
// When user scrolls
|
|
112
|
-
if (scroller.classList.contains('slds-
|
|
113
|
-
const scrollX = scroller.scrollLeft;
|
|
114
|
-
if (this._lastScrollX == null) {
|
|
115
|
-
this._lastScrollX = scrollX;
|
|
116
|
-
} else {
|
|
117
|
-
delta = Math.abs(this._lastScrollX - scrollX);
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
// When user scrolls vertically
|
|
100
|
+
// When user scrolls vertically.
|
|
101
|
+
if (scroller.classList.contains('slds-scrollable_y')) {
|
|
121
102
|
const scrollY = scroller.scrollTop;
|
|
122
103
|
if (this._lastScrollY == null) {
|
|
123
104
|
this._lastScrollY = scrollY;
|
|
124
105
|
} else {
|
|
125
106
|
delta = Math.abs(this._lastScrollY - scrollY);
|
|
126
107
|
}
|
|
108
|
+
} else {
|
|
109
|
+
// When user scrolls horizontally.
|
|
110
|
+
const scrollX = scroller.scrollLeft;
|
|
111
|
+
if (this._lastScrollX == null) {
|
|
112
|
+
this._lastScrollX = scrollX;
|
|
113
|
+
} else {
|
|
114
|
+
delta = Math.abs(this._lastScrollX - scrollX);
|
|
115
|
+
}
|
|
127
116
|
}
|
|
128
117
|
|
|
129
118
|
// If user has scrolled past threshold,
|
|
@@ -148,14 +137,14 @@ export function handleInlineEditPanelScroll(event) {
|
|
|
148
137
|
* Dispatches the `cellchange` event with the `draftValues` in the
|
|
149
138
|
* detail object.
|
|
150
139
|
*
|
|
151
|
-
* @param {Object} dt - datatable instance
|
|
152
|
-
* @param {Object}
|
|
140
|
+
* @param {Object} dt - The datatable instance
|
|
141
|
+
* @param {Object} changes - Object containing cell changes
|
|
153
142
|
*/
|
|
154
|
-
function dispatchCellChangeEvent(dt,
|
|
143
|
+
function dispatchCellChangeEvent(dt, changes) {
|
|
155
144
|
dt.dispatchEvent(
|
|
156
145
|
new CustomEvent('cellchange', {
|
|
157
146
|
detail: {
|
|
158
|
-
draftValues: getResolvedCellChanges(dt.state,
|
|
147
|
+
draftValues: getResolvedCellChanges(dt.state, changes),
|
|
159
148
|
},
|
|
160
149
|
})
|
|
161
150
|
);
|
|
@@ -164,13 +153,14 @@ function dispatchCellChangeEvent(dt, cellChange) {
|
|
|
164
153
|
/************************** INLINE EDIT STATE MANAGEMENT **************************/
|
|
165
154
|
|
|
166
155
|
export function isInlineEditTriggered(state) {
|
|
167
|
-
return
|
|
156
|
+
return hasOwnProperties(state.inlineEdit.dirtyValues);
|
|
168
157
|
}
|
|
169
158
|
|
|
170
159
|
export function cancelInlineEdit(dt) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
const { state, _privateTypes } = dt;
|
|
161
|
+
resetErrors(state);
|
|
162
|
+
state.inlineEdit.dirtyValues = {};
|
|
163
|
+
updateRowsAndCellIndexes(state, _privateTypes);
|
|
174
164
|
}
|
|
175
165
|
|
|
176
166
|
export function closeInlineEdit(dt) {
|
|
@@ -224,7 +214,7 @@ function processInlineEditFinish(dt, reason, rowKeyValue, colKeyValue) {
|
|
|
224
214
|
const shouldSaveData =
|
|
225
215
|
isValidCell(state, rowKeyValue, colKeyValue) &&
|
|
226
216
|
reason !== 'edit-canceled' &&
|
|
227
|
-
!(
|
|
217
|
+
!(reason === 'lost-focus' && inlineEditState.massEditEnabled);
|
|
228
218
|
|
|
229
219
|
if (shouldSaveData) {
|
|
230
220
|
const panel = template.querySelector(IEDIT_PANEL_SELECTOR);
|
|
@@ -242,7 +232,6 @@ function processInlineEditFinish(dt, reason, rowKeyValue, colKeyValue) {
|
|
|
242
232
|
[colKeyValue]: editValue,
|
|
243
233
|
},
|
|
244
234
|
};
|
|
245
|
-
|
|
246
235
|
if (updateAllSelectedRows) {
|
|
247
236
|
const selectedRowsKeys = getSelectedRowsKeys(state);
|
|
248
237
|
for (let i = 0; i < selectedRowsKeys.length; i += 1) {
|
|
@@ -257,17 +246,17 @@ function processInlineEditFinish(dt, reason, rowKeyValue, colKeyValue) {
|
|
|
257
246
|
dispatchCellChangeEvent(dt, changes);
|
|
258
247
|
|
|
259
248
|
// TODO: do we need to update all rows in the dt or just the one that was modified?
|
|
260
|
-
updateRowsAndCellIndexes
|
|
249
|
+
updateRowsAndCellIndexes(state, dt._privateTypes);
|
|
261
250
|
}
|
|
262
251
|
}
|
|
263
252
|
|
|
264
253
|
if (reason !== 'lost-focus') {
|
|
265
254
|
if (reason === 'tab-pressed-next') {
|
|
266
|
-
reactToTabForward(
|
|
255
|
+
reactToTabForward(state, template);
|
|
267
256
|
} else if (reason === 'tab-pressed-prev') {
|
|
268
|
-
reactToTabBackward(
|
|
257
|
+
reactToTabBackward(state, template);
|
|
269
258
|
} else {
|
|
270
|
-
setFocusActiveCell(
|
|
259
|
+
setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
|
|
271
260
|
}
|
|
272
261
|
}
|
|
273
262
|
|
|
@@ -314,7 +303,7 @@ function openInlineEdit(dt, target) {
|
|
|
314
303
|
|
|
315
304
|
const { rowKeyValue, colKeyValue } = target;
|
|
316
305
|
const colIndex = getStateColumnIndex(state, colKeyValue);
|
|
317
|
-
const col =
|
|
306
|
+
const col = state.columns[colIndex];
|
|
318
307
|
|
|
319
308
|
inlineEditState.isPanelVisible = true;
|
|
320
309
|
inlineEditState.rowKeyValue = rowKeyValue;
|
|
@@ -328,8 +317,8 @@ function openInlineEdit(dt, target) {
|
|
|
328
317
|
|
|
329
318
|
const { typeAttributes } = col || {};
|
|
330
319
|
if (typeAttributes) {
|
|
331
|
-
//
|
|
332
|
-
// then assign the resolved values to inlineEdit.resolvedTypeAttributes
|
|
320
|
+
// When the inline edit panel is opened resolve the typeAttributes if available
|
|
321
|
+
// then assign the resolved values to inlineEdit.resolvedTypeAttributes.
|
|
333
322
|
inlineEditState.resolvedTypeAttributes = resolveNestedTypeAttributes(
|
|
334
323
|
state,
|
|
335
324
|
rowKeyValue,
|
|
@@ -378,15 +367,14 @@ export function openInlineEditOnActiveCell(dt) {
|
|
|
378
367
|
if (!isActiveCellEditable(state)) {
|
|
379
368
|
const firstEditableCell = getFirstEditableCell(dt);
|
|
380
369
|
if (firstEditableCell) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
firstEditableCell.
|
|
384
|
-
|
|
385
|
-
);
|
|
386
|
-
setFocusAndOpenInlineEdit(dt, state.activeCell);
|
|
370
|
+
state.activeCell = {
|
|
371
|
+
rowKeyValue: firstEditableCell.rowKeyValue,
|
|
372
|
+
colKeyValue: firstEditableCell.colKeyValue,
|
|
373
|
+
};
|
|
374
|
+
setFocusAndOpenInlineEdit(dt);
|
|
387
375
|
}
|
|
388
376
|
} else {
|
|
389
|
-
setFocusAndOpenInlineEdit(dt
|
|
377
|
+
setFocusAndOpenInlineEdit(dt);
|
|
390
378
|
}
|
|
391
379
|
}
|
|
392
380
|
}
|
|
@@ -399,9 +387,9 @@ export function openInlineEditOnActiveCell(dt) {
|
|
|
399
387
|
// eslint-disable-next-line @lwc/lwc/no-async-await
|
|
400
388
|
async function setFocusAndOpenInlineEdit(dt) {
|
|
401
389
|
const { state, template } = dt;
|
|
402
|
-
await setFocusActiveCell(
|
|
403
|
-
const
|
|
404
|
-
openInlineEdit(dt,
|
|
390
|
+
await setFocusActiveCell(state, template, NAVIGATION_DIR.USE_CURRENT);
|
|
391
|
+
const cellElement = getActiveCellElement(template, state);
|
|
392
|
+
openInlineEdit(dt, cellElement);
|
|
405
393
|
}
|
|
406
394
|
|
|
407
395
|
/************************** PANEL POSITIONING **************************/
|
|
@@ -418,10 +406,10 @@ async function setFocusAndOpenInlineEdit(dt) {
|
|
|
418
406
|
* - horizontal - Left -> align panel to left edge of cell
|
|
419
407
|
* - vertical - Top -> align panel to top of the cell
|
|
420
408
|
*
|
|
421
|
-
* @param {Object} dt - datatable instance
|
|
422
|
-
* @param {HTMLElement}
|
|
409
|
+
* @param {Object} dt - The datatable instance
|
|
410
|
+
* @param {HTMLElement} cellElement - The cell element on which inline edit should open
|
|
423
411
|
*/
|
|
424
|
-
function startPanelPositioning(dt,
|
|
412
|
+
function startPanelPositioning(dt, cellElement) {
|
|
425
413
|
// eslint-disable-next-line @lwc/lwc/no-async-operation
|
|
426
414
|
requestAnimationFrame(() => {
|
|
427
415
|
// we need to discard previous binding otherwise the panel
|
|
@@ -429,19 +417,19 @@ function startPanelPositioning(dt, target) {
|
|
|
429
417
|
stopPanelPositioning(dt);
|
|
430
418
|
|
|
431
419
|
dt._positionRelationship = startPositioning(dt, {
|
|
432
|
-
target,
|
|
420
|
+
target: cellElement,
|
|
433
421
|
element() {
|
|
434
422
|
const panel = dt.template.querySelector(IEDIT_PANEL_SELECTOR);
|
|
435
423
|
return panel.getPositionedElement();
|
|
436
424
|
},
|
|
437
425
|
autoFlip: true,
|
|
438
426
|
align: {
|
|
439
|
-
horizontal:
|
|
440
|
-
vertical:
|
|
427
|
+
horizontal: DIRECTION.Left,
|
|
428
|
+
vertical: DIRECTION.Top,
|
|
441
429
|
},
|
|
442
430
|
targetAlign: {
|
|
443
|
-
horizontal:
|
|
444
|
-
vertical:
|
|
431
|
+
horizontal: DIRECTION.Left,
|
|
432
|
+
vertical: DIRECTION.Top,
|
|
445
433
|
},
|
|
446
434
|
});
|
|
447
435
|
});
|
|
@@ -474,7 +462,7 @@ function repositionPanel(dt) {
|
|
|
474
462
|
/************************** DIRTY/UNSAVED VALUES **************************/
|
|
475
463
|
|
|
476
464
|
/**
|
|
477
|
-
* @param {Object} state -
|
|
465
|
+
* @param {Object} state - The datatable state
|
|
478
466
|
* @returns {Array} - An array of objects, each object describing the dirty values in the form { colName : dirtyValue }.
|
|
479
467
|
* A special key is the { [keyField]: value } pair used to identify the row containing this changed values.
|
|
480
468
|
* The returned array will be in the form - [{colName : dirtyValue, ... , [keyField]: value }, {...}, {...}]
|
|
@@ -486,18 +474,36 @@ export function getDirtyValues(state) {
|
|
|
486
474
|
/**
|
|
487
475
|
* Sets the dirty values in the datatable.
|
|
488
476
|
*
|
|
489
|
-
* @param {Object} state
|
|
477
|
+
* @param {Object} state The datatable state
|
|
490
478
|
* @param {Array} values An untracked array of objects, each object describing the dirty values in the form { colName : dirtyValue }.
|
|
491
479
|
* A special key is the { [keyField]: value } pair used to identify the row containing this changed values.
|
|
492
480
|
*/
|
|
493
481
|
export function setDirtyValues(state, values) {
|
|
494
|
-
const keyField =
|
|
482
|
+
const { columns, keyField } = state;
|
|
495
483
|
const dirtyValues = Array.isArray(values) ? values : [];
|
|
496
|
-
|
|
497
484
|
const result = {};
|
|
498
485
|
for (let dirtyIndex = 0; dirtyIndex < dirtyValues.length; dirtyIndex += 1) {
|
|
499
486
|
const rowValues = dirtyValues[dirtyIndex];
|
|
500
|
-
const
|
|
487
|
+
const colKeys = Object.keys(rowValues);
|
|
488
|
+
const colChanges = {};
|
|
489
|
+
for (
|
|
490
|
+
let colKeysIndex = 0, { length: colKeysLength } = colKeys;
|
|
491
|
+
colKeysIndex < colKeysLength;
|
|
492
|
+
colKeysIndex += 1
|
|
493
|
+
) {
|
|
494
|
+
const externalColKeyValue = colKeys[colKeysIndex];
|
|
495
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
496
|
+
const col = columns[colIndex];
|
|
497
|
+
if (
|
|
498
|
+
col.columnKey === externalColKeyValue ||
|
|
499
|
+
(!col.columnKey && col.fieldName === externalColKeyValue)
|
|
500
|
+
) {
|
|
501
|
+
colChanges[col.colKeyValue] =
|
|
502
|
+
rowValues[externalColKeyValue];
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
501
507
|
delete colChanges[keyField];
|
|
502
508
|
result[rowValues[keyField]] = colChanges;
|
|
503
509
|
}
|
|
@@ -505,9 +511,9 @@ export function setDirtyValues(state, values) {
|
|
|
505
511
|
}
|
|
506
512
|
|
|
507
513
|
/**
|
|
508
|
-
* Updates the dirty values specified in
|
|
514
|
+
* Updates the dirty values specified in the `changes` object.
|
|
509
515
|
*
|
|
510
|
-
* @param {Object} state -
|
|
516
|
+
* @param {Object} state - The datatable state
|
|
511
517
|
* @param {Object} changes - An object in the form of { rowKeyValue: { colKeyValue1: value, ..., colKeyValueN: value } ... }
|
|
512
518
|
*/
|
|
513
519
|
function updateDirtyValues(state, changes) {
|
|
@@ -523,64 +529,6 @@ function updateDirtyValues(state, changes) {
|
|
|
523
529
|
}
|
|
524
530
|
}
|
|
525
531
|
|
|
526
|
-
/**
|
|
527
|
-
* Constructs and returns an object that contains the cell changes which can
|
|
528
|
-
* be referenced by the column key value. It follows this format:
|
|
529
|
-
* { <colKeyValue: "<editedValue>"> }; Ex. { "name-text-2": "My changes" }
|
|
530
|
-
*
|
|
531
|
-
* @param {Object} state - datatable's state object
|
|
532
|
-
* @param {Object} rowValues - internal representation of changes in a row
|
|
533
|
-
* @returns {Object} - changes in a column that can be referenced by the column key
|
|
534
|
-
*/
|
|
535
|
-
function getCellChangesFromCustomer(state, rowValues) {
|
|
536
|
-
const columns = getColumns(state);
|
|
537
|
-
const colKeys = Object.keys(rowValues);
|
|
538
|
-
const colChanges = {};
|
|
539
|
-
for (
|
|
540
|
-
let colKeysIndex = 0, { length: colKeysLength } = colKeys;
|
|
541
|
-
colKeysIndex < colKeysLength;
|
|
542
|
-
colKeysIndex += 1
|
|
543
|
-
) {
|
|
544
|
-
const externalColKeyValue = colKeys[colKeysIndex];
|
|
545
|
-
const colIndex = getColumnIndexByColumnKey(state, externalColKeyValue);
|
|
546
|
-
if (colIndex >= 0) {
|
|
547
|
-
const colKey = columns[colIndex].colKeyValue;
|
|
548
|
-
colChanges[colKey] = rowValues[externalColKeyValue];
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
return colChanges;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Retrieves the changes in cells in a particular column
|
|
556
|
-
* Returns an object where each item follows this format:
|
|
557
|
-
* { <columnName>: "<changes>"} -> Ex. { name: "My changes" }
|
|
558
|
-
*
|
|
559
|
-
* @param {Object} state - Datatable state
|
|
560
|
-
* @param {Object} colChanges - The internal representation of changes in a row
|
|
561
|
-
* @returns {Object} - the list of customer changes in a column
|
|
562
|
-
*/
|
|
563
|
-
function getCellChangesByColumn(state, colChanges) {
|
|
564
|
-
const columns = getColumns(state);
|
|
565
|
-
const changeColKeys = Object.keys(colChanges);
|
|
566
|
-
const { length: changeColCount } = changeColKeys;
|
|
567
|
-
const cellChanges = {};
|
|
568
|
-
for (
|
|
569
|
-
let changeColIndex = 0;
|
|
570
|
-
changeColIndex < changeColCount;
|
|
571
|
-
changeColIndex += 1
|
|
572
|
-
) {
|
|
573
|
-
const colKeyValue = changeColKeys[changeColIndex];
|
|
574
|
-
const colIndex = getStateColumnIndex(state, colKeyValue);
|
|
575
|
-
if (colIndex !== -1) {
|
|
576
|
-
const col = columns[colIndex];
|
|
577
|
-
cellChanges[col.columnKey || col.fieldName] =
|
|
578
|
-
colChanges[colKeyValue];
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
return cellChanges;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
532
|
/**
|
|
585
533
|
* Constructs an array of resolved cell changes made via inline edit
|
|
586
534
|
* Each array item consists of an identifier of the row and column in order to locate
|
|
@@ -590,13 +538,13 @@ function getCellChangesByColumn(state, colChanges) {
|
|
|
590
538
|
* Ex. [{ name: "My changes", id: "2" }]; where column name is 'name' and 'id' is the keyField
|
|
591
539
|
* The keyField can be used to identify the row.
|
|
592
540
|
*
|
|
593
|
-
* @param {Object} state - datatable state
|
|
541
|
+
* @param {Object} state - The datatable state
|
|
594
542
|
* @param {Object} rowChanges - list of cell changes to be resolved
|
|
595
543
|
* @returns {Array} - array containing changes and identifiers of column and row where the changes
|
|
596
544
|
* should be applied
|
|
597
545
|
*/
|
|
598
546
|
function getResolvedCellChanges(state, rowChanges) {
|
|
599
|
-
const keyField =
|
|
547
|
+
const { columns, keyField } = state;
|
|
600
548
|
const result = [];
|
|
601
549
|
const changeRowKeys = Object.keys(rowChanges);
|
|
602
550
|
for (
|
|
@@ -606,12 +554,27 @@ function getResolvedCellChanges(state, rowChanges) {
|
|
|
606
554
|
) {
|
|
607
555
|
const rowKeyValue = changeRowKeys[changeRowIndex];
|
|
608
556
|
const colChanges = rowChanges[rowKeyValue];
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
557
|
+
const changeColKeys = Object.keys(colChanges);
|
|
558
|
+
const { length: changeColCount } = changeColKeys;
|
|
559
|
+
if (changeColCount) {
|
|
560
|
+
const cellChanges = {
|
|
561
|
+
// Add identifier for which row has change
|
|
562
|
+
[keyField]: rowKeyValue,
|
|
563
|
+
};
|
|
564
|
+
// Get the changes made by column
|
|
565
|
+
for (
|
|
566
|
+
let changeColIndex = 0;
|
|
567
|
+
changeColIndex < changeColCount;
|
|
568
|
+
changeColIndex += 1
|
|
569
|
+
) {
|
|
570
|
+
const colKeyValue = changeColKeys[changeColIndex];
|
|
571
|
+
const colIndex = getStateColumnIndex(state, colKeyValue);
|
|
572
|
+
if (colIndex !== -1) {
|
|
573
|
+
const col = columns[colIndex];
|
|
574
|
+
cellChanges[col.columnKey || col.fieldName] =
|
|
575
|
+
colChanges[colKeyValue];
|
|
576
|
+
}
|
|
577
|
+
}
|
|
615
578
|
result.push(cellChanges);
|
|
616
579
|
}
|
|
617
580
|
}
|
|
@@ -623,14 +586,14 @@ function getResolvedCellChanges(state, rowChanges) {
|
|
|
623
586
|
/**
|
|
624
587
|
* Returns the resolved typeAttributes
|
|
625
588
|
*
|
|
626
|
-
* @param {Object} state -
|
|
627
|
-
* @param {String} rowKeyValue - row key
|
|
628
|
-
* @param {String} colKeyValue - column key
|
|
629
|
-
* @param {
|
|
630
|
-
* @param {
|
|
631
|
-
* @param {
|
|
589
|
+
* @param {Object} state - The datatable state
|
|
590
|
+
* @param {String} rowKeyValue - The row key
|
|
591
|
+
* @param {String} colKeyValue - The column key
|
|
592
|
+
* @param {Object} types - The type handling factory
|
|
593
|
+
* @param {Object} typeAttributes - values of typeAttributes from column definition
|
|
594
|
+
* @param {Number} colIndex - The column index
|
|
632
595
|
*
|
|
633
|
-
* @returns {Object}
|
|
596
|
+
* @returns {Object} The resolved typeAttributes.
|
|
634
597
|
*/
|
|
635
598
|
export function resolveNestedTypeAttributes(
|
|
636
599
|
state,
|
|
@@ -649,7 +612,7 @@ export function resolveNestedTypeAttributes(
|
|
|
649
612
|
const { length: attributeNamesLength } = attributeNames;
|
|
650
613
|
const _rowData = getUserRowByCellKeys(state, rowKeyValue, colKeyValue);
|
|
651
614
|
// We only want to resolve typeAttributes based on the custom types configuration
|
|
652
|
-
// If the attribute is not in that configuration, the value of
|
|
615
|
+
// If the attribute is not in that configuration, the value of attrValue
|
|
653
616
|
// for that will be undefined. This behavior is consistent with view cell.
|
|
654
617
|
for (let i = 0; i < attributeNamesLength; i += 1) {
|
|
655
618
|
const attrName = attributeNames[i];
|
|
@@ -665,7 +628,7 @@ export function resolveNestedTypeAttributes(
|
|
|
665
628
|
}
|
|
666
629
|
|
|
667
630
|
/**
|
|
668
|
-
* Helper function to recursively traverse and resolve the nested
|
|
631
|
+
* Helper function to recursively traverse and resolve the nested attrValue object.
|
|
669
632
|
* For example, resolve {
|
|
670
633
|
* editTypeAttributes: {
|
|
671
634
|
* value: {
|
|
@@ -682,7 +645,7 @@ export function resolveNestedTypeAttributes(
|
|
|
682
645
|
*/
|
|
683
646
|
function resolveNestedTypeAttributesHelper(rowData, attrValue) {
|
|
684
647
|
let resolvedTypeAttributes = {};
|
|
685
|
-
if (!
|
|
648
|
+
if (!(typeof attrValue === 'object' && attrValue !== null)) {
|
|
686
649
|
// Primitive value.
|
|
687
650
|
// For example, if the typeAttributes is { count: 5},
|
|
688
651
|
// 5 will be the attrValue passed in to the function.
|
|
@@ -702,7 +665,7 @@ function resolveNestedTypeAttributesHelper(rowData, attrValue) {
|
|
|
702
665
|
// so we need to check if key is 'fieldName' or not and resolve it immediately.
|
|
703
666
|
if (name === 'fieldName') {
|
|
704
667
|
resolvedTypeAttributes = rowData[value];
|
|
705
|
-
} else if (
|
|
668
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
706
669
|
// This is the case when attrValue is something like {label: {fieldName: 'name'}}.
|
|
707
670
|
// It's an object but the value maps a field name
|
|
708
671
|
const { fieldName } = value;
|
|
@@ -734,8 +697,14 @@ function resolveNestedTypeAttributesHelper(rowData, attrValue) {
|
|
|
734
697
|
*/
|
|
735
698
|
function getFirstEditableCell(dt) {
|
|
736
699
|
const { state } = dt;
|
|
737
|
-
const columns =
|
|
738
|
-
const editableColumns =
|
|
700
|
+
const { columns } = state;
|
|
701
|
+
const editableColumns = [];
|
|
702
|
+
for (let i = 0, { length } = columns; i < length; i += 1) {
|
|
703
|
+
const col = columns[i];
|
|
704
|
+
if (col.editable) {
|
|
705
|
+
editableColumns.push(col);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
739
708
|
const { length: editableColumnsLength } = editableColumns;
|
|
740
709
|
if (editableColumnsLength > 0) {
|
|
741
710
|
const { rows } = state;
|
|
@@ -783,7 +752,7 @@ function getCellValue(state, rowKeyValue, colKeyValue) {
|
|
|
783
752
|
*/
|
|
784
753
|
function setAriaSelectedOnAllSelectedRows(state) {
|
|
785
754
|
const { colKeyValue } = state.inlineEdit;
|
|
786
|
-
const selectedRowsKeys =
|
|
755
|
+
const { selectedRowsKeys } = state;
|
|
787
756
|
const keys = Object.keys(selectedRowsKeys);
|
|
788
757
|
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
789
758
|
const rowKeyValue = keys[i];
|
|
@@ -801,7 +770,7 @@ function setAriaSelectedOnAllSelectedRows(state) {
|
|
|
801
770
|
*/
|
|
802
771
|
function unsetAriaSelectedOnAllSelectedRows(state) {
|
|
803
772
|
const { colKeyValue } = state.inlineEdit;
|
|
804
|
-
const selectedRowsKeys =
|
|
773
|
+
const { selectedRowsKeys } = state;
|
|
805
774
|
const keys = Object.keys(selectedRowsKeys);
|
|
806
775
|
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
807
776
|
const rowKeyValue = keys[i];
|