@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.
- 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 +303 -0
- package/es/components/Tabs/Tabs.js +136 -95
- 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/SideNav.d.ts +1 -1
- package/es/index.js +16 -16
- package/es/internal/keyboard/match.js +2 -2
- package/es/internal/useControllableState.js +2 -2
- 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 +303 -0
- package/lib/components/Tabs/Tabs.js +135 -94
- 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/SideNav.d.ts +1 -1
- package/lib/index.js +51 -47
- package/lib/internal/keyboard/match.js +2 -2
- package/lib/internal/useControllableState.js +2 -2
- 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,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');
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React, { type MouseEvent, type KeyboardEvent, type HTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface ModalBodyProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
/** Specify the content to be placed in the ModalBody. */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/**
|
|
6
|
+
* Provide whether the modal content has a form element.
|
|
7
|
+
* If `true` is used here, non-form child content should have `bx--modal-content__regular-content` class.
|
|
8
|
+
*/
|
|
9
|
+
hasForm?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Specify whether the modal contains scrolling content
|
|
12
|
+
*/
|
|
13
|
+
hasScrollingContent?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const ModalBody: React.ForwardRefExoticComponent<ModalBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
16
|
+
export interface ComposedModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
17
|
+
/**
|
|
18
|
+
* Specify the aria-label for bx--modal-container
|
|
19
|
+
*/
|
|
20
|
+
'aria-label'?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Specify the aria-labelledby for bx--modal-container
|
|
23
|
+
*/
|
|
24
|
+
'aria-labelledby'?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Specify the content to be placed in the ComposedModal
|
|
27
|
+
*/
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* Specify an optional className to be applied to the modal root node
|
|
31
|
+
*/
|
|
32
|
+
className?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Specify an optional className to be applied to the modal node
|
|
35
|
+
*/
|
|
36
|
+
containerClassName?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Specify whether the primary button should be replaced with danger button.
|
|
39
|
+
* Note that this prop is not applied if you render primary/danger button by yourself
|
|
40
|
+
*/
|
|
41
|
+
danger?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Specify whether the Modal content should have any inner padding.
|
|
44
|
+
*/
|
|
45
|
+
isFullWidth?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Specify an optional handler for closing modal.
|
|
48
|
+
* Returning `false` here prevents closing modal.
|
|
49
|
+
*/
|
|
50
|
+
onClose?(event: MouseEvent): void | boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Called for all `onKeyDown` events that do not close the modal
|
|
53
|
+
*/
|
|
54
|
+
onKeyDown?(evt: KeyboardEvent): void;
|
|
55
|
+
/**
|
|
56
|
+
* Specify whether the Modal is currently open
|
|
57
|
+
*/
|
|
58
|
+
open?: boolean;
|
|
59
|
+
preventCloseOnClickOutside?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Specify a CSS selector that matches the DOM element that should be
|
|
62
|
+
* focused when the Modal opens
|
|
63
|
+
*/
|
|
64
|
+
selectorPrimaryFocus?: string;
|
|
65
|
+
/** Specify the CSS selectors that match the floating menus. */
|
|
66
|
+
selectorsFloatingMenus?: Array<string | null | undefined>;
|
|
67
|
+
size?: 'xs' | 'sm' | 'md' | 'lg';
|
|
68
|
+
}
|
|
69
|
+
declare const ComposedModal: React.ForwardRefExoticComponent<ComposedModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
70
|
+
export default ComposedModal;
|
|
@@ -11,6 +11,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var React = require('react');
|
|
14
|
+
var reactIs = require('react-is');
|
|
14
15
|
var PropTypes = require('prop-types');
|
|
15
16
|
var ModalHeader = require('./ModalHeader.js');
|
|
16
17
|
var ModalFooter = require('./ModalFooter.js');
|
|
@@ -19,6 +20,8 @@ var toggleClass = require('../../tools/toggleClass.js');
|
|
|
19
20
|
var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
|
|
20
21
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
21
22
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
23
|
+
var match = require('../../internal/keyboard/match.js');
|
|
24
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
22
25
|
|
|
23
26
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
24
27
|
|
|
@@ -35,12 +38,7 @@ const ModalBody = /*#__PURE__*/React__default["default"].forwardRef(function Mod
|
|
|
35
38
|
...rest
|
|
36
39
|
} = _ref;
|
|
37
40
|
const prefix = usePrefix.usePrefix();
|
|
38
|
-
const contentClass = cx__default["default"]({
|
|
39
|
-
[`${prefix}--modal-content`]: true,
|
|
40
|
-
[`${prefix}--modal-content--with-form`]: hasForm,
|
|
41
|
-
[`${prefix}--modal-scroll-content`]: hasScrollingContent,
|
|
42
|
-
[customClassName]: customClassName
|
|
43
|
-
});
|
|
41
|
+
const contentClass = cx__default["default"](`${prefix}--modal-content`, hasForm && `${prefix}--modal-content--with-form`, hasScrollingContent && `${prefix}--modal-scroll-content`, customClassName);
|
|
44
42
|
const hasScrollingContentProps = hasScrollingContent ? {
|
|
45
43
|
tabIndex: 0,
|
|
46
44
|
role: 'region'
|
|
@@ -57,6 +55,7 @@ ModalBody.propTypes = {
|
|
|
57
55
|
/**
|
|
58
56
|
* Required props for the accessibility label of the header
|
|
59
57
|
*/
|
|
58
|
+
// @ts-expect-error: Built-in prop-types > TS logic doesn't jive well with custom validators
|
|
60
59
|
['aria-label']: requiredIfGivenPropIsTruthy["default"]('hasScrollingContent', PropTypes__default["default"].string),
|
|
61
60
|
/**
|
|
62
61
|
* Specify the content to be placed in the ModalBody
|
|
@@ -95,28 +94,38 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
95
94
|
...rest
|
|
96
95
|
} = _ref2;
|
|
97
96
|
const prefix = usePrefix.usePrefix();
|
|
98
|
-
const [isOpen,
|
|
99
|
-
const [
|
|
100
|
-
const innerModal = React.useRef();
|
|
101
|
-
const button = React.useRef();
|
|
102
|
-
const startSentinel = React.useRef();
|
|
103
|
-
const endSentinel = React.useRef();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
const [isOpen, setIsOpen] = React.useState(!!open);
|
|
98
|
+
const [wasOpen, setWasOpen] = React.useState(!!open);
|
|
99
|
+
const innerModal = React.useRef(null);
|
|
100
|
+
const button = React.useRef(null);
|
|
101
|
+
const startSentinel = React.useRef(null);
|
|
102
|
+
const endSentinel = React.useRef(null);
|
|
103
|
+
|
|
104
|
+
// Kepp track of modal open/close state
|
|
105
|
+
// and propagate it to the document.body
|
|
106
|
+
React.useEffect(() => {
|
|
107
|
+
if (open !== wasOpen) {
|
|
108
|
+
setIsOpen(!!open);
|
|
109
|
+
setWasOpen(!!open);
|
|
110
|
+
toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, !!open);
|
|
111
|
+
}
|
|
112
|
+
}, [open, wasOpen, prefix]);
|
|
113
|
+
// Remove the document.body className on unmount
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
return () => {
|
|
116
|
+
toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, false);
|
|
117
|
+
};
|
|
118
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
119
|
+
|
|
108
120
|
function handleKeyDown(evt) {
|
|
109
|
-
|
|
110
|
-
if (evt.which === 27) {
|
|
121
|
+
if (match.match(evt, keys.Escape)) {
|
|
111
122
|
closeModal(evt);
|
|
112
123
|
}
|
|
113
|
-
onKeyDown(evt);
|
|
124
|
+
onKeyDown?.(evt);
|
|
114
125
|
}
|
|
115
126
|
function handleMousedown(evt) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
if (innerModal.current && !innerModal.current.contains(evt.target)) {
|
|
127
|
+
const isInside = innerModal.current?.contains(evt.target);
|
|
128
|
+
if (!isInside && !preventCloseOnClickOutside) {
|
|
120
129
|
closeModal(evt);
|
|
121
130
|
}
|
|
122
131
|
}
|
|
@@ -125,7 +134,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
125
134
|
target: oldActiveNode,
|
|
126
135
|
relatedTarget: currentActiveNode
|
|
127
136
|
} = _ref3;
|
|
128
|
-
if (open && currentActiveNode && oldActiveNode) {
|
|
137
|
+
if (open && currentActiveNode && oldActiveNode && innerModal.current) {
|
|
129
138
|
const {
|
|
130
139
|
current: bodyNode
|
|
131
140
|
} = innerModal;
|
|
@@ -137,62 +146,46 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
137
146
|
} = endSentinel;
|
|
138
147
|
wrapFocus["default"]({
|
|
139
148
|
bodyNode,
|
|
140
|
-
startSentinelNode,
|
|
141
|
-
endSentinelNode,
|
|
149
|
+
startTrapNode: startSentinelNode,
|
|
150
|
+
endTrapNode: endSentinelNode,
|
|
142
151
|
currentActiveNode,
|
|
143
152
|
oldActiveNode,
|
|
144
|
-
selectorsFloatingMenus
|
|
153
|
+
selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean)
|
|
145
154
|
});
|
|
146
155
|
}
|
|
147
156
|
}
|
|
148
157
|
function closeModal(evt) {
|
|
149
158
|
if (!onClose || onClose(evt) !== false) {
|
|
150
|
-
|
|
159
|
+
setIsOpen(false);
|
|
151
160
|
}
|
|
152
161
|
}
|
|
153
|
-
const modalClass = cx__default["default"]({
|
|
154
|
-
|
|
155
|
-
'is-visible': isOpen,
|
|
156
|
-
[customClassName]: customClassName,
|
|
157
|
-
[`${prefix}--modal--danger`]: danger
|
|
158
|
-
});
|
|
159
|
-
const containerClass = cx__default["default"]({
|
|
160
|
-
[`${prefix}--modal-container`]: true,
|
|
161
|
-
[`${prefix}--modal-container--${size}`]: size,
|
|
162
|
-
[`${prefix}--modal-container--full-width`]: isFullWidth,
|
|
163
|
-
[containerClassName]: containerClassName
|
|
164
|
-
});
|
|
162
|
+
const modalClass = cx__default["default"](`${prefix}--modal`, isOpen && 'is-visible', danger && `${prefix}--modal--danger`, customClassName);
|
|
163
|
+
const containerClass = cx__default["default"](`${prefix}--modal-container`, size && `${prefix}--modal-container--${size}`, isFullWidth && `${prefix}--modal-container--full-width`, containerClassName);
|
|
165
164
|
|
|
166
165
|
// Generate aria-label based on Modal Header label if one is not provided (L253)
|
|
167
166
|
let generatedAriaLabel;
|
|
168
167
|
const childrenWithProps = React__default["default"].Children.toArray(children).map(child => {
|
|
169
|
-
switch (
|
|
170
|
-
case React__default["default"].createElement(ModalHeader.ModalHeader).type:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
168
|
+
switch (true) {
|
|
169
|
+
case reactIs.isElement(child) && child.type === React__default["default"].createElement(ModalHeader.ModalHeader).type:
|
|
170
|
+
{
|
|
171
|
+
const el = child;
|
|
172
|
+
generatedAriaLabel = el.props.label;
|
|
173
|
+
return /*#__PURE__*/React__default["default"].cloneElement(el, {
|
|
174
|
+
closeModal
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
case reactIs.isElement(child) && child.type === React__default["default"].createElement(ModalFooter.ModalFooter).type:
|
|
178
|
+
{
|
|
179
|
+
const el = child;
|
|
180
|
+
return /*#__PURE__*/React__default["default"].cloneElement(el, {
|
|
181
|
+
closeModal,
|
|
182
|
+
inputref: button
|
|
183
|
+
});
|
|
184
|
+
}
|
|
180
185
|
default:
|
|
181
186
|
return child;
|
|
182
187
|
}
|
|
183
188
|
});
|
|
184
|
-
React.useEffect(() => {
|
|
185
|
-
if (prevOpen !== isOpen) {
|
|
186
|
-
toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, isOpen);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
React.useEffect(() => {
|
|
190
|
-
return () => toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, false);
|
|
191
|
-
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
192
|
-
|
|
193
|
-
React.useEffect(() => {
|
|
194
|
-
toggleClass["default"](document.body, `${prefix}--body--with-modal-open`, open);
|
|
195
|
-
}, [open, prefix]);
|
|
196
189
|
React.useEffect(() => {
|
|
197
190
|
const focusButton = focusContainerElement => {
|
|
198
191
|
if (focusContainerElement) {
|
|
@@ -267,7 +260,7 @@ ComposedModal.propTypes = {
|
|
|
267
260
|
*/
|
|
268
261
|
danger: PropTypes__default["default"].bool,
|
|
269
262
|
/**
|
|
270
|
-
* Specify whether
|
|
263
|
+
* Specify whether the Modal content should have any inner padding.
|
|
271
264
|
*/
|
|
272
265
|
isFullWidth: PropTypes__default["default"].bool,
|
|
273
266
|
/**
|
|
@@ -300,10 +293,8 @@ ComposedModal.propTypes = {
|
|
|
300
293
|
size: PropTypes__default["default"].oneOf(['xs', 'sm', 'md', 'lg'])
|
|
301
294
|
};
|
|
302
295
|
ComposedModal.defaultProps = {
|
|
303
|
-
onKeyDown: () => {},
|
|
304
296
|
selectorPrimaryFocus: '[data-modal-primary-focus]'
|
|
305
297
|
};
|
|
306
|
-
var ComposedModal$1 = ComposedModal;
|
|
307
298
|
|
|
308
299
|
exports.ModalBody = ModalBody;
|
|
309
|
-
exports["default"] = ComposedModal
|
|
300
|
+
exports["default"] = ComposedModal;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { type ReactNode, type MouseEvent, type Ref } from 'react';
|
|
2
|
+
interface SecondaryButtonProps {
|
|
3
|
+
buttonText: ReactNode;
|
|
4
|
+
onClick(evt: MouseEvent): void;
|
|
5
|
+
}
|
|
6
|
+
export interface SecondaryButtonSetProps {
|
|
7
|
+
closeModal(evt: MouseEvent): void;
|
|
8
|
+
onRequestClose(evt: MouseEvent): void;
|
|
9
|
+
secondaryButtonText?: string;
|
|
10
|
+
secondaryButtons?: [SecondaryButtonProps, SecondaryButtonProps];
|
|
11
|
+
secondaryClassName?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ModalFooterProps {
|
|
14
|
+
/**
|
|
15
|
+
* Pass in content that will be rendered in the Modal Footer
|
|
16
|
+
*/
|
|
17
|
+
children: ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Specify a custom className to be applied to the Modal Footer container
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Specify an optional function that is called whenever the modal is closed
|
|
24
|
+
*/
|
|
25
|
+
closeModal?(evt: MouseEvent): void;
|
|
26
|
+
/**
|
|
27
|
+
* Specify whether the primary button should be replaced with danger button.
|
|
28
|
+
* Note that this prop is not applied if you render primary/danger button by yourself
|
|
29
|
+
*/
|
|
30
|
+
danger?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The `ref` callback for the primary button.
|
|
33
|
+
*/
|
|
34
|
+
inputref?: Ref<HTMLButtonElement>;
|
|
35
|
+
/**
|
|
36
|
+
* Specify an optional function for when the modal is requesting to be
|
|
37
|
+
* closed
|
|
38
|
+
*/
|
|
39
|
+
onRequestClose?(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Specify an optional function for when the modal is requesting to be
|
|
42
|
+
* submitted
|
|
43
|
+
*/
|
|
44
|
+
onRequestSubmit?(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Specify whether the primary button should be disabled
|
|
47
|
+
*/
|
|
48
|
+
primaryButtonDisabled?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Specify the text for the primary button
|
|
51
|
+
*/
|
|
52
|
+
primaryButtonText?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Specify a custom className to be applied to the primary button
|
|
55
|
+
*/
|
|
56
|
+
primaryClassName?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Specify the text for the secondary button
|
|
59
|
+
*/
|
|
60
|
+
secondaryButtonText?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Specify an array of config objects for secondary buttons
|
|
63
|
+
*/
|
|
64
|
+
secondaryButtons?: [SecondaryButtonProps, SecondaryButtonProps];
|
|
65
|
+
/**
|
|
66
|
+
* Specify a custom className to be applied to the secondary button
|
|
67
|
+
*/
|
|
68
|
+
secondaryClassName?: string;
|
|
69
|
+
}
|
|
70
|
+
export declare const ModalFooter: React.ForwardRefExoticComponent<ModalFooterProps & React.RefAttributes<HTMLElement>>;
|
|
71
|
+
export {};
|