@salesforce/design-system-react 0.10.44 → 0.10.47
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/button/__tests__/button.browser-test.jsx +0 -1
- package/components/combobox/combobox.d.ts +3 -0
- package/components/combobox/combobox.jsx +4 -1
- package/components/component-docs.json +6 -3
- package/components/data-table/cell.jsx +2 -2
- package/components/data-table/index.jsx +134 -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/pill-container/__docs__/__snapshots__/storybook-stories.storyshot +15 -15
- package/components/pill-container/private/selected-listbox.jsx +1 -0
- package/components/popover/__tests__/popover.browser-test.jsx +28 -0
- package/components/progress-indicator.d.ts +29 -8
- package/components/slider.d.ts +10 -4
- package/components/utilities/truncate/index.jsx +1 -1
- package/design-system-react-components.js +62406 -0
- package/design-system-react-components.js.map +1 -0
- package/design-system-react-components.min.js +3 -0
- package/design-system-react-components.min.js.LICENSE.txt +83 -0
- package/design-system-react-components.min.js.map +1 -0
- package/design-system-react.js +73800 -0
- package/design-system-react.js.map +1 -0
- package/design-system-react.min.js +3 -0
- package/design-system-react.min.js.LICENSE.txt +83 -0
- package/design-system-react.min.js.map +1 -0
- package/lib/components/button/__tests__/button.browser-test.jsx +0 -1
- package/lib/components/combobox/combobox.d.ts +3 -0
- package/lib/components/combobox/combobox.js +4 -1
- package/lib/components/component-docs.json +6 -3
- package/lib/components/data-table/cell.js +6 -6
- package/lib/components/data-table/index.js +131 -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/pill-container/__docs__/__snapshots__/storybook-stories.storyshot +15 -15
- package/lib/components/pill-container/private/selected-listbox.js +3 -0
- package/lib/components/popover/__tests__/popover.browser-test.jsx +28 -0
- package/lib/components/progress-indicator.d.ts +29 -8
- package/lib/components/slider.d.ts +10 -4
- package/lib/components/utilities/truncate/index.js +2 -2
- package/lib/design-system-react-components.min.js.LICENSE.txt +83 -0
- package/lib/design-system-react.min.js.LICENSE.txt +83 -0
- package/lib/package.json +5 -5
- package/lib/utilities/keyboard-navigable-dialog.js +6 -1
- 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/combobox.d.ts +3 -0
- package/module/components/combobox/combobox.js +4 -1
- package/module/components/combobox/combobox.js.map +1 -1
- package/module/components/component-docs.json +6 -3
- 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 +124 -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/pill-container/__docs__/__snapshots__/storybook-stories.storyshot +15 -15
- package/module/components/pill-container/private/selected-listbox.js +3 -0
- package/module/components/pill-container/private/selected-listbox.js.map +1 -1
- package/module/components/popover/__tests__/popover.browser-test.js +25 -0
- package/module/components/popover/__tests__/popover.browser-test.js.map +1 -1
- package/module/components/progress-indicator.d.ts +29 -8
- package/module/components/slider.d.ts +10 -4
- package/module/components/utilities/truncate/index.js +1 -1
- package/module/components/utilities/truncate/index.js.map +1 -1
- package/module/utilities/keyboard-navigable-dialog.js +4 -1
- package/module/utilities/keyboard-navigable-dialog.js.map +1 -1
- package/package.json +5 -5
- package/utilities/keyboard-navigable-dialog.js +3 -0
|
@@ -162,6 +162,7 @@ declare module '@salesforce/design-system-react/components/combobox/combobox' {
|
|
|
162
162
|
* * `id`: A unique identifier string.
|
|
163
163
|
* * `label`: A primary string of text for a menu item or group separator.
|
|
164
164
|
* * `subTitle`: A secondary string of text added for clarity. (optional)
|
|
165
|
+
* * `title`: A string of text shown as the title of the selected item (optional)
|
|
165
166
|
* * `type`: 'separator' is the only type currently used
|
|
166
167
|
* * `disabled`: Set to true to disable this menu item.
|
|
167
168
|
* * `tooltipContent`: Content that is displayed in tooltip when item is disabled
|
|
@@ -170,6 +171,7 @@ declare module '@salesforce/design-system-react/components/combobox/combobox' {
|
|
|
170
171
|
* id: '2',
|
|
171
172
|
* label: 'Salesforce.com, Inc.',
|
|
172
173
|
* subTitle: 'Account • San Francisco',
|
|
174
|
+
* title: 'Salesforce',
|
|
173
175
|
* type: 'account',
|
|
174
176
|
* disabled: true,
|
|
175
177
|
* tooltipContent: "You don't have permission to select this item."
|
|
@@ -182,6 +184,7 @@ declare module '@salesforce/design-system-react/components/combobox/combobox' {
|
|
|
182
184
|
icon?: React.ReactNode;
|
|
183
185
|
label?: string;
|
|
184
186
|
subTitle?: string;
|
|
187
|
+
title?: string;
|
|
185
188
|
type?: string;
|
|
186
189
|
disabled?: boolean;
|
|
187
190
|
tooltipContent?: React.ReactNode;
|
|
@@ -302,6 +302,7 @@ var propTypes = {
|
|
|
302
302
|
* * `id`: A unique identifier string.
|
|
303
303
|
* * `label`: A primary string of text for a menu item or group separator.
|
|
304
304
|
* * `subTitle`: A secondary string of text added for clarity. (optional)
|
|
305
|
+
* * `title`: A string of text shown as the title of the selected item (optional)
|
|
305
306
|
* * `type`: 'separator' is the only type currently used
|
|
306
307
|
* * `disabled`: Set to true to disable this menu item.
|
|
307
308
|
* * `tooltipContent`: Content that is displayed in tooltip when item is disabled
|
|
@@ -310,6 +311,7 @@ var propTypes = {
|
|
|
310
311
|
* id: '2',
|
|
311
312
|
* label: 'Salesforce.com, Inc.',
|
|
312
313
|
* subTitle: 'Account • San Francisco',
|
|
314
|
+
* title: 'Salesforce',
|
|
313
315
|
* type: 'account',
|
|
314
316
|
* disabled: true,
|
|
315
317
|
* tooltipContent: "You don't have permission to select this item."
|
|
@@ -322,8 +324,9 @@ var propTypes = {
|
|
|
322
324
|
icon: _propTypes.default.node,
|
|
323
325
|
label: _propTypes.default.string,
|
|
324
326
|
subTitle: _propTypes.default.string,
|
|
327
|
+
title: _propTypes.default.string,
|
|
325
328
|
type: _propTypes.default.string,
|
|
326
|
-
disabled: _propTypes.default.
|
|
329
|
+
disabled: _propTypes.default.bool,
|
|
327
330
|
tooltipContent: _propTypes.default.node
|
|
328
331
|
})),
|
|
329
332
|
|
|
@@ -4958,13 +4958,16 @@
|
|
|
4958
4958
|
"name": "string",
|
|
4959
4959
|
"required": false
|
|
4960
4960
|
},
|
|
4961
|
+
"title": {
|
|
4962
|
+
"name": "string",
|
|
4963
|
+
"required": false
|
|
4964
|
+
},
|
|
4961
4965
|
"type": {
|
|
4962
4966
|
"name": "string",
|
|
4963
4967
|
"required": false
|
|
4964
4968
|
},
|
|
4965
4969
|
"disabled": {
|
|
4966
|
-
"name": "
|
|
4967
|
-
"raw": "PropTypes.boolean",
|
|
4970
|
+
"name": "bool",
|
|
4968
4971
|
"required": false
|
|
4969
4972
|
},
|
|
4970
4973
|
"tooltipContent": {
|
|
@@ -4975,7 +4978,7 @@
|
|
|
4975
4978
|
}
|
|
4976
4979
|
},
|
|
4977
4980
|
"required": false,
|
|
4978
|
-
"description": "**Array of item objects in the dropdown menu.**\nEach object can contain:\n* `icon`: An `Icon` component. (not used in read-only variant)\n* `id`: A unique identifier string.\n* `label`: A primary string of text for a menu item or group separator.\n* `subTitle`: A secondary string of text added for clarity. (optional)\n* `type`: 'separator' is the only type currently used\n* `disabled`: Set to true to disable this menu item.\n* `tooltipContent`: Content that is displayed in tooltip when item is disabled\n```\n{\n\tid: '2',\n\tlabel: 'Salesforce.com, Inc.',\n\tsubTitle: 'Account • San Francisco',\n\ttype: 'account',\n disabled: true,\n tooltipContent: \"You don't have permission to select this item.\"\n},\n```\nNote: At the moment, Combobox does not support two consecutive separators. _Tested with snapshot testing._"
|
|
4981
|
+
"description": "**Array of item objects in the dropdown menu.**\nEach object can contain:\n* `icon`: An `Icon` component. (not used in read-only variant)\n* `id`: A unique identifier string.\n* `label`: A primary string of text for a menu item or group separator.\n* `subTitle`: A secondary string of text added for clarity. (optional)\n* `title`: A string of text shown as the title of the selected item (optional)\n* `type`: 'separator' is the only type currently used\n* `disabled`: Set to true to disable this menu item.\n* `tooltipContent`: Content that is displayed in tooltip when item is disabled\n```\n{\n\tid: '2',\n\tlabel: 'Salesforce.com, Inc.',\n\tsubTitle: 'Account • San Francisco',\n\ttitle: 'Salesforce',\n\ttype: 'account',\n disabled: true,\n tooltipContent: \"You don't have permission to select this item.\"\n},\n```\nNote: At the moment, Combobox does not support two consecutive separators. _Tested with snapshot testing._"
|
|
4979
4982
|
},
|
|
4980
4983
|
"menuItemVisibleLength": {
|
|
4981
4984
|
"type": {
|
|
@@ -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,88 @@ 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, items, 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
|
+
items: items
|
|
182
|
+
}, columnProps);
|
|
183
|
+
|
|
184
|
+
if (id) {
|
|
185
|
+
props.id = id;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
var Cell;
|
|
189
|
+
|
|
190
|
+
if (columnChildren && columnChildren.type.displayName === _constants.DATA_TABLE_CELL) {
|
|
191
|
+
Cell = columnChildren.type;
|
|
192
|
+
(0, _lodash.default)(props, columnChildren.props);
|
|
193
|
+
} else {
|
|
194
|
+
Cell = _cell.default;
|
|
195
|
+
} // eslint-disable-next-line fp/no-mutating-methods
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
columns.push({
|
|
199
|
+
Cell: Cell,
|
|
200
|
+
props: props
|
|
201
|
+
});
|
|
202
|
+
} else if (child && child.type.displayName === _rowActions.default.displayName) {
|
|
203
|
+
var dropdown = child.props.dropdown;
|
|
204
|
+
var dropdownPropOverrides = {};
|
|
205
|
+
|
|
206
|
+
if (fixedHeader) {
|
|
207
|
+
dropdownPropOverrides.menuPosition = 'overflowBoundaryElement';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
RowActions = /*#__PURE__*/_react.default.cloneElement(child, {
|
|
211
|
+
dropdown: dropdown ? /*#__PURE__*/_react.default.cloneElement(dropdown, dropdownPropOverrides) : null
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
columns: columns,
|
|
218
|
+
RowActions: RowActions
|
|
219
|
+
};
|
|
220
|
+
}, _lodash2.default);
|
|
135
221
|
/**
|
|
136
222
|
* 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
223
|
*
|
|
@@ -153,6 +239,27 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
153
239
|
|
|
154
240
|
_this = _super.call(this, props);
|
|
155
241
|
|
|
242
|
+
_defineProperty(_assertThisInitialized(_this), "getTableContext", (0, _memoizeOne.default)(function (state, isKeyboardNavigation) {
|
|
243
|
+
return {
|
|
244
|
+
activeCell: state.activeCell,
|
|
245
|
+
activeElement: state.activeElement,
|
|
246
|
+
mode: state.mode,
|
|
247
|
+
tableHasFocus: state.tableHasFocus,
|
|
248
|
+
changeActiveCell: _this.changeActiveCell,
|
|
249
|
+
changeActiveElement: _this.changeActiveElement,
|
|
250
|
+
handleKeyDown: _this.handleKeyDown,
|
|
251
|
+
registerInteractiveElement: _this.registerInteractiveElement,
|
|
252
|
+
allowKeyboardNavigation: state.allowKeyboardNavigation,
|
|
253
|
+
setAllowKeyboardNavigation: function setAllowKeyboardNavigation(allowKeyboardNavigation) {
|
|
254
|
+
if (isKeyboardNavigation) {
|
|
255
|
+
_this.setState({
|
|
256
|
+
allowKeyboardNavigation: allowKeyboardNavigation
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
}));
|
|
262
|
+
|
|
156
263
|
_defineProperty(_assertThisInitialized(_this), "handleToggleAll", function (e, _ref) {
|
|
157
264
|
var checked = _ref.checked;
|
|
158
265
|
|
|
@@ -186,7 +293,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
186
293
|
if (selected) {
|
|
187
294
|
selection = _this.props.selectRows === 'radio' ? [item] : [].concat(_toConsumableArray(_this.props.selection), [item]);
|
|
188
295
|
} else {
|
|
189
|
-
selection = (0,
|
|
296
|
+
selection = (0, _lodash3.default)(_this.props.selection, item);
|
|
190
297
|
}
|
|
191
298
|
|
|
192
299
|
_this.props.onChange(selection, e);
|
|
@@ -199,7 +306,7 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
199
306
|
if (selected) {
|
|
200
307
|
_selection2 = _this.props.selectRows === 'radio' ? [item] : [].concat(_toConsumableArray(_this.props.selection), [item]);
|
|
201
308
|
} else {
|
|
202
|
-
_selection2 = (0,
|
|
309
|
+
_selection2 = (0, _lodash3.default)(_this.props.selection, item);
|
|
203
310
|
}
|
|
204
311
|
|
|
205
312
|
_this.props.onRowChange(e, {
|
|
@@ -356,10 +463,6 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
356
463
|
this.loadMoreIfNeeded();
|
|
357
464
|
}
|
|
358
465
|
|
|
359
|
-
if (this.props.items !== prevProps.items) {
|
|
360
|
-
this.interactiveElements = {};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
466
|
if (this.state.allowKeyboardNavigation && !prevState.allowKeyboardNavigation) {
|
|
364
467
|
// When re-enabling keyboard navigation (e.g. when a dropdown closes), mark that
|
|
365
468
|
// focus has returned to the table. This must wait until after `allowKeyboardNavigation`
|
|
@@ -436,6 +539,14 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
436
539
|
|
|
437
540
|
return null;
|
|
438
541
|
}
|
|
542
|
+
}, {
|
|
543
|
+
key: "UNSAFE_componentWillUpdate",
|
|
544
|
+
value: // eslint-disable-next-line camelcase
|
|
545
|
+
function UNSAFE_componentWillUpdate(nextProps) {
|
|
546
|
+
if (this.props.items !== nextProps.items) {
|
|
547
|
+
this.interactiveElements = {};
|
|
548
|
+
}
|
|
549
|
+
}
|
|
439
550
|
}, {
|
|
440
551
|
key: "isResizable",
|
|
441
552
|
value: function isResizable() {
|
|
@@ -843,73 +954,12 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
843
954
|
var canSelectRows = this.props.selectRows && numNonHeaderRows > 0 ? this.props.selectRows : false;
|
|
844
955
|
var allSelected = canSelectRows && numNonHeaderRows === numSelected;
|
|
845
956
|
var indeterminateSelected = canSelectRows && numNonHeaderRows !== numSelected && numSelected !== 0;
|
|
846
|
-
var columns = [];
|
|
847
|
-
var RowActions = null;
|
|
848
|
-
|
|
849
|
-
_react.default.Children.forEach(this.props.children, function (child) {
|
|
850
|
-
if (child && child.type.displayName === _column.default.displayName) {
|
|
851
|
-
var _child$props = child.props,
|
|
852
|
-
children = _child$props.children,
|
|
853
|
-
columnProps = _objectWithoutProperties(_child$props, ["children"]);
|
|
854
|
-
|
|
855
|
-
var props = (0, _lodash.default)({}, _this4.props); // eslint-disable-next-line fp/no-delete
|
|
856
957
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
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
|
|
958
|
+
var _getColumnsAndRowActi = getColumnsAndRowActions(this.props.children, this.props.id, this.getFixedHeader(), this.props.fixedLayout, this.props.items, this.props.search),
|
|
959
|
+
columns = _getColumnsAndRowActi.columns,
|
|
960
|
+
RowActions = _getColumnsAndRowActi.RowActions;
|
|
867
961
|
|
|
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
|
-
}
|
|
962
|
+
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
963
|
|
|
914
964
|
if (this.props.selectRows && this.props.selectRows !== 'radio') {
|
|
915
965
|
ariaProps['aria-multiselectable'] = 'true';
|
|
@@ -921,27 +971,9 @@ var DataTable = /*#__PURE__*/function (_React$Component) {
|
|
|
921
971
|
column: this.headerRefs.column.slice(0, columns.length),
|
|
922
972
|
select: canSelectRows ? this.headerRefs.select : []
|
|
923
973
|
};
|
|
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
974
|
|
|
943
975
|
var component = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_tableContext.default.Provider, {
|
|
944
|
-
value:
|
|
976
|
+
value: this.getTableContext(this.state, this.getKeyboardNavigation())
|
|
945
977
|
}, /*#__PURE__*/_react.default.createElement("table", _extends({}, ariaProps, {
|
|
946
978
|
className: (0, _classnames.default)('slds-table', {
|
|
947
979
|
'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
|
+
}
|