@carbon/react 1.31.3 → 1.32.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.
- package/README.md +1 -1
- package/es/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/es/components/Accordion/Accordion.Skeleton.js +3 -3
- package/es/components/Accordion/Accordion.d.ts +65 -0
- package/es/components/Accordion/Accordion.js +5 -6
- package/es/components/Accordion/AccordionItem.d.ts +105 -0
- package/es/components/Accordion/AccordionItem.js +12 -9
- package/es/components/Accordion/AccordionProvider.d.ts +20 -0
- package/es/components/Accordion/AccordionProvider.js +25 -0
- package/es/components/Accordion/index.d.ts +11 -0
- package/es/components/Button/Button.Skeleton.d.ts +28 -0
- package/es/components/Button/Button.Skeleton.js +5 -3
- package/es/components/Button/Button.d.ts +72 -0
- package/es/components/Button/Button.js +13 -10
- package/es/components/Button/index.d.ts +11 -0
- package/es/components/Button/index.js +2 -1
- package/es/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/es/components/ButtonSet/ButtonSet.js +1 -2
- package/es/components/ButtonSet/index.d.ts +9 -0
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +1 -0
- package/es/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/es/components/ComposedModal/ComposedModal.js +58 -67
- package/es/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/es/components/ComposedModal/ModalFooter.js +22 -19
- package/es/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/es/components/ComposedModal/ModalHeader.js +8 -25
- package/es/components/ComposedModal/index.d.ts +9 -0
- package/es/components/ContainedList/ContainedList.js +12 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/es/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/es/components/DangerButton/DangerButton.d.ts +9 -0
- package/es/components/DangerButton/DangerButton.js +2 -2
- package/es/components/DangerButton/index.d.ts +9 -0
- package/es/components/DataTable/TableBatchAction.js +1 -0
- package/es/components/DataTable/TableBatchActions.js +1 -0
- package/es/components/DataTable/TableBody.d.ts +29 -0
- package/es/components/DataTable/TableBody.js +2 -3
- package/es/components/DataTable/TableContainer.d.ts +51 -0
- package/es/components/DataTable/TableContainer.js +3 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/es/components/DataTable/TableExpandHeader.js +4 -5
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/es/components/Dropdown/Dropdown.js +1 -0
- package/es/components/FluidTextInput/FluidTextInput.js +1 -0
- package/es/components/FormGroup/FormGroup.d.ts +80 -0
- package/es/components/IconButton/index.js +3 -2
- package/es/components/Layout/index.d.ts +74 -0
- package/es/components/Layout/index.js +14 -5
- package/es/components/Link/Link.d.ts +2 -2
- package/es/components/Link/Link.js +2 -1
- package/es/components/MenuButton/index.js +1 -0
- package/es/components/Modal/Modal.js +1 -0
- package/es/components/ModalWrapper/ModalWrapper.js +1 -0
- package/es/components/Notification/Notification.d.ts +531 -0
- package/es/components/Notification/Notification.js +40 -6
- package/es/components/Notification/index.d.ts +7 -0
- package/es/components/PrimaryButton/PrimaryButton.js +1 -0
- package/es/components/SecondaryButton/SecondaryButton.js +1 -0
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/es/components/SkeletonText/SkeletonText.js +15 -17
- package/es/components/SkeletonText/index.d.ts +9 -0
- package/es/components/Switch/Switch.d.ts +56 -0
- package/es/components/Switch/Switch.js +4 -4
- package/es/components/Tab/index.d.ts +9 -0
- package/es/components/TabContent/TabContent.d.ts +40 -0
- package/es/components/TabContent/TabContent.js +6 -12
- package/es/components/TabContent/index.d.ts +10 -0
- package/es/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/es/components/Tabs/Tabs.Skeleton.js +2 -2
- package/es/components/Tabs/Tabs.d.ts +311 -0
- package/es/components/Tabs/Tabs.js +151 -97
- package/es/components/Tabs/index.d.ts +10 -0
- package/es/components/Tabs/usePressable.js +11 -0
- package/es/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/es/components/TextInput/ControlledPasswordInput.js +5 -6
- package/es/components/Tile/Tile.d.ts +153 -0
- package/es/components/Tile/Tile.js +62 -74
- package/es/components/Tile/index.d.ts +7 -0
- package/es/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/es/components/Toggle/Toggle.Skeleton.js +24 -64
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/UIShell/HeaderGlobalAction.js +1 -0
- package/es/components/UIShell/HeaderPanel.js +61 -5
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/Switcher.js +45 -5
- package/es/components/UIShell/SwitcherItem.js +45 -6
- package/es/index.js +16 -16
- package/es/internal/keyboard/match.js +2 -2
- package/es/internal/useControllableState.js +2 -2
- package/es/internal/useMatchMedia.js +44 -0
- package/es/internal/wrapFocus.js +6 -6
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/es/prop-types/types.js +3 -0
- package/lib/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/lib/components/Accordion/Accordion.Skeleton.js +3 -3
- package/lib/components/Accordion/Accordion.d.ts +65 -0
- package/lib/components/Accordion/Accordion.js +5 -6
- package/lib/components/Accordion/AccordionItem.d.ts +105 -0
- package/lib/components/Accordion/AccordionItem.js +11 -8
- package/lib/components/Accordion/AccordionProvider.d.ts +20 -0
- package/lib/components/Accordion/AccordionProvider.js +34 -0
- package/lib/components/Accordion/index.d.ts +11 -0
- package/lib/components/Button/Button.Skeleton.d.ts +28 -0
- package/lib/components/Button/Button.Skeleton.js +5 -3
- package/lib/components/Button/Button.d.ts +72 -0
- package/lib/components/Button/Button.js +18 -11
- package/lib/components/Button/index.d.ts +11 -0
- package/lib/components/Button/index.js +6 -0
- package/lib/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/lib/components/ButtonSet/ButtonSet.js +1 -2
- package/lib/components/ButtonSet/index.d.ts +9 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/lib/components/ComposedModal/ComposedModal.js +58 -67
- package/lib/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/lib/components/ComposedModal/ModalFooter.js +22 -19
- package/lib/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/lib/components/ComposedModal/ModalHeader.js +8 -25
- package/lib/components/ComposedModal/index.d.ts +9 -0
- package/lib/components/ContainedList/ContainedList.js +12 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/lib/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/lib/components/DangerButton/DangerButton.d.ts +9 -0
- package/lib/components/DangerButton/DangerButton.js +2 -2
- package/lib/components/DangerButton/index.d.ts +9 -0
- package/lib/components/DataTable/TableBatchAction.js +1 -0
- package/lib/components/DataTable/TableBatchActions.js +1 -0
- package/lib/components/DataTable/TableBody.d.ts +29 -0
- package/lib/components/DataTable/TableBody.js +3 -4
- package/lib/components/DataTable/TableContainer.d.ts +51 -0
- package/lib/components/DataTable/TableContainer.js +3 -4
- package/lib/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/lib/components/DataTable/TableExpandHeader.js +4 -5
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/lib/components/Dropdown/Dropdown.js +1 -0
- package/lib/components/FluidTextInput/FluidTextInput.js +1 -0
- package/lib/components/FormGroup/FormGroup.d.ts +80 -0
- package/lib/components/IconButton/index.js +3 -2
- package/lib/components/Layout/index.d.ts +74 -0
- package/lib/components/Layout/index.js +14 -5
- package/lib/components/Link/Link.d.ts +2 -2
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/MenuButton/index.js +1 -0
- package/lib/components/Modal/Modal.js +1 -0
- package/lib/components/ModalWrapper/ModalWrapper.js +1 -0
- package/lib/components/Notification/Notification.d.ts +531 -0
- package/lib/components/Notification/Notification.js +40 -6
- package/lib/components/Notification/index.d.ts +7 -0
- package/lib/components/PrimaryButton/PrimaryButton.js +1 -0
- package/lib/components/SecondaryButton/SecondaryButton.js +1 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/lib/components/SkeletonText/SkeletonText.js +15 -17
- package/lib/components/SkeletonText/index.d.ts +9 -0
- package/lib/components/Switch/Switch.d.ts +56 -0
- package/lib/components/Switch/Switch.js +4 -4
- package/lib/components/Tab/index.d.ts +9 -0
- package/lib/components/TabContent/TabContent.d.ts +40 -0
- package/lib/components/TabContent/TabContent.js +6 -12
- package/lib/components/TabContent/index.d.ts +10 -0
- package/lib/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/lib/components/Tabs/Tabs.Skeleton.js +2 -2
- package/lib/components/Tabs/Tabs.d.ts +311 -0
- package/lib/components/Tabs/Tabs.js +150 -96
- package/lib/components/Tabs/index.d.ts +10 -0
- package/lib/components/Tabs/usePressable.js +11 -0
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +5 -6
- package/lib/components/Tile/Tile.d.ts +153 -0
- package/lib/components/Tile/Tile.js +62 -74
- package/lib/components/Tile/index.d.ts +7 -0
- package/lib/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/lib/components/Toggle/Toggle.Skeleton.js +22 -62
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/UIShell/HeaderGlobalAction.js +1 -0
- package/lib/components/UIShell/HeaderPanel.js +60 -4
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/Switcher.js +44 -4
- package/lib/components/UIShell/SwitcherItem.js +45 -6
- package/lib/index.js +51 -47
- package/lib/internal/keyboard/match.js +2 -2
- package/lib/internal/useControllableState.js +2 -2
- package/lib/internal/useMatchMedia.js +48 -0
- package/lib/internal/wrapFocus.js +6 -6
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/lib/prop-types/types.js +3 -0
- package/package.json +4 -3
|
@@ -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;
|
|
@@ -14,6 +14,7 @@ var cx = require('classnames');
|
|
|
14
14
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
15
15
|
var PropTypes = require('prop-types');
|
|
16
16
|
var React = require('react');
|
|
17
|
+
var AccordionProvider = require('./AccordionProvider.js');
|
|
17
18
|
|
|
18
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
20
|
|
|
@@ -39,13 +40,11 @@ function Accordion(_ref) {
|
|
|
39
40
|
[`${prefix}--layout--size-${size}`]: size,
|
|
40
41
|
[`${prefix}--accordion--flush`]: isFlush && align !== 'start'
|
|
41
42
|
});
|
|
42
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
43
|
+
return /*#__PURE__*/React__default["default"].createElement(AccordionProvider.AccordionProvider, {
|
|
44
|
+
disabled: disabled
|
|
45
|
+
}, /*#__PURE__*/React__default["default"].createElement("ul", _rollupPluginBabelHelpers["extends"]({
|
|
43
46
|
className: className
|
|
44
|
-
}, rest),
|
|
45
|
-
return /*#__PURE__*/React__default["default"].cloneElement(child, {
|
|
46
|
-
disabled
|
|
47
|
-
});
|
|
48
|
-
}) : children);
|
|
47
|
+
}, rest), children));
|
|
49
48
|
}
|
|
50
49
|
Accordion.propTypes = {
|
|
51
50
|
/**
|
|
@@ -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;
|
|
@@ -18,6 +18,7 @@ require('../Text/index.js');
|
|
|
18
18
|
var useId = require('../../internal/useId.js');
|
|
19
19
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
|
+
var AccordionProvider = require('./AccordionProvider.js');
|
|
21
22
|
var Text = require('../Text/Text.js');
|
|
22
23
|
var match = require('../../internal/keyboard/match.js');
|
|
23
24
|
var keys = require('../../internal/keyboard/keys.js');
|
|
@@ -34,21 +35,23 @@ const defaultRenderToggle = props => /*#__PURE__*/React__default["default"].crea
|
|
|
34
35
|
function AccordionItem(_ref) {
|
|
35
36
|
let {
|
|
36
37
|
children,
|
|
37
|
-
className: customClassName,
|
|
38
|
-
iconDescription,
|
|
39
|
-
// eslint-disable-line
|
|
38
|
+
className: customClassName = '',
|
|
40
39
|
open = false,
|
|
41
40
|
onHeadingClick,
|
|
42
41
|
renderExpando = defaultRenderToggle,
|
|
43
42
|
// remove renderExpando in next major release
|
|
44
43
|
renderToggle,
|
|
45
44
|
title = 'title',
|
|
46
|
-
disabled,
|
|
45
|
+
disabled: controlledDisabled,
|
|
46
|
+
handleAnimationEnd,
|
|
47
47
|
...rest
|
|
48
48
|
} = _ref;
|
|
49
49
|
const [isOpen, setIsOpen] = React.useState(open);
|
|
50
50
|
const [prevIsOpen, setPrevIsOpen] = React.useState(open);
|
|
51
51
|
const [animation, setAnimation] = React.useState('');
|
|
52
|
+
const accordionState = React.useContext(AccordionProvider.AccordionContext);
|
|
53
|
+
const disabledIsControlled = typeof controlledDisabled === 'boolean';
|
|
54
|
+
const disabled = disabledIsControlled ? controlledDisabled : accordionState.disabled;
|
|
52
55
|
const id = useId.useId('accordion-item');
|
|
53
56
|
const prefix = usePrefix.usePrefix();
|
|
54
57
|
const className = cx__default["default"]({
|
|
@@ -88,16 +91,16 @@ function AccordionItem(_ref) {
|
|
|
88
91
|
setIsOpen(false);
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
|
-
function
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
+
function onAnimationEnd(event) {
|
|
95
|
+
if (handleAnimationEnd) {
|
|
96
|
+
handleAnimationEnd(event);
|
|
94
97
|
}
|
|
95
98
|
setAnimation('');
|
|
96
99
|
}
|
|
97
100
|
return /*#__PURE__*/React__default["default"].createElement("li", _rollupPluginBabelHelpers["extends"]({
|
|
98
101
|
className: className
|
|
99
102
|
}, rest, {
|
|
100
|
-
onAnimationEnd:
|
|
103
|
+
onAnimationEnd: onAnimationEnd
|
|
101
104
|
}), /*#__PURE__*/React__default["default"].createElement(Toggle, {
|
|
102
105
|
disabled: disabled,
|
|
103
106
|
"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,34 @@
|
|
|
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
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var React = require('react');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
+
|
|
16
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
17
|
+
|
|
18
|
+
const AccordionContext = /*#__PURE__*/React.createContext({
|
|
19
|
+
disabled: false
|
|
20
|
+
});
|
|
21
|
+
const AccordionProvider = _ref => {
|
|
22
|
+
let {
|
|
23
|
+
disabled,
|
|
24
|
+
children
|
|
25
|
+
} = _ref;
|
|
26
|
+
return /*#__PURE__*/React__default["default"].createElement(AccordionContext.Provider, {
|
|
27
|
+
value: {
|
|
28
|
+
disabled
|
|
29
|
+
}
|
|
30
|
+
}, children);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
exports.AccordionContext = AccordionContext;
|
|
34
|
+
exports.AccordionProvider = 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 };
|
|
@@ -34,7 +34,7 @@ const ButtonSkeleton = _ref => {
|
|
|
34
34
|
[`${prefix}--skeleton`]: true,
|
|
35
35
|
[`${prefix}--btn`]: true,
|
|
36
36
|
[`${prefix}--btn--sm`]: small || size === 'sm',
|
|
37
|
-
[`${prefix}--btn--md`]: size === '
|
|
37
|
+
[`${prefix}--btn--md`]: size === 'md',
|
|
38
38
|
[`${prefix}--btn--lg`]: size === 'lg',
|
|
39
39
|
[`${prefix}--btn--xl`]: size === 'xl',
|
|
40
40
|
[`${prefix}--btn--2xl`]: size === '2xl'
|
|
@@ -67,11 +67,13 @@ ButtonSkeleton.propTypes = {
|
|
|
67
67
|
*/
|
|
68
68
|
size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg', 'xl', '2xl']),
|
|
69
69
|
/**
|
|
70
|
+
* @deprecated This property will be removed in the next major Carbon version,
|
|
71
|
+
* use size={sm} instead.
|
|
72
|
+
*
|
|
70
73
|
* Specify whether the Button should be a small variant
|
|
71
74
|
*/
|
|
72
75
|
small: PropTypes__default["default"].bool
|
|
73
76
|
};
|
|
74
|
-
var ButtonSkeleton$1 = ButtonSkeleton;
|
|
75
77
|
|
|
76
78
|
exports.ButtonSkeleton = ButtonSkeleton;
|
|
77
|
-
exports["default"] = ButtonSkeleton
|
|
79
|
+
exports["default"] = ButtonSkeleton;
|
|
@@ -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;
|
|
@@ -13,7 +13,6 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
|
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
15
|
var cx = require('classnames');
|
|
16
|
-
var types = require('../../prop-types/types.js');
|
|
17
16
|
var index = require('../IconButton/index.js');
|
|
18
17
|
var events = require('../../tools/events.js');
|
|
19
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
@@ -25,6 +24,10 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
25
24
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
26
25
|
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
27
26
|
|
|
27
|
+
const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
|
|
28
|
+
const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
29
|
+
const ButtonTooltipAlignments = ['start', 'center', 'end'];
|
|
30
|
+
const ButtonTooltipPositions = ['top', 'right', 'bottom', 'left'];
|
|
28
31
|
const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(_ref, ref) {
|
|
29
32
|
let {
|
|
30
33
|
as,
|
|
@@ -91,23 +94,24 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
91
94
|
const dangerButtonVariants = ['danger', 'danger--tertiary', 'danger--ghost'];
|
|
92
95
|
let component = 'button';
|
|
93
96
|
const assistiveId = useId.useId('danger-description');
|
|
97
|
+
const {
|
|
98
|
+
'aria-pressed': ariaPressed
|
|
99
|
+
} = rest;
|
|
94
100
|
let otherProps = {
|
|
95
101
|
disabled,
|
|
96
102
|
type,
|
|
97
|
-
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId :
|
|
98
|
-
'aria-pressed':
|
|
103
|
+
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : undefined,
|
|
104
|
+
'aria-pressed': ariaPressed ?? (hasIconOnly && kind === 'ghost' ? isSelected : undefined)
|
|
99
105
|
};
|
|
100
106
|
const anchorProps = {
|
|
101
107
|
href
|
|
102
108
|
};
|
|
103
|
-
let assistiveText;
|
|
109
|
+
let assistiveText = null;
|
|
104
110
|
if (dangerButtonVariants.includes(kind)) {
|
|
105
111
|
assistiveText = /*#__PURE__*/React__default["default"].createElement("span", {
|
|
106
112
|
id: assistiveId,
|
|
107
113
|
className: `${prefix}--visually-hidden`
|
|
108
114
|
}, dangerDescription);
|
|
109
|
-
} else {
|
|
110
|
-
assistiveText = null;
|
|
111
115
|
}
|
|
112
116
|
if (as) {
|
|
113
117
|
component = as;
|
|
@@ -130,7 +134,7 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
130
134
|
...otherProps
|
|
131
135
|
}, assistiveText, children, buttonImage);
|
|
132
136
|
if (hasIconOnly) {
|
|
133
|
-
let align;
|
|
137
|
+
let align = undefined;
|
|
134
138
|
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
135
139
|
if (tooltipAlignment === 'center') {
|
|
136
140
|
align = tooltipPosition;
|
|
@@ -199,7 +203,7 @@ Button.propTypes = {
|
|
|
199
203
|
if (props.renderIcon && !props.children && !props.iconDescription) {
|
|
200
204
|
return new Error('renderIcon property specified without also providing an iconDescription property.');
|
|
201
205
|
}
|
|
202
|
-
return
|
|
206
|
+
return null;
|
|
203
207
|
},
|
|
204
208
|
/**
|
|
205
209
|
* Specify whether the Button is expressive, or not
|
|
@@ -212,7 +216,7 @@ Button.propTypes = {
|
|
|
212
216
|
/**
|
|
213
217
|
* Specify the kind of Button you want to create
|
|
214
218
|
*/
|
|
215
|
-
kind: PropTypes__default["default"].oneOf(
|
|
219
|
+
kind: PropTypes__default["default"].oneOf(ButtonKinds),
|
|
216
220
|
/**
|
|
217
221
|
* Provide an optional function to be called when the button element
|
|
218
222
|
* loses focus
|
|
@@ -270,6 +274,9 @@ Button.propTypes = {
|
|
|
270
274
|
*/
|
|
271
275
|
type: PropTypes__default["default"].oneOf(['button', 'reset', 'submit'])
|
|
272
276
|
};
|
|
273
|
-
var Button$1 = Button;
|
|
274
277
|
|
|
275
|
-
exports
|
|
278
|
+
exports.ButtonKinds = ButtonKinds;
|
|
279
|
+
exports.ButtonSizes = ButtonSizes;
|
|
280
|
+
exports.ButtonTooltipAlignments = ButtonTooltipAlignments;
|
|
281
|
+
exports.ButtonTooltipPositions = ButtonTooltipPositions;
|
|
282
|
+
exports["default"] = Button;
|
|
@@ -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';
|
|
@@ -10,8 +10,14 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var Button = require('./Button.js');
|
|
13
|
+
var Button_Skeleton = require('./Button.Skeleton.js');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
exports.Button = Button["default"];
|
|
18
|
+
exports.ButtonKinds = Button.ButtonKinds;
|
|
19
|
+
exports.ButtonSizes = Button.ButtonSizes;
|
|
20
|
+
exports.ButtonTooltipAlignments = Button.ButtonTooltipAlignments;
|
|
21
|
+
exports.ButtonTooltipPositions = Button.ButtonTooltipPositions;
|
|
17
22
|
exports["default"] = Button["default"];
|
|
23
|
+
exports.ButtonSkeleton = Button_Skeleton["default"];
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -17,6 +17,7 @@ var useResizeObserver = require('use-resize-observer/polyfilled');
|
|
|
17
17
|
var iconsReact = require('@carbon/icons-react');
|
|
18
18
|
var Copy = require('../Copy/Copy.js');
|
|
19
19
|
var Button = require('../Button/Button.js');
|
|
20
|
+
require('../Button/Button.Skeleton.js');
|
|
20
21
|
var CopyButton = require('../CopyButton/CopyButton.js');
|
|
21
22
|
var uniqueId = require('../../tools/uniqueId.js');
|
|
22
23
|
var copy = require('copy-to-clipboard');
|
|
@@ -15,6 +15,7 @@ var PropTypes = require('prop-types');
|
|
|
15
15
|
var cx = require('classnames');
|
|
16
16
|
var iconsReact = require('@carbon/icons-react');
|
|
17
17
|
var Button = require('../Button/Button.js');
|
|
18
|
+
require('../Button/Button.Skeleton.js');
|
|
18
19
|
var index = require('../IconButton/index.js');
|
|
19
20
|
var Menu = require('../Menu/Menu.js');
|
|
20
21
|
var useAttachedMenu = require('../../internal/useAttachedMenu.js');
|