lightning-base-components 1.14.2-alpha → 1.14.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.
Files changed (53) hide show
  1. package/metadata/raptor.json +1 -0
  2. package/package.json +17 -1
  3. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsPlural.js +1 -0
  4. package/scopedImports/@salesforce-label-LightningDualListbox.movedOptionsSingular.js +1 -0
  5. package/scopedImports/@salesforce-label-LightningErrorMessage.validitySelectAtleastOne.js +1 -0
  6. package/scopedImports/@salesforce-label-LightningMap.titleWithAddress.js +1 -0
  7. package/src/lightning/ariaObserver/__docs__/ariaObserver.md +142 -0
  8. package/src/lightning/buttonMenu/keyboard.js +0 -10
  9. package/src/lightning/card/card.html +6 -0
  10. package/src/lightning/checkboxGroup/checkboxGroup.html +2 -2
  11. package/src/lightning/checkboxGroup/checkboxGroup.js +6 -1
  12. package/src/lightning/colorPickerCustom/colorPickerCustom.js +20 -1
  13. package/src/lightning/datatable/__docs__/datatable.md +55 -0
  14. package/src/lightning/datatable/__examples__/basic/basic.html +1 -1
  15. package/src/lightning/datatable/columns-shared.js +1 -1
  16. package/src/lightning/datatable/datatable.js +97 -24
  17. package/src/lightning/datatable/errors.js +20 -9
  18. package/src/lightning/datatable/headerActions.js +77 -49
  19. package/src/lightning/datatable/inlineEdit.js +505 -370
  20. package/src/lightning/datatable/inlineEditShared.js +24 -0
  21. package/src/lightning/datatable/keyboard.js +1 -1
  22. package/src/lightning/datatable/renderManager.js +241 -129
  23. package/src/lightning/datatable/rowLevelActions.js +17 -13
  24. package/src/lightning/datatable/rowNumber.js +54 -20
  25. package/src/lightning/datatable/rowSelection.js +760 -0
  26. package/src/lightning/datatable/rowSelectionShared.js +79 -0
  27. package/src/lightning/datatable/rows.js +16 -5
  28. package/src/lightning/datatable/state.js +10 -1
  29. package/src/lightning/datatable/templates/div/div.css +4 -0
  30. package/src/lightning/datatable/templates/div/div.html +1 -0
  31. package/src/lightning/datatable/utils.js +14 -0
  32. package/src/lightning/dualListbox/dualListbox.html +1 -1
  33. package/src/lightning/dualListbox/dualListbox.js +42 -0
  34. package/src/lightning/inputUtils/validity.js +12 -1
  35. package/src/lightning/pillContainer/__docs__/pillContainer.md +45 -1
  36. package/src/lightning/positionLibrary/positionLibrary.js +31 -43
  37. package/src/lightning/primitiveCellActions/primitiveCellActions.js +69 -12
  38. package/src/lightning/primitiveCellFactory/cellWithStandardLayout.html +13 -11
  39. package/src/lightning/primitiveCellFactory/primitiveCellFactory.js +13 -8
  40. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.html +17 -14
  41. package/src/lightning/primitiveDatatableIeditPanel/primitiveDatatableIeditPanel.js +167 -98
  42. package/src/lightning/primitiveDatatableIeditTypeFactory/primitiveDatatableIeditTypeFactory.js +94 -69
  43. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.html +4 -4
  44. package/src/lightning/primitiveDatatableStatusBar/primitiveDatatableStatusBar.js +4 -4
  45. package/src/lightning/primitiveHeaderActions/primitiveHeaderActions.js +99 -37
  46. package/src/lightning/progressIndicator/progressIndicator.js +1 -1
  47. package/src/lightning/progressStep/progressStep.js +1 -1
  48. package/src/lightning/staticMap/staticMap.html +1 -0
  49. package/src/lightning/staticMap/staticMap.js +39 -2
  50. package/src/lightning/utils/classSet.js +4 -1
  51. package/src/lightning/datatable/inlineEdit-shared.js +0 -14
  52. package/src/lightning/datatable/selector-shared.js +0 -38
  53. package/src/lightning/datatable/selector.js +0 -527
