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
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTotalWidthsMetadata,
|
|
3
|
-
getColumnWidthFromDef,
|
|
4
|
-
} from './widthManagerShared';
|
|
5
1
|
import { clamp } from './utils';
|
|
2
|
+
import { getColumnWidth, getTotalWidthsData } from './widthManagerShared';
|
|
6
3
|
|
|
7
4
|
const MIN_MAX_THRESHOLD = 0.5;
|
|
8
5
|
const TRUNCATION_ALLOWANCE = 20;
|
|
@@ -25,7 +22,11 @@ function hasColumn(columns, colIndex) {
|
|
|
25
22
|
* @returns {Number} The total width of all columns
|
|
26
23
|
*/
|
|
27
24
|
function getTotalColumnWidth(columnWidths) {
|
|
28
|
-
|
|
25
|
+
let total = 0;
|
|
26
|
+
for (let i = 0, { length } = columnWidths; i < length; i += 1) {
|
|
27
|
+
total += columnWidths[i];
|
|
28
|
+
}
|
|
29
|
+
return total;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
/**
|
|
@@ -56,12 +57,12 @@ function canAddWidth(currentWidth, widthToAdd, maxColumnWidth) {
|
|
|
56
57
|
* Determines the expected table width
|
|
57
58
|
*
|
|
58
59
|
* @param {Number} availableWidth The available width for the entire table
|
|
59
|
-
* @param {Object}
|
|
60
|
+
* @param {Object} widthsData The widths data
|
|
60
61
|
* @returns {Number} The expected width of the table
|
|
61
62
|
*/
|
|
62
|
-
function getExpectedTableWidth(availableWidth,
|
|
63
|
-
const minExpectedTableWidth = getMinExpectedTableWidth(
|
|
64
|
-
return
|
|
63
|
+
function getExpectedTableWidth(availableWidth, widthsData) {
|
|
64
|
+
const minExpectedTableWidth = getMinExpectedTableWidth(widthsData);
|
|
65
|
+
return widthsData.totalFlexibleColumns === 0
|
|
65
66
|
? minExpectedTableWidth
|
|
66
67
|
: Math.max(minExpectedTableWidth, availableWidth);
|
|
67
68
|
}
|
|
@@ -69,18 +70,17 @@ function getExpectedTableWidth(availableWidth, widthsMetadata) {
|
|
|
69
70
|
/**
|
|
70
71
|
* Determines the minimum expected table width
|
|
71
72
|
*
|
|
72
|
-
* @param {Object}
|
|
73
|
+
* @param {Object} widthsData The widths data
|
|
73
74
|
* @returns {Number} The minimum expected table width
|
|
74
75
|
*/
|
|
75
|
-
function getMinExpectedTableWidth(
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return minTotalFlexibleWidth + totalFixedWidth + totalResizedWidth;
|
|
76
|
+
function getMinExpectedTableWidth(widthsData) {
|
|
77
|
+
const minTotalFlexibleWidth =
|
|
78
|
+
widthsData.totalFlexibleColumns * widthsData.minColumnWidth;
|
|
79
|
+
return (
|
|
80
|
+
minTotalFlexibleWidth +
|
|
81
|
+
widthsData.totalFixedWidth +
|
|
82
|
+
widthsData.totalResizedWidth
|
|
83
|
+
);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -91,21 +91,21 @@ export class AutoWidthStrategy {
|
|
|
91
91
|
|
|
92
92
|
// Instance array to hold column width ratios either calculated from visual distribution of column labels
|
|
93
93
|
// or from distribution of data amongst the columns. These ratios are reused except when datatable reacts
|
|
94
|
-
// to changes in data or columns and other
|
|
95
|
-
|
|
94
|
+
// to changes in data or columns and other variables at which point they are recalculated.
|
|
95
|
+
columnWidthRatios = [];
|
|
96
96
|
|
|
97
97
|
// Object used to store `minColumnWidth`, `maxColumnWidth`, along with other metadata like `totalFixedColumns`
|
|
98
|
-
// Refer: widthManagerShared.js
|
|
99
|
-
|
|
98
|
+
// Refer: widthManagerShared.js getTotalWidthsData
|
|
99
|
+
columnWidthData = {};
|
|
100
100
|
|
|
101
101
|
// Object which holds columns with min width (+ threshold) and columns with max width (-threshold)
|
|
102
102
|
// It is used in redistribution of extra space that is left or taken up while calculating auto widths
|
|
103
|
-
|
|
103
|
+
columnWidthsDistribution = {};
|
|
104
104
|
|
|
105
105
|
/************************** LIFECYCLE HOOKS **************************/
|
|
106
106
|
|
|
107
107
|
constructor(minColumnWidth, maxColumnWidth, wrapTextMaxLines = 3) {
|
|
108
|
-
this.
|
|
108
|
+
this.columnWidthData = {
|
|
109
109
|
minColumnWidth,
|
|
110
110
|
maxColumnWidth,
|
|
111
111
|
wrapTextMaxLines,
|
|
@@ -122,7 +122,7 @@ export class AutoWidthStrategy {
|
|
|
122
122
|
* @param {Number} value The minimum column width in pixels
|
|
123
123
|
*/
|
|
124
124
|
set minColumnWidth(value) {
|
|
125
|
-
this.
|
|
125
|
+
this.columnWidthData.minColumnWidth = value;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
@@ -131,7 +131,7 @@ export class AutoWidthStrategy {
|
|
|
131
131
|
* @param {Number} value The maximum column width in pixels
|
|
132
132
|
*/
|
|
133
133
|
set maxColumnWidth(value) {
|
|
134
|
-
this.
|
|
134
|
+
this.columnWidthData.maxColumnWidth = value;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
/**
|
|
@@ -140,33 +140,9 @@ export class AutoWidthStrategy {
|
|
|
140
140
|
* @param {Number} value The maximum number of lines
|
|
141
141
|
*/
|
|
142
142
|
set wrapTextMaxLines(value) {
|
|
143
|
-
this.
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/************************** PRIVATE GETTERS **************************/
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Gets the column width ratios
|
|
150
|
-
* See `_columnWidthRatios` in Private Variables for more information.
|
|
151
|
-
*
|
|
152
|
-
* @returns {Array} An array of column width ratios
|
|
153
|
-
*/
|
|
154
|
-
get columnWidthRatios() {
|
|
155
|
-
return this._columnWidthRatios;
|
|
143
|
+
this.columnWidthData.wrapTextMaxLines = value;
|
|
156
144
|
}
|
|
157
145
|
|
|
158
|
-
/**
|
|
159
|
-
* Gets the column width distribution.
|
|
160
|
-
* See `_columnWidthsDistribution` in Private Variables for more information.
|
|
161
|
-
*
|
|
162
|
-
* @returns {Object} An object of column width distributions
|
|
163
|
-
*/
|
|
164
|
-
get columnWidthsDistribution() {
|
|
165
|
-
return this._columnWidthsDistribution;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/************************* HELPER FUNCTIONS **************************/
|
|
169
|
-
|
|
170
146
|
/**
|
|
171
147
|
* Get adjusted column widths from existing ratios which are based on data cells room taken
|
|
172
148
|
* or based on column labels space in headers. If `recomputeAutoWidthRatios` is true or ratios
|
|
@@ -174,55 +150,48 @@ export class AutoWidthStrategy {
|
|
|
174
150
|
* ratio. Any remaining space or extra space taken is then redistributed in second pass.
|
|
175
151
|
*
|
|
176
152
|
* @param {Object} datatableInterface Interface to datatable with callbacks giving width information
|
|
177
|
-
* @param {Object}
|
|
153
|
+
* @param {Object} columns Column definitions array with defined widths and other attributes
|
|
178
154
|
* @param {Boolean} recomputeAutoWidthRatios Whether ratios should be recalculated
|
|
179
155
|
* @returns {Object} columnWidths: [], expectedTableWidth: (number)
|
|
180
156
|
*/
|
|
181
157
|
getAdjustedColumnWidths(
|
|
182
158
|
datatableInterface,
|
|
183
|
-
|
|
159
|
+
columns,
|
|
184
160
|
recomputeAutoWidthRatios
|
|
185
161
|
) {
|
|
186
|
-
const
|
|
187
|
-
this._columnWidthMetaData,
|
|
188
|
-
columnDefs
|
|
189
|
-
);
|
|
190
|
-
|
|
162
|
+
const widthsData = getTotalWidthsData(this.columnWidthData, columns);
|
|
191
163
|
const availableWidth = datatableInterface.getAvailableWidthFromDom();
|
|
192
|
-
|
|
193
|
-
let expectedTableWidth = getExpectedTableWidth(
|
|
164
|
+
const expectedTableWidth = getExpectedTableWidth(
|
|
194
165
|
availableWidth,
|
|
195
|
-
|
|
196
|
-
|
|
166
|
+
widthsData,
|
|
167
|
+
columns
|
|
197
168
|
);
|
|
198
169
|
|
|
199
|
-
this.
|
|
170
|
+
this.resetColumnWidthsDistribution();
|
|
200
171
|
|
|
201
172
|
if (recomputeAutoWidthRatios || this.columnWidthRatios.length === 0) {
|
|
202
|
-
this.
|
|
173
|
+
this.calculateColumnWidthRatios(
|
|
203
174
|
datatableInterface,
|
|
204
|
-
|
|
205
|
-
|
|
175
|
+
columns,
|
|
176
|
+
widthsData
|
|
206
177
|
);
|
|
207
178
|
}
|
|
208
179
|
|
|
209
|
-
let columnWidths = [];
|
|
210
180
|
// If the lengths don't match, return
|
|
211
181
|
if (
|
|
212
182
|
recomputeAutoWidthRatios &&
|
|
213
|
-
this.columnWidthRatios.length !==
|
|
183
|
+
this.columnWidthRatios.length !== columns.length
|
|
214
184
|
) {
|
|
215
|
-
return { expectedTableWidth, columnWidths };
|
|
185
|
+
return { expectedTableWidth, columnWidths: [] };
|
|
216
186
|
}
|
|
217
187
|
|
|
218
188
|
// First pass - Distribute widths as per ratios or defined widths if there are any
|
|
219
|
-
columnWidths = this.
|
|
189
|
+
const columnWidths = this.distributeWidthFromRatios(
|
|
220
190
|
expectedTableWidth,
|
|
221
|
-
|
|
222
|
-
|
|
191
|
+
columns,
|
|
192
|
+
widthsData
|
|
223
193
|
);
|
|
224
|
-
|
|
225
|
-
let columnWidthsSum = getTotalColumnWidth(columnWidths);
|
|
194
|
+
const columnWidthsSum = getTotalColumnWidth(columnWidths);
|
|
226
195
|
|
|
227
196
|
// Second pass - There could be excess width remaining due to clamping to `maxWidth`
|
|
228
197
|
// or we might have used more space due to clamping to `minWidth `in certain cases.
|
|
@@ -231,95 +200,94 @@ export class AutoWidthStrategy {
|
|
|
231
200
|
// We need to redistribute this space using below methods.
|
|
232
201
|
if (expectedTableWidth > columnWidthsSum) {
|
|
233
202
|
// We have more space, let's redistribute space
|
|
234
|
-
this.
|
|
203
|
+
this.redistributeExtraWidth(
|
|
235
204
|
expectedTableWidth,
|
|
236
205
|
columnWidths,
|
|
237
|
-
|
|
206
|
+
columns
|
|
238
207
|
);
|
|
239
208
|
} else if (expectedTableWidth < columnWidthsSum) {
|
|
240
209
|
// We have to take away used space
|
|
241
|
-
this.
|
|
210
|
+
this.redistributeDeficitWidth(
|
|
242
211
|
expectedTableWidth,
|
|
243
212
|
columnWidths,
|
|
244
|
-
|
|
213
|
+
columns
|
|
245
214
|
);
|
|
246
215
|
}
|
|
247
216
|
return { columnWidths, expectedTableWidth };
|
|
248
217
|
}
|
|
249
218
|
|
|
250
219
|
/**
|
|
251
|
-
* @private
|
|
252
220
|
* Calculates the ratios for each cell based on available space for a given row.
|
|
253
221
|
*
|
|
254
222
|
* @param {Array} cellWidths An array of the cell widths
|
|
255
223
|
* @param {Number} totalWidth The total available width
|
|
256
224
|
* @returns {Array} An array of cell width ratios
|
|
257
225
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
226
|
+
getRatios(cellWidths, totalWidth) {
|
|
227
|
+
const { length } = cellWidths;
|
|
228
|
+
const ratios = Array(length);
|
|
229
|
+
for (let i = 0; i < length; i += 1) {
|
|
230
|
+
ratios[i] = (100 * cellWidths[i]) / totalWidth;
|
|
231
|
+
}
|
|
232
|
+
return ratios;
|
|
262
233
|
}
|
|
263
234
|
|
|
264
235
|
/**
|
|
265
|
-
* @private
|
|
266
236
|
* Calculates and sets the column width ratios object.
|
|
267
237
|
*
|
|
268
238
|
* @param {Object} datatableInterface The datatable
|
|
269
|
-
* @param {Array}
|
|
270
|
-
* @param {Object}
|
|
239
|
+
* @param {Array} columns The column definitions
|
|
240
|
+
* @param {Object} widthsData The widths data
|
|
271
241
|
*/
|
|
272
|
-
|
|
273
|
-
datatableInterface,
|
|
274
|
-
columnDefs,
|
|
275
|
-
widthsMetadata
|
|
276
|
-
) {
|
|
242
|
+
calculateColumnWidthRatios(datatableInterface, columns, widthsData) {
|
|
277
243
|
// Take into account columns with text wrapping
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
244
|
+
const { wrapTextMaxLines } = widthsData;
|
|
245
|
+
const dataCellWidths = datatableInterface.getDataCellWidths();
|
|
246
|
+
for (
|
|
247
|
+
let colIndex = 0, { length } = dataCellWidths;
|
|
248
|
+
colIndex < length;
|
|
249
|
+
colIndex += 1
|
|
250
|
+
) {
|
|
251
|
+
const col = columns[colIndex];
|
|
252
|
+
if (col) {
|
|
253
|
+
if (col.wrapText) {
|
|
254
|
+
const width = dataCellWidths[colIndex];
|
|
255
|
+
dataCellWidths[colIndex] = width / wrapTextMaxLines;
|
|
256
|
+
} else {
|
|
257
|
+
const { fixedWidth } = col;
|
|
258
|
+
if (fixedWidth) {
|
|
259
|
+
dataCellWidths[colIndex] = fixedWidth;
|
|
288
260
|
}
|
|
289
261
|
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
this._setColumnWidthRatios(
|
|
296
|
-
tableScrollWidth,
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
this.setColumnWidthRatios(
|
|
265
|
+
datatableInterface.getTableElementWidth(),
|
|
297
266
|
dataCellWidths,
|
|
298
|
-
|
|
299
|
-
|
|
267
|
+
datatableInterface.getHeaderCellWidths(),
|
|
268
|
+
widthsData
|
|
300
269
|
);
|
|
301
270
|
}
|
|
302
271
|
|
|
303
272
|
/**
|
|
304
|
-
* @private
|
|
305
273
|
* Calculates and creates the column width ratios array.
|
|
306
274
|
*
|
|
307
275
|
* @param {Number} tableScrollWidth The width of the table that is hidden behind a hotizontal scroll
|
|
308
276
|
* @param {Array} dataCellWidths An array of the widths of the data cells
|
|
309
277
|
* @param {Array} headerCellWidths An array of the widths of the header cells
|
|
310
|
-
* @param {Object}
|
|
278
|
+
* @param {Object} widthsData The unwrapped widths data
|
|
311
279
|
*/
|
|
312
|
-
|
|
280
|
+
setColumnWidthRatios(
|
|
313
281
|
tableScrollWidth,
|
|
314
282
|
dataCellWidths,
|
|
315
283
|
headerCellWidths,
|
|
316
|
-
|
|
284
|
+
widthsData
|
|
317
285
|
) {
|
|
318
286
|
// Reset ratios
|
|
319
|
-
this.
|
|
287
|
+
this.columnWidthRatios = [];
|
|
320
288
|
|
|
321
289
|
if (tableScrollWidth > 0) {
|
|
322
|
-
const { totalFixedWidth, totalResizedWidth } =
|
|
290
|
+
const { totalFixedWidth, totalResizedWidth } = widthsData;
|
|
323
291
|
|
|
324
292
|
if (dataCellWidths.length === 0) {
|
|
325
293
|
if (headerCellWidths.length > 0) {
|
|
@@ -334,7 +302,7 @@ export class AutoWidthStrategy {
|
|
|
334
302
|
const totalFlexibleWidth =
|
|
335
303
|
totalHeaderWidth - totalFixedWidth - totalResizedWidth;
|
|
336
304
|
// Calculate ratio from header cells
|
|
337
|
-
this.
|
|
305
|
+
this.columnWidthRatios = this.getRatios(
|
|
338
306
|
headerCellWidths,
|
|
339
307
|
totalFlexibleWidth
|
|
340
308
|
);
|
|
@@ -350,7 +318,7 @@ export class AutoWidthStrategy {
|
|
|
350
318
|
totalResizedWidth;
|
|
351
319
|
|
|
352
320
|
// Calculate ratio from data cells
|
|
353
|
-
this.
|
|
321
|
+
this.columnWidthRatios = this.getRatios(
|
|
354
322
|
dataCellWidths,
|
|
355
323
|
totalFlexibleWidth
|
|
356
324
|
);
|
|
@@ -359,114 +327,103 @@ export class AutoWidthStrategy {
|
|
|
359
327
|
}
|
|
360
328
|
|
|
361
329
|
/**
|
|
362
|
-
* @private
|
|
363
330
|
* Resets the column width distribution.
|
|
364
331
|
*/
|
|
365
|
-
|
|
332
|
+
resetColumnWidthsDistribution() {
|
|
366
333
|
this.columnWidthsDistribution.colsWithMinWidth = [];
|
|
367
334
|
this.columnWidthsDistribution.colsWithMaxWidth = [];
|
|
368
335
|
}
|
|
369
336
|
|
|
370
337
|
/**
|
|
371
|
-
* @private
|
|
372
338
|
* Allocates width to a column as per defined width or as per ratio.
|
|
373
339
|
*
|
|
374
340
|
* @param {Number} availableWidth Available width for the table
|
|
375
|
-
* @param {Object}
|
|
376
|
-
* @param {Object}
|
|
341
|
+
* @param {Object} columns Column definitions in state
|
|
342
|
+
* @param {Object} widthsData Metadata regarding widths includes `max`, `min`, `flexiblewidth`, `fixedwidth`
|
|
377
343
|
*/
|
|
378
|
-
|
|
344
|
+
distributeWidthFromRatios(availableWidth, columns, widthsData) {
|
|
379
345
|
const columnWidths = [];
|
|
380
|
-
|
|
346
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
347
|
+
const col = columns[colIndex];
|
|
381
348
|
const width =
|
|
382
|
-
|
|
383
|
-
this.
|
|
349
|
+
getColumnWidth(col) ||
|
|
350
|
+
this.getColumnWidthFromRatio(
|
|
384
351
|
availableWidth,
|
|
385
|
-
|
|
352
|
+
widthsData,
|
|
386
353
|
colIndex
|
|
387
354
|
);
|
|
388
355
|
columnWidths[colIndex] = width;
|
|
389
|
-
}
|
|
356
|
+
}
|
|
390
357
|
return columnWidths;
|
|
391
358
|
}
|
|
392
359
|
|
|
393
360
|
/**
|
|
394
|
-
* @private
|
|
395
361
|
* Calculates column width of a given column from the ratio.
|
|
396
362
|
* Clamps to `minColWidth` and `maxColWidth`.
|
|
397
363
|
* Also sets housekeeping data for `colsWithMaxWidth` threshold and `colsWithMinWidth` threshold.
|
|
398
364
|
*
|
|
399
365
|
* @param {Number} availableWidth Available width for the table
|
|
400
|
-
* @param {Object}
|
|
366
|
+
* @param {Object} widthsData Metadata regarding widths includes max, min, flexiblewidth, fixedwidth
|
|
401
367
|
* @param {Number} colIndex Column number
|
|
402
368
|
*/
|
|
403
|
-
|
|
404
|
-
const ratios = this.columnWidthRatios;
|
|
405
|
-
const { colsWithMinWidth, colsWithMaxWidth } =
|
|
406
|
-
this.columnWidthsDistribution;
|
|
369
|
+
getColumnWidthFromRatio(availableWidth, widthsData, colIndex) {
|
|
407
370
|
const {
|
|
408
371
|
totalFixedWidth,
|
|
409
372
|
totalResizedWidth,
|
|
410
373
|
minColumnWidth,
|
|
411
374
|
maxColumnWidth,
|
|
412
|
-
} =
|
|
375
|
+
} = widthsData;
|
|
376
|
+
const widthRatio = this.columnWidthRatios[colIndex];
|
|
413
377
|
const totalFlexibleWidth =
|
|
414
378
|
availableWidth - totalFixedWidth - totalResizedWidth;
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
calculatedWidth = calculatedWidth + TRUNCATION_ALLOWANCE;
|
|
421
|
-
|
|
379
|
+
const calculatedWidth =
|
|
380
|
+
Math.floor((totalFlexibleWidth * widthRatio) / 100) +
|
|
381
|
+
TRUNCATION_ALLOWANCE;
|
|
382
|
+
const { colsWithMinWidth, colsWithMaxWidth } =
|
|
383
|
+
this.columnWidthsDistribution;
|
|
422
384
|
const minWidthThreshold =
|
|
423
385
|
minColumnWidth + Math.ceil(MIN_MAX_THRESHOLD * minColumnWidth);
|
|
424
|
-
const maxWidthThreshold =
|
|
425
|
-
maxColumnWidth - Math.ceil(MIN_MAX_THRESHOLD * maxColumnWidth);
|
|
426
|
-
|
|
427
386
|
if (calculatedWidth < minWidthThreshold) {
|
|
428
387
|
colsWithMinWidth.push(colIndex);
|
|
429
388
|
}
|
|
430
|
-
|
|
389
|
+
const maxWidthThreshold =
|
|
390
|
+
maxColumnWidth - Math.ceil(MIN_MAX_THRESHOLD * maxColumnWidth);
|
|
431
391
|
if (calculatedWidth > maxWidthThreshold) {
|
|
432
392
|
colsWithMaxWidth.push(colIndex);
|
|
433
393
|
}
|
|
434
|
-
|
|
435
394
|
return clamp(calculatedWidth, minColumnWidth, maxColumnWidth);
|
|
436
395
|
}
|
|
437
396
|
|
|
438
397
|
/**
|
|
439
|
-
* @private
|
|
440
398
|
* This method gives extra width that was remaining by first giving width to columns with
|
|
441
399
|
* max width or within threshold of max width then by giving from all columns possible,
|
|
442
400
|
* excluding fixed width columns, columns that can become max width after redistribution.
|
|
443
401
|
*
|
|
444
402
|
* @param {Number} expectedTableWidth Width taken by the table in the DOM
|
|
445
403
|
* @param {Array} columnWidths Column widths array
|
|
446
|
-
* @param {Object}
|
|
404
|
+
* @param {Object} columns Column definitions from state
|
|
447
405
|
*/
|
|
448
|
-
|
|
406
|
+
redistributeExtraWidth(expectedTableWidth, columnWidths, columns) {
|
|
449
407
|
const { colsWithMinWidth } = this.columnWidthsDistribution;
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
this._columnWidthMetaData,
|
|
453
|
-
columnDefs
|
|
454
|
-
);
|
|
408
|
+
const { length: colsWithMinWidthLength } = colsWithMinWidth;
|
|
409
|
+
const widthsData = getTotalWidthsData(this.columnWidthData, columns);
|
|
455
410
|
const { maxColumnWidth, totalResizedColumns, totalFixedColumns } =
|
|
456
|
-
|
|
411
|
+
widthsData;
|
|
457
412
|
|
|
458
413
|
let columnWidthsSum = getTotalColumnWidth(columnWidths);
|
|
459
|
-
let extraSpace =
|
|
460
|
-
let totalColsToDistribute = 0;
|
|
414
|
+
let extraSpace = 0;
|
|
461
415
|
let extraWidthPerColumn = 0;
|
|
416
|
+
let totalColsToDistribute = 0;
|
|
462
417
|
|
|
463
418
|
// First distribute space to columns with min width or threshold of min width
|
|
464
|
-
if (
|
|
465
|
-
|
|
419
|
+
if (colsWithMinWidthLength > 0) {
|
|
420
|
+
extraSpace = expectedTableWidth - columnWidthsSum;
|
|
421
|
+
totalColsToDistribute = colsWithMinWidthLength;
|
|
466
422
|
extraWidthPerColumn = Math.floor(
|
|
467
423
|
extraSpace / totalColsToDistribute
|
|
468
424
|
);
|
|
469
|
-
|
|
425
|
+
for (let i = 0; i < colsWithMinWidthLength; i += 1) {
|
|
426
|
+
const colIndex = colsWithMinWidth[i];
|
|
470
427
|
const currentWidth = columnWidths[colIndex];
|
|
471
428
|
if (
|
|
472
429
|
canAddWidth(
|
|
@@ -479,26 +436,28 @@ export class AutoWidthStrategy {
|
|
|
479
436
|
columnWidthsSum += extraWidthPerColumn;
|
|
480
437
|
columnWidths[colIndex] = newWidth;
|
|
481
438
|
}
|
|
482
|
-
}
|
|
439
|
+
}
|
|
483
440
|
}
|
|
484
441
|
|
|
485
442
|
extraSpace = expectedTableWidth - columnWidthsSum;
|
|
486
|
-
const totalFixedWidthColumns = totalResizedColumns + totalFixedColumns;
|
|
487
443
|
|
|
488
444
|
// Now distribute to every column possible excluding columns with defined widths
|
|
489
445
|
// after this distribution its still possible we might have more space remaining
|
|
490
446
|
// since we couldn't add widths to majority of columns.
|
|
491
447
|
if (extraSpace > 0) {
|
|
492
|
-
|
|
448
|
+
const totalFixedWidthColumns =
|
|
449
|
+
totalResizedColumns + totalFixedColumns;
|
|
450
|
+
const { length: colCount } = columns;
|
|
493
451
|
|
|
452
|
+
totalColsToDistribute = colCount - totalFixedWidthColumns;
|
|
494
453
|
extraWidthPerColumn = Math.floor(
|
|
495
454
|
extraSpace / totalColsToDistribute
|
|
496
455
|
);
|
|
497
|
-
|
|
456
|
+
for (let colIndex = 0; colIndex < colCount; colIndex += 1) {
|
|
457
|
+
const col = columns[colIndex];
|
|
498
458
|
const currentWidth = columnWidths[colIndex];
|
|
499
|
-
|
|
500
459
|
if (
|
|
501
|
-
!
|
|
460
|
+
!getColumnWidth(col) &&
|
|
502
461
|
canAddWidth(
|
|
503
462
|
currentWidth,
|
|
504
463
|
extraWidthPerColumn,
|
|
@@ -509,29 +468,25 @@ export class AutoWidthStrategy {
|
|
|
509
468
|
columnWidthsSum += extraWidthPerColumn;
|
|
510
469
|
columnWidths[colIndex] = newWidth;
|
|
511
470
|
}
|
|
512
|
-
}
|
|
471
|
+
}
|
|
513
472
|
}
|
|
514
473
|
}
|
|
515
474
|
|
|
516
475
|
/**
|
|
517
|
-
* @private
|
|
518
476
|
* This method removes extra space that was taken by first taking away width from columns with
|
|
519
477
|
* max width or within threshold of max width then by taking away from all columns possible,
|
|
520
478
|
* excluding fixed width columns, column with min width or can become min width after taking away.
|
|
521
479
|
*
|
|
522
480
|
* @param {Number} expectedTableWidth Width taken by the table in the DOM
|
|
523
481
|
* @param {Array} columnWidths Column widths array
|
|
524
|
-
* @param {Object}
|
|
482
|
+
* @param {Object} columns Column definitions from state
|
|
525
483
|
*/
|
|
526
|
-
|
|
527
|
-
const {
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
this._columnWidthMetaData,
|
|
531
|
-
columnDefs
|
|
532
|
-
);
|
|
484
|
+
redistributeDeficitWidth(expectedTableWidth, columnWidths, columns) {
|
|
485
|
+
const { colsWithMaxWidth } = this.columnWidthsDistribution;
|
|
486
|
+
const { length: colsWithMaxWidthLength } = colsWithMaxWidth;
|
|
487
|
+
const widthsData = getTotalWidthsData(this.columnWidthData, columns);
|
|
533
488
|
const { minColumnWidth, totalResizedColumns, totalFixedColumns } =
|
|
534
|
-
|
|
489
|
+
widthsData;
|
|
535
490
|
|
|
536
491
|
let columnWidthsSum = getTotalColumnWidth(columnWidths);
|
|
537
492
|
let extraSpace = expectedTableWidth - columnWidthsSum;
|
|
@@ -539,14 +494,14 @@ export class AutoWidthStrategy {
|
|
|
539
494
|
let extraWidthPerColumn = 0;
|
|
540
495
|
|
|
541
496
|
// First take away width from columns with max width or threshold of max width
|
|
542
|
-
if (
|
|
543
|
-
totalColsToDistribute =
|
|
497
|
+
if (colsWithMaxWidthLength > 0) {
|
|
498
|
+
totalColsToDistribute = colsWithMaxWidthLength;
|
|
544
499
|
extraWidthPerColumn = Math.floor(
|
|
545
500
|
Math.abs(extraSpace) / totalColsToDistribute
|
|
546
501
|
);
|
|
547
|
-
|
|
502
|
+
for (let i = 0, { length } = colsWithMaxWidth; i < length; i += 1) {
|
|
503
|
+
const colIndex = colsWithMaxWidth[i];
|
|
548
504
|
const currentWidth = columnWidths[colIndex];
|
|
549
|
-
|
|
550
505
|
if (
|
|
551
506
|
canRemoveWidth(
|
|
552
507
|
currentWidth,
|
|
@@ -558,7 +513,7 @@ export class AutoWidthStrategy {
|
|
|
558
513
|
columnWidthsSum -= extraWidthPerColumn;
|
|
559
514
|
columnWidths[colIndex] = newWidth;
|
|
560
515
|
}
|
|
561
|
-
}
|
|
516
|
+
}
|
|
562
517
|
}
|
|
563
518
|
|
|
564
519
|
extraSpace = expectedTableWidth - columnWidthsSum;
|
|
@@ -567,20 +522,21 @@ export class AutoWidthStrategy {
|
|
|
567
522
|
// Now from every column possible excluding columns with defined widths
|
|
568
523
|
// and excluding columns within minWidthThreshold
|
|
569
524
|
// after this distribution its still possible we might have used more space
|
|
570
|
-
// since we
|
|
525
|
+
// since we couldn't take away widths from majority of columns
|
|
571
526
|
if (extraSpace < 0) {
|
|
527
|
+
const { colsWithMinWidth } = this.columnWidthsDistribution;
|
|
572
528
|
totalColsToDistribute =
|
|
573
|
-
|
|
529
|
+
columns.length -
|
|
574
530
|
(totalFixedWidthColumns + colsWithMinWidth.length);
|
|
575
531
|
extraWidthPerColumn = Math.floor(
|
|
576
532
|
Math.abs(extraSpace) / totalColsToDistribute
|
|
577
533
|
);
|
|
578
|
-
|
|
534
|
+
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
535
|
+
const col = columns[colIndex];
|
|
579
536
|
const currentWidth = columnWidths[colIndex];
|
|
580
|
-
|
|
581
537
|
if (
|
|
582
|
-
!getColumnWidthFromDef(column) &&
|
|
583
538
|
!hasColumn(colsWithMinWidth, colIndex) &&
|
|
539
|
+
!getColumnWidth(col) &&
|
|
584
540
|
canRemoveWidth(
|
|
585
541
|
currentWidth,
|
|
586
542
|
extraWidthPerColumn,
|
|
@@ -591,7 +547,7 @@ export class AutoWidthStrategy {
|
|
|
591
547
|
columnWidthsSum -= extraWidthPerColumn;
|
|
592
548
|
columnWidths[colIndex] = newWidth;
|
|
593
549
|
}
|
|
594
|
-
}
|
|
550
|
+
}
|
|
595
551
|
}
|
|
596
552
|
}
|
|
597
553
|
}
|