lightning-base-components 1.13.6-alpha → 1.13.10-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 +104 -2
- package/package.json +37 -1
- package/scopedImports/@salesforce-label-LightningAlert.defaultLabel.js +1 -0
- package/scopedImports/@salesforce-label-LightningConfirm.defaultLabel.js +1 -0
- package/scopedImports/@salesforce-label-LightningDateTimePicker.selectDateFor.js +1 -0
- package/scopedImports/@salesforce-label-LightningInteractiveDialogBase.cancel.js +1 -0
- package/scopedImports/@salesforce-label-LightningInteractiveDialogBase.ok.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.recentItems.js +1 -0
- package/scopedImports/@salesforce-label-LightningModalBase.close.js +1 -0
- package/scopedImports/@salesforce-label-LightningModalBase.waitstate.js +1 -0
- package/scopedImports/@salesforce-label-LightningPrompt.defaultLabel.js +1 -0
- package/src/lightning/baseCombobox/baseCombobox.html +50 -24
- package/src/lightning/baseCombobox/baseCombobox.js +53 -28
- package/src/lightning/card/card.html +7 -1
- package/src/lightning/card/card.js +30 -2
- package/src/lightning/card/utils.js +14 -0
- package/src/lightning/combobox/combobox.css +12 -0
- package/src/lightning/combobox/combobox.html +1 -0
- package/src/lightning/datatable/__docs__/datatable.md +40 -13
- package/src/lightning/datatable/columnWidthManager.js +8 -4
- package/src/lightning/datatable/columns-shared.js +8 -7
- package/src/lightning/datatable/columns.js +38 -4
- package/src/lightning/datatable/datatable.js +932 -727
- package/src/lightning/datatable/datatableResizeObserver.js +1 -1
- package/src/lightning/datatable/inlineEdit.js +15 -3
- package/src/lightning/datatable/keyboard.js +1078 -935
- package/src/lightning/datatable/resizer.js +92 -109
- package/src/lightning/datatable/rows.js +245 -59
- package/src/lightning/datatable/sort.js +83 -28
- package/src/lightning/datatable/{normalizer.js → state.js} +16 -28
- package/src/lightning/datatable/templates/div/div.css +53 -0
- package/src/lightning/datatable/templates/div/div.html +272 -0
- package/src/lightning/datatable/{datatable.css → templates/table/table.css} +0 -0
- package/src/lightning/datatable/templates/table/table.html +260 -0
- package/src/lightning/datatable/widthManagerShared.js +1 -1
- package/src/lightning/datepicker/datepicker.html +3 -3
- package/src/lightning/datepicker/datepicker.js +6 -2
- package/src/lightning/datetimepicker/datetimepicker.html +3 -4
- package/src/lightning/datetimepicker/datetimepicker.js +0 -2
- package/src/lightning/formattedRichText/__docs__/formattedRichText.md +1 -0
- package/src/lightning/helptext/helptext.js +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/asset_audit.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/attach.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/historical_adherence.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/med_rec_recommendation.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/medication_dispense.html +11 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/medication_reconciliation.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/report_type.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/story.html +2 -4
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tour.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/unified_health_score.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +26 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/asset_audit.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/collection_alt.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_doc.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/einstein.html +2 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/entitlement.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/signature.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tour.html +9 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/truck.html +10 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/asset_audit.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/attach.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/historical_adherence.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/med_rec_recommendation.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/medication_dispense.html +11 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/medication_reconciliation.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/report_type.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/story.html +2 -4
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/unified_health_score.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +26 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/asset_audit.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/collection_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_doc.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/einstein.html +2 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/entitlement.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/signature.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/truck.html +10 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/asset_audit.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/attach.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/historical_adherence.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/med_rec_recommendation.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/medication_dispense.html +11 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/medication_reconciliation.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/report_type.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/story.html +2 -4
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/unified_health_score.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +15 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/asset_audit.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/attach.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/historical_adherence.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/med_rec_recommendation.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/med_rec_statement_recommendation.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/medication_dispense.html +11 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/medication_reconciliation.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/report_type.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/story.html +2 -4
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/unified_health_score.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +15 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +12 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/asset_audit.html +9 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/collection_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_doc.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/einstein.html +2 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/entitlement.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/signature.html +9 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/truck.html +10 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/workforce_engagement.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +12 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/asset_audit.html +9 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/collection_alt.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_doc.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/contract_payment.html +10 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/einstein.html +2 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/entitlement.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/field_sales.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/signature.html +9 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tour.html +9 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tour_check.html +8 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/truck.html +10 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/workforce_engagement.html +8 -0
- package/src/lightning/input/__docs__/input.md +4 -0
- package/src/lightning/input/input.js +11 -6
- package/src/lightning/pill/link.html +1 -1
- package/src/lightning/pill/pill.js +18 -0
- package/src/lightning/pill/plainLink.html +2 -0
- package/src/lightning/pillContainer/barePillContainer.html +5 -5
- package/src/lightning/pillContainer/pillContainer.js +5 -4
- package/src/lightning/pillContainer/standardPillContainer.html +5 -5
- package/src/lightning/positionLibrary/__component__/positionLibraryBounding.spec.js +8 -6
- package/src/lightning/positionLibrary/__component__/x/bounding/bounding.html +1 -1
- package/src/lightning/positionLibrary/__component__/x/bounding/bounding.js +6 -9
- package/src/lightning/positionLibrary/direction.js +17 -5
- package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.js +20 -0
- package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +10 -0
- package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.js +17 -3
- package/src/lightning/primitiveDatatableTooltip/primitiveDatatableTooltip.js +1 -0
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +5 -4
- package/src/lightning/primitiveHeaderFactory/primitiveHeaderFactory.js +255 -94
- package/src/lightning/primitiveHeaderFactory/selectableHeader.html +25 -23
- package/src/lightning/primitiveHeaderFactory/sortableHeader.html +13 -9
- package/src/lightning/progressIndicator/progressIndicator.js +30 -9
- package/src/lightning/progressRing/progressRing.html +6 -0
- package/src/lightning/progressRing/progressRing.js +98 -3
- package/src/lightning/progressStep/progressStep.js +6 -3
- package/src/lightning/timepicker/timepicker.html +1 -0
- package/src/lightning/utilsPrivate/aria.js +30 -0
- package/src/lightning/utilsPrivate/contentMutation.js +24 -2
- package/src/lightning/utilsPrivate/utilsPrivate.js +1 -1
- package/src/lightning/datatable/datatable.html +0 -237
- package/src/lightning/datatable/keys.js +0 -32
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assert } from 'lightning/utilsPrivate';
|
|
2
2
|
import { classSet, isObjectLike } from './utils';
|
|
3
|
-
import { createRowKeysGenerator, generateColKeyValue } from './keys';
|
|
4
3
|
import { isTreeType, getAttributesNames } from './types';
|
|
5
4
|
import {
|
|
6
5
|
isSelectedRow,
|
|
@@ -14,18 +13,14 @@ import {
|
|
|
14
13
|
getSubTypeAttributesValues,
|
|
15
14
|
getCellAttributesValues,
|
|
16
15
|
isCustomerColumn,
|
|
16
|
+
generateColKeyValue,
|
|
17
17
|
} from './columns';
|
|
18
18
|
import { isRowNumberColumn, getRowNumberErrorColumnDef } from './rowNumber';
|
|
19
19
|
import { getRowError } from './errors';
|
|
20
20
|
import { getDirtyValue } from './inlineEdit-shared';
|
|
21
21
|
|
|
22
|
-
export function
|
|
23
|
-
return
|
|
24
|
-
data: [],
|
|
25
|
-
keyField: undefined,
|
|
26
|
-
rows: [],
|
|
27
|
-
indexes: {},
|
|
28
|
-
};
|
|
22
|
+
export function getData(state) {
|
|
23
|
+
return state.data;
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
export function setData(state, data) {
|
|
@@ -36,14 +31,14 @@ export function setData(state, data) {
|
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
export function getData(state) {
|
|
40
|
-
return state.data;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
export function getRows(state) {
|
|
44
35
|
return state.rows;
|
|
45
36
|
}
|
|
46
37
|
|
|
38
|
+
export function getKeyField(state) {
|
|
39
|
+
return state.keyField;
|
|
40
|
+
}
|
|
41
|
+
|
|
47
42
|
export function setKeyField(state, value) {
|
|
48
43
|
assert(
|
|
49
44
|
typeof value === 'string',
|
|
@@ -56,17 +51,14 @@ export function setKeyField(state, value) {
|
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
export function getKeyField(state) {
|
|
60
|
-
return state.keyField;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
54
|
export function hasValidKeyField(state) {
|
|
64
55
|
const keyField = getKeyField(state);
|
|
65
56
|
return typeof keyField === 'string';
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
/**
|
|
69
|
-
*
|
|
60
|
+
* Resolves the CSS classes for a row based on the row.isSelected state
|
|
61
|
+
*
|
|
70
62
|
* @param {object} row - a row object in state.rows collection
|
|
71
63
|
* @returns {string} the classSet string
|
|
72
64
|
*/
|
|
@@ -92,17 +84,41 @@ export function getUserRowByCellKeys(state, rowKeyValue, colKeyValue) {
|
|
|
92
84
|
return getData(state)[rowIndex];
|
|
93
85
|
}
|
|
94
86
|
|
|
87
|
+
/**
|
|
88
|
+
* It creates a row key generator based on the keyField passed in by the consumer.
|
|
89
|
+
* If the keyField passed in through the generator does not point to a value in the row object,
|
|
90
|
+
* it falls back to a generated key using indexes. Ex. row-0/row-1
|
|
91
|
+
*
|
|
92
|
+
* @param {String} keyField - keyField provided by the consumer
|
|
93
|
+
* @returns {Function} - function with the unique row key generator
|
|
94
|
+
*/
|
|
95
|
+
export function uniqueRowKeyGenerator(keyField) {
|
|
96
|
+
let index = 0;
|
|
97
|
+
return function (row) {
|
|
98
|
+
if (row[keyField]) {
|
|
99
|
+
return row[keyField];
|
|
100
|
+
}
|
|
101
|
+
return `row-${index++}`;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
95
105
|
/**
|
|
96
106
|
* It compute the state.rows collection based on the current normalized (data, columns)
|
|
97
107
|
* and generate cells indexes map(state.indexes)
|
|
108
|
+
*
|
|
109
|
+
* TODO: Reduce redundant calls to this function. This is indirectly called by the
|
|
110
|
+
* setters of 'data' and 'columns'. Additionally, for the role-based table, if we are
|
|
111
|
+
* attaching the 'cell' class, calling this from connectedCallback of datatable would
|
|
112
|
+
* eliminate the need for updateCellClassForRoleBasedMode.
|
|
113
|
+
*
|
|
98
114
|
* @param {object} state - the current datatable state
|
|
99
115
|
*/
|
|
100
116
|
export function updateRowsAndCellIndexes() {
|
|
101
117
|
const { state, privateTypes: types } = this;
|
|
102
|
-
const { keyField } = state;
|
|
118
|
+
const { keyField, renderModeRoleBased } = state;
|
|
103
119
|
const data = getData(state);
|
|
104
120
|
const columns = getColumns(state);
|
|
105
|
-
const
|
|
121
|
+
const computeUniqueRowKey = uniqueRowKeyGenerator(keyField);
|
|
106
122
|
const scopeCol = columns.find(
|
|
107
123
|
(colData) => types.isValidType(colData.type) && colData.isScopeCol
|
|
108
124
|
);
|
|
@@ -130,6 +146,11 @@ export function updateRowsAndCellIndexes() {
|
|
|
130
146
|
const { fieldName } = colData;
|
|
131
147
|
const colKeyValue = generateColKeyValue(colData, colIndex);
|
|
132
148
|
const dirtyValue = getDirtyValue(state, row.key, colKeyValue);
|
|
149
|
+
const cellHasErrors = hasCellErrors(
|
|
150
|
+
rowErrors,
|
|
151
|
+
colData.fieldName,
|
|
152
|
+
colData.columnKey
|
|
153
|
+
);
|
|
133
154
|
const computedCellValue =
|
|
134
155
|
dirtyValue !== undefined ? dirtyValue : rowData[fieldName];
|
|
135
156
|
// cell object creation
|
|
@@ -147,14 +168,11 @@ export function updateRowsAndCellIndexes() {
|
|
|
147
168
|
class: computeCellClassNames(
|
|
148
169
|
rowData,
|
|
149
170
|
colData,
|
|
150
|
-
|
|
151
|
-
dirtyValue
|
|
152
|
-
|
|
153
|
-
hasError: hasCellErrors(
|
|
154
|
-
rowErrors,
|
|
155
|
-
colData.fieldName,
|
|
156
|
-
colData.columnKey
|
|
171
|
+
cellHasErrors,
|
|
172
|
+
dirtyValue,
|
|
173
|
+
renderModeRoleBased
|
|
157
174
|
),
|
|
175
|
+
hasError: cellHasErrors,
|
|
158
176
|
isDataType:
|
|
159
177
|
types.isValidType(colData.type) && !colData.isScopeCol,
|
|
160
178
|
isDataTypeScope:
|
|
@@ -163,35 +181,23 @@ export function updateRowsAndCellIndexes() {
|
|
|
163
181
|
wrapTextMaxLines: state.wrapText[colKeyValue]
|
|
164
182
|
? state.wrapTextMaxLines
|
|
165
183
|
: undefined,
|
|
166
|
-
|
|
167
|
-
types.isCustomType(colData.type) &&
|
|
168
|
-
!types.isStandardCellLayoutForCustomType(colData.type)
|
|
169
|
-
? 'padding: 0px;'
|
|
170
|
-
: undefined,
|
|
184
|
+
style: computeCellStyles(types, colData, renderModeRoleBased),
|
|
171
185
|
};
|
|
172
186
|
if (isCustomerColumn(colData)) {
|
|
173
|
-
|
|
187
|
+
assignCustomerColumnAttributes(
|
|
174
188
|
cell,
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
189
|
+
row,
|
|
190
|
+
rowData,
|
|
191
|
+
colData,
|
|
192
|
+
types
|
|
179
193
|
);
|
|
180
|
-
if (!cell.editable) {
|
|
181
|
-
cell.ariaReadOnly = true;
|
|
182
|
-
}
|
|
183
|
-
if (isTreeType(colData.type)) {
|
|
184
|
-
Object.assign(cell, computeCellStateTypeAttributes(row));
|
|
185
|
-
}
|
|
186
194
|
} else if (isRowNumberColumn(colData)) {
|
|
187
|
-
|
|
188
|
-
const errorColumnDef = getRowNumberErrorColumnDef(
|
|
189
|
-
rowErrors,
|
|
190
|
-
scopeColValue
|
|
191
|
-
);
|
|
192
|
-
Object.assign(
|
|
195
|
+
assignRowNumberColumnAttributes(
|
|
193
196
|
cell,
|
|
194
|
-
|
|
197
|
+
rowData,
|
|
198
|
+
types,
|
|
199
|
+
rowErrors,
|
|
200
|
+
scopeCol
|
|
195
201
|
);
|
|
196
202
|
}
|
|
197
203
|
|
|
@@ -226,6 +232,80 @@ function hasCellErrors(rowErrors, fieldName, columnKey) {
|
|
|
226
232
|
return rowErrorsHasColumnKey || (!columnKey && rowErrorsHasFieldName);
|
|
227
233
|
}
|
|
228
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Computes and sets the following resolved values in the cell object:
|
|
237
|
+
* 1. `typeAttributes` specified in the column definition
|
|
238
|
+
* 2. `cellAttributes` specified in the column definition
|
|
239
|
+
* 3. Editability of the cell and subsequently the ariaReadOnly property
|
|
240
|
+
* 4. Visibility of read only icon
|
|
241
|
+
*
|
|
242
|
+
* Computes and sets the following tree specific attributes
|
|
243
|
+
* into typeAttributes21/22 in the cell object:
|
|
244
|
+
* 1. row.hasChildren
|
|
245
|
+
* 2. row.isExpanded
|
|
246
|
+
*
|
|
247
|
+
* @param {Object} cell - cell metadata
|
|
248
|
+
* @param {Object} row - row metadata
|
|
249
|
+
* @param {Object} rowData - data to be rendered in the cells of that row
|
|
250
|
+
* @param {Object} colData - column definition
|
|
251
|
+
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
252
|
+
*/
|
|
253
|
+
function assignCustomerColumnAttributes(cell, row, rowData, colData, types) {
|
|
254
|
+
Object.assign(
|
|
255
|
+
cell,
|
|
256
|
+
computeCellTypeAttributes(rowData, colData, types),
|
|
257
|
+
computeCellAttributes(rowData, colData),
|
|
258
|
+
computeCellEditable(rowData, colData),
|
|
259
|
+
computeCellDisplayReadOnlyIcon(colData)
|
|
260
|
+
);
|
|
261
|
+
if (!cell.editable) {
|
|
262
|
+
cell.ariaReadOnly = true;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// If this is tree grid, this maps and sets into the cell object the tree specific attributes:
|
|
266
|
+
// 1) row.hasChildren to typeAttribute21 and
|
|
267
|
+
// 2) row.isExpanded to and typeAttribute22
|
|
268
|
+
if (isTreeType(colData.type)) {
|
|
269
|
+
Object.assign(cell, computeCellStateTypeAttributes(row));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Computes and sets the resolved typeAttribute for the row number column error state
|
|
275
|
+
*
|
|
276
|
+
* @param {Object} cell - cell metadata
|
|
277
|
+
* @param {Object} rowData - data to be rendered in the cells of that row
|
|
278
|
+
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
279
|
+
* @param {Object} rowErrors - contains the errors present in that row
|
|
280
|
+
* @param {Object} scopeCol - column with scope=row
|
|
281
|
+
*/
|
|
282
|
+
function assignRowNumberColumnAttributes(
|
|
283
|
+
cell,
|
|
284
|
+
rowData,
|
|
285
|
+
types,
|
|
286
|
+
rowErrors,
|
|
287
|
+
scopeCol
|
|
288
|
+
) {
|
|
289
|
+
const scopeColValue = rowData[scopeCol.fieldName];
|
|
290
|
+
const errorColumnDef = getRowNumberErrorColumnDef(rowErrors, scopeColValue);
|
|
291
|
+
Object.assign(
|
|
292
|
+
cell,
|
|
293
|
+
computeCellTypeAttributes(rowData, errorColumnDef, types)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* This function extracts the `cellAttributes` and their values that are specified
|
|
299
|
+
* in the column definition.
|
|
300
|
+
* If a cell attribute points to a fieldName in a row, that value is resolved here.
|
|
301
|
+
*
|
|
302
|
+
* This object that contains the resolved mapping is then set in the `cell` object
|
|
303
|
+
* in each row.
|
|
304
|
+
*
|
|
305
|
+
* @param {Object} row - current row data. Required for cases cellAttributes refers to a fieldName in a row
|
|
306
|
+
* @param {Object} column - column definition
|
|
307
|
+
* @returns {Object} - contains the resolved mapping of cellAttributes and their values
|
|
308
|
+
*/
|
|
229
309
|
export function computeCellAttributes(row, column) {
|
|
230
310
|
const cellAttributesValues = getCellAttributesValues(column);
|
|
231
311
|
return Object.keys(cellAttributesValues).reduce((attrs, attrName) => {
|
|
@@ -236,6 +316,29 @@ export function computeCellAttributes(row, column) {
|
|
|
236
316
|
}, {});
|
|
237
317
|
}
|
|
238
318
|
|
|
319
|
+
/**
|
|
320
|
+
* This function retrieves the allowlisted type attributes for a particular type and
|
|
321
|
+
* maps the value set in the column definition to `typeAttribute{index}`.
|
|
322
|
+
*
|
|
323
|
+
* The types and their corresponding allowlisted attributes can be seen in types.js
|
|
324
|
+
*
|
|
325
|
+
* Ex. For the type 'url', there are 3 type attributes allowlisted: label, target, tooltip
|
|
326
|
+
* If you pass typeAttributes: {label: 'My Label', target: '_blank', myattr: false}
|
|
327
|
+
* in the column definition, this function would map ->
|
|
328
|
+
* typeAttribute0: 'My Label', typeAttribute1: '_blank' and typeAttribute2: undefined
|
|
329
|
+
* `myattr` is not allowlisted so it is discarded
|
|
330
|
+
*
|
|
331
|
+
* This mapping is later set into the `cell` object for each row and
|
|
332
|
+
* will be passed in to primitive-cell-factory as
|
|
333
|
+
* type-attribute-0={cell.typeAttribute0}
|
|
334
|
+
* type-attribute-1={cell.typeAttribute1}
|
|
335
|
+
* ...
|
|
336
|
+
*
|
|
337
|
+
* @param {Object} row - current row data. Required for cases typeAttributes refers to a fieldName in a row
|
|
338
|
+
* @param {Object} column - column definition
|
|
339
|
+
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
340
|
+
* @returns {Object} - object containing all the typeAttributes{index} and their mapped values
|
|
341
|
+
*/
|
|
239
342
|
export function computeCellTypeAttributes(row, column, types) {
|
|
240
343
|
if (column.typeAttributes && column.typeAttributes.subType) {
|
|
241
344
|
return computeCellSubTypeAttributes(row, column);
|
|
@@ -298,7 +401,47 @@ function computeCellDisplayReadOnlyIcon(column) {
|
|
|
298
401
|
};
|
|
299
402
|
}
|
|
300
403
|
|
|
301
|
-
|
|
404
|
+
/**
|
|
405
|
+
* Computes styles to be set on the cell
|
|
406
|
+
* 1. Remove padding from the cell if the cell is of a custom type
|
|
407
|
+
* and has opted out of using the standard layout
|
|
408
|
+
* 2. Set width of the cell. Width of each cell needs to be set and
|
|
409
|
+
* managed by ourselves unlike the <table> version.
|
|
410
|
+
*
|
|
411
|
+
* @param {Object} types - instance of DatatableTypes from `./types.js`
|
|
412
|
+
* @param {Object} colData - column definition
|
|
413
|
+
* @param {Boolean} renderModeRoleBased - render mode of datatable (div || table)
|
|
414
|
+
* @returns {String} - styles to be set on the cell
|
|
415
|
+
*/
|
|
416
|
+
function computeCellStyles(types, colData, renderModeRoleBased) {
|
|
417
|
+
let style = '';
|
|
418
|
+
const columnType = colData.type;
|
|
419
|
+
|
|
420
|
+
// When a custom type is not using the standard layout,
|
|
421
|
+
// remove the padding that comes with the standard layout
|
|
422
|
+
if (
|
|
423
|
+
types.isCustomType(columnType) &&
|
|
424
|
+
!types.isStandardCellLayoutForCustomType(columnType)
|
|
425
|
+
) {
|
|
426
|
+
style = 'padding: 0;';
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Width needs to be managed when rendering as divs
|
|
430
|
+
if (renderModeRoleBased) {
|
|
431
|
+
const columnWidth = colData.columnWidth;
|
|
432
|
+
style += columnWidth > 0 ? `width:${columnWidth}px;` : '';
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return style;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
function computeCellClassNames(
|
|
439
|
+
row,
|
|
440
|
+
column,
|
|
441
|
+
cellHasErrors,
|
|
442
|
+
dirtyValue,
|
|
443
|
+
renderModeRoleBased
|
|
444
|
+
) {
|
|
302
445
|
const classNames = classSet('');
|
|
303
446
|
// TODO: With the current SLDS design, the 'slds-cell-edit' class is required on a cell in cases
|
|
304
447
|
// where the read only icon is to be displayed. This is an issue with their design that will need to
|
|
@@ -306,16 +449,11 @@ function computeCellClassNames(row, column, rowErrors, dirtyValue) {
|
|
|
306
449
|
classNames.add({
|
|
307
450
|
'slds-cell-edit':
|
|
308
451
|
isCellEditable(row, column) || column.displayReadOnlyIcon,
|
|
452
|
+
'slds-tree__item': isTreeType(column.type),
|
|
453
|
+
'slds-has-error': cellHasErrors,
|
|
454
|
+
'slds-is-edited': dirtyValue !== undefined,
|
|
455
|
+
cell: renderModeRoleBased,
|
|
309
456
|
});
|
|
310
|
-
classNames.add({ 'slds-tree__item': isTreeType(column.type) });
|
|
311
|
-
classNames.add({
|
|
312
|
-
'slds-has-error': hasCellErrors(
|
|
313
|
-
rowErrors,
|
|
314
|
-
column.fieldName,
|
|
315
|
-
column.columnKey
|
|
316
|
-
),
|
|
317
|
-
});
|
|
318
|
-
classNames.add({ 'slds-is-edited': dirtyValue !== undefined });
|
|
319
457
|
return classNames.toString();
|
|
320
458
|
}
|
|
321
459
|
|
|
@@ -431,3 +569,51 @@ export function getRowHasChildren(column, row) {
|
|
|
431
569
|
);
|
|
432
570
|
return !!hasChildren;
|
|
433
571
|
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* For the role-based table, we need to manage the width of each cell separately.
|
|
575
|
+
* Re-compute the cell styles so that the width of the cell is set
|
|
576
|
+
* to that of its column.
|
|
577
|
+
*
|
|
578
|
+
* @param {Object} state - Datatable's state object
|
|
579
|
+
*/
|
|
580
|
+
export function recomputeCellStyles(types, state) {
|
|
581
|
+
const columns = getColumns(state);
|
|
582
|
+
state.rows.forEach((row) => {
|
|
583
|
+
row.cells.forEach((cell, colIndex) => {
|
|
584
|
+
const colData = columns[colIndex];
|
|
585
|
+
cell.style = computeCellStyles(types, colData, true);
|
|
586
|
+
});
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* The cells' classes are normally updated via `updateRowsAndCellIndexes()`. This ideally
|
|
592
|
+
* happens after renderMode is set since `updateRowsAndCellIndexes` requires the final
|
|
593
|
+
* renderMode value in order to set the 'cell' class on each cell.
|
|
594
|
+
*
|
|
595
|
+
* However, in some cases, it's possible that updateRowsAndCellIndexes is called
|
|
596
|
+
* before the renderMode is set (to 'role-based'). This will cause the 'cell' class to NOT be set
|
|
597
|
+
* in the individual cells because state.renderModeRoleBased will be `false` at that point.
|
|
598
|
+
* As a result, positioning of the cell content will be off.
|
|
599
|
+
*
|
|
600
|
+
* In such a case where the renderMode is 'role-based' and when the updateRowsAndCellIndexes
|
|
601
|
+
* has already been called (indicated by the presence of 'state.rows'), retroactively
|
|
602
|
+
* add the 'cell' class to each cell.
|
|
603
|
+
*
|
|
604
|
+
* TODO: The 'cell' class will not be required once we move to the SLDS blueprint.
|
|
605
|
+
* Remove this and usages once datatable migrates to using the SLDS blueprint for the role-based table.
|
|
606
|
+
*
|
|
607
|
+
* @param {Object} state - Datatable's state object
|
|
608
|
+
*/
|
|
609
|
+
export function updateCellClassForRoleBasedMode(state) {
|
|
610
|
+
if (state.renderModeRoleBased && state.rows) {
|
|
611
|
+
state.rows.forEach((row) => {
|
|
612
|
+
row.cells.forEach((cell) => {
|
|
613
|
+
const classes = classSet(cell.class);
|
|
614
|
+
classes.add('cell');
|
|
615
|
+
cell.class = classes.toString();
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}
|
|
@@ -1,39 +1,71 @@
|
|
|
1
1
|
import { assert } from 'lightning/utilsPrivate';
|
|
2
2
|
import { getColumnName } from './columns-shared';
|
|
3
3
|
|
|
4
|
-
export function getSortDefaultState() {
|
|
5
|
-
return {
|
|
6
|
-
sortedBy: undefined,
|
|
7
|
-
sortedDirection: undefined,
|
|
8
|
-
defaultSortDirection: 'asc',
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
4
|
const VALID_SORT_DIRECTIONS = {
|
|
13
5
|
asc: true,
|
|
14
6
|
desc: true,
|
|
15
7
|
};
|
|
16
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the supplied sort direction is valid.
|
|
11
|
+
* Refer to `VALID_SORT_DIRECTIONS` for valid solid directions.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} value The sort direction to validate
|
|
14
|
+
* @return {boolean} Whether the supplied sort direction is valid
|
|
15
|
+
*/
|
|
17
16
|
export function isValidSortDirection(value) {
|
|
18
17
|
return !!VALID_SORT_DIRECTIONS[value];
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Gets the default sort direction. When clicking on a header to sort,
|
|
22
|
+
* the default sort direction is applied first. Clicking again reverses it
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} state The current datatable state
|
|
25
|
+
* @return {string} The default sort direction
|
|
26
|
+
*/
|
|
27
|
+
export function getDefaultSortDirection(state) {
|
|
28
|
+
return state.defaultSortDirection;
|
|
23
29
|
}
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Sets the default sort direction. When clicking on a header to sort,
|
|
33
|
+
* the default sort direction is applied first. Clicking again reverses it
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} state The current datatable state
|
|
36
|
+
* @param {string} value The value to update the default sort direction to
|
|
37
|
+
*/
|
|
38
|
+
export function setDefaultSortDirection(state, value) {
|
|
39
|
+
assert(
|
|
40
|
+
isValidSortDirection(value),
|
|
41
|
+
`The "defaultSortDirection" value passed into lightning:datatable
|
|
42
|
+
is incorrect, "defaultSortDirection" value should be one of
|
|
43
|
+
${Object.keys(VALID_SORT_DIRECTIONS).join()}.`
|
|
44
|
+
);
|
|
45
|
+
state.defaultSortDirection = isValidSortDirection(value)
|
|
46
|
+
? value
|
|
47
|
+
: getDefaultSortDirection(state);
|
|
31
48
|
}
|
|
32
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Gets the current sort direction
|
|
52
|
+
*
|
|
53
|
+
* @param {Object} state The current datatable state
|
|
54
|
+
* @return {string} The current sort direction
|
|
55
|
+
*/
|
|
33
56
|
export function getSortedDirection(state) {
|
|
34
57
|
return state.sortedDirection;
|
|
35
58
|
}
|
|
36
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Sets the current sort direction.
|
|
62
|
+
* In the case an invalid sort direction is provided, throw
|
|
63
|
+
* an error providing resolution information. In an error case,
|
|
64
|
+
* `sortedDirection` will be `undefined`
|
|
65
|
+
*
|
|
66
|
+
* @param {Object} state The current datatable state
|
|
67
|
+
* @param {string} value The value to update the sort direction to
|
|
68
|
+
*/
|
|
37
69
|
export function setSortedDirection(state, value) {
|
|
38
70
|
assert(
|
|
39
71
|
isValidSortDirection(value),
|
|
@@ -44,27 +76,50 @@ export function setSortedDirection(state, value) {
|
|
|
44
76
|
state.sortedDirection = isValidSortDirection(value) ? value : undefined;
|
|
45
77
|
}
|
|
46
78
|
|
|
47
|
-
|
|
48
|
-
|
|
79
|
+
/**
|
|
80
|
+
* Gets the current sort value. The value will match the name
|
|
81
|
+
* of a given column in the datatable
|
|
82
|
+
*
|
|
83
|
+
* @param {Object} state The current datatable state
|
|
84
|
+
* @return {string} The current sort value
|
|
85
|
+
*/
|
|
86
|
+
export function getSortedBy(state) {
|
|
87
|
+
return state.sortedBy;
|
|
49
88
|
}
|
|
50
89
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Sets the current sort value. The value should match the name
|
|
92
|
+
* of a given column in the datatable. In the case that a
|
|
93
|
+
* non-string value is provided, the sort value with fallback
|
|
94
|
+
* to `undefined`
|
|
95
|
+
*
|
|
96
|
+
* @param {Object} state The current datatable state
|
|
97
|
+
* @param {string} value The value to update the sort state to
|
|
98
|
+
*/
|
|
99
|
+
export function setSortedBy(state, value) {
|
|
100
|
+
if (typeof value === 'string') {
|
|
101
|
+
state.sortedBy = value;
|
|
102
|
+
} else {
|
|
103
|
+
state.sortedBy = undefined;
|
|
104
|
+
}
|
|
61
105
|
}
|
|
62
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Applies sorting to each datatable column
|
|
109
|
+
*
|
|
110
|
+
* @param {Object} state The current datatable state
|
|
111
|
+
*/
|
|
63
112
|
export function updateSorting(state) {
|
|
64
113
|
const columns = state.columns;
|
|
65
114
|
columns.forEach((column) => updateColumnSortingState(column, state));
|
|
66
115
|
}
|
|
67
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Applies sorting to a datatable column
|
|
119
|
+
*
|
|
120
|
+
* @param {Object} column The datatable column name to sort
|
|
121
|
+
* @param {Object} state The current datatable state
|
|
122
|
+
*/
|
|
68
123
|
export function updateColumnSortingState(column, state) {
|
|
69
124
|
const { sortedBy, sortedDirection, defaultSortDirection } = state;
|
|
70
125
|
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This function returns the initial state of the datatable.
|
|
3
|
+
* The state object is further manipulated while it is passed around by datatable
|
|
4
|
+
*
|
|
5
|
+
* TODO: Check to see if there are other items that need to be added to the default state
|
|
6
|
+
* @returns {Object} - intial state of the datatable
|
|
7
|
+
*/
|
|
3
8
|
export const getDefaultState = function () {
|
|
4
9
|
return {
|
|
5
10
|
// columns
|
|
6
11
|
columns: [],
|
|
12
|
+
hideCheckboxColumn: false,
|
|
7
13
|
|
|
8
14
|
// rows
|
|
9
15
|
data: [],
|
|
@@ -16,6 +22,7 @@ export const getDefaultState = function () {
|
|
|
16
22
|
maxRowSelection: undefined,
|
|
17
23
|
|
|
18
24
|
headerIndexes: {},
|
|
25
|
+
hideTableHeader: false,
|
|
19
26
|
|
|
20
27
|
// keyboard
|
|
21
28
|
keyboardMode: 'NAVIGATION',
|
|
@@ -28,6 +35,7 @@ export const getDefaultState = function () {
|
|
|
28
35
|
|
|
29
36
|
// header actions
|
|
30
37
|
wrapText: {},
|
|
38
|
+
wrapTextMaxLines: undefined,
|
|
31
39
|
|
|
32
40
|
// sort
|
|
33
41
|
sortedBy: undefined,
|
|
@@ -38,20 +46,17 @@ export const getDefaultState = function () {
|
|
|
38
46
|
showRowNumberColumn: false,
|
|
39
47
|
rowNumberOffset: 0,
|
|
40
48
|
|
|
41
|
-
// resizer
|
|
42
|
-
resizeColumnDisabled: false,
|
|
43
|
-
resizeStep: 10,
|
|
44
|
-
columnWidths: [],
|
|
45
|
-
tableWidth: 0,
|
|
46
|
-
minColumnWidth: 50,
|
|
47
|
-
maxColumnWidth: 1000,
|
|
48
|
-
columnWidthsMode: 'fixed',
|
|
49
|
-
|
|
50
49
|
// infinite loading
|
|
51
50
|
enableInfiniteLoading: false,
|
|
52
51
|
loadMoreOffset: 20,
|
|
53
52
|
isLoading: false,
|
|
54
53
|
|
|
54
|
+
// table render mode
|
|
55
|
+
renderModeRoleBased: false,
|
|
56
|
+
|
|
57
|
+
// viewport rendering
|
|
58
|
+
enableViewportRendering: undefined,
|
|
59
|
+
|
|
55
60
|
// inline edit
|
|
56
61
|
inlineEdit: {
|
|
57
62
|
dirtyValues: {},
|
|
@@ -62,22 +67,5 @@ export const getDefaultState = function () {
|
|
|
62
67
|
rows: {},
|
|
63
68
|
table: {},
|
|
64
69
|
},
|
|
65
|
-
|
|
66
|
-
hideTableHeader: false,
|
|
67
|
-
wrapTextMaxLines: undefined,
|
|
68
70
|
};
|
|
69
71
|
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* It generate headerIndexes based in the current metadata
|
|
73
|
-
* headerIndexes represent the position of the header(column)
|
|
74
|
-
* based on the unique colKeyValue
|
|
75
|
-
* @param {object} columns - the current normalized column metadata
|
|
76
|
-
* @returns {object} headerIndexes e.g. { 'name-text' 0, 'amount-number': 1 }
|
|
77
|
-
*/
|
|
78
|
-
export const generateHeaderIndexes = function (columns) {
|
|
79
|
-
return columns.reduce((prev, col, index) => {
|
|
80
|
-
prev[generateColKeyValue(col, index)] = index;
|
|
81
|
-
return prev;
|
|
82
|
-
}, {});
|
|
83
|
-
};
|