@carbon/react 1.31.3 → 1.32.0-rc.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.
Files changed (182) hide show
  1. package/README.md +1 -1
  2. package/es/components/Accordion/Accordion.Skeleton.d.ts +64 -0
  3. package/es/components/Accordion/Accordion.Skeleton.js +3 -3
  4. package/es/components/Accordion/Accordion.d.ts +65 -0
  5. package/es/components/Accordion/Accordion.js +5 -6
  6. package/es/components/Accordion/AccordionItem.d.ts +105 -0
  7. package/es/components/Accordion/AccordionItem.js +12 -9
  8. package/es/components/Accordion/AccordionProvider.d.ts +20 -0
  9. package/es/components/Accordion/AccordionProvider.js +25 -0
  10. package/es/components/Accordion/index.d.ts +11 -0
  11. package/es/components/Button/Button.Skeleton.d.ts +28 -0
  12. package/es/components/Button/Button.Skeleton.js +5 -3
  13. package/es/components/Button/Button.d.ts +72 -0
  14. package/es/components/Button/Button.js +13 -10
  15. package/es/components/Button/index.d.ts +11 -0
  16. package/es/components/Button/index.js +2 -1
  17. package/es/components/ButtonSet/ButtonSet.d.ts +17 -0
  18. package/es/components/ButtonSet/ButtonSet.js +1 -2
  19. package/es/components/ButtonSet/index.d.ts +9 -0
  20. package/es/components/CodeSnippet/CodeSnippet.js +1 -0
  21. package/es/components/ComboButton/index.js +1 -0
  22. package/es/components/ComposedModal/ComposedModal.d.ts +70 -0
  23. package/es/components/ComposedModal/ComposedModal.js +58 -67
  24. package/es/components/ComposedModal/ModalFooter.d.ts +71 -0
  25. package/es/components/ComposedModal/ModalFooter.js +22 -19
  26. package/es/components/ComposedModal/ModalHeader.d.ts +58 -0
  27. package/es/components/ComposedModal/ModalHeader.js +8 -25
  28. package/es/components/ComposedModal/index.d.ts +9 -0
  29. package/es/components/ContainedList/ContainedList.js +12 -1
  30. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
  31. package/es/components/ContentSwitcher/ContentSwitcher.js +14 -6
  32. package/es/components/DangerButton/DangerButton.d.ts +9 -0
  33. package/es/components/DangerButton/DangerButton.js +2 -2
  34. package/es/components/DangerButton/index.d.ts +9 -0
  35. package/es/components/DataTable/TableBatchAction.js +1 -0
  36. package/es/components/DataTable/TableBatchActions.js +1 -0
  37. package/es/components/DataTable/TableBody.d.ts +29 -0
  38. package/es/components/DataTable/TableBody.js +2 -3
  39. package/es/components/DataTable/TableContainer.d.ts +51 -0
  40. package/es/components/DataTable/TableContainer.js +3 -4
  41. package/es/components/DataTable/TableExpandHeader.d.ts +86 -0
  42. package/es/components/DataTable/TableExpandHeader.js +4 -5
  43. package/es/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
  44. package/es/components/Dropdown/Dropdown.js +1 -0
  45. package/es/components/FluidTextInput/FluidTextInput.js +1 -0
  46. package/es/components/FormGroup/FormGroup.d.ts +80 -0
  47. package/es/components/IconButton/index.js +3 -2
  48. package/es/components/Layout/index.d.ts +74 -0
  49. package/es/components/Layout/index.js +14 -5
  50. package/es/components/Link/Link.d.ts +2 -2
  51. package/es/components/Link/Link.js +2 -1
  52. package/es/components/MenuButton/index.js +1 -0
  53. package/es/components/Modal/Modal.js +1 -0
  54. package/es/components/ModalWrapper/ModalWrapper.js +1 -0
  55. package/es/components/Notification/Notification.d.ts +531 -0
  56. package/es/components/Notification/Notification.js +40 -6
  57. package/es/components/Notification/index.d.ts +7 -0
  58. package/es/components/PrimaryButton/PrimaryButton.js +1 -0
  59. package/es/components/SecondaryButton/SecondaryButton.js +1 -0
  60. package/es/components/Select/Select.d.ts +1 -1
  61. package/es/components/SkeletonText/SkeletonText.d.ts +61 -0
  62. package/es/components/SkeletonText/SkeletonText.js +15 -17
  63. package/es/components/SkeletonText/index.d.ts +9 -0
  64. package/es/components/Switch/Switch.d.ts +56 -0
  65. package/es/components/Switch/Switch.js +4 -4
  66. package/es/components/Tab/index.d.ts +9 -0
  67. package/es/components/TabContent/TabContent.d.ts +40 -0
  68. package/es/components/TabContent/TabContent.js +6 -12
  69. package/es/components/TabContent/index.d.ts +10 -0
  70. package/es/components/Tabs/Tabs.Skeleton.d.ts +33 -0
  71. package/es/components/Tabs/Tabs.Skeleton.js +2 -2
  72. package/es/components/Tabs/Tabs.d.ts +303 -0
  73. package/es/components/Tabs/Tabs.js +136 -95
  74. package/es/components/Tabs/index.d.ts +10 -0
  75. package/es/components/Tabs/usePressable.js +11 -0
  76. package/es/components/TextInput/ControlledPasswordInput.d.ts +90 -0
  77. package/es/components/TextInput/ControlledPasswordInput.js +5 -6
  78. package/es/components/Tile/Tile.d.ts +153 -0
  79. package/es/components/Tile/Tile.js +62 -74
  80. package/es/components/Tile/index.d.ts +7 -0
  81. package/es/components/Toggle/Toggle.Skeleton.d.ts +3 -47
  82. package/es/components/Toggle/Toggle.Skeleton.js +24 -64
  83. package/es/components/Toggle/Toggle.js +1 -1
  84. package/es/components/UIShell/HeaderGlobalAction.js +1 -0
  85. package/es/components/UIShell/SideNav.d.ts +1 -1
  86. package/es/index.js +16 -16
  87. package/es/internal/keyboard/match.js +2 -2
  88. package/es/internal/useControllableState.js +2 -2
  89. package/es/internal/wrapFocus.js +6 -6
  90. package/es/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
  91. package/es/prop-types/types.js +3 -0
  92. package/lib/components/Accordion/Accordion.Skeleton.d.ts +64 -0
  93. package/lib/components/Accordion/Accordion.Skeleton.js +3 -3
  94. package/lib/components/Accordion/Accordion.d.ts +65 -0
  95. package/lib/components/Accordion/Accordion.js +5 -6
  96. package/lib/components/Accordion/AccordionItem.d.ts +105 -0
  97. package/lib/components/Accordion/AccordionItem.js +11 -8
  98. package/lib/components/Accordion/AccordionProvider.d.ts +20 -0
  99. package/lib/components/Accordion/AccordionProvider.js +34 -0
  100. package/lib/components/Accordion/index.d.ts +11 -0
  101. package/lib/components/Button/Button.Skeleton.d.ts +28 -0
  102. package/lib/components/Button/Button.Skeleton.js +5 -3
  103. package/lib/components/Button/Button.d.ts +72 -0
  104. package/lib/components/Button/Button.js +18 -11
  105. package/lib/components/Button/index.d.ts +11 -0
  106. package/lib/components/Button/index.js +6 -0
  107. package/lib/components/ButtonSet/ButtonSet.d.ts +17 -0
  108. package/lib/components/ButtonSet/ButtonSet.js +1 -2
  109. package/lib/components/ButtonSet/index.d.ts +9 -0
  110. package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
  111. package/lib/components/ComboButton/index.js +1 -0
  112. package/lib/components/ComposedModal/ComposedModal.d.ts +70 -0
  113. package/lib/components/ComposedModal/ComposedModal.js +58 -67
  114. package/lib/components/ComposedModal/ModalFooter.d.ts +71 -0
  115. package/lib/components/ComposedModal/ModalFooter.js +22 -19
  116. package/lib/components/ComposedModal/ModalHeader.d.ts +58 -0
  117. package/lib/components/ComposedModal/ModalHeader.js +8 -25
  118. package/lib/components/ComposedModal/index.d.ts +9 -0
  119. package/lib/components/ContainedList/ContainedList.js +12 -1
  120. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
  121. package/lib/components/ContentSwitcher/ContentSwitcher.js +14 -6
  122. package/lib/components/DangerButton/DangerButton.d.ts +9 -0
  123. package/lib/components/DangerButton/DangerButton.js +2 -2
  124. package/lib/components/DangerButton/index.d.ts +9 -0
  125. package/lib/components/DataTable/TableBatchAction.js +1 -0
  126. package/lib/components/DataTable/TableBatchActions.js +1 -0
  127. package/lib/components/DataTable/TableBody.d.ts +29 -0
  128. package/lib/components/DataTable/TableBody.js +3 -4
  129. package/lib/components/DataTable/TableContainer.d.ts +51 -0
  130. package/lib/components/DataTable/TableContainer.js +3 -4
  131. package/lib/components/DataTable/TableExpandHeader.d.ts +86 -0
  132. package/lib/components/DataTable/TableExpandHeader.js +4 -5
  133. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
  134. package/lib/components/Dropdown/Dropdown.js +1 -0
  135. package/lib/components/FluidTextInput/FluidTextInput.js +1 -0
  136. package/lib/components/FormGroup/FormGroup.d.ts +80 -0
  137. package/lib/components/IconButton/index.js +3 -2
  138. package/lib/components/Layout/index.d.ts +74 -0
  139. package/lib/components/Layout/index.js +14 -5
  140. package/lib/components/Link/Link.d.ts +2 -2
  141. package/lib/components/Link/Link.js +2 -1
  142. package/lib/components/MenuButton/index.js +1 -0
  143. package/lib/components/Modal/Modal.js +1 -0
  144. package/lib/components/ModalWrapper/ModalWrapper.js +1 -0
  145. package/lib/components/Notification/Notification.d.ts +531 -0
  146. package/lib/components/Notification/Notification.js +40 -6
  147. package/lib/components/Notification/index.d.ts +7 -0
  148. package/lib/components/PrimaryButton/PrimaryButton.js +1 -0
  149. package/lib/components/SecondaryButton/SecondaryButton.js +1 -0
  150. package/lib/components/Select/Select.d.ts +1 -1
  151. package/lib/components/SkeletonText/SkeletonText.d.ts +61 -0
  152. package/lib/components/SkeletonText/SkeletonText.js +15 -17
  153. package/lib/components/SkeletonText/index.d.ts +9 -0
  154. package/lib/components/Switch/Switch.d.ts +56 -0
  155. package/lib/components/Switch/Switch.js +4 -4
  156. package/lib/components/Tab/index.d.ts +9 -0
  157. package/lib/components/TabContent/TabContent.d.ts +40 -0
  158. package/lib/components/TabContent/TabContent.js +6 -12
  159. package/lib/components/TabContent/index.d.ts +10 -0
  160. package/lib/components/Tabs/Tabs.Skeleton.d.ts +33 -0
  161. package/lib/components/Tabs/Tabs.Skeleton.js +2 -2
  162. package/lib/components/Tabs/Tabs.d.ts +303 -0
  163. package/lib/components/Tabs/Tabs.js +135 -94
  164. package/lib/components/Tabs/index.d.ts +10 -0
  165. package/lib/components/Tabs/usePressable.js +11 -0
  166. package/lib/components/TextInput/ControlledPasswordInput.d.ts +90 -0
  167. package/lib/components/TextInput/ControlledPasswordInput.js +5 -6
  168. package/lib/components/Tile/Tile.d.ts +153 -0
  169. package/lib/components/Tile/Tile.js +62 -74
  170. package/lib/components/Tile/index.d.ts +7 -0
  171. package/lib/components/Toggle/Toggle.Skeleton.d.ts +3 -47
  172. package/lib/components/Toggle/Toggle.Skeleton.js +22 -62
  173. package/lib/components/Toggle/Toggle.js +1 -1
  174. package/lib/components/UIShell/HeaderGlobalAction.js +1 -0
  175. package/lib/components/UIShell/SideNav.d.ts +1 -1
  176. package/lib/index.js +51 -47
  177. package/lib/internal/keyboard/match.js +2 -2
  178. package/lib/internal/useControllableState.js +2 -2
  179. package/lib/internal/wrapFocus.js +6 -6
  180. package/lib/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
  181. package/lib/prop-types/types.js +3 -0
  182. package/package.json +4 -3
