@carbon/react 1.53.0-rc.0 → 1.53.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.
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import React, { AnimationEventHandler, MouseEventHandler, PropsWithChildren } from 'react';
9
+ interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
+ /**
11
+ * Specify how the trigger should align with the tooltip
12
+ */
13
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
14
+ /**
15
+ * Specify an optional className to be applied to the underlying `<button>`
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Specify the string that is displayed when the button is clicked and the
20
+ * content is copied
21
+ */
22
+ feedback?: string;
23
+ /**
24
+ * Specify the time it takes for the feedback message to timeout
25
+ */
26
+ feedbackTimeout?: number;
27
+ /**
28
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
29
+ * animation ends
30
+ */
31
+ onAnimationEnd?: AnimationEventHandler<HTMLButtonElement>;
32
+ /**
33
+ * Specify an optional `onClick` handler that is called when the underlying
34
+ * `<button>` is clicked
35
+ */
36
+ onClick?: MouseEventHandler<HTMLButtonElement>;
37
+ }
38
+ declare function Copy({ align, children, className, feedback, feedbackTimeout, onAnimationEnd, onClick, ...other }: PropsWithChildren<CopyProps>): import("react/jsx-runtime").JSX.Element;
39
+ declare namespace Copy {
40
+ var propTypes: {
41
+ /**
42
+ * Specify how the trigger should align with the tooltip
43
+ */
44
+ align: PropTypes.Requireable<string>;
45
+ /**
46
+ * Pass in content to be rendered in the underlying `<button>`
47
+ */
48
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
49
+ /**
50
+ * Specify an optional className to be applied to the underlying `<button>`
51
+ */
52
+ className: PropTypes.Requireable<string>;
53
+ /**
54
+ * Specify the string that is displayed when the button is clicked and the
55
+ * content is copied
56
+ */
57
+ feedback: PropTypes.Requireable<string>;
58
+ /**
59
+ * Specify the time it takes for the feedback message to timeout
60
+ */
61
+ feedbackTimeout: PropTypes.Requireable<number>;
62
+ /**
63
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
64
+ * animation ends
65
+ */
66
+ onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
67
+ /**
68
+ * Specify an optional `onClick` handler that is called when the underlying
69
+ * `<button>` is clicked
70
+ */
71
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
72
+ };
73
+ }
74
+ export default Copy;
@@ -57,7 +57,7 @@ function Copy(_ref) {
57
57
  onClick: composeEventHandlers([onClick, handleClick]),
58
58
  onAnimationEnd: composeEventHandlers([onAnimationEnd, handleAnimationEnd])
59
59
  }, other, {
60
- "aria-label": !children && (animation ? feedback : other['aria-label']) || null
60
+ "aria-label": !children && (animation ? feedback : other['aria-label']) || undefined
61
61
  }), children);
62
62
  }
