@carbon/react 1.51.0-rc.0 → 1.51.1

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/README.md CHANGED
@@ -51,6 +51,25 @@ to include `node_modules` in its `includePaths` option. For more information,
51
51
  checkout the [configuration](../styles/docs/sass.md#configuration) section in
52
52
  our Sass docs.
53
53
 
54
+ ### TypeScript
55
+
56
+ There is an ongoing project to add `*.d.ts` files to `@carbon/react`. Though not
57
+ all components have yet been typed, you can still use the project successfully
58
+ in a TypeScript setting, provided you amend to your `tsconfig.json` or
59
+ equivalent configuration file. Include the `skipLibCheck: true` compiler option:
60
+
61
+ ```json
62
+ {
63
+ "compilerOptions": {
64
+ "skipLibCheck": true
65
+ }
66
+ }
67
+ ```
68
+
69
+ To track the progress of TypeScript adoption, check out:
70
+
71
+ - [TypeScript Adoption](https://github.com/orgs/carbon-design-system/projects/53)
72
+
54
73
  ## Usage
55
74
 
56
75
  The `@carbon/react` package provides components and icons for the Carbon Design
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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 from 'react';
9
+ interface AiSkeletonIconProps {
10
+ /**
11
+ * Specify an optional className to add.
12
+ */
13
+ className?: string;
14
+ /**
15
+ * The CSS styles.
16
+ */
17
+ style?: React.CSSProperties;
18
+ }
19
+ declare const AiSkeletonIcon: {
20
+ ({ className, ...rest }: AiSkeletonIconProps): import("react/jsx-runtime").JSX.Element;
21
+ propTypes: {
22
+ /**
23
+ * Specify an optional className to add.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ /**
27
+ * The CSS styles.
28
+ */
29
+ style: PropTypes.Requireable<object>;
30
+ };
31
+ };
32
+ export default AiSkeletonIcon;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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
+ export interface AiSkeletonPlaceholderProps {
9
+ /**
10
+ * Add a custom class to the component to set the height and width
11
+ */
12
+ className?: string;
13
+ }
14
+ declare const AiSkeletonPlaceholder: {
15
+ ({ className, ...other }: AiSkeletonPlaceholderProps): import("react/jsx-runtime").JSX.Element;
16
+ propTypes: {
17
+ /**
18
+ * Add a custom class to the component
19
+ * to set the height and width
20
+ */
21
+ className: PropTypes.Requireable<string>;
22
+ };
23
+ };
24
+ export default AiSkeletonPlaceholder;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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
+ interface AiSkeletonTextProps {
9
+ /**
10
+ * Specify an optional className to be applied to the container node.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Generates skeleton text at a larger size.
15
+ */
16
+ heading?: boolean;
17
+ /**
18
+ * The number of lines shown if paragraph is true.
19
+ */
20
+ lineCount?: number;
21
+ /**
22
+ * Set this to true to generate multiple lines of text.
23
+ */
24
+ paragraph?: boolean;
25
+ /**
26
+ * Width (in px or %) of single line of text or max-width of paragraph lines.
27
+ */
28
+ width?: string;
29
+ }
30
+ declare const AiSkeletonText: {
31
+ ({ className, ...rest }: AiSkeletonTextProps): import("react/jsx-runtime").JSX.Element;
32
+ propTypes: {
33
+ /**
34
+ * Specify an optional className to be applied to the container node
35
+ */
36
+ className: PropTypes.Requireable<string>;
37
+ /**
38
+ * generates skeleton text at a larger size
39
+ */
40
+ heading: PropTypes.Requireable<boolean>;
41
+ /**
42
+ * the number of lines shown if paragraph is true
43
+ */
44
+ lineCount: PropTypes.Requireable<number>;
45
+ /**
46
+ * will generate multiple lines of text
47
+ */
48
+ paragraph: PropTypes.Requireable<boolean>;
49
+ /**
50
+ * width (in px or %) of single line of text or max-width of paragraph lines
51
+ */
52
+ width: PropTypes.Requireable<string>;
53
+ };
54
+ };
55
+ export default AiSkeletonText;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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 AiSkeletonPlaceholder from './AiSkeletonPlaceholder';
8
+ import AiSkeletonIcon from './AiSkeletonIcon';
9
+ import AiSkeletonText from './AiSkeletonText';
10
+ export { AiSkeletonText, AiSkeletonIcon, AiSkeletonPlaceholder };
@@ -21,12 +21,14 @@ const ChatButton = /*#__PURE__*/React__default.forwardRef(function ChatButton(_r
21
21
  isQuickAction,
22
22
  isSelected,
23
23
  kind,
24
+ renderIcon,
24
25
  size,
25
26
  ...other
26
27
  } = _ref;
27
28
  const prefix = usePrefix();
28
29
  const classNames = cx(className, {
29
30
  [`${prefix}--chat-btn`]: true,
31
+ [`${prefix}--chat-btn--with-icon`]: renderIcon,
30
32
  [`${prefix}--chat-btn--quick-action`]: isQuickAction,
31
33
  [`${prefix}--chat-btn--quick-action--selected`]: isSelected
32
34
  });
@@ -43,7 +45,8 @@ const ChatButton = /*#__PURE__*/React__default.forwardRef(function ChatButton(_r
43
45
  className: classNames,
44
46
  kind: kind,
45
47
  ref: ref,
46
- size: size
48
+ size: size,
49
+ renderIcon: renderIcon
47
50
  }, other), children);
48
51
  });
