lightning-base-components 1.14.3-alpha → 1.15.1-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 +37 -4
- package/package.json +11 -4
- package/scopedImports/@salesforce-internal-core.appVersion.js +1 -1
- package/scopedImports/@salesforce-label-LightningModalBase.cancelandclose.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressBar.progressBar.js +1 -0
- package/src/lightning/alert/__docs__/alert.md +101 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/alert/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/alert/alert.html +3 -0
- package/src/lightning/alert/alert.js +78 -0
- package/src/lightning/alert/alert.js-meta.xml +6 -0
- package/src/lightning/ariaObserver/__component__/ariaObserver.spec.js +9 -0
- package/src/lightning/ariaObserver/ariaObserver.js +24 -35
- package/src/lightning/baseFormattedText/baseFormattedText.html +6 -1
- package/src/lightning/baseFormattedText/baseFormattedText.js +5 -0
- package/src/lightning/button/__wdio__/utam/utam.html +3 -0
- package/src/lightning/button/__wdio__/utam/utam.js +3 -0
- package/src/lightning/button/__wdio__/utam/utam.spec.js +20 -0
- package/src/lightning/buttonMenu/buttonMenu.js +12 -0
- package/src/lightning/confirm/__docs__/confirm.md +100 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/confirm/__examples__disabled/basic/basic.js +14 -0
- package/src/lightning/confirm/confirm.html +3 -0
- package/src/lightning/confirm/confirm.js +80 -0
- package/src/lightning/confirm/confirm.js-meta.xml +6 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/fetchDataHelper.js +21 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.html +13 -0
- package/src/lightning/datatable/__examples__/withInfiniteLoading/withInfiniteLoading.js +42 -0
- package/src/lightning/datatable/__wdio__/utam/utam.html +17 -0
- package/src/lightning/datatable/__wdio__/utam/utam.js +91 -0
- package/src/lightning/datatable/__wdio__/utam/utam.spec.js +189 -0
- package/src/lightning/datatable/autoWidthStrategy.js +170 -61
- package/src/lightning/datatable/{resizer.js → columnResizer.js} +0 -0
- package/src/lightning/datatable/columnWidthManager.js +226 -44
- package/src/lightning/datatable/columns.js +166 -71
- package/src/lightning/datatable/datatable.js +136 -60
- package/src/lightning/datatable/fixedWidthStrategy.js +43 -8
- package/src/lightning/datatable/headerActions.js +2 -2
- package/src/lightning/datatable/infiniteLoading.js +100 -28
- package/src/lightning/datatable/inlineEdit.js +21 -30
- package/src/lightning/datatable/keyboard.js +166 -131
- package/src/lightning/datatable/renderManager.js +117 -122
- package/src/lightning/datatable/{datatableResizeObserver.js → resizeObserver.js} +46 -29
- package/src/lightning/datatable/resizeSensor.js +19 -3
- package/src/lightning/datatable/rowSelection.js +1 -1
- package/src/lightning/datatable/rowSelectionShared.js +33 -20
- package/src/lightning/datatable/rows.js +9 -8
- package/src/lightning/datatable/sort.js +8 -8
- package/src/lightning/datatable/state.js +14 -2
- package/src/lightning/datatable/templates/div/div.html +133 -119
- package/src/lightning/datatable/templates/table/table.html +10 -2
- package/src/lightning/datatable/tree.js +25 -0
- package/src/lightning/datatable/types.js +77 -9
- package/src/lightning/datatable/utils.js +51 -24
- package/src/lightning/datatable/virtualization.js +319 -0
- package/src/lightning/datatable/widthManagerShared.js +27 -3
- package/src/lightning/datatable/wrapText.js +115 -48
- package/src/lightning/datepicker/__perf__DISABLED/datepickerWithCalendarOpen.perf.js +55 -0
- package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +36 -3
- package/src/lightning/formattedDateTime/__examples__/datetime/datetime.html +2 -2
- package/src/lightning/formattedDateTime/__examples__/datetime/datetime.js +3 -1
- package/src/lightning/formattedDateTime/__examples__/time/time.html +1 -1
- package/src/lightning/formattedDateTime/__examples__/time/time.js +3 -1
- package/src/lightning/formattedDateTime/formattedDateTime.js +1 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplates/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplates/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/templates.js +8 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandard/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/dashboard_component.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/standard/travel_mode.html +2 -2
- package/src/lightning/iconSvgTemplatesStandardRtl/buildTemplates/templates.js +4 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtility/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/templates.js +5 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/data_model.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product.html +1 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/serialized_product_transaction.html +2 -1
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/slack.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/tableau.html +7 -0
- package/src/lightning/iconSvgTemplatesUtilityRtl/buildTemplates/utility/video_off.html +7 -0
- package/src/lightning/input/__docs__/input.md +2 -0
- package/src/lightning/input/input.html +2 -5
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.css +494 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.html +63 -0
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js +200 -0
- package/src/lightning/menuItem/menuItem.js +4 -1
- package/src/lightning/modalBase/modalBase.css +20 -0
- package/src/lightning/modalBase/modalBase.html +54 -0
- package/src/lightning/modalBase/modalBase.js +1039 -0
- package/src/lightning/overlay/__docs__/overlay.md +90 -0
- package/src/lightning/overlay/__examples__/alert/alert.html +27 -0
- package/src/lightning/overlay/__examples__/alert/alert.js +33 -0
- package/src/lightning/overlay/__examples__/basic/basic.css +7 -0
- package/src/lightning/overlay/__examples__/basic/basic.html +18 -0
- package/src/lightning/overlay/__examples__/basic/basic.js +61 -0
- package/src/lightning/overlay/__examples__/demo/demo.html +29 -0
- package/src/lightning/overlay/__examples__/demo/demo.js +40 -0
- package/src/lightning/overlay/__examples__/panel/panel.html +17 -0
- package/src/lightning/overlay/__examples__/panel/panel.js +21 -0
- package/src/lightning/overlay/overlay.html +3 -0
- package/src/lightning/overlay/overlay.js +45 -0
- package/src/lightning/overlayContainer/__docs__/overlayContainer.md +0 -0
- package/src/lightning/overlayContainer/overlayContainer.html +3 -0
- package/src/lightning/overlayContainer/overlayContainer.js +138 -0
- package/src/lightning/overlayManager/overlayManager.js +54 -0
- package/src/lightning/overlayUtils/overlayUtils.js +17 -0
- package/src/lightning/progressBar/progressBar.html +2 -1
- package/src/lightning/progressBar/progressBar.js +18 -1
- package/src/lightning/prompt/__docs__/prompt.md +102 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.css +7 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.html +8 -0
- package/src/lightning/prompt/__examples__disabled/basic/basic.js +15 -0
- package/src/lightning/prompt/prompt.css +81 -0
- package/src/lightning/prompt/prompt.html +8 -0
- package/src/lightning/prompt/prompt.js +92 -0
- package/src/lightning/prompt/prompt.js-meta.xml +6 -0
- package/src/lightning/spinner/spinner.html +1 -1
- package/src/lightning/spinner/spinner.js +12 -0
- package/src/lightning/utilsPrivate/phonify.js +1 -1
- package/scopedImports/@salesforce-label-LightningModalBase.close.js +0 -1
|
@@ -13,33 +13,62 @@ const i18n = {
|
|
|
13
13
|
rowActionsDefaultAriaLabel,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
export const SELECTABLE_ROW_CHECKBOX = 'SELECTABLE_CHECKBOX';
|
|
17
|
+
|
|
18
|
+
const SELECTABLE_COLUMN = {
|
|
19
|
+
type: SELECTABLE_ROW_CHECKBOX,
|
|
20
|
+
fixedWidth: 32,
|
|
21
|
+
tabIndex: -1,
|
|
22
|
+
internal: true,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Returns the columns default state.
|
|
27
|
+
*
|
|
28
|
+
* @returns {Object} The default column state.
|
|
29
|
+
*/
|
|
16
30
|
export function getColumnsDefaultState() {
|
|
17
31
|
return {
|
|
18
32
|
columns: [],
|
|
19
33
|
};
|
|
20
34
|
}
|
|
21
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether or not the datatable has columns.
|
|
38
|
+
*
|
|
39
|
+
* @param {Object} state The datatable's state.
|
|
40
|
+
* @returns {Boolean} Whether the datatable has columns.
|
|
41
|
+
*/
|
|
22
42
|
export function hasColumns(state) {
|
|
23
43
|
return getColumns(state).length > 0;
|
|
24
44
|
}
|
|
25
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Returns whether or not the column has been specified by the customer.
|
|
48
|
+
*
|
|
49
|
+
* @param {Object} column The column definition object.
|
|
50
|
+
* @returns {Boolean} Whether the column is customer defined or not.
|
|
51
|
+
*/
|
|
26
52
|
export function isCustomerColumn(column) {
|
|
27
53
|
return column.internal !== true;
|
|
28
54
|
}
|
|
29
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Returns the datatable's columns from state.
|
|
58
|
+
*
|
|
59
|
+
* @param {Object} state The datatable's state.
|
|
60
|
+
* @returns {Array} The datatable's columns definition.
|
|
61
|
+
*/
|
|
30
62
|
export function getColumns(state) {
|
|
31
63
|
return state.columns;
|
|
32
64
|
}
|
|
33
65
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
internal: true,
|
|
41
|
-
};
|
|
42
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Returns whether any of the datatable's columns are editable.
|
|
68
|
+
*
|
|
69
|
+
* @param {Array} columns The datatable's column definition.
|
|
70
|
+
* @returns {Boolean} Whether any of the columns are editable.
|
|
71
|
+
*/
|
|
43
72
|
export function hasEditableColumn(columns) {
|
|
44
73
|
return columns.some((column) => column.editable);
|
|
45
74
|
}
|
|
@@ -50,8 +79,8 @@ export function hasEditableColumn(columns) {
|
|
|
50
79
|
* that are present in both the input and output array, the relative ordering between
|
|
51
80
|
* them that existed in the input array is maintained in the output array.
|
|
52
81
|
*
|
|
53
|
-
* @param {Array} columns
|
|
54
|
-
*
|
|
82
|
+
* @param {Array} columns The datatable's column definition. Must be truthy and must be
|
|
83
|
+
* filled with truthy column definition objects.
|
|
55
84
|
*/
|
|
56
85
|
export function getEditableColumns(columns) {
|
|
57
86
|
return columns.filter((column) => column.editable);
|
|
@@ -64,8 +93,8 @@ export function getEditableColumns(columns) {
|
|
|
64
93
|
* the invocation of this function results in a no-op because we instead rely on later
|
|
65
94
|
* row level checks to determine cell editability.
|
|
66
95
|
*
|
|
67
|
-
* @param {Object} column column
|
|
68
|
-
* @param {Object} types
|
|
96
|
+
* @param {Object} column The column definition object.
|
|
97
|
+
* @param {Object} types The DatatableTypes object.
|
|
69
98
|
*/
|
|
70
99
|
export function normalizeEditable(column, types) {
|
|
71
100
|
if (types.isEditableType(column.type)) {
|
|
@@ -81,10 +110,24 @@ export function normalizeEditable(column, types) {
|
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Steps through and corrects column definitions inconsistencies.
|
|
115
|
+
*
|
|
116
|
+
* For customer-specified columns, we verify all parameters are valid and set
|
|
117
|
+
* how we would expect them to prevent errors from bubbling up.
|
|
118
|
+
* See `normalizeColumnDataType`, `normalizeEditable`.
|
|
119
|
+
*
|
|
120
|
+
* For tree-types, we verify all sub-type attributes are within our allowed
|
|
121
|
+
* parameters. See `getNormalizedSubTypeAttribute`.
|
|
122
|
+
*
|
|
123
|
+
* @param {Object} state The datatable state.
|
|
124
|
+
* @param {Array} columns The datatable's column definitions.
|
|
125
|
+
* @param {Object} types The type handling factory.
|
|
126
|
+
*/
|
|
84
127
|
export function normalizeColumns(state, columns, types) {
|
|
85
128
|
if (columns.length !== 0) {
|
|
86
129
|
let firstColumnForReaders = 0;
|
|
87
|
-
//
|
|
130
|
+
// Workaround: https://git.soma.salesforce.com/raptor/raptor/issues/763
|
|
88
131
|
const normalizedColumns = Object.assign([], columns);
|
|
89
132
|
|
|
90
133
|
if (!state.hideCheckboxColumn) {
|
|
@@ -100,7 +143,7 @@ export function normalizeColumns(state, columns, types) {
|
|
|
100
143
|
|
|
101
144
|
const columnKeyMap = {};
|
|
102
145
|
state.columns = normalizedColumns.map((column, index) => {
|
|
103
|
-
// Verify columnKey is unique
|
|
146
|
+
// Verify `columnKey` is unique
|
|
104
147
|
const columnKey = column.columnKey;
|
|
105
148
|
if (columnKey && columnKeyMap[columnKey]) {
|
|
106
149
|
console.error(
|
|
@@ -115,7 +158,8 @@ export function normalizeColumns(state, columns, types) {
|
|
|
115
158
|
);
|
|
116
159
|
normalizedColumn.ariaLabel =
|
|
117
160
|
normalizedColumn.label || normalizedColumn.ariaLabel || null;
|
|
118
|
-
|
|
161
|
+
|
|
162
|
+
// `customType` attribute is needed to render default iedit component
|
|
119
163
|
normalizedColumn.editableCustomType =
|
|
120
164
|
types.isStandardCellLayoutForCustomType(normalizedColumn.type);
|
|
121
165
|
|
|
@@ -131,6 +175,7 @@ export function normalizeColumns(state, columns, types) {
|
|
|
131
175
|
normalizedColumn.typeAttributes
|
|
132
176
|
);
|
|
133
177
|
}
|
|
178
|
+
|
|
134
179
|
return Object.assign(normalizedColumn, {
|
|
135
180
|
tabIndex: -1,
|
|
136
181
|
colKeyValue: generateColKeyValue(normalizedColumn, index),
|
|
@@ -142,17 +187,12 @@ export function normalizeColumns(state, columns, types) {
|
|
|
142
187
|
}
|
|
143
188
|
}
|
|
144
189
|
|
|
145
|
-
function normalizeColumnDataType(column, types) {
|
|
146
|
-
if (!types.isValidType(column.type)) {
|
|
147
|
-
column.type = getRegularColumnDefaults().type;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
190
|
/**
|
|
152
191
|
* Normalizes the subType and subTypeAttributes in the typeAttributes.
|
|
153
|
-
*
|
|
154
|
-
* @param {
|
|
155
|
-
* @
|
|
192
|
+
*
|
|
193
|
+
* @param {String} type The type of this column
|
|
194
|
+
* @param {Object} typeAttributes The type attributes of the column
|
|
195
|
+
* @returns {Object} A new typeAttributes object with the sybtype and subTypeAttributes normalized.
|
|
156
196
|
*/
|
|
157
197
|
export function getNormalizedSubTypeAttribute(type, typeAttributes) {
|
|
158
198
|
const typeAttributesOverrides = {};
|
|
@@ -166,42 +206,12 @@ export function getNormalizedSubTypeAttribute(type, typeAttributes) {
|
|
|
166
206
|
return Object.assign({}, typeAttributes, typeAttributesOverrides);
|
|
167
207
|
}
|
|
168
208
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function getActionColumnDefaults() {
|
|
178
|
-
return {
|
|
179
|
-
fixedWidth: 50,
|
|
180
|
-
resizable: false,
|
|
181
|
-
ariaLabel: i18n.rowActionsDefaultAriaLabel,
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
function getTreeColumnDefaults() {
|
|
186
|
-
return {
|
|
187
|
-
type: 'tree',
|
|
188
|
-
subType: 'text',
|
|
189
|
-
typeAttributes: {},
|
|
190
|
-
cellAttributes: {},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function getColumnDefaults(column) {
|
|
195
|
-
switch (column.type) {
|
|
196
|
-
case 'action':
|
|
197
|
-
return getActionColumnDefaults();
|
|
198
|
-
case 'tree':
|
|
199
|
-
return getTreeColumnDefaults();
|
|
200
|
-
default:
|
|
201
|
-
return getRegularColumnDefaults();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Retrieves the type attributes for a given column.
|
|
211
|
+
*
|
|
212
|
+
* @param {Object} column The column definition object.
|
|
213
|
+
* @returns Type attributes for the given column, if they exist.
|
|
214
|
+
*/
|
|
205
215
|
export function getTypeAttributesValues(column) {
|
|
206
216
|
if (isObjectLike(column.typeAttributes)) {
|
|
207
217
|
return column.typeAttributes;
|
|
@@ -209,6 +219,12 @@ export function getTypeAttributesValues(column) {
|
|
|
209
219
|
return {};
|
|
210
220
|
}
|
|
211
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Retrieves the sub-type attributes for a given column.
|
|
224
|
+
*
|
|
225
|
+
* @param {Object} column The column definition object.
|
|
226
|
+
* @returns {Object} Sub-type attributes for the given column, if they exist.
|
|
227
|
+
*/
|
|
212
228
|
export function getSubTypeAttributesValues(column) {
|
|
213
229
|
if (isObjectLike(column.typeAttributes.subTypeAttributes)) {
|
|
214
230
|
return column.typeAttributes.subTypeAttributes;
|
|
@@ -216,6 +232,12 @@ export function getSubTypeAttributesValues(column) {
|
|
|
216
232
|
return {};
|
|
217
233
|
}
|
|
218
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves the cell attributes for a given column.
|
|
237
|
+
*
|
|
238
|
+
* @param {Object} column The column definition object.
|
|
239
|
+
* @returns {Object} Cell attributes for the given column, if they exist.
|
|
240
|
+
*/
|
|
219
241
|
export function getCellAttributesValues(column) {
|
|
220
242
|
if (isObjectLike(column.cellAttributes)) {
|
|
221
243
|
return column.cellAttributes;
|
|
@@ -226,9 +248,9 @@ export function getCellAttributesValues(column) {
|
|
|
226
248
|
/**
|
|
227
249
|
* Generates a unique column key value.
|
|
228
250
|
*
|
|
229
|
-
* @param {
|
|
230
|
-
* @param {
|
|
231
|
-
* @returns {
|
|
251
|
+
* @param {Object} columnMetadata The object for an specific column metadata
|
|
252
|
+
* @param {Integer} index Optionally, the index of the column.
|
|
253
|
+
* @returns {String} It generates the column key value based on the column field name and type.
|
|
232
254
|
*/
|
|
233
255
|
export function generateColKeyValue(columnMetadata, index) {
|
|
234
256
|
const { columnKey, fieldName, type } = columnMetadata;
|
|
@@ -239,9 +261,10 @@ export function generateColKeyValue(columnMetadata, index) {
|
|
|
239
261
|
/**
|
|
240
262
|
* Return the index in dt.columns (user definition) related to colKeyValue.
|
|
241
263
|
* -1 if no column with that key exist or if its internal.
|
|
264
|
+
*
|
|
242
265
|
* @param {Object} state The datatable state
|
|
243
266
|
* @param {String} colKeyValue The generated key for the column
|
|
244
|
-
* @
|
|
267
|
+
* @returns {Number} The index in `dt.columns`. -1 if not found or if its internal.
|
|
245
268
|
*/
|
|
246
269
|
export function getUserColumnIndex(state, colKeyValue) {
|
|
247
270
|
const stateColumnIndex = getStateColumnIndex(state, colKeyValue);
|
|
@@ -267,8 +290,8 @@ export function getUserColumnIndex(state, colKeyValue) {
|
|
|
267
290
|
*
|
|
268
291
|
* These indexes are set in the state object - `state.headerIndexes`
|
|
269
292
|
*
|
|
270
|
-
* @param {
|
|
271
|
-
* @returns {
|
|
293
|
+
* @param {Object} columns The current normalized column metadata
|
|
294
|
+
* @returns {Object} headerIndexes e.g. { 'name-text': 0, 'amount-number': 1 }
|
|
272
295
|
*/
|
|
273
296
|
export const generateHeaderIndexes = function (columns) {
|
|
274
297
|
return columns.reduce((prev, col, index) => {
|
|
@@ -282,17 +305,18 @@ export const generateHeaderIndexes = function (columns) {
|
|
|
282
305
|
*
|
|
283
306
|
* @param {Object} state The datatable state
|
|
284
307
|
* @param {String} colKeyValue The generated key for the column
|
|
285
|
-
* @
|
|
308
|
+
* @returns {Number} The index in state.columns
|
|
286
309
|
*/
|
|
287
310
|
export function getStateColumnIndex(state, colKeyValue) {
|
|
288
311
|
return state.headerIndexes[colKeyValue];
|
|
289
312
|
}
|
|
290
313
|
|
|
291
314
|
/**
|
|
315
|
+
* Retrieves a column index number by its key.
|
|
292
316
|
*
|
|
293
|
-
* @param {Object} state
|
|
294
|
-
* @param {String} key
|
|
295
|
-
* @returns {
|
|
317
|
+
* @param {Object} state The datatable state
|
|
318
|
+
* @param {String} key The key of the column. Defaults to field name if 'columnKey' is not provided.
|
|
319
|
+
* @returns {Number} The index in state.columns, -1 if it does not exist
|
|
296
320
|
*/
|
|
297
321
|
export function getColumnIndexByColumnKey(state, key) {
|
|
298
322
|
let i = 0;
|
|
@@ -307,3 +331,74 @@ export function getColumnIndexByColumnKey(state, key) {
|
|
|
307
331
|
|
|
308
332
|
return existFieldName ? i : -1;
|
|
309
333
|
}
|
|
334
|
+
|
|
335
|
+
/************************** PRIVATE METHODS ***************************/
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* If the specified column type is not supported, resets it to default.
|
|
339
|
+
*
|
|
340
|
+
* @param {Object} column The column definition object.
|
|
341
|
+
* @param {Object} types The type handling factory.
|
|
342
|
+
*/
|
|
343
|
+
function normalizeColumnDataType(column, types) {
|
|
344
|
+
if (!types.isValidType(column.type)) {
|
|
345
|
+
column.type = getRegularColumnDefaults().type;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Returns the column defaults based on its type.
|
|
351
|
+
*
|
|
352
|
+
* @param {Object} column The column definition object.
|
|
353
|
+
* @returns {Object} The column defaults.
|
|
354
|
+
*/
|
|
355
|
+
function getColumnDefaults(column) {
|
|
356
|
+
switch (column.type) {
|
|
357
|
+
case 'action':
|
|
358
|
+
return getActionColumnDefaults();
|
|
359
|
+
case 'tree':
|
|
360
|
+
return getTreeColumnDefaults();
|
|
361
|
+
default:
|
|
362
|
+
return getRegularColumnDefaults();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Retrieves the defaults for regular columns.
|
|
368
|
+
*
|
|
369
|
+
* @returns {Object} Regular column defaults
|
|
370
|
+
*/
|
|
371
|
+
function getRegularColumnDefaults() {
|
|
372
|
+
return {
|
|
373
|
+
type: 'text',
|
|
374
|
+
typeAttributes: {},
|
|
375
|
+
cellAttributes: {},
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Retrieves the defaults for action columns.
|
|
381
|
+
*
|
|
382
|
+
* @returns {Object} Action column defaults
|
|
383
|
+
*/
|
|
384
|
+
function getActionColumnDefaults() {
|
|
385
|
+
return {
|
|
386
|
+
fixedWidth: 50,
|
|
387
|
+
resizable: false,
|
|
388
|
+
ariaLabel: i18n.rowActionsDefaultAriaLabel,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Retrieves the defaults for tree columns.
|
|
394
|
+
*
|
|
395
|
+
* @returns {Object} Tree column defaults
|
|
396
|
+
*/
|
|
397
|
+
function getTreeColumnDefaults() {
|
|
398
|
+
return {
|
|
399
|
+
type: 'tree',
|
|
400
|
+
subType: 'text',
|
|
401
|
+
typeAttributes: {},
|
|
402
|
+
cellAttributes: {},
|
|
403
|
+
};
|
|
404
|
+
}
|