@carbon/react 1.53.1 → 1.54.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/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +981 -1068
- package/es/components/Button/Button.d.ts +1 -1
- package/es/components/Button/Button.js +13 -89
- package/es/components/Button/ButtonBase.d.ts +10 -0
- package/es/components/Button/ButtonBase.js +110 -0
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboBox/ComboBox.js +13 -4
- package/es/components/ComboButton/index.js +1 -1
- package/es/components/ComposedModal/ComposedModal.js +19 -10
- package/es/components/DataTable/DataTable.js +1 -1
- package/es/components/DataTable/TableBatchAction.d.ts +1 -1
- package/es/components/DataTable/TableToolbarMenu.d.ts +5 -1
- package/es/components/DataTable/TableToolbarMenu.js +7 -0
- package/es/components/DatePicker/DatePicker.d.ts +4 -0
- package/es/components/DatePicker/DatePicker.js +37 -0
- package/es/components/IconButton/index.d.ts +1 -1
- package/es/components/IconButton/index.js +3 -4
- package/es/components/ListBox/ListBox.d.ts +8 -0
- package/es/components/ListBox/ListBox.js +15 -3
- package/es/components/Loading/Loading.d.ts +1 -1
- package/es/components/Menu/Menu.js +2 -0
- package/es/components/Modal/Modal.js +14 -5
- package/es/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/es/components/Notification/Notification.js +18 -6
- package/es/components/Pagination/Pagination.Skeleton.d.ts +25 -0
- package/es/components/Pagination/Pagination.d.ts +102 -0
- package/es/components/Pagination/Pagination.js +13 -14
- package/es/components/Pagination/index.d.ts +10 -0
- package/es/components/Popover/index.d.ts +1 -1
- package/es/components/Popover/index.js +175 -108
- package/es/components/RadioTile/RadioTile.d.ts +55 -0
- package/es/components/RadioTile/RadioTile.js +17 -17
- package/es/components/RadioTile/index.d.ts +10 -0
- package/es/components/Slider/Slider.Skeleton.js +6 -2
- package/es/components/Slug/index.js +23 -2
- package/es/components/Stack/HStack.d.ts +10 -0
- package/es/components/Stack/HStack.js +23 -0
- package/es/components/Stack/Stack.d.ts +1 -1
- package/es/components/Stack/Stack.js +2 -2
- package/es/components/Stack/VStack.d.ts +10 -0
- package/es/components/Stack/{index.js → VStack.js} +1 -8
- package/es/components/Stack/index.d.ts +3 -6
- package/es/components/StructuredList/StructuredList.d.ts +8 -0
- package/es/components/StructuredList/StructuredList.js +28 -10
- package/es/components/TileGroup/TileGroup.js +30 -24
- package/es/components/Toggletip/index.d.ts +1 -18
- package/es/components/Toggletip/index.js +27 -4
- package/es/components/Tooltip/Tooltip.js +23 -5
- package/es/feature-flags.js +2 -1
- package/es/index.d.ts +1 -0
- package/es/index.js +5 -4
- package/es/internal/FloatingMenu.js +26 -5
- package/es/internal/environment.js +5 -1
- package/es/internal/keyboard/navigation.js +6 -2
- package/es/internal/useOutsideClick.js +31 -0
- package/es/internal/wrapFocus.js +51 -1
- package/es/tools/createPropAdapter.js +40 -0
- package/lib/components/Button/Button.d.ts +1 -1
- package/lib/components/Button/Button.js +13 -90
- package/lib/components/Button/ButtonBase.d.ts +10 -0
- package/lib/components/Button/ButtonBase.js +119 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboBox/ComboBox.js +13 -4
- package/lib/components/ComboButton/index.js +1 -1
- package/lib/components/ComposedModal/ComposedModal.js +17 -8
- package/lib/components/DataTable/DataTable.js +1 -1
- package/lib/components/DataTable/TableBatchAction.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarMenu.d.ts +5 -1
- package/lib/components/DataTable/TableToolbarMenu.js +7 -0
- package/lib/components/DatePicker/DatePicker.d.ts +4 -0
- package/lib/components/DatePicker/DatePicker.js +37 -0
- package/lib/components/IconButton/index.d.ts +1 -1
- package/lib/components/IconButton/index.js +3 -4
- package/lib/components/ListBox/ListBox.d.ts +8 -0
- package/lib/components/ListBox/ListBox.js +15 -3
- package/lib/components/Loading/Loading.d.ts +1 -1
- package/lib/components/Menu/Menu.js +2 -0
- package/lib/components/Modal/Modal.js +14 -5
- package/lib/components/ModalWrapper/ModalWrapper.d.ts +1 -1
- package/lib/components/Notification/Notification.js +15 -3
- package/lib/components/Pagination/Pagination.Skeleton.d.ts +25 -0
- package/lib/components/Pagination/Pagination.d.ts +102 -0
- package/lib/components/Pagination/Pagination.js +13 -14
- package/lib/components/Pagination/index.d.ts +10 -0
- package/lib/components/Popover/index.d.ts +1 -1
- package/lib/components/Popover/index.js +174 -107
- package/lib/components/RadioTile/RadioTile.d.ts +55 -0
- package/lib/components/RadioTile/RadioTile.js +17 -17
- package/lib/components/RadioTile/index.d.ts +10 -0
- package/lib/components/Slider/Slider.Skeleton.js +5 -1
- package/lib/components/Slug/index.js +23 -2
- package/lib/components/Stack/HStack.d.ts +10 -0
- package/lib/components/Stack/HStack.js +31 -0
- package/lib/components/Stack/Stack.d.ts +1 -1
- package/lib/components/Stack/Stack.js +3 -3
- package/lib/components/Stack/VStack.d.ts +10 -0
- package/lib/components/Stack/{index.js → VStack.js} +0 -8
- package/lib/components/Stack/index.d.ts +3 -6
- package/lib/components/StructuredList/StructuredList.d.ts +8 -0
- package/lib/components/StructuredList/StructuredList.js +27 -9
- package/lib/components/TileGroup/TileGroup.js +30 -24
- package/lib/components/Toggletip/index.d.ts +1 -18
- package/lib/components/Toggletip/index.js +27 -4
- package/lib/components/Tooltip/Tooltip.js +23 -5
- package/lib/feature-flags.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +15 -14
- package/lib/internal/FloatingMenu.js +44 -4
- package/lib/internal/environment.js +5 -1
- package/lib/internal/keyboard/navigation.js +6 -2
- package/lib/internal/useOutsideClick.js +35 -0
- package/lib/internal/wrapFocus.js +51 -0
- package/lib/tools/createPropAdapter.js +44 -0
- package/package.json +9 -7
|
@@ -12,17 +12,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
|
-
var cx = require('classnames');
|
|
16
15
|
var index = require('../IconButton/index.js');
|
|
17
16
|
var events = require('../../tools/events.js');
|
|
18
|
-
var
|
|
19
|
-
var useId = require('../../internal/useId.js');
|
|
17
|
+
var ButtonBase = require('./ButtonBase.js');
|
|
20
18
|
|
|
21
19
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
20
|
|
|
23
21
|
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
24
22
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
25
|
-
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
26
23
|
|
|
27
24
|
const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
|
|
28
25
|
const ButtonSizes = ['sm', 'md', 'lg', 'xl', '2xl'];
|
|
@@ -34,18 +31,13 @@ function isIconOnlyButton(hasIconOnly, _kind) {
|
|
|
34
31
|
}
|
|
35
32
|
return false;
|
|
36
33
|
}
|
|
37
|
-
const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(
|
|
38
|
-
|
|
34
|
+
const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button(props, ref) {
|
|
35
|
+
const tooltipRef = React.useRef(null);
|
|
36
|
+
const {
|
|
39
37
|
as,
|
|
40
38
|
children,
|
|
41
|
-
className,
|
|
42
|
-
dangerDescription = 'danger',
|
|
43
|
-
disabled = false,
|
|
44
39
|
hasIconOnly = false,
|
|
45
|
-
href,
|
|
46
40
|
iconDescription,
|
|
47
|
-
isExpressive = false,
|
|
48
|
-
isSelected,
|
|
49
41
|
kind = 'primary',
|
|
50
42
|
onBlur,
|
|
51
43
|
onClick,
|
|
@@ -54,92 +46,21 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
54
46
|
onMouseLeave,
|
|
55
47
|
renderIcon: ButtonImageElement,
|
|
56
48
|
size,
|
|
57
|
-
tabIndex,
|
|
58
49
|
tooltipAlignment = 'center',
|
|
59
50
|
tooltipPosition = 'top',
|
|
60
|
-
type = 'button',
|
|
61
51
|
...rest
|
|
62
|
-
} =
|
|
63
|
-
const tooltipRef = React.useRef(null);
|
|
64
|
-
const prefix = usePrefix.usePrefix();
|
|
52
|
+
} = props;
|
|
65
53
|
const handleClick = evt => {
|
|
66
54
|
// Prevent clicks on the tooltip from triggering the button click event
|
|
67
55
|
if (evt.target === tooltipRef.current) {
|
|
68
56
|
evt.preventDefault();
|
|
69
57
|
}
|
|
70
58
|
};
|
|
71
|
-
const buttonClasses = cx__default["default"](className, {
|
|
72
|
-
[`${prefix}--btn`]: true,
|
|
73
|
-
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
74
|
-
// TODO: V12 - Remove this class
|
|
75
|
-
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
76
|
-
// TODO: V12 - Remove this class
|
|
77
|
-
[`${prefix}--btn--xl`]: size === 'xl',
|
|
78
|
-
// TODO: V12 - Remove this class
|
|
79
|
-
[`${prefix}--btn--2xl`]: size === '2xl',
|
|
80
|
-
// TODO: V12 - Remove this class
|
|
81
|
-
[`${prefix}--layout--size-${size}`]: size,
|
|
82
|
-
[`${prefix}--btn--${kind}`]: kind,
|
|
83
|
-
[`${prefix}--btn--disabled`]: disabled,
|
|
84
|
-
[`${prefix}--btn--expressive`]: isExpressive,
|
|
85
|
-
[`${prefix}--btn--icon-only`]: hasIconOnly,
|
|
86
|
-
[`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost'
|
|
87
|
-
});
|
|
88
|
-
const commonProps = {
|
|
89
|
-
tabIndex,
|
|
90
|
-
className: buttonClasses,
|
|
91
|
-
ref
|
|
92
|
-
};
|
|
93
|
-
const buttonImage = !ButtonImageElement ? null : /*#__PURE__*/React__default["default"].createElement(ButtonImageElement, {
|
|
94
|
-
"aria-label": iconDescription,
|
|
95
|
-
className: `${prefix}--btn__icon`,
|
|
96
|
-
"aria-hidden": "true"
|
|
97
|
-
});
|
|
98
59
|
const iconOnlyImage = !ButtonImageElement ? null : /*#__PURE__*/React__default["default"].createElement(ButtonImageElement, null);
|
|
99
|
-
const dangerButtonVariants = ['danger', 'danger--tertiary', 'danger--ghost'];
|
|
100
|
-
let component = 'button';
|
|
101
|
-
const assistiveId = useId.useId('danger-description');
|
|
102
|
-
const {
|
|
103
|
-
'aria-pressed': ariaPressed,
|
|
104
|
-
'aria-describedby': ariaDescribedBy
|
|
105
|
-
} = rest;
|
|
106
|
-
let otherProps = {
|
|
107
|
-
disabled,
|
|
108
|
-
type,
|
|
109
|
-
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : ariaDescribedBy || undefined,
|
|
110
|
-
'aria-pressed': ariaPressed ?? (hasIconOnly && kind === 'ghost' ? isSelected : undefined)
|
|
111
|
-
};
|
|
112
|
-
const anchorProps = {
|
|
113
|
-
href
|
|
114
|
-
};
|
|
115
|
-
let assistiveText = null;
|
|
116
|
-
if (dangerButtonVariants.includes(kind)) {
|
|
117
|
-
assistiveText = /*#__PURE__*/React__default["default"].createElement("span", {
|
|
118
|
-
id: assistiveId,
|
|
119
|
-
className: `${prefix}--visually-hidden`
|
|
120
|
-
}, dangerDescription);
|
|
121
|
-
}
|
|
122
|
-
if (as) {
|
|
123
|
-
component = as;
|
|
124
|
-
otherProps = {
|
|
125
|
-
...otherProps,
|
|
126
|
-
...anchorProps
|
|
127
|
-
};
|
|
128
|
-
} else if (href && !disabled) {
|
|
129
|
-
component = 'a';
|
|
130
|
-
otherProps = anchorProps;
|
|
131
|
-
}
|
|
132
60
|
if (!isIconOnlyButton(hasIconOnly)) {
|
|
133
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
onFocus,
|
|
137
|
-
onBlur,
|
|
138
|
-
onClick,
|
|
139
|
-
...rest,
|
|
140
|
-
...commonProps,
|
|
141
|
-
...otherProps
|
|
142
|
-
}, assistiveText, children, buttonImage);
|
|
61
|
+
return /*#__PURE__*/React__default["default"].createElement(ButtonBase["default"], _rollupPluginBabelHelpers["extends"]({
|
|
62
|
+
ref: ref
|
|
63
|
+
}, props));
|
|
143
64
|
} else {
|
|
144
65
|
let align = undefined;
|
|
145
66
|
if (tooltipPosition === 'top' || tooltipPosition === 'bottom') {
|
|
@@ -156,7 +77,8 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
156
77
|
if (tooltipPosition === 'right' || tooltipPosition === 'left') {
|
|
157
78
|
align = tooltipPosition;
|
|
158
79
|
}
|
|
159
|
-
return /*#__PURE__*/React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({
|
|
80
|
+
return /*#__PURE__*/React__default["default"].createElement(index.IconButton, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
81
|
+
ref: ref,
|
|
160
82
|
as: as,
|
|
161
83
|
align: align,
|
|
162
84
|
label: iconDescription,
|
|
@@ -166,8 +88,9 @@ const Button = /*#__PURE__*/React__default["default"].forwardRef(function Button
|
|
|
166
88
|
onMouseLeave: onMouseLeave,
|
|
167
89
|
onFocus: onFocus,
|
|
168
90
|
onBlur: onBlur,
|
|
169
|
-
onClick: events.composeEventHandlers([onClick, handleClick])
|
|
170
|
-
|
|
91
|
+
onClick: events.composeEventHandlers([onClick, handleClick]),
|
|
92
|
+
renderIcon: iconOnlyImage ? null : ButtonImageElement // avoid doubling the icon.
|
|
93
|
+
}), iconOnlyImage ?? children);
|
|
171
94
|
}
|
|
172
95
|
});
|
|
173
96
|
Button.displayName = 'Button';
|
|
@@ -0,0 +1,10 @@
|
|
|
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 { ButtonProps } from './Button';
|
|
9
|
+
declare const ButtonBase: React.ForwardRefExoticComponent<Omit<ButtonProps<React.ElementType<any>>, "ref"> & React.RefAttributes<unknown>>;
|
|
10
|
+
export default ButtonBase;
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
var cx = require('classnames');
|
|
14
|
+
var usePrefix = require('../../internal/usePrefix.js');
|
|
15
|
+
var useId = require('../../internal/useId.js');
|
|
16
|
+
|
|
17
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
+
|
|
19
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
20
|
+
var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
21
|
+
|
|
22
|
+
const ButtonBase = /*#__PURE__*/React__default["default"].forwardRef(function ButtonBase(_ref, ref) {
|
|
23
|
+
let {
|
|
24
|
+
as,
|
|
25
|
+
children,
|
|
26
|
+
className,
|
|
27
|
+
dangerDescription = 'danger',
|
|
28
|
+
disabled = false,
|
|
29
|
+
hasIconOnly = false,
|
|
30
|
+
href,
|
|
31
|
+
iconDescription,
|
|
32
|
+
isExpressive = false,
|
|
33
|
+
isSelected,
|
|
34
|
+
kind = 'primary',
|
|
35
|
+
onBlur,
|
|
36
|
+
onClick,
|
|
37
|
+
onFocus,
|
|
38
|
+
onMouseEnter,
|
|
39
|
+
onMouseLeave,
|
|
40
|
+
renderIcon: ButtonImageElement,
|
|
41
|
+
size,
|
|
42
|
+
tabIndex,
|
|
43
|
+
type = 'button',
|
|
44
|
+
...rest
|
|
45
|
+
} = _ref;
|
|
46
|
+
const prefix = usePrefix.usePrefix();
|
|
47
|
+
const buttonClasses = cx__default["default"](className, {
|
|
48
|
+
[`${prefix}--btn`]: true,
|
|
49
|
+
[`${prefix}--btn--sm`]: size === 'sm' && !isExpressive,
|
|
50
|
+
// TODO: V12 - Remove this class
|
|
51
|
+
[`${prefix}--btn--md`]: size === 'md' && !isExpressive,
|
|
52
|
+
// TODO: V12 - Remove this class
|
|
53
|
+
[`${prefix}--btn--xl`]: size === 'xl',
|
|
54
|
+
// TODO: V12 - Remove this class
|
|
55
|
+
[`${prefix}--btn--2xl`]: size === '2xl',
|
|
56
|
+
// TODO: V12 - Remove this class
|
|
57
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
58
|
+
[`${prefix}--btn--${kind}`]: kind,
|
|
59
|
+
[`${prefix}--btn--disabled`]: disabled,
|
|
60
|
+
[`${prefix}--btn--expressive`]: isExpressive,
|
|
61
|
+
[`${prefix}--btn--icon-only`]: hasIconOnly && !className?.includes(`${prefix}--btn--icon-only`),
|
|
62
|
+
[`${prefix}--btn--selected`]: hasIconOnly && isSelected && kind === 'ghost'
|
|
63
|
+
});
|
|
64
|
+
const commonProps = {
|
|
65
|
+
tabIndex,
|
|
66
|
+
className: buttonClasses,
|
|
67
|
+
ref
|
|
68
|
+
};
|
|
69
|
+
const buttonImage = !ButtonImageElement ? null : /*#__PURE__*/React__default["default"].createElement(ButtonImageElement, {
|
|
70
|
+
"aria-label": iconDescription,
|
|
71
|
+
className: `${prefix}--btn__icon`,
|
|
72
|
+
"aria-hidden": "true"
|
|
73
|
+
});
|
|
74
|
+
const dangerButtonVariants = ['danger', 'danger--tertiary', 'danger--ghost'];
|
|
75
|
+
let component = 'button';
|
|
76
|
+
const assistiveId = useId.useId('danger-description');
|
|
77
|
+
const {
|
|
78
|
+
'aria-pressed': ariaPressed,
|
|
79
|
+
'aria-describedby': ariaDescribedBy
|
|
80
|
+
} = rest;
|
|
81
|
+
let otherProps = {
|
|
82
|
+
disabled,
|
|
83
|
+
type,
|
|
84
|
+
'aria-describedby': dangerButtonVariants.includes(kind) ? assistiveId : ariaDescribedBy || undefined,
|
|
85
|
+
'aria-pressed': ariaPressed ?? (hasIconOnly && kind === 'ghost' ? isSelected : undefined)
|
|
86
|
+
};
|
|
87
|
+
const anchorProps = {
|
|
88
|
+
href
|
|
89
|
+
};
|
|
90
|
+
let assistiveText = null;
|
|
91
|
+
if (dangerButtonVariants.includes(kind)) {
|
|
92
|
+
assistiveText = /*#__PURE__*/React__default["default"].createElement("span", {
|
|
93
|
+
id: assistiveId,
|
|
94
|
+
className: `${prefix}--visually-hidden`
|
|
95
|
+
}, dangerDescription);
|
|
96
|
+
}
|
|
97
|
+
if (as) {
|
|
98
|
+
component = as;
|
|
99
|
+
otherProps = {
|
|
100
|
+
...otherProps,
|
|
101
|
+
...anchorProps
|
|
102
|
+
};
|
|
103
|
+
} else if (href && !disabled) {
|
|
104
|
+
component = 'a';
|
|
105
|
+
otherProps = anchorProps;
|
|
106
|
+
}
|
|
107
|
+
return /*#__PURE__*/React__default["default"].createElement(component, {
|
|
108
|
+
onMouseEnter,
|
|
109
|
+
onMouseLeave,
|
|
110
|
+
onFocus,
|
|
111
|
+
onBlur,
|
|
112
|
+
onClick,
|
|
113
|
+
...rest,
|
|
114
|
+
...commonProps,
|
|
115
|
+
...otherProps
|
|
116
|
+
}, assistiveText, children, buttonImage);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
exports["default"] = ButtonBase;
|
|
@@ -249,7 +249,9 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
249
249
|
const titleClasses = cx__default["default"](`${prefix}--label`, {
|
|
250
250
|
[`${prefix}--label--disabled`]: disabled
|
|
251
251
|
});
|
|
252
|
-
const
|
|
252
|
+
const helperTextId = `combobox-helper-text-${comboBoxInstanceId}`;
|
|
253
|
+
const warnTextId = `combobox-warn-text-${comboBoxInstanceId}`;
|
|
254
|
+
const invalidTextId = `combobox-invalid-text-${comboBoxInstanceId}`;
|
|
253
255
|
const helperClasses = cx__default["default"](`${prefix}--form__helper-text`, {
|
|
254
256
|
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
255
257
|
});
|
|
@@ -387,6 +389,11 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
387
389
|
}
|
|
388
390
|
}
|
|
389
391
|
} : {};
|
|
392
|
+
|
|
393
|
+
// The input should be described by the appropriate message text id
|
|
394
|
+
// when both the message is supplied *and* when the component is in
|
|
395
|
+
// the matching state (invalid, warn, etc).
|
|
396
|
+
const ariaDescribedBy = invalid && invalidText && invalidTextId || warn && warnText && warnTextId || helperText && !isFluid && helperTextId || undefined;
|
|
390
397
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
391
398
|
className: wrapperClasses
|
|
392
399
|
}, titleText && /*#__PURE__*/React__default["default"].createElement(Text.Text, _rollupPluginBabelHelpers["extends"]({
|
|
@@ -399,11 +406,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
399
406
|
disabled: disabled,
|
|
400
407
|
invalid: invalid,
|
|
401
408
|
invalidText: invalidText,
|
|
409
|
+
invalidTextId: invalidTextId,
|
|
402
410
|
isOpen: isOpen,
|
|
403
411
|
light: light,
|
|
404
412
|
size: size,
|
|
405
413
|
warn: warn,
|
|
406
|
-
warnText: warnText
|
|
414
|
+
warnText: warnText,
|
|
415
|
+
warnTextId: warnTextId
|
|
407
416
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
408
417
|
className: `${prefix}--list-box__field`
|
|
409
418
|
}, /*#__PURE__*/React__default["default"].createElement("input", _rollupPluginBabelHelpers["extends"]({
|
|
@@ -421,7 +430,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
421
430
|
}, inputProps, rest, readOnlyEventHandlers, {
|
|
422
431
|
readOnly: readOnly,
|
|
423
432
|
ref: mergeRefs["default"](textInput, ref),
|
|
424
|
-
"aria-describedby":
|
|
433
|
+
"aria-describedby": ariaDescribedBy
|
|
425
434
|
})), invalid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
426
435
|
className: `${prefix}--list-box__invalid-icon`
|
|
427
436
|
}), showWarning && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
@@ -460,7 +469,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
460
469
|
}));
|
|
461
470
|
}) : null)), helperText && !invalid && !warn && !isFluid && (_Text || (_Text = /*#__PURE__*/React__default["default"].createElement(Text.Text, {
|
|
462
471
|
as: "div",
|
|
463
|
-
id:
|
|
472
|
+
id: helperTextId,
|
|
464
473
|
className: helperClasses
|
|
465
474
|
}, helperText))));
|
|
466
475
|
});
|
|
@@ -162,7 +162,7 @@ ComboButton.propTypes = {
|
|
|
162
162
|
/**
|
|
163
163
|
* Specify how the trigger tooltip should be aligned.
|
|
164
164
|
*/
|
|
165
|
-
tooltipAlignment: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
165
|
+
tooltipAlignment: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-start', 'top-right', 'top-end', 'bottom', 'bottom-left', 'bottom-start', 'bottom-right', 'bottom-end', 'left', 'right']),
|
|
166
166
|
/**
|
|
167
167
|
* Optional method that takes in a message id and returns an
|
|
168
168
|
* internationalized string.
|
|
@@ -23,6 +23,7 @@ var toggleClass = require('../../tools/toggleClass.js');
|
|
|
23
23
|
var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
|
|
24
24
|
var wrapFocus = require('../../internal/wrapFocus.js');
|
|
25
25
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
26
|
+
var index = require('../FeatureFlags/index.js');
|
|
26
27
|
var match = require('../../internal/keyboard/match.js');
|
|
27
28
|
var keys = require('../../internal/keyboard/keys.js');
|
|
28
29
|
|
|
@@ -125,6 +126,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
125
126
|
const button = React.useRef(null);
|
|
126
127
|
const startSentinel = React.useRef(null);
|
|
127
128
|
const endSentinel = React.useRef(null);
|
|
129
|
+
const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
|
|
128
130
|
|
|
129
131
|
// Keep track of modal open/close state
|
|
130
132
|
// and propagate it to the document.body
|
|
@@ -142,12 +144,19 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
142
144
|
};
|
|
143
145
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
144
146
|
|
|
145
|
-
function handleKeyDown(
|
|
146
|
-
|
|
147
|
-
if (match.match(
|
|
148
|
-
closeModal(
|
|
147
|
+
function handleKeyDown(event) {
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
if (match.match(event, keys.Escape)) {
|
|
150
|
+
closeModal(event);
|
|
151
|
+
}
|
|
152
|
+
if (focusTrapWithoutSentinels && open && match.match(event, keys.Tab) && innerModal.current) {
|
|
153
|
+
wrapFocus.wrapFocusWithoutSentinels({
|
|
154
|
+
containerNode: innerModal.current,
|
|
155
|
+
currentActiveNode: event.target,
|
|
156
|
+
event: event
|
|
157
|
+
});
|
|
149
158
|
}
|
|
150
|
-
onKeyDown?.(
|
|
159
|
+
onKeyDown?.(event);
|
|
151
160
|
}
|
|
152
161
|
function handleMousedown(evt) {
|
|
153
162
|
evt.stopPropagation();
|
|
@@ -255,7 +264,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
255
264
|
role: "presentation",
|
|
256
265
|
ref: ref,
|
|
257
266
|
"aria-hidden": !open,
|
|
258
|
-
onBlur: handleBlur,
|
|
267
|
+
onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
|
|
259
268
|
onMouseDown: handleMousedown,
|
|
260
269
|
onKeyDown: handleKeyDown,
|
|
261
270
|
className: modalClass
|
|
@@ -265,14 +274,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
265
274
|
"aria-modal": "true",
|
|
266
275
|
"aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
|
|
267
276
|
"aria-labelledby": ariaLabelledBy
|
|
268
|
-
}, /*#__PURE__*/React__default["default"].createElement("button", {
|
|
277
|
+
}, !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
269
278
|
type: "button",
|
|
270
279
|
ref: startSentinel,
|
|
271
280
|
className: `${prefix}--visually-hidden`
|
|
272
281
|
}, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
273
282
|
ref: innerModal,
|
|
274
283
|
className: `${prefix}--modal-container-body`
|
|
275
|
-
}, normalizedSlug, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("button", {
|
|
284
|
+
}, normalizedSlug, childrenWithProps), !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("button", {
|
|
276
285
|
type: "button",
|
|
277
286
|
ref: endSentinel,
|
|
278
287
|
className: `${prefix}--visually-hidden`
|
|
@@ -24,7 +24,7 @@ export interface TableBatchActionProps extends React.ButtonHTMLAttributes<HTMLBu
|
|
|
24
24
|
declare const TableBatchAction: {
|
|
25
25
|
({ renderIcon, iconDescription, ...props }: {
|
|
26
26
|
[x: string]: any;
|
|
27
|
-
renderIcon?: import("@carbon/icons-react
|
|
27
|
+
renderIcon?: import("@carbon/icons-react").CarbonIconType | undefined;
|
|
28
28
|
iconDescription?: string | undefined;
|
|
29
29
|
}): import("react/jsx-runtime").JSX.Element;
|
|
30
30
|
propTypes: {
|
|
@@ -8,13 +8,17 @@ import React from 'react';
|
|
|
8
8
|
export interface TableToolbarMenuProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
/**
|
|
11
|
-
* Provide an optional class name for the toolbar menu
|
|
11
|
+
* Provide an optional class name for the toolbar menu trigger button
|
|
12
12
|
*/
|
|
13
13
|
className?: string;
|
|
14
14
|
/**
|
|
15
15
|
* The description of the menu icon.
|
|
16
16
|
*/
|
|
17
17
|
iconDescription?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Provide an optional class name for the toolbar menu
|
|
20
|
+
*/
|
|
21
|
+
menuOptionsClass?: string;
|
|
18
22
|
/**
|
|
19
23
|
* Optional prop to allow overriding the default menu icon
|
|
20
24
|
*/
|
|
@@ -30,16 +30,19 @@ const TableToolbarMenu = _ref => {
|
|
|
30
30
|
renderIcon = iconsReact.Settings,
|
|
31
31
|
iconDescription = defaultIconDescription,
|
|
32
32
|
children,
|
|
33
|
+
menuOptionsClass,
|
|
33
34
|
...rest
|
|
34
35
|
} = _ref;
|
|
35
36
|
const prefix = usePrefix.usePrefix();
|
|
36
37
|
const toolbarActionClasses = cx__default["default"](className, `${prefix}--toolbar-action ${prefix}--overflow-menu`);
|
|
38
|
+
const menuOptionsClasses = cx__default["default"](menuOptionsClass, `${prefix}--toolbar-action__menu`);
|
|
37
39
|
return /*#__PURE__*/React__default["default"].createElement(index["default"], _rollupPluginBabelHelpers["extends"]({
|
|
38
40
|
"aria-label": iconDescription,
|
|
39
41
|
renderIcon: renderIcon,
|
|
40
42
|
className: toolbarActionClasses,
|
|
41
43
|
title: iconDescription,
|
|
42
44
|
iconDescription: iconDescription,
|
|
45
|
+
menuOptionsClass: menuOptionsClasses,
|
|
43
46
|
flipped: true
|
|
44
47
|
}, rest), children);
|
|
45
48
|
};
|
|
@@ -53,6 +56,10 @@ TableToolbarMenu.propTypes = {
|
|
|
53
56
|
* The description of the menu icon.
|
|
54
57
|
*/
|
|
55
58
|
iconDescription: PropTypes__default["default"].string,
|
|
59
|
+
/**
|
|
60
|
+
* Provide an optional class name for the toolbar menu
|
|
61
|
+
*/
|
|
62
|
+
menuOptionsClass: PropTypes__default["default"].string,
|
|
56
63
|
/**
|
|
57
64
|
* Optional prop to allow overriding the default menu icon
|
|
58
65
|
*/
|
|
@@ -102,6 +102,10 @@ interface DatePickerProps {
|
|
|
102
102
|
* The `open` event handler.
|
|
103
103
|
*/
|
|
104
104
|
onOpen?: flatpickr.Options.Hook;
|
|
105
|
+
/**
|
|
106
|
+
* flatpickr prop passthrough. Controls how dates are parsed.
|
|
107
|
+
*/
|
|
108
|
+
parseDate?: (date: string) => Date | false;
|
|
105
109
|
/**
|
|
106
110
|
* whether the DatePicker is to be readOnly
|
|
107
111
|
* if boolean applies to all inputs
|
|
@@ -170,6 +170,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
170
170
|
readOnly = false,
|
|
171
171
|
short = false,
|
|
172
172
|
value,
|
|
173
|
+
parseDate: parseDateProp,
|
|
173
174
|
...rest
|
|
174
175
|
} = _ref;
|
|
175
176
|
const prefix = usePrefix.usePrefix();
|
|
@@ -279,6 +280,37 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
279
280
|
} else {
|
|
280
281
|
localeData = l10n__default["default"][locale];
|
|
281
282
|
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* parseDate is called before the date is actually set.
|
|
286
|
+
* It attempts to parse the input value and return a valid date string.
|
|
287
|
+
* Flatpickr's default parser results in odd dates when given invalid
|
|
288
|
+
* values, so instead here we normalize the month/day to `1` if given
|
|
289
|
+
* a value outside the acceptable range.
|
|
290
|
+
*/
|
|
291
|
+
let parseDate;
|
|
292
|
+
if (!parseDateProp && dateFormat === 'm/d/Y') {
|
|
293
|
+
// This function only supports the default dateFormat.
|
|
294
|
+
parseDate = date => {
|
|
295
|
+
// Month must be 1-12. If outside these bounds, `1` should be used.
|
|
296
|
+
const month = date.split('/')[0] <= 12 && date.split('/')[0] > 0 ? parseInt(date.split('/')[0]) : 1;
|
|
297
|
+
const year = parseInt(date.split('/')[2]);
|
|
298
|
+
if (month && year) {
|
|
299
|
+
// The month and year must be provided to be able to determine
|
|
300
|
+
// the number of days in the month.
|
|
301
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
302
|
+
// If the day does not fall within the days in the month, `1` should be used.
|
|
303
|
+
const day = date.split('/')[1] <= daysInMonth && date.split('/')[1] > 0 ? parseInt(date.split('/')[1]) : 1;
|
|
304
|
+
return new Date(`${year}/${month}/${day}`);
|
|
305
|
+
} else {
|
|
306
|
+
// With no month and year, we cannot calculate anything.
|
|
307
|
+
// Returning false gives flatpickr an invalid date, which will clear the input
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
} else if (parseDateProp) {
|
|
312
|
+
parseDate = parseDateProp;
|
|
313
|
+
}
|
|
282
314
|
const {
|
|
283
315
|
current: start
|
|
284
316
|
} = startInputField;
|
|
@@ -297,6 +329,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
|
|
|
297
329
|
[enableOrDisable]: enableOrDisableArr,
|
|
298
330
|
minDate: minDate,
|
|
299
331
|
maxDate: maxDate,
|
|
332
|
+
parseDate: parseDate,
|
|
300
333
|
plugins: [datePickerType === 'range' ? rangePlugin["default"]({
|
|
301
334
|
input: endInputField.current
|
|
302
335
|
}) : () => {}, appendTo ? appendToPlugin["default"]({
|
|
@@ -708,6 +741,10 @@ DatePicker.propTypes = {
|
|
|
708
741
|
* `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
|
|
709
742
|
*/
|
|
710
743
|
onOpen: PropTypes__default["default"].func,
|
|
744
|
+
/**
|
|
745
|
+
* flatpickr prop passthrough. Controls how dates are parsed.
|
|
746
|
+
*/
|
|
747
|
+
parseDate: PropTypes__default["default"].func,
|
|
711
748
|
/**
|
|
712
749
|
* whether the DatePicker is to be readOnly
|
|
713
750
|
* if boolean applies to all inputs
|
|
@@ -13,7 +13,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
13
13
|
/**
|
|
14
14
|
* Specify how the trigger should align with the tooltip
|
|
15
15
|
*/
|
|
16
|
-
align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
|
|
16
|
+
align?: 'top' | 'top-left' | 'top-start' | 'top-right' | 'top-end' | 'bottom' | 'bottom-left' | 'bottom-start' | 'bottom-right' | 'bottom-end' | 'left' | 'right';
|
|
17
17
|
/**
|
|
18
18
|
* Provide an icon or asset to be rendered inside of the IconButton
|
|
19
19
|
*/
|
|
@@ -12,12 +12,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
12
12
|
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
13
13
|
var PropTypes = require('prop-types');
|
|
14
14
|
var React = require('react');
|
|
15
|
-
var Button = require('../Button/Button.js');
|
|
16
|
-
require('../Button/Button.Skeleton.js');
|
|
17
15
|
var cx = require('classnames');
|
|
18
16
|
require('../Tooltip/DefinitionTooltip.js');
|
|
19
17
|
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
20
18
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
19
|
+
var ButtonBase = require('../Button/ButtonBase.js');
|
|
21
20
|
|
|
22
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
23
22
|
|
|
@@ -55,7 +54,7 @@ const IconButton = /*#__PURE__*/React__default["default"].forwardRef(function Ic
|
|
|
55
54
|
enterDelayMs: enterDelayMs,
|
|
56
55
|
label: label,
|
|
57
56
|
leaveDelayMs: leaveDelayMs
|
|
58
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
57
|
+
}, /*#__PURE__*/React__default["default"].createElement(ButtonBase["default"], _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
59
58
|
disabled: disabled,
|
|
60
59
|
kind: kind,
|
|
61
60
|
ref: ref,
|
|
@@ -69,7 +68,7 @@ IconButton.propTypes = {
|
|
|
69
68
|
/**
|
|
70
69
|
* Specify how the trigger should align with the tooltip
|
|
71
70
|
*/
|
|
72
|
-
align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
|
|
71
|
+
align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-start', 'top-right', 'top-end', 'bottom', 'bottom-left', 'bottom-start', 'bottom-right', 'bottom-end', 'left', 'right']),
|
|
73
72
|
/**
|
|
74
73
|
* Provide an icon or asset to be rendered inside of the IconButton
|
|
75
74
|
*/
|
|
@@ -21,6 +21,10 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
|
|
|
21
21
|
* Specify the text to be displayed when the control is invalid
|
|
22
22
|
*/
|
|
23
23
|
invalidText?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Specify the id to be applied to the element containing the invalid text
|
|
26
|
+
*/
|
|
27
|
+
invalidTextId?: string;
|
|
24
28
|
/**
|
|
25
29
|
* Specify if the control should render open
|
|
26
30
|
*/
|
|
@@ -50,6 +54,10 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
|
|
|
50
54
|
* Provide the text that is displayed when the control is in warning state
|
|
51
55
|
*/
|
|
52
56
|
warnText?: React.ReactNode;
|
|
57
|
+
/**
|
|
58
|
+
* Specify the id to be applied to the element containing the warn text
|
|
59
|
+
*/
|
|
60
|
+
warnTextId?: string;
|
|
53
61
|
}
|
|
54
62
|
export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
|
|
55
63
|
/**
|