@carbon/ibm-products 1.20.2 → 1.22.0
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/css/components/Datagrid/styles/index.css +17 -0
- package/css/components/Datagrid/styles/index.css.map +1 -1
- package/css/components/Datagrid/styles/useColumnCenterAlign.css +18 -0
- package/css/components/Datagrid/styles/useColumnCenterAlign.css.map +1 -0
- package/css/index-full-carbon.css +25 -4
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +4 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +25 -4
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +25 -4
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +92 -92
- package/es/components/Datagrid/index.js +2 -1
- package/es/components/Datagrid/useColumnCenterAlign.js +52 -0
- package/es/components/Datagrid/utils/makeData.js +155 -0
- package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +93 -112
- package/lib/components/Datagrid/index.js +9 -1
- package/lib/components/Datagrid/useColumnCenterAlign.js +59 -0
- package/lib/components/Datagrid/utils/makeData.js +167 -0
- package/package.json +2 -2
- package/scss/components/Datagrid/styles/index.scss +1 -0
- package/scss/components/Datagrid/styles/useColumnCenterAlign.scss +19 -0
- package/scss/components/Tearsheet/_tearsheet.scss +5 -0
- package/scss/components/WebTerminal/_web-terminal.scss +1 -1
@@ -1,92 +1,92 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
};
|
92
|
-
export default StickyActionsColumn;
|
1
|
+
// import React, { useState, useEffect } from 'react';
|
2
|
+
// import { Datagrid, useActionsColumn, useDatagrid, useStickyColumn } from '..';
|
3
|
+
// import { defaultHeader, makeData, Wrapper } from './common';
|
4
|
+
// StickyActionsColumn.story = {
|
5
|
+
// parameters: {
|
6
|
+
// notes: `
|
7
|
+
// Sticky column and actions column can be used at the same time like the demo above. Following is the doc for each of them.
|
8
|
+
// # Sticky column
|
9
|
+
// This will make the column mark with \`sticky: "right"\` to be sticky on the right.
|
10
|
+
// ## Incompatible with following plugins:
|
11
|
+
// - \`useInfiniteScroll\`
|
12
|
+
// ## Sample usage:
|
13
|
+
// 1. include the \`useStickyColumn\` hook
|
14
|
+
// 2. add \`sticky="right"\` to the column object
|
15
|
+
// \`\`\`js
|
16
|
+
// const columns = [
|
17
|
+
// ... // other columns
|
18
|
+
// {
|
19
|
+
// Header: "",
|
20
|
+
// accessor: "actions",
|
21
|
+
// sticky: "right",
|
22
|
+
// width: 60,
|
23
|
+
// },
|
24
|
+
// ]
|
25
|
+
// const datagridState = useDatagrid(
|
26
|
+
// {
|
27
|
+
// columns,
|
28
|
+
// data,
|
29
|
+
// },
|
30
|
+
// useStickyColumn
|
31
|
+
// );
|
32
|
+
// \`\`\`
|
33
|
+
// \`\`\`html
|
34
|
+
// <Datagrid {...datagridState} />
|
35
|
+
// \`\`\`
|
36
|
+
// # Actions column
|
37
|
+
// This will add OverflowMenu component to the cells on the column mark with \`isAction: true\`. Each action button callback will include the actionId and row object
|
38
|
+
// ## Sample usage:
|
39
|
+
// 1. include \`useActionsColumn\` hook
|
40
|
+
// 2. add \`isAction = true\` to the column object in which you which to add the overflow menu actions
|
41
|
+
// 3. add \`rowActions = []\` array to the props
|
42
|
+
// - \`rowActions[].id\` for callback to identify the action is called
|
43
|
+
// - \`rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)\` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
44
|
+
// - \`rowActions[].shouldHideMenuItem(row: Row)\` callback to hide this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
45
|
+
// - \`rowActions[].shouldDisableMenuItem(row: Row)\` callback to disable this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
46
|
+
// - This will override \`rowActions[].disabled\` (from Carbon) because \`shouldDisableMenuItem\` is more specific to the row.
|
47
|
+
// - each action object can take all the props from \`OverflowMenuItem\` props, see [carbon docs](https://react.carbondesignsystem.com/?path=/docs/components-overflowmenu--default#overflowmenu)
|
48
|
+
// \`\`\`js
|
49
|
+
// const columns = [
|
50
|
+
// ... // other columns
|
51
|
+
// {
|
52
|
+
// Header: "",
|
53
|
+
// accessor: "actions",
|
54
|
+
// isAction: true,
|
55
|
+
// },
|
56
|
+
// ]
|
57
|
+
// const onActionClick = (actionId, row, event) => {};
|
58
|
+
// const datagridState = useDatagrid(
|
59
|
+
// {
|
60
|
+
// columns,
|
61
|
+
// data,
|
62
|
+
// rowActions: [
|
63
|
+
// {
|
64
|
+
// id: 'edit',
|
65
|
+
// itemText: 'Edit',
|
66
|
+
// onClick: onActionClick
|
67
|
+
// },
|
68
|
+
// {
|
69
|
+
// id: 'hidden',
|
70
|
+
// itemText: 'Hidden item',
|
71
|
+
// onClick: onActionClick,
|
72
|
+
// shouldHideMenuItem: () => true,
|
73
|
+
// },
|
74
|
+
// {
|
75
|
+
// id: 'delete',
|
76
|
+
// itemText: 'Delete',
|
77
|
+
// hasDivider: true,
|
78
|
+
// isDelete: true,
|
79
|
+
// onClick: onActionClick
|
80
|
+
// },
|
81
|
+
// ]
|
82
|
+
// },
|
83
|
+
// useActionsColumn,
|
84
|
+
// );
|
85
|
+
// \`\`\`
|
86
|
+
// \`\`\`html
|
87
|
+
// <Datagrid {...datagridState} />
|
88
|
+
// \`\`\`
|
89
|
+
// `,
|
90
|
+
// },
|
91
|
+
// };
|
92
|
+
// export default StickyActionsColumn;
|
@@ -19,4 +19,5 @@ export { default as useDisableSelectRows } from './useDisableSelectRows';
|
|
19
19
|
export { default as useStickyColumn } from './useStickyColumn';
|
20
20
|
export { default as useActionsColumn } from './useActionsColumn';
|
21
21
|
export { default as useCustomizeColumns } from './useCustomizeColumns';
|
22
|
-
export { default as useSelectAllWithToggle } from './useSelectAllToggle';
|
22
|
+
export { default as useSelectAllWithToggle } from './useSelectAllToggle';
|
23
|
+
export { default as useColumnCenterAlign } from './useColumnCenterAlign';
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
5
|
+
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
|
+
|
8
|
+
/*
|
9
|
+
* Licensed Materials - Property of IBM
|
10
|
+
* 5724-Q36
|
11
|
+
* (c) Copyright IBM Corp. 2020
|
12
|
+
* US Government Users Restricted Rights - Use, duplication or disclosure
|
13
|
+
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
14
|
+
*/
|
15
|
+
import React from 'react';
|
16
|
+
import cx from 'classnames';
|
17
|
+
import { pkg } from '../../settings';
|
18
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
19
|
+
|
20
|
+
var useColumnCenterAlign = function useColumnCenterAlign(hooks) {
|
21
|
+
var centerAlignRenderer = function centerAlignRenderer(tableProps, column) {
|
22
|
+
return /*#__PURE__*/React.createElement("div", {
|
23
|
+
className: cx("".concat(blockClass, "__center-align-cell-renderer"), {
|
24
|
+
sortDisabled: !tableProps.isTableSortable || tableProps.column.disableSortBy === true
|
25
|
+
})
|
26
|
+
}, column.Cell(tableProps));
|
27
|
+
};
|
28
|
+
|
29
|
+
var centerAlignHeader = function centerAlignHeader(headerProp, column) {
|
30
|
+
return /*#__PURE__*/React.createElement("div", {
|
31
|
+
className: "".concat(blockClass, "__center-align-header")
|
32
|
+
}, typeof column.Header === 'function' ? column.Header(headerProp) : column.Header);
|
33
|
+
};
|
34
|
+
|
35
|
+
var centerAlignedColumns = function centerAlignedColumns(columns) {
|
36
|
+
var columnsWithDefaultCells = columns.map(function (column) {
|
37
|
+
return _objectSpread(_objectSpread({}, column), {}, {
|
38
|
+
Cell: column.centerAlignedColumn ? function (tableProp) {
|
39
|
+
return centerAlignRenderer(tableProp, column);
|
40
|
+
} : column.Cell,
|
41
|
+
Header: column.centerAlignedColumn ? function (headerProp) {
|
42
|
+
return centerAlignHeader(headerProp, column);
|
43
|
+
} : column.Header
|
44
|
+
});
|
45
|
+
});
|
46
|
+
return _toConsumableArray(columnsWithDefaultCells);
|
47
|
+
};
|
48
|
+
|
49
|
+
hooks.visibleColumns.push(centerAlignedColumns);
|
50
|
+
};
|
51
|
+
|
52
|
+
export default useColumnCenterAlign;
|
@@ -0,0 +1,155 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
|
+
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Copyright IBM Corp. 2022, 2022
|
9
|
+
*
|
10
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
12
|
+
*/
|
13
|
+
import React from 'react';
|
14
|
+
import namor from 'namor';
|
15
|
+
export var makeData = function makeData() {
|
16
|
+
for (var _len = arguments.length, lens = new Array(_len), _key = 0; _key < _len; _key++) {
|
17
|
+
lens[_key] = arguments[_key];
|
18
|
+
}
|
19
|
+
|
20
|
+
var makeDataLevel = function makeDataLevel() {
|
21
|
+
var depth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
22
|
+
var len = lens[depth];
|
23
|
+
return range(len).map(function () {
|
24
|
+
return _objectSpread(_objectSpread({}, newPerson()), {}, {
|
25
|
+
subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined
|
26
|
+
});
|
27
|
+
});
|
28
|
+
};
|
29
|
+
|
30
|
+
return makeDataLevel();
|
31
|
+
};
|
32
|
+
export var range = function range(len) {
|
33
|
+
var arr = [];
|
34
|
+
|
35
|
+
for (var i = 0; i < len; i++) {
|
36
|
+
arr.push(i);
|
37
|
+
}
|
38
|
+
|
39
|
+
return arr;
|
40
|
+
};
|
41
|
+
|
42
|
+
var newPerson = function newPerson() {
|
43
|
+
var statusChance = Math.random();
|
44
|
+
return {
|
45
|
+
firstName: namor.generate({
|
46
|
+
words: 1,
|
47
|
+
numbers: 0
|
48
|
+
}),
|
49
|
+
lastName: namor.generate({
|
50
|
+
words: 1,
|
51
|
+
numbers: 0
|
52
|
+
}),
|
53
|
+
age: Math.floor(Math.random() * 30),
|
54
|
+
visits: Math.floor(Math.random() * 100),
|
55
|
+
progress: Math.floor(Math.random() * 100),
|
56
|
+
someone1: namor.generate({
|
57
|
+
words: 1,
|
58
|
+
numbers: 0
|
59
|
+
}),
|
60
|
+
someone2: namor.generate({
|
61
|
+
words: 1,
|
62
|
+
numbers: 0
|
63
|
+
}),
|
64
|
+
someone3: namor.generate({
|
65
|
+
words: 1,
|
66
|
+
numbers: 0
|
67
|
+
}),
|
68
|
+
someone4: namor.generate({
|
69
|
+
words: 1,
|
70
|
+
numbers: 0
|
71
|
+
}),
|
72
|
+
someone5: namor.generate({
|
73
|
+
words: 1,
|
74
|
+
numbers: 0
|
75
|
+
}),
|
76
|
+
someone6: namor.generate({
|
77
|
+
words: 1,
|
78
|
+
numbers: 0
|
79
|
+
}),
|
80
|
+
someone7: namor.generate({
|
81
|
+
words: 1,
|
82
|
+
numbers: 0
|
83
|
+
}),
|
84
|
+
someone8: namor.generate({
|
85
|
+
words: 1,
|
86
|
+
numbers: 0
|
87
|
+
}),
|
88
|
+
someone9: namor.generate({
|
89
|
+
words: 1,
|
90
|
+
numbers: 0
|
91
|
+
}),
|
92
|
+
someone10: namor.generate({
|
93
|
+
words: 1,
|
94
|
+
numbers: 0
|
95
|
+
}),
|
96
|
+
someone11: namor.generate({
|
97
|
+
words: 1,
|
98
|
+
numbers: 0
|
99
|
+
}),
|
100
|
+
someone12: namor.generate({
|
101
|
+
words: 1,
|
102
|
+
numbers: 0
|
103
|
+
}),
|
104
|
+
someone13: namor.generate({
|
105
|
+
words: 1,
|
106
|
+
numbers: 0
|
107
|
+
}),
|
108
|
+
someone14: namor.generate({
|
109
|
+
words: 1,
|
110
|
+
numbers: 0
|
111
|
+
}),
|
112
|
+
someone15: namor.generate({
|
113
|
+
words: 1,
|
114
|
+
numbers: 0
|
115
|
+
}),
|
116
|
+
someone16: namor.generate({
|
117
|
+
words: 1,
|
118
|
+
numbers: 0
|
119
|
+
}),
|
120
|
+
someone17: namor.generate({
|
121
|
+
words: 1,
|
122
|
+
numbers: 0
|
123
|
+
}),
|
124
|
+
someone18: namor.generate({
|
125
|
+
words: 1,
|
126
|
+
numbers: 0
|
127
|
+
}),
|
128
|
+
someone19: namor.generate({
|
129
|
+
words: 1,
|
130
|
+
numbers: 0
|
131
|
+
}),
|
132
|
+
someone20: namor.generate({
|
133
|
+
words: 1,
|
134
|
+
numbers: 0
|
135
|
+
}),
|
136
|
+
status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single'
|
137
|
+
};
|
138
|
+
};
|
139
|
+
|
140
|
+
export var newPersonWithTwoLines = function newPersonWithTwoLines() {
|
141
|
+
return {
|
142
|
+
firstName: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", null, namor.generate({
|
143
|
+
words: 1,
|
144
|
+
numbers: 0
|
145
|
+
})), /*#__PURE__*/React.createElement("div", null, namor.generate({
|
146
|
+
words: 1,
|
147
|
+
numbers: 0
|
148
|
+
}))),
|
149
|
+
lastName: namor.generate({
|
150
|
+
words: 1,
|
151
|
+
numbers: 0
|
152
|
+
}),
|
153
|
+
age: Math.floor(Math.random() * 30)
|
154
|
+
};
|
155
|
+
};
|
@@ -1,112 +1,93 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
}
|
95
|
-
}, {
|
96
|
-
id: 'delete',
|
97
|
-
itemText: 'Delete',
|
98
|
-
hasDivider: true,
|
99
|
-
isDelete: true,
|
100
|
-
onClick: onActionClick
|
101
|
-
}]
|
102
|
-
}, _.useStickyColumn, _.useActionsColumn);
|
103
|
-
return /*#__PURE__*/_react.default.createElement(_common.Wrapper, null, /*#__PURE__*/_react.default.createElement("h3", null, msg), /*#__PURE__*/_react.default.createElement(_.Datagrid, datagridState), /*#__PURE__*/_react.default.createElement("p", null, "More details documentation check the Notes section below"));
|
104
|
-
};
|
105
|
-
|
106
|
-
StickyActionsColumn.story = {
|
107
|
-
parameters: {
|
108
|
-
notes: "\n Sticky column and actions column can be used at the same time like the demo above. Following is the doc for each of them.\n\n # Sticky column\n This will make the column mark with `sticky: \"right\"` to be sticky on the right.\n\n ## Incompatible with following plugins:\n - `useInfiniteScroll`\n\n ## Sample usage:\n \n 1. include the `useStickyColumn` hook\n 2. add `sticky=\"right\"` to the column object\n\n ```js\n const columns = [\n ... // other columns\n {\n Header: \"\",\n accessor: \"actions\",\n sticky: \"right\",\n width: 60,\n },\n ]\n const datagridState = useDatagrid(\n {\n columns,\n data,\n },\n useStickyColumn\n );\n ```\n ```html\n <Datagrid {...datagridState} />\n ```\n\n # Actions column\n This will add OverflowMenu component to the cells on the column mark with `isAction: true`. Each action button callback will include the actionId and row object\n\n ## Sample usage:\n 1. include `useActionsColumn` hook\n 2. add `isAction = true` to the column object in which you which to add the overflow menu actions\n 3. add `rowActions = []` array to the props\n - `rowActions[].id` for callback to identify the action is called\n - `rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - `rowActions[].shouldHideMenuItem(row: Row)` callback to hide this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - `rowActions[].shouldDisableMenuItem(row: Row)` callback to disable this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)\n - This will override `rowActions[].disabled` (from Carbon) because `shouldDisableMenuItem` is more specific to the row.\n - each action object can take all the props from `OverflowMenuItem` props, see [carbon docs](https://react.carbondesignsystem.com/?path=/docs/components-overflowmenu--default#overflowmenu)\n\n ```js\n const columns = [\n ... // other columns\n {\n Header: \"\",\n accessor: \"actions\",\n isAction: true,\n },\n ]\n const onActionClick = (actionId, row, event) => {};\n const datagridState = useDatagrid(\n {\n columns,\n data,\n rowActions: [\n {\n id: 'edit',\n itemText: 'Edit',\n onClick: onActionClick\n },\n {\n id: 'hidden',\n itemText: 'Hidden item',\n onClick: onActionClick,\n shouldHideMenuItem: () => true,\n },\n {\n id: 'delete',\n itemText: 'Delete',\n hasDivider: true,\n isDelete: true,\n onClick: onActionClick\n },\n ]\n },\n useActionsColumn,\n );\n ```\n ```html\n <Datagrid {...datagridState} />\n ```\n "
|
109
|
-
}
|
110
|
-
};
|
111
|
-
var _default = StickyActionsColumn;
|
112
|
-
exports.default = _default;
|
1
|
+
// import React, { useState, useEffect } from 'react';
|
2
|
+
// import { Datagrid, useActionsColumn, useDatagrid, useStickyColumn } from '..';
|
3
|
+
// import { defaultHeader, makeData, Wrapper } from './common';
|
4
|
+
// StickyActionsColumn.story = {
|
5
|
+
// parameters: {
|
6
|
+
// notes: `
|
7
|
+
// Sticky column and actions column can be used at the same time like the demo above. Following is the doc for each of them.
|
8
|
+
// # Sticky column
|
9
|
+
// This will make the column mark with \`sticky: "right"\` to be sticky on the right.
|
10
|
+
// ## Incompatible with following plugins:
|
11
|
+
// - \`useInfiniteScroll\`
|
12
|
+
// ## Sample usage:
|
13
|
+
// 1. include the \`useStickyColumn\` hook
|
14
|
+
// 2. add \`sticky="right"\` to the column object
|
15
|
+
// \`\`\`js
|
16
|
+
// const columns = [
|
17
|
+
// ... // other columns
|
18
|
+
// {
|
19
|
+
// Header: "",
|
20
|
+
// accessor: "actions",
|
21
|
+
// sticky: "right",
|
22
|
+
// width: 60,
|
23
|
+
// },
|
24
|
+
// ]
|
25
|
+
// const datagridState = useDatagrid(
|
26
|
+
// {
|
27
|
+
// columns,
|
28
|
+
// data,
|
29
|
+
// },
|
30
|
+
// useStickyColumn
|
31
|
+
// );
|
32
|
+
// \`\`\`
|
33
|
+
// \`\`\`html
|
34
|
+
// <Datagrid {...datagridState} />
|
35
|
+
// \`\`\`
|
36
|
+
// # Actions column
|
37
|
+
// This will add OverflowMenu component to the cells on the column mark with \`isAction: true\`. Each action button callback will include the actionId and row object
|
38
|
+
// ## Sample usage:
|
39
|
+
// 1. include \`useActionsColumn\` hook
|
40
|
+
// 2. add \`isAction = true\` to the column object in which you which to add the overflow menu actions
|
41
|
+
// 3. add \`rowActions = []\` array to the props
|
42
|
+
// - \`rowActions[].id\` for callback to identify the action is called
|
43
|
+
// - \`rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)\` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
44
|
+
// - \`rowActions[].shouldHideMenuItem(row: Row)\` callback to hide this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
45
|
+
// - \`rowActions[].shouldDisableMenuItem(row: Row)\` callback to disable this menuitem. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
46
|
+
// - This will override \`rowActions[].disabled\` (from Carbon) because \`shouldDisableMenuItem\` is more specific to the row.
|
47
|
+
// - each action object can take all the props from \`OverflowMenuItem\` props, see [carbon docs](https://react.carbondesignsystem.com/?path=/docs/components-overflowmenu--default#overflowmenu)
|
48
|
+
// \`\`\`js
|
49
|
+
// const columns = [
|
50
|
+
// ... // other columns
|
51
|
+
// {
|
52
|
+
// Header: "",
|
53
|
+
// accessor: "actions",
|
54
|
+
// isAction: true,
|
55
|
+
// },
|
56
|
+
// ]
|
57
|
+
// const onActionClick = (actionId, row, event) => {};
|
58
|
+
// const datagridState = useDatagrid(
|
59
|
+
// {
|
60
|
+
// columns,
|
61
|
+
// data,
|
62
|
+
// rowActions: [
|
63
|
+
// {
|
64
|
+
// id: 'edit',
|
65
|
+
// itemText: 'Edit',
|
66
|
+
// onClick: onActionClick
|
67
|
+
// },
|
68
|
+
// {
|
69
|
+
// id: 'hidden',
|
70
|
+
// itemText: 'Hidden item',
|
71
|
+
// onClick: onActionClick,
|
72
|
+
// shouldHideMenuItem: () => true,
|
73
|
+
// },
|
74
|
+
// {
|
75
|
+
// id: 'delete',
|
76
|
+
// itemText: 'Delete',
|
77
|
+
// hasDivider: true,
|
78
|
+
// isDelete: true,
|
79
|
+
// onClick: onActionClick
|
80
|
+
// },
|
81
|
+
// ]
|
82
|
+
// },
|
83
|
+
// useActionsColumn,
|
84
|
+
// );
|
85
|
+
// \`\`\`
|
86
|
+
// \`\`\`html
|
87
|
+
// <Datagrid {...datagridState} />
|
88
|
+
// \`\`\`
|
89
|
+
// `,
|
90
|
+
// },
|
91
|
+
// };
|
92
|
+
// export default StickyActionsColumn;
|
93
|
+
"use strict";
|
@@ -17,6 +17,12 @@ Object.defineProperty(exports, "useActionsColumn", {
|
|
17
17
|
return _useActionsColumn.default;
|
18
18
|
}
|
19
19
|
});
|
20
|
+
Object.defineProperty(exports, "useColumnCenterAlign", {
|
21
|
+
enumerable: true,
|
22
|
+
get: function get() {
|
23
|
+
return _useColumnCenterAlign.default;
|
24
|
+
}
|
25
|
+
});
|
20
26
|
Object.defineProperty(exports, "useColumnRightAlign", {
|
21
27
|
enumerable: true,
|
22
28
|
get: function get() {
|
@@ -124,4 +130,6 @@ var _useActionsColumn = _interopRequireDefault(require("./useActionsColumn"));
|
|
124
130
|
|
125
131
|
var _useCustomizeColumns = _interopRequireDefault(require("./useCustomizeColumns"));
|
126
132
|
|
127
|
-
var _useSelectAllToggle = _interopRequireDefault(require("./useSelectAllToggle"));
|
133
|
+
var _useSelectAllToggle = _interopRequireDefault(require("./useSelectAllToggle"));
|
134
|
+
|
135
|
+
var _useColumnCenterAlign = _interopRequireDefault(require("./useColumnCenterAlign"));
|