lightning-base-components 1.21.2-alpha → 1.21.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/metadata/raptor.json +28 -1
- package/package.json +28 -2
- package/scopedImports/@salesforce-label-LightningRichTextEditor.colorPicker.js +1 -0
- package/src/lightning/accordion/accordion-section.slds.css +3 -3
- package/src/lightning/accordion/accordion.slds.css +1 -2
- package/src/lightning/accordionSection/accordion-section.slds.css +3 -3
- package/src/lightning/accordionSection/accordionSection.js +3 -1
- package/src/lightning/accordionSection/button.slds.css +1 -1
- package/src/lightning/badge/badge.js +1 -0
- package/src/lightning/badge/badge.js-meta.xml +3 -0
- package/src/lightning/baseCombobox/base-combobox.slds.css +11 -6
- package/src/lightning/baseCombobox/baseCombobox.html +1 -1
- package/src/lightning/baseCombobox/baseCombobox.js +2 -2
- package/src/lightning/baseCombobox/baseCombobox.js-meta.xml +6 -0
- package/src/lightning/baseCombobox/input-text.slds.css +41 -68
- package/src/lightning/baseCombobox/keyboard.js +12 -4
- package/src/lightning/baseCombobox/listbox.slds.css +51 -99
- package/src/lightning/baseCombobox/spinner.slds.css +62 -62
- package/src/lightning/baseComboboxFormattedText/baseComboboxFormattedText.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/baseComboboxItem.js +10 -6
- package/src/lightning/baseComboboxItem/baseComboboxItem.js-meta.xml +6 -0
- package/src/lightning/baseComboboxItem/listbox.slds.css +51 -99
- package/src/lightning/baseFormattedText/baseFormattedText.js +2 -2
- package/src/lightning/button/button.js +2 -1
- package/src/lightning/button/button.slds.css +1 -1
- package/src/lightning/buttonIcon/button-icon.slds.css +1 -1
- package/src/lightning/buttonIconStateful/button-icon-stateful.slds.css +4 -2
- package/src/lightning/buttonIconStateful/button-icon.slds.css +1 -1
- package/src/lightning/buttonIconStateful/button.slds.css +1 -1
- package/src/lightning/buttonMenu/button-icon.slds.css +1 -1
- package/src/lightning/buttonMenu/button-menu.slds.css +8 -2
- package/src/lightning/buttonMenu/button.slds.css +1 -1
- package/src/lightning/buttonStateful/button-stateful.slds.css +6 -2
- package/src/lightning/buttonStateful/button.slds.css +1 -1
- package/src/lightning/buttonStateful/buttonStateful.js +4 -1
- package/src/lightning/calendar/calendar.js-meta.xml +6 -0
- package/src/lightning/calendar/calendar.slds.css +9 -2
- package/src/lightning/colorPickerCustom/color-picker-custom.slds.css +22 -23
- package/src/lightning/colorPickerCustom/input-text.slds.css +41 -68
- package/src/lightning/colorPickerPanel/color-picker-panel.slds.css +9 -10
- package/src/lightning/colorPickerPanel/popover.slds.css +0 -2
- package/src/lightning/combobox/combobox.slds.css +1 -2
- package/src/lightning/combobox/form-element.slds.css +54 -54
- package/src/lightning/datatable/__examples__/customDatatableWrapper/customDatatableWrapper.js +0 -69
- package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.html +1 -1
- package/src/lightning/datatable/__examples__/customDatatypeDeleteRowBtn/customDatatypeDeleteRowBtn.js +1 -16
- package/src/lightning/datatable/__examples__/customDatatypeLink/customDatatypeLink.html +3 -3
- package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.html +1 -8
- package/src/lightning/datatable/__examples__/customDatatypeRowOrderingBtn/customDatatypeRowOrderingBtn.js +2 -39
- package/src/lightning/datatable/__examples__/customDatatypeTable/customNumber.html +1 -1
- package/src/lightning/datatable/__examples__/customDatatypeTable/customNumberEdit.html +2 -0
- package/src/lightning/datatable/__examples__/customDatatypeTable/deleteRow.html +3 -2
- package/src/lightning/datatable/__examples__/customDatatypeTable/iconPill.html +1 -1
- package/src/lightning/datatable/__examples__/customNestedComponent/customNestedComponent.html +10 -0
- package/src/lightning/datatable/__examples__/customNestedComponent/customNestedComponent.js +12 -0
- package/src/lightning/datatable/autoWidthStrategy.js +147 -191
- package/src/lightning/datatable/columnResizer.js +35 -35
- package/src/lightning/datatable/columnWidthManager.js +118 -177
- package/src/lightning/datatable/columns.js +90 -59
- package/src/lightning/datatable/datagrid.slds.css +187 -0
- package/src/lightning/datatable/datatable.js +248 -229
- package/src/lightning/datatable/errors.js +3 -0
- package/src/lightning/datatable/fixedWidthStrategy.js +22 -29
- package/src/lightning/datatable/headerActions.js +7 -9
- package/src/lightning/datatable/infiniteLoading.js +15 -15
- package/src/lightning/datatable/inlineEdit.js +255 -235
- package/src/lightning/datatable/keyboard.js +318 -282
- package/src/lightning/datatable/renderManager.js +10 -7
- package/src/lightning/datatable/resizeObserver.js +11 -59
- package/src/lightning/datatable/rowLevelActions.js +6 -5
- package/src/lightning/datatable/rowNumber.js +23 -23
- package/src/lightning/datatable/rowSelection.js +173 -145
- package/src/lightning/datatable/rowSelectionShared.js +13 -6
- package/src/lightning/datatable/rows.js +231 -196
- package/src/lightning/datatable/sort.js +26 -22
- package/src/lightning/datatable/templates/div/div.css +2 -57
- package/src/lightning/datatable/templates/div/div.html +13 -6
- package/src/lightning/datatable/templates/div/div.lbc.native.css +3 -0
- package/src/lightning/datatable/templates/div/div.lbc.synthetic.css +86 -0
- package/src/lightning/datatable/templates/table/table.html +1 -0
- package/src/lightning/datatable/utils.js +5 -5
- package/src/lightning/datatable/widthManagerShared.js +24 -21
- package/src/lightning/datatable/wrapText.js +25 -26
- package/src/lightning/datepicker/datepicker.js +32 -9
- package/src/lightning/datepicker/datepicker.js-meta.xml +6 -0
- package/src/lightning/datepicker/form-element.slds.css +54 -54
- package/src/lightning/datepicker/input-text.slds.css +41 -68
- package/src/lightning/datetimepicker/datetimepicker.js-meta.xml +6 -0
- package/src/lightning/datetimepicker/form-element.slds.css +54 -54
- package/src/lightning/datetimepicker/input-text.slds.css +41 -68
- package/src/lightning/dualListbox/dual-listbox.slds.css +7 -2
- package/src/lightning/dualListbox/form-element.slds.css +54 -54
- package/src/lightning/dualListbox/listbox.slds.css +51 -99
- package/src/lightning/dynamicIcon/dynamic-icon-strength.slds.css +1 -2
- package/src/lightning/dynamicIcon/dynamic-icon-trend.slds.css +1 -2
- package/src/lightning/formattedDateTime/formattedDateTime.js +7 -62
- package/src/lightning/formattedDateTime/formattedDateTime.js-meta.xml +3 -0
- package/src/lightning/formattedLocation/formattedLocation.html +1 -3
- package/src/lightning/formattedLocation/formattedLocation.js +3 -25
- package/src/lightning/formattedLookup/events.js +2 -4
- package/src/lightning/formattedNumber/formattedNumber.js +2 -49
- package/src/lightning/formattedRichText/formattedRichText.js +5 -5
- package/src/lightning/formattedRichText/linkTextNodes.js +58 -0
- package/src/lightning/groupedCombobox/form-element.slds.css +54 -54
- package/src/lightning/groupedCombobox/grouped-combobox.slds.css +0 -2
- package/src/lightning/groupedCombobox/groupedCombobox.js-meta.xml +1 -1
- package/src/lightning/groupedCombobox/input-text.slds.css +41 -68
- package/src/lightning/helptext/button-icon.slds.css +1 -1
- package/src/lightning/helptext/form-element.slds.css +54 -54
- package/src/lightning/icon/icon.slds.css +12 -25
- package/src/lightning/input/form-element.slds.css +54 -54
- package/src/lightning/inputAddress/form-element.slds.css +54 -54
- package/src/lightning/inputAddress/input-address.slds.css +1 -2
- package/src/lightning/inputAddress/input-text.slds.css +41 -68
- package/src/lightning/inputAddress/inputAddress.js +1 -0
- package/src/lightning/inputAddress/inputAddress.js-meta.xml +3 -0
- package/src/lightning/inputLocation/form-element.slds.css +54 -54
- package/src/lightning/inputLocation/input-location.slds.css +1 -2
- package/src/lightning/inputLocation/input-text.slds.css +41 -68
- package/src/lightning/inputName/form-element.slds.css +54 -54
- package/src/lightning/inputName/input-text.slds.css +41 -68
- package/src/lightning/interactiveDialogBase/interactive-dialog-base.slds.css +0 -3
- package/src/lightning/interactiveDialogBase/interactiveDialogBase.js-meta.xml +6 -0
- package/src/lightning/lookupAddress/form-element.slds.css +54 -54
- package/src/lightning/lookupAddress/listbox.slds.css +51 -99
- package/src/lightning/lookupAddress/location.js +2 -0
- package/src/lightning/lookupAddress/lookup-address.slds.css +0 -2
- package/src/lightning/lookupAddress/lookupAddress.js +15 -10
- package/src/lightning/menuDivider/menu-divider.slds.css +0 -2
- package/src/lightning/menuItem/menu-item.slds.css +8 -2
- package/src/lightning/menuSubheader/menu-subheader.slds.css +1 -2
- package/src/lightning/modalBase/modal-base.slds.css +3 -3
- package/src/lightning/modalBase/modalBase.js +0 -8
- package/src/lightning/modalBase/modalBase.js-meta.xml +6 -0
- package/src/lightning/modalBody/modal-body.slds.css +1 -2
- package/src/lightning/modalFooter/modal-footer.slds.css +2 -2
- package/src/lightning/modalFooter/modalFooter.js +0 -21
- package/src/lightning/modalHeader/modal-header.slds.css +1 -2
- package/src/lightning/modalHeader/modalHeader.js +0 -22
- package/src/lightning/overlay/overlay.js-meta.xml +6 -0
- package/src/lightning/pill/pill.slds.css +32 -58
- package/src/lightning/pillContainer/button.slds.css +1 -1
- package/src/lightning/pillContainer/listbox.slds.css +51 -99
- package/src/lightning/pillContainer/pill-container.slds.css +6 -10
- package/src/lightning/pillContainer/pill.slds.css +32 -58
- package/src/lightning/popup/popover.slds.css +0 -2
- package/src/lightning/primitiveBubble/primitiveBubble.js-meta.xml +6 -0
- package/src/lightning/primitiveButton/primitiveButoon.js-meta.xml +6 -0
- package/src/lightning/primitiveCellCheckbox/checkbox.css +2 -0
- package/src/lightning/primitiveColorpickerButton/color-picker-button.slds.css +16 -38
- package/src/lightning/primitiveCustomCell/primitiveCustomCell.js +26 -1
- package/src/lightning/primitiveHeaderFactory/nonsortableHeader.css +1 -0
- package/src/lightning/primitiveHeaderFactory/selectableHeader.css +2 -0
- package/src/lightning/primitiveIcon/icon.slds.css +12 -25
- package/src/lightning/primitiveIcon/primitiveIcon.js-meta.xml +6 -0
- package/src/lightning/primitiveIframe/primitiveIframe.js +3 -1
- package/src/lightning/primitiveInputCheckbox/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js +5 -2
- package/src/lightning/primitiveInputCheckbox/primitiveInputCheckbox.js-meta.xml +6 -0
- package/src/lightning/primitiveInputCheckboxButton/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputCheckboxButton/input-checkbox-button.slds.css +6 -4
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js +5 -2
- package/src/lightning/primitiveInputCheckboxButton/primitiveInputCheckboxButton.js-meta.xml +6 -0
- package/src/lightning/primitiveInputColor/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputColor/input-color.slds.css +2 -3
- package/src/lightning/primitiveInputColor/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputColor/primitiveInputColor.js +5 -2
- package/src/lightning/primitiveInputColor/primitiveInputColor.js-meta.xml +6 -0
- package/src/lightning/primitiveInputFile/button.slds.css +1 -1
- package/src/lightning/primitiveInputFile/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputFile/input-file.slds.css +1 -4
- package/src/lightning/primitiveInputFile/primitiveInputFile.js +4 -2
- package/src/lightning/primitiveInputFile/primitiveInputFile.js-meta.xml +6 -0
- package/src/lightning/primitiveInputRadio/primitiveInputRadio.js +4 -2
- package/src/lightning/primitiveInputSimple/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputSimple/input-text.slds.css +41 -68
- package/src/lightning/primitiveInputSimple/primitiveInputSimple.js-meta.xml +6 -0
- package/src/lightning/primitiveInputToggle/form-element.slds.css +54 -54
- package/src/lightning/primitiveInputToggle/input-toggle.slds.css +50 -27
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js +5 -2
- package/src/lightning/primitiveInputToggle/primitiveInputToggle.js-meta.xml +6 -0
- package/src/lightning/progressBar/progress-bar.slds.css +8 -10
- package/src/lightning/progressRing/progress-ring.slds.css +0 -23
- package/src/lightning/progressStep/progressStep.js +1 -14
- package/src/lightning/radioGroup/form-element.slds.css +54 -54
- package/src/lightning/radioGroup/radioGroup.html +1 -2
- package/src/lightning/radioGroup/radioGroup.js +1 -0
- package/src/lightning/routingService/routingService.js +31 -5
- package/src/lightning/select/form-element.slds.css +54 -54
- package/src/lightning/select/select.slds.css +4 -2
- package/src/lightning/sldsUtilsVisibility/sldsUtilsVisibility.css +4 -0
- package/src/lightning/spinner/spinner.slds.css +62 -62
- package/src/lightning/tab/tab.js +4 -2
- package/src/lightning/tab/tab.slds.css +14 -7
- package/src/lightning/tabBar/tab-bar.slds.css +16 -6
- package/src/lightning/tabset/__docs__/tabset.md +24 -1
- package/src/lightning/tabset/tabset.js +25 -38
- package/src/lightning/tabset/tabset.slds.css +0 -2
- package/src/lightning/textarea/form-element.slds.css +54 -54
- package/src/lightning/textarea/textarea.js +5 -1
- package/src/lightning/textarea/textarea.slds.css +22 -9
- package/src/lightning/timepicker/form-element.slds.css +54 -54
- package/src/lightning/timepicker/timepicker.js-meta.xml +6 -0
- package/src/lightning/timepicker/timepicker.slds.css +2 -2
- package/src/lightning/toast/__docs__/toast.md +20 -22
- package/src/lightning/toast/button-icon.slds.css +1 -1
- package/src/lightning/toast/icon.slds.css +12 -25
- package/src/lightning/toast/toast.js +15 -12
- package/src/lightning/toast/toast.slds.css +6 -18
- package/src/lightning/toastContainer/toast.slds.css +6 -18
- package/src/lightning/toastContainer/toastContainer.js +25 -17
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +12 -9
- package/src/lightning/tree/tree.js +2 -0
- package/src/lightning/utils/classSet.js +9 -3
- package/src/lightning/utilsPrivate/formatUtils.js +158 -0
- package/src/lightning/utilsPrivate/textUtils.js +16 -0
- package/src/lightning/utilsPrivate/utilsPrivate.js +56 -15
- package/src/lightning/utilsPrivate/validationUtils.js +59 -0
- package/src/lightning/verticalNavigationSection/vertical-navigation-section.slds.css +0 -2
- package/src/lightning/datatable/resizeSensor.js +0 -244
- package/src/lightning/formattedRichText/linkify.js +0 -43
- package/src/lightning/utilsPrivate/smartSetAttribute.js +0 -19
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getAdjustedRowNumberColumnWidth,
|
|
12
12
|
} from './rowNumber';
|
|
13
13
|
import {
|
|
14
|
-
|
|
14
|
+
getColumnWidth,
|
|
15
15
|
getDomWidth,
|
|
16
16
|
buildCSSWidthStyle,
|
|
17
17
|
} from './widthManagerShared';
|
|
@@ -39,21 +39,21 @@ const tableTypes = {
|
|
|
39
39
|
* Computes and updates the `widthsData` for a datatable.
|
|
40
40
|
*
|
|
41
41
|
* @param {Object} adjustedWidths The adjusted widths object
|
|
42
|
-
* @param {Array}
|
|
43
|
-
* @param {Object} widthsData The
|
|
42
|
+
* @param {Array} columns The column definitions
|
|
43
|
+
* @param {Object} widthsData The widths data to update
|
|
44
44
|
*/
|
|
45
|
-
export function
|
|
45
|
+
export function updateColumnWidths(adjustedWidths, columns, widthsData) {
|
|
46
46
|
const { columnWidths } = adjustedWidths;
|
|
47
|
-
const { length:
|
|
48
|
-
if (columnWidths.length !==
|
|
47
|
+
const { length: colCount } = columns;
|
|
48
|
+
if (columnWidths.length !== colCount) {
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
let columnWidthsSum = 0;
|
|
52
52
|
const rtl = isRTL();
|
|
53
|
-
for (let
|
|
54
|
-
const col =
|
|
55
|
-
const newWidth = columnWidths[
|
|
56
|
-
widthsData.columnWidths[
|
|
53
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
54
|
+
const col = columns[colIndex];
|
|
55
|
+
const newWidth = columnWidths[colIndex];
|
|
56
|
+
widthsData.columnWidths[colIndex] = newWidth;
|
|
57
57
|
col.columnWidth = newWidth;
|
|
58
58
|
col.style = buildCSSWidthStyle(newWidth);
|
|
59
59
|
|
|
@@ -77,16 +77,16 @@ export function computeColumnWidths(adjustedWidths, columnDefs, widthsData) {
|
|
|
77
77
|
*/
|
|
78
78
|
export class ColumnWidthManager {
|
|
79
79
|
// Private variables
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
columnWidthMode = FIXED_WIDTH_MODE;
|
|
81
|
+
resizeObserverAvailable = typeof ResizeObserver === 'function';
|
|
82
82
|
|
|
83
83
|
// Flag to indicate resetting column widths is needed.
|
|
84
84
|
// Could be with or without `autoResizingUpdate`.
|
|
85
|
-
|
|
85
|
+
isResizingUpdateQueued = false;
|
|
86
86
|
|
|
87
87
|
// Flag to indicate whether auto resizing computation update is needed,
|
|
88
88
|
// in which case table styles need to auto flow.
|
|
89
|
-
|
|
89
|
+
isAutoResizingUpdateQueued = false;
|
|
90
90
|
|
|
91
91
|
/************************** LIFECYCLE HOOKS **************************/
|
|
92
92
|
|
|
@@ -105,9 +105,10 @@ export class ColumnWidthManager {
|
|
|
105
105
|
minColumnWidth,
|
|
106
106
|
maxColumnWidth
|
|
107
107
|
);
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
this.widthStrategies = {
|
|
109
|
+
[FIXED_WIDTH_MODE]: fixedWidthStrategy,
|
|
110
|
+
[AUTO_WIDTH_MODE]: autoWidthStrategy,
|
|
111
|
+
};
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
/************************** PRIVATE GETTERS **************************/
|
|
@@ -118,40 +119,22 @@ export class ColumnWidthManager {
|
|
|
118
119
|
* @returns {Object} The column width strategy
|
|
119
120
|
*/
|
|
120
121
|
get columnWidthStrategy() {
|
|
121
|
-
return this.
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Gets the configured column width mode.
|
|
126
|
-
*
|
|
127
|
-
* @returns {String} The column width mode
|
|
128
|
-
*/
|
|
129
|
-
get columnWidthMode() {
|
|
130
|
-
return this._columnWidthMode;
|
|
122
|
+
return this.widthStrategies[this.columnWidthMode];
|
|
131
123
|
}
|
|
132
124
|
|
|
133
125
|
/************************** PRIVATE SETTERS **************************/
|
|
134
126
|
|
|
135
|
-
/**
|
|
136
|
-
* Sets the column width mode.
|
|
137
|
-
*
|
|
138
|
-
* @param {String} value The new column width mode
|
|
139
|
-
*/
|
|
140
|
-
set columnWidthMode(value) {
|
|
141
|
-
this._columnWidthMode = value;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
127
|
/**
|
|
145
128
|
* Sets the minimum column width (in pixels).
|
|
146
129
|
*
|
|
147
130
|
* @param {Number} value The minimum column width
|
|
148
131
|
*/
|
|
149
132
|
set minColumnWidth(value) {
|
|
150
|
-
const {
|
|
151
|
-
const keys = Object.keys(
|
|
133
|
+
const { widthStrategies } = this;
|
|
134
|
+
const keys = Object.keys(widthStrategies);
|
|
152
135
|
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
153
136
|
const strategy = keys[i];
|
|
154
|
-
|
|
137
|
+
widthStrategies[strategy].minColumnWidth = value;
|
|
155
138
|
}
|
|
156
139
|
}
|
|
157
140
|
|
|
@@ -161,11 +144,11 @@ export class ColumnWidthManager {
|
|
|
161
144
|
* @param {Number} value The maximum column width
|
|
162
145
|
*/
|
|
163
146
|
set maxColumnWidth(value) {
|
|
164
|
-
const {
|
|
165
|
-
const keys = Object.keys(
|
|
147
|
+
const { widthStrategies } = this;
|
|
148
|
+
const keys = Object.keys(widthStrategies);
|
|
166
149
|
for (let i = 0, { length } = keys; i < length; i += 1) {
|
|
167
150
|
const strategy = keys[i];
|
|
168
|
-
|
|
151
|
+
widthStrategies[strategy].maxColumnWidth = value;
|
|
169
152
|
}
|
|
170
153
|
}
|
|
171
154
|
|
|
@@ -175,7 +158,7 @@ export class ColumnWidthManager {
|
|
|
175
158
|
* @param {Number} value The maximum number of lines text can be wrapped on
|
|
176
159
|
*/
|
|
177
160
|
set wrapTextMaxLines(value) {
|
|
178
|
-
this.
|
|
161
|
+
this.widthStrategies[AUTO_WIDTH_MODE].wrapTextMaxLines = value;
|
|
179
162
|
}
|
|
180
163
|
|
|
181
164
|
/************************* HELPER FUNCTIONS **************************/
|
|
@@ -189,24 +172,6 @@ export class ColumnWidthManager {
|
|
|
189
172
|
this._renderMode = mode;
|
|
190
173
|
}
|
|
191
174
|
|
|
192
|
-
/**
|
|
193
|
-
* Returns whether a resizing update is queued.
|
|
194
|
-
*
|
|
195
|
-
* @returns {Boolean} Whether there is a resizing update queued
|
|
196
|
-
*/
|
|
197
|
-
isResizingUpdateQueued() {
|
|
198
|
-
return this._queueResizingUpdate;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Returns whether an auto-resizing update is queued.
|
|
203
|
-
*
|
|
204
|
-
* @returns {Boolean} Whether there is an auto-resizing update queued
|
|
205
|
-
*/
|
|
206
|
-
isAutoResizingUpdateQueued() {
|
|
207
|
-
return this._queueAutoResizingUpdate;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
175
|
/**
|
|
211
176
|
* Determines if we should fire the resize event based on the previous
|
|
212
177
|
* widths data and the column definition. The event is only fired when
|
|
@@ -214,43 +179,39 @@ export class ColumnWidthManager {
|
|
|
214
179
|
* nothing happens.
|
|
215
180
|
*
|
|
216
181
|
* @param {Object} previousWidthsData The previous widths data to evaluate
|
|
217
|
-
* @param {Array}
|
|
182
|
+
* @param {Array} columns The column definitions
|
|
218
183
|
* @returns {Boolean} Whether or not the resize event should be fired
|
|
219
184
|
*/
|
|
220
|
-
shouldFireResizeEvent(previousWidthsData,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
return false;
|
|
185
|
+
shouldFireResizeEvent(previousWidthsData, columns) {
|
|
186
|
+
return (
|
|
187
|
+
this._columnWidthMode === FIXED_WIDTH_MODE &&
|
|
188
|
+
getColumnsWidths(previousWidthsData).length !== columns.length
|
|
189
|
+
);
|
|
228
190
|
}
|
|
229
191
|
|
|
230
192
|
/**
|
|
231
193
|
* Adjusts all the column sizes based on the supplied widths data.
|
|
232
194
|
*
|
|
233
|
-
* @param {Node}
|
|
234
|
-
* @param {Array} columnDefs The column definitions
|
|
195
|
+
* @param {Node} template The datatable template
|
|
196
|
+
* @param {Array} columnDefs The column definitions
|
|
235
197
|
* @param {Object} widthsData The widths data object
|
|
236
198
|
*/
|
|
237
|
-
adjustColumnsSize(
|
|
199
|
+
adjustColumnsSize(template, columns, widthsData) {
|
|
238
200
|
const {
|
|
239
|
-
|
|
240
|
-
|
|
201
|
+
isResizingUpdateQueued,
|
|
202
|
+
isAutoResizingUpdateQueued,
|
|
241
203
|
columnWidthStrategy,
|
|
242
204
|
} = this;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
if (_queueResizingUpdate) {
|
|
205
|
+
if (isResizingUpdateQueued) {
|
|
206
|
+
let adjustedWidths;
|
|
246
207
|
// If table is hidden when updating and `ResizeObserver` is not available,
|
|
247
208
|
// then updating sizes causes min widths to be set.
|
|
248
209
|
// Hence, the check if ok update from DOM.
|
|
249
|
-
if (this.
|
|
210
|
+
if (this.shouldResizeWithUpdate(template, widthsData)) {
|
|
250
211
|
adjustedWidths = columnWidthStrategy.getAdjustedColumnWidths(
|
|
251
|
-
this.
|
|
252
|
-
|
|
253
|
-
|
|
212
|
+
this.getDatatableInterface(template),
|
|
213
|
+
columns,
|
|
214
|
+
isAutoResizingUpdateQueued
|
|
254
215
|
);
|
|
255
216
|
} else {
|
|
256
217
|
// Otherwise update from previous widths
|
|
@@ -259,26 +220,25 @@ export class ColumnWidthManager {
|
|
|
259
220
|
expectedTableWidth: widthsData.tableWidth,
|
|
260
221
|
};
|
|
261
222
|
}
|
|
262
|
-
|
|
223
|
+
updateColumnWidths(adjustedWidths, columns, widthsData);
|
|
263
224
|
}
|
|
264
|
-
|
|
265
|
-
this.
|
|
266
|
-
this._queueResizingUpdate = false;
|
|
225
|
+
this.isAutoResizingUpdateQueued = false;
|
|
226
|
+
this.isResizingUpdateQueued = false;
|
|
267
227
|
}
|
|
268
228
|
|
|
269
229
|
/**
|
|
270
230
|
* Adjusts all the column widths after a resize happens.
|
|
271
231
|
*
|
|
272
|
-
* @param {Node}
|
|
273
|
-
* @param {Array}
|
|
232
|
+
* @param {Node} template The datatable template
|
|
233
|
+
* @param {Array} columns The column definitions
|
|
274
234
|
* @param {Object} widthsData The widths data object
|
|
275
235
|
*/
|
|
276
|
-
adjustColumnsSizeAfterResize(
|
|
236
|
+
adjustColumnsSizeAfterResize(template, columns, widthsData) {
|
|
277
237
|
const adjustedWidths = this.columnWidthStrategy.getAdjustedColumnWidths(
|
|
278
|
-
this.
|
|
279
|
-
|
|
238
|
+
this.getDatatableInterface(template),
|
|
239
|
+
columns
|
|
280
240
|
);
|
|
281
|
-
|
|
241
|
+
updateColumnWidths(adjustedWidths, columns, widthsData);
|
|
282
242
|
}
|
|
283
243
|
|
|
284
244
|
/**
|
|
@@ -286,17 +246,17 @@ export class ColumnWidthManager {
|
|
|
286
246
|
*
|
|
287
247
|
* @param {Object} previousData The previous data
|
|
288
248
|
* @param {Object} newData The new data
|
|
289
|
-
* @param {Array}
|
|
249
|
+
* @param {Array} columns The column definitions
|
|
290
250
|
*/
|
|
291
|
-
handleDataChange(previousData, newData,
|
|
292
|
-
if (
|
|
251
|
+
handleDataChange(previousData, newData, columns) {
|
|
252
|
+
if (columns.length > 0) {
|
|
293
253
|
// Resize columns with auto-resizing update only if...
|
|
294
254
|
// The mode is auto and new data length is equal to previous data
|
|
295
255
|
// length (change in data) or previously there was no data at all.
|
|
296
256
|
if (this.columnWidthMode === AUTO_WIDTH_MODE) {
|
|
297
|
-
if (this.
|
|
298
|
-
this.
|
|
299
|
-
this.
|
|
257
|
+
if (this.hasDataChanged(previousData, newData)) {
|
|
258
|
+
this.isResizingUpdateQueued = true;
|
|
259
|
+
this.setAutoResizingUpdate(columns);
|
|
300
260
|
}
|
|
301
261
|
}
|
|
302
262
|
}
|
|
@@ -305,24 +265,24 @@ export class ColumnWidthManager {
|
|
|
305
265
|
/**
|
|
306
266
|
* React to change in column definitions
|
|
307
267
|
*
|
|
308
|
-
* @param {Array}
|
|
268
|
+
* @param {Array} columns The column definitions
|
|
309
269
|
*/
|
|
310
|
-
handleColumnsChange(
|
|
311
|
-
if (
|
|
312
|
-
this.
|
|
313
|
-
this.
|
|
270
|
+
handleColumnsChange(columns) {
|
|
271
|
+
if (columns.length > 0) {
|
|
272
|
+
this.isResizingUpdateQueued = true;
|
|
273
|
+
this.setAutoResizingUpdate(columns);
|
|
314
274
|
}
|
|
315
275
|
}
|
|
316
276
|
|
|
317
277
|
/**
|
|
318
278
|
* React to change in column widths mode
|
|
319
279
|
*
|
|
320
|
-
* @param {Array}
|
|
280
|
+
* @param {Array} columns The column definitions
|
|
321
281
|
*/
|
|
322
|
-
handleWidthModeChange(
|
|
323
|
-
if (
|
|
324
|
-
this.
|
|
325
|
-
this.
|
|
282
|
+
handleWidthModeChange(columns) {
|
|
283
|
+
if (columns.length > 0) {
|
|
284
|
+
this.isResizingUpdateQueued = true;
|
|
285
|
+
this.setAutoResizingUpdate(columns);
|
|
326
286
|
}
|
|
327
287
|
}
|
|
328
288
|
|
|
@@ -330,23 +290,21 @@ export class ColumnWidthManager {
|
|
|
330
290
|
* React to change in row number offset
|
|
331
291
|
*
|
|
332
292
|
* @param {Object} state The datatable state
|
|
333
|
-
* @param {Object} widthsData The
|
|
293
|
+
* @param {Object} widthsData The widths data
|
|
334
294
|
*/
|
|
335
295
|
handleRowNumberOffsetChange(state, widthsData) {
|
|
336
296
|
const colIndex = getRowNumberColumnIndex(state);
|
|
337
297
|
if (colIndex > -1) {
|
|
338
|
-
const
|
|
298
|
+
const { columns } = state;
|
|
299
|
+
const col = columns[colIndex];
|
|
339
300
|
const newWidth = getAdjustedRowNumberColumnWidth(state);
|
|
340
|
-
if (
|
|
341
|
-
|
|
342
|
-
newWidth,
|
|
343
|
-
rowNumberCol.minWidth
|
|
344
|
-
);
|
|
301
|
+
if (col.initialWidth !== newWidth) {
|
|
302
|
+
col.initialWidth = Math.max(newWidth, col.minWidth);
|
|
345
303
|
if (hasDefinedColumnsWidths(widthsData)) {
|
|
346
304
|
// When columns are resized with the resizer, a horizontal scroller appears.
|
|
347
305
|
// Adjusting the columns size will respect widths already set and try to fit this column.
|
|
348
|
-
this.
|
|
349
|
-
this.
|
|
306
|
+
this.isResizingUpdateQueued = true;
|
|
307
|
+
this.setAutoResizingUpdate(columns);
|
|
350
308
|
}
|
|
351
309
|
}
|
|
352
310
|
}
|
|
@@ -357,11 +315,11 @@ export class ColumnWidthManager {
|
|
|
357
315
|
*
|
|
358
316
|
* @param {Any} previousValue The previous column value
|
|
359
317
|
* @param {Any} newValue The new column value
|
|
360
|
-
* @param {Array}
|
|
318
|
+
* @param {Array} columns The column definitions
|
|
361
319
|
*/
|
|
362
|
-
handleCheckboxColumnChange(previousValue, newValue,
|
|
363
|
-
if (
|
|
364
|
-
this.
|
|
320
|
+
handleCheckboxColumnChange(previousValue, newValue, columns) {
|
|
321
|
+
if (columns.length > 0 && previousValue !== newValue) {
|
|
322
|
+
this.isResizingUpdateQueued = true;
|
|
365
323
|
}
|
|
366
324
|
}
|
|
367
325
|
|
|
@@ -370,29 +328,28 @@ export class ColumnWidthManager {
|
|
|
370
328
|
*
|
|
371
329
|
* @param {Any} previousValue The previous column value
|
|
372
330
|
* @param {Any} newValue The new column value
|
|
373
|
-
* @param {Array}
|
|
331
|
+
* @param {Array} columns The column definitions
|
|
374
332
|
*/
|
|
375
|
-
handleRowNumberColumnChange(previousValue, newValue,
|
|
376
|
-
if (
|
|
377
|
-
this.
|
|
378
|
-
this.
|
|
333
|
+
handleRowNumberColumnChange(previousValue, newValue, columns) {
|
|
334
|
+
if (columns.length > 0 && previousValue !== newValue) {
|
|
335
|
+
this.isResizingUpdateQueued = true;
|
|
336
|
+
this.setAutoResizingUpdate(columns);
|
|
379
337
|
}
|
|
380
338
|
}
|
|
381
339
|
|
|
382
340
|
/**
|
|
383
|
-
* @private
|
|
384
341
|
* Queues up an auto resizing update. If a column width isn't defined,
|
|
385
342
|
* reset the width so it can be recalculated.
|
|
386
343
|
*
|
|
387
|
-
* @param {Array}
|
|
344
|
+
* @param {Array} columns The column definitions
|
|
388
345
|
*/
|
|
389
|
-
|
|
346
|
+
setAutoResizingUpdate(columns) {
|
|
390
347
|
if (this.columnWidthMode === AUTO_WIDTH_MODE) {
|
|
391
|
-
this.
|
|
348
|
+
this.isAutoResizingUpdateQueued = true;
|
|
392
349
|
}
|
|
393
|
-
for (let
|
|
394
|
-
const col =
|
|
395
|
-
if (!
|
|
350
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
351
|
+
const col = columns[colIndex];
|
|
352
|
+
if (!getColumnWidth(col)) {
|
|
396
353
|
col.columnWidth = null;
|
|
397
354
|
col.style = '';
|
|
398
355
|
}
|
|
@@ -400,26 +357,18 @@ export class ColumnWidthManager {
|
|
|
400
357
|
}
|
|
401
358
|
|
|
402
359
|
/**
|
|
403
|
-
* @private
|
|
404
|
-
* Resets the auto resizing update queue.
|
|
405
|
-
*/
|
|
406
|
-
_resetAutoResizingUpdate() {
|
|
407
|
-
this._queueAutoResizingUpdate = false;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* @private
|
|
412
360
|
* Evalutes if there is a change between two sets of data.
|
|
413
361
|
*
|
|
414
362
|
* @param {Array} previousData An array of previous data
|
|
415
363
|
* @param {Array} newData An array of new data
|
|
416
364
|
* @returns {Boolean} Whether or not the is a difference between the two data sets
|
|
417
365
|
*/
|
|
418
|
-
|
|
366
|
+
hasDataChanged(previousData, newData) {
|
|
367
|
+
const { length: previousDataLength } = previousData;
|
|
368
|
+
const { length: newDataLength } = newData;
|
|
419
369
|
return (
|
|
420
|
-
|
|
421
|
-
(
|
|
422
|
-
previousData.length !== newData.length)
|
|
370
|
+
newDataLength > 0 &&
|
|
371
|
+
(previousDataLength === 0 || previousDataLength !== newDataLength)
|
|
423
372
|
);
|
|
424
373
|
}
|
|
425
374
|
|
|
@@ -427,16 +376,16 @@ export class ColumnWidthManager {
|
|
|
427
376
|
* @private
|
|
428
377
|
* Determines if a column should resize with an update.
|
|
429
378
|
*
|
|
430
|
-
* @param {Node}
|
|
379
|
+
* @param {Node} template The datatable template
|
|
431
380
|
* @param {Object} widthsData The source widths data
|
|
432
381
|
* @returns {Boolean} Whether the column should resize with an update
|
|
433
382
|
*/
|
|
434
|
-
|
|
383
|
+
shouldResizeWithUpdate(template, widthsData) {
|
|
435
384
|
if (hasDefinedColumnsWidths(widthsData)) {
|
|
436
385
|
// Can resize from DOM when table is visible.
|
|
437
386
|
// Otherwise, only when `ResizeObserver` is available in browser.
|
|
438
387
|
return (
|
|
439
|
-
this.
|
|
388
|
+
this.resizeObserverAvailable || isTableRenderedVisible(template)
|
|
440
389
|
);
|
|
441
390
|
}
|
|
442
391
|
return true;
|
|
@@ -456,57 +405,49 @@ export class ColumnWidthManager {
|
|
|
456
405
|
}
|
|
457
406
|
|
|
458
407
|
/**
|
|
459
|
-
* @private
|
|
460
408
|
* Retrieves the datatable interface from the DOM
|
|
461
409
|
*
|
|
462
|
-
* @param {Node}
|
|
410
|
+
* @param {Node} template The datatable template
|
|
463
411
|
* @returns {Object} The datatable interface
|
|
464
412
|
*/
|
|
465
|
-
|
|
413
|
+
getDatatableInterface(template) {
|
|
466
414
|
const datatableSelectors = this._getTableSelectors();
|
|
467
415
|
return {
|
|
468
416
|
getAvailableWidthFromDom() {
|
|
469
|
-
const container =
|
|
417
|
+
const container = template.querySelector(
|
|
470
418
|
datatableSelectors.CONTAINER
|
|
471
419
|
);
|
|
472
420
|
return getDomWidth(container);
|
|
473
421
|
},
|
|
474
422
|
getDataCellWidths() {
|
|
475
|
-
const
|
|
423
|
+
const cellElements = template.querySelectorAll(
|
|
476
424
|
datatableSelectors.DATA_CELL
|
|
477
425
|
);
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
result.push(cell.offsetWidth);
|
|
483
|
-
return result;
|
|
484
|
-
}, []);
|
|
426
|
+
const { length } = cellElements;
|
|
427
|
+
const result = Array(length);
|
|
428
|
+
for (let i = 0; i < length; i += 1) {
|
|
429
|
+
result[i] = cellElements[i].offsetWidth;
|
|
485
430
|
}
|
|
486
|
-
return
|
|
431
|
+
return result;
|
|
487
432
|
},
|
|
488
433
|
getHeaderCellWidths() {
|
|
489
|
-
const
|
|
434
|
+
const headerElements = template.querySelectorAll(
|
|
490
435
|
datatableSelectors.HEADER_CELL
|
|
491
436
|
);
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
result.push(headerDomWidth);
|
|
499
|
-
}
|
|
500
|
-
return result;
|
|
501
|
-
}, []);
|
|
437
|
+
const result = [];
|
|
438
|
+
for (let i = 0; i < headerElements.length; i += 1) {
|
|
439
|
+
const headerDomWidth = headerElements[i].getDomWidth();
|
|
440
|
+
if (headerDomWidth) {
|
|
441
|
+
result.push(headerDomWidth);
|
|
442
|
+
}
|
|
502
443
|
}
|
|
503
|
-
return
|
|
444
|
+
return result;
|
|
504
445
|
},
|
|
505
446
|
getTableElementWidth() {
|
|
506
447
|
const tableElement =
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
448
|
+
template.querySelector(datatableSelectors.BASE) ||
|
|
449
|
+
template.querySelector('[role="grid"]') ||
|
|
450
|
+
template.querySelector('[role="treegrid"]');
|
|
510
451
|
return getDomWidth(tableElement);
|
|
511
452
|
},
|
|
512
453
|
};
|