@@ -1,25 +1,36 @@
1
- export function getErrorsState() {
2
- return {
3
- errors: {
4
- rows: {},
5
- table: {},
6
- },
7
- };
8
- }
1
+ // Default empty error state
2
+ const DEFAULT_ERROR_STATE = {
3
+ rows: {},
4
+ table: {},
5
+ };
9
6
 
7
+ /**
8
+ * Retrieves the errors object from datatable's state object
9
+ * Returns the set of row-level errors and table-level errors
10
+ */
10
11
  export function getErrors(state) {
11
12
  return state.errors;
12
13
  }
13
14
 
15
+ /**
16
+ * Sets the row-level errors and table-level errors in datatable's state object
17
+ * Errors being set here overwrite the previous error object in the state
18
+ */
14
19
  export function setErrors(state, errors) {
15
- return (state.errors = Object.assign({}, getErrorsState(), errors));
20
+ return (state.errors = Object.assign({}, DEFAULT_ERROR_STATE, errors));
16
21
  }
17
22
 
23
+ /**
24
+ * Retrieves the row-level errors of a particular row from datatable's state object
25
+ */
18
26
  export function getRowError(state, rowKey) {
19
27
  const rows = getErrors(state).rows;
20
28
  return (rows && rows[rowKey]) || {};
21
29
  }
22
30
 
31
+ /**
32
+ * Retrieves the table-level errors from the datatable's state object
33
+ */
23
34
  export function getTableError(state) {
24
35
  return getErrors(state).table || {};
25
36
  }
@@ -1,49 +1,31 @@
1
1
  import { unwrap } from 'lwc';
2
2
  import { getUserColumnIndex, getColumns } from './columns';
3
- import * as wraptext from './wrapText';
3
+ import { getActions, handleTriggeredAction } from './wrapText';
4
4
 
5
- function handleTriggeredInternalAction(dt, action, colKeyValue) {
6
- wraptext.handleTriggeredAction(dt.state, action, colKeyValue);
7
- dispatchHeaderActionEvent(dt, action, colKeyValue);
8
- }
9
-
10
- function handleTriggeredCustomerAction(dt, action, colKeyValue) {
11
- dispatchHeaderActionEvent(dt, action, colKeyValue);
12
- }
5
+ // Height of a clickable menu item
6
+ const ACTION_REM_HEIGHT = 2.125;
13
7
 
14
- function dispatchHeaderActionEvent(dt, action, colKeyValue) {
15
- const userColumnIndex = getUserColumnIndex(dt.state, colKeyValue);
16
- const customerColumnDefinition = dt.columns[userColumnIndex];
17
-
18
- dt.dispatchEvent(
19
- new CustomEvent('headeraction', {
20
- detail: {
21
- action: unwrap(action),
22
- columnDefinition: unwrap(customerColumnDefinition),
23
- },
24
- })
25
- );
26
- }
8
+ // Height of the menu divider, 1 rem + 1px (1/16px)
9
+ const DIVIDER_REM_HEIGHT = 1.0625;
27
10
 
28
- function getMenuAlignment(columns, index) {
29
- const isLastColumn = index === columns.length - 1;
30
-
31
- return isLastColumn || columns[index + 1].type === 'action'
32
- ? 'auto-right'
33
- : 'auto-left';
34
- }
11
+ /************************** PUBLIC METHODS ***************************/
35
12
 
13
+ /**
14
+ * Merges wrapText internal actions.
15
+ * If there are new internal actions in the future, they may be added here.
16
+ *
17
+ * @param {Object} state The state of the datatable
18
+ * @param {Object} columnDefinition The column definition to extract internal actions from
19
+ * @return {Array} All wrapText internal actions
20
+ */
36
21
  export function getInternalActions(state, columnDefinition) {
37
- // merge all internal actions here
38
- // currently, only wrapText internal actions
39
- // there may be new internal actions in the future
40
- return [...wraptext.getActions(state, columnDefinition)];
22
+ return [...getActions(state, columnDefinition)];
41
23
  }
42
24
 
43
25
  /**
44
26
  * Overrides the actions with the internal ones, plus the customer ones.
45
27
  *
46
- * @param {Object} state The state of the datatable.
28
+ * @param {Object} state The state of the datatable
47
29
  */
