lightning-base-components 1.21.2-alpha → 1.21.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.
- package/metadata/raptor.json +28 -1
- package/package.json +28 -2
- package/scopedImports/@salesforce-label-LightningRichTextEditor.colorPicker.js +1 -0
- package/src/lightning/accordion/accordion-section.slds.css +3 -3
- package/src/lightning/accordion/accordion.slds.css +1 -2
- package/src/lightning/accordionSection/accordion-section.slds.css +3 -3
- package/src/lightning/accordionSection/accordionSection.js +3 -1
- package/src/lightning/accordionSection/button.slds.css +1 -1
- package/src/lightning/badge/badge.js +1 -0
- package/src/lightning/badge/badge.js-meta.xml +3 -0
- package/src/lightning/baseCombobox/base-combobox.slds.css +11 -6
- package/src/lightning/baseCombobox/baseCombobox.html +1 -1
- package/src/lightning/baseCombobox/baseCombobox.js +2 -2
- package/src/lightning/baseCombobox/baseCombobox.js-meta.xml +6 -0
- package/src/lightning/baseCombobox/input-text.slds.css +41 -68
- package/src/lightning/baseCombobox/keyboard.js +12 -4
- package/src/lightning/baseCombobox/listbox.slds.css +51 -99
- package/src/lightning/baseCombobox/spinner.slds.css +62 -62
- package/src/lightning/baseComboboxFormattedText/baseComboboxFormattedText.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/baseComboboxItem.js +10 -6
- package/src/lightning/baseComboboxItem/baseComboboxItem.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/listbox.slds.css +51 -99
- package/src/lightning/baseFormattedText/baseFormattedText.js +2 -2
- package/src/lightning/button/button.js +2 -1
- package/src/lightning/button/button.slds.css +1 -1
- package/src/lightning/buttonIcon/button-icon.slds.css +1 -1
- package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +4 -2
- package/src/lightning/buttonIconStateful/button-icon.slds.css +1 -1
- package/src/lightning/buttonIconStateful/button.slds.css +1 -1
- package/src/lightning/buttonMenu/button-icon.slds.css +1 -1
- package/src/lightning/buttonMenu/button-menu.slds.css +8 -2
- package/src/lightning/buttonMenu/button.slds.css +1 -1
- package/src/lightning/buttonStateful/button-stateful.slds.css +6 -2
- package/src/lightning/buttonStateful/button.slds.css +1 -1
- package/src/lightning/buttonStateful/buttonStateful.js +4 -1
- package/src/lightning/calendar/calendar.js-meta.xml +6 -0
- package/src/lightning/calendar/calendar.slds.css +9 -2
- package/src/lightning/colorPickerCustom/color-picker-custom.slds.css +22 -23
- package/src/lightning/colorPickerCustom/input-text.slds.css +41 -68
- package/src/lightning/colorPickerPanel/color-picker-panel.slds.css +9 -10
- package/src/lightning/colorPickerPanel/popover.slds.css +0 -2
- package/src/lightning/combobox/combobox.slds.css +1 -2
- package/src/lightning/combobox/form-element.slds.css +54 -54
- package/src/lightning/datatable/__examples__/customDatatableWrapper/customDatatableWrapper.js +0 -69
- package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +1 -1
- package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +1 -16
- package/src/lightning/datatable/__examples__/customDatatypeLink/customDatatypeLink.html +3 -3
- package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +1 -8
- package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +2 -39
- package/src/lightning/datatable/__examples__/customDatatypeTable/customNumber.html +1 -1
- package/src/lightning/datatable/__examples__/customDatatypeTable/customNumberEdit.html +2 -0
- package/src/lightning/datatable/__examples__/customDatatypeTable/deleteRow.html +3 -2
- package/src/lightning/datatable/__examples__/customDatatypeTable/iconPill.html +1 -1
- package/src/lightning/datatable/__examples__/customNestedComponent/customNestedComponent.html +10 -0
- package/src/lightning/datatable/__examples__/customNestedComponent/customNestedComponent.js +12 -0
- package/src/lightning/datatable/autoWidthStrategy.js +147 -191
- package/src/lightning/datatable/columnResizer.js +35 -35
- package/src/lightning/datatable/columnWidthManager.js +118 -177
- package/src/lightning/datatable/columns.js +90 -59
- package/src/lightning/datatable/datagrid.slds.css +187 -0
- package/src/lightning/datatable/datatable.js +248 -229
- package/src/lightning/datatable/errors.js +3 -0
- package/src/lightning/datatable/fixedWidthStrategy.js +22 -29
- package/src/lightning/datatable/headerActions.js +7 -9
- package/src/lightning/datatable/infiniteLoading.js +15 -15
- package/src/lightning/datatable/inlineEdit.js +255 -235
- package/src/lightning/datatable/keyboard.js +318 -282
- package/src/lightning/datatable/renderManager.js +10 -7
- package/src/lightning/datatable/resizeObserver.js +11 -59
- package/src/lightning/datatable/rowLevelActions.js +6 -5
- package/src/lightning/datatable/rowNumber.js +23 -23
- package/src/lightning/datatable/rowSelection.js +173 -145
- package/src/lightning/datatable/rowSelectionShared.js +13 -6
- package/src/lightning/datatable/rows.js +231 -196
- package/src/lightning/datatable/sort.js +26 -22
- package/src/lightning/datatable/templates/div/div.css +2 -57
- package/src/lightning/datatable/templates/div/div.html +13 -6
- package/src/lightning/datatable/templates/div/div.lbc.native.css +3 -0
- package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +86 -0
- package/src/lightning/datatable/templates/table/table.html +1 -0
- package/src/lightning/datatable/utils.js +5 -5
- package/src/lightning/datatable/widthManagerShared.js +24 -21
- package/src/lightning/datatable/wrapText.js +25 -26
- package/src/lightning/datepicker/datepicker.js +32 -9
- package/src/lightning/datepicker/datepicker.js-meta.xml +6 -0
- package/src/lightning/datepicker/form-element.slds.css +54 -54
- package/src/lightning/datepicker/input-text.slds.css +41 -68
- package/src/lightning/datetimepicker/datetimepicker.js-meta.xml +6 -0
- package/src/lightning/datetimepicker/form-element.slds.css +54 -54
- package/src/lightning/datetimepicker/input-text.slds.css +41 -68
- package/src/lightning/dualListbox/dual-listbox.slds.css +7 -2
- package/src/lightning/dualListbox/form-element.slds.css +54 -54
- package/src/lightning/dualListbox/listbox.slds.css +51 -99
- package/src/lightning/dynamicIcon/dynamic-icon-strength.slds.css +1 -2
- package/src/lightning/dynamicIcon/dynamic-icon-trend.slds.css +1 -2
- package/src/lightning/formattedDateTime/formattedDateTime.js +7 -62
- package/src/lightning/formattedDateTime/formattedDateTime.js-meta.xml +3 -0
- package/src/lightning/formattedLocation/formattedLocation.html +1 -3
- package/src/lightning/formattedLocation/formattedLocation.js +3 -25
- package/src/lightning/formattedLookup/events.js +2 -4
- package/src/lightning/formattedNumber/formattedNumber.js +2 -49
- package/src/lightning/formattedRichText/formattedRichText.js +5 -5
- package/src/lightning/formattedRichText/linkTextNodes.js +58 -0
- package/src/lightning/groupedCombobox/form-element.slds.css +54 -54
- package/src/lightning/groupedCombobox/grouped-combobox.slds.css +0 -2
- package/src/lightning/groupedCombobox/groupedCombobox.js-meta.xml +1 -1
- package/src/lightning/groupedCombobox/input-text.slds.css +41 -68
- package/src/lightning/helptext/button-icon.slds.css +1 -1
- package/src/lightning/helptext/form-element.slds.css +54 -54
- package/src/lightning/icon/icon.slds.css +12 -25
- package/src/lightning/input/form-element.slds.css +54 -54
- package/src/lightning/inputAddress/form-element.slds.css +54 -54
- package/src/lightning/inputAddress/input-address.slds.css +1 -2
- package/src/lightning/inputAddress/input-text.slds.css +41 -68
- package/src/lightning/inputAddress/inputAddress.js +1 -0
- package/src/lightning/inputAddress/inputAddress.js-meta.xml +3 -0
- package/src/lightning/inputLocation/form-element.slds.css +54 -54
- package/src/lightning/inputLocation/input-location.slds.css +1 -2
- package/src/lightning/inputLocation/input-text.slds.css +41 -68
- package/src/lightning/inputName/form-element.slds.css +54 -54
- package/src/lightning/inputName/input-text.slds.css +41 -68
- package/src/lightning/interactiveDialogBase/interactive-dialog-base.slds.css +0 -3
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js-meta.xml +6 -0
- package/src/lightning/lookupAddress/form-element.slds.css +54 -54
- package/src/lightning/lookupAddress/listbox.slds.css +51 -99
- package/src/lightning/lookupAddress/location.js +2 -0
- package/src/lightning/lookupAddress/lookup-address.slds.css +0 -2
- package/src/lightning/lookupAddress/lookupAddress.js +15 -10
- package/src/lightning/menuDivider/menu-divider.slds.css +0 -2
- package/src/lightning/menuItem/menu-item.slds.css +8 -2
- package/src/lightning/menuSubheader/menu-subheader.slds.css +1 -2
- package/src/lightning/modalBase/modal-base.slds.css +3 -3
- package/src/lightning/modalBase/modalBase.js +0 -8
- package/src/lightning/modalBase/modalBase.js-meta.xml +6 -0
- package/src/lightning/modalBody/modal-body.slds.css +1 -2
- package/src/lightning/modalFooter/modal-footer.slds.css +2 -2
- package/src/lightning/modalFooter/modalFooter.js +0 -21
- package/src/lightning/modalHeader/modal-header.slds.css +1 -2
- package/src/lightning/modalHeader/modalHeader.js +0 -22
- package/src/lightning/overlay/overlay.js-meta.xml +6 -0
- package/src/lightning/pill/pill.slds.css +32 -58
- package/src/lightning/pillContainer/button.slds.css +1 -1
- package/src/lightning/pillContainer/listbox.slds.css +51 -99
- package/src/lightning/pillContainer/pill-container.slds.css +6 -10
- package/src/lightning/pillContainer/pill.slds.css +32 -58
- package/src/lightning/popup/popover.slds.css +0 -2
- package/src/lightning/primitiveBubble/primitiveBubble.js-meta.xml +6 -0
- package/src/lightning/primitiveButton/primitiveButoon.js-meta.xml +6 -0
- package/src/lightning/primitiveCellCheckbox/checkbox.css +2 -0
- package/src/lightning/primitiveColorpickerButton/color-picker-button.slds.css +16 -38
- package/src/lightning/primitiveCustomCell/primitiveCustomCell.js +26 -1
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.css +1 -0
- package/src/lightning/primitiveHeaderFactory/selectableHeader.css +2 -0
- package/src/lightning/primitiveIcon/icon.slds.css +12 -25
- package/src/lightning/primitiveIcon/primitiveIcon.js-meta.xml +6 -0
- package/src/lightning/primitiveIframe/primitiveIframe.js +3 -1
- package/src/lightning/primitiveInputCheckbox/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +5 -2
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js-meta.xml +6 -0
- package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +6 -4
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +5 -2
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js-meta.xml +6 -0
- package/src/lightning/primitiveInputColor/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputColor/input-color.slds.css +2 -3
- package/src/lightning/primitiveInputColor/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputColor/primitiveInputColor.js +5 -2
- package/src/lightning/primitiveInputColor/primitiveInputColor.js-meta.xml +6 -0
- package/src/lightning/primitiveInputFile/button.slds.css +1 -1
- package/src/lightning/primitiveInputFile/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputFile/input-file.slds.css +1 -4
- package/src/lightning/primitiveInputFile/primitiveInputFile.js +4 -2
- package/src/lightning/primitiveInputFile/primitiveInputFile.js-meta.xml +6 -0
- package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +4 -2
- package/src/lightning/primitiveInputSimple/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputSimple/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputSimple/primitiveInputSimple.js-meta.xml +6 -0
- package/src/lightning/primitiveInputToggle/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputToggle/input-toggle.slds.css +50 -27
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +5 -2
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js-meta.xml +6 -0
- package/src/lightning/progressBar/progress-bar.slds.css +8 -10
- package/src/lightning/progressRing/progress-ring.slds.css +0 -23
- package/src/lightning/progressStep/progressStep.js +1 -14
- package/src/lightning/radioGroup/form-element.slds.css +54 -54
- package/src/lightning/radioGroup/radioGroup.html +1 -2
- package/src/lightning/radioGroup/radioGroup.js +1 -0
- package/src/lightning/routingService/routingService.js +31 -5
- package/src/lightning/select/form-element.slds.css +54 -54
- package/src/lightning/select/select.slds.css +4 -2
- package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +4 -0
- package/src/lightning/spinner/spinner.slds.css +62 -62
- package/src/lightning/tab/tab.js +4 -2
- package/src/lightning/tab/tab.slds.css +14 -7
- package/src/lightning/tabBar/tab-bar.slds.css +16 -6
- package/src/lightning/tabset/__docs__/tabset.md +24 -1
- package/src/lightning/tabset/tabset.js +25 -38
- package/src/lightning/tabset/tabset.slds.css +0 -2
- package/src/lightning/textarea/form-element.slds.css +54 -54
- package/src/lightning/textarea/textarea.js +5 -1
- package/src/lightning/textarea/textarea.slds.css +22 -9
- package/src/lightning/timepicker/form-element.slds.css +54 -54
- package/src/lightning/timepicker/timepicker.js-meta.xml +6 -0
- package/src/lightning/timepicker/timepicker.slds.css +2 -2
- package/src/lightning/toast/__docs__/toast.md +20 -22
- package/src/lightning/toast/button-icon.slds.css +1 -1
- package/src/lightning/toast/icon.slds.css +12 -25
- package/src/lightning/toast/toast.js +15 -12
- package/src/lightning/toast/toast.slds.css +6 -18
- package/src/lightning/toastContainer/toast.slds.css +6 -18
- package/src/lightning/toastContainer/toastContainer.js +25 -17
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +12 -9
- package/src/lightning/tree/tree.js +2 -0
- package/src/lightning/utils/classSet.js +9 -3
- package/src/lightning/utilsPrivate/formatUtils.js +158 -0
- package/src/lightning/utilsPrivate/textUtils.js +16 -0
- package/src/lightning/utilsPrivate/utilsPrivate.js +56 -15
- package/src/lightning/utilsPrivate/validationUtils.js +59 -0
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +0 -2
- package/src/lightning/datatable/resizeSensor.js +0 -244
- package/src/lightning/formattedRichText/linkify.js +0 -43
- package/src/lightning/utilsPrivate/smartSetAttribute.js +0 -19
|
@@ -40,13 +40,13 @@ export function getKeyField(state) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function setKeyField(state, value) {
|
|
43
|
-
assert(
|
|
44
|
-
typeof value === 'string',
|
|
45
|
-
`The "keyField" value expected in lightning:datatable must be type String.`
|
|
46
|
-
);
|
|
47
43
|
if (typeof value === 'string') {
|
|
48
44
|
state.keyField = value;
|
|
49
45
|
} else {
|
|
46
|
+
assert(
|
|
47
|
+
false,
|
|
48
|
+
`The "keyField" value expected in lightning:datatable must be type String.`
|
|
49
|
+
);
|
|
50
50
|
state.keyField = undefined;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -63,12 +63,7 @@ export function hasValidKeyField(state) {
|
|
|
63
63
|
* @returns {string} the classSet string
|
|
64
64
|
*/
|
|
65
65
|
export function resolveRowClassNames(row) {
|
|
66
|
-
|
|
67
|
-
if (row.isSelected) {
|
|
68
|
-
classes.add('slds-is-selected');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return classes.toString();
|
|
66
|
+
return `slds-hint-parent${row.isSelected ? ' slds-is-selected' : ''}`;
|
|
72
67
|
}
|
|
73
68
|
|
|
74
69
|
/**
|
|
@@ -118,93 +113,124 @@ export function updateRowsAndCellIndexes() {
|
|
|
118
113
|
const data = getData(state);
|
|
119
114
|
const columns = getColumns(state);
|
|
120
115
|
const computeUniqueRowKey = uniqueRowKeyGenerator(keyField);
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
const { length: rowCount } = data;
|
|
117
|
+
const { length: colCount } = columns;
|
|
118
|
+
|
|
119
|
+
let scopeCol;
|
|
120
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
121
|
+
const col = columns[colIndex];
|
|
122
|
+
if (col.isScopeCol && types.isValidType(col.type)) {
|
|
123
|
+
scopeCol = col;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
124
128
|
// initializing indexes
|
|
125
129
|
state.indexes = {};
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
const rows = Array(rowCount);
|
|
132
|
+
state.rows = rows;
|
|
133
|
+
|
|
134
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex += 1) {
|
|
135
|
+
const rowData = data[rowIndex];
|
|
136
|
+
const key = computeUniqueRowKey(rowData);
|
|
137
|
+
const rowErrors = getRowError(state, key);
|
|
138
|
+
|
|
139
|
+
state.indexes[key] = { rowIndex };
|
|
140
|
+
|
|
141
|
+
const isRowSelected = isSelectedRow(state, key);
|
|
142
|
+
const rowNumber = rowIndex + 1;
|
|
143
|
+
const cells = Array(colCount);
|
|
144
|
+
|
|
128
145
|
const row = {
|
|
129
|
-
key
|
|
130
|
-
cells
|
|
146
|
+
key,
|
|
147
|
+
cells,
|
|
148
|
+
rowIndex,
|
|
149
|
+
rowNumber, // for UTAM since methods are base-1
|
|
150
|
+
ariaRowIndex: rowIndex + 2, // aria attrs are base-1 and also count header as a row
|
|
151
|
+
inputType: getRowSelectionInputType(state),
|
|
152
|
+
isSelected: isRowSelected,
|
|
153
|
+
ariaSelected: isRowSelected ? 'true' : false,
|
|
154
|
+
isDisabled: isDisabledRow(state, key),
|
|
155
|
+
classnames: resolveRowClassNames(rowData),
|
|
156
|
+
tabIndex: -1,
|
|
157
|
+
style: virtualize
|
|
158
|
+
? styleToString({
|
|
159
|
+
position: 'absolute',
|
|
160
|
+
top: `${rowIndex * rowHeight}px`,
|
|
161
|
+
})
|
|
162
|
+
: '',
|
|
163
|
+
level: undefined,
|
|
164
|
+
posInSet: undefined,
|
|
165
|
+
setSize: undefined,
|
|
166
|
+
isExpanded: undefined,
|
|
167
|
+
hasChildren: undefined,
|
|
131
168
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
state.indexes[row.key] = { rowIndex };
|
|
135
|
-
|
|
136
|
-
row.rowIndex = rowIndex;
|
|
137
|
-
row.rowNumber = rowIndex + 1; // for UTAM since methods are base-1
|
|
138
|
-
row.ariaRowIndex = rowIndex + 2; // aria attrs are base-1 and also count header as a row
|
|
139
|
-
row.inputType = getRowSelectionInputType(state);
|
|
140
|
-
row.isSelected = isSelectedRow(state, row.key);
|
|
141
|
-
row.ariaSelected = row.isSelected ? 'true' : false;
|
|
142
|
-
row.isDisabled = isDisabledRow(state, row.key);
|
|
143
|
-
row.classnames = resolveRowClassNames(row);
|
|
169
|
+
|
|
170
|
+
// Add tree specific row properties.
|
|
144
171
|
Object.assign(row, getRowStateForTree(rowData, state));
|
|
145
|
-
row.tabIndex = -1;
|
|
146
|
-
if (virtualize) {
|
|
147
|
-
row.style = styleToString({
|
|
148
|
-
position: 'absolute',
|
|
149
|
-
top: `${rowIndex * rowHeight}px`,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
172
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
173
|
+
rows[rowIndex] = row;
|
|
174
|
+
|
|
175
|
+
// Add cell indexes.
|
|
176
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
177
|
+
const col = columns[colIndex];
|
|
178
|
+
const {
|
|
179
|
+
fieldName,
|
|
180
|
+
isScopeCol,
|
|
181
|
+
label: dataLabel,
|
|
182
|
+
type: columnType,
|
|
183
|
+
typeAttributes,
|
|
184
|
+
} = col;
|
|
185
|
+
const colKeyValue = generateColKeyValue(col, colIndex);
|
|
186
|
+
const columnSubType = typeAttributes
|
|
187
|
+
? typeAttributes.subType
|
|
188
|
+
: undefined;
|
|
156
189
|
const dirtyValue = getDirtyValueFromCell(
|
|
157
190
|
state,
|
|
158
191
|
row.key,
|
|
159
192
|
colKeyValue
|
|
160
193
|
);
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
);
|
|
166
|
-
const
|
|
167
|
-
|
|
194
|
+
const hasError = hasCellErrors(rowErrors, fieldName, col.columnKey);
|
|
195
|
+
// value based on the fieldName
|
|
196
|
+
const value =
|
|
197
|
+
dirtyValue === undefined ? rowData[fieldName] : dirtyValue;
|
|
198
|
+
const isValidType = types.isValidType(columnType);
|
|
199
|
+
const isCheckbox = columnType === 'SELECTABLE_CHECKBOX';
|
|
200
|
+
const isDataType = isValidType && !isScopeCol;
|
|
201
|
+
const isDataTypeScope = isValidType && isScopeCol;
|
|
202
|
+
|
|
168
203
|
// cell object creation
|
|
169
204
|
const cell = {
|
|
170
|
-
columnType
|
|
171
|
-
columnSubType
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
value: computedCellValue, // value based on the fieldName
|
|
176
|
-
displayValue: rowData.displayValue ? rowData.displayValue : '',
|
|
205
|
+
columnType,
|
|
206
|
+
columnSubType,
|
|
207
|
+
dataLabel,
|
|
208
|
+
value,
|
|
209
|
+
displayValue: rowData.displayValue || '',
|
|
177
210
|
rowKeyValue: row.key, // unique row key value
|
|
178
211
|
colKeyValue, // unique column key value
|
|
179
|
-
tabIndex: -1,
|
|
180
|
-
isCheckbox
|
|
212
|
+
tabIndex: -1,
|
|
213
|
+
isCheckbox,
|
|
181
214
|
class: computeCellClassNames(
|
|
182
215
|
rowData,
|
|
183
|
-
|
|
184
|
-
|
|
216
|
+
col,
|
|
217
|
+
hasError,
|
|
185
218
|
dirtyValue,
|
|
186
219
|
renderModeRoleBased
|
|
187
220
|
),
|
|
188
|
-
hasError
|
|
189
|
-
isDataType
|
|
190
|
-
|
|
191
|
-
isDataTypeScope:
|
|
192
|
-
types.isValidType(colData.type) && colData.isScopeCol,
|
|
221
|
+
hasError,
|
|
222
|
+
isDataType,
|
|
223
|
+
isDataTypeScope,
|
|
193
224
|
wrapText: state.wrapText[colKeyValue], // wrapText state
|
|
194
225
|
wrapTextMaxLines: state.wrapText[colKeyValue]
|
|
195
226
|
? state.wrapTextMaxLines
|
|
196
227
|
: undefined,
|
|
197
|
-
style: computeCellStyles(types,
|
|
228
|
+
style: computeCellStyles(types, col, renderModeRoleBased),
|
|
198
229
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
rowData,
|
|
204
|
-
colData,
|
|
205
|
-
types
|
|
206
|
-
);
|
|
207
|
-
} else if (isRowNumberColumn(colData)) {
|
|
230
|
+
|
|
231
|
+
if (isCustomerColumn(col)) {
|
|
232
|
+
assignCustomerColumnAttributes(cell, row, rowData, col, types);
|
|
233
|
+
} else if (isRowNumberColumn(col)) {
|
|
208
234
|
assignRowNumberColumnAttributes(
|
|
209
235
|
cell,
|
|
210
236
|
rowData,
|
|
@@ -218,14 +244,9 @@ export function updateRowsAndCellIndexes() {
|
|
|
218
244
|
// Keeping the hash for backward compatibility, but we need to have 2 indexes, 1 for columns and one for rows,
|
|
219
245
|
// because of memory usage and also at certain point we might have the data but not the columns
|
|
220
246
|
state.indexes[row.key][colKeyValue] = [rowIndex, colIndex];
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
}, row.cells);
|
|
225
|
-
|
|
226
|
-
prev.push(row);
|
|
227
|
-
return prev;
|
|
228
|
-
}, []);
|
|
247
|
+
cells[colIndex] = cell;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
229
250
|
}
|
|
230
251
|
|
|
231
252
|
/**
|
|
@@ -238,11 +259,11 @@ export function updateRowsAndCellIndexes() {
|
|
|
238
259
|
* as column identifiers.
|
|
239
260
|
*/
|
|
240
261
|
function hasCellErrors(rowErrors, fieldName, columnKey) {
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
262
|
+
const cellErrors = rowErrors.cells;
|
|
263
|
+
const errorFieldNames = rowErrors.fieldNames;
|
|
264
|
+
return columnKey
|
|
265
|
+
? !!(cellErrors && cellErrors[columnKey])
|
|
266
|
+
: !!(errorFieldNames && errorFieldNames.includes(fieldName));
|
|
246
267
|
}
|
|
247
268
|
|
|
248
269
|
/**
|
|
@@ -315,18 +336,20 @@ function assignRowNumberColumnAttributes(
|
|
|
315
336
|
* This object that contains the resolved mapping is then set in the `cell` object
|
|
316
337
|
* in each row.
|
|
317
338
|
*
|
|
318
|
-
* @param {Object}
|
|
319
|
-
* @param {Object}
|
|
339
|
+
* @param {Object} rowData - current row data. Required for cases cellAttributes refers to a fieldName in a row
|
|
340
|
+
* @param {Object} col - column definition
|
|
320
341
|
* @returns {Object} - contains the resolved mapping of cellAttributes and their values
|
|
321
342
|
*/
|
|
322
|
-
export function computeCellAttributes(
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
343
|
+
export function computeCellAttributes(rowData, col) {
|
|
344
|
+
const cellAttrs = {};
|
|
345
|
+
const cellAttributes = getCellAttributesValues(col);
|
|
346
|
+
const keys = Object.keys(cellAttributes);
|
|
347
|
+
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
348
|
+
const attrName = keys[i];
|
|
349
|
+
const attrValue = cellAttributes[attrName];
|
|
350
|
+
cellAttrs[attrName] = resolveAttributeValue(attrValue, rowData);
|
|
351
|
+
}
|
|
352
|
+
return cellAttrs;
|
|
330
353
|
}
|
|
331
354
|
|
|
332
355
|
/**
|
|
@@ -347,43 +370,47 @@ export function computeCellAttributes(row, column) {
|
|
|
347
370
|
* type-attribute-1={cell.typeAttribute1}
|
|
348
371
|
* ...
|
|
349
372
|
*
|
|
350
|
-
* @param {Object}
|
|
351
|
-
* @param {Object}
|
|
373
|
+
* @param {Object} rowData - current row data. Required for cases typeAttributes refers to a fieldName in a row
|
|
374
|
+
* @param {Object} col - column definition
|
|
352
375
|
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
353
376
|
* @returns {Object} - object containing all the typeAttributes{index} and their mapped values
|
|
354
377
|
*/
|
|
355
|
-
export function computeCellTypeAttributes(
|
|
356
|
-
|
|
357
|
-
|
|
378
|
+
export function computeCellTypeAttributes(rowData, column, types) {
|
|
379
|
+
const { typeAttributes } = column;
|
|
380
|
+
if (typeAttributes && typeAttributes.subType) {
|
|
381
|
+
return computeCellSubTypeAttributes(rowData, column);
|
|
358
382
|
}
|
|
359
|
-
const
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
383
|
+
const attributeNames = types.getType(column.type).typeAttributes;
|
|
384
|
+
const attributeValues = getTypeAttributesValues(column);
|
|
385
|
+
|
|
386
|
+
const cellAttrs = {};
|
|
387
|
+
const attributeNamesLength = attributeNames ? attributeNames.length : 0;
|
|
388
|
+
for (let i = 0; i < attributeNamesLength; i += 1) {
|
|
389
|
+
const attrName = attributeNames[i];
|
|
390
|
+
const attrValue = attributeValues[attrName];
|
|
391
|
+
cellAttrs[`typeAttribute${i}`] = resolveAttributeValue(
|
|
392
|
+
attrValue,
|
|
393
|
+
rowData
|
|
368
394
|
);
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
}, {});
|
|
395
|
+
}
|
|
396
|
+
return cellAttrs;
|
|
372
397
|
}
|
|
373
398
|
|
|
374
|
-
|
|
375
|
-
const
|
|
376
|
-
const
|
|
399
|
+
function computeCellSubTypeAttributes(rowData, column) {
|
|
400
|
+
const attributeNames = getAttributesNames(column.typeAttributes.subType);
|
|
401
|
+
const attributeValues = getSubTypeAttributesValues(column);
|
|
377
402
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
403
|
+
const cellAttrs = {};
|
|
404
|
+
const attributeNamesLength = attributeNames ? attributeNames.length : 0;
|
|
405
|
+
for (let i = 0; i < attributeNamesLength; i += 1) {
|
|
406
|
+
const attrName = attributeNames[i];
|
|
407
|
+
const attrValue = attributeValues[attrName];
|
|
408
|
+
cellAttrs[`typeAttribute${i}`] = resolveAttributeValue(
|
|
409
|
+
attrValue,
|
|
410
|
+
rowData
|
|
383
411
|
);
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}, {});
|
|
412
|
+
}
|
|
413
|
+
return cellAttrs;
|
|
387
414
|
}
|
|
388
415
|
|
|
389
416
|
function computeCellEditable(row, column) {
|
|
@@ -401,16 +428,16 @@ function computeCellEditable(row, column) {
|
|
|
401
428
|
*
|
|
402
429
|
* Returns false in all other cases.
|
|
403
430
|
*
|
|
404
|
-
* @param {object}
|
|
405
|
-
* @param {object}
|
|
431
|
+
* @param {object} rowData - a row data object stored in datatable state. Must be truthy.
|
|
432
|
+
* @param {object} col - a column data object stored in datatable state. Must be truthy.
|
|
406
433
|
*/
|
|
407
|
-
export function isCellEditable(
|
|
408
|
-
return !!resolveAttributeValue(
|
|
434
|
+
export function isCellEditable(rowData, col) {
|
|
435
|
+
return !!resolveAttributeValue(col.editable, rowData);
|
|
409
436
|
}
|
|
410
437
|
|
|
411
|
-
function computeCellDisplayReadOnlyIcon(
|
|
438
|
+
function computeCellDisplayReadOnlyIcon(col) {
|
|
412
439
|
return {
|
|
413
|
-
displayReadOnlyIcon: !!
|
|
440
|
+
displayReadOnlyIcon: !!col.displayReadOnlyIcon,
|
|
414
441
|
};
|
|
415
442
|
}
|
|
416
443
|
|
|
@@ -422,52 +449,61 @@ function computeCellDisplayReadOnlyIcon(column) {
|
|
|
422
449
|
* managed by ourselves unlike the <table> version.
|
|
423
450
|
*
|
|
424
451
|
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
425
|
-
* @param {Object}
|
|
452
|
+
* @param {Object} col - column definition
|
|
426
453
|
* @param {Boolean} renderModeRoleBased - render mode of datatable (div || table)
|
|
427
454
|
* @returns {String} - styles to be set on the cell
|
|
428
455
|
*/
|
|
429
|
-
function computeCellStyles(types,
|
|
430
|
-
|
|
431
|
-
const columnType = colData.type;
|
|
456
|
+
function computeCellStyles(types, col, renderModeRoleBased) {
|
|
457
|
+
const columnType = col.type;
|
|
432
458
|
|
|
433
|
-
|
|
434
|
-
// remove the padding that comes with the standard layout
|
|
459
|
+
let cellStyle = '';
|
|
435
460
|
if (
|
|
436
461
|
types.isCustomType(columnType) &&
|
|
437
462
|
!types.isStandardCellLayoutForCustomType(columnType)
|
|
438
463
|
) {
|
|
439
|
-
|
|
464
|
+
// When a custom type is not using the standard layout,
|
|
465
|
+
// remove the padding that comes with the standard layout
|
|
466
|
+
cellStyle = 'padding: 0;';
|
|
440
467
|
}
|
|
441
468
|
|
|
442
469
|
// Width needs to be managed when rendering as divs
|
|
443
470
|
if (renderModeRoleBased) {
|
|
444
|
-
const columnWidth =
|
|
445
|
-
|
|
471
|
+
const { columnWidth } = col.columnWidth;
|
|
472
|
+
if (columnWidth > 0) {
|
|
473
|
+
cellStyle += `width:${columnWidth}px;`;
|
|
474
|
+
}
|
|
446
475
|
}
|
|
447
476
|
|
|
448
|
-
return
|
|
477
|
+
return cellStyle;
|
|
449
478
|
}
|
|
450
479
|
|
|
451
480
|
function computeCellClassNames(
|
|
452
481
|
row,
|
|
453
482
|
column,
|
|
454
|
-
|
|
483
|
+
hasError,
|
|
455
484
|
dirtyValue,
|
|
456
485
|
renderModeRoleBased
|
|
457
486
|
) {
|
|
458
|
-
const classNames = classSet('');
|
|
459
487
|
// TODO: With the current SLDS design, the 'slds-cell-edit' class is required on a cell in cases
|
|
460
488
|
// where the read only icon is to be displayed. This is an issue with their design that will need to
|
|
461
489
|
// be addressed on their end, so once they do that we can modify this code accordingly.
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
'
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
490
|
+
let cellClass = '';
|
|
491
|
+
if (column.displayReadOnlyIcon || isCellEditable(row, column)) {
|
|
492
|
+
cellClass += 'slds-cell-edit';
|
|
493
|
+
}
|
|
494
|
+
if (isTreeType(column.type)) {
|
|
495
|
+
cellClass += (cellClass.length ? ' ' : '') + 'slds-tree__item';
|
|
496
|
+
}
|
|
497
|
+
if (hasError) {
|
|
498
|
+
cellClass += (cellClass.length ? ' ' : '') + 'slds-has-error';
|
|
499
|
+
}
|
|
500
|
+
if (dirtyValue !== undefined) {
|
|
501
|
+
cellClass += (cellClass.length ? ' ' : '') + 'slds-is-edited';
|
|
502
|
+
}
|
|
503
|
+
if (renderModeRoleBased) {
|
|
504
|
+
cellClass += (cellClass.length ? ' ' : '') + 'cell';
|
|
505
|
+
}
|
|
506
|
+
return cellClass;
|
|
471
507
|
}
|
|
472
508
|
|
|
473
509
|
/**
|
|
@@ -506,11 +542,11 @@ export function getRowsTotal(state) {
|
|
|
506
542
|
return getRows(state).length;
|
|
507
543
|
}
|
|
508
544
|
|
|
509
|
-
function resolveAttributeValue(attrValue,
|
|
545
|
+
function resolveAttributeValue(attrValue, rowData) {
|
|
510
546
|
if (isObjectLike(attrValue)) {
|
|
511
|
-
const fieldName = attrValue
|
|
547
|
+
const { fieldName } = attrValue;
|
|
512
548
|
if (fieldName) {
|
|
513
|
-
return
|
|
549
|
+
return rowData[fieldName];
|
|
514
550
|
}
|
|
515
551
|
}
|
|
516
552
|
|
|
@@ -518,69 +554,68 @@ function resolveAttributeValue(attrValue, row) {
|
|
|
518
554
|
}
|
|
519
555
|
|
|
520
556
|
function getRowStateForTree(row, state) {
|
|
557
|
+
const _row = {};
|
|
521
558
|
const column = getStateTreeColumn(state);
|
|
522
559
|
if (column) {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
hasChildren: getRowHasChildren(column, row),
|
|
529
|
-
};
|
|
560
|
+
_row.hasChildren = getRowHasChildren(column, row);
|
|
561
|
+
_row.isExpanded = isRowExpanded(column, row);
|
|
562
|
+
_row.level = getRowLevel(column, row);
|
|
563
|
+
_row.posInSet = getRowPosInSet(column, row);
|
|
564
|
+
_row.setSize = getRowSetSize(column, row);
|
|
530
565
|
}
|
|
531
|
-
return
|
|
566
|
+
return _row;
|
|
532
567
|
}
|
|
533
568
|
|
|
534
|
-
export function getRowLevel(column,
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
569
|
+
export function getRowLevel(column, rowData) {
|
|
570
|
+
const treeColTypeAttrs = getTypeAttributesValues(column);
|
|
571
|
+
return (
|
|
572
|
+
resolveAttributeValue(
|
|
573
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().level],
|
|
574
|
+
rowData
|
|
575
|
+
) || 1
|
|
539
576
|
);
|
|
540
|
-
return attrValue ? attrValue : 1;
|
|
541
577
|
}
|
|
542
578
|
|
|
543
579
|
function getRowPosInSet(column, row) {
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
580
|
+
const treeColTypeAttrs = getTypeAttributesValues(column);
|
|
581
|
+
return (
|
|
582
|
+
resolveAttributeValue(
|
|
583
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().position],
|
|
584
|
+
row
|
|
585
|
+
) || 1
|
|
548
586
|
);
|
|
549
|
-
return attrValue ? attrValue : 1;
|
|
550
587
|
}
|
|
551
588
|
|
|
552
589
|
function getRowSetSize(column, row) {
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
590
|
+
const treeColTypeAttrs = getTypeAttributesValues(column);
|
|
591
|
+
return (
|
|
592
|
+
resolveAttributeValue(
|
|
593
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().setsize],
|
|
594
|
+
row
|
|
595
|
+
) || 1
|
|
557
596
|
);
|
|
558
|
-
return attrValue ? attrValue : 1;
|
|
559
597
|
}
|
|
560
598
|
|
|
561
|
-
export function isRowExpanded(column,
|
|
562
|
-
const
|
|
599
|
+
export function isRowExpanded(column, rowData) {
|
|
600
|
+
const treeColTypeAttrs = getTypeAttributesValues(column);
|
|
563
601
|
const hasChildren = resolveAttributeValue(
|
|
564
|
-
|
|
565
|
-
|
|
602
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().children],
|
|
603
|
+
rowData
|
|
566
604
|
);
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
typeAttributesValues[getTreeStateIndicatorFieldNames().children],
|
|
581
|
-
row
|
|
605
|
+
return hasChildren
|
|
606
|
+
? `${!!resolveAttributeValue(
|
|
607
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().expanded],
|
|
608
|
+
rowData
|
|
609
|
+
)}`
|
|
610
|
+
: undefined;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function getRowHasChildren(column, rowData) {
|
|
614
|
+
const treeColTypeAttrs = getTypeAttributesValues(column);
|
|
615
|
+
return !!resolveAttributeValue(
|
|
616
|
+
treeColTypeAttrs[getTreeStateIndicatorFieldNames().children],
|
|
617
|
+
rowData
|
|
582
618
|
);
|
|
583
|
-
return !!hasChildren;
|
|
584
619
|
}
|
|
585
620
|
|
|
586
621
|
/**
|