lightning-base-components 1.21.3-alpha → 1.21.5-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/metadata/raptor.json +49 -0
- package/package.json +96 -21
- package/scopedImports/@salesforce-label-LightningDatatable.showActions.js +1 -1
- package/scopedImports/@salesforce-label-LightningForm.controllerFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsHeader.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.dependentFieldsListHeading.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.generalDependentFieldsMessage.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.learnMore.js +1 -0
- package/scopedImports/@salesforce-label-LightningForm.okButton.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.messageWhenSearchTermTooShort.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalCancel.js +1 -0
- package/scopedImports/@salesforce-label-LightningLookup.modalSelect.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.currentStage.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.errorStage.js +1 -0
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageComplete.js +1 -1
- package/scopedImports/@salesforce-label-LightningProgressIndicator.stageNotStarted.js +1 -1
- package/src/lightning/accordion/__docs__/accordion.md +0 -4
- package/src/lightning/accordionSection/__docs__/accordionSection.md +0 -4
- package/src/lightning/avatar/__docs__/avatar.md +0 -4
- package/src/lightning/avatar/avatar.html +1 -0
- package/src/lightning/badge/__docs__/badge.md +0 -4
- package/src/lightning/badge/badge.html +3 -3
- package/src/lightning/barcodeScanner/__docs__/barcodeScanner.md +0 -4
- package/src/lightning/baseCombobox/baseCombobox.html +4 -1
- package/src/lightning/baseCombobox/baseCombobox.js +5 -18
- package/src/lightning/baseComboboxItem/baseComboboxItem.js +6 -10
- package/src/lightning/button/__docs__/button.md +5 -8
- package/src/lightning/button/button.js +3 -4
- package/src/lightning/buttonGroup/__docs__/buttonGroup.md +0 -4
- package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -4
- package/src/lightning/buttonIcon/buttonIcon.html +1 -1
- package/src/lightning/buttonIcon/buttonIcon.js +18 -17
- package/src/lightning/buttonIconStateful/__docs__/buttonIconStateful.md +0 -4
- package/src/lightning/buttonMenu/__docs__/buttonMenu.md +0 -4
- package/src/lightning/buttonMenu/buttonMenu.css +5 -0
- package/src/lightning/buttonMenu/buttonMenu.js +2 -0
- package/src/lightning/buttonStateful/__docs__/buttonStateful.md +0 -4
- package/src/lightning/buttonStateful/buttonStateful.html +5 -3
- package/src/lightning/buttonStateful/buttonStateful.js +4 -0
- package/src/lightning/card/__docs__/card.md +0 -4
- package/src/lightning/card/card.js-meta.xml +3 -0
- package/src/lightning/carousel/__docs__/carousel.md +0 -4
- package/src/lightning/checkboxGroup/__docs__/checkboxGroup.md +0 -4
- package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
- package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
- package/src/lightning/combobox/__docs__/combobox.md +0 -4
- package/src/lightning/combobox/combobox.html +1 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.html +11 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/customComponentWrapper.js +25 -0
- package/src/lightning/datatable/__examples__disabled/customComponentWrapper/generateData.js +15 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/customInput.html +4 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js +17 -0
- package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/nestedSimpleComponentParent.html +7 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.html +9 -0
- package/src/lightning/datatable/__examples__disabled/simpleComponentNested/simpleComponentNested.js +6 -0
- package/src/lightning/datatable/autoWidthStrategy.js +8 -36
- package/src/lightning/datatable/columnResizer.js +51 -161
- package/src/lightning/datatable/columnWidthManager.js +25 -81
- package/src/lightning/datatable/columns.js +180 -302
- package/src/lightning/datatable/datatable.js +454 -441
- package/src/lightning/datatable/errors.js +17 -29
- package/src/lightning/datatable/fixedWidthStrategy.js +7 -22
- package/src/lightning/datatable/headerActions.js +8 -38
- package/src/lightning/datatable/indexes.js +42 -0
- package/src/lightning/datatable/infiniteLoading.js +16 -35
- package/src/lightning/datatable/inlineEdit.js +126 -156
- package/src/lightning/datatable/keyboard.js +226 -282
- package/src/lightning/datatable/renderManager.js +0 -4
- package/src/lightning/datatable/resizeObserver.js +4 -13
- package/src/lightning/datatable/rowLevelActions.js +2 -2
- package/src/lightning/datatable/rowNumber.js +21 -59
- package/src/lightning/datatable/rowSelection.js +95 -178
- package/src/lightning/datatable/rowSelectionShared.js +13 -27
- package/src/lightning/datatable/rows.js +171 -418
- package/src/lightning/datatable/sort.js +16 -75
- package/src/lightning/datatable/templates/div/div.html +12 -4
- package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +10 -16
- package/src/lightning/datatable/templates/table/table.html +15 -5
- package/src/lightning/datatable/tree.js +17 -35
- package/src/lightning/datatable/types.js +10 -31
- package/src/lightning/datatable/utils.js +48 -24
- package/src/lightning/datatable/virtualization.js +2 -5
- package/src/lightning/datatable/widthManagerShared.js +0 -20
- package/src/lightning/datatable/wrapText.js +29 -60
- package/src/lightning/dualListbox/__docs__/dualListbox.md +0 -4
- package/src/lightning/dualListbox/dualListbox.js +7 -8
- package/src/lightning/dynamicIcon/__docs__/dynamicIcon.md +0 -4
- package/src/lightning/formattedDateTime/__docs__/formattedDateTime.md +0 -4
- package/src/lightning/formattedLocation/__docs__/formattedLocation.md +0 -4
- package/src/lightning/formattedName/__docs__/formattedName.md +0 -4
- package/src/lightning/formattedName/formattedName.js +3 -2
- package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
- package/src/lightning/formattedNumber/__docs__/formattedNumber.md +0 -4
- package/src/lightning/formattedNumber/formattedNumber.js +3 -2
- package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
- package/src/lightning/formattedPhone/__docs__/formattedPhone.md +0 -4
- package/src/lightning/formattedRichText/richTextConfig.js +1 -0
- package/src/lightning/formattedText/__docs__/formattedText.md +0 -4
- package/src/lightning/formattedTime/__docs__/formattedTime.md +0 -4
- package/src/lightning/formattedUrl/__docs__/formattedUrl.md +0 -4
- package/src/lightning/helptext/helptext.css +7 -0
- package/src/lightning/helptext/helptext.js +3 -4
- package/src/lightning/icon/__docs__/icon.md +0 -4
- package/src/lightning/icon/icon.html +1 -1
- package/src/lightning/input/input.html +5 -0
- package/src/lightning/inputAddress/addressFormat.js +31 -4
- package/src/lightning/inputAddress/fieldsLayout.js +6 -0
- package/src/lightning/inputAddress/inputAddress.html +19 -1
- package/src/lightning/inputAddress/inputAddress.js +80 -3
- package/src/lightning/inputLocation/__docs__/inputLocation.md +0 -4
- package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
- package/src/lightning/layout/__docs__/layout.md +0 -4
- package/src/lightning/layoutItem/__docs__/layoutItem.md +0 -4
- package/src/lightning/lookupAddress/lookupAddress.html +6 -1
- package/src/lightning/lookupAddress/lookupAddress.js +25 -0
- package/src/lightning/menuItem/__docs__/menuItem.md +0 -4
- package/src/lightning/menuSubheader/menu-subheader.slds.css +1 -1
- package/src/lightning/modal/__docs__/modal.md +10 -1
- package/src/lightning/modal/__modalUtils__/modalContainerTestConstants.js +3 -7
- package/src/lightning/modal/__modalUtils__/modalContainerTestMethods.js +39 -133
- package/src/lightning/modal/__modalUtils__/modalContainerTestMockData.js +1 -1
- package/src/lightning/modal/modal.js +1 -1
- package/src/lightning/modalBase/modalBase.html +15 -10
- package/src/lightning/modalBase/modalBase.js +132 -147
- package/src/lightning/modalBody/modalBody.css +6 -0
- package/src/lightning/modalHeader/modalHeader.html +16 -4
- package/src/lightning/modalHeader/modalHeader.js +61 -14
- package/src/lightning/pill/__docs__/pill.md +0 -4
- package/src/lightning/pill/link.html +1 -0
- package/src/lightning/pill/plain.html +1 -0
- package/src/lightning/pill/plainLink.html +1 -0
- package/src/lightning/pillContainer/__docs__/pillContainer.md +0 -4
- package/src/lightning/primitiveBubble/primitiveBubble.js +42 -0
- package/src/lightning/primitiveDatatableCell/primitiveDatatableCell.js +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.html +1 -1
- package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +13 -0
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.html +19 -6
- package/src/lightning/primitiveHeaderFactory/sortableHeader.html +3 -1
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.css +11 -0
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.html +2 -1
- package/src/lightning/primitiveResizeHandler/primitiveResizeHandler.js +1 -0
- package/src/lightning/progressStep/base.html +5 -6
- package/src/lightning/progressStep/progressStep.js +14 -9
- package/src/lightning/prompt/__docs__/prompt.md +1 -1
- package/src/lightning/radioGroup/__docs__/radioGroup.md +0 -4
- package/src/lightning/relativeDateTime/__docs__/relativeDateTime.md +0 -4
- package/src/lightning/shadowBaseClassPrivate/shadowBaseClassPrivate.js +0 -2
- package/src/lightning/sldsCommon/sldsCommon.css +134 -98
- package/src/lightning/sldsUtilsAlignment/sldsUtilsAlignment.css +1 -1
- package/src/lightning/sldsUtilsBox/sldsUtilsBox.css +14 -13
- package/src/lightning/sldsUtilsGrid/sldsUtilsGrid.css +95 -92
- package/src/lightning/sldsUtilsHyphenation/sldsUtilsHyphenation.css +1 -1
- package/src/lightning/sldsUtilsMargin/sldsUtilsMargin.css +77 -75
- package/src/lightning/sldsUtilsPadding/sldsUtilsPadding.css +73 -73
- package/src/lightning/sldsUtilsSizing/sldsUtilsSizing.css +552 -558
- package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +2 -2
- package/src/lightning/slider/__docs__/slider.md +0 -4
- package/src/lightning/spinner/__docs__/spinner.md +0 -4
- package/src/lightning/staticMap/staticMap.js +3 -2
- package/src/lightning/tab/__docs__/tab.md +0 -4
- package/src/lightning/tab/tab.js +6 -3
- package/src/lightning/tab/tab.js-meta.xml +3 -0
- package/src/lightning/tabBar/tabBar.js +10 -5
- package/src/lightning/tabset/__docs__/tabset.md +0 -4
- package/src/lightning/tabset/tabset.html +2 -0
- package/src/lightning/tabset/tabset.js-meta.xml +3 -0
- package/src/lightning/textarea/__docs__/textarea.md +0 -4
- package/src/lightning/textarea/textarea.js +6 -1
- package/src/lightning/tile/__docs__/tile.md +0 -4
- package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +24 -15
- package/src/lightning/tree/__docs__/tree.md +0 -4
- package/src/lightning/tree/tree.js +5 -1
- package/src/lightning/verticalNavigation/__docs__/verticalNavigation.md +0 -4
- package/src/lightning/verticalNavigation/vertical-navigation.slds.css +14 -0
- package/src/lightning/verticalNavigation/verticalNavigation.css +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.html +1 -1
- package/src/lightning/verticalNavigation/verticalNavigation.js +66 -28
- package/src/lightning/verticalNavigation/verticalNavigation.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/__docs__/verticalNavigationItem.md +0 -4
- package/src/lightning/verticalNavigationItem/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.css +2 -3
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js +29 -15
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.native.css +2 -0
- package/src/lightning/verticalNavigationItem/verticalNavigationItem.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemBadge/__docs__/verticalNavigationItemBadge.md +0 -4
- package/src/lightning/verticalNavigationItemBadge/badge.slds.css +76 -0
- package/src/lightning/verticalNavigationItemBadge/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.css +2 -3
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.html +1 -1
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js +28 -15
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationItemBadge/verticalNavigationItemBadge.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/__docs__/verticalNavigationItemIcon.md +0 -4
- package/src/lightning/verticalNavigationItemIcon/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.css +2 -3
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js +29 -15
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.native.css +3 -0
- package/src/lightning/verticalNavigationItemIcon/verticalNavigationItemIcon.lbc.synthetic.css +3 -0
- package/src/lightning/verticalNavigationOverflow/button.slds.css +503 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-item.slds.css +63 -0
- package/src/lightning/verticalNavigationOverflow/vertical-navigation-section.slds.css +17 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.css +2 -1
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.html +2 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js +18 -13
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.js-meta.xml +3 -0
- package/src/lightning/verticalNavigationOverflow/verticalNavigationOverflow.lbc.native.css +5 -0
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +14 -14
- package/src/lightning/verticalNavigationSection/verticalNavigationSection.js-meta.xml +3 -0
- package/src/lightning/datatable/inlineEditShared.js +0 -26
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatableWrapper/customDatatableWrapper.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeLink/customDatatypeLink.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeNumber/customDatatypeNumber.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customDatatypeTable.js +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customLink.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customName.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumber.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/customNumberEdit.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/deleteRow.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/iconPill.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customDatatypeTable/orderingButtons.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.html +0 -0
- /package/src/lightning/datatable/{__examples__ → __examples__disabled}/customNestedComponent/customNestedComponent.js +0 -0
|
@@ -1,127 +1,34 @@
|
|
|
1
|
+
import labelRowNumber from '@salesforce/label/LightningDatatable.rowNumber';
|
|
2
|
+
import rowActionsDefaultAriaLabel from '@salesforce/label/LightningDatatable.rowActionsDefaultAriaLabel';
|
|
1
3
|
import { normalizeBoolean } from 'lightning/utilsPrivate';
|
|
2
4
|
import { isObjectLike } from './utils';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
hasRowNumberColumn,
|
|
6
|
-
setShowRowNumberColumn,
|
|
7
|
-
} from './rowNumber';
|
|
8
|
-
import { isTreeType, isValidTypeForTree } from './types';
|
|
9
|
-
import { updateColumnSortingState } from './sort';
|
|
10
|
-
import rowActionsDefaultAriaLabel from '@salesforce/label/LightningDatatable.rowActionsDefaultAriaLabel';
|
|
5
|
+
import { ROW_NUMBER_INITIAL_WIDTH } from './rowNumber';
|
|
6
|
+
import { SELECTABLE_HEADER_TYPE } from './rowSelectionShared';
|
|
11
7
|
|
|
12
8
|
const i18n = {
|
|
13
9
|
rowActionsDefaultAriaLabel,
|
|
10
|
+
rowNumber: labelRowNumber,
|
|
14
11
|
};
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
const ROW_NUMBER_COLUMN = {
|
|
14
|
+
type: 'rowNumber',
|
|
15
|
+
ariaLabel: i18n.rowNumber,
|
|
16
|
+
initialWidth: ROW_NUMBER_INITIAL_WIDTH,
|
|
17
|
+
internal: true,
|
|
18
|
+
minWidth: 52,
|
|
19
|
+
maxWidth: 1000,
|
|
20
|
+
resizable: false,
|
|
21
|
+
sortable: false,
|
|
22
|
+
tabIndex: -1,
|
|
23
|
+
};
|
|
17
24
|
|
|
18
25
|
const SELECTABLE_COLUMN = {
|
|
19
|
-
type:
|
|
26
|
+
type: SELECTABLE_HEADER_TYPE,
|
|
20
27
|
fixedWidth: 32,
|
|
21
|
-
tabIndex: -1,
|
|
22
28
|
internal: true,
|
|
29
|
+
tabIndex: -1,
|
|
23
30
|
};
|
|
24
31
|
|
|
25
|
-
/**
|
|
26
|
-
* Returns the columns default state.
|
|
27
|
-
*
|
|
28
|
-
* @returns {Object} The default column state.
|
|
29
|
-
*/
|
|
30
|
-
export function getColumnsDefaultState() {
|
|
31
|
-
return {
|
|
32
|
-
columns: [],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
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
|
-
*/
|
|
42
|
-
export function hasColumns(state) {
|
|
43
|
-
return getColumns(state).length > 0;
|
|
44
|
-
}
|
|
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
|
-
*/
|
|
52
|
-
export function isCustomerColumn(column) {
|
|
53
|
-
return column.internal !== true;
|
|
54
|
-
}
|
|
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
|
-
*/
|
|
62
|
-
export function getColumns(state) {
|
|
63
|
-
return state.columns;
|
|
64
|
-
}
|
|
65
|
-
|
|
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
|
-
*/
|
|
72
|
-
export function hasEditableColumn(columns) {
|
|
73
|
-
const { length: colCount } = columns;
|
|
74
|
-
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
75
|
-
if (columns[colIndex].editable) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Given an array of column definitions, returns a filtered array containing only those
|
|
84
|
-
* elements from the original array that are editable. For any two columns, C_1 and C_2,
|
|
85
|
-
* that are present in both the input and output array, the relative ordering between
|
|
86
|
-
* them that existed in the input array is maintained in the output array.
|
|
87
|
-
*
|
|
88
|
-
* @param {Array} columns The datatable's column definition. Must be truthy and must be
|
|
89
|
-
* filled with truthy column definition objects.
|
|
90
|
-
*/
|
|
91
|
-
export function getEditableColumns(columns) {
|
|
92
|
-
const editableColumns = [];
|
|
93
|
-
for (let i = 0, { length } = columns; i < length; i += 1) {
|
|
94
|
-
const col = columns[i];
|
|
95
|
-
if (col.editable) {
|
|
96
|
-
editableColumns.push(col);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return editableColumns;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Normalizes the editable property of the column after checking whether the column type
|
|
104
|
-
* is a valid editable standard type or if it's a customType and uses standardCellLayout.
|
|
105
|
-
* If column.editable is associated with an object that also has a 'fieldName' key, then
|
|
106
|
-
* the invocation of this function results in a no-op because we instead rely on later
|
|
107
|
-
* row level checks to determine cell editability.
|
|
108
|
-
*
|
|
109
|
-
* @param {Object} column The column definition object.
|
|
110
|
-
* @param {Object} types The DatatableTypes object.
|
|
111
|
-
*/
|
|
112
|
-
export function normalizeEditable(column, types) {
|
|
113
|
-
if (types.isEditableType(column.type)) {
|
|
114
|
-
const { editable } = column;
|
|
115
|
-
if (!(editable && editable.fieldName)) {
|
|
116
|
-
column.editable = normalizeBoolean(editable);
|
|
117
|
-
}
|
|
118
|
-
column.editTemplate = types.getCustomTypeEditTemplate(column.type);
|
|
119
|
-
} else {
|
|
120
|
-
column.editable = false;
|
|
121
|
-
column.editTemplate = undefined;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
32
|
/**
|
|
126
33
|
* Steps through and corrects column definitions inconsistencies.
|
|
127
34
|
*
|
|
@@ -132,110 +39,179 @@ export function normalizeEditable(column, types) {
|
|
|
132
39
|
* For tree-types, we verify all sub-type attributes are within our allowed
|
|
133
40
|
* parameters. See `getNormalizedSubTypeAttribute`.
|
|
134
41
|
*
|
|
135
|
-
* @param {Object} state The datatable state
|
|
136
|
-
* @param {Array}
|
|
137
|
-
* @param {Object} types
|
|
42
|
+
* @param {Object} state - The datatable state
|
|
43
|
+
* @param {Array} rawColumns - The user provided column definitions to normalize
|
|
44
|
+
* @param {Object} types - The type handling factory
|
|
138
45
|
*/
|
|
139
|
-
export function normalizeColumns(state,
|
|
140
|
-
const { length: colCount } =
|
|
141
|
-
if (colCount
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
46
|
+
export function normalizeColumns(state, rawColumns, types) {
|
|
47
|
+
const { length: colCount } = rawColumns;
|
|
48
|
+
if (colCount === 0) {
|
|
49
|
+
// Tracked state change.
|
|
50
|
+
state.columns = [];
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let normColCount = colCount;
|
|
54
|
+
let { showRowNumberColumn } = state;
|
|
55
|
+
const notHideCheckboxColumn = !state.hideCheckboxColumn;
|
|
146
56
|
|
|
147
|
-
|
|
148
|
-
|
|
57
|
+
if (!showRowNumberColumn) {
|
|
58
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
59
|
+
if (rawColumns[colIndex].editable) {
|
|
60
|
+
showRowNumberColumn = true;
|
|
61
|
+
// Untracked state change.
|
|
62
|
+
state.showRowNumberColumn = true;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
149
65
|
}
|
|
66
|
+
}
|
|
67
|
+
if (showRowNumberColumn) {
|
|
68
|
+
normColCount += 1;
|
|
69
|
+
}
|
|
70
|
+
if (notHideCheckboxColumn) {
|
|
71
|
+
normColCount += 1;
|
|
72
|
+
}
|
|
73
|
+
const normalizedColumns = Array(normColCount);
|
|
74
|
+
|
|
75
|
+
// Tracked state change.
|
|
76
|
+
state.columns = normalizedColumns;
|
|
77
|
+
|
|
78
|
+
let firstColumnForReaders = 0;
|
|
79
|
+
if (showRowNumberColumn) {
|
|
80
|
+
normalizedColumns[firstColumnForReaders] = Object.assign(
|
|
81
|
+
{},
|
|
82
|
+
ROW_NUMBER_COLUMN
|
|
83
|
+
);
|
|
84
|
+
firstColumnForReaders += 1;
|
|
85
|
+
}
|
|
86
|
+
if (notHideCheckboxColumn) {
|
|
87
|
+
normalizedColumns[firstColumnForReaders] = Object.assign(
|
|
88
|
+
{},
|
|
89
|
+
SELECTABLE_COLUMN
|
|
90
|
+
);
|
|
91
|
+
firstColumnForReaders += 1;
|
|
92
|
+
}
|
|
93
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
94
|
+
normalizedColumns[colIndex + firstColumnForReaders] =
|
|
95
|
+
rawColumns[colIndex];
|
|
96
|
+
}
|
|
150
97
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
normColCount += 1;
|
|
154
|
-
}
|
|
155
|
-
const normalizedColumns = Array(normColCount);
|
|
98
|
+
const { defaultSortDirection, sortedBy, sortedDirection } = state;
|
|
99
|
+
const seenColumnKeys = new Set();
|
|
156
100
|
|
|
157
|
-
|
|
158
|
-
|
|
101
|
+
for (let colIndex = 0; colIndex < normColCount; colIndex += 1) {
|
|
102
|
+
const refCol = normalizedColumns[colIndex];
|
|
103
|
+
const { columnKey } = refCol;
|
|
159
104
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
105
|
+
// Verify `columnKey` is unique
|
|
106
|
+
if (columnKey && seenColumnKeys.has(columnKey)) {
|
|
107
|
+
console.error(
|
|
108
|
+
`The "columnKey" column property must be unique. Found a duplicate of columnKey "${columnKey}".`
|
|
164
109
|
);
|
|
165
|
-
firstColumnForReaders += 1;
|
|
166
|
-
}
|
|
167
|
-
if (showRowNumberColumn) {
|
|
168
|
-
normalizedColumns[firstColumnForReaders] = getRowNumberColumnDef();
|
|
169
|
-
firstColumnForReaders += 1;
|
|
170
110
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
111
|
+
seenColumnKeys.add(columnKey);
|
|
112
|
+
|
|
113
|
+
const { type: refColumnType } = refCol;
|
|
114
|
+
const colName = columnKey || refCol.fieldName;
|
|
115
|
+
|
|
116
|
+
// Normalize columns.
|
|
117
|
+
const normCol = {
|
|
118
|
+
ariaLabel: '',
|
|
119
|
+
cellAttributes: {},
|
|
120
|
+
resizable: true,
|
|
121
|
+
type: 'text',
|
|
122
|
+
typeAttributes: {},
|
|
123
|
+
subType: '',
|
|
124
|
+
};
|
|
125
|
+
if (refColumnType === 'action') {
|
|
126
|
+
normCol.ariaLabel = i18n.rowActionsDefaultAriaLabel;
|
|
127
|
+
normCol.fixedWidth = 50;
|
|
128
|
+
normCol.resizable = false;
|
|
129
|
+
} else if (refColumnType === 'tree') {
|
|
130
|
+
normCol.subType = 'text';
|
|
174
131
|
}
|
|
132
|
+
Object.assign(normCol, refCol);
|
|
175
133
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const { columnKey } = column;
|
|
180
|
-
|
|
181
|
-
// state.columns = normalizedColumns.map((column, index) => {
|
|
182
|
-
// Verify `columnKey` is unique
|
|
183
|
-
if (columnKey && seenColumnKeys.has(columnKey)) {
|
|
184
|
-
console.error(
|
|
185
|
-
`The "columnKey" column property must be unique. Found a duplicate of columnKey "${columnKey}".`
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
seenColumnKeys.add(columnKey);
|
|
134
|
+
// Store in caches early so data can be referenced by other methods
|
|
135
|
+
// during initialization.
|
|
136
|
+
normalizedColumns[colIndex] = normCol;
|
|
189
137
|
|
|
190
|
-
|
|
191
|
-
normalizedColumns[colIndex] = normCol;
|
|
192
|
-
normCol.ariaLabel = normCol.label || normCol.ariaLabel || null;
|
|
138
|
+
let { type: columnType } = normCol;
|
|
193
139
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
140
|
+
normCol.ariaLabel = normCol.label || normCol.ariaLabel || null;
|
|
141
|
+
// `customType` attribute is needed to render default inline edit component
|
|
142
|
+
normCol.editableCustomType =
|
|
143
|
+
types.isStandardCellLayoutForCustomType(columnType);
|
|
198
144
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
145
|
+
// normalize customer column
|
|
146
|
+
if (!normCol.internal) {
|
|
147
|
+
// normalize column dataType
|
|
148
|
+
if (!types.isValidType(columnType)) {
|
|
149
|
+
columnType = 'text';
|
|
150
|
+
normCol.type = columnType;
|
|
203
151
|
}
|
|
204
|
-
|
|
205
|
-
if (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
normCol.
|
|
209
|
-
|
|
152
|
+
// normalize editable
|
|
153
|
+
if (types.isEditableType(columnType)) {
|
|
154
|
+
const { editable } = normCol;
|
|
155
|
+
if (!(editable && editable.fieldName)) {
|
|
156
|
+
normCol.editable = normalizeBoolean(editable);
|
|
157
|
+
}
|
|
158
|
+
normCol.editTemplate =
|
|
159
|
+
types.getCustomTypeEditTemplate(columnType);
|
|
160
|
+
} else {
|
|
161
|
+
normCol.editable = false;
|
|
162
|
+
normCol.editTemplate = undefined;
|
|
210
163
|
}
|
|
164
|
+
// update column sorting state
|
|
165
|
+
const { sortable } = normCol;
|
|
166
|
+
if (sortable && colName === sortedBy) {
|
|
167
|
+
normCol.sorted = true;
|
|
168
|
+
normCol.sortAriaLabel =
|
|
169
|
+
sortedDirection === 'desc' ? 'descending' : 'ascending';
|
|
170
|
+
normCol.sortedDirection = sortedDirection;
|
|
171
|
+
} else {
|
|
172
|
+
normCol.sorted = false;
|
|
173
|
+
normCol.sortAriaLabel = sortable ? 'other' : null;
|
|
174
|
+
normCol.sortedDirection = defaultSortDirection;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
211
177
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
178
|
+
// Generate colKeyValue after normalizing customer column.
|
|
179
|
+
normCol.colKeyValue = generateColKeyValue(normCol, colIndex);
|
|
180
|
+
normCol.isScopeCol = colIndex === firstColumnForReaders;
|
|
181
|
+
normCol.isLastCol = colIndex === normColCount - 1;
|
|
182
|
+
normCol.tabIndex = -1;
|
|
183
|
+
|
|
184
|
+
// normalize tree column
|
|
185
|
+
if (normCol.type === 'tree') {
|
|
186
|
+
// normalized subType attributes
|
|
187
|
+
const { typeAttributes } = normCol;
|
|
188
|
+
const typeAttributesOverrides = {};
|
|
189
|
+
if (!types.isValidTypeForTree(typeAttributes.subType)) {
|
|
190
|
+
typeAttributesOverrides.subType = 'text';
|
|
191
|
+
}
|
|
192
|
+
if (!typeAttributes.subTypeAttributes) {
|
|
193
|
+
typeAttributesOverrides.subTypeAttributes = {};
|
|
194
|
+
}
|
|
195
|
+
normCol.typeAttributes = Object.assign(
|
|
196
|
+
{},
|
|
197
|
+
typeAttributes,
|
|
198
|
+
typeAttributesOverrides
|
|
199
|
+
);
|
|
216
200
|
}
|
|
217
|
-
} else {
|
|
218
|
-
state.columns = [];
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
201
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
202
|
+
// partially inline updateHeaderInternalActions from datatable/headerActions
|
|
203
|
+
const { actions } = normCol;
|
|
204
|
+
const isLastColumn = colIndex === normColCount - 1;
|
|
205
|
+
normCol.actions = {
|
|
206
|
+
menuAlignment:
|
|
207
|
+
isLastColumn ||
|
|
208
|
+
normalizedColumns[colIndex + 1].type === 'action'
|
|
209
|
+
? 'auto-right'
|
|
210
|
+
: 'auto-left',
|
|
211
|
+
customerActions: Array.isArray(actions) ? actions : [],
|
|
212
|
+
internalActions: undefined,
|
|
213
|
+
};
|
|
233
214
|
}
|
|
234
|
-
if (!typeAttributes.subTypeAttributes) {
|
|
235
|
-
typeAttributesOverrides.subTypeAttributes = {};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
return Object.assign({}, typeAttributes, typeAttributesOverrides);
|
|
239
215
|
}
|
|
240
216
|
|
|
241
217
|
/**
|
|
@@ -245,10 +221,8 @@ export function getNormalizedSubTypeAttribute(type, typeAttributes) {
|
|
|
245
221
|
* @returns Type attributes for the given column, if they exist.
|
|
246
222
|
*/
|
|
247
223
|
export function getTypeAttributesValues(column) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
return {};
|
|
224
|
+
const { typeAttributes } = column;
|
|
225
|
+
return isObjectLike(typeAttributes) ? typeAttributes : {};
|
|
252
226
|
}
|
|
253
227
|
|
|
254
228
|
/**
|
|
@@ -258,10 +232,8 @@ export function getTypeAttributesValues(column) {
|
|
|
258
232
|
* @returns {Object} Sub-type attributes for the given column, if they exist.
|
|
259
233
|
*/
|
|
260
234
|
export function getSubTypeAttributesValues(column) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
return {};
|
|
235
|
+
const { subTypeAttributes } = column.typeAttributes;
|
|
236
|
+
return isObjectLike(subTypeAttributes) ? subTypeAttributes : {};
|
|
265
237
|
}
|
|
266
238
|
|
|
267
239
|
/**
|
|
@@ -271,10 +243,8 @@ export function getSubTypeAttributesValues(column) {
|
|
|
271
243
|
* @returns {Object} Cell attributes for the given column, if they exist.
|
|
272
244
|
*/
|
|
273
245
|
export function getCellAttributesValues(column) {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
277
|
-
return {};
|
|
246
|
+
const { cellAttributes } = column;
|
|
247
|
+
return isObjectLike(cellAttributes) ? cellAttributes : {};
|
|
278
248
|
}
|
|
279
249
|
|
|
280
250
|
/**
|
|
@@ -300,14 +270,14 @@ export function generateColKeyValue(columnMetadata, index) {
|
|
|
300
270
|
*/
|
|
301
271
|
export function getUserColumnIndex(state, colKeyValue) {
|
|
302
272
|
const { columns } = state;
|
|
303
|
-
const colIndex =
|
|
273
|
+
const colIndex = state.headerIndexes[colKeyValue];
|
|
304
274
|
if (columns[colIndex].internal) {
|
|
305
275
|
return -1;
|
|
306
276
|
}
|
|
307
277
|
let internalColumns = 0;
|
|
308
278
|
for (let i = 0; i < colIndex; i += 1) {
|
|
309
279
|
if (columns[i].internal) {
|
|
310
|
-
internalColumns
|
|
280
|
+
internalColumns += 1;
|
|
311
281
|
}
|
|
312
282
|
}
|
|
313
283
|
|
|
@@ -341,95 +311,3 @@ export const generateHeaderIndexes = function (columns) {
|
|
|
341
311
|
export function getStateColumnIndex(state, colKeyValue) {
|
|
342
312
|
return state.headerIndexes[colKeyValue];
|
|
343
313
|
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Retrieves a column index number by its key.
|
|
347
|
-
*
|
|
348
|
-
* @param {Object} state The datatable state
|
|
349
|
-
* @param {String} key The key of the column. Defaults to field name if 'columnKey' is not provided.
|
|
350
|
-
* @returns {Number} The index in state.columns, -1 if it does not exist
|
|
351
|
-
*/
|
|
352
|
-
export function getColumnIndexByColumnKey(state, key) {
|
|
353
|
-
const columns = getColumns(state);
|
|
354
|
-
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
355
|
-
const col = columns[colIndex];
|
|
356
|
-
if (
|
|
357
|
-
col.columnKey === key ||
|
|
358
|
-
(!col.columnKey && col.fieldName === key)
|
|
359
|
-
) {
|
|
360
|
-
return colIndex;
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
return -1;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/************************** PRIVATE METHODS ***************************/
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* If the specified column type is not supported, resets it to default.
|
|
370
|
-
*
|
|
371
|
-
* @param {Object} column The column definition object.
|
|
372
|
-
* @param {Object} types The type handling factory.
|
|
373
|
-
*/
|
|
374
|
-
function normalizeColumnDataType(column, types) {
|
|
375
|
-
if (!types.isValidType(column.type)) {
|
|
376
|
-
column.type = getRegularColumnDefaults().type;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Returns the column defaults based on its type.
|
|
382
|
-
*
|
|
383
|
-
* @param {Object} column The column definition object.
|
|
384
|
-
* @returns {Object} The column defaults.
|
|
385
|
-
*/
|
|
386
|
-
function getColumnDefaults(column) {
|
|
387
|
-
switch (column.type) {
|
|
388
|
-
case 'action':
|
|
389
|
-
return getActionColumnDefaults();
|
|
390
|
-
case 'tree':
|
|
391
|
-
return getTreeColumnDefaults();
|
|
392
|
-
default:
|
|
393
|
-
return getRegularColumnDefaults();
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* Retrieves the defaults for regular columns.
|
|
399
|
-
*
|
|
400
|
-
* @returns {Object} Regular column defaults
|
|
401
|
-
*/
|
|
402
|
-
function getRegularColumnDefaults() {
|
|
403
|
-
return {
|
|
404
|
-
type: 'text',
|
|
405
|
-
typeAttributes: {},
|
|
406
|
-
cellAttributes: {},
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Retrieves the defaults for action columns.
|
|
412
|
-
*
|
|
413
|
-
* @returns {Object} Action column defaults
|
|
414
|
-
*/
|
|
415
|
-
function getActionColumnDefaults() {
|
|
416
|
-
return {
|
|
417
|
-
fixedWidth: 50,
|
|
418
|
-
resizable: false,
|
|
419
|
-
ariaLabel: i18n.rowActionsDefaultAriaLabel,
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Retrieves the defaults for tree columns.
|
|
425
|
-
*
|
|
426
|
-
* @returns {Object} Tree column defaults
|
|
427
|
-
*/
|
|
428
|
-
function getTreeColumnDefaults() {
|
|
429
|
-
return {
|
|
430
|
-
type: 'tree',
|
|
431
|
-
subType: 'text',
|
|
432
|
-
typeAttributes: {},
|
|
433
|
-
cellAttributes: {},
|
|
434
|
-
};
|
|
435
|
-
}
|