package/README.md CHANGED
@@ -58,7 +58,7 @@ styles from the project or include the styles for a specific component:
58
58
  // Bring in all the styles for Carbon
59
59
  @use '@carbon/react';
60
60
 
61
- // Preferred: bring in the styles for one component
61
+ // Or bring in the styles for just one component
62
62
  @use '@carbon/react/scss/components/button';
63
63
  ```
64
64
 
@@ -0,0 +1,64 @@
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
+ /// <reference types="react" />
8
+ import PropTypes from 'prop-types';
9
+ interface AccordionSkeletonProps {
10
+ /**
11
+ * Specify the alignment of the accordion heading
12
+ * title and chevron.
13
+ */
14
+ align?: 'start' | 'end';
15
+ /**
16
+ * Specify an optional className to add.
17
+ */
18
+ className?: string;
19
+ /**
20
+ * Set number of items to render.
21
+ */
22
+ count?: number;
23
+ /**
24
+ * Specify whether an individual AccordionItem should
25
+ * be flush, default is false.
26
+ */
27
+ isFlush?: boolean;
28
+ /**
29
+ * `false` to not display the first item opened.
30
+ */
31
+ open?: boolean;
32
+ }
33
+ declare function AccordionSkeleton({ align, className, count, isFlush, open, ...rest }: AccordionSkeletonProps): JSX.Element;
34
+ declare namespace AccordionSkeleton {
35
+ var propTypes: {
36
+ /**
37
+ * Specify the alignment of the accordion heading title and chevron.
38
+ */
39
+ align: PropTypes.Requireable<string>;
40
+ /**
41
+ * Specify an optional className to add.
42
+ */
43
+ className: PropTypes.Requireable<string>;
44
+ /**
45
+ * Set number of items to render
46
+ */
47
+ count: PropTypes.Requireable<number>;
48
+ /**
49
+ * Specify whether an individual AccordionItem should be flush, default is false
50
+ */
51
+ isFlush: PropTypes.Requireable<boolean>;
52
+ /**
53
+ * `false` to not display the first item opened
54
+ */
55
+ open: PropTypes.Requireable<boolean>;
56
+ };
57
+ var defaultProps: {
58
+ open: boolean;
59
+ count: number;
60
+ align: string;
61
+ };
62
+ }
63
+ export default AccordionSkeleton;
64
+ export { AccordionSkeleton };
@@ -16,11 +16,11 @@ import { usePrefix } from '../../internal/usePrefix.js';
16
16
  var _SkeletonText, _SkeletonText2, _SkeletonText3;
17
17
  function AccordionSkeleton(_ref) {
18
18
  let {
19
- align,
19
+ align = 'end',
20
20
  className,
21
- count,
21
+ count = 4,
22
22
  isFlush,
23
- open,
23
+ open = true,
24
24
  ...rest
25
25
  } = _ref;
26
26
  const prefix = usePrefix();
@@ -0,0 +1,65 @@
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 { PropsWithChildren } from 'react';
9
+ interface AccordionProps {
10
+ /**
11
+ * Specify the alignment of the accordion heading
12
+ * title and chevron. Defaults to `end`.
13
+ */
14
+ align?: 'start' | 'end';
15
+ /**
16
+ * Specify an optional className to be applied to
17
+ * the container node.
18
+ */
19
+ className?: string;
20
+ /**
21
+ * Specify whether an individual AccordionItem
22
+ * should be disabled.
23
+ */
24
+ disabled?: boolean;
25
+ /**
26
+ * Specify whether Accordion text should be flush,
27
+ * default is `false`, does not work with `align="start"`.
28
+ */
29
+ isFlush?: boolean;
30
+ /**
31
+ * Specify the size of the Accordion. Currently
32
+ * supports the following: `sm`, `md`, `lg`
33
+ */
34
+ size?: 'sm' | 'md' | 'lg';
35
+ }
36
+ declare function Accordion({ align, children, className: customClassName, disabled, isFlush, size, ...rest }: PropsWithChildren<AccordionProps>): JSX.Element;
37
+ declare namespace Accordion {
38
+ var propTypes: {
39
+ /**
40
+ * Specify the alignment of the accordion heading title and chevron.
41
+ */
42
+ align: PropTypes.Requireable<string>;
43
+ /**
44
+ * Pass in the children that will be rendered within the Accordion
45
+ */
46
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
47
+ /**
48
+ * Specify an optional className to be applied to the container node
49
+ */
50
+ className: PropTypes.Requireable<string>;
51
+ /**
52
+ * Specify whether an individual AccordionItem should be disabled
53
+ */
54
+ disabled: PropTypes.Requireable<boolean>;
55
+ /**
56
+ * Specify whether Accordion text should be flush, default is false, does not work with align="start"
57
+ */
58
+ isFlush: PropTypes.Requireable<boolean>;
59
+ /**
60
+ * Specify the size of the Accordion. Currently supports the following:
61
+ */
62
+ size: PropTypes.Requireable<string>;
63
+ };
64
+ }
65
+ export default Accordion;
@@ -10,6 +10,7 @@ import cx from 'classnames';
10
10
  import { usePrefix } from '../../internal/usePrefix.js';
11
11
  import PropTypes from 'prop-types';
12
12
  import React__default from 'react';
13
+ import { AccordionProvider } from './AccordionProvider.js';
13
14
 
14
15
  function Accordion(_ref) {
15
16
  let {
@@ -29,13 +30,11 @@ function Accordion(_ref) {
29
30
  [`${prefix}--layout--size-${size}`]: size,
30
31
  [`${prefix}--accordion--flush`]: isFlush && align !== 'start'
31
32
  });
32
- return /*#__PURE__*/React__default.createElement("ul", _extends({
33
+ return /*#__PURE__*/React__default.createElement(AccordionProvider, {
34
+ disabled: disabled
35
+ }, /*#__PURE__*/React__default.createElement("ul", _extends({
33
36
  className: className
34
- }, rest), disabled ? React__default.Children.toArray(children).map(child => {
35
- return /*#__PURE__*/React__default.cloneElement(child, {
36
- disabled
37
- });
38
- }) : children);
37
+ }, rest), children));
39
38
  }
40
39
  Accordion.propTypes = {
41
40
  /**
@@ -0,0 +1,105 @@
1
+ import PropTypes from 'prop-types';
2
+ import { AnimationEventHandler, AriaAttributes, KeyboardEvent, MouseEventHandler, PropsWithChildren, ReactElement, ReactNode } from 'react';
3
+ interface AccordionItemProps {
4
+ /**
5
+ * Specify an optional className to be
6
+ * applied to the container node.
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Specify whether an individual `AccordionItem` should
11
+ * be disabled (overrides the parent accordion state). If undefined,
12
+ * this value will be managed by the parent Accordion.
13
+ */
14
+ disabled?: boolean;
15
+ /**
16
+ * The handler of the massaged `click` event.
17
+ */
18
+ onClick?: MouseEventHandler<HTMLLIElement>;
19
+ /**
20
+ * The handler of the massaged `click` event on
21
+ * the heading.
22
+ */
23
+ onHeadingClick?: ({ isOpen, event, }: {
24
+ isOpen: boolean;
25
+ event: Parameters<MouseEventHandler<HTMLButtonElement>>[0];
26
+ }) => void;
27
+ /**
28
+ * `true` to open the expand.
29
+ */
30
+ open?: boolean;
31
+ /**
32
+ * @deprecated This prop has been deprecated and will be
33
+ * removed in the next major release of Carbon. Use the
34
+ * `renderToggle` prop instead.
35
+ */
36
+ renderExpando?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement;
37
+ /**
38
+ * The callback function to render the expand button.
39
+ * Can be a React component class.
40
+ */
41
+ renderToggle?: (props: PropsWithChildren<AccordionToggleProps>) => ReactElement;
42
+ /**
43
+ * The accordion title.
44
+ */
45
+ title?: ReactNode;
46
+ /**
47
+ * The callback function to run on the `onAnimationEnd`
48
+ * event for the list item.
49
+ */
50
+ handleAnimationEnd?: AnimationEventHandler<HTMLLIElement>;
51
+ }
52
+ interface AccordionToggleProps {
53
+ 'aria-controls'?: AriaAttributes['aria-controls'];
54
+ 'aria-expanded'?: AriaAttributes['aria-expanded'];
55
+ className?: string;
56
+ disabled?: boolean;
57
+ onClick?: MouseEventHandler<HTMLButtonElement>;
58
+ onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void;
59
+ type?: 'button';
60
+ }
61
+ declare function AccordionItem({ children, className: customClassName, open, onHeadingClick, renderExpando, // remove renderExpando in next major release
62
+ renderToggle, title, disabled: controlledDisabled, handleAnimationEnd, ...rest }: PropsWithChildren<AccordionItemProps>): JSX.Element;
63
+ declare namespace AccordionItem {
64
+ var propTypes: {
65
+ /**
66
+ * Provide the contents of your AccordionItem
67
+ */
68
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
69
+ /**
70
+ * Specify an optional className to be applied to the container node
71
+ */
72
+ className: PropTypes.Requireable<string>;
73
+ /**
74
+ * Specify whether an individual AccordionItem should be disabled
75
+ */
76
+ disabled: PropTypes.Requireable<boolean>;
77
+ /**
78
+ * The handler of the massaged `click` event.
79
+ */
80
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
81
+ /**
82
+ * The handler of the massaged `click` event on the heading.
83
+ */
84
+ onHeadingClick: PropTypes.Requireable<(...args: any[]) => any>;
85
+ /**
86
+ * `true` to open the expand.
87
+ */
88
+ open: PropTypes.Requireable<boolean>;
89
+ /**
90
+ * The callback function to render the expand button.
91
+ * Can be a React component class.
92
+ */
93
+ renderExpando: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
94
+ /**
95
+ * The callback function to render the expand button.
96
+ * Can be a React component class.
97
+ */
98
+ renderToggle: PropTypes.Requireable<(...args: any[]) => any>;
99
+ /**
100
+ * The accordion title.
101
+ */
102
+ title: PropTypes.Requireable<PropTypes.ReactNodeLike>;
103
+ };
104
+ }
105
+ export default AccordionItem;
@@ -9,11 +9,12 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { ChevronRight } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default, { useState } from 'react';
12
+ import React__default, { useState, useContext } from 'react';
13
13
  import '../Text/index.js';
14
14
  import { useId } from '../../internal/useId.js';
15
15
  import deprecate from '../../prop-types/deprecate.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
+ import { AccordionContext } from './AccordionProvider.js';
17
18
  import { Text } from '../Text/Text.js';
18
19
  import { match } from '../../internal/keyboard/match.js';
19
20
  import { Escape } from '../../internal/keyboard/keys.js';
@@ -24,21 +25,23 @@ const defaultRenderToggle = props => /*#__PURE__*/React__default.createElement("
24
25
  function AccordionItem(_ref) {
25
26
  let {
26
27
  children,
27
- className: customClassName,
28
- iconDescription,
29
- // eslint-disable-line
28
+ className: customClassName = '',
30
29
  open = false,
31
30
  onHeadingClick,
32
31
  renderExpando = defaultRenderToggle,
33
32
  // remove renderExpando in next major release
34
33
  renderToggle,
35
34
  title = 'title',
36
- disabled,
35
+ disabled: controlledDisabled,
36
+ handleAnimationEnd,
37
37
  ...rest
38
38
  } = _ref;
39
39
  const [isOpen, setIsOpen] = useState(open);
40
40
  const [prevIsOpen, setPrevIsOpen] = useState(open);
41
41
  const [animation, setAnimation] = useState('');
42
+ const accordionState = useContext(AccordionContext);
43
+ const disabledIsControlled = typeof controlledDisabled === 'boolean';
44
+ const disabled = disabledIsControlled ? controlledDisabled : accordionState.disabled;
42
45
  const id = useId('accordion-item');
43
46
  const prefix = usePrefix();
44
47
  const className = cx({
@@ -78,16 +81,16 @@ function AccordionItem(_ref) {
78
81
  setIsOpen(false);
79
82
  }
80
83
  }
81
- function handleAnimationEnd(event) {
82
- if (rest.handleAnimationEnd) {
83
- rest.handleAnimationEnd(event);
84
+ function onAnimationEnd(event) {
85
+ if (handleAnimationEnd) {
86
+ handleAnimationEnd(event);
84
87
  }
85
88
  setAnimation('');
86
89
  }
87
90
  return /*#__PURE__*/React__default.createElement("li", _extends({
88
91
  className: className
89
92
  }, rest, {
90
- onAnimationEnd: handleAnimationEnd
93
+ onAnimationEnd: onAnimationEnd
91
94
  }), /*#__PURE__*/React__default.createElement(Toggle, {
92
95
  disabled: disabled,
93
96
  "aria-controls": id,
@@ -0,0 +1,20 @@
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 React, { PropsWithChildren } from 'react';
8
+ type AccordionProviderProp = {
9
+ /**
10
+ * Global setting to disable all AccordionItems
11
+ * within the Accordion. Individual AccordionItems can be
12
+ * disabled by passing the `disabled` prop to the AccordionItem.
13
+ */
14
+ disabled: boolean;
15
+ };
16
+ export declare const AccordionContext: React.Context<{
17
+ disabled: boolean;
18
+ }>;
19
+ export declare const AccordionProvider: ({ disabled, children, }: PropsWithChildren<AccordionProviderProp>) => JSX.Element;
20
+ export {};
@@ -0,0 +1,25 @@
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
+
8
+ import React__default, { createContext } from 'react';
9
+
10
+ const AccordionContext = /*#__PURE__*/createContext({
11
+ disabled: false
12
+ });
13
+ const AccordionProvider = _ref => {
14
+ let {
15
+ disabled,
16
+ children
17
+ } = _ref;
18
+ return /*#__PURE__*/React__default.createElement(AccordionContext.Provider, {
19
+ value: {
20
+ disabled
21
+ }
22
+ }, children);
23
+ };
24
+
25
+ export { AccordionContext, AccordionProvider };
@@ -0,0 +1,11 @@
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 Accordion from './Accordion';
8
+ export default Accordion;
9
+ export { Accordion };
10
+ export { default as AccordionItem } from './AccordionItem';
11
+ export { default as AccordionSkeleton } from './Accordion.Skeleton';
@@ -0,0 +1,28 @@
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 React from 'react';
8
+ import { ButtonSize } from './Button';
9
+ export interface ButtonSkeletonProps extends React.HTMLAttributes<HTMLElement> {
10
+ /**
11
+ * Optionally specify an href for your Button to become an `<a>` element
12
+ */
13
+ href?: string;
14
+ /**
15
+ * Specify the size of the button, from a list of available sizes.
16
+ */
17
+ size?: ButtonSize;
18
+ /**
19
+ * @deprecated This property will be removed in the next major Carbon version,
20
+ * use size={sm} instead.
21
+ *
22
+ * Specify whether the Button should be a small variant
23
+ */
24
+ small?: boolean;
25
+ }
26
+ declare const ButtonSkeleton: React.FC<ButtonSkeletonProps>;
27
+ export default ButtonSkeleton;
28
+ export { ButtonSkeleton };
@@ -24,7 +24,7 @@ const ButtonSkeleton = _ref => {
24
24
  [`${prefix}--skeleton`]: true,
25
25
  [`${prefix}--btn`]: true,
26
26
  [`${prefix}--btn--sm`]: small || size === 'sm',
27
- [`${prefix}--btn--md`]: size === 'field' || size === 'md',
27
+ [`${prefix}--btn--md`]: size === 'md',
28
28
  [`${prefix}--btn--lg`]: size === 'lg',
29
29
  [`${prefix}--btn--xl`]: size === 'xl',
30
30
  [`${prefix}--btn--2xl`]: size === '2xl'
@@ -57,10 +57,12 @@ ButtonSkeleton.propTypes = {
57
57
  */
58
58
  size: PropTypes.oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
59
59
  /**
60
+ * @deprecated This property will be removed in the next major Carbon version,
61
+ * use size={sm} instead.
62
+ *
60
63
  * Specify whether the Button should be a small variant
61
64
  */
62
65
  small: PropTypes.bool
63
66
  };
64
- var ButtonSkeleton$1 = ButtonSkeleton;
65
67
 
66
- export { ButtonSkeleton, ButtonSkeleton$1 as default };
68
+ export { ButtonSkeleton, ButtonSkeleton as default };
@@ -0,0 +1,72 @@
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 React from 'react';
8
+ import { PolymorphicProps } from '../../types/common';
9
+ export declare const ButtonKinds: readonly ["primary", "secondary", "danger", "ghost", "danger--primary", "danger--ghost", "danger--tertiary", "tertiary"];
10
+ export type ButtonKind = (typeof ButtonKinds)[number];
11
+ export declare const ButtonSizes: readonly ["sm", "md", "lg", "xl", "2xl"];
12
+ export type ButtonSize = (typeof ButtonSizes)[number];
13
+ export declare const ButtonTooltipAlignments: readonly ["start", "center", "end"];
14
+ export type ButtonTooltipAlignment = (typeof ButtonTooltipAlignments)[number];
15
+ export declare const ButtonTooltipPositions: string[];
16
+ export type ButtonTooltipPosition = (typeof ButtonTooltipPositions)[number];
17
+ interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
18
+ /**
19
+ * Specify the message read by screen readers for the danger button variant
20
+ */
21
+ dangerDescription?: string;
22
+ /**
23
+ * Specify if the button is an icon-only button
24
+ */
25
+ hasIconOnly?: boolean;
26
+ /**
27
+ * Optionally specify an href for your Button to become an `<a>` element
28
+ */
29
+ href?: string;
30
+ /**
31
+ * If specifying the `renderIcon` prop, provide a description for that icon that can
32
+ * be read by screen readers
33
+ */
34
+ iconDescription?: string;
35
+ /**
36
+ * Specify whether the Button is expressive, or not
37
+ */
38
+ isExpressive?: boolean;
39
+ /**
40
+ * Specify whether the Button is currently selected. Only applies to the Ghost variant.
41
+ */
42
+ isSelected?: boolean;
43
+ /**
44
+ * Specify the kind of Button you want to create
45
+ */
46
+ kind?: ButtonKind;
47
+ /**
48
+ * Optional prop to allow overriding the icon rendering.
49
+ * Can be a React component class
50
+ */
51
+ renderIcon?: React.ElementType;
52
+ /**
53
+ * Specify the size of the button, from the following list of sizes:
54
+ */
55
+ size?: ButtonSize;
56
+ /**
57
+ * Specify the alignment of the tooltip to the icon-only button.
58
+ * Can be one of: start, center, or end.
59
+ */
60
+ tooltipAlignment?: ButtonTooltipAlignment;
61
+ /**
62
+ * Specify the direction of the tooltip for icon-only buttons.
63
+ * Can be either top, right, bottom, or left.
64
+ */
65
+ tooltipPosition?: ButtonTooltipPosition;
66
+ }
67
+ export type ButtonProps<T extends React.ElementType> = PolymorphicProps<T, ButtonBaseProps>;
68
+ export interface ButtonComponent {
69
+ <T extends React.ElementType>(props: ButtonProps<T>, context?: any): React.ReactElement<any, any> | null;
70
+ }
71
+ declare const _default: ButtonComponent;
72
+ export default _default;
@@ -9,12 +9,15 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import PropTypes from 'prop-types';
10
10
  import React__default, { useRef } from 'react';
11
11
  import cx from 'classnames';
12
- import { ButtonKinds } from '../../prop-types/types.js';
13
12
  import { IconButton } from '../IconButton/index.js';
14
13
  import { composeEventHandlers } from '../../tools/events.js';
15
14
  import { usePrefix } from '../../internal/usePrefix.js';
16
15
  import { useId } from '../../internal/useId.js';
17
16
 
17
+ const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
18
+ const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
19
+ const ButtonTooltipAlignments = ['start', 'center', 'end'];
20
+ const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
18
21
  const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref) {
19
22
  let {
20
23
  as,
@@ -81,23 +84,24 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
81
84
  const dangerButtonVariants = ['danger', 'danger--tertiary', 'danger--ghost'];
82
85
  let component = 'button';
83
86
  const assistiveId = useId('danger-description');
87
+ const {
88
+ 'aria-pressed': ariaPressed
89
+ } = rest;
84
90
  let otherProps = {
85
91
  disabled,
86
92
  type,
87
- 'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : null,
88
- 'aria-pressed': rest['aria-pressed'] ?? (hasIconOnly && kind === 'ghost' ? isSelected : null)
93
+ 'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : undefined,
94
+ 'aria-pressed': ariaPressed ?? (hasIconOnly && kind === 'ghost' ? isSelected : undefined)
89
95
  };
90
96
  const anchorProps = {
91
97
  href
92
98
  };
93
- let assistiveText;
99
+ let assistiveText = null;
94
100
  if (dangerButtonVariants.includes(kind)) {
95
101
  assistiveText = /*#__PURE__*/React__default.createElement("span", {
96
102
  id: assistiveId,
97
103
  className: `${prefix}--visually-hidden`
98
104
  }, dangerDescription);
99
- } else {
100
- assistiveText = null;
101
105
  }
102
106
  if (as) {
103
107
  component = as;
@@ -120,7 +124,7 @@ const Button = /*#__PURE__*/React__default.forwardRef(function Button(_ref, ref)
120
124
  ...otherProps
121
125
  }, assistiveText, children, buttonImage);
122
126
  if (hasIconOnly) {
123
- let align;
127
+ let align = undefined;
124
128
  if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
125
129
  if (tooltipAlignment === 'center') {
126
130
  align = tooltipPosition;
@@ -189,7 +193,7 @@ Button.propTypes = {
189
193
  if (props.renderIcon && !props.children && !props.iconDescription) {
190
194
  return new Error('renderIcon property specified without also providing an iconDescription property.');
191
195
  }
192
- return undefined;
196
+ return null;
193
197
  },
194
198
  /**
195
199
  * Specify whether the Button is expressive, or not
@@ -260,6 +264,5 @@ Button.propTypes = {
260
264
  */
261
265
  type: PropTypes.oneOf(['button', 'reset', 'submit'])
262
266
  };
263
- var Button$1 = Button;
264
267
 
265
- export { Button$1 as default };
268
+ export { ButtonKinds, ButtonSizes, ButtonTooltipAlignments, ButtonTooltipPositions, Button as default };
@@ -0,0 +1,11 @@
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 Button from './Button';
8
+ export default Button;
9
+ export { Button };
10
+ export * from './Button';
11
+ export { default as ButtonSkeleton } from './Button.Skeleton';
@@ -6,4 +6,5 @@
6
6
  */
7
7
 
8
8
  import Button from './Button.js';
9
- export { default as Button, default } from './Button.js';
9
+ export { default as Button, ButtonKinds, ButtonSizes, ButtonTooltipAlignments, ButtonTooltipPositions, default } from './Button.js';
10
+ export { default as ButtonSkeleton } from './Button.Skeleton.js';
@@ -0,0 +1,17 @@
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 React from 'react';
8
+ import { ForwardRefReturn } from '../../types/common';
9
+ export interface ButtonSetProps extends React.HTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify the button arrangement of the set (vertically stacked or
12
+ * horizontal)
13
+ */
14
+ stacked?: boolean;
15
+ }
16
+ declare const ButtonSet: ForwardRefReturn<HTMLDivElement, ButtonSetProps>;
17
+ export default ButtonSet;
@@ -43,6 +43,5 @@ ButtonSet.propTypes = {
43
43
  */
44
44
  stacked: PropTypes.bool
45
45
  };
46
- var ButtonSet$1 = ButtonSet;
47
46
 
48
- export { ButtonSet$1 as default };
47
+ export { ButtonSet as default };
@@ -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 ButtonSet from './ButtonSet';
8
+ export { ButtonSet };
9
+ export default ButtonSet;