lightning-base-components 1.21.3-alpha → 1.21.4-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 +88 -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.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/avatar/avatar.html +1 -0
- package/src/lightning/badge/badge.html +3 -3
- package/src/lightning/baseCombobox/baseCombobox.html +4 -1
- package/src/lightning/baseCombobox/baseCombobox.js +3 -16
- package/src/lightning/button/__docs__/button.md +2 -1
- package/src/lightning/button/button.js +3 -4
- package/src/lightning/buttonIcon/__docs__/buttonIcon.md +1 -0
- package/src/lightning/buttonIcon/buttonIcon.html +1 -1
- package/src/lightning/buttonIcon/buttonIcon.js +18 -17
- package/src/lightning/buttonMenu/buttonMenu.css +5 -0
- package/src/lightning/buttonMenu/buttonMenu.js +2 -0
- package/src/lightning/colorPickerCustom/colorPickerCustom.js +12 -0
- package/src/lightning/colorPickerPanel/colorPickerPanel.js +11 -1
- 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 +455 -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 +125 -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 +49 -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/dualListbox.js +7 -8
- package/src/lightning/formattedName/formattedName.js +3 -2
- package/src/lightning/formattedName/formattedName.js-meta.xml +3 -0
- package/src/lightning/formattedNumber/formattedNumber.js +3 -2
- package/src/lightning/formattedNumber/formattedNumber.js-meta.xml +3 -0
- package/src/lightning/formattedRichText/richTextConfig.js +1 -0
- package/src/lightning/helptext/helptext.css +7 -0
- package/src/lightning/helptext/helptext.js +3 -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 +74 -3
- package/src/lightning/internationalizationLibrary/address/AddressFormat.js +553 -610
- package/src/lightning/lookupAddress/lookupAddress.html +6 -1
- package/src/lightning/lookupAddress/lookupAddress.js +25 -0
- 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 +131 -146
- 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/link.html +1 -0
- package/src/lightning/pill/plain.html +1 -0
- package/src/lightning/pill/plainLink.html +1 -0
- 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/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/staticMap/staticMap.js +3 -2
- 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/tabset.html +2 -0
- package/src/lightning/tabset/tabset.js-meta.xml +3 -0
- package/src/lightning/textarea/textarea.js +6 -1
- package/src/lightning/toastContainer/__docs__/toastContainer.md +3 -2
- package/src/lightning/tooltipLibrary/tooltipLibrary.js +24 -15
- 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/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/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/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
|
@@ -95,6 +95,18 @@ export default class LightningColorPickerCustom extends LightningShadowBaseClass
|
|
|
95
95
|
this._currentColor = value;
|
|
96
96
|
this._hex = fullHex;
|
|
97
97
|
this._rgb = hexToRgb(fullHex);
|
|
98
|
+
|
|
99
|
+
// W-13851481 bug-fix: if canvas open, update it
|
|
100
|
+
if (this._canvas) {
|
|
101
|
+
const hue = rgbToHsl(this._rgb).hue;
|
|
102
|
+
const position = this.rgbToPosition(this._rgb);
|
|
103
|
+
const selectedColor = `#${rgbToHex(this._rgb)}`;
|
|
104
|
+
|
|
105
|
+
this.updateRainbow(hue);
|
|
106
|
+
this.setCanvasColor(hue);
|
|
107
|
+
this.setCanvasCursor(position.x, position.y);
|
|
108
|
+
this.updateSelectedColor(selectedColor);
|
|
109
|
+
}
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
@api
|
|
@@ -5,7 +5,7 @@ import labelDoneButton from '@salesforce/label/LightningColorPicker.doneButton';
|
|
|
5
5
|
import { api, track } from 'lwc';
|
|
6
6
|
import LightningShadowBaseClass from 'lightning/shadowBaseClassPrivate';
|
|
7
7
|
import { classSet } from 'lightning/utils';
|
|
8
|
-
import { keyCodes } from 'lightning/utilsPrivate';
|
|
8
|
+
import { keyCodes, isCSR } from 'lightning/utilsPrivate';
|
|
9
9
|
|
|
10
10
|
const i18n = {
|
|
11
11
|
cancelButton: labelCancelButton,
|
|
@@ -26,6 +26,16 @@ export default class LightningColorPickerPanel extends LightningShadowBaseClass
|
|
|
26
26
|
this._selectedColor = this.currentColor || DEFAULT_COLOR;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
renderedCallback() {
|
|
30
|
+
// W-14600421 bug fix: prevent panel from falling outside user focus,
|
|
31
|
+
// like when viewports are too small
|
|
32
|
+
if (isCSR && typeof document.body.scrollIntoView === 'function') {
|
|
33
|
+
this.template
|
|
34
|
+
.querySelector('lightning-color-picker-custom')
|
|
35
|
+
.scrollIntoView();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
get i18n() {
|
|
30
40
|
return i18n;
|
|
31
41
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- Move this component to __examples__ -->
|
|
3
|
+
<!-- In playground add <datatable-custom-component-wrapper></datatable-custom-component-wrapper> -->
|
|
4
|
+
<datatable-my-custom-type-datatable
|
|
5
|
+
key-field="Id"
|
|
6
|
+
data={data}
|
|
7
|
+
columns={columns}
|
|
8
|
+
show-row-number-column
|
|
9
|
+
>
|
|
10
|
+
</datatable-my-custom-type-datatable>
|
|
11
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LightningElement } from 'lwc';
|
|
2
|
+
import generateData from './generateData.js';
|
|
3
|
+
const columns = [
|
|
4
|
+
{
|
|
5
|
+
label: 'Custom input',
|
|
6
|
+
type: 'customInput',
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
label: 'Custom Component Buttons',
|
|
10
|
+
type: 'customComponent',
|
|
11
|
+
},
|
|
12
|
+
{ label: 'Label', fieldName: 'name' },
|
|
13
|
+
{ label: 'Website', fieldName: 'website', type: 'url' },
|
|
14
|
+
{ label: 'Phone', fieldName: 'phone', type: 'phone' },
|
|
15
|
+
{ label: 'Balance', fieldName: 'amount', type: 'currency' },
|
|
16
|
+
];
|
|
17
|
+
export default class MyDatatable extends LightningElement {
|
|
18
|
+
data = [];
|
|
19
|
+
columns = columns;
|
|
20
|
+
rowOffset = 0;
|
|
21
|
+
|
|
22
|
+
connectedCallback() {
|
|
23
|
+
this.data = generateData({ amountOfRecords: 5 });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default function generateData({ amountOfRecords }) {
|
|
2
|
+
return [...Array(amountOfRecords)].map((_, index) => {
|
|
3
|
+
return {
|
|
4
|
+
name: `Name (${index})`,
|
|
5
|
+
website: 'www.salesforce.com',
|
|
6
|
+
amount: Math.floor(Math.random() * 100),
|
|
7
|
+
phone: `${
|
|
8
|
+
Math.floor(Math.random() * 900 + 100) * 10000000 + 5551212
|
|
9
|
+
}`,
|
|
10
|
+
closeAt: new Date(
|
|
11
|
+
Date.now() + 86400000 * Math.ceil(Math.random() * 20)
|
|
12
|
+
),
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
}
|
package/src/lightning/datatable/__examples__disabled/myCustomTypeDatatable/myCustomTypeDatatable.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//myCustomTypeDatatable.js
|
|
2
|
+
import LightningDatatable from 'lightning/datatable';
|
|
3
|
+
import customInputTemplate from './customInput.html';
|
|
4
|
+
import customComponentTemplate from './nestedSimpleComponentParent.html';
|
|
5
|
+
|
|
6
|
+
export default class MyCustomTypeDatatable extends LightningDatatable {
|
|
7
|
+
static customTypes = {
|
|
8
|
+
customInput: {
|
|
9
|
+
template: customInputTemplate,
|
|
10
|
+
standardCellLayout: true,
|
|
11
|
+
},
|
|
12
|
+
customComponent: {
|
|
13
|
+
template: customComponentTemplate,
|
|
14
|
+
standardCellLayout: false,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- We add an internal component here so that we can garner access to a full LWC component including access to a JS file. -->
|
|
3
|
+
<!-- This is common if a custom component needs some kind of wiring up. -->
|
|
4
|
+
<!-- We pass tabindex down as we don't want this component to be shown as accessible in the dom, but we want children of it to be -->
|
|
5
|
+
<!-- We set data-navigation here as this component has children that are navigable -->
|
|
6
|
+
<datatable-simple-component-nested internal-tab-index={internalTabIndex} data-navigation="enable"></datatable-simple-component-nested>
|
|
7
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- We don't need to set data-navigation on this div as we are not traversing a shadowroot -->
|
|
3
|
+
<div>
|
|
4
|
+
<!-- Since this component needs to be navigable we set data-navigation to enable navigation. -->
|
|
5
|
+
<!-- As it is navigable we also need to set the tabindex=0 so that from a dom structure perspective it shows as navgiable. -->
|
|
6
|
+
<lightning-button variant="base" label="Base" title="Looks like a link" class="slds-m-left_x-small" data-navigation="enable" tabindex={internalTabIndex}></lightning-button>
|
|
7
|
+
<lightning-button label="Neutral" title="Non-primary action" class="slds-m-left_x-small" data-navigation="enable" tabindex={internalTabIndex}></lightning-button>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
@@ -4,17 +4,6 @@ import { getColumnWidth, getTotalWidthsData } from './widthManagerShared';
|
|
|
4
4
|
const MIN_MAX_THRESHOLD = 0.5;
|
|
5
5
|
const TRUNCATION_ALLOWANCE = 20;
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Determines if a column exists at a specified index
|
|
9
|
-
*
|
|
10
|
-
* @param {Array} columns An array of columns
|
|
11
|
-
* @param {Integer} colIndex The column index to locate
|
|
12
|
-
* @returns {Boolean} Whether the column exists at the specified index
|
|
13
|
-
*/
|
|
14
|
-
function hasColumn(columns, colIndex) {
|
|
15
|
-
return columns.some((current) => current === colIndex);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
7
|
/**
|
|
19
8
|
* Calculates the total width of all columns
|
|
20
9
|
*
|
|
@@ -61,34 +50,21 @@ function canAddWidth(currentWidth, widthToAdd, maxColumnWidth) {
|
|
|
61
50
|
* @returns {Number} The expected width of the table
|
|
62
51
|
*/
|
|
63
52
|
function getExpectedTableWidth(availableWidth, widthsData) {
|
|
64
|
-
const minExpectedTableWidth = getMinExpectedTableWidth(widthsData);
|
|
65
|
-
return widthsData.totalFlexibleColumns === 0
|
|
66
|
-
? minExpectedTableWidth
|
|
67
|
-
: Math.max(minExpectedTableWidth, availableWidth);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Determines the minimum expected table width
|
|
72
|
-
*
|
|
73
|
-
* @param {Object} widthsData The widths data
|
|
74
|
-
* @returns {Number} The minimum expected table width
|
|
75
|
-
*/
|
|
76
|
-
function getMinExpectedTableWidth(widthsData) {
|
|
77
53
|
const minTotalFlexibleWidth =
|
|
78
54
|
widthsData.totalFlexibleColumns * widthsData.minColumnWidth;
|
|
79
|
-
|
|
55
|
+
const minExpectedTableWidth =
|
|
80
56
|
minTotalFlexibleWidth +
|
|
81
57
|
widthsData.totalFixedWidth +
|
|
82
|
-
widthsData.totalResizedWidth
|
|
83
|
-
|
|
58
|
+
widthsData.totalResizedWidth;
|
|
59
|
+
return widthsData.totalFlexibleColumns === 0
|
|
60
|
+
? minExpectedTableWidth
|
|
61
|
+
: Math.max(minExpectedTableWidth, availableWidth);
|
|
84
62
|
}
|
|
85
63
|
|
|
86
64
|
/**
|
|
87
65
|
* Strategy for columns that automatically determine their widths.
|
|
88
66
|
*/
|
|
89
67
|
export class AutoWidthStrategy {
|
|
90
|
-
// Private variables
|
|
91
|
-
|
|
92
68
|
// Instance array to hold column width ratios either calculated from visual distribution of column labels
|
|
93
69
|
// or from distribution of data amongst the columns. These ratios are reused except when datatable reacts
|
|
94
70
|
// to changes in data or columns and other variables at which point they are recalculated.
|
|
@@ -102,8 +78,6 @@ export class AutoWidthStrategy {
|
|
|
102
78
|
// It is used in redistribution of extra space that is left or taken up while calculating auto widths
|
|
103
79
|
columnWidthsDistribution = {};
|
|
104
80
|
|
|
105
|
-
/************************** LIFECYCLE HOOKS **************************/
|
|
106
|
-
|
|
107
81
|
constructor(minColumnWidth, maxColumnWidth, wrapTextMaxLines = 3) {
|
|
108
82
|
this.columnWidthData = {
|
|
109
83
|
minColumnWidth,
|
|
@@ -114,8 +88,6 @@ export class AutoWidthStrategy {
|
|
|
114
88
|
this.columnWidthsDistribution.colsWithMaxWidth = [];
|
|
115
89
|
}
|
|
116
90
|
|
|
117
|
-
/************************** PRIVATE SETTERS **************************/
|
|
118
|
-
|
|
119
91
|
/**
|
|
120
92
|
* Sets the minimum column width
|
|
121
93
|
*
|
|
@@ -182,7 +154,7 @@ export class AutoWidthStrategy {
|
|
|
182
154
|
recomputeAutoWidthRatios &&
|
|
183
155
|
this.columnWidthRatios.length !== columns.length
|
|
184
156
|
) {
|
|
185
|
-
return {
|
|
157
|
+
return { columnWidths: [] };
|
|
186
158
|
}
|
|
187
159
|
|
|
188
160
|
// First pass - Distribute widths as per ratios or defined widths if there are any
|
|
@@ -213,7 +185,7 @@ export class AutoWidthStrategy {
|
|
|
213
185
|
columns
|
|
214
186
|
);
|
|
215
187
|
}
|
|
216
|
-
return { columnWidths
|
|
188
|
+
return { columnWidths };
|
|
217
189
|
}
|
|
218
190
|
|
|
219
191
|
/**
|
|
@@ -535,7 +507,7 @@ export class AutoWidthStrategy {
|
|
|
535
507
|
const col = columns[colIndex];
|
|
536
508
|
const currentWidth = columnWidths[colIndex];
|
|
537
509
|
if (
|
|
538
|
-
!
|
|
510
|
+
!colsWithMinWidth.includes(colIndex) &&
|
|
539
511
|
!getColumnWidth(col) &&
|
|
540
512
|
canRemoveWidth(
|
|
541
513
|
currentWidth,
|
|
@@ -1,119 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { clamp, normalizeNumberAttribute } from './utils';
|
|
4
|
-
import { buildCSSWidthStyle } from './widthManagerShared';
|
|
1
|
+
import { isRTL, normalizeBoolean } from 'lightning/utilsPrivate';
|
|
2
|
+
import { clamp, getScrollerY, normalizeNumberAttribute } from './utils';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
|
-
* Returns the default state/values of the resizer metadata
|
|
5
|
+
* Returns the default state/values of the resizer metadata.
|
|
6
|
+
*
|
|
8
7
|
* @returns {Object} - resizer default state
|
|
9
8
|
*/
|
|
10
9
|
export function getResizerDefaultState() {
|
|
11
10
|
return {
|
|
11
|
+
columnWidths: [],
|
|
12
|
+
columnWidthsMode: 'fixed',
|
|
13
|
+
maxColumnWidth: 1000,
|
|
14
|
+
minColumnWidth: 50,
|
|
12
15
|
resizeColumnDisabled: false,
|
|
13
16
|
resizeStep: 10,
|
|
14
|
-
columnWidths: [],
|
|
15
17
|
tableWidth: 0,
|
|
16
|
-
minColumnWidth: 50,
|
|
17
|
-
maxColumnWidth: 1000,
|
|
18
|
-
columnWidthsMode: 'fixed',
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
export const RESIZER_DEFAULT_STATE = getResizerDefaultState();
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
/***************** GETTERS / SETTERS *****************/
|
|
25
24
|
|
|
26
|
-
export function isResizeColumnDisabled(widthsData) {
|
|
27
|
-
return widthsData.resizeColumnDisabled;
|
|
28
|
-
}
|
|
29
25
|
export function setResizeColumnDisabled(widthsData, value) {
|
|
26
|
+
// Untracked state change.
|
|
30
27
|
widthsData.resizeColumnDisabled = normalizeBoolean(value);
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
/************* resizeStep *************/
|
|
34
|
-
|
|
35
|
-
export function getResizeStep(widthsData) {
|
|
36
|
-
return widthsData.resizeStep;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
30
|
export function setResizeStep(widthsData, value) {
|
|
31
|
+
// Tracked state change.
|
|
40
32
|
widthsData.resizeStep = normalizeNumberAttribute(
|
|
41
33
|
'resizeStep',
|
|
42
34
|
value,
|
|
43
35
|
'non-negative',
|
|
44
|
-
|
|
36
|
+
RESIZER_DEFAULT_STATE.resizeStep
|
|
45
37
|
);
|
|
46
38
|
}
|
|
47
39
|
|
|
48
|
-
/************* columnWidths *************/
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Returns the columnsWidths saved in the state
|
|
52
|
-
* @param {object} widthsData - data regarding column and table widths
|
|
53
|
-
* @returns {Array|*} - list of column widths
|
|
54
|
-
*/
|
|
55
|
-
export function getColumnsWidths(widthsData) {
|
|
56
|
-
return widthsData.columnWidths;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Sets columnWidths to empty array
|
|
60
|
-
* @param {object} widthsData - data regarding column and table widths
|
|
61
|
-
*/
|
|
62
|
-
export function resetColumnWidths(widthsData) {
|
|
63
|
-
widthsData.columnWidths = [];
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Returns true if there are widths stored in the state
|
|
67
|
-
* @param {object} widthsData - data regarding column and table widths
|
|
68
|
-
* @returns {boolean} - true if there are widths store in the state
|
|
69
|
-
*/
|
|
70
|
-
export function hasDefinedColumnsWidths(widthsData) {
|
|
71
|
-
return widthsData.columnWidths.length > 0;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/************* tableWidth *************/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get the full width of table
|
|
78
|
-
* @param {object} widthsData - data regarding column and table widths
|
|
79
|
-
* @returns {number} - table's width
|
|
80
|
-
*/
|
|
81
|
-
function getTableWidth(widthsData) {
|
|
82
|
-
return widthsData.tableWidth;
|
|
83
|
-
}
|
|
84
|
-
function setTableWidth(widthsData, tableWidth) {
|
|
85
|
-
widthsData.tableWidth = tableWidth;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/************* minColumnWidth *************/
|
|
89
|
-
|
|
90
|
-
export function getMinColumnWidth(widthsData) {
|
|
91
|
-
return widthsData.minColumnWidth;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
40
|
export function setMinColumnWidth(columns, widthsData, value) {
|
|
41
|
+
// Untracked state changes.
|
|
95
42
|
widthsData.minColumnWidth = normalizeNumberAttribute(
|
|
96
43
|
'minColumnWidth',
|
|
97
44
|
value,
|
|
98
45
|
'non-negative',
|
|
99
|
-
|
|
46
|
+
RESIZER_DEFAULT_STATE.minColumnWidth
|
|
100
47
|
);
|
|
101
48
|
// Tracked state change.
|
|
102
49
|
updateColumnWidthsMetadata(columns, widthsData);
|
|
103
50
|
}
|
|
104
51
|
|
|
105
|
-
/************* maxColumnWidth *************/
|
|
106
|
-
|
|
107
|
-
export function getMaxColumnWidth(widthsData) {
|
|
108
|
-
return widthsData.maxColumnWidth;
|
|
109
|
-
}
|
|
110
52
|
export function setMaxColumnWidth(columns, widthsData, value) {
|
|
111
53
|
// Untracked state change.
|
|
112
54
|
widthsData.maxColumnWidth = normalizeNumberAttribute(
|
|
113
55
|
'maxColumnWidth',
|
|
114
56
|
value,
|
|
115
57
|
'non-negative',
|
|
116
|
-
|
|
58
|
+
RESIZER_DEFAULT_STATE.maxColumnWidth
|
|
117
59
|
);
|
|
118
60
|
// Tracked state change.
|
|
119
61
|
updateColumnWidthsMetadata(columns, widthsData);
|
|
@@ -122,93 +64,61 @@ export function setMaxColumnWidth(columns, widthsData, value) {
|
|
|
122
64
|
/***************************** RESIZE LOGIC *****************************/
|
|
123
65
|
|
|
124
66
|
/**
|
|
125
|
-
*
|
|
126
|
-
* @param {object} widthsData - data regarding column and table widths
|
|
127
|
-
* @returns {string} - style string
|
|
128
|
-
*/
|
|
129
|
-
export function getCSSWidthStyleOfTable(widthsData) {
|
|
130
|
-
return buildCSSWidthStyle(getTableWidth(widthsData));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* - It adjusts the columns widths from the state
|
|
135
|
-
* - It is used when there are columnwidths in state but the table is hidden with offsetwidth 0
|
|
136
|
-
* - In this case we reset the columns to the width in state
|
|
67
|
+
* Resizes a column width.
|
|
137
68
|
*
|
|
138
|
-
* @param {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
let columnsWidthSum = 0;
|
|
143
|
-
const columns = getColumns(state);
|
|
144
|
-
for (let i = 0, { length } = columns; i < length; i += 1) {
|
|
145
|
-
const width = columnsWidths[i];
|
|
146
|
-
if (width !== undefined) {
|
|
147
|
-
const col = columns[i];
|
|
148
|
-
if (isRTL()) {
|
|
149
|
-
col.offset = columnsWidthSum;
|
|
150
|
-
}
|
|
151
|
-
columnsWidthSum += width;
|
|
152
|
-
col.columnWidth = width;
|
|
153
|
-
col.style = buildCSSWidthStyle(width);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
setTableWidth(state, columnsWidthSum);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Resizes a column width
|
|
161
|
-
* @param {object} columns - all columns on the table
|
|
162
|
-
* @param {object} widthsData - object containing the resizer metadata
|
|
163
|
-
* @param {number} colIndex - the index of the column based on state.columns
|
|
164
|
-
* @param {number} width - the new width is gonna be applied
|
|
69
|
+
* @param {Object} columns - The column definitions
|
|
70
|
+
* @param {Object} widthsData - The widths data
|
|
71
|
+
* @param {number} colIndex - The index of the column based on state.columns
|
|
72
|
+
* @param {number} width - The new width is gonna be applied
|
|
165
73
|
*/
|
|
166
74
|
export function resizeColumn(columns, widthsData, colIndex, width) {
|
|
167
75
|
const col = columns[colIndex];
|
|
168
|
-
const columnWidths =
|
|
76
|
+
const { columnWidths } = widthsData;
|
|
169
77
|
const currentWidth = columnWidths[colIndex];
|
|
170
78
|
const { minWidth, maxWidth } = col;
|
|
171
79
|
const newWidth = clamp(width, minWidth, maxWidth);
|
|
172
80
|
if (currentWidth !== newWidth) {
|
|
173
81
|
const newDelta = newWidth - currentWidth;
|
|
174
|
-
|
|
175
|
-
|
|
82
|
+
// Untracked state changes.
|
|
83
|
+
columnWidths[colIndex] = newWidth;
|
|
84
|
+
widthsData.tableWidth += newDelta;
|
|
85
|
+
// Tracked state changes.
|
|
86
|
+
col.columnWidth = newWidth;
|
|
87
|
+
col.style = newWidth ? `width: ${newWidth}px;` : '';
|
|
176
88
|
// Workaround for header positioning issues in RTL
|
|
177
|
-
|
|
89
|
+
if (isRTL()) {
|
|
90
|
+
// update column offsets
|
|
91
|
+
for (let i = colIndex + 1; i < columns.length; i += 1) {
|
|
92
|
+
// Tracked state change.
|
|
93
|
+
columns[i].offset += newDelta;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
178
96
|
// Tracked state change.
|
|
179
97
|
col.isResized = true;
|
|
180
98
|
}
|
|
181
99
|
}
|
|
182
100
|
|
|
183
101
|
/**
|
|
184
|
-
* Resize a column width with an additional delta
|
|
102
|
+
* Resize a column width with an additional delta.
|
|
103
|
+
*
|
|
185
104
|
* @param {object} columns - The column definitions
|
|
186
105
|
* @param {object} widthsData - The widths data
|
|
187
106
|
* @param {number} colIndex - The index of the column based on state.columns
|
|
188
107
|
* @param {number} delta - The delta that creates the new width
|
|
189
108
|
*/
|
|
190
109
|
export function resizeColumnWithDelta(columns, widthsData, colIndex, delta) {
|
|
191
|
-
const currentWidth =
|
|
110
|
+
const currentWidth = widthsData.columnWidths[colIndex];
|
|
192
111
|
resizeColumn(columns, widthsData, colIndex, currentWidth + delta);
|
|
193
112
|
}
|
|
194
113
|
|
|
195
|
-
function updateColumnWidth(columns, widthsData, colIndex, newWidth) {
|
|
196
|
-
const columnsWidths = getColumnsWidths(widthsData);
|
|
197
|
-
columnsWidths[colIndex] = newWidth;
|
|
198
|
-
|
|
199
|
-
const column = columns[colIndex];
|
|
200
|
-
column.columnWidth = newWidth;
|
|
201
|
-
column.style = buildCSSWidthStyle(newWidth);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
114
|
export function updateColumnWidthsMetadata(columns, widthsData) {
|
|
115
|
+
const { maxColumnWidth, minColumnWidth } = widthsData;
|
|
205
116
|
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
206
117
|
const col = columns[colIndex];
|
|
207
118
|
if (!col.internal) {
|
|
208
|
-
col.
|
|
209
|
-
col.
|
|
119
|
+
col.maxWidth = maxColumnWidth;
|
|
120
|
+
col.minWidth = minColumnWidth;
|
|
210
121
|
}
|
|
211
|
-
|
|
212
122
|
const { initialWidth } = col;
|
|
213
123
|
if (initialWidth) {
|
|
214
124
|
const { minWidth: min, maxWidth: max } = col;
|
|
@@ -218,26 +128,10 @@ export function updateColumnWidthsMetadata(columns, widthsData) {
|
|
|
218
128
|
}
|
|
219
129
|
|
|
220
130
|
/**
|
|
221
|
-
*
|
|
222
|
-
* This is used to position the column headers properly in RTL.
|
|
131
|
+
* Returns the current widths for customer columns.
|
|
223
132
|
*
|
|
224
|
-
* @param {
|
|
225
|
-
* @param {
|
|
226
|
-
* @param {number} newDelta - The change in column width to apply to
|
|
227
|
-
*/
|
|
228
|
-
function updateColumnOffsets(columns, colIndex, newDelta) {
|
|
229
|
-
if (isRTL()) {
|
|
230
|
-
for (let i = colIndex, { length } = columns; i < length; i += 1) {
|
|
231
|
-
// Tracked state change.
|
|
232
|
-
columns[i].offset += newDelta;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Returns the current widths for customer columns
|
|
239
|
-
* @param {object} columns - The columns of the table
|
|
240
|
-
* @param {object} widthsData - The data regarding column and table widths
|
|
133
|
+
* @param {Object} columns - The columns of the table
|
|
134
|
+
* @param {Object} widthsData - The data regarding column and table widths
|
|
241
135
|
* @returns {Array} - The widths collection, every element
|
|
242
136
|
* belong to a column with the same index in column prop
|
|
243
137
|
*/
|
|
@@ -245,7 +139,7 @@ export function getCustomerColumnWidths(columns, widthsData) {
|
|
|
245
139
|
const widths = [];
|
|
246
140
|
const { columnWidths } = widthsData;
|
|
247
141
|
for (let colIndex = 0; colIndex < columns.length; colIndex += 1) {
|
|
248
|
-
if (
|
|
142
|
+
if (columns[colIndex].internal !== true) {
|
|
249
143
|
widths.push(columnWidths[colIndex]);
|
|
250
144
|
}
|
|
251
145
|
}
|
|
@@ -253,13 +147,13 @@ export function getCustomerColumnWidths(columns, widthsData) {
|
|
|
253
147
|
}
|
|
254
148
|
|
|
255
149
|
/**
|
|
256
|
-
* It returns if table is rendered and not hidden
|
|
257
|
-
*
|
|
258
|
-
* @
|
|
150
|
+
* It returns if table is rendered and not hidden.
|
|
151
|
+
*
|
|
152
|
+
* @param {Node} template - The datatable template
|
|
153
|
+
* @returns {boolean} - Whether the datatable is rendered and not hidden on the page
|
|
259
154
|
*/
|
|
260
|
-
export function isTableRenderedVisible(
|
|
261
|
-
const
|
|
262
|
-
const scrollerY = root.querySelector(CONTAINER_SEL);
|
|
155
|
+
export function isTableRenderedVisible(template) {
|
|
156
|
+
const scrollerY = getScrollerY(template);
|
|
263
157
|
return (
|
|
264
158
|
scrollerY &&
|
|
265
159
|
!!(
|
|
@@ -269,7 +163,3 @@ export function isTableRenderedVisible(root) {
|
|
|
269
163
|
)
|
|
270
164
|
);
|
|
271
165
|
}
|
|
272
|
-
|
|
273
|
-
function getColumns(state) {
|
|
274
|
-
return state.columns;
|
|
275
|
-
}
|