@carbon/ibm-products 2.43.2-canary.104 → 2.43.2-canary.105

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,61 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ButtonProps } from '@carbon/type';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ interface Action extends ButtonProps {
5
+ id?: string;
6
+ key: string;
7
+ iconDescription: string;
8
+ label: string;
9
+ onClick?: () => void;
10
+ renderIcon: CarbonIconType;
11
+ }
12
+ interface ActionBarProps extends PropsWithChildren {
13
+ /**
14
+ * Specifies the action bar items. Each item is specified as an object
15
+ * with required fields: key for array rendering, renderIcon, iconDescription and
16
+ * label to provide the icon to display,
17
+ * and optional 'onClick' to receive notifications when the button is clicked.
18
+ * Additional fields in the object will be passed to the
19
+ * Button component, and these can include 'disabled', 'ref', 'className',
20
+ * and any other Button props.
21
+ *
22
+ * Note that the Button props 'kind', 'size',
23
+ * 'tooltipPosition', 'tooltipAlignment' and 'type' are ignored, as these
24
+ * cannot be used for an action bar item.
25
+ *
26
+ * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
27
+ */
28
+ actions?: readonly Action[];
29
+ /**
30
+ * className
31
+ */
32
+ className?: string;
33
+ /**
34
+ * maxVisible : Maximum action bar items visible before going into the overflow menu
35
+ */
36
+ maxVisible?: number;
37
+ /**
38
+ * class name applied to the overflow options
39
+ */
40
+ menuOptionsClass?: string;
41
+ /**
42
+ * onItemCountChange - event reporting maxWidth
43
+ */
44
+ onWidthChange?: (sizes: {
45
+ minWidth: number;
46
+ maxWidth: number;
47
+ }) => void;
48
+ /**
49
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
50
+ */
51
+ overflowAriaLabel: string;
52
+ /**
53
+ * align tags to right of available space
54
+ */
55
+ rightAlign?: boolean;
56
+ }
1
57
  /**
2
58
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
3
59
  */
4
- export let ActionBar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
60
+ export declare let ActionBar: React.ForwardRefExoticComponent<ActionBarProps & React.RefAttributes<HTMLDivElement>>;
61
+ export {};
@@ -20,7 +20,6 @@ import { ActionBarOverflowItems } from './ActionBarOverflowItems.js';
20
20
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
21
21
  _excluded2 = ["key", "id"],
22
22
  _excluded3 = ["key"];
23
-
24
23
  // The block part of our conventional BEM class names (blockClass__E--M).
25
24
  var blockClass = "".concat(pkg.prefix, "--action-bar");
26
25
  var componentName = 'ActionBar';
@@ -29,7 +28,6 @@ var componentName = 'ActionBar';
29
28
  var defaults = {
30
29
  actions: Object.freeze([])
31
30
  };
32
-
33
31
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
34
32
 
35
33
  /**
@@ -53,7 +51,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
53
51
  _useState4 = _slicedToArray(_useState3, 2),
54
52
  displayedItems = _useState4[0],
55
53
  setDisplayedItems = _useState4[1];
56
- var _useState5 = useState([]),
54
+ var _useState5 = useState(null),
57
55
  _useState6 = _slicedToArray(_useState5, 2),
58
56
  hiddenSizingItems = _useState6[0],
59
57
  setHiddenSizingItems = _useState6[1];
@@ -61,7 +59,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
61
59
  var refDisplayedItems = useRef(null);
62
60
  var sizingRef = useRef(null);
63
61
  var sizes = useRef({});
64
- var backupRef = useRef();
62
+ var backupRef = useRef(null);
65
63
  var localRef = ref || backupRef;
66
64
 
67
65
  // create hidden sizing items
@@ -121,24 +119,25 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
121
119
  var checkFullyVisibleItems = function checkFullyVisibleItems() {
122
120
  /* istanbul ignore if */
