@carbon/ibm-products 1.20.1 → 1.21.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.
@@ -1,92 +1,92 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
- import React, { useState, useEffect } from 'react';
4
- import { Datagrid, useActionsColumn, useDatagrid, useStickyColumn } from '..';
5
- import { defaultHeader, makeData, Wrapper } from './common';
6
-
7
- var StickyActionsColumn = function StickyActionsColumn() {
8
- var columns = React.useMemo(function () {
9
- return [].concat(_toConsumableArray(defaultHeader), [{
10
- Header: '',
11
- accessor: 'actions',
12
- sticky: 'right',
13
- width: 60,
14
- isAction: true
15
- }]);
16
- }, []);
17
-
18
- var _useState = useState([]),
19
- _useState2 = _slicedToArray(_useState, 2),
20
- data = _useState2[0],
21
- setData = _useState2[1];
22
-
23
- var _useState3 = useState('click action menu'),
24
- _useState4 = _slicedToArray(_useState3, 2),
25
- msg = _useState4[0],
26
- setMsg = _useState4[1];
27
-
28
- var onActionClick = function onActionClick(actionId, row) {
29
- var original = row.original;
30
- setMsg("Clicked [".concat(actionId, "] on row: <").concat(original.firstName, " ").concat(original.lastName, ">"));
31
- };
32
-
33
- var _useState5 = useState(true),
34
- _useState6 = _slicedToArray(_useState5, 2),
35
- isFetching = _useState6[0],
36
- setIsFetching = _useState6[1];
37
-
38
- useEffect(function () {
39
- var fetchData = function fetchData() {
40
- return new Promise(function (resolve) {
41
- setIsFetching(true);
42
- setTimeout(function () {
43
- setData(data.concat(makeData(30, 5, 2)));
44
- resolve();
45
- }, 1000);
46
- }).then(function () {
47
- return setIsFetching(false);
48
- });
49
- };
50
-
51
- fetchData();
52
- }, [data]);
53
- var datagridState = useDatagrid({
54
- columns: columns,
55
- data: data,
56
- isFetching: isFetching,
57
- rowActions: [{
58
- id: 'edit',
59
- itemText: 'Edit',
60
- onClick: onActionClick
61
- }, {
62
- id: 'vote',
63
- itemText: 'Vote',
64
- onClick: onActionClick,
65
- shouldHideMenuItem: function shouldHideMenuItem(row) {
66
- return row.original.age <= 18;
67
- }
68
- }, {
69
- id: 'retire',
70
- itemText: 'Retire',
71
- onClick: onActionClick,
72
- disabled: false,
73
- shouldDisableMenuItem: function shouldDisableMenuItem(row) {
74
- return row.original.age <= 60;
75
- }
76
- }, {
77
- id: 'delete',
78
- itemText: 'Delete',
79
- hasDivider: true,
80
- isDelete: true,
81
- onClick: onActionClick
82
- }]
83
- }, useStickyColumn, useActionsColumn);
84
- return /*#__PURE__*/React.createElement(Wrapper, null, /*#__PURE__*/React.createElement("h3", null, msg), /*#__PURE__*/React.createElement(Datagrid, datagridState), /*#__PURE__*/React.createElement("p", null, "More details documentation check the Notes section below"));
85
- };
86
-
87
- StickyActionsColumn.story = {
88
- parameters: {
89
- 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 "
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;
@@ -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
+ };
@@ -19,8 +19,6 @@ var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _propTypes = _interopRequireDefault(require("prop-types"));
21
21
 
22
- var _InlineCheckbox = _interopRequireDefault(require("carbon-components-react/lib/components/InlineCheckbox"));
23
-
24
22
  var _carbonComponentsReact = require("carbon-components-react");
25
23
 
26
24
  var _iconsReact = require("@carbon/icons-react");
@@ -81,7 +79,7 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
81
79
  role: "columnheader",
82
80
  scope: "col",
83
81
  className: "".concat(blockClass, "__select-all-toggle-on")
84
- }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_InlineCheckbox.default, (0, _extends2.default)({}, selectProps, {
82
+ }, /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Checkbox, (0, _extends2.default)({}, selectProps, {
85
83
  name: "".concat(tableId, "-select-all-checkbox-name"),
86
84
  onClick: function onClick(e) {
87
85
  onChange(e);
@@ -1,112 +1,93 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.default = void 0;
11
-
12
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
-
14
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
- var _react = _interopRequireWildcard(require("react"));
17
-
18
- var _ = require("..");
19
-
20
- var _common = require("./common");
21
-
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
25
-
26
- var StickyActionsColumn = function StickyActionsColumn() {
27
- var columns = _react.default.useMemo(function () {
28
- return [].concat((0, _toConsumableArray2.default)(_common.defaultHeader), [{
29
- Header: '',
30
- accessor: 'actions',
31
- sticky: 'right',
32
- width: 60,
33
- isAction: true
34
- }]);
35
- }, []);
36
-
37
- var _useState = (0, _react.useState)([]),
38
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
39
- data = _useState2[0],
40
- setData = _useState2[1];
41
-
42
- var _useState3 = (0, _react.useState)('click action menu'),
43
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
44
- msg = _useState4[0],
45
- setMsg = _useState4[1];
46
-
47
- var onActionClick = function onActionClick(actionId, row) {
48
- var original = row.original;
49
- setMsg("Clicked [".concat(actionId, "] on row: <").concat(original.firstName, " ").concat(original.lastName, ">"));
50
- };
51
-
52
- var _useState5 = (0, _react.useState)(true),
53
- _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
54
- isFetching = _useState6[0],
55
- setIsFetching = _useState6[1];
56
-
57
- (0, _react.useEffect)(function () {
58
- var fetchData = function fetchData() {
59
- return new Promise(function (resolve) {
60
- setIsFetching(true);
61
- setTimeout(function () {
62
- setData(data.concat((0, _common.makeData)(30, 5, 2)));
63
- resolve();
64
- }, 1000);
65
- }).then(function () {
66
- return setIsFetching(false);
67
- });
68
- };
69
-
70
- fetchData();
71
- }, [data]);
72
- var datagridState = (0, _.useDatagrid)({
73
- columns: columns,
74
- data: data,
75
- isFetching: isFetching,
76
- rowActions: [{
77
- id: 'edit',
78
- itemText: 'Edit',
79
- onClick: onActionClick
80
- }, {
81
- id: 'vote',
82
- itemText: 'Vote',
83
- onClick: onActionClick,
84
- shouldHideMenuItem: function shouldHideMenuItem(row) {
85
- return row.original.age <= 18;
86
- }
87
- }, {
88
- id: 'retire',
89
- itemText: 'Retire',
90
- onClick: onActionClick,
91
- disabled: false,
92
- shouldDisableMenuItem: function shouldDisableMenuItem(row) {
93
- return row.original.age <= 60;
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";