carbon-react 93.0.4 → 94.0.3
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/lib/__internal__/checkable-input/checkable-input.component.js +7 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.component.js +11 -1
- package/lib/__internal__/checkable-input/hidden-checkable-input.d.ts +5 -1
- package/lib/__internal__/form-field/form-field.component.js +9 -8
- package/lib/__internal__/form-field/form-field.d.ts +2 -0
- package/lib/components/action-popover/action-popover.component.js +28 -20
- package/lib/components/action-popover/action-popover.style.js +22 -12
- package/lib/components/i18n-provider/i18n-provider.component.js +0 -3
- package/lib/locales/en-gb.js +1 -8
- package/lib/locales/locale.d.ts +0 -7
- package/lib/locales/pl-pl.js +1 -8
- package/package.json +1 -6
- package/lib/components/action-toolbar/action-toolbar.component.js +0 -213
- package/lib/components/action-toolbar/action-toolbar.d.ts +0 -20
- package/lib/components/action-toolbar/action-toolbar.style.js +0 -40
- package/lib/components/action-toolbar/index.d.ts +0 -1
- package/lib/components/action-toolbar/index.js +0 -15
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.component.js +0 -174
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.d.ts +0 -25
- package/lib/components/configurable-items/configurable-item-row/configurable-item-row.style.js +0 -73
- package/lib/components/configurable-items/configurable-item-row/index.d.ts +0 -1
- package/lib/components/configurable-items/configurable-item-row/index.js +0 -15
- package/lib/components/configurable-items/configurable-items.component.js +0 -155
- package/lib/components/configurable-items/configurable-items.d.ts +0 -20
- package/lib/components/configurable-items/configurable-items.style.js +0 -70
- package/lib/components/configurable-items/index.d.ts +0 -2
- package/lib/components/configurable-items/index.js +0 -23
- package/lib/components/drag-and-drop/__internal__/item-target/index.js +0 -15
- package/lib/components/drag-and-drop/__internal__/item-target/item-target.js +0 -44
- package/lib/components/drag-and-drop/__internal__/item-types/index.js +0 -15
- package/lib/components/drag-and-drop/__internal__/item-types/item-types.js +0 -20
- package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.js +0 -171
- package/lib/components/drag-and-drop/custom-drag-layer/custom-drag-layer.style.js +0 -28
- package/lib/components/drag-and-drop/custom-drag-layer/index.js +0 -15
- package/lib/components/drag-and-drop/drag-and-drop-test.stories.js +0 -95
- package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/index.js +0 -15
- package/lib/components/drag-and-drop/draggable-context/__internal__/scrollable-parent/scrollable-parent.js +0 -36
- package/lib/components/drag-and-drop/draggable-context/draggable-context.js +0 -264
- package/lib/components/drag-and-drop/draggable-context/index.js +0 -15
- package/lib/components/drag-and-drop/index.js +0 -39
- package/lib/components/drag-and-drop/with-drag/index.js +0 -15
- package/lib/components/drag-and-drop/with-drag/with-drag.js +0 -176
- package/lib/components/drag-and-drop/with-drop/index.js +0 -15
- package/lib/components/drag-and-drop/with-drop/with-drop.js +0 -201
- package/lib/components/table/draggable-table-cell/draggable-table-cell.component.js +0 -59
- package/lib/components/table/draggable-table-cell/draggable-table-cell.style.js +0 -36
- package/lib/components/table/draggable-table-cell/index.js +0 -15
- package/lib/components/table/index.js +0 -43
- package/lib/components/table/table-cell/index.js +0 -15
- package/lib/components/table/table-cell/table-cell.component.js +0 -164
- package/lib/components/table/table-cell/table-cell.style.js +0 -164
- package/lib/components/table/table-header/index.js +0 -15
- package/lib/components/table/table-header/table-header.component.js +0 -282
- package/lib/components/table/table-header/table-header.style.js +0 -116
- package/lib/components/table/table-modern.style.js +0 -110
- package/lib/components/table/table-row/index.js +0 -15
- package/lib/components/table/table-row/table-row-modern.style.js +0 -70
- package/lib/components/table/table-row/table-row.component.js +0 -486
- package/lib/components/table/table-row/table-row.style.js +0 -165
- package/lib/components/table/table-sizes.style.js +0 -33
- package/lib/components/table/table-story-helpers/table-story-wrapper.component.js +0 -189
- package/lib/components/table/table-subheader/index.js +0 -15
- package/lib/components/table/table-subheader/table-subheader.component.js +0 -35
- package/lib/components/table/table-subheader/table-subheader.style.js +0 -33
- package/lib/components/table/table.component.js +0 -792
- package/lib/components/table/table.config.js +0 -14
- package/lib/components/table/table.style.js +0 -139
- package/lib/components/table-ajax/__internal__/serialize/package.json +0 -3
- package/lib/components/table-ajax/__internal__/serialize/serialize.js +0 -26
- package/lib/components/table-ajax/index.js +0 -37
- package/lib/components/table-ajax/table-ajax.component.js +0 -602
- package/lib/patterns/configurable-items/actions/actions.js +0 -41
- package/lib/patterns/configurable-items/actions/package.json +0 -3
- package/lib/patterns/configurable-items/configurable-items-content/configurable-items-content.js +0 -140
- package/lib/patterns/configurable-items/configurable-items-content/package.json +0 -3
- package/lib/patterns/configurable-items/configurable-items.js +0 -216
- package/lib/patterns/configurable-items/constants/constants.js +0 -13
- package/lib/patterns/configurable-items/constants/package.json +0 -3
- package/lib/patterns/configurable-items/package.json +0 -3
- package/lib/patterns/configurable-items/store/package.json +0 -3
- package/lib/patterns/configurable-items/store/store.js +0 -92
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _base = _interopRequireDefault(require("../../../style/themes/base"));
|
|
13
|
-
|
|
14
|
-
var _inputPresentation = _interopRequireDefault(require("../../../__internal__/input/input-presentation.style"));
|
|
15
|
-
|
|
16
|
-
var _input = _interopRequireDefault(require("../../../__internal__/input/input.style"));
|
|
17
|
-
|
|
18
|
-
var _tableSizesStyle = _interopRequireDefault(require("../table-sizes.style.js"));
|
|
19
|
-
|
|
20
|
-
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
25
|
-
|
|
26
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
27
|
-
|
|
28
|
-
const StyledTableCell = _styledComponents.default.td`
|
|
29
|
-
${({
|
|
30
|
-
action,
|
|
31
|
-
align,
|
|
32
|
-
theme,
|
|
33
|
-
size,
|
|
34
|
-
isTextArea,
|
|
35
|
-
isDate
|
|
36
|
-
}) => {
|
|
37
|
-
const {
|
|
38
|
-
colors,
|
|
39
|
-
table
|
|
40
|
-
} = theme;
|
|
41
|
-
return (0, _styledComponents.css)`
|
|
42
|
-
background-color: ${table.primary};
|
|
43
|
-
border-width: 0;
|
|
44
|
-
border-bottom: 1px solid ${table.secondary};
|
|
45
|
-
font-size: 13px;
|
|
46
|
-
overflow: visible;
|
|
47
|
-
padding: 8px;
|
|
48
|
-
text-align: ${align};
|
|
49
|
-
vertical-align: middle;
|
|
50
|
-
white-space: nowrap;
|
|
51
|
-
|
|
52
|
-
> .common-input {
|
|
53
|
-
margin-bottom: -4px;
|
|
54
|
-
margin-left: -6px;
|
|
55
|
-
margin-right: -6px;
|
|
56
|
-
margin-top: -4px;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
${action && applyActionStyling(colors)}
|
|
60
|
-
|
|
61
|
-
${size ? applyModernPresentationStyling(size, isTextArea, isDate) : ""}
|
|
62
|
-
`;
|
|
63
|
-
}}
|
|
64
|
-
`;
|
|
65
|
-
|
|
66
|
-
function applyActionStyling(colors) {
|
|
67
|
-
return (0, _styledComponents.css)`
|
|
68
|
-
width: 18px;
|
|
69
|
-
|
|
70
|
-
.icon-delete:before {
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
color: ${colors.border};
|
|
73
|
-
font-size: 16px;
|
|
74
|
-
line-height: 15px;
|
|
75
|
-
margin-left: 1px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.icon-delete:hover:before {
|
|
79
|
-
color: #c7384f;
|
|
80
|
-
}
|
|
81
|
-
`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function applyModernPresentationStyling(size, isTextArea, isDate) {
|
|
85
|
-
const {
|
|
86
|
-
inputHeight,
|
|
87
|
-
fontSize,
|
|
88
|
-
paddingSize
|
|
89
|
-
} = _tableSizesStyle.default[size];
|
|
90
|
-
return `
|
|
91
|
-
&& ${_inputPresentation.default} {
|
|
92
|
-
min-height: ${inputHeight}px;
|
|
93
|
-
padding-left: ${paddingSize};
|
|
94
|
-
padding-right: ${paddingSize};
|
|
95
|
-
position: relative;
|
|
96
|
-
${size === "large" && isDate ? "width: 150px;" : ""}
|
|
97
|
-
${additionalPresentationStyling(isTextArea, inputHeight)}
|
|
98
|
-
}
|
|
99
|
-
${applyModernInputStyling(isTextArea, inputHeight, fontSize)}
|
|
100
|
-
`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function additionalPresentationStyling(isTextArea, inputHeight) {
|
|
104
|
-
if (isTextArea) {
|
|
105
|
-
return `
|
|
106
|
-
height: ${inputHeight * 3}px;
|
|
107
|
-
margin-top: 4px;
|
|
108
|
-
margin-bottom: 4px;
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return `
|
|
113
|
-
height: ${inputHeight}px;
|
|
114
|
-
`;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function applyModernInputStyling(isTextArea, inputHeight, fontSize) {
|
|
118
|
-
if (isTextArea) {
|
|
119
|
-
return `
|
|
120
|
-
textarea {
|
|
121
|
-
font-size: ${fontSize};
|
|
122
|
-
overflow: auto;
|
|
123
|
-
resize: none;
|
|
124
|
-
flex-grow: 1;
|
|
125
|
-
height: auto !important;
|
|
126
|
-
padding-top: 5px;
|
|
127
|
-
padding-bottom: 5px;
|
|
128
|
-
}
|
|
129
|
-
`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return `
|
|
133
|
-
&& ${_input.default} {
|
|
134
|
-
font-size: ${fontSize};
|
|
135
|
-
height: ${inputHeight}px;
|
|
136
|
-
padding-top: 0px;
|
|
137
|
-
padding-bottom: 0px;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
&& ${_icon.default} {
|
|
141
|
-
font-size: 13px;
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
StyledTableCell.propTypes = {
|
|
147
|
-
/** Defines the cell type to be an action - used for the delete cell. */
|
|
148
|
-
action: _propTypes.default.bool,
|
|
149
|
-
|
|
150
|
-
/** Defines the alignment of the cell (eg "left", "center" or "right"). */
|
|
151
|
-
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
152
|
-
|
|
153
|
-
/** Defines the height of a cell used to size an input for example */
|
|
154
|
-
size: _propTypes.default.oneOf(["compact", "small", "medium", "large"]),
|
|
155
|
-
|
|
156
|
-
/** Used to toggle the input wrapper height. */
|
|
157
|
-
isTextArea: _propTypes.default.bool
|
|
158
|
-
};
|
|
159
|
-
StyledTableCell.defaultProps = {
|
|
160
|
-
theme: _base.default,
|
|
161
|
-
align: "left"
|
|
162
|
-
};
|
|
163
|
-
var _default = StyledTableCell;
|
|
164
|
-
exports.default = _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _tableHeader.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _tableHeader = _interopRequireDefault(require("./table-header.component"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _tableHeader = _interopRequireDefault(require("./table-header.style"));
|
|
13
|
-
|
|
14
|
-
var _icon = _interopRequireDefault(require("../../icon"));
|
|
15
|
-
|
|
16
|
-
var _ether = require("../../../__internal__/utils/ether");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
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); } }
|
|
23
|
-
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
25
|
-
|
|
26
|
-
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); }
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
40
|
-
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; }
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* A TableHeader widget.
|
|
44
|
-
*
|
|
45
|
-
* == How to use a TableHeader in a component:
|
|
46
|
-
*
|
|
47
|
-
* See documentation for Table component.
|
|
48
|
-
*
|
|
49
|
-
* You can set a property of 'align' which should be a string. This will
|
|
50
|
-
* align the content to either "left", "center" or "right".
|
|
51
|
-
*
|
|
52
|
-
* == Sortable Columns:
|
|
53
|
-
*
|
|
54
|
-
* To make a column sortable, pass a prop of 'sortable={ true }' to the corresponding
|
|
55
|
-
* TableHeader.
|
|
56
|
-
* Sortable columns also require a 'name' prop which must correspond to the database key.
|
|
57
|
-
*
|
|
58
|
-
* You can also provide a custom sortOrder - 'asc' (ascending) or 'desc' (descending).
|
|
59
|
-
* By Default columns are sorted in ascending order.
|
|
60
|
-
*
|
|
61
|
-
* See the Table documentation for more information on hooking up a change handler
|
|
62
|
-
* to setup sort functionality in your app.
|
|
63
|
-
*/
|
|
64
|
-
let TableHeader = /*#__PURE__*/function (_React$Component) {
|
|
65
|
-
_inherits(TableHeader, _React$Component);
|
|
66
|
-
|
|
67
|
-
var _super = _createSuper(TableHeader);
|
|
68
|
-
|
|
69
|
-
function TableHeader(...args) {
|
|
70
|
-
var _this;
|
|
71
|
-
|
|
72
|
-
_classCallCheck(this, TableHeader);
|
|
73
|
-
|
|
74
|
-
_this = _super.call(this, ...args);
|
|
75
|
-
|
|
76
|
-
_defineProperty(_assertThisInitialized(_this), "emitSortEvent", () => {
|
|
77
|
-
let sortOrder = _this.context.sortOrder || "desc"; // If this is the current sorted column. flip order
|
|
78
|
-
|
|
79
|
-
if (_this.sorted) {
|
|
80
|
-
sortOrder = _this.context.sortOrder === "asc" ? "desc" : "asc";
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
_this.context.onSort(_this.props.name, sortOrder);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return _this;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
_createClass(TableHeader, [{
|
|
90
|
-
key: "onSortableColumnClick",
|
|
91
|
-
value:
|
|
92
|
-
/**
|
|
93
|
-
* Event handler for clicks on the <a> tag used for activating
|
|
94
|
-
* column sorting.
|
|
95
|
-
*
|
|
96
|
-
* Used to prevent the default action of the <a> tag.
|
|
97
|
-
*/
|
|
98
|
-
function onSortableColumnClick(event) {
|
|
99
|
-
event.preventDefault();
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Returns props to be used on the TH element.
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
}, {
|
|
106
|
-
key: "tableHeaderProps",
|
|
107
|
-
get: function () {
|
|
108
|
-
const {
|
|
109
|
-
children,
|
|
110
|
-
...props
|
|
111
|
-
} = (0, _ether.validProps)(this);
|
|
112
|
-
if (this.props.sortable) props.onClick = this.emitSortEvent;
|
|
113
|
-
return props;
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "isCurrentSortedColumn",
|
|
117
|
-
get: function () {
|
|
118
|
-
return this.props.sortable && this.props.name === this.context.sortedColumn;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Returns sort icon HTML if column is sortable and has been sorted.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
|
-
}, {
|
|
125
|
-
key: "sortIconHTML",
|
|
126
|
-
get: function () {
|
|
127
|
-
if (this.sorted) {
|
|
128
|
-
const type = this.context.sortOrder === "desc" ? "sort_down" : "sort_up";
|
|
129
|
-
return /*#__PURE__*/_react.default.createElement(_icon.default, {
|
|
130
|
-
type: type
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return null;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Determines if this column is currently sorted.
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
}, {
|
|
141
|
-
key: "sorted",
|
|
142
|
-
get: function () {
|
|
143
|
-
return this.props.sortable && this.context.sortedColumn === this.props.name;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Returns descriptive text to describe the sortable column, and about
|
|
147
|
-
* what will happen when they next attempt to sort the column i.e. which
|
|
148
|
-
* direction it will sort in.
|
|
149
|
-
*
|
|
150
|
-
* NB If the current sortOrder is undefined, assume the next sort order
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
}, {
|
|
154
|
-
key: "sortDescription",
|
|
155
|
-
get: function () {
|
|
156
|
-
if (!this.props.sortable) {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
const currentSortOrder = this.context.sortOrder;
|
|
161
|
-
let nextSortOrder = null;
|
|
162
|
-
let currentSortDescription = null;
|
|
163
|
-
|
|
164
|
-
if (currentSortOrder) {
|
|
165
|
-
nextSortOrder = currentSortOrder === "asc" ? "descending" : "ascending";
|
|
166
|
-
currentSortDescription = `sorted ${currentSortOrder === "desc" ? "descending" : "ascending"}, `;
|
|
167
|
-
} else {
|
|
168
|
-
nextSortOrder = "descending";
|
|
169
|
-
currentSortDescription = "";
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
return `Sortable column, ${currentSortDescription}activate to sort column ${nextSortOrder}`;
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "ariaAttributes",
|
|
176
|
-
value: function ariaAttributes() {
|
|
177
|
-
const aria = {};
|
|
178
|
-
|
|
179
|
-
if (this.context.sortOrder && this.isCurrentSortedColumn) {
|
|
180
|
-
aria["aria-sort"] = this.context.sortOrder === "asc" ? "ascending" : "descending";
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return aria;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Emits sort event to parent context - table.
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
}, {
|
|
190
|
-
key: "componentTags",
|
|
191
|
-
value: function componentTags(props) {
|
|
192
|
-
return {
|
|
193
|
-
"data-component": "table-header",
|
|
194
|
-
"data-element": props["data-element"],
|
|
195
|
-
"data-role": props["data-role"]
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "styledComponent",
|
|
200
|
-
value: function styledComponent() {
|
|
201
|
-
return this.props.styledComponent || _tableHeader.default;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Renders the component.
|
|
205
|
-
*/
|
|
206
|
-
|
|
207
|
-
}, {
|
|
208
|
-
key: "render",
|
|
209
|
-
value: function render() {
|
|
210
|
-
let contents = null;
|
|
211
|
-
|
|
212
|
-
if (this.props.sortable) {
|
|
213
|
-
const sortOrder = this.context.sortOrder === "asc" ? "desc" : "asc";
|
|
214
|
-
contents = /*#__PURE__*/_react.default.createElement("a", {
|
|
215
|
-
href: `#sort-${sortOrder}`,
|
|
216
|
-
"aria-label": this.sortDescription,
|
|
217
|
-
onClick: this.onSortableColumnClick
|
|
218
|
-
}, this.props.children, this.sortIconHTML);
|
|
219
|
-
} else {
|
|
220
|
-
contents = this.props.children;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const additionalProps = {
|
|
224
|
-
align: this.props.align,
|
|
225
|
-
sortable: this.props.sortable
|
|
226
|
-
};
|
|
227
|
-
if (/^\d+$/.test(this.props.width)) additionalProps.width = this.props.width;
|
|
228
|
-
return /*#__PURE__*/_react.default.createElement(this.styledComponent(), { ...this.componentTags(this.props),
|
|
229
|
-
...this.tableHeaderProps,
|
|
230
|
-
...this.ariaAttributes(),
|
|
231
|
-
...additionalProps
|
|
232
|
-
}, contents);
|
|
233
|
-
}
|
|
234
|
-
}]);
|
|
235
|
-
|
|
236
|
-
return TableHeader;
|
|
237
|
-
}(_react.default.Component);
|
|
238
|
-
|
|
239
|
-
TableHeader.propTypes = {
|
|
240
|
-
/** Aligns the content of the cell (can be "left", "center" or "right"). */
|
|
241
|
-
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
242
|
-
|
|
243
|
-
/** The body of the content component. */
|
|
244
|
-
children: _propTypes.default.node,
|
|
245
|
-
|
|
246
|
-
/** Name of the column to sort. Should correspond to name in database. */
|
|
247
|
-
name(props, propName) {
|
|
248
|
-
if (props.sortable) {
|
|
249
|
-
if (!props[propName]) {
|
|
250
|
-
throw new Error("Sortable columns require a prop of name of type String");
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
if (typeof props[propName] !== "string") {
|
|
254
|
-
throw new Error("name must be a string");
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
/** Whether column is sortable. */
|
|
260
|
-
sortable: _propTypes.default.bool,
|
|
261
|
-
|
|
262
|
-
/** Whether component is a subheader. */
|
|
263
|
-
styledComponent: _propTypes.default.node,
|
|
264
|
-
|
|
265
|
-
/** A width value to constrain a column eg 250. */
|
|
266
|
-
width: _propTypes.default.string
|
|
267
|
-
};
|
|
268
|
-
TableHeader.defaultProps = {
|
|
269
|
-
children: null,
|
|
270
|
-
name: "",
|
|
271
|
-
sortable: false,
|
|
272
|
-
align: "left"
|
|
273
|
-
};
|
|
274
|
-
/** Sort handler passed from table context */
|
|
275
|
-
|
|
276
|
-
TableHeader.contextTypes = {
|
|
277
|
-
onSort: _propTypes.default.func,
|
|
278
|
-
sortedColumn: _propTypes.default.string,
|
|
279
|
-
sortOrder: _propTypes.default.string
|
|
280
|
-
};
|
|
281
|
-
var _default = TableHeader;
|
|
282
|
-
exports.default = _default;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
-
|
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
|
-
var _base = _interopRequireDefault(require("../../../style/themes/base"));
|
|
13
|
-
|
|
14
|
-
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
19
|
-
|
|
20
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
-
|
|
22
|
-
const StyledTableHeader = _styledComponents.default.th`
|
|
23
|
-
${({
|
|
24
|
-
align,
|
|
25
|
-
sortable,
|
|
26
|
-
theme,
|
|
27
|
-
width
|
|
28
|
-
}) => {
|
|
29
|
-
const {
|
|
30
|
-
table,
|
|
31
|
-
colors
|
|
32
|
-
} = theme;
|
|
33
|
-
return (0, _styledComponents.css)`
|
|
34
|
-
background-color: ${table.header};
|
|
35
|
-
border-width: 0;
|
|
36
|
-
border-bottom: 1px solid ${table.secondary};
|
|
37
|
-
border-left: 1px solid ${colors.border};
|
|
38
|
-
box-sizing: border-box;
|
|
39
|
-
color: ${colors.white};
|
|
40
|
-
font-weight: 700;
|
|
41
|
-
outline: medium none;
|
|
42
|
-
padding: 0 8px;
|
|
43
|
-
position: relative;
|
|
44
|
-
text-align: ${align};
|
|
45
|
-
text-overflow: ellipsis;
|
|
46
|
-
user-select: none;
|
|
47
|
-
vertical-align: middle;
|
|
48
|
-
white-space: nowrap;
|
|
49
|
-
|
|
50
|
-
&:first-child {
|
|
51
|
-
border-left: none;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
${width && (0, _styledComponents.css)`
|
|
55
|
-
width: ${width}px;
|
|
56
|
-
`}
|
|
57
|
-
|
|
58
|
-
${sortable && applySortableStyling(align, colors, table)}
|
|
59
|
-
`;
|
|
60
|
-
}}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
function applySortableStyling(align, colors, table) {
|
|
64
|
-
return (0, _styledComponents.css)`
|
|
65
|
-
cursor: pointer;
|
|
66
|
-
|
|
67
|
-
&:hover {
|
|
68
|
-
background-color: ${table.tertiary};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
${_icon.default} {
|
|
72
|
-
color: ${colors.white};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
a {
|
|
76
|
-
&:link,
|
|
77
|
-
&:visited,
|
|
78
|
-
&:hover,
|
|
79
|
-
&:active {
|
|
80
|
-
color: ${colors.white};
|
|
81
|
-
text-decoration: none;
|
|
82
|
-
display: flex;
|
|
83
|
-
align-items: center;
|
|
84
|
-
line-height: 16px;
|
|
85
|
-
height: 24px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
span {
|
|
89
|
-
float: ${align === "right" ? "left" : "right"};
|
|
90
|
-
|
|
91
|
-
.carbon-icon__svg--sort-down,
|
|
92
|
-
.carbon-icon__svg--sort-up {
|
|
93
|
-
height: 11px;
|
|
94
|
-
width: 10px;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
`;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
StyledTableHeader.propTypes = {
|
|
102
|
-
/** Sets the alignment from the content */
|
|
103
|
-
align: _propTypes.default.oneOf(["center", "left", "right"]),
|
|
104
|
-
|
|
105
|
-
/** Toggles whether column is sortable */
|
|
106
|
-
sortable: _propTypes.default.bool,
|
|
107
|
-
|
|
108
|
-
/** Width to set column to. */
|
|
109
|
-
width: _propTypes.default.string
|
|
110
|
-
};
|
|
111
|
-
StyledTableHeader.defaultProps = {
|
|
112
|
-
theme: _base.default,
|
|
113
|
-
align: "left"
|
|
114
|
-
};
|
|
115
|
-
var _default = StyledTableHeader;
|
|
116
|
-
exports.default = _default;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyModernTableStyling = applyModernTableStyling;
|
|
7
|
-
exports.applyModernInternalStyling = applyModernInternalStyling;
|
|
8
|
-
|
|
9
|
-
var _styledComponents = require("styled-components");
|
|
10
|
-
|
|
11
|
-
var _tableCell = _interopRequireDefault(require("./table-cell/table-cell.style"));
|
|
12
|
-
|
|
13
|
-
var _tableHeader = _interopRequireDefault(require("./table-header/table-header.style"));
|
|
14
|
-
|
|
15
|
-
var _tableRow = _interopRequireDefault(require("./table-row/table-row.style"));
|
|
16
|
-
|
|
17
|
-
var _tableSizes = _interopRequireDefault(require("./table-sizes.style"));
|
|
18
|
-
|
|
19
|
-
var _icon = _interopRequireDefault(require("../icon/icon.style"));
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
|
-
function convertTableType(type) {
|
|
24
|
-
if (["primary", "secondary", "tertiary"].includes(type)) return type;
|
|
25
|
-
if (type === "transparent") return "tertiary";
|
|
26
|
-
if (type === "light") return "secondary";
|
|
27
|
-
return "primary";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function applyModernInternalStyling({
|
|
31
|
-
tableType,
|
|
32
|
-
theme
|
|
33
|
-
}) {
|
|
34
|
-
const type = convertTableType(tableType);
|
|
35
|
-
return (0, _styledComponents.css)`
|
|
36
|
-
background-color: transparent;
|
|
37
|
-
border: 1px solid
|
|
38
|
-
${type === "tertiary" ? "transparent" : theme.table.secondary};
|
|
39
|
-
`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function applyModernTableStyling({
|
|
43
|
-
tableType,
|
|
44
|
-
theme,
|
|
45
|
-
isZebra,
|
|
46
|
-
size
|
|
47
|
-
}) {
|
|
48
|
-
const type = convertTableType(tableType);
|
|
49
|
-
const {
|
|
50
|
-
table
|
|
51
|
-
} = theme;
|
|
52
|
-
const {
|
|
53
|
-
height,
|
|
54
|
-
fontSize,
|
|
55
|
-
paddingSize
|
|
56
|
-
} = _tableSizes.default[size];
|
|
57
|
-
return (0, _styledComponents.css)`
|
|
58
|
-
background-color: ${type === "tertiary" ? "transparent" : theme.colors.white};
|
|
59
|
-
& ${_tableRow.default} {
|
|
60
|
-
height: ${height};
|
|
61
|
-
${_tableCell.default}, ${_tableHeader.default} {
|
|
62
|
-
font-size: ${fontSize};
|
|
63
|
-
padding-left: ${paddingSize};
|
|
64
|
-
padding-right: ${paddingSize};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
${isZebra && `
|
|
68
|
-
&:nth-child(2n) {
|
|
69
|
-
${_tableCell.default} {
|
|
70
|
-
background-color: ${table.zebra};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
:hover ${_tableCell.default} {
|
|
74
|
-
background-color: ${table.primary};
|
|
75
|
-
}
|
|
76
|
-
`}
|
|
77
|
-
&:hover ${_tableCell.default} {
|
|
78
|
-
background-color: ${table.primary};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
${type !== "primary" && additionalThemeStyling(type, theme)}
|
|
82
|
-
`;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function additionalThemeStyling(type, {
|
|
86
|
-
text,
|
|
87
|
-
table,
|
|
88
|
-
colors
|
|
89
|
-
}) {
|
|
90
|
-
return (0, _styledComponents.css)`
|
|
91
|
-
${type === "tertiary" ? "border-color: transparent;" : ""}
|
|
92
|
-
${_tableCell.default} {
|
|
93
|
-
background-color: ${colors.white};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
${_tableHeader.default} {
|
|
97
|
-
background-color: ${type === "secondary" ? table.secondary : "transparent"};
|
|
98
|
-
${type === "tertiary" ? "border-left-color: transparent;" : ""}
|
|
99
|
-
color: ${text.color};
|
|
100
|
-
|
|
101
|
-
${_icon.default},
|
|
102
|
-
a:link,
|
|
103
|
-
a:visited,
|
|
104
|
-
a:hover,
|
|
105
|
-
a:active {
|
|
106
|
-
color: ${text.color};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
`;
|
|
110
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _tableRow.default;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _tableRow = _interopRequireDefault(require("./table-row.component"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|