48
30
  export function updateHeaderActions(state) {
49
31
  const columns = getColumns(state);
@@ -59,31 +41,36 @@ export function updateHeaderActions(state) {
59
41
  });
60
42
  }
61
43
 
44
+ /**
45
+ * For internal actions, handles triggering the action.
46
+ * Then dispatches the header action event.
47
+ *
48
+ * @param {Event} event
49
+ */
62
50
  export function handleHeaderActionTriggered(event) {
51
+ event.stopPropagation();
52
+
63
53
  const { action, actionType, colKeyValue } = event.detail;
64
54
 
65
- event.stopPropagation();
66
- if (actionType === 'customer') {
67
- handleTriggeredCustomerAction(this, action, colKeyValue);
68
- } else {
69
- handleTriggeredInternalAction(this, action, colKeyValue);
55
+ if (actionType !== 'customer') {
56
+ handleTriggeredAction(this.state, action, colKeyValue);
70
57
  }
71
- }
72
58
 
73
- export function getColumnActionsDefaultState() {
74
- return Object.assign({}, wraptext.getDefaultState());
59
+ dispatchHeaderActionEvent(this, action, colKeyValue);
75
60
  }
76
61
 
77
- // in rem, the height of a clickable menu item
78
- const ACTION_HEIGHT = 2.125;
79
- // 1 rem + 1px (1/16px), height of the menu divider
80
- const DIVIDER_HEIGHT = 1.0625;
81
-
62
+ /**
63
+ * Calculates the size and positioning of the header action
64
+ * menu when it is opened.
65
+ *
66
+ * @param {Event} event
67
+ */
82
68
  export function handleHeaderActionMenuOpening(event) {
83
69
  event.stopPropagation();
84
70
  event.preventDefault();
85
- const actionsHeight = event.detail.actionsCount * ACTION_HEIGHT;
86
- const dividersHeight = event.detail.dividersCount * DIVIDER_HEIGHT;
71
+
72
+ const actionsHeight = event.detail.actionsCount * ACTION_REM_HEIGHT;
73
+ const dividersHeight = event.detail.dividersCount * DIVIDER_REM_HEIGHT;
87
74
  const wrapperHeight = 1;
88
75
  this._actionsMinHeightStyle = `min-height:${
89
76
  actionsHeight + dividersHeight + wrapperHeight
@@ -91,6 +78,47 @@ export function handleHeaderActionMenuOpening(event) {
91
78
  event.detail.saveContainerPosition(this.getViewableRect());
92
79
  }
93
80
 
81
+ /**
82
+ * Resets header action menu height when closed.
83
+ */
94
84
  export function handleHeaderActionMenuClosed() {
95
85
  this._actionsMinHeightStyle = '';
96
86
  }
87
+
88
+ /************************** PRIVATE METHODS ***************************/
89
+
90
+ /**
91
+ * Dispatches the `headeraction` event.
92
+ *
93
+ * @param {Object} dt The datatable
94
+ * @param {Object} action The action to dispatch
95
+ * @param {String} colKeyValue The column to dispatch the action on
96
+ */
97
+ function dispatchHeaderActionEvent(dt, action, colKeyValue) {
98
+ const userColumnIndex = getUserColumnIndex(dt.state, colKeyValue);
99
+ const customerColumnDefinition = dt.columns[userColumnIndex];
100
+
101
+ dt.dispatchEvent(
102
+ new CustomEvent('headeraction', {
103
+ detail: {
104
+ action: unwrap(action),
105
+ columnDefinition: unwrap(customerColumnDefinition),
106
+ },
107
+ })
108
+ );
109
+ }
110
+
111
+ /**
112
+ * Determines the menu alignment based on column placement.
113
+ *
114
+ * @param {Array} columns Array of all the columns
115
+ * @param {Integer} index The current column index to check
116
+ * @return {String} The computed alignment
117
+ */
118
+ function getMenuAlignment(columns, index) {
119
+ const isLastColumn = index === columns.length - 1;
120
+
121
+ return isLastColumn || columns[index + 1].type === 'action'
122
+ ? 'auto-right'
123
+ : 'auto-left';
124
+ }