49
52
  ChatButton.propTypes = {
@@ -71,6 +74,11 @@ ChatButton.propTypes = {
71
74
  * Specify the kind of `ChatButton` you want to create
72
75
  */
73
76
  kind: PropTypes.oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
77
+ /**
78
+ * Optional prop to specify an icon to be rendered.
79
+ * Can be a React component class
80
+ */
81
+ renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
74
82
  /**
75
83
  * Specify the size of the `ChatButton`, from the following list of sizes:
76
84
  */
@@ -36,9 +36,8 @@ const ModalBody = /*#__PURE__*/React__default.forwardRef(function ModalBody(_ref
36
36
  const contentClass = cx({
37
37
  [`${prefix}--modal-content`]: true,
38
38
  [`${prefix}--modal-content--with-form`]: hasForm,
39
- [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
40
- customClassName
41
- });
39
+ [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
40
+ }, customClassName);
42
41
  useIsomorphicEffect(() => {
43
42
  if (contentRef.current) {
44
43
  setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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 from 'react';
9
+ interface AiSkeletonIconProps {
10
+ /**
11
+ * Specify an optional className to add.
12
+ */
13
+ className?: string;
14
+ /**
15
+ * The CSS styles.
16
+ */
17
+ style?: React.CSSProperties;
18
+ }
19
+ declare const AiSkeletonIcon: {
20
+ ({ className, ...rest }: AiSkeletonIconProps): import("react/jsx-runtime").JSX.Element;
21
+ propTypes: {
22
+ /**
23
+ * Specify an optional className to add.
24
+ */
25
+ className: PropTypes.Requireable<string>;
26
+ /**
27
+ * The CSS styles.
28
+ */
29
+ style: PropTypes.Requireable<object>;
30
+ };
31
+ };
32
+ export default AiSkeletonIcon;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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
+ export interface AiSkeletonPlaceholderProps {
9
+ /**
10
+ * Add a custom class to the component to set the height and width
11
+ */
12
+ className?: string;
13
+ }
14
+ declare const AiSkeletonPlaceholder: {
15
+ ({ className, ...other }: AiSkeletonPlaceholderProps): import("react/jsx-runtime").JSX.Element;
16
+ propTypes: {
17
+ /**
18
+ * Add a custom class to the component
19
+ * to set the height and width
20
+ */
21
+ className: PropTypes.Requireable<string>;
22
+ };
23
+ };
24
+ export default AiSkeletonPlaceholder;
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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
+ interface AiSkeletonTextProps {
9
+ /**
10
+ * Specify an optional className to be applied to the container node.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * Generates skeleton text at a larger size.
15
+ */
16
+ heading?: boolean;
17
+ /**
18
+ * The number of lines shown if paragraph is true.
19
+ */
20
+ lineCount?: number;
21
+ /**
22
+ * Set this to true to generate multiple lines of text.
23
+ */
24
+ paragraph?: boolean;
25
+ /**
26
+ * Width (in px or %) of single line of text or max-width of paragraph lines.
27
+ */
28
+ width?: string;
29
+ }
30
+ declare const AiSkeletonText: {
31
+ ({ className, ...rest }: AiSkeletonTextProps): import("react/jsx-runtime").JSX.Element;
32
+ propTypes: {
33
+ /**
34
+ * Specify an optional className to be applied to the container node
35
+ */
36
+ className: PropTypes.Requireable<string>;
37
+ /**
38
+ * generates skeleton text at a larger size
39
+ */
40
+ heading: PropTypes.Requireable<boolean>;
41
+ /**
42
+ * the number of lines shown if paragraph is true
43
+ */
44
+ lineCount: PropTypes.Requireable<number>;
45
+ /**
46
+ * will generate multiple lines of text
47
+ */
48
+ paragraph: PropTypes.Requireable<boolean>;
49
+ /**
50
+ * width (in px or %) of single line of text or max-width of paragraph lines
51
+ */
52
+ width: PropTypes.Requireable<string>;
53
+ };
54
+ };
55
+ export default AiSkeletonText;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2024
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 AiSkeletonPlaceholder from './AiSkeletonPlaceholder';
8
+ import AiSkeletonIcon from './AiSkeletonIcon';
9
+ import AiSkeletonText from './AiSkeletonText';
10
+ export { AiSkeletonText, AiSkeletonIcon, AiSkeletonPlaceholder };
@@ -31,12 +31,14 @@ const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function Ch
31
31
  isQuickAction,
32
32
  isSelected,
33
33
  kind,
34
+ renderIcon,
34
35
  size,
35
36
  ...other
36
37
  } = _ref;
37
38
  const prefix = usePrefix.usePrefix();
38
39
  const classNames = cx__default["default"](className, {
39
40
  [`${prefix}--chat-btn`]: true,
41
+ [`${prefix}--chat-btn--with-icon`]: renderIcon,
40
42
  [`${prefix}--chat-btn--quick-action`]: isQuickAction,
41
43
  [`${prefix}--chat-btn--quick-action--selected`]: isSelected
42
44
  });
@@ -53,7 +55,8 @@ const ChatButton = /*#__PURE__*/React__default["default"].forwardRef(function Ch
53
55
  className: classNames,
54
56
  kind: kind,
55
57
  ref: ref,
56
- size: size
58
+ size: size,
59
+ renderIcon: renderIcon
57
60
  }, other), children);
58
61
  });
59
62
  ChatButton.propTypes = {
@@ -81,6 +84,11 @@ ChatButton.propTypes = {
81
84
  * Specify the kind of `ChatButton` you want to create
82
85
  */
83
86
  kind: PropTypes__default["default"].oneOf(['primary', 'secondary', 'danger', 'ghost', 'tertiary']),
87
+ /**
88
+ * Optional prop to specify an icon to be rendered.
89
+ * Can be a React component class
90
+ */
91
+ renderIcon: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object]),
84
92
  /**
85
93
  * Specify the size of the `ChatButton`, from the following list of sizes:
86
94
  */
@@ -47,9 +47,8 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
47
47
  const contentClass = cx__default["default"]({
48
48
  [`${prefix}--modal-content`]: true,
49
49
  [`${prefix}--modal-content--with-form`]: hasForm,
50
- [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
51
- customClassName
52
- });
50
+ [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable
51
+ }, customClassName);
53
52
  useIsomorphicEffect["default"](() => {
54
53
  if (contentRef.current) {
55
54
  setIsScrollable(contentRef.current.scrollHeight > contentRef.current.clientHeight);
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.51.0-rc.0",
4
+ "version": "1.51.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -51,7 +51,7 @@
51
51
  "@carbon/feature-flags": "^0.16.0",
52
52
  "@carbon/icons-react": "^11.36.0",
53
53
  "@carbon/layout": "^11.20.0",
54
- "@carbon/styles": "^1.51.0-rc.0",
54
+ "@carbon/styles": "^1.51.1",
55
55
  "@ibm/telemetry-js": "^1.2.0",
56
56
  "classnames": "2.5.1",
57
57
  "copy-to-clipboard": "^3.3.1",
@@ -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.32.0-rc.0",
82
+ "@carbon/themes": "^11.32.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": "c70f968d388bbf968269066402a741327b00ac1c"
142
+ "gitHead": "de5bf0cfcece9d4294a6f4569319a219cb6201fa"
143
143
  }
@@ -0,0 +1,9 @@
1
+ // Code generated by @carbon/react. DO NOT EDIT.
2
+ //
3
+ // Copyright IBM Corp. 2018, 2023
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+
9
+ @forward '@carbon/styles/scss/components/skeleton-styles/ai-skeleton-styles';