123
121
  if (sizingRef.current) {
122
+ var _refDisplayedItems$cu;
124
123
  var sizingItems = Array.from(sizingRef.current.querySelectorAll(".".concat(blockClass, "__hidden-sizing-item")));
125
124
 
126
125
  // first item is always the overflow even if nothing else is rendered
127
126
  var overflowItem = sizingItems.shift();
128
127
 
129
128
  // determine how many will fit
130
- var spaceAvailable = refDisplayedItems.current.offsetWidth;
129
+ var spaceAvailable = (_refDisplayedItems$cu = refDisplayedItems.current) === null || _refDisplayedItems$cu === void 0 ? void 0 : _refDisplayedItems$cu.offsetWidth;
131
130
  var willFit = 0;
132
131
  var maxVisibleWidth = 0;
133
132
  var fitLimit = maxVisible ? Math.min(maxVisible, sizingItems.length) : sizingItems.length;
134
133
 
135
134
  // loop checking the space available
136
135
  for (var i = 0; i < fitLimit; i++) {
137
- var newSpaceAvailable = spaceAvailable - sizingItems[i].offsetWidth;
136
+ var newSpaceAvailable = spaceAvailable && spaceAvailable - sizingItems[i].offsetWidth;
138
137
 
139
138
  // update maxVisibleWidth for later use by onWidthChange
140
139
  maxVisibleWidth += sizingItems[i].offsetWidth;
141
- if (newSpaceAvailable >= 0) {
140
+ if (newSpaceAvailable && newSpaceAvailable >= 0) {
142
141
  spaceAvailable = newSpaceAvailable;
143
142
  willFit += 1;
144
143
  }
@@ -148,7 +147,7 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
148
147
  var overflowWidth = overflowItem.offsetWidth;
149
148
  if (willFit < sizingItems.length) {
150
149
  // Check space for overflow
151
- while (willFit > 0 && spaceAvailable < overflowWidth) {
150
+ while (willFit > 0 && spaceAvailable && spaceAvailable < overflowWidth) {
152
151
  willFit -= 1;
153
152
 
154
153
  // Highly unlikely that any action bar item is narrower than the overflow item
@@ -161,7 +160,10 @@ var ActionBar = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
161
160
  sizes.current.minWidth = overflowWidth;
162
161
  sizes.current.maxWidth = maxVisibleWidth;
163
162
  // emit onWidthChange
164
- onWidthChange(_objectSpread2({}, sizes.current));
163
+ onWidthChange({
164
+ minWidth: overflowWidth,
165
+ maxWidth: maxVisibleWidth
166
+ });
165
167
  }
166
168
  if (willFit < 1) {
167
169
  setDisplayCount(0);
@@ -212,14 +214,17 @@ ActionBar.propTypes = {
212
214
  *
213
215
  * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
214
216
  */
217
+ /**@ts-ignore */
215
218
  actions: PropTypes.arrayOf(PropTypes.shape(_objectSpread2(_objectSpread2({}, prepareProps(Button.propTypes, [
216
219
  // props not desired from Button.propTypes
217
220
  'kind', 'size', 'tooltipPosition', 'tooltipAlignment'])), {}, {
221
+ id: PropTypes.string,
218
222
  // Additional props
219
223
  key: PropTypes.string.isRequired,
220
224
  // Redefine as form different to Button and a key prop used by ActionBarItems
221
225
  iconDescription: PropTypes.string.isRequired,
222
226
  label: PropTypes.string.isRequired,
227
+ /**@ts-ignore */
223
228
  renderIcon: Button.propTypes.renderIcon.isRequired,
224
229
  // We duplicate onClick here to improve DocGen in Storybook
225
230
  onClick: PropTypes.func
@@ -1,5 +1,39 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
3
+ interface ActionBarItemProps extends PropsWithChildren {
4
+ /**
5
+ * Specify an optional className to be added to your Button
6
+ *
7
+ * (inherited from Carbon Button)
8
+ */
9
+ className?: string;
10
+ /**
11
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
12
+ * be read by screen readers
13
+ *
14
+ * (inherited from Carbon Button)
15
+ */
16
+ label?: string;
17
+ /**
18
+ * Optional click handler
19
+ *
20
+ * (inherited from Carbon Button)
21
+ */
22
+ onClick?: () => void;
23
+ /**
24
+ * Optional prop to allow overriding the icon rendering.
25
+ * Can be a React component class
26
+ *
27
+ * (inherited from Carbon Button)
28
+ */
29
+ renderIcon?: CarbonIconType;
30
+ /**
31
+ * Optional tab index
32
+ */
33
+ tabIndex?: number;
34
+ }
1
35
  /**
2
36
  * The ActionBarItem is used in the page header to populate the action bar
3
37
  */
4
- export let ActionBarItem: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
38
+ export declare let ActionBarItem: React.ForwardRefExoticComponent<ActionBarItemProps & React.RefAttributes<HTMLDivElement>>;
39
+ export {};
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
+ import { objectSpread2 as _objectSpread2, objectWithoutProperties as _objectWithoutProperties } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
9
  import React__default from 'react';
10
10
  import PropTypes from '../../node_modules/prop-types/index.js';
11
11
  import cx from 'classnames';
@@ -13,11 +13,9 @@ import { pkg } from '../../settings.js';
13
13
  import { IconButton } from '@carbon/react';
14
14
 
15
15
  var _excluded = ["label", "className", "renderIcon"];
16
-
17
16
  // The block part of our conventional BEM class names (blockClass__E--M).
18
17
  var componentName = 'ActionBarItem';
19
18
  var blockClass = "".concat(pkg.prefix, "--action-bar-item");
20
-
21
19
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
22
20
 
23
21
  /**
@@ -85,7 +83,12 @@ ActionBarItem.propTypes = _objectSpread2(_objectSpread2({}, propTypes), {}, {
85
83
  *
86
84
  * (inherited from Carbon Button)
87
85
  */
88
- renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
86
+ /**@ts-ignore */
87
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
88
+ /**
89
+ * Optional tab index
90
+ */
91
+ tabIndex: PropTypes.number
89
92
  });
90
93
 
91
94
  export { ActionBarItem };
@@ -1,18 +1,57 @@
1
- export function ActionBarOverflowItems({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: {
2
- className: any;
3
- menuOptionsClass: any;
4
- overflowItems: any;
5
- overflowAriaLabel: any;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- export namespace ActionBarOverflowItems {
8
- export { componentName as displayName };
9
- export namespace propTypes {
10
- let className: PropTypes.Requireable<string>;
11
- let menuOptionsClass: PropTypes.Requireable<string>;
12
- let overflowAriaLabel: PropTypes.Requireable<string>;
13
- let overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
14
- }
15
- }
16
- declare const componentName: "ActionBar";
1
+ import { PropsWithChildren, ReactElement } from 'react';
17
2
  import PropTypes from 'prop-types';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ type OverflowItem = {
5
+ label: string;
6
+ onClick: () => void;
7
+ renderIcon: CarbonIconType;
8
+ };
9
+ interface ActionBarOverflowItemProps extends PropsWithChildren {
10
+ /**
11
+ * className
12
+ */
13
+ className?: string;
14
+ /**
15
+ * class name applied to the overflow options
16
+ */
17
+ menuOptionsClass?: string;
18
+ /**
19
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
20
+ */
21
+ overflowAriaLabel?: string;
22
+ /**
23
+ * overflowItems: items to bre shown in the ActionBar overflow menu
24
+ */
25
+ overflowItems?: ReactElement<OverflowItem>[];
26
+ /**
27
+ * Optional tab index
28
+ */
29
+ tabIndex?: number;
30
+ }
31
+ export declare const ActionBarOverflowItems: {
32
+ ({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: ActionBarOverflowItemProps): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ propTypes: {
35
+ /**
36
+ * className
37
+ */
38
+ className: PropTypes.Requireable<string>;
39
+ /**
40
+ * class name applied to the overflow options
41
+ */
42
+ menuOptionsClass: PropTypes.Requireable<string>;
43
+ /**
44
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
45
+ */
46
+ overflowAriaLabel: PropTypes.Requireable<string>;
47
+ /**
48
+ * overflowItems: items to bre shown in the ActionBar overflow menu
49
+ */
50
+ overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
51
+ /**
52
+ * Optional tab index
53
+ */
54
+ tabIndex: PropTypes.Requireable<number>;
55
+ };
56
+ };
18
57
  export {};
@@ -33,17 +33,17 @@ var ActionBarOverflowItems = function ActionBarOverflowItems(_ref) {
33
33
  // This uses a copy of a menu item option
34
34
  // NOTE: Cannot use a real Tooltip icon below as it uses a <button /> the
35
35
  // div equivalent below is based on Carbon 10.25.0
36
- var ItemIcon = item.props.renderIcon;
36
+ var ItemIcon = item === null || item === void 0 ? void 0 : item.props.renderIcon;
37
37
  return /*#__PURE__*/React__default.createElement(OverflowMenuItem, {
38
38
  className: "".concat(blockClass, "__item"),
39
- onClick: item.props.onClick,
39
+ onClick: item === null || item === void 0 ? void 0 : item.props.onClick,
40
40
  itemText: /*#__PURE__*/React__default.createElement("div", {
41
41
  className: "".concat(blockClass, "__item-content"),
42
42
  "aria-describedby": "".concat(internalId.current, "-").concat(index, "--item-label")
43
43
  }, /*#__PURE__*/React__default.createElement("span", {
44
44
  className: "".concat(blockClass, "__item-label"),
45
45
  id: "".concat(internalId.current, "-").concat(index, "--item-label")
46
- }, item.props.label), typeof item.props.renderIcon === 'function' ? /*#__PURE__*/React__default.createElement(ItemIcon, null) : item.props.renderIcon)
46
+ }, item === null || item === void 0 ? void 0 : item.props.label), typeof (item === null || item === void 0 ? void 0 : item.props.renderIcon) === 'function' ? /*#__PURE__*/React__default.createElement(ItemIcon, null) : item === null || item === void 0 ? void 0 : item.props.renderIcon)
47
47
  });
48
48
  }));
49
49
  };
@@ -65,7 +65,11 @@ ActionBarOverflowItems.propTypes = {
65
65
  /**
66
66
  * overflowItems: items to bre shown in the ActionBar overflow menu
67
67
  */
68
- overflowItems: PropTypes.arrayOf(PropTypes.element)
68
+ overflowItems: PropTypes.arrayOf(PropTypes.element),
69
+ /**
70
+ * Optional tab index
71
+ */
72
+ tabIndex: PropTypes.number
69
73
  };
70
74
 
71
75
  export { ActionBarOverflowItems };
@@ -1,5 +1,61 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { ButtonProps } from '@carbon/type';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ interface Action extends ButtonProps {
5
+ id?: string;
6
+ key: string;
7
+ iconDescription: string;
8
+ label: string;
9
+ onClick?: () => void;
10
+ renderIcon: CarbonIconType;
11
+ }
12
+ interface ActionBarProps extends PropsWithChildren {
13
+ /**
14
+ * Specifies the action bar items. Each item is specified as an object
15
+ * with required fields: key for array rendering, renderIcon, iconDescription and
16
+ * label to provide the icon to display,
17
+ * and optional 'onClick' to receive notifications when the button is clicked.
18
+ * Additional fields in the object will be passed to the
19
+ * Button component, and these can include 'disabled', 'ref', 'className',
20
+ * and any other Button props.
21
+ *
22
+ * Note that the Button props 'kind', 'size',
23
+ * 'tooltipPosition', 'tooltipAlignment' and 'type' are ignored, as these
24
+ * cannot be used for an action bar item.
25
+ *
26
+ * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
27
+ */
28
+ actions?: readonly Action[];
29
+ /**
30
+ * className
31
+ */
32
+ className?: string;
33
+ /**
34
+ * maxVisible : Maximum action bar items visible before going into the overflow menu
35
+ */
36
+ maxVisible?: number;
37
+ /**
38
+ * class name applied to the overflow options
39
+ */
40
+ menuOptionsClass?: string;
41
+ /**
42
+ * onItemCountChange - event reporting maxWidth
43
+ */
44
+ onWidthChange?: (sizes: {
45
+ minWidth: number;
46
+ maxWidth: number;
47
+ }) => void;
48
+ /**
49
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
50
+ */
51
+ overflowAriaLabel: string;
52
+ /**
53
+ * align tags to right of available space
54
+ */
55
+ rightAlign?: boolean;
56
+ }
1
57
  /**
2
58
  * The ActionBar is used internally by the PageHeader to wrap ActionBarItems.
3
59
  */
4
- export let ActionBar: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
60
+ export declare let ActionBar: React.ForwardRefExoticComponent<ActionBarProps & React.RefAttributes<HTMLDivElement>>;
61
+ export {};
@@ -29,7 +29,6 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
29
29
  var _excluded = ["actions", "className", "maxVisible", "menuOptionsClass", "onWidthChange", "overflowAriaLabel", "rightAlign"],
30
30
  _excluded2 = ["key", "id"],
31
31
  _excluded3 = ["key"];
32
-
33
32
  // The block part of our conventional BEM class names (blockClass__E--M).
34
33
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar");
35
34
  var componentName = 'ActionBar';
@@ -38,7 +37,6 @@ var componentName = 'ActionBar';
38
37
  var defaults = {
39
38
  actions: Object.freeze([])
40
39
  };
41
-
42
40
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
43
41
 
44
42
  /**
@@ -62,7 +60,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
62
60
  _useState4 = _rollupPluginBabelHelpers.slicedToArray(_useState3, 2),
63
61
  displayedItems = _useState4[0],
64
62
  setDisplayedItems = _useState4[1];
65
- var _useState5 = React.useState([]),
63
+ var _useState5 = React.useState(null),
66
64
  _useState6 = _rollupPluginBabelHelpers.slicedToArray(_useState5, 2),
67
65
  hiddenSizingItems = _useState6[0],
68
66
  setHiddenSizingItems = _useState6[1];
@@ -70,7 +68,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
70
68
  var refDisplayedItems = React.useRef(null);
71
69
  var sizingRef = React.useRef(null);
72
70
  var sizes = React.useRef({});
73
- var backupRef = React.useRef();
71
+ var backupRef = React.useRef(null);
74
72
  var localRef = ref || backupRef;
75
73
 
76
74
  // create hidden sizing items
@@ -130,24 +128,25 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
130
128
  var checkFullyVisibleItems = function checkFullyVisibleItems() {
131
129
  /* istanbul ignore if */
132
130
  if (sizingRef.current) {
131
+ var _refDisplayedItems$cu;
133
132
  var sizingItems = Array.from(sizingRef.current.querySelectorAll(".".concat(blockClass, "__hidden-sizing-item")));
134
133
 
135
134
  // first item is always the overflow even if nothing else is rendered
136
135
  var overflowItem = sizingItems.shift();
137
136
 
138
137
  // determine how many will fit
139
- var spaceAvailable = refDisplayedItems.current.offsetWidth;
138
+ var spaceAvailable = (_refDisplayedItems$cu = refDisplayedItems.current) === null || _refDisplayedItems$cu === void 0 ? void 0 : _refDisplayedItems$cu.offsetWidth;
140
139
  var willFit = 0;
141
140
  var maxVisibleWidth = 0;
142
141
  var fitLimit = maxVisible ? Math.min(maxVisible, sizingItems.length) : sizingItems.length;
143
142
 
144
143
  // loop checking the space available
145
144
  for (var i = 0; i < fitLimit; i++) {
146
- var newSpaceAvailable = spaceAvailable - sizingItems[i].offsetWidth;
145
+ var newSpaceAvailable = spaceAvailable && spaceAvailable - sizingItems[i].offsetWidth;
147
146
 
148
147
  // update maxVisibleWidth for later use by onWidthChange
149
148
  maxVisibleWidth += sizingItems[i].offsetWidth;
150
- if (newSpaceAvailable >= 0) {
149
+ if (newSpaceAvailable && newSpaceAvailable >= 0) {
151
150
  spaceAvailable = newSpaceAvailable;
152
151
  willFit += 1;
153
152
  }
@@ -157,7 +156,7 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
157
156
  var overflowWidth = overflowItem.offsetWidth;
158
157
  if (willFit < sizingItems.length) {
159
158
  // Check space for overflow
160
- while (willFit > 0 && spaceAvailable < overflowWidth) {
159
+ while (willFit > 0 && spaceAvailable && spaceAvailable < overflowWidth) {
161
160
  willFit -= 1;
162
161
 
163
162
  // Highly unlikely that any action bar item is narrower than the overflow item
@@ -170,7 +169,10 @@ exports.ActionBar = /*#__PURE__*/React__default["default"].forwardRef(function (
170
169
  sizes.current.minWidth = overflowWidth;
171
170
  sizes.current.maxWidth = maxVisibleWidth;
172
171
  // emit onWidthChange
173
- onWidthChange(_rollupPluginBabelHelpers.objectSpread2({}, sizes.current));
172
+ onWidthChange({
173
+ minWidth: overflowWidth,
174
+ maxWidth: maxVisibleWidth
175
+ });
174
176
  }
175
177
  if (willFit < 1) {
176
178
  setDisplayCount(0);
@@ -221,14 +223,17 @@ exports.ActionBar.propTypes = {
221
223
  *
222
224
  * Carbon Button API https://react.carbondesignsystem.com/?path=/docs/components-button--default#component-api
223
225
  */
226
+ /**@ts-ignore */
224
227
  actions: index["default"].arrayOf(index["default"].shape(_rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, propsHelper.prepareProps(react.Button.propTypes, [
225
228
  // props not desired from Button.propTypes
226
229
  'kind', 'size', 'tooltipPosition', 'tooltipAlignment'])), {}, {
230
+ id: index["default"].string,
227
231
  // Additional props
228
232
  key: index["default"].string.isRequired,
229
233
  // Redefine as form different to Button and a key prop used by ActionBarItems
230
234
  iconDescription: index["default"].string.isRequired,
231
235
  label: index["default"].string.isRequired,
236
+ /**@ts-ignore */
232
237
  renderIcon: react.Button.propTypes.renderIcon.isRequired,
233
238
  // We duplicate onClick here to improve DocGen in Storybook
234
239
  onClick: index["default"].func
@@ -1,5 +1,39 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
3
+ interface ActionBarItemProps extends PropsWithChildren {
4
+ /**
5
+ * Specify an optional className to be added to your Button
6
+ *
7
+ * (inherited from Carbon Button)
8
+ */
9
+ className?: string;
10
+ /**
11
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
12
+ * be read by screen readers
13
+ *
14
+ * (inherited from Carbon Button)
15
+ */
16
+ label?: string;
17
+ /**
18
+ * Optional click handler
19
+ *
20
+ * (inherited from Carbon Button)
21
+ */
22
+ onClick?: () => void;
23
+ /**
24
+ * Optional prop to allow overriding the icon rendering.
25
+ * Can be a React component class
26
+ *
27
+ * (inherited from Carbon Button)
28
+ */
29
+ renderIcon?: CarbonIconType;
30
+ /**
31
+ * Optional tab index
32
+ */
33
+ tabIndex?: number;
34
+ }
1
35
  /**
2
36
  * The ActionBarItem is used in the page header to populate the action bar
3
37
  */
4
- export let ActionBarItem: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
5
- import React from 'react';
38
+ export declare let ActionBarItem: React.ForwardRefExoticComponent<ActionBarItemProps & React.RefAttributes<HTMLDivElement>>;
39
+ export {};
@@ -22,11 +22,9 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
22
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
23
23
 
24
24
  var _excluded = ["label", "className", "renderIcon"];
25
-
26
25
  // The block part of our conventional BEM class names (blockClass__E--M).
27
26
  var componentName = 'ActionBarItem';
28
27
  var blockClass = "".concat(settings.pkg.prefix, "--action-bar-item");
29
-
30
28
  // NOTE: the component SCSS is not imported here: it is rolled up separately.
31
29
 
32
30
  /**
@@ -94,5 +92,10 @@ exports.ActionBarItem.propTypes = _rollupPluginBabelHelpers.objectSpread2(_rollu
94
92
  *
95
93
  * (inherited from Carbon Button)
96
94
  */
97
- renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object])
95
+ /**@ts-ignore */
96
+ renderIcon: index["default"].oneOfType([index["default"].func, index["default"].object]),
97
+ /**
98
+ * Optional tab index
99
+ */
100
+ tabIndex: index["default"].number
98
101
  });
@@ -1,18 +1,57 @@
1
- export function ActionBarOverflowItems({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: {
2
- className: any;
3
- menuOptionsClass: any;
4
- overflowItems: any;
5
- overflowAriaLabel: any;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- export namespace ActionBarOverflowItems {
8
- export { componentName as displayName };
9
- export namespace propTypes {
10
- let className: PropTypes.Requireable<string>;
11
- let menuOptionsClass: PropTypes.Requireable<string>;
12
- let overflowAriaLabel: PropTypes.Requireable<string>;
13
- let overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
14
- }
15
- }
16
- declare const componentName: "ActionBar";
1
+ import { PropsWithChildren, ReactElement } from 'react';
17
2
  import PropTypes from 'prop-types';
3
+ import { CarbonIconType } from '@carbon/icons-react/lib/CarbonIcon';
4
+ type OverflowItem = {
5
+ label: string;
6
+ onClick: () => void;
7
+ renderIcon: CarbonIconType;
8
+ };
9
+ interface ActionBarOverflowItemProps extends PropsWithChildren {
10
+ /**
11
+ * className
12
+ */
13
+ className?: string;
14
+ /**
15
+ * class name applied to the overflow options
16
+ */
17
+ menuOptionsClass?: string;
18
+ /**
19
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
20
+ */
21
+ overflowAriaLabel?: string;
22
+ /**
23
+ * overflowItems: items to bre shown in the ActionBar overflow menu
24
+ */
25
+ overflowItems?: ReactElement<OverflowItem>[];
26
+ /**
27
+ * Optional tab index
28
+ */
29
+ tabIndex?: number;
30
+ }
31
+ export declare const ActionBarOverflowItems: {
32
+ ({ className, menuOptionsClass, overflowItems, overflowAriaLabel, }: ActionBarOverflowItemProps): import("react/jsx-runtime").JSX.Element;
33
+ displayName: string;
34
+ propTypes: {
35
+ /**
36
+ * className
37
+ */
38
+ className: PropTypes.Requireable<string>;
39
+ /**
40
+ * class name applied to the overflow options
41
+ */
42
+ menuOptionsClass: PropTypes.Requireable<string>;
43
+ /**
44
+ * overflowAriaLabel label for open close button overflow used for action bar items that do nto fit.
45
+ */
46
+ overflowAriaLabel: PropTypes.Requireable<string>;
47
+ /**
48
+ * overflowItems: items to bre shown in the ActionBar overflow menu
49
+ */
50
+ overflowItems: PropTypes.Requireable<(PropTypes.ReactElementLike | null | undefined)[]>;
51
+ /**
52
+ * Optional tab index
53
+ */
54
+ tabIndex: PropTypes.Requireable<number>;
55
+ };
56
+ };
18
57
  export {};
@@ -42,17 +42,17 @@ var ActionBarOverflowItems = function ActionBarOverflowItems(_ref) {
42
42
  // This uses a copy of a menu item option
43
43
  // NOTE: Cannot use a real Tooltip icon below as it uses a <button /> the
44
44
  // div equivalent below is based on Carbon 10.25.0
45
- var ItemIcon = item.props.renderIcon;
45
+ var ItemIcon = item === null || item === void 0 ? void 0 : item.props.renderIcon;
46
46
  return /*#__PURE__*/React__default["default"].createElement(react.OverflowMenuItem, {
47
47
  className: "".concat(blockClass, "__item"),
48
- onClick: item.props.onClick,
48
+ onClick: item === null || item === void 0 ? void 0 : item.props.onClick,
49
49
  itemText: /*#__PURE__*/React__default["default"].createElement("div", {
50
50
  className: "".concat(blockClass, "__item-content"),
51
51
  "aria-describedby": "".concat(internalId.current, "-").concat(index, "--item-label")
52
52
  }, /*#__PURE__*/React__default["default"].createElement("span", {
53
53
  className: "".concat(blockClass, "__item-label"),
54
54
  id: "".concat(internalId.current, "-").concat(index, "--item-label")
55
- }, item.props.label), typeof item.props.renderIcon === 'function' ? /*#__PURE__*/React__default["default"].createElement(ItemIcon, null) : item.props.renderIcon)
55
+ }, item === null || item === void 0 ? void 0 : item.props.label), typeof (item === null || item === void 0 ? void 0 : item.props.renderIcon) === 'function' ? /*#__PURE__*/React__default["default"].createElement(ItemIcon, null) : item === null || item === void 0 ? void 0 : item.props.renderIcon)
56
56
  });
57
57
  }));
58
58
  };
@@ -74,7 +74,11 @@ ActionBarOverflowItems.propTypes = {
74
74
  /**
75
75
  * overflowItems: items to bre shown in the ActionBar overflow menu
76
76
  */
77
- overflowItems: index["default"].arrayOf(index["default"].element)
77
+ overflowItems: index["default"].arrayOf(index["default"].element),
78
+ /**
79
+ * Optional tab index
80
+ */
81
+ tabIndex: index["default"].number
78
82
  };
79
83
 
80
84
  exports.ActionBarOverflowItems = ActionBarOverflowItems;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "2.43.2-canary.104+5c1e5682a",
4
+ "version": "2.43.2-canary.105+30b4fdb2a",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -96,7 +96,7 @@
96
96
  "dependencies": {
97
97
  "@babel/runtime": "^7.23.9",
98
98
  "@carbon/feature-flags": "^0.20.0",
99
- "@carbon/ibm-products-styles": "^2.39.1-canary.114+5c1e5682a",
99
+ "@carbon/ibm-products-styles": "^2.42.0-rc.0",
100
100
  "@carbon/telemetry": "^0.1.0",
101
101
  "@dnd-kit/core": "^6.0.8",
102
102
  "@dnd-kit/modifiers": "^7.0.0",
@@ -120,5 +120,5 @@
120
120
  "react": "^16.8.6 || ^17.0.1 || ^18.2.0",
121
121
  "react-dom": "^16.8.6 || ^17.0.1 || ^18.2.0"
122
122
  },
123
- "gitHead": "5c1e5682a1d849f809f252555001adadef3c2800"
123
+ "gitHead": "30b4fdb2a315b501d3e33f93ea45b6f967117aed"
124
124
  }