@salesforce/design-system-react 0.10.41 → 0.10.45
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/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot +47 -157
- package/components/brand-band/__docs__/storybook-stories.jsx +4 -2
- package/components/brand-band/__examples__/{lightning-blue-theme.jsx → group-image.jsx} +1 -11
- package/components/brand-band/__examples__/no-image.jsx +1 -2
- package/{lib/components/brand-band/__examples__/lightning-blue-theme.jsx → components/brand-band/__examples__/user-image.jsx} +1 -11
- package/components/brand-band/check-props.js +18 -0
- package/components/brand-band/component.json +8 -4
- package/components/brand-band/index.jsx +23 -66
- package/components/brand-band.d.ts +1 -26
- package/components/button/__tests__/button.browser-test.jsx +0 -1
- package/components/combobox/__tests__/combobox.browser-test.jsx +18 -0
- package/components/combobox/combobox.jsx +4 -1
- package/components/component-docs.json +13 -38
- package/components/data-table/cell.jsx +2 -2
- package/components/data-table/index.jsx +130 -85
- package/components/data-table/private/context-helper.js +26 -14
- package/components/data-table/private/head.jsx +269 -260
- package/components/data-table/private/header-cell.jsx +204 -230
- package/components/data-table/private/row.jsx +140 -105
- package/components/data-table/row-actions.jsx +2 -2
- package/components/icon/__docs__/__snapshots__/storybook-stories.storyshot +49 -2
- package/components/icon/__docs__/storybook-stories.jsx +2 -0
- package/components/icon/__examples__/color-success.jsx +24 -0
- package/components/icon/__examples__/colors.jsx +10 -2
- package/components/icon/index.jsx +2 -0
- package/components/icon.d.ts +1 -1
- package/components/site-stories.js +8 -4
- package/components/utilities/truncate/index.jsx +1 -1
- package/lib/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot +47 -157
- package/lib/components/brand-band/__docs__/storybook-stories.jsx +4 -2
- package/lib/components/brand-band/__examples__/group-image.jsx +12 -0
- package/lib/components/brand-band/__examples__/no-image.jsx +1 -2
- package/lib/components/brand-band/__examples__/user-image.jsx +12 -0
- package/lib/components/brand-band/check-props.js +29 -0
- package/lib/components/brand-band/component.json +8 -4
- package/lib/components/brand-band/index.js +9 -50
- package/lib/components/brand-band.d.ts +1 -26
- package/lib/components/button/__tests__/button.browser-test.jsx +0 -1
- package/lib/components/combobox/__tests__/combobox.browser-test.jsx +18 -0
- package/lib/components/combobox/combobox.js +6 -2
- package/lib/components/component-docs.json +13 -38
- package/lib/components/data-table/cell.js +6 -6
- package/lib/components/data-table/index.js +127 -99
- package/lib/components/data-table/private/context-helper.js +13 -14
- package/lib/components/data-table/private/head.js +233 -252
- package/lib/components/data-table/private/header-cell.js +185 -221
- package/lib/components/data-table/private/row.js +97 -89
- package/lib/components/data-table/row-actions.js +6 -6
- package/lib/components/icon/__docs__/__snapshots__/storybook-stories.storyshot +49 -2
- package/lib/components/icon/__docs__/storybook-stories.jsx +2 -0
- package/lib/components/icon/__examples__/color-success.jsx +24 -0
- package/lib/components/icon/__examples__/colors.jsx +10 -2
- package/lib/components/icon/index.js +2 -1
- package/lib/components/icon.d.ts +1 -1
- package/lib/components/site-stories.js +6 -3
- package/lib/components/utilities/truncate/index.js +2 -2
- package/lib/package.json +13 -9
- package/module/components/brand-band/__docs__/__snapshots__/storybook-stories.storyshot +47 -157
- package/module/components/brand-band/__docs__/storybook-stories.js +6 -3
- package/module/components/brand-band/__docs__/storybook-stories.js.map +1 -1
- package/module/components/brand-band/__examples__/{lightning-blue-theme.js → group-image.js} +4 -9
- package/module/components/brand-band/__examples__/group-image.js.map +1 -0
- package/module/components/brand-band/__examples__/no-image.js +2 -4
- package/module/components/brand-band/__examples__/no-image.js.map +1 -1
- package/module/components/brand-band/__examples__/user-image.js +52 -0
- package/module/components/brand-band/__examples__/user-image.js.map +1 -0
- package/module/components/brand-band/check-props.js +20 -0
- package/module/components/brand-band/check-props.js.map +1 -0
- package/module/components/brand-band/component.json +8 -4
- package/module/components/brand-band/index.js +10 -51
- package/module/components/brand-band/index.js.map +1 -1
- package/module/components/brand-band.d.ts +1 -26
- package/module/components/button/__tests__/button.browser-test.js +0 -1
- package/module/components/button/__tests__/button.browser-test.js.map +1 -1
- package/module/components/combobox/__tests__/combobox.browser-test.js +22 -0
- package/module/components/combobox/__tests__/combobox.browser-test.js.map +1 -1
- package/module/components/combobox/combobox.js +6 -2
- package/module/components/combobox/combobox.js.map +1 -1
- package/module/components/component-docs.json +13 -38
- package/module/components/data-table/cell.js +6 -6
- package/module/components/data-table/cell.js.map +1 -1
- package/module/components/data-table/index.js +120 -95
- package/module/components/data-table/index.js.map +1 -1
- package/module/components/data-table/private/context-helper.js +12 -12
- package/module/components/data-table/private/context-helper.js.map +1 -1
- package/module/components/data-table/private/head.js +230 -255
- package/module/components/data-table/private/head.js.map +1 -1
- package/module/components/data-table/private/header-cell.js +184 -225
- package/module/components/data-table/private/header-cell.js.map +1 -1
- package/module/components/data-table/private/row.js +95 -87
- package/module/components/data-table/private/row.js.map +1 -1
- package/module/components/data-table/row-actions.js +6 -6
- package/module/components/data-table/row-actions.js.map +1 -1
- package/module/components/icon/__docs__/__snapshots__/storybook-stories.storyshot +49 -2
- package/module/components/icon/__docs__/storybook-stories.js +3 -0
- package/module/components/icon/__docs__/storybook-stories.js.map +1 -1
- package/module/components/icon/__examples__/color-success.js +64 -0
- package/module/components/icon/__examples__/color-success.js.map +1 -0
- package/module/components/icon/__examples__/colors.js +11 -2
- package/module/components/icon/__examples__/colors.js.map +1 -1
- package/module/components/icon/index.js +2 -1
- package/module/components/icon/index.js.map +1 -1
- package/module/components/icon.d.ts +1 -1
- package/module/components/site-stories.js +6 -3
- package/module/components/site-stories.js.map +1 -1
- package/module/components/utilities/truncate/index.js +1 -1
- package/module/components/utilities/truncate/index.js.map +1 -1
- package/package.json +13 -9
- package/module/components/brand-band/__examples__/lightning-blue-theme.js.map +0 -1
|
@@ -1148,17 +1148,8 @@
|
|
|
1148
1148
|
"dependencies": []
|
|
1149
1149
|
},
|
|
1150
1150
|
"brand-band": {
|
|
1151
|
-
"description": "The brand band provides theming capability that adds personality and improves information density and contrast
|
|
1151
|
+
"description": "The brand band provides theming capability that adds personality and improves information density and contrast.",
|
|
1152
1152
|
"methods": [
|
|
1153
|
-
{
|
|
1154
|
-
"name": "injectLightningBlueStyles",
|
|
1155
|
-
"docblock": null,
|
|
1156
|
-
"modifiers": [
|
|
1157
|
-
"static"
|
|
1158
|
-
],
|
|
1159
|
-
"params": [],
|
|
1160
|
-
"returns": null
|
|
1161
|
-
},
|
|
1162
1153
|
{
|
|
1163
1154
|
"name": "getId",
|
|
1164
1155
|
"docblock": null,
|
|
@@ -1211,6 +1202,14 @@
|
|
|
1211
1202
|
{
|
|
1212
1203
|
"value": "'none'",
|
|
1213
1204
|
"computed": false
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
"value": "'group'",
|
|
1208
|
+
"computed": false
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
"value": "'user'",
|
|
1212
|
+
"computed": false
|
|
1214
1213
|
}
|
|
1215
1214
|
]
|
|
1216
1215
|
},
|
|
@@ -1273,34 +1272,6 @@
|
|
|
1273
1272
|
},
|
|
1274
1273
|
"required": false,
|
|
1275
1274
|
"description": "Custom styles to be passed to the component"
|
|
1276
|
-
},
|
|
1277
|
-
"styleContainer": {
|
|
1278
|
-
"type": {
|
|
1279
|
-
"name": "object"
|
|
1280
|
-
},
|
|
1281
|
-
"required": false,
|
|
1282
|
-
"description": "Custom styles to be passed to the component container"
|
|
1283
|
-
},
|
|
1284
|
-
"theme": {
|
|
1285
|
-
"type": {
|
|
1286
|
-
"name": "enum",
|
|
1287
|
-
"value": [
|
|
1288
|
-
{
|
|
1289
|
-
"value": "'default'",
|
|
1290
|
-
"computed": false
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
"value": "'lightning-blue'",
|
|
1294
|
-
"computed": false
|
|
1295
|
-
}
|
|
1296
|
-
]
|
|
1297
|
-
},
|
|
1298
|
-
"required": false,
|
|
1299
|
-
"description": "Different brand band styling.\nNOTE: using 'lightning-blue' may result in incorrect styling depending on server CSP settings. See opening component documentation above for details.",
|
|
1300
|
-
"defaultValue": {
|
|
1301
|
-
"value": "'default'",
|
|
1302
|
-
"computed": false
|
|
1303
|
-
}
|
|
1304
1275
|
}
|
|
1305
1276
|
},
|
|
1306
1277
|
"route": "brand-band",
|
|
@@ -9534,6 +9505,10 @@
|
|
|
9534
9505
|
{
|
|
9535
9506
|
"value": "'warning'",
|
|
9536
9507
|
"computed": false
|
|
9508
|
+
},
|
|
9509
|
+
{
|
|
9510
|
+
"value": "'success'",
|
|
9511
|
+
"computed": false
|
|
9537
9512
|
}
|
|
9538
9513
|
]
|
|
9539
9514
|
},
|
|
@@ -10,7 +10,7 @@ import classNames from 'classnames';
|
|
|
10
10
|
|
|
11
11
|
import CellContext from './private/cell-context';
|
|
12
12
|
import TableContext from './private/table-context';
|
|
13
|
-
import
|
|
13
|
+
import useContextHelper from './private/context-helper';
|
|
14
14
|
|
|
15
15
|
// ## Constants
|
|
16
16
|
import { DATA_TABLE_CELL } from '../../utilities/constants';
|
|
@@ -21,7 +21,7 @@ import { DATA_TABLE_CELL } from '../../utilities/constants';
|
|
|
21
21
|
const DataTableCell = (props) => {
|
|
22
22
|
const tableContext = useContext(TableContext);
|
|
23
23
|
const cellContext = useContext(CellContext);
|
|
24
|
-
const { tabIndex, hasFocus, handleFocus, handleKeyDown } =
|
|
24
|
+
const { tabIndex, hasFocus, handleFocus, handleKeyDown } = useContextHelper(
|
|
25
25
|
tableContext,
|
|
26
26
|
cellContext,
|
|
27
27
|
props.fixedLayout
|
|
@@ -16,8 +16,9 @@ import shortid from 'shortid';
|
|
|
16
16
|
|
|
17
17
|
import classNames from 'classnames';
|
|
18
18
|
import assign from 'lodash.assign';
|
|
19
|
+
import isEqual from 'lodash.isequal';
|
|
20
|
+
import memoize from 'memoize-one';
|
|
19
21
|
import reject from 'lodash.reject';
|
|
20
|
-
|
|
21
22
|
// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)
|
|
22
23
|
import ColumnResizer from 'column-resizer';
|
|
23
24
|
import checkProps from './check-props';
|
|
@@ -74,6 +75,90 @@ const defaultProps = {
|
|
|
74
75
|
},
|
|
75
76
|
};
|
|
76
77
|
|
|
78
|
+
const getAssistiveText = memoize(
|
|
79
|
+
(
|
|
80
|
+
assistiveText,
|
|
81
|
+
actionsHeaderText,
|
|
82
|
+
columnSortText,
|
|
83
|
+
columnSortedAscendingText,
|
|
84
|
+
columnSortedDescendingText,
|
|
85
|
+
selectAllRowsText,
|
|
86
|
+
selectRowText
|
|
87
|
+
) => {
|
|
88
|
+
const result = {
|
|
89
|
+
...defaultProps.assistiveText,
|
|
90
|
+
...assistiveText,
|
|
91
|
+
};
|
|
92
|
+
if (actionsHeaderText) {
|
|
93
|
+
result.actionsHeader = actionsHeaderText;
|
|
94
|
+
}
|
|
95
|
+
if (selectAllRowsText) {
|
|
96
|
+
result.selectAllRows = selectAllRowsText;
|
|
97
|
+
}
|
|
98
|
+
if (columnSortedAscendingText) {
|
|
99
|
+
result.columnSortedAscending = columnSortedAscendingText;
|
|
100
|
+
}
|
|
101
|
+
if (columnSortedDescendingText) {
|
|
102
|
+
result.columnSortedDescending = columnSortedDescendingText;
|
|
103
|
+
}
|
|
104
|
+
if (columnSortText) {
|
|
105
|
+
result.columnSort = columnSortText;
|
|
106
|
+
}
|
|
107
|
+
if (selectRowText) {
|
|
108
|
+
result.selectRow = selectRowText;
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
},
|
|
112
|
+
isEqual
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const getColumnsAndRowActions = memoize(
|
|
116
|
+
(children, id, fixedHeader, fixedLayout, search) => {
|
|
117
|
+
const columns = [];
|
|
118
|
+
let RowActions = null;
|
|
119
|
+
|
|
120
|
+
React.Children.forEach(children, (child) => {
|
|
121
|
+
if (child && child.type.displayName === DataTableColumn.displayName) {
|
|
122
|
+
const { children: columnChildren, ...columnProps } = child.props;
|
|
123
|
+
const props = { fixedLayout, search, id, ...columnProps };
|
|
124
|
+
|
|
125
|
+
let Cell;
|
|
126
|
+
if (
|
|
127
|
+
columnChildren &&
|
|
128
|
+
columnChildren.type.displayName === DATA_TABLE_CELL
|
|
129
|
+
) {
|
|
130
|
+
Cell = columnChildren.type;
|
|
131
|
+
assign(props, columnChildren.props);
|
|
132
|
+
} else {
|
|
133
|
+
Cell = DataTableCell;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// eslint-disable-next-line fp/no-mutating-methods
|
|
137
|
+
columns.push({
|
|
138
|
+
Cell,
|
|
139
|
+
props,
|
|
140
|
+
});
|
|
141
|
+
} else if (
|
|
142
|
+
child &&
|
|
143
|
+
child.type.displayName === DataTableRowActions.displayName
|
|
144
|
+
) {
|
|
145
|
+
const { dropdown } = child.props;
|
|
146
|
+
const dropdownPropOverrides = {};
|
|
147
|
+
if (fixedHeader) {
|
|
148
|
+
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
149
|
+
}
|
|
150
|
+
RowActions = React.cloneElement(child, {
|
|
151
|
+
dropdown: dropdown
|
|
152
|
+
? React.cloneElement(dropdown, dropdownPropOverrides)
|
|
153
|
+
: null,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return { columns, RowActions };
|
|
158
|
+
},
|
|
159
|
+
isEqual
|
|
160
|
+
);
|
|
161
|
+
|
|
77
162
|
/**
|
|
78
163
|
* DataTables support the display of structured data in rows and columns with an HTML table. To sort, filter or paginate the table, simply update the data passed in the items to the table and it will re-render itself appropriately. The table will throw a sort event as needed, and helper components for paging and filtering are coming soon.
|
|
79
164
|
*
|
|
@@ -366,9 +451,7 @@ class DataTable extends React.Component {
|
|
|
366
451
|
// Simulating a scroll here will ensure that enough rows are loaded to enable scrolling
|
|
367
452
|
this.loadMoreIfNeeded();
|
|
368
453
|
}
|
|
369
|
-
|
|
370
|
-
this.interactiveElements = {};
|
|
371
|
-
}
|
|
454
|
+
|
|
372
455
|
if (
|
|
373
456
|
this.state.allowKeyboardNavigation &&
|
|
374
457
|
!prevState.allowKeyboardNavigation
|
|
@@ -440,6 +523,23 @@ class DataTable extends React.Component {
|
|
|
440
523
|
return null;
|
|
441
524
|
}
|
|
442
525
|
|
|
526
|
+
getTableContext = memoize((state, isKeyboardNavigation) => ({
|
|
527
|
+
activeCell: state.activeCell,
|
|
528
|
+
activeElement: state.activeElement,
|
|
529
|
+
mode: state.mode,
|
|
530
|
+
tableHasFocus: state.tableHasFocus,
|
|
531
|
+
changeActiveCell: this.changeActiveCell,
|
|
532
|
+
changeActiveElement: this.changeActiveElement,
|
|
533
|
+
handleKeyDown: this.handleKeyDown,
|
|
534
|
+
registerInteractiveElement: this.registerInteractiveElement,
|
|
535
|
+
allowKeyboardNavigation: state.allowKeyboardNavigation,
|
|
536
|
+
setAllowKeyboardNavigation: (allowKeyboardNavigation) => {
|
|
537
|
+
if (isKeyboardNavigation) {
|
|
538
|
+
this.setState({ allowKeyboardNavigation });
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
}));
|
|
542
|
+
|
|
443
543
|
handleToggleAll = (e, { checked }) => {
|
|
444
544
|
// REMOVE AT NEXT BREAKING CHANGE
|
|
445
545
|
// `onChange` is deprecated and replaced with `onRowChange`
|
|
@@ -587,6 +687,13 @@ class DataTable extends React.Component {
|
|
|
587
687
|
}
|
|
588
688
|
};
|
|
589
689
|
|
|
690
|
+
// eslint-disable-next-line camelcase
|
|
691
|
+
UNSAFE_componentWillUpdate(nextProps) {
|
|
692
|
+
if (this.props.items !== nextProps.items) {
|
|
693
|
+
this.interactiveElements = {};
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
590
697
|
isResizable() {
|
|
591
698
|
return this.props.fixedLayout && this.props.resizable;
|
|
592
699
|
}
|
|
@@ -989,71 +1096,24 @@ class DataTable extends React.Component {
|
|
|
989
1096
|
const allSelected = canSelectRows && numNonHeaderRows === numSelected;
|
|
990
1097
|
const indeterminateSelected =
|
|
991
1098
|
canSelectRows && numNonHeaderRows !== numSelected && numSelected !== 0;
|
|
992
|
-
const columns = [];
|
|
993
|
-
let RowActions = null;
|
|
994
1099
|
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
assign(props, columnProps);
|
|
1003
|
-
|
|
1004
|
-
let Cell;
|
|
1005
|
-
if (children && children.type.displayName === DATA_TABLE_CELL) {
|
|
1006
|
-
Cell = children.type;
|
|
1007
|
-
assign(props, children.props);
|
|
1008
|
-
} else {
|
|
1009
|
-
Cell = DataTableCell;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
// eslint-disable-next-line fp/no-mutating-methods
|
|
1013
|
-
columns.push({
|
|
1014
|
-
Cell,
|
|
1015
|
-
props,
|
|
1016
|
-
dataTableProps: this.props,
|
|
1017
|
-
});
|
|
1018
|
-
} else if (
|
|
1019
|
-
child &&
|
|
1020
|
-
child.type.displayName === DataTableRowActions.displayName
|
|
1021
|
-
) {
|
|
1022
|
-
const { dropdown } = child.props;
|
|
1023
|
-
const dropdownPropOverrides = {};
|
|
1024
|
-
if (this.getFixedHeader()) {
|
|
1025
|
-
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
1026
|
-
}
|
|
1027
|
-
RowActions = React.cloneElement(child, {
|
|
1028
|
-
dropdown: dropdown
|
|
1029
|
-
? React.cloneElement(dropdown, dropdownPropOverrides)
|
|
1030
|
-
: null,
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1100
|
+
const { columns, RowActions } = getColumnsAndRowActions(
|
|
1101
|
+
this.props.children,
|
|
1102
|
+
this.props.id,
|
|
1103
|
+
this.getFixedHeader(),
|
|
1104
|
+
this.props.fixedLayout,
|
|
1105
|
+
this.props.search
|
|
1106
|
+
);
|
|
1034
1107
|
|
|
1035
|
-
const assistiveText =
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
}
|
|
1045
|
-
if (this.props.assistiveTextForColumnSortedAscending) {
|
|
1046
|
-
assistiveText.columnSortedAscending = this.props.assistiveTextForColumnSortedAscending;
|
|
1047
|
-
}
|
|
1048
|
-
if (this.props.assistiveTextForColumnSortedDescending) {
|
|
1049
|
-
assistiveText.columnSortedDescending = this.props.assistiveTextForColumnSortedDescending;
|
|
1050
|
-
}
|
|
1051
|
-
if (this.props.assistiveTextForColumnSort) {
|
|
1052
|
-
assistiveText.columnSort = this.props.assistiveTextForColumnSort;
|
|
1053
|
-
}
|
|
1054
|
-
if (this.props.assistiveTextForSelectRow) {
|
|
1055
|
-
assistiveText.selectRow = this.props.assistiveTextForSelectRow;
|
|
1056
|
-
}
|
|
1108
|
+
const assistiveText = getAssistiveText(
|
|
1109
|
+
this.props.assistiveText,
|
|
1110
|
+
this.props.assistiveTextForActionsHeader,
|
|
1111
|
+
this.props.assistiveTextForSelectAllRows,
|
|
1112
|
+
this.props.assistiveTextForColumnSortedAscending,
|
|
1113
|
+
this.props.assistiveTextForColumnSortedDescending,
|
|
1114
|
+
this.props.assistiveTextForColumnSort,
|
|
1115
|
+
this.props.assistiveTextForSelectRow
|
|
1116
|
+
);
|
|
1057
1117
|
|
|
1058
1118
|
if (this.props.selectRows && this.props.selectRows !== 'radio') {
|
|
1059
1119
|
ariaProps['aria-multiselectable'] = 'true';
|
|
@@ -1066,26 +1126,11 @@ class DataTable extends React.Component {
|
|
|
1066
1126
|
select: canSelectRows ? this.headerRefs.select : [],
|
|
1067
1127
|
};
|
|
1068
1128
|
|
|
1069
|
-
const tableContext = {
|
|
1070
|
-
activeCell: this.state.activeCell,
|
|
1071
|
-
activeElement: this.state.activeElement,
|
|
1072
|
-
mode: this.state.mode,
|
|
1073
|
-
tableHasFocus: this.state.tableHasFocus,
|
|
1074
|
-
changeActiveCell: this.changeActiveCell,
|
|
1075
|
-
changeActiveElement: this.changeActiveElement,
|
|
1076
|
-
handleKeyDown: this.handleKeyDown,
|
|
1077
|
-
registerInteractiveElement: this.registerInteractiveElement,
|
|
1078
|
-
allowKeyboardNavigation: this.state.allowKeyboardNavigation,
|
|
1079
|
-
setAllowKeyboardNavigation: (allowKeyboardNavigation) => {
|
|
1080
|
-
if (this.getKeyboardNavigation()) {
|
|
1081
|
-
this.setState({ allowKeyboardNavigation });
|
|
1082
|
-
}
|
|
1083
|
-
},
|
|
1084
|
-
};
|
|
1085
|
-
|
|
1086
1129
|
let component = (
|
|
1087
1130
|
<React.Fragment>
|
|
1088
|
-
<TableContext.Provider
|
|
1131
|
+
<TableContext.Provider
|
|
1132
|
+
value={this.getTableContext(this.state, this.getKeyboardNavigation())}
|
|
1133
|
+
>
|
|
1089
1134
|
<table
|
|
1090
1135
|
{...ariaProps}
|
|
1091
1136
|
className={classNames(
|
|
@@ -1,30 +1,42 @@
|
|
|
1
1
|
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
|
|
2
2
|
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
|
|
3
3
|
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* Calculates data table keyboard navigation state based on currently selected cell
|
|
6
8
|
*/
|
|
7
|
-
export default (
|
|
9
|
+
export default function useTableContextHelper(
|
|
10
|
+
tableContext,
|
|
11
|
+
cellContext,
|
|
12
|
+
fixedLayout
|
|
13
|
+
) {
|
|
8
14
|
const isActive =
|
|
9
15
|
tableContext.activeCell.rowIndex === cellContext.rowIndex &&
|
|
10
16
|
tableContext.activeCell.columnIndex === cellContext.columnIndex;
|
|
11
17
|
|
|
12
18
|
const hasFocus = fixedLayout && tableContext.tableHasFocus && isActive;
|
|
13
|
-
|
|
14
|
-
const handleFocus = () => {
|
|
19
|
+
const { changeActiveCell, handleKeyDown: handleTableKeyDown } = tableContext;
|
|
20
|
+
const handleFocus = useCallback(() => {
|
|
15
21
|
if (fixedLayout && tableContext.allowKeyboardNavigation) {
|
|
16
|
-
|
|
17
|
-
cellContext.rowIndex,
|
|
18
|
-
cellContext.columnIndex
|
|
19
|
-
);
|
|
22
|
+
changeActiveCell(cellContext.rowIndex, cellContext.columnIndex);
|
|
20
23
|
}
|
|
21
|
-
}
|
|
24
|
+
}, [
|
|
25
|
+
fixedLayout,
|
|
26
|
+
tableContext.allowKeyboardNavigation,
|
|
27
|
+
changeActiveCell,
|
|
28
|
+
cellContext.rowIndex,
|
|
29
|
+
cellContext.columnIndex,
|
|
30
|
+
]);
|
|
22
31
|
|
|
23
|
-
const handleKeyDown = (
|
|
24
|
-
|
|
25
|
-
tableContext.
|
|
26
|
-
|
|
27
|
-
|
|
32
|
+
const handleKeyDown = useCallback(
|
|
33
|
+
(event) => {
|
|
34
|
+
if (fixedLayout && tableContext.allowKeyboardNavigation) {
|
|
35
|
+
handleTableKeyDown(event);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[fixedLayout, tableContext.allowKeyboardNavigation, handleTableKeyDown]
|
|
39
|
+
);
|
|
28
40
|
|
|
29
41
|
const tabIndex =
|
|
30
42
|
fixedLayout &&
|
|
@@ -35,4 +47,4 @@ export default (tableContext, cellContext, fixedLayout) => {
|
|
|
35
47
|
: undefined;
|
|
36
48
|
|
|
37
49
|
return { tabIndex, hasFocus, handleFocus, handleKeyDown };
|
|
38
|
-
}
|
|
50
|
+
}
|