63
63
  Copy.propTypes = {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Copy from './Copy';
8
+ export default Copy;
9
+ export { Copy };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import { MouseEventHandler } from 'react';
9
+ import { ButtonProps } from '../Button';
10
+ export interface CopyButtonProps extends ButtonProps<'button'> {
11
+ /**
12
+ * Specify how the trigger should align with the tooltip
13
+ */
14
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
15
+ /**
16
+ * Specify an optional className to be applied to the underlying `<button>`
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify the string that is displayed when the button is clicked and the
21
+ * content is copied
22
+ */
23
+ feedback?: string;
24
+ /**
25
+ * Specify the time it takes for the feedback message to timeout
26
+ */
27
+ feedbackTimeout?: number;
28
+ /**
29
+ * Provide a description for the icon representing the copy action that can
30
+ * be read by screen readers
31
+ */
32
+ iconDescription?: string;
33
+ /**
34
+ * Specify an optional `onClick` handler that is called when the underlying
35
+ * `<button>` is clicked
36
+ */
37
+ onClick?: MouseEventHandler<HTMLButtonElement>;
38
+ }
39
+ declare function CopyButton({ align, feedback, feedbackTimeout, iconDescription, className, onClick, ...other }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
40
+ declare namespace CopyButton {
41
+ var propTypes: {
42
+ /**
43
+ * Specify how the trigger should align with the tooltip
44
+ */
45
+ align: PropTypes.Requireable<string>;
46
+ /**
47
+ * Specify an optional className to be applied to the underlying `<button>`
48
+ */
49
+ className: PropTypes.Requireable<string>;
50
+ /**
51
+ * Specify the string that is displayed when the button is clicked and the
52
+ * content is copied
53
+ */
54
+ feedback: PropTypes.Requireable<string>;
55
+ /**
56
+ * Specify the time it takes for the feedback message to timeout
57
+ */
58
+ feedbackTimeout: PropTypes.Requireable<number>;
59
+ /**
60
+ * Provide a description for the icon representing the copy action that can
61
+ * be read by screen readers
62
+ */
63
+ iconDescription: PropTypes.Requireable<string>;
64
+ /**
65
+ * Specify an optional `onClick` handler that is called when the underlying
66
+ * `<button>` is clicked
67
+ */
68
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
69
+ };
70
+ }
71
+ export default CopyButton;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import CopyButton from './CopyButton';
8
+ export default CopyButton;
9
+ export { CopyButton };
@@ -118,6 +118,9 @@ class OverflowMenu extends Component {
118
118
  const {
119
119
  onClick = noopFn
120
120
  } = this.props;
121
+ this.setState({
122
+ click: true
123
+ });
121
124
  evt.stopPropagation();
122
125
  if (!this._menuBody || !this._menuBody.contains(evt.target)) {
123
126
  this.setState({
@@ -127,6 +130,15 @@ class OverflowMenu extends Component {
127
130
  }
128
131
  });
129
132
  _defineProperty(this, "closeMenuAndFocus", () => {
133
+ let wasClicked = this.state.click;
134
+ let wasOpen = this.state.open;
135
+ this.closeMenu(() => {
136
+ if (wasOpen && !wasClicked) {
137
+ this.focusMenuEl();
138
+ }
139
+ });
140
+ });
141
+ _defineProperty(this, "closeMenuOnEscape", () => {
130
142
  let wasOpen = this.state.open;
131
143
  this.closeMenu(() => {
132
144
  if (wasOpen) {
@@ -141,7 +153,7 @@ class OverflowMenu extends Component {
141
153
 
142
154
  // Close the overflow menu on escape
143
155
  if (matches(evt, [Escape])) {
144
- this.closeMenuAndFocus();
156
+ this.closeMenuOnEscape();
145
157
 
146
158
  // Stop the esc keypress from bubbling out and closing something it shouldn't
147
159
  evt.stopPropagation();
package/es/index.js CHANGED
@@ -25,6 +25,8 @@ export { default as ComposedModal, ModalBody } from './components/ComposedModal/
25
25
  export { ModalHeader } from './components/ComposedModal/ModalHeader.js';
26
26
  export { ModalFooter } from './components/ComposedModal/ModalFooter.js';
27
27
  export { default as ContentSwitcher } from './components/ContentSwitcher/index.js';
28
+ export { default as Copy } from './components/Copy/Copy.js';
29
+ export { default as CopyButton } from './components/CopyButton/CopyButton.js';
28
30
  export { default as DangerButton } from './components/DangerButton/DangerButton.js';
29
31
  import './components/DataTable/index.js';
30
32
  export { default as DataTableSkeleton } from './components/DataTableSkeleton/DataTableSkeleton.js';
@@ -169,8 +171,6 @@ export { default as CodeSnippet } from './components/CodeSnippet/CodeSnippet.js'
169
171
  export { default as ContainedListItem } from './components/ContainedList/ContainedListItem/ContainedListItem.js';
170
172
  export { default as ContainedList } from './components/ContainedList/ContainedList.js';
171
173
  export { default as useContextMenu } from './components/ContextMenu/useContextMenu.js';
172
- export { default as Copy } from './components/Copy/Copy.js';
173
- export { default as CopyButton } from './components/CopyButton/CopyButton.js';
174
174
  export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.js';
175
175
  export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
176
176
  export { default as TextInput } from './components/TextInput/TextInput.js';
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import React, { AnimationEventHandler, MouseEventHandler, PropsWithChildren } from 'react';
9
+ interface CopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
10
+ /**
11
+ * Specify how the trigger should align with the tooltip
12
+ */
13
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
14
+ /**
15
+ * Specify an optional className to be applied to the underlying `<button>`
16
+ */
17
+ className?: string;
18
+ /**
19
+ * Specify the string that is displayed when the button is clicked and the
20
+ * content is copied
21
+ */
22
+ feedback?: string;
23
+ /**
24
+ * Specify the time it takes for the feedback message to timeout
25
+ */
26
+ feedbackTimeout?: number;
27
+ /**
28
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
29
+ * animation ends
30
+ */
31
+ onAnimationEnd?: AnimationEventHandler<HTMLButtonElement>;
32
+ /**
33
+ * Specify an optional `onClick` handler that is called when the underlying
34
+ * `<button>` is clicked
35
+ */
36
+ onClick?: MouseEventHandler<HTMLButtonElement>;
37
+ }
38
+ declare function Copy({ align, children, className, feedback, feedbackTimeout, onAnimationEnd, onClick, ...other }: PropsWithChildren<CopyProps>): import("react/jsx-runtime").JSX.Element;
39
+ declare namespace Copy {
40
+ var propTypes: {
41
+ /**
42
+ * Specify how the trigger should align with the tooltip
43
+ */
44
+ align: PropTypes.Requireable<string>;
45
+ /**
46
+ * Pass in content to be rendered in the underlying `<button>`
47
+ */
48
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
49
+ /**
50
+ * Specify an optional className to be applied to the underlying `<button>`
51
+ */
52
+ className: PropTypes.Requireable<string>;
53
+ /**
54
+ * Specify the string that is displayed when the button is clicked and the
55
+ * content is copied
56
+ */
57
+ feedback: PropTypes.Requireable<string>;
58
+ /**
59
+ * Specify the time it takes for the feedback message to timeout
60
+ */
61
+ feedbackTimeout: PropTypes.Requireable<number>;
62
+ /**
63
+ * Specify an optional `onAnimationEnd` handler that is called when the underlying
64
+ * animation ends
65
+ */
66
+ onAnimationEnd: PropTypes.Requireable<(...args: any[]) => any>;
67
+ /**
68
+ * Specify an optional `onClick` handler that is called when the underlying
69
+ * `<button>` is clicked
70
+ */
71
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
72
+ };
73
+ }
74
+ export default Copy;
@@ -68,7 +68,7 @@ function Copy(_ref) {
68
68
  onClick: events.composeEventHandlers([onClick, handleClick]),
69
69
  onAnimationEnd: events.composeEventHandlers([onAnimationEnd, handleAnimationEnd])
70
70
  }, other, {
71
- "aria-label": !children && (animation ? feedback : other['aria-label']) || null
71
+ "aria-label": !children && (animation ? feedback : other['aria-label']) || undefined
72
72
  }), children);
73
73
  }
74
74
  Copy.propTypes = {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import Copy from './Copy';
8
+ export default Copy;
9
+ export { Copy };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PropTypes from 'prop-types';
8
+ import { MouseEventHandler } from 'react';
9
+ import { ButtonProps } from '../Button';
10
+ export interface CopyButtonProps extends ButtonProps<'button'> {
11
+ /**
12
+ * Specify how the trigger should align with the tooltip
13
+ */
14
+ align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
15
+ /**
16
+ * Specify an optional className to be applied to the underlying `<button>`
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Specify the string that is displayed when the button is clicked and the
21
+ * content is copied
22
+ */
23
+ feedback?: string;
24
+ /**
25
+ * Specify the time it takes for the feedback message to timeout
26
+ */
27
+ feedbackTimeout?: number;
28
+ /**
29
+ * Provide a description for the icon representing the copy action that can
30
+ * be read by screen readers
31
+ */
32
+ iconDescription?: string;
33
+ /**
34
+ * Specify an optional `onClick` handler that is called when the underlying
35
+ * `<button>` is clicked
36
+ */
37
+ onClick?: MouseEventHandler<HTMLButtonElement>;
38
+ }
39
+ declare function CopyButton({ align, feedback, feedbackTimeout, iconDescription, className, onClick, ...other }: CopyButtonProps): import("react/jsx-runtime").JSX.Element;
40
+ declare namespace CopyButton {
41
+ var propTypes: {
42
+ /**
43
+ * Specify how the trigger should align with the tooltip
44
+ */
45
+ align: PropTypes.Requireable<string>;
46
+ /**
47
+ * Specify an optional className to be applied to the underlying `<button>`
48
+ */
49
+ className: PropTypes.Requireable<string>;
50
+ /**
51
+ * Specify the string that is displayed when the button is clicked and the
52
+ * content is copied
53
+ */
54
+ feedback: PropTypes.Requireable<string>;
55
+ /**
56
+ * Specify the time it takes for the feedback message to timeout
57
+ */
58
+ feedbackTimeout: PropTypes.Requireable<number>;
59
+ /**
60
+ * Provide a description for the icon representing the copy action that can
61
+ * be read by screen readers
62
+ */
63
+ iconDescription: PropTypes.Requireable<string>;
64
+ /**
65
+ * Specify an optional `onClick` handler that is called when the underlying
66
+ * `<button>` is clicked
67
+ */
68
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
69
+ };
70
+ }
71
+ export default CopyButton;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import CopyButton from './CopyButton';
8
+ export default CopyButton;
9
+ export { CopyButton };
@@ -129,6 +129,9 @@ class OverflowMenu extends React.Component {
129
129
  const {
130
130
  onClick = noopFn.noopFn
131
131
  } = this.props;
132
+ this.setState({
133
+ click: true
134
+ });
132
135
  evt.stopPropagation();
133
136
  if (!this._menuBody || !this._menuBody.contains(evt.target)) {
134
137
  this.setState({
@@ -138,6 +141,15 @@ class OverflowMenu extends React.Component {
138
141
  }
139
142
  });
140
143
  _rollupPluginBabelHelpers.defineProperty(this, "closeMenuAndFocus", () => {
144
+ let wasClicked = this.state.click;
145
+ let wasOpen = this.state.open;
146
+ this.closeMenu(() => {
147
+ if (wasOpen && !wasClicked) {
148
+ this.focusMenuEl();
149
+ }
150
+ });
151
+ });
152
+ _rollupPluginBabelHelpers.defineProperty(this, "closeMenuOnEscape", () => {
141
153
  let wasOpen = this.state.open;
142
154
  this.closeMenu(() => {
143
155
  if (wasOpen) {
@@ -152,7 +164,7 @@ class OverflowMenu extends React.Component {
152
164
 
153
165
  // Close the overflow menu on escape
154
166
  if (match.matches(evt, [keys.Escape])) {
155
- this.closeMenuAndFocus();
167
+ this.closeMenuOnEscape();
156
168
 
157
169
  // Stop the esc keypress from bubbling out and closing something it shouldn't
158
170
  evt.stopPropagation();
package/lib/index.js CHANGED
@@ -29,6 +29,8 @@ var ComposedModal = require('./components/ComposedModal/ComposedModal.js');
29
29
  var ModalHeader = require('./components/ComposedModal/ModalHeader.js');
30
30
  var ModalFooter = require('./components/ComposedModal/ModalFooter.js');
31
31
  var index$6 = require('./components/ContentSwitcher/index.js');
32
+ var Copy = require('./components/Copy/Copy.js');
33
+ var CopyButton = require('./components/CopyButton/CopyButton.js');
32
34
  var DangerButton = require('./components/DangerButton/DangerButton.js');
33
35
  require('./components/DataTable/index.js');
34
36
  var DataTableSkeleton = require('./components/DataTableSkeleton/DataTableSkeleton.js');
@@ -173,8 +175,6 @@ var CodeSnippet = require('./components/CodeSnippet/CodeSnippet.js');
173
175
  var ContainedListItem = require('./components/ContainedList/ContainedListItem/ContainedListItem.js');
174
176
  var ContainedList = require('./components/ContainedList/ContainedList.js');
175
177
  var useContextMenu = require('./components/ContextMenu/useContextMenu.js');
176
- var Copy = require('./components/Copy/Copy.js');
177
- var CopyButton = require('./components/CopyButton/CopyButton.js');
178
178
  var Slider_Skeleton = require('./components/Slider/Slider.Skeleton.js');
179
179
  var TextInput_Skeleton = require('./components/TextInput/TextInput.Skeleton.js');
180
180
  var TextInput = require('./components/TextInput/TextInput.js');
@@ -255,6 +255,8 @@ exports.ModalBody = ComposedModal.ModalBody;
255
255
  exports.ModalHeader = ModalHeader.ModalHeader;
256
256
  exports.ModalFooter = ModalFooter.ModalFooter;
257
257
  exports.ContentSwitcher = index$6["default"];
258
+ exports.Copy = Copy["default"];
259
+ exports.CopyButton = CopyButton["default"];
258
260
  exports.DangerButton = DangerButton["default"];
259
261
  exports.DataTableSkeleton = DataTableSkeleton["default"];
260
262
  exports.DatePicker = DatePicker["default"];
@@ -438,8 +440,6 @@ exports.CodeSnippet = CodeSnippet["default"];
438
440
  exports.ContainedListItem = ContainedListItem["default"];
439
441
  exports.ContainedList = ContainedList["default"];
440
442
  exports.useContextMenu = useContextMenu["default"];
441
- exports.Copy = Copy["default"];
442
- exports.CopyButton = CopyButton["default"];
443
443
  exports.SliderSkeleton = Slider_Skeleton["default"];
444
444
  exports.TextInputSkeleton = TextInput_Skeleton["default"];
445
445
  exports.TextInput = TextInput["default"];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.53.0-rc.0",
4
+ "version": "1.53.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -48,14 +48,14 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@babel/runtime": "^7.18.3",
51
- "@carbon/feature-flags": "^0.18.0-rc.0",
52
- "@carbon/icons-react": "^11.38.0-rc.0",
53
- "@carbon/layout": "^11.21.0-rc.0",
54
- "@carbon/styles": "^1.53.0-rc.0",
51
+ "@carbon/feature-flags": "^0.18.0",
52
+ "@carbon/icons-react": "^11.38.0",
53
+ "@carbon/layout": "^11.21.0",
54
+ "@carbon/styles": "^1.53.0",
55
55
  "@ibm/telemetry-js": "^1.2.1",
56
56
  "classnames": "2.5.1",
57
57
  "copy-to-clipboard": "^3.3.1",
58
- "downshift": "8.3.2",
58
+ "downshift": "8.4.0",
59
59
  "flatpickr": "4.6.13",
60
60
  "invariant": "^2.2.3",
61
61
  "lodash.debounce": "^4.0.8",
@@ -79,7 +79,7 @@
79
79
  "@babel/preset-react": "^7.22.3",
80
80
  "@babel/preset-typescript": "^7.21.5",
81
81
  "@carbon/test-utils": "^10.30.0",
82
- "@carbon/themes": "^11.33.0-rc.0",
82
+ "@carbon/themes": "^11.33.0",
83
83
  "@rollup/plugin-babel": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^25.0.0",
85
85
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "fd9030978919c8d2ce0c102db94aeabf88563c34"
142
+ "gitHead": "7920f5261d5867837e0b7e6092c98a6597ac0771"
143
143
  }