@salesforce/design-system-react 0.10.43 → 0.10.46
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.d.ts +3 -0
- package/components/combobox/combobox.jsx +7 -1
- package/components/component-docs.json +14 -39
- 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/site-stories.js +8 -4
- package/components/slider.d.ts +10 -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.d.ts +3 -0
- package/lib/components/combobox/combobox.js +9 -2
- package/lib/components/component-docs.json +14 -39
- 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/site-stories.js +6 -3
- package/lib/components/slider.d.ts +10 -4
- package/lib/components/utilities/truncate/index.js +2 -2
- package/lib/package.json +14 -10
- 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.d.ts +3 -0
- package/module/components/combobox/combobox.js +9 -2
- package/module/components/combobox/combobox.js.map +1 -1
- package/module/components/component-docs.json +14 -39
- 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/site-stories.js +6 -3
- package/module/components/site-stories.js.map +1 -1
- 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/package.json +14 -10
- package/module/components/brand-band/__examples__/lightning-blue-theme.js.map +0 -1
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
6
|
-
|
|
7
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
1
|
+
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; }
|
|
10
2
|
|
|
11
|
-
function
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
12
4
|
|
|
13
|
-
function
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
6
|
|
|
15
|
-
function
|
|
7
|
+
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."); }
|
|
16
8
|
|
|
17
|
-
function
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
18
10
|
|
|
19
|
-
function
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
20
12
|
|
|
21
|
-
function
|
|
13
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
22
14
|
|
|
23
|
-
function
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
24
16
|
|
|
25
17
|
/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */
|
|
26
18
|
|
|
27
19
|
/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */
|
|
28
20
|
// ### React
|
|
29
|
-
import React from 'react';
|
|
21
|
+
import React, { useContext, useEffect, useRef, useState } from 'react';
|
|
30
22
|
import PropTypes from 'prop-types'; // ### classNames
|
|
31
23
|
|
|
32
24
|
import classNames from 'classnames'; // ### isFunction
|
|
@@ -41,215 +33,11 @@ import Link from './link';
|
|
|
41
33
|
import InteractiveLink from '../interactive-link';
|
|
42
34
|
import CellContext from '../private/cell-context';
|
|
43
35
|
import TableContext from '../private/table-context';
|
|
44
|
-
import
|
|
45
|
-
|
|
46
|
-
import { DATA_TABLE_HEADER_CELL, DATA_TABLE_COLUMN } from '../../../utilities/constants';
|
|
47
|
-
/**
|
|
48
|
-
* Used internally, renders each individual column heading.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
var DataTableHeaderCell = /*#__PURE__*/function (_React$Component) {
|
|
52
|
-
_inherits(DataTableHeaderCell, _React$Component);
|
|
53
|
-
|
|
54
|
-
var _super = _createSuper(DataTableHeaderCell);
|
|
55
|
-
|
|
56
|
-
function DataTableHeaderCell() {
|
|
57
|
-
var _this;
|
|
58
|
-
|
|
59
|
-
_classCallCheck(this, DataTableHeaderCell);
|
|
60
|
-
|
|
61
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
62
|
-
args[_key] = arguments[_key];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
66
|
-
|
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
68
|
-
sortDirection: null
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "handleSort", function (e) {
|
|
72
|
-
e.preventDefault();
|
|
73
|
-
var oldSortDirection = _this.props.sortDirection || _this.state.sortDirection; // UX pattern: If sortable, and the DataTable's parent has not defined the sort order, then ascending (that is A->Z) is the default sort order on first click. Some columns, such as "last viewed" or "recently updated," should sort descending first, since that is what the user probably wants. Who wants to see the oldest files first?
|
|
74
|
-
|
|
75
|
-
var sortDirection = function sortDirectionFunction(direction, isDefaultSortDescending) {
|
|
76
|
-
switch (direction) {
|
|
77
|
-
case 'asc':
|
|
78
|
-
return 'desc';
|
|
79
|
-
|
|
80
|
-
case 'desc':
|
|
81
|
-
return 'asc';
|
|
82
|
-
|
|
83
|
-
case null:
|
|
84
|
-
return isDefaultSortDescending ? 'desc' : 'asc';
|
|
85
|
-
|
|
86
|
-
default:
|
|
87
|
-
return 'asc';
|
|
88
|
-
}
|
|
89
|
-
}(oldSortDirection, _this.props.isDefaultSortDescending);
|
|
90
|
-
|
|
91
|
-
var data = {
|
|
92
|
-
property: _this.props.property,
|
|
93
|
-
sortDirection: sortDirection
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
_this.setState({
|
|
97
|
-
sortDirection: sortDirection
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
if (isFunction(_this.props.onSort)) {
|
|
101
|
-
_this.props.onSort(data, e);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
36
|
+
import useContextHelper from './context-helper'; // ## Constants
|
|
104
37
|
|
|
105
|
-
|
|
106
|
-
}
|
|
38
|
+
import { DATA_TABLE_HEADER_CELL, DATA_TABLE_COLUMN } from '../../../utilities/constants'; // ### Prop Types
|
|
107
39
|
|
|
108
|
-
|
|
109
|
-
key: "componentDidMount",
|
|
110
|
-
value: function componentDidMount() {
|
|
111
|
-
checkProps(DATA_TABLE_COLUMN, this.props);
|
|
112
|
-
}
|
|
113
|
-
}, {
|
|
114
|
-
key: "componentDidUpdate",
|
|
115
|
-
value: function componentDidUpdate(prevProps) {
|
|
116
|
-
// reset sort state when another column is sorted
|
|
117
|
-
if (prevProps.isSorted === true && this.props.isSorted === false) {
|
|
118
|
-
this.setState({
|
|
119
|
-
sortDirection: null
|
|
120
|
-
}); // eslint-disable-line react/no-did-update-set-state
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
key: "render",
|
|
125
|
-
value: // ### Render
|
|
126
|
-
function render() {
|
|
127
|
-
var _this2 = this;
|
|
128
|
-
|
|
129
|
-
var _this$props = this.props,
|
|
130
|
-
fixedHeader = _this$props.fixedHeader,
|
|
131
|
-
isSorted = _this$props.isSorted,
|
|
132
|
-
label = _this$props.label,
|
|
133
|
-
sortable = _this$props.sortable,
|
|
134
|
-
width = _this$props.width,
|
|
135
|
-
property = _this$props.property;
|
|
136
|
-
|
|
137
|
-
var labelType = _typeof(label); // This decides which arrow to render--which is current sort order if the column is sorted OR the future sort order if the arrow is clicked in the future.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var sortDirection = this.props.sortDirection || this.state.sortDirection || this.props.isDefaultSortDescending && 'desc';
|
|
141
|
-
var expandedSortDirection = sortDirection === 'desc' ? 'descending' : 'ascending';
|
|
142
|
-
var ariaSort = isSorted ? expandedSortDirection : 'none';
|
|
143
|
-
|
|
144
|
-
var getFixedLayoutSubRenders = function getFixedLayoutSubRenders(isHidden) {
|
|
145
|
-
if (sortable) {
|
|
146
|
-
// Don't make the anchor interactable when it's hidden
|
|
147
|
-
var SortLink = isHidden ? Link : InteractiveLink;
|
|
148
|
-
return /*#__PURE__*/React.createElement(SortLink, {
|
|
149
|
-
href: "#",
|
|
150
|
-
className: "slds-th__action slds-text-link_reset",
|
|
151
|
-
onClick: _this2.handleSort,
|
|
152
|
-
role: "button"
|
|
153
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
154
|
-
className: "slds-assistive-text"
|
|
155
|
-
}, _this2.props.assistiveTextForColumnSort || _this2.props.assistiveText.columnSort, ' '), /*#__PURE__*/React.createElement("span", {
|
|
156
|
-
className: "slds-truncate",
|
|
157
|
-
title: labelType === 'string' ? label : undefined
|
|
158
|
-
}, label), /*#__PURE__*/React.createElement(Icon, {
|
|
159
|
-
className: "slds-is-sortable__icon",
|
|
160
|
-
category: "utility",
|
|
161
|
-
name: sortDirection === 'desc' ? 'arrowdown' : 'arrowup',
|
|
162
|
-
size: "x-small"
|
|
163
|
-
}), sortDirection ? /*#__PURE__*/React.createElement("span", {
|
|
164
|
-
className: "slds-assistive-text",
|
|
165
|
-
"aria-atomic": "true"
|
|
166
|
-
}, sortDirection === 'asc' ? _this2.props.assistiveTextForColumnSortedAscending || _this2.props.assistiveText.columnSortedAscending : _this2.props.assistiveTextForColumnSortedDescending || _this2.props.assistiveText.columnSortedDescending) : null);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return /*#__PURE__*/React.createElement("span", {
|
|
170
|
-
className: "slds-p-horizontal_x-small slds-th__action",
|
|
171
|
-
style: {
|
|
172
|
-
display: 'flex'
|
|
173
|
-
}
|
|
174
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
175
|
-
className: "slds-truncate",
|
|
176
|
-
title: labelType === 'string' ? label : undefined
|
|
177
|
-
}, label));
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
var getHeaderCellContent = function getHeaderCellContent(isHidden) {
|
|
181
|
-
return _this2.props.fixedLayout ? getFixedLayoutSubRenders(isHidden) : /*#__PURE__*/React.createElement("div", {
|
|
182
|
-
className: "slds-truncate",
|
|
183
|
-
title: labelType === 'string' ? label : undefined
|
|
184
|
-
}, label);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
return /*#__PURE__*/React.createElement(TableContext.Consumer, null, function (tableContext) {
|
|
188
|
-
return /*#__PURE__*/React.createElement(CellContext.Consumer, null, function (cellContext) {
|
|
189
|
-
var _classNames;
|
|
190
|
-
|
|
191
|
-
var _contextHelper = contextHelper(tableContext, cellContext, _this2.props.fixedLayout),
|
|
192
|
-
tabIndex = _contextHelper.tabIndex,
|
|
193
|
-
hasFocus = _contextHelper.hasFocus,
|
|
194
|
-
handleFocus = _contextHelper.handleFocus,
|
|
195
|
-
handleKeyDown = _contextHelper.handleKeyDown;
|
|
196
|
-
|
|
197
|
-
return /*#__PURE__*/React.createElement("th", {
|
|
198
|
-
id: "".concat(_this2.props.id, "-").concat(property, "-th"),
|
|
199
|
-
"aria-label": labelType === 'string' ? label : undefined,
|
|
200
|
-
"aria-sort": ariaSort,
|
|
201
|
-
className: classNames((_classNames = {
|
|
202
|
-
'slds-is-sortable': sortable,
|
|
203
|
-
'slds-is-sorted': isSorted
|
|
204
|
-
}, _defineProperty(_classNames, "slds-is-sorted_".concat(sortDirection), sortDirection), _defineProperty(_classNames, 'slds-is-sorted_asc', isSorted && !sortDirection), _classNames)),
|
|
205
|
-
onFocus: handleFocus,
|
|
206
|
-
onKeyDown: handleKeyDown,
|
|
207
|
-
ref: function ref(_ref) {
|
|
208
|
-
if (_this2.props.cellRef) {
|
|
209
|
-
_this2.props.cellRef(_ref);
|
|
210
|
-
|
|
211
|
-
if (_ref && hasFocus) {
|
|
212
|
-
_ref.focus();
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
scope: "col",
|
|
217
|
-
style: fixedHeader || width ? {
|
|
218
|
-
height: fixedHeader ? 0 : null,
|
|
219
|
-
lineHeight: fixedHeader ? 0 : null,
|
|
220
|
-
width: width || null
|
|
221
|
-
} : null,
|
|
222
|
-
tabIndex: tabIndex
|
|
223
|
-
}, fixedHeader ? /*#__PURE__*/React.cloneElement(getHeaderCellContent(true), {
|
|
224
|
-
style: {
|
|
225
|
-
display: 'flex',
|
|
226
|
-
height: 0,
|
|
227
|
-
overflow: 'hidden',
|
|
228
|
-
paddingBottom: 0,
|
|
229
|
-
paddingTop: 0,
|
|
230
|
-
visibility: 'hidden'
|
|
231
|
-
}
|
|
232
|
-
}) : getHeaderCellContent(), fixedHeader ? /*#__PURE__*/React.createElement(CellFixed, null, /*#__PURE__*/React.cloneElement(getHeaderCellContent(), {
|
|
233
|
-
style: {
|
|
234
|
-
alignItems: 'center',
|
|
235
|
-
display: 'flex',
|
|
236
|
-
flex: '1 1 auto',
|
|
237
|
-
lineHeight: 1.25,
|
|
238
|
-
width: '100%'
|
|
239
|
-
},
|
|
240
|
-
tabIndex: sortable ? 0 : null
|
|
241
|
-
})) : null);
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}]);
|
|
246
|
-
|
|
247
|
-
return DataTableHeaderCell;
|
|
248
|
-
}(React.Component);
|
|
249
|
-
|
|
250
|
-
_defineProperty(DataTableHeaderCell, "displayName", DATA_TABLE_HEADER_CELL);
|
|
251
|
-
|
|
252
|
-
_defineProperty(DataTableHeaderCell, "propTypes", {
|
|
40
|
+
var propTypes = {
|
|
253
41
|
assistiveText: PropTypes.shape({
|
|
254
42
|
actionsHeader: PropTypes.string,
|
|
255
43
|
columnSort: PropTypes.string,
|
|
@@ -301,7 +89,178 @@ _defineProperty(DataTableHeaderCell, "propTypes", {
|
|
|
301
89
|
* Width of column. This is required for advanced/fixed layout tables. Please provide units. (`rems` are recommended)
|
|
302
90
|
*/
|
|
303
91
|
width: PropTypes.string
|
|
304
|
-
}
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Used internally, renders each individual column heading.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
var DataTableHeaderCell = function DataTableHeaderCell(props) {
|
|
98
|
+
var _classNames;
|
|
99
|
+
|
|
100
|
+
var _useState = useState(null),
|
|
101
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
102
|
+
sortDirection = _useState2[0],
|
|
103
|
+
setSortDirection = _useState2[1];
|
|
104
|
+
|
|
105
|
+
var prevIsSorted = useRef(null);
|
|
106
|
+
var tableContext = useContext(TableContext);
|
|
107
|
+
var cellContext = useContext(CellContext);
|
|
108
|
+
|
|
109
|
+
var _useContextHelper = useContextHelper(tableContext, cellContext, props.fixedLayout),
|
|
110
|
+
tabIndex = _useContextHelper.tabIndex,
|
|
111
|
+
hasFocus = _useContextHelper.hasFocus,
|
|
112
|
+
handleFocus = _useContextHelper.handleFocus,
|
|
113
|
+
handleKeyDown = _useContextHelper.handleKeyDown;
|
|
114
|
+
|
|
115
|
+
useEffect(function () {
|
|
116
|
+
checkProps(DATA_TABLE_COLUMN, props); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
117
|
+
}, []);
|
|
118
|
+
useEffect(function () {
|
|
119
|
+
if (prevIsSorted.current === true && props.isSorted === false) {
|
|
120
|
+
setSortDirection(null);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
prevIsSorted.current = props.isSorted;
|
|
124
|
+
}, [props.isSorted]);
|
|
305
125
|
|
|
126
|
+
var handleSort = function handleSort(e) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
var oldSortDirection = props.sortDirection || sortDirection; // UX pattern: If sortable, and the DataTable's parent has not defined the sort order, then ascending (that is A->Z) is the default sort order on first click. Some columns, such as "last viewed" or "recently updated," should sort descending first, since that is what the user probably wants. Who wants to see the oldest files first?
|
|
129
|
+
|
|
130
|
+
var newSortDirection = function sortDirectionFunction(direction, isDefaultSortDescending) {
|
|
131
|
+
switch (direction) {
|
|
132
|
+
case 'asc':
|
|
133
|
+
return 'desc';
|
|
134
|
+
|
|
135
|
+
case 'desc':
|
|
136
|
+
return 'asc';
|
|
137
|
+
|
|
138
|
+
case null:
|
|
139
|
+
return isDefaultSortDescending ? 'desc' : 'asc';
|
|
140
|
+
|
|
141
|
+
default:
|
|
142
|
+
return 'asc';
|
|
143
|
+
}
|
|
144
|
+
}(oldSortDirection, props.isDefaultSortDescending);
|
|
145
|
+
|
|
146
|
+
var data = {
|
|
147
|
+
property: props.property,
|
|
148
|
+
sortDirection: newSortDirection
|
|
149
|
+
};
|
|
150
|
+
setSortDirection(newSortDirection);
|
|
151
|
+
|
|
152
|
+
if (isFunction(props.onSort)) {
|
|
153
|
+
props.onSort(data, e);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var fixedHeader = props.fixedHeader,
|
|
158
|
+
isSorted = props.isSorted,
|
|
159
|
+
label = props.label,
|
|
160
|
+
sortable = props.sortable,
|
|
161
|
+
width = props.width,
|
|
162
|
+
property = props.property;
|
|
163
|
+
|
|
164
|
+
var labelType = _typeof(label); // This decides which arrow to render--which is current sort order if the column is sorted OR the future sort order if the arrow is clicked in the future.
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
var effectiveSortDirection = props.sortDirection || sortDirection || props.isDefaultSortDescending && 'desc';
|
|
168
|
+
var expandedSortDirection = effectiveSortDirection === 'desc' ? 'descending' : 'ascending';
|
|
169
|
+
var ariaSort = isSorted ? expandedSortDirection : 'none';
|
|
170
|
+
|
|
171
|
+
var getFixedLayoutSubRenders = function getFixedLayoutSubRenders(isHidden) {
|
|
172
|
+
if (sortable) {
|
|
173
|
+
// Don't make the anchor interactable when it's hidden
|
|
174
|
+
var SortLink = isHidden ? Link : InteractiveLink;
|
|
175
|
+
return /*#__PURE__*/React.createElement(SortLink, {
|
|
176
|
+
href: "#",
|
|
177
|
+
className: "slds-th__action slds-text-link_reset",
|
|
178
|
+
onClick: handleSort,
|
|
179
|
+
role: "button"
|
|
180
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
181
|
+
className: "slds-assistive-text"
|
|
182
|
+
}, props.assistiveTextForColumnSort || props.assistiveText.columnSort, ' '), /*#__PURE__*/React.createElement("span", {
|
|
183
|
+
className: "slds-truncate",
|
|
184
|
+
title: labelType === 'string' ? label : undefined
|
|
185
|
+
}, label), /*#__PURE__*/React.createElement(Icon, {
|
|
186
|
+
className: "slds-is-sortable__icon",
|
|
187
|
+
category: "utility",
|
|
188
|
+
name: effectiveSortDirection === 'desc' ? 'arrowdown' : 'arrowup',
|
|
189
|
+
size: "x-small"
|
|
190
|
+
}), effectiveSortDirection ? /*#__PURE__*/React.createElement("span", {
|
|
191
|
+
className: "slds-assistive-text",
|
|
192
|
+
"aria-atomic": "true"
|
|
193
|
+
}, effectiveSortDirection === 'asc' ? props.assistiveTextForColumnSortedAscending || props.assistiveText.columnSortedAscending : props.assistiveTextForColumnSortedDescending || props.assistiveText.columnSortedDescending) : null);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
197
|
+
className: "slds-p-horizontal_x-small slds-th__action",
|
|
198
|
+
style: {
|
|
199
|
+
display: 'flex'
|
|
200
|
+
}
|
|
201
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
202
|
+
className: "slds-truncate",
|
|
203
|
+
title: labelType === 'string' ? label : undefined
|
|
204
|
+
}, label));
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
var getHeaderCellContent = function getHeaderCellContent(isHidden) {
|
|
208
|
+
return props.fixedLayout ? getFixedLayoutSubRenders(isHidden) : /*#__PURE__*/React.createElement("div", {
|
|
209
|
+
className: "slds-truncate",
|
|
210
|
+
title: labelType === 'string' ? label : undefined
|
|
211
|
+
}, label);
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
215
|
+
id: "".concat(props.id, "-").concat(property, "-th"),
|
|
216
|
+
"aria-label": labelType === 'string' ? label : undefined,
|
|
217
|
+
"aria-sort": ariaSort,
|
|
218
|
+
className: classNames((_classNames = {
|
|
219
|
+
'slds-is-sortable': sortable,
|
|
220
|
+
'slds-is-sorted': isSorted
|
|
221
|
+
}, _defineProperty(_classNames, "slds-is-sorted_".concat(effectiveSortDirection), effectiveSortDirection), _defineProperty(_classNames, 'slds-is-sorted_asc', isSorted && !effectiveSortDirection), _classNames)),
|
|
222
|
+
onFocus: handleFocus,
|
|
223
|
+
onKeyDown: handleKeyDown,
|
|
224
|
+
ref: function ref(_ref) {
|
|
225
|
+
if (props.cellRef) {
|
|
226
|
+
props.cellRef(_ref);
|
|
227
|
+
|
|
228
|
+
if (_ref && hasFocus) {
|
|
229
|
+
_ref.focus();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
scope: "col",
|
|
234
|
+
style: fixedHeader || width ? {
|
|
235
|
+
height: fixedHeader ? 0 : null,
|
|
236
|
+
lineHeight: fixedHeader ? 0 : null,
|
|
237
|
+
width: width || null
|
|
238
|
+
} : null,
|
|
239
|
+
tabIndex: tabIndex
|
|
240
|
+
}, fixedHeader ? /*#__PURE__*/React.cloneElement(getHeaderCellContent(true), {
|
|
241
|
+
style: {
|
|
242
|
+
display: 'flex',
|
|
243
|
+
height: 0,
|
|
244
|
+
overflow: 'hidden',
|
|
245
|
+
paddingBottom: 0,
|
|
246
|
+
paddingTop: 0,
|
|
247
|
+
visibility: 'hidden'
|
|
248
|
+
}
|
|
249
|
+
}) : getHeaderCellContent(), fixedHeader ? /*#__PURE__*/React.createElement(CellFixed, null, /*#__PURE__*/React.cloneElement(getHeaderCellContent(), {
|
|
250
|
+
style: {
|
|
251
|
+
alignItems: 'center',
|
|
252
|
+
display: 'flex',
|
|
253
|
+
flex: '1 1 auto',
|
|
254
|
+
lineHeight: 1.25,
|
|
255
|
+
width: '100%'
|
|
256
|
+
},
|
|
257
|
+
tabIndex: sortable ? 0 : null
|
|
258
|
+
})) : null);
|
|
259
|
+
}; // ### Display Name
|
|
260
|
+
// Always use the canonical component name as the React display name.
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
DataTableHeaderCell.displayName = DATA_TABLE_HEADER_CELL;
|
|
264
|
+
DataTableHeaderCell.propTypes = propTypes;
|
|
306
265
|
export default DataTableHeaderCell;
|
|
307
266
|
//# sourceMappingURL=header-cell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../.tmp-es/components/data-table/private/header-cell.jsx"],"names":["React","PropTypes","classNames","isFunction","CellFixed","Icon","checkProps","Link","InteractiveLink","CellContext","TableContext","contextHelper","DATA_TABLE_HEADER_CELL","DATA_TABLE_COLUMN","DataTableHeaderCell","sortDirection","e","preventDefault","oldSortDirection","props","state","sortDirectionFunction","direction","isDefaultSortDescending","data","property","setState","onSort","prevProps","isSorted","fixedHeader","label","sortable","width","labelType","expandedSortDirection","ariaSort","getFixedLayoutSubRenders","isHidden","SortLink","handleSort","assistiveTextForColumnSort","assistiveText","columnSort","undefined","assistiveTextForColumnSortedAscending","columnSortedAscending","assistiveTextForColumnSortedDescending","columnSortedDescending","display","getHeaderCellContent","fixedLayout","tableContext","cellContext","tabIndex","hasFocus","handleFocus","handleKeyDown","id","ref","cellRef","focus","height","lineHeight","cloneElement","style","overflow","paddingBottom","paddingTop","visibility","alignItems","flex","Component","shape","actionsHeader","string","selectAllRows","selectRow","func","bool","isRequired","oneOfType","node","oneOf"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;AAEA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,OAAOC,SAAP,MAAsB,YAAtB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB,C,CAEA;;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,IAAP,MAAiB,YAAjB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;AACA,OAAOC,aAAP,MAA0B,kBA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AE,EAAEzD,SAAS,CAAC0E,MAAV,CAAiBK,UAXH;;AAYlB;AACF;AACA;AACEzD,EAAAA,uBAAuB,EAAEtB,SAAS,CAAC8E,IAfjB;;AAgBlB;AACF;AACA;AACElD,EAAAA,QAAQ,EAAE5B,SAAS,CAAC8E,IAnBF;;AAoBlB;AACF;AACA;AACEhD,EAAAA,KAAK,EAAE9B,SAAS,CAACgF,SAAV,CAAoB,CAAChF,SAAS,CAAC0E,MAAX,EAAmB1E,SAAS,CAACiF,IAA7B,CAApB,CAvBW;;AAwBlB;AACF;AACA;AACEvD,EAAAA,MAAM,EAAE1B,SAAS,CAAC6E,IA3BA;;AA4BlB;AACF;AACA;AACErD,EAAAA,QAAQ,EAAExB,SAAS,CAAC0E,MA/BF;;AAgClB;AACF;AACA;AACE3C,EAAAA,QAAQ,EAAE/B,SAAS,CAAC8E,IAnCF;;AAoClB;AACF;AACA;AACEhE,EAAAA,aAAa,EAAEd,SAAS,CAACkF,KAAV,CAAgB,CAAC,MAAD,EAAS,KAAT,CAAhB,CAvCG;;AAwClB;AACF;AACA;AACElD,EAAAA,KAAK,EAAEhC,SAAS,CAAC0E;AA3CC,C;;AA2QpB,eAAe7D,mBAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// ## Children\nimport CellFixed from './cell-fixed';\nimport Icon from '../../icon';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from '../column-check-props';\n\nimport Link from './link';\nimport InteractiveLink from '../interactive-link';\nimport CellContext from '../private/cell-context';\nimport TableContext from '../private/table-context';\nimport contextHelper from './context-helper';\n\n// ## Constants\nimport {\n\tDATA_TABLE_HEADER_CELL,\n\tDATA_TABLE_COLUMN,\n} from '../../../utilities/constants';\n\n/**\n * Used internally, renders each individual column heading.\n */\nclass DataTableHeaderCell extends React.Component {\n\t// ### Display Name\n\t// Always use the canonical component name as the React display name.\n\tstatic displayName = DATA_TABLE_HEADER_CELL;\n\n\t// ### Prop Types\n\tstatic propTypes = {\n\t\tassistiveText: PropTypes.shape({\n\t\t\tactionsHeader: PropTypes.string,\n\t\t\tcolumnSort: PropTypes.string,\n\t\t\tcolumnSortedAscending: PropTypes.string,\n\t\t\tcolumnSortedDescending: PropTypes.string,\n\t\t\tselectAllRows: PropTypes.string,\n\t\t\tselectRow: PropTypes.string,\n\t\t}),\n\t\tcellRef: PropTypes.func,\n\t\tfixedHeader: PropTypes.bool,\n\t\tid: PropTypes.string.isRequired,\n\t\t/**\n\t\t * Some columns, such as \"date last viewed\" or \"date recently updated,\" should sort descending first, since that is what the user probably wants. How often does one want to see their oldest files first in a table? If sortable and the `DataTable`'s parent has not defined the sort order, then ascending (A at the top to Z at the bottom) is the default sort order on first click.\n\t\t */\n\t\tisDefaultSortDescending: PropTypes.bool,\n\t\t/**\n\t\t * Indicates if column is sorted.\n\t\t */\n\t\tisSorted: PropTypes.bool,\n\t\t/**\n\t\t * The column label.\n\t\t */\n\t\tlabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n\t\t/**\n\t\t * The function to execute on sort.\n\t\t */\n\t\tonSort: PropTypes.func,\n\t\t/**\n\t\t * The property which corresponds to this column.\n\t\t */\n\t\tproperty: PropTypes.string,\n\t\t/**\n\t\t * Whether or not the column is sortable.\n\t\t */\n\t\tsortable: PropTypes.bool,\n\t\t/**\n\t\t * The current sort direction.\n\t\t */\n\t\tsortDirection: PropTypes.oneOf(['desc', 'asc']),\n\t\t/**\n\t\t * Width of column. This is required for advanced/fixed layout tables. Please provide units. (`rems` are recommended)\n\t\t */\n\t\twidth: PropTypes.string,\n\t};\n\n\tstate = {\n\t\tsortDirection: null,\n\t};\n\n\tcomponentDidMount() {\n\t\tcheckProps(DATA_TABLE_COLUMN, this.props);\n\t}\n\n\tcomponentDidUpdate(prevProps) {\n\t\t// reset sort state when another column is sorted\n\t\tif (prevProps.isSorted === true && this.props.isSorted === false) {\n\t\t\tthis.setState({ sortDirection: null }); // eslint-disable-line react/no-did-update-set-state\n\t\t}\n\t}\n\n\thandleSort = (e) => {\n\t\te.preventDefault();\n\n\t\tconst oldSortDirection =\n\t\t\tthis.props.sortDirection || this.state.sortDirection;\n\t\t// UX pattern: If sortable, and the DataTable's parent has not defined the sort order, then ascending (that is A->Z) is the default sort order on first click. Some columns, such as \"last viewed\" or \"recently updated,\" should sort descending first, since that is what the user probably wants. Who wants to see the oldest files first?\n\t\tconst sortDirection = (function sortDirectionFunction(\n\t\t\tdirection,\n\t\t\tisDefaultSortDescending\n\t\t) {\n\t\t\tswitch (direction) {\n\t\t\t\tcase 'asc':\n\t\t\t\t\treturn 'desc';\n\t\t\t\tcase 'desc':\n\t\t\t\t\treturn 'asc';\n\t\t\t\tcase null:\n\t\t\t\t\treturn isDefaultSortDescending ? 'desc' : 'asc';\n\t\t\t\tdefault:\n\t\t\t\t\treturn 'asc';\n\t\t\t}\n\t\t})(oldSortDirection, this.props.isDefaultSortDescending);\n\t\tconst data = {\n\t\t\tproperty: this.props.property,\n\t\t\tsortDirection,\n\t\t};\n\n\t\tthis.setState({\n\t\t\tsortDirection,\n\t\t});\n\n\t\tif (isFunction(this.props.onSort)) {\n\t\t\tthis.props.onSort(data, e);\n\t\t}\n\t};\n\n\t// ### Render\n\trender() {\n\t\tconst {\n\t\t\tfixedHeader,\n\t\t\tisSorted,\n\t\t\tlabel,\n\t\t\tsortable,\n\t\t\twidth,\n\t\t\tproperty,\n\t\t} = this.props;\n\n\t\tconst labelType = typeof label;\n\t\t// This decides which arrow to render--which is current sort order if the column is sorted OR the future sort order if the arrow is clicked in the future.\n\t\tconst sortDirection =\n\t\t\tthis.props.sortDirection ||\n\t\t\tthis.state.sortDirection ||\n\t\t\t(this.props.isDefaultSortDescending && 'desc');\n\t\tconst expandedSortDirection =\n\t\t\tsortDirection === 'desc' ? 'descending' : 'ascending';\n\t\tconst ariaSort = isSorted ? expandedSortDirection : 'none';\n\n\t\tconst getFixedLayoutSubRenders = (isHidden) => {\n\t\t\tif (sortable) {\n\t\t\t\t// Don't make the anchor interactable when it's hidden\n\t\t\t\tconst SortLink = isHidden ? Link : InteractiveLink;\n\t\t\t\treturn (\n\t\t\t\t\t<SortLink\n\t\t\t\t\t\thref=\"#\"\n\t\t\t\t\t\tclassName=\"slds-th__action slds-text-link_reset\"\n\t\t\t\t\t\tonClick={this.handleSort}\n\t\t\t\t\t\trole=\"button\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t{this.props.assistiveTextForColumnSort ||\n\t\t\t\t\t\t\t\tthis.props.assistiveText.columnSort}{' '}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{label}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\tclassName=\"slds-is-sortable__icon\"\n\t\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\t\tname={sortDirection === 'desc' ? 'arrowdown' : 'arrowup'}\n\t\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{sortDirection ? (\n\t\t\t\t\t\t\t<span className=\"slds-assistive-text\" aria-atomic=\"true\">\n\t\t\t\t\t\t\t\t{sortDirection === 'asc'\n\t\t\t\t\t\t\t\t\t? this.props.assistiveTextForColumnSortedAscending ||\n\t\t\t\t\t\t\t\t\t this.props.assistiveText.columnSortedAscending\n\t\t\t\t\t\t\t\t\t: this.props.assistiveTextForColumnSortedDescending ||\n\t\t\t\t\t\t\t\t\t this.props.assistiveText.columnSortedDescending}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</SortLink>\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<span\n\t\t\t\t\tclassName=\"slds-p-horizontal_x-small slds-th__action\"\n\t\t\t\t\tstyle={{ display: 'flex' }}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t\t\t>\n\t\t\t\t\t\t{label}\n\t\t\t\t\t</span>\n\t\t\t\t</span>\n\t\t\t);\n\t\t};\n\n\t\tconst getHeaderCellContent = (isHidden) =>\n\t\t\tthis.props.fixedLayout ? (\n\t\t\t\tgetFixedLayoutSubRenders(isHidden)\n\t\t\t) : (\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</div>\n\t\t\t);\n\n\t\treturn (\n\t\t\t<TableContext.Consumer>\n\t\t\t\t{(tableContext) => (\n\t\t\t\t\t<CellContext.Consumer>\n\t\t\t\t\t\t{(cellContext) => {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\thasFocus,\n\t\t\t\t\t\t\t\thandleFocus,\n\t\t\t\t\t\t\t\thandleKeyDown,\n\t\t\t\t\t\t\t} = contextHelper(\n\t\t\t\t\t\t\t\ttableContext,\n\t\t\t\t\t\t\t\tcellContext,\n\t\t\t\t\t\t\t\tthis.props.fixedLayout\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<th\n\t\t\t\t\t\t\t\t\tid={`${this.props.id}-${property}-th`}\n\t\t\t\t\t\t\t\t\taria-label={labelType === 'string' ? label : undefined}\n\t\t\t\t\t\t\t\t\taria-sort={ariaSort}\n\t\t\t\t\t\t\t\t\tclassName={classNames({\n\t\t\t\t\t\t\t\t\t\t'slds-is-sortable': sortable,\n\t\t\t\t\t\t\t\t\t\t'slds-is-sorted': isSorted,\n\t\t\t\t\t\t\t\t\t\t[`slds-is-sorted_${sortDirection}`]: sortDirection,\n\t\t\t\t\t\t\t\t\t\t'slds-is-sorted_asc': isSorted && !sortDirection, // default for hover, up arrow is ascending which means A is at the top of the table, and Z is at the bottom. You have to think about row numbers abstracting, and not the visual order on the table.\n\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\tonFocus={handleFocus}\n\t\t\t\t\t\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\t\t\t\t\t\tref={(ref) => {\n\t\t\t\t\t\t\t\t\t\tif (this.props.cellRef) {\n\t\t\t\t\t\t\t\t\t\t\tthis.props.cellRef(ref);\n\t\t\t\t\t\t\t\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\t\t\t\t\t\t\t\tref.focus();\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\tscope=\"col\"\n\t\t\t\t\t\t\t\t\tstyle={\n\t\t\t\t\t\t\t\t\t\tfixedHeader || width\n\t\t\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: fixedHeader ? 0 : null,\n\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight: fixedHeader ? 0 : null,\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: width || null,\n\t\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t\t: null\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\ttabIndex={tabIndex}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{fixedHeader\n\t\t\t\t\t\t\t\t\t\t? React.cloneElement(getHeaderCellContent(true), {\n\t\t\t\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\t\t\theight: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\t\t\t\t\t\t\tpaddingBottom: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tpaddingTop: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t })\n\t\t\t\t\t\t\t\t\t\t: getHeaderCellContent()}\n\t\t\t\t\t\t\t\t\t{fixedHeader ? (\n\t\t\t\t\t\t\t\t\t\t<CellFixed>\n\t\t\t\t\t\t\t\t\t\t\t{React.cloneElement(getHeaderCellContent(), {\n\t\t\t\t\t\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\t\t\t\t\t\t\tflex: '1 1 auto',\n\t\t\t\t\t\t\t\t\t\t\t\t\tlineHeight: 1.25,\n\t\t\t\t\t\t\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\t\ttabIndex: sortable ? 0 : null,\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t</CellFixed>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</th>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}}\n\t\t\t\t\t</CellContext.Consumer>\n\t\t\t\t)}\n\t\t\t</TableContext.Consumer>\n\t\t);\n\t}\n}\n\nexport default DataTableHeaderCell;\n"],"file":"header-cell.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../.tmp-es/components/data-table/private/header-cell.jsx"],"names":["React","useContext","useEffect","useRef","useState","PropTypes","classNames","isFunction","CellFixed","Icon","checkProps","Link","InteractiveLink","CellContext","TableContext","useContextHelper","DATA_TABLE_HEADER_CELL","DATA_TABLE_COLUMN","propTypes","assistiveText","shape","actionsHeader","string","columnSort","columnSortedAscending","columnSortedDescending","selectAllRows","selectRow","cellRef","func","fixedHeader","bool","id","isRequired","isDefaultSortDescending","isSorted","label","oneOfType","node","onSort","property","sortable","sortDirection","oneOf","width","DataTableHeaderCell","props","setSortDirection","prevIsSorted","tableContext","cellContext","fixedLayout","tabIndex","hasFocus","handleFocus","handleKeyDown","current","handleSort","e","preventDefault","oldSortDirection","newSortDirection","sortDirectionFunction","direction","data","labelType","effectiveSortDirection","expandedSortDirection","ariaSort","getFixedLayoutSubRenders","isHidden","SortLink","assistiveTextForColumnSort","undefined","assistiveTextForColumnSortedAscending","assistiveTextForColumnSortedDescending","display","getHeaderCellContent","ref","focus","height","lineHeight","cloneElement","style","overflow","paddingBottom","paddingTop","visibility","alignItems","flex","displayName"],"mappings":";;;;;;;;;;;;;;;;AAAA;;AACA;AAEA;AACA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,SAA5B,EAAuCC,MAAvC,EAA+CC,QAA/C,QAA+D,OAA/D;AAEA,OAAOC,SAAP,MAAsB,YAAtB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,YAAvB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,mBAAvB,C,CAEA;;AACA,OAAOC,SAAP,MAAsB,cAAtB;AACA,OAAOC,IAAP,MAAiB,YAAjB,C,CAEA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,WAAP,MAAwB,yBAAxB;AACA,OAAOC,YAAP,MAAyB,0BAAzB;AACA,OAAOC,gBAAP,MAA6B,kBAA7B,C,CAEA;;AACA,SACCC,sBADD,EAECC,iBAFD,QAGO,8BAHP,C,CAKA;;AACA,IAAMC,SAAS,GA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AN,CAAmBL,oBAAoB,CAAC,IAAD,CAAvC,EAA+C;AAC/CM,IAAAA,KAAK,EAAE;AACNP,MAAAA,OAAO,EAAE,MADH;AAENI,MAAAA,MAAM,EAAE,CAFF;AAGNI,MAAAA,QAAQ,EAAE,QAHJ;AAINC,MAAAA,aAAa,EAAE,CAJT;AAKNC,MAAAA,UAAU,EAAE,CALN;AAMNC,MAAAA,UAAU,EAAE;AANN;AADwC,GAA/C,CADS,GAWTV,oBAAoB,EA3CxB,EA4CE/C,WAAW,gBACX,oBAAC,SAAD,qBACE9B,KAAK,CAACkF,YAAN,CAAmBL,oBAAoB,EAAvC,EAA2C;AAC3CM,IAAAA,KAAK,EAAE;AACNK,MAAAA,UAAU,EAAE,QADN;AAENZ,MAAAA,OAAO,EAAE,MAFH;AAGNa,MAAAA,IAAI,EAAE,UAHA;AAINR,MAAAA,UAAU,EAAE,IAJN;AAKNrC,MAAAA,KAAK,EAAE;AALD,KADoC;AAQ3CQ,IAAAA,QAAQ,EAAEX,QAAQ,GAAG,CAAH,GAAO;AARkB,GAA3C,CADF,CADW,GAaR,IAzDL,CADD;AA6DA,CAjMD,C,CAmMA;AACA;;;AACAI,mBAAmB,CAAC6C,WAApB,GAAkC1E,sBAAlC;AACA6B,mBAAmB,CAAC3B,SAApB,GAAgCA,SAAhC;AAEA,eAAe2B,mBAAf","sourcesContent":["/* Copyright (c) 2015-present, salesforce.com, inc. All rights reserved */\n/* Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license */\n\n// ### React\nimport React, { useContext, useEffect, useRef, useState } from 'react';\n\nimport PropTypes from 'prop-types';\n\n// ### classNames\nimport classNames from 'classnames';\n\n// ### isFunction\nimport isFunction from 'lodash.isfunction';\n\n// ## Children\nimport CellFixed from './cell-fixed';\nimport Icon from '../../icon';\n\n// This component's `checkProps` which issues warnings to developers about properties when in development mode (similar to React's built in development tools)\nimport checkProps from '../column-check-props';\n\nimport Link from './link';\nimport InteractiveLink from '../interactive-link';\nimport CellContext from '../private/cell-context';\nimport TableContext from '../private/table-context';\nimport useContextHelper from './context-helper';\n\n// ## Constants\nimport {\n\tDATA_TABLE_HEADER_CELL,\n\tDATA_TABLE_COLUMN,\n} from '../../../utilities/constants';\n\n// ### Prop Types\nconst propTypes = {\n\tassistiveText: PropTypes.shape({\n\t\tactionsHeader: PropTypes.string,\n\t\tcolumnSort: PropTypes.string,\n\t\tcolumnSortedAscending: PropTypes.string,\n\t\tcolumnSortedDescending: PropTypes.string,\n\t\tselectAllRows: PropTypes.string,\n\t\tselectRow: PropTypes.string,\n\t}),\n\tcellRef: PropTypes.func,\n\tfixedHeader: PropTypes.bool,\n\tid: PropTypes.string.isRequired,\n\t/**\n\t * Some columns, such as \"date last viewed\" or \"date recently updated,\" should sort descending first, since that is what the user probably wants. How often does one want to see their oldest files first in a table? If sortable and the `DataTable`'s parent has not defined the sort order, then ascending (A at the top to Z at the bottom) is the default sort order on first click.\n\t */\n\tisDefaultSortDescending: PropTypes.bool,\n\t/**\n\t * Indicates if column is sorted.\n\t */\n\tisSorted: PropTypes.bool,\n\t/**\n\t * The column label.\n\t */\n\tlabel: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),\n\t/**\n\t * The function to execute on sort.\n\t */\n\tonSort: PropTypes.func,\n\t/**\n\t * The property which corresponds to this column.\n\t */\n\tproperty: PropTypes.string,\n\t/**\n\t * Whether or not the column is sortable.\n\t */\n\tsortable: PropTypes.bool,\n\t/**\n\t * The current sort direction.\n\t */\n\tsortDirection: PropTypes.oneOf(['desc', 'asc']),\n\t/**\n\t * Width of column. This is required for advanced/fixed layout tables. Please provide units. (`rems` are recommended)\n\t */\n\twidth: PropTypes.string,\n};\n\n/**\n * Used internally, renders each individual column heading.\n */\nconst DataTableHeaderCell = (props) => {\n\tconst [sortDirection, setSortDirection] = useState(null);\n\tconst prevIsSorted = useRef(null);\n\tconst tableContext = useContext(TableContext);\n\tconst cellContext = useContext(CellContext);\n\tconst { tabIndex, hasFocus, handleFocus, handleKeyDown } = useContextHelper(\n\t\ttableContext,\n\t\tcellContext,\n\t\tprops.fixedLayout\n\t);\n\n\tuseEffect(() => {\n\t\tcheckProps(DATA_TABLE_COLUMN, props);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (prevIsSorted.current === true && props.isSorted === false) {\n\t\t\tsetSortDirection(null);\n\t\t}\n\t\tprevIsSorted.current = props.isSorted;\n\t}, [props.isSorted]);\n\n\tconst handleSort = (e) => {\n\t\te.preventDefault();\n\n\t\tconst oldSortDirection = props.sortDirection || sortDirection;\n\t\t// UX pattern: If sortable, and the DataTable's parent has not defined the sort order, then ascending (that is A->Z) is the default sort order on first click. Some columns, such as \"last viewed\" or \"recently updated,\" should sort descending first, since that is what the user probably wants. Who wants to see the oldest files first?\n\t\tconst newSortDirection = (function sortDirectionFunction(\n\t\t\tdirection,\n\t\t\tisDefaultSortDescending\n\t\t) {\n\t\t\tswitch (direction) {\n\t\t\t\tcase 'asc':\n\t\t\t\t\treturn 'desc';\n\t\t\t\tcase 'desc':\n\t\t\t\t\treturn 'asc';\n\t\t\t\tcase null:\n\t\t\t\t\treturn isDefaultSortDescending ? 'desc' : 'asc';\n\t\t\t\tdefault:\n\t\t\t\t\treturn 'asc';\n\t\t\t}\n\t\t})(oldSortDirection, props.isDefaultSortDescending);\n\t\tconst data = {\n\t\t\tproperty: props.property,\n\t\t\tsortDirection: newSortDirection,\n\t\t};\n\n\t\tsetSortDirection(newSortDirection);\n\n\t\tif (isFunction(props.onSort)) {\n\t\t\tprops.onSort(data, e);\n\t\t}\n\t};\n\n\tconst { fixedHeader, isSorted, label, sortable, width, property } = props;\n\n\tconst labelType = typeof label;\n\t// This decides which arrow to render--which is current sort order if the column is sorted OR the future sort order if the arrow is clicked in the future.\n\tconst effectiveSortDirection =\n\t\tprops.sortDirection ||\n\t\tsortDirection ||\n\t\t(props.isDefaultSortDescending && 'desc');\n\tconst expandedSortDirection =\n\t\teffectiveSortDirection === 'desc' ? 'descending' : 'ascending';\n\tconst ariaSort = isSorted ? expandedSortDirection : 'none';\n\n\tconst getFixedLayoutSubRenders = (isHidden) => {\n\t\tif (sortable) {\n\t\t\t// Don't make the anchor interactable when it's hidden\n\t\t\tconst SortLink = isHidden ? Link : InteractiveLink;\n\t\t\treturn (\n\t\t\t\t<SortLink\n\t\t\t\t\thref=\"#\"\n\t\t\t\t\tclassName=\"slds-th__action slds-text-link_reset\"\n\t\t\t\t\tonClick={handleSort}\n\t\t\t\t\trole=\"button\"\n\t\t\t\t>\n\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t{props.assistiveTextForColumnSort || props.assistiveText.columnSort}{' '}\n\t\t\t\t\t</span>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t\t\t>\n\t\t\t\t\t\t{label}\n\t\t\t\t\t</span>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\tclassName=\"slds-is-sortable__icon\"\n\t\t\t\t\t\tcategory=\"utility\"\n\t\t\t\t\t\tname={effectiveSortDirection === 'desc' ? 'arrowdown' : 'arrowup'}\n\t\t\t\t\t\tsize=\"x-small\"\n\t\t\t\t\t/>\n\t\t\t\t\t{effectiveSortDirection ? (\n\t\t\t\t\t\t<span className=\"slds-assistive-text\" aria-atomic=\"true\">\n\t\t\t\t\t\t\t{effectiveSortDirection === 'asc'\n\t\t\t\t\t\t\t\t? props.assistiveTextForColumnSortedAscending ||\n\t\t\t\t\t\t\t\t props.assistiveText.columnSortedAscending\n\t\t\t\t\t\t\t\t: props.assistiveTextForColumnSortedDescending ||\n\t\t\t\t\t\t\t\t props.assistiveText.columnSortedDescending}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\t\t\t\t</SortLink>\n\t\t\t);\n\t\t}\n\t\treturn (\n\t\t\t<span\n\t\t\t\tclassName=\"slds-p-horizontal_x-small slds-th__action\"\n\t\t\t\tstyle={{ display: 'flex' }}\n\t\t\t>\n\t\t\t\t<span\n\t\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t\t>\n\t\t\t\t\t{label}\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t);\n\t};\n\n\tconst getHeaderCellContent = (isHidden) =>\n\t\tprops.fixedLayout ? (\n\t\t\tgetFixedLayoutSubRenders(isHidden)\n\t\t) : (\n\t\t\t<div\n\t\t\t\tclassName=\"slds-truncate\"\n\t\t\t\ttitle={labelType === 'string' ? label : undefined}\n\t\t\t>\n\t\t\t\t{label}\n\t\t\t</div>\n\t\t);\n\n\treturn (\n\t\t<th\n\t\t\tid={`${props.id}-${property}-th`}\n\t\t\taria-label={labelType === 'string' ? label : undefined}\n\t\t\taria-sort={ariaSort}\n\t\t\tclassName={classNames({\n\t\t\t\t'slds-is-sortable': sortable,\n\t\t\t\t'slds-is-sorted': isSorted,\n\t\t\t\t[`slds-is-sorted_${effectiveSortDirection}`]: effectiveSortDirection,\n\t\t\t\t'slds-is-sorted_asc': isSorted && !effectiveSortDirection, // default for hover, up arrow is ascending which means A is at the top of the table, and Z is at the bottom. You have to think about row numbers abstracting, and not the visual order on the table.\n\t\t\t})}\n\t\t\tonFocus={handleFocus}\n\t\t\tonKeyDown={handleKeyDown}\n\t\t\tref={(ref) => {\n\t\t\t\tif (props.cellRef) {\n\t\t\t\t\tprops.cellRef(ref);\n\t\t\t\t\tif (ref && hasFocus) {\n\t\t\t\t\t\tref.focus();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}}\n\t\t\tscope=\"col\"\n\t\t\tstyle={\n\t\t\t\tfixedHeader || width\n\t\t\t\t\t? {\n\t\t\t\t\t\t\theight: fixedHeader ? 0 : null,\n\t\t\t\t\t\t\tlineHeight: fixedHeader ? 0 : null,\n\t\t\t\t\t\t\twidth: width || null,\n\t\t\t\t\t }\n\t\t\t\t\t: null\n\t\t\t}\n\t\t\ttabIndex={tabIndex}\n\t\t>\n\t\t\t{fixedHeader\n\t\t\t\t? React.cloneElement(getHeaderCellContent(true), {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\theight: 0,\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\tpaddingBottom: 0,\n\t\t\t\t\t\t\tpaddingTop: 0,\n\t\t\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\t\t},\n\t\t\t\t })\n\t\t\t\t: getHeaderCellContent()}\n\t\t\t{fixedHeader ? (\n\t\t\t\t<CellFixed>\n\t\t\t\t\t{React.cloneElement(getHeaderCellContent(), {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\t\tflex: '1 1 auto',\n\t\t\t\t\t\t\tlineHeight: 1.25,\n\t\t\t\t\t\t\twidth: '100%',\n\t\t\t\t\t\t},\n\t\t\t\t\t\ttabIndex: sortable ? 0 : null,\n\t\t\t\t\t})}\n\t\t\t\t</CellFixed>\n\t\t\t) : null}\n\t\t</th>\n\t);\n};\n\n// ### Display Name\n// Always use the canonical component name as the React display name.\nDataTableHeaderCell.displayName = DATA_TABLE_HEADER_CELL;\nDataTableHeaderCell.propTypes = propTypes;\n\nexport default DataTableHeaderCell;\n"],"file":"header-cell.js"}
|