@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
|
},
|
|
@@ -17,7 +17,7 @@ var _cellContext = _interopRequireDefault(require("./private/cell-context"));
|
|
|
17
17
|
|
|
18
18
|
var _tableContext = _interopRequireDefault(require("./private/table-context"));
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _contextHelper = _interopRequireDefault(require("./private/context-helper"));
|
|
21
21
|
|
|
22
22
|
var _constants = require("../../utilities/constants");
|
|
23
23
|
|
|
@@ -41,11 +41,11 @@ var DataTableCell = function DataTableCell(props) {
|
|
|
41
41
|
var tableContext = (0, _react.useContext)(_tableContext.default);
|
|
42
42
|
var cellContext = (0, _react.useContext)(_cellContext.default);
|
|
43
43
|
|
|
44
|
-
var
|
|
45
|
-
tabIndex =
|
|
46
|
-
hasFocus =
|
|
47
|
-
handleFocus =
|
|
48
|
-
handleKeyDown =
|
|
44
|
+
var _useContextHelper = (0, _contextHelper.default)(tableContext, cellContext, props.fixedLayout),
|
|
45
|
+
tabIndex = _useContextHelper.tabIndex,
|
|
46
|
+
hasFocus = _useContextHelper.hasFocus,
|
|
47
|
+
handleFocus = _useContextHelper.handleFocus,
|
|
48
|
+
handleKeyDown = _useContextHelper.handleKeyDown;
|
|
49
49
|
|
|
50
50
|
var childText = /*#__PURE__*/_react.default.isValidElement(props.children) ? props.children.props.children : props.children;
|
|
51
51
|
|
|
@@ -17,7 +17,11 @@ var _classnames = _interopRequireDefault(require("classnames"));
|
|
|
17
17
|
|
|
18
18
|
var _lodash = _interopRequireDefault(require("lodash.assign"));
|
|
19
19
|
|
|
20
|
-
var _lodash2 = _interopRequireDefault(require("lodash.
|
|
20
|
+
var _lodash2 = _interopRequireDefault(require("lodash.isequal"));
|
|
21
|
+
|
|
22
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
23
|
+
|
|
24
|
+
var _lodash3 = _interopRequireDefault(require("lodash.reject"));
|
|
21
25
|
|
|
22
26
|
var _columnResizer = _interopRequireDefault(require("column-resizer"));
|
|
23
27
|
|
|
@@ -57,10 +61,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
57
61
|
|
|
58
62
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
59
63
|
|
|
60
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
61
|
-
|
|
62
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
63
|
-
|
|
64
64
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
65
65
|
|
|
66
66
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -69,10 +69,6 @@ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "und
|
|
|
69
69
|
|
|
70
70
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
71
71
|
|
|
72
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
73
|
-
|
|
74
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
75
|
-
|
|
76
72
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
77
73
|
|
|
78
74
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -105,6 +101,14 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
105
101
|
|
|
106
102
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
107
103
|
|
|
104
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
105
|
+
|
|
106
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
107
|
+
|
|
108
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
109
|
+
|
|
110
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
111
|
+
|
|
108
112
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
109
113
|
|
|
110
114
|
// Safely get the length of an array, returning 0 for invalid input.
|
|
@@ -132,6 +136,84 @@ var defaultProps = {
|
|
|
132
136
|
draggingClass: 'slds-table-column-resizer'
|
|
133
137
|
}
|
|
134
138
|
};
|
|
139
|
+
var getAssistiveText = (0, _memoizeOne.default)(function (assistiveText, actionsHeaderText, columnSortText, columnSortedAscendingText, columnSortedDescendingText, selectAllRowsText, selectRowText) {
|
|
140
|
+
var result = _objectSpread(_objectSpread({}, defaultProps.assistiveText), assistiveText);
|
|
141
|
+
|
|
142
|
+
if (actionsHeaderText) {
|
|
143
|
+
result.actionsHeader = actionsHeaderText;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (selectAllRowsText) {
|
|
147
|
+
result.selectAllRows = selectAllRowsText;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (columnSortedAscendingText) {
|
|
151
|
+
result.columnSortedAscending = columnSortedAscendingText;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (columnSortedDescendingText) {
|
|
155
|
+
result.columnSortedDescending = columnSortedDescendingText;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (columnSortText) {
|
|
159
|
+
result.columnSort = columnSortText;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (selectRowText) {
|
|
163
|
+
result.selectRow = selectRowText;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return result;
|
|
167
|
+
}, _lodash2.default);
|
|
168
|
+
var getColumnsAndRowActions = (0, _memoizeOne.default)(function (children, id, fixedHeader, fixedLayout, search) {
|
|
169
|
+
var columns = [];
|
|
170
|
+
var RowActions = null;
|
|
171
|
+
|
|
172
|
+
_react.default.Children.forEach(children, function (child) {
|
|
173
|
+
if (child && child.type.displayName === _column.default.displayName) {
|
|
174
|
+
var _child$props = child.props,
|
|
175
|
+
columnChildren = _child$props.children,
|
|
176
|
+
columnProps = _objectWithoutProperties(_child$props, ["children"]);
|
|
177
|
+
|
|
178
|
+
var props = _objectSpread({
|
|
179
|
+
fixedLayout: fixedLayout,
|
|
180
|
+
search: search,
|
|
181
|
+
id: id
|
|
182
|
+
}, columnProps);
|
|
183
|
+
|
|
184
|
+
var Cell;
|
|
185
|
+
|
|
186
|
+
if (columnChildren && columnChildren.type.displayName === _constants.DATA_TABLE_CELL) {
|
|
187
|
+
Cell = columnChildren.type;
|
|
188
|
+
(0, _lodash.default)(props, columnChildren.props);
|
|
189
|
+
} else {
|
|
190
|
+
Cell = _cell.default;
|
|
191
|
+
} // eslint-disable-next-line fp/no-mutating-methods
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
columns.push({
|
|
195
|
+
Cell: Cell,
|
|
196
|
+
props: props
|
|
197
|
+
});
|
|
198
|
+
} else if (child && child.type.displayName === _rowActions.default.displayName) {
|
|
199
|
+
var dropdown = child.props.dropdown;
|
|
200
|
+
var dropdownPropOverrides = {};
|
|
201
|
+
|
|
202
|
+
if (fixedHeader) {
|
|
203
|
+
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
RowActions = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
207
|
+
dropdown: dropdown ? /*#__PURE__*/_react.default.cloneElement(dropdown, dropdownPropOverrides) : null
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
columns: columns,
|
|
214
|
+
RowActions: RowActions
|
|
215
|
+
};
|
|
216
|
+
}, _lodash2.default);
|
|
135
217
|
/**
|
|
136
218
|
* 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.
|
|
137
219
|
*
|
|
@@ -153,6 +235,27 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
153
235
|
|
|
154
236
|
_this = _super.call(this, props);
|
|
155
237
|
|
|
238
|
+
_defineProperty(_assertThisInitialized(_this), "getTableContext", (0, _memoizeOne.default)(function (state, isKeyboardNavigation) {
|
|
239
|
+
return {
|
|
240
|
+
activeCell: state.activeCell,
|
|
241
|
+
activeElement: state.activeElement,
|
|
242
|
+
mode: state.mode,
|
|
243
|
+
tableHasFocus: state.tableHasFocus,
|
|
244
|
+
changeActiveCell: _this.changeActiveCell,
|
|
245
|
+
changeActiveElement: _this.changeActiveElement,
|
|
246
|
+
handleKeyDown: _this.handleKeyDown,
|
|
247
|
+
registerInteractiveElement: _this.registerInteractiveElement,
|
|
248
|
+
allowKeyboardNavigation: state.allowKeyboardNavigation,
|
|
249
|
+
setAllowKeyboardNavigation: function setAllowKeyboardNavigation(allowKeyboardNavigation) {
|
|
250
|
+
if (isKeyboardNavigation) {
|
|
251
|
+
_this.setState({
|
|
252
|
+
allowKeyboardNavigation: allowKeyboardNavigation
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
}));
|
|
258
|
+
|
|
156
259
|
_defineProperty(_assertThisInitialized(_this), "handleToggleAll", function (e, _ref) {
|
|
157
260
|
var checked = _ref.checked;
|
|
158
261
|
|
|
@@ -186,7 +289,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
186
289
|
if (selected) {
|
|
187
290
|
selection = _this.props.selectRows === 'radio' ? [item] : [].concat(_toConsumableArray(_this.props.selection), [item]);
|
|
188
291
|
} else {
|
|
189
|
-
selection = (0,
|
|
292
|
+
selection = (0, _lodash3.default)(_this.props.selection, item);
|
|
190
293
|
}
|
|
191
294
|
|
|
192
295
|
_this.props.onChange(selection, e);
|
|
@@ -199,7 +302,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
199
302
|
if (selected) {
|
|
200
303
|
_selection2 = _this.props.selectRows === 'radio' ? [item] : [].concat(_toConsumableArray(_this.props.selection), [item]);
|
|
201
304
|
} else {
|
|
202
|
-
_selection2 = (0,
|
|
305
|
+
_selection2 = (0, _lodash3.default)(_this.props.selection, item);
|
|
203
306
|
}
|
|
204
307
|
|
|
205
308
|
_this.props.onRowChange(e, {
|
|
@@ -356,10 +459,6 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
356
459
|
this.loadMoreIfNeeded();
|
|
357
460
|
}
|
|
358
461
|
|
|
359
|
-
if (this.props.items !== prevProps.items) {
|
|
360
|
-
this.interactiveElements = {};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
462
|
if (this.state.allowKeyboardNavigation && !prevState.allowKeyboardNavigation) {
|
|
364
463
|
// When re-enabling keyboard navigation (e.g. when a dropdown closes), mark that
|
|
365
464
|
// focus has returned to the table. This must wait until after `allowKeyboardNavigation`
|
|
@@ -436,6 +535,14 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
436
535
|
|
|
437
536
|
return null;
|
|
438
537
|
}
|
|
538
|
+
}, {
|
|
539
|
+
key: "UNSAFE_componentWillUpdate",
|
|
540
|
+
value: // eslint-disable-next-line camelcase
|
|
541
|
+
function UNSAFE_componentWillUpdate(nextProps) {
|
|
542
|
+
if (this.props.items !== nextProps.items) {
|
|
543
|
+
this.interactiveElements = {};
|
|
544
|
+
}
|
|
545
|
+
}
|
|
439
546
|
}, {
|
|
440
547
|
key: "isResizable",
|
|
441
548
|
value: function isResizable() {
|
|
@@ -843,73 +950,12 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
843
950
|
var canSelectRows = this.props.selectRows && numNonHeaderRows > 0 ? this.props.selectRows : false;
|
|
844
951
|
var allSelected = canSelectRows && numNonHeaderRows === numSelected;
|
|
845
952
|
var indeterminateSelected = canSelectRows && numNonHeaderRows !== numSelected && numSelected !== 0;
|
|
846
|
-
var columns = [];
|
|
847
|
-
var RowActions = null;
|
|
848
953
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
children = _child$props.children,
|
|
853
|
-
columnProps = _objectWithoutProperties(_child$props, ["children"]);
|
|
954
|
+
var _getColumnsAndRowActi = getColumnsAndRowActions(this.props.children, this.props.id, this.getFixedHeader(), this.props.fixedLayout, this.props.search),
|
|
955
|
+
columns = _getColumnsAndRowActi.columns,
|
|
956
|
+
RowActions = _getColumnsAndRowActi.RowActions;
|
|
854
957
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
delete props.children;
|
|
858
|
-
(0, _lodash.default)(props, columnProps);
|
|
859
|
-
var Cell;
|
|
860
|
-
|
|
861
|
-
if (children && children.type.displayName === _constants.DATA_TABLE_CELL) {
|
|
862
|
-
Cell = children.type;
|
|
863
|
-
(0, _lodash.default)(props, children.props);
|
|
864
|
-
} else {
|
|
865
|
-
Cell = _cell.default;
|
|
866
|
-
} // eslint-disable-next-line fp/no-mutating-methods
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
columns.push({
|
|
870
|
-
Cell: Cell,
|
|
871
|
-
props: props,
|
|
872
|
-
dataTableProps: _this4.props
|
|
873
|
-
});
|
|
874
|
-
} else if (child && child.type.displayName === _rowActions.default.displayName) {
|
|
875
|
-
var dropdown = child.props.dropdown;
|
|
876
|
-
var dropdownPropOverrides = {};
|
|
877
|
-
|
|
878
|
-
if (_this4.getFixedHeader()) {
|
|
879
|
-
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
RowActions = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
883
|
-
dropdown: dropdown ? /*#__PURE__*/_react.default.cloneElement(dropdown, dropdownPropOverrides) : null
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
var assistiveText = _objectSpread(_objectSpread({}, defaultProps.assistiveText), this.props.assistiveText);
|
|
889
|
-
|
|
890
|
-
if (this.props.assistiveTextForActionsHeader) {
|
|
891
|
-
assistiveText.actionsHeader = this.props.assistiveTextForActionsHeader;
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
if (this.props.assistiveTextForSelectAllRows) {
|
|
895
|
-
assistiveText.selectAllRows = this.props.assistiveTextForSelectAllRows;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
if (this.props.assistiveTextForColumnSortedAscending) {
|
|
899
|
-
assistiveText.columnSortedAscending = this.props.assistiveTextForColumnSortedAscending;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
if (this.props.assistiveTextForColumnSortedDescending) {
|
|
903
|
-
assistiveText.columnSortedDescending = this.props.assistiveTextForColumnSortedDescending;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
if (this.props.assistiveTextForColumnSort) {
|
|
907
|
-
assistiveText.columnSort = this.props.assistiveTextForColumnSort;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
if (this.props.assistiveTextForSelectRow) {
|
|
911
|
-
assistiveText.selectRow = this.props.assistiveTextForSelectRow;
|
|
912
|
-
}
|
|
958
|
+
var assistiveText = getAssistiveText(this.props.assistiveText, this.props.assistiveTextForActionsHeader, this.props.assistiveTextForSelectAllRows, this.props.assistiveTextForColumnSortedAscending, this.props.assistiveTextForColumnSortedDescending, this.props.assistiveTextForColumnSort, this.props.assistiveTextForSelectRow);
|
|
913
959
|
|
|
914
960
|
if (this.props.selectRows && this.props.selectRows !== 'radio') {
|
|
915
961
|
ariaProps['aria-multiselectable'] = 'true';
|
|
@@ -921,27 +967,9 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
921
967
|
column: this.headerRefs.column.slice(0, columns.length),
|
|
922
968
|
select: canSelectRows ? this.headerRefs.select : []
|
|
923
969
|
};
|
|
924
|
-
var tableContext = {
|
|
925
|
-
activeCell: this.state.activeCell,
|
|
926
|
-
activeElement: this.state.activeElement,
|
|
927
|
-
mode: this.state.mode,
|
|
928
|
-
tableHasFocus: this.state.tableHasFocus,
|
|
929
|
-
changeActiveCell: this.changeActiveCell,
|
|
930
|
-
changeActiveElement: this.changeActiveElement,
|
|
931
|
-
handleKeyDown: this.handleKeyDown,
|
|
932
|
-
registerInteractiveElement: this.registerInteractiveElement,
|
|
933
|
-
allowKeyboardNavigation: this.state.allowKeyboardNavigation,
|
|
934
|
-
setAllowKeyboardNavigation: function setAllowKeyboardNavigation(allowKeyboardNavigation) {
|
|
935
|
-
if (_this4.getKeyboardNavigation()) {
|
|
936
|
-
_this4.setState({
|
|
937
|
-
allowKeyboardNavigation: allowKeyboardNavigation
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
970
|
|
|
943
971
|
var component = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_tableContext.default.Provider, {
|
|
944
|
-
value:
|
|
972
|
+
value: this.getTableContext(this.state, this.getKeyboardNavigation())
|
|
945
973
|
}, /*#__PURE__*/_react.default.createElement("table", _extends({}, ariaProps, {
|
|
946
974
|
className: (0, _classnames.default)('slds-table', {
|
|
947
975
|
'slds-table_fixed-layout': this.getFixedLayout(),
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = useTableContextHelper;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
7
9
|
|
|
8
10
|
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
|
|
9
11
|
|
|
@@ -12,22 +14,21 @@ exports.default = void 0;
|
|
|
12
14
|
/**
|
|
13
15
|
* Calculates data table keyboard navigation state based on currently selected cell
|
|
14
16
|
*/
|
|
15
|
-
|
|
17
|
+
function useTableContextHelper(tableContext, cellContext, fixedLayout) {
|
|
16
18
|
var isActive = tableContext.activeCell.rowIndex === cellContext.rowIndex && tableContext.activeCell.columnIndex === cellContext.columnIndex;
|
|
17
19
|
var hasFocus = fixedLayout && tableContext.tableHasFocus && isActive;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
var changeActiveCell = tableContext.changeActiveCell,
|
|
21
|
+
handleTableKeyDown = tableContext.handleKeyDown;
|
|
22
|
+
var handleFocus = (0, _react.useCallback)(function () {
|
|
20
23
|
if (fixedLayout && tableContext.allowKeyboardNavigation) {
|
|
21
|
-
|
|
24
|
+
changeActiveCell(cellContext.rowIndex, cellContext.columnIndex);
|
|
22
25
|
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
var handleKeyDown = function handleKeyDown(event) {
|
|
26
|
+
}, [fixedLayout, tableContext.allowKeyboardNavigation, changeActiveCell, cellContext.rowIndex, cellContext.columnIndex]);
|
|
27
|
+
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
26
28
|
if (fixedLayout && tableContext.allowKeyboardNavigation) {
|
|
27
|
-
|
|
29
|
+
handleTableKeyDown(event);
|
|
28
30
|
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
+
}, [fixedLayout, tableContext.allowKeyboardNavigation, handleTableKeyDown]);
|
|
31
32
|
var tabIndex = fixedLayout && isActive && !tableContext.activeElement && tableContext.allowKeyboardNavigation ? '0' : undefined;
|
|
32
33
|
return {
|
|
33
34
|
tabIndex: tabIndex,
|
|
@@ -35,6 +36,4 @@ var _default = function _default(tableContext, cellContext, fixedLayout) {
|
|
|
35
36
|
handleFocus: handleFocus,
|
|
36
37
|
handleKeyDown: handleKeyDown
|
|
37
38
|
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.default = _default;
|
|
39
|
+
}
|