@carbon/react 1.30.0 → 1.31.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/es/components/Accordion/Accordion.js +3 -1
- package/es/components/Button/Button.js +6 -1
- package/es/components/Checkbox/Checkbox.js +2 -2
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +6 -5
- package/es/components/ContainedList/ContainedList.js +12 -4
- package/es/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/es/components/CopyButton/CopyButton.js +8 -2
- package/es/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/es/components/DataTableSkeleton/index.d.ts +9 -0
- package/es/components/FileUploader/FileUploaderButton.js +2 -1
- package/es/components/IconButton/index.js +10 -2
- package/es/components/Layout/index.js +118 -0
- package/es/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/es/components/Menu/MenuItem.js +2 -1
- package/es/components/MenuButton/index.js +7 -4
- package/es/components/OverflowMenu/index.js +9 -1
- package/es/components/OverflowMenu/next/index.js +98 -0
- package/es/components/OverflowMenuV2/index.js +15 -73
- package/es/components/Tabs/Tabs.js +5 -1
- package/es/components/Tag/Tag.js +2 -0
- package/es/components/TextArea/TextArea.Skeleton.js +1 -2
- package/es/components/TextArea/TextArea.js +1 -2
- package/es/components/TextArea/index.d.ts +10 -0
- package/es/components/TextInput/PasswordInput.js +1 -2
- package/es/components/TextInput/TextInput.Skeleton.js +1 -2
- package/es/components/TextInput/TextInput.js +5 -4
- package/es/components/TextInput/index.d.ts +4 -0
- package/es/components/TimePicker/TimePicker.d.ts +8 -0
- package/es/components/TimePicker/TimePicker.js +26 -6
- package/es/components/Tooltip/Tooltip.js +4 -2
- package/es/components/UIShell/SideNav.d.ts +2 -1
- package/es/components/UIShell/SideNav.js +25 -7
- package/es/index.d.ts +21 -20
- package/es/index.js +28 -26
- package/lib/components/Accordion/Accordion.js +3 -1
- package/lib/components/Button/Button.js +6 -1
- package/lib/components/Checkbox/Checkbox.js +2 -2
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +6 -5
- package/lib/components/ContainedList/ContainedList.js +12 -4
- package/lib/components/ContainedList/ContainedListItem/ContainedListItem.js +6 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +10 -1
- package/lib/components/CopyButton/CopyButton.js +8 -2
- package/lib/components/DataTableSkeleton/DataTableSkeleton.js +1 -2
- package/lib/components/DataTableSkeleton/index.d.ts +9 -0
- package/lib/components/FileUploader/FileUploaderButton.js +2 -1
- package/lib/components/IconButton/index.js +10 -2
- package/lib/components/Layout/index.js +129 -0
- package/lib/components/ListBox/ListBoxPropTypes.d.ts +1 -1
- package/lib/components/Menu/MenuItem.js +2 -1
- package/lib/components/MenuButton/index.js +7 -4
- package/lib/components/OverflowMenu/index.js +13 -1
- package/lib/components/OverflowMenu/next/index.js +108 -0
- package/lib/components/OverflowMenuV2/index.js +14 -74
- package/lib/components/Tabs/Tabs.js +5 -1
- package/lib/components/Tag/Tag.js +2 -0
- package/lib/components/TextArea/TextArea.Skeleton.js +1 -2
- package/lib/components/TextArea/TextArea.js +1 -2
- package/lib/components/TextArea/index.d.ts +10 -0
- package/lib/components/TextInput/PasswordInput.js +1 -2
- package/lib/components/TextInput/TextInput.Skeleton.js +1 -2
- package/lib/components/TextInput/TextInput.js +5 -4
- package/lib/components/TextInput/index.d.ts +4 -0
- package/lib/components/TimePicker/TimePicker.d.ts +8 -0
- package/lib/components/TimePicker/TimePicker.js +26 -6
- package/lib/components/Tooltip/Tooltip.js +4 -2
- package/lib/components/UIShell/SideNav.d.ts +2 -1
- package/lib/components/UIShell/SideNav.js +24 -6
- package/lib/index.d.ts +21 -20
- package/lib/index.js +88 -85
- package/package.json +8 -8
- /package/es/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/es/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirection.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/LayoutDirectionContext.js +0 -0
- /package/lib/components/{Layout → LayoutDirection}/useLayoutDirection.js +0 -0
|
@@ -5,80 +5,22 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { OverflowMenuVertical } from '@carbon/icons-react';
|
|
13
|
-
import { Menu } from '../Menu/Menu.js';
|
|
14
|
-
import { useId } from '../../internal/useId.js';
|
|
15
|
-
import { usePrefix } from '../../internal/usePrefix.js';
|
|
16
|
-
import { useAttachedMenu } from '../../internal/useAttachedMenu.js';
|
|
8
|
+
import React__default from 'react';
|
|
9
|
+
import { warning } from '../../internal/warning.js';
|
|
10
|
+
import { FeatureFlags } from '../FeatureFlags/index.js';
|
|
11
|
+
import OverflowMenu from '../OverflowMenu/index.js';
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
function OverflowMenuV2(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const triggerRef = useRef(null);
|
|
30
|
-
const {
|
|
31
|
-
open,
|
|
32
|
-
x,
|
|
33
|
-
y,
|
|
34
|
-
handleClick,
|
|
35
|
-
handleMousedown,
|
|
36
|
-
handleClose
|
|
37
|
-
} = useAttachedMenu(triggerRef);
|
|
38
|
-
const containerClasses = cx(`${prefix}--overflow-menu__container`);
|
|
39
|
-
const triggerClasses = cx(`${prefix}--overflow-menu`, {
|
|
40
|
-
[`${prefix}--overflow-menu--open`]: open,
|
|
41
|
-
[className]: className
|
|
42
|
-
}, size !== defaultSize && `${prefix}--overflow-menu--${size}`);
|
|
43
|
-
return /*#__PURE__*/React__default.createElement("div", {
|
|
44
|
-
className: containerClasses,
|
|
45
|
-
"aria-owns": id
|
|
46
|
-
}, /*#__PURE__*/React__default.createElement("button", _extends({}, rest, {
|
|
47
|
-
type: "button",
|
|
48
|
-
"aria-haspopup": true,
|
|
49
|
-
"aria-expanded": open,
|
|
50
|
-
className: triggerClasses,
|
|
51
|
-
onClick: handleClick,
|
|
52
|
-
onMouseDown: handleMousedown,
|
|
53
|
-
ref: triggerRef
|
|
54
|
-
}), /*#__PURE__*/React__default.createElement(IconElement, {
|
|
55
|
-
className: `${prefix}--overflow-menu__icon`
|
|
56
|
-
})), /*#__PURE__*/React__default.createElement(Menu, {
|
|
57
|
-
id: id,
|
|
58
|
-
size: size,
|
|
59
|
-
open: open,
|
|
60
|
-
onClose: handleClose,
|
|
61
|
-
x: x,
|
|
62
|
-
y: y
|
|
63
|
-
}, children));
|
|
13
|
+
let didWarnAboutDeprecation = false;
|
|
14
|
+
function OverflowMenuV2(props) {
|
|
15
|
+
if (process.env.NODE_ENV !== "production") {
|
|
16
|
+
process.env.NODE_ENV !== "production" ? warning(didWarnAboutDeprecation, '`<OverflowMenuV2>` is deprecated and will be removed in the next major version. Use `<OverflowMenu>` with the `enable-v12-overflowmenu` feature flag instead.') : void 0;
|
|
17
|
+
didWarnAboutDeprecation = true;
|
|
18
|
+
}
|
|
19
|
+
return /*#__PURE__*/React__default.createElement(FeatureFlags, {
|
|
20
|
+
flags: {
|
|
21
|
+
'enable-v12-overflowmenu': true
|
|
22
|
+
}
|
|
23
|
+
}, /*#__PURE__*/React__default.createElement(OverflowMenu, props));
|
|
64
24
|
}
|
|
65
|
-
OverflowMenuV2.propTypes = {
|
|
66
|
-
/**
|
|
67
|
-
* A collection of MenuItems to be rendered within this OverflowMenu.
|
|
68
|
-
*/
|
|
69
|
-
children: PropTypes.node,
|
|
70
|
-
/**
|
|
71
|
-
* Additional CSS class names for the trigger button.
|
|
72
|
-
*/
|
|
73
|
-
className: PropTypes.string,
|
|
74
|
-
/**
|
|
75
|
-
* Otionally provide a custom icon to be rendered on the trigger button.
|
|
76
|
-
*/
|
|
77
|
-
renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
78
|
-
/**
|
|
79
|
-
* Specify the size of the menu, from a list of available sizes.
|
|
80
|
-
*/
|
|
81
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg'])
|
|
82
|
-
};
|
|
83
25
|
|
|
84
26
|
export { OverflowMenuV2 };
|
|
@@ -541,7 +541,11 @@ const Tab = /*#__PURE__*/React__default.forwardRef(function Tab(_ref5, forwardRe
|
|
|
541
541
|
type: "button"
|
|
542
542
|
}), /*#__PURE__*/React__default.createElement("div", {
|
|
543
543
|
className: `${prefix}--tabs__nav-item-label-wrapper`
|
|
544
|
-
}, /*#__PURE__*/React__default.createElement("
|
|
544
|
+
}, dismissable && Icon && /*#__PURE__*/React__default.createElement("div", {
|
|
545
|
+
className: `${prefix}--tabs__nav-item--icon-left`
|
|
546
|
+
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
547
|
+
size: 16
|
|
548
|
+
})), /*#__PURE__*/React__default.createElement("span", {
|
|
545
549
|
className: `${prefix}--tabs__nav-item-label`
|
|
546
550
|
}, children), /*#__PURE__*/React__default.createElement("div", {
|
|
547
551
|
className: cx(`${prefix}--tabs__nav-item--icon`, {
|
package/es/components/Tag/Tag.js
CHANGED
|
@@ -49,6 +49,8 @@ const Tag = _ref => {
|
|
|
49
49
|
[`${prefix}--tag--disabled`]: disabled,
|
|
50
50
|
[`${prefix}--tag--filter`]: filter,
|
|
51
51
|
[`${prefix}--tag--${size}`]: size,
|
|
52
|
+
// TODO: V12 - Remove this class
|
|
53
|
+
[`${prefix}--layout--size-${size}`]: size,
|
|
52
54
|
[`${prefix}--tag--${type}`]: type,
|
|
53
55
|
[`${prefix}--tag--interactive`]: other.onClick && !filter
|
|
54
56
|
});
|
|
@@ -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 TextArea from './TextArea';
|
|
8
|
+
export { default as TextAreaSkeleton } from './TextArea.Skeleton';
|
|
9
|
+
export default TextArea;
|
|
10
|
+
export { TextArea };
|
|
@@ -34,7 +34,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
|
|
|
34
34
|
onClick = () => {},
|
|
35
35
|
placeholder,
|
|
36
36
|
readOnly,
|
|
37
|
-
size
|
|
37
|
+
size,
|
|
38
38
|
type = 'text',
|
|
39
39
|
warn = false,
|
|
40
40
|
warnText,
|
|
@@ -61,7 +61,9 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
|
|
|
61
61
|
[`${prefix}--text-input--light`]: light,
|
|
62
62
|
[`${prefix}--text-input--invalid`]: normalizedProps.invalid,
|
|
63
63
|
[`${prefix}--text-input--warning`]: normalizedProps.warn,
|
|
64
|
-
[`${prefix}--text-input--${size}`]: size
|
|
64
|
+
[`${prefix}--text-input--${size}`]: size,
|
|
65
|
+
// TODO: V12 - Remove this class
|
|
66
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
65
67
|
});
|
|
66
68
|
const sharedTextInputProps = {
|
|
67
69
|
id,
|
|
@@ -260,6 +262,5 @@ TextInput.propTypes = {
|
|
|
260
262
|
*/
|
|
261
263
|
warnText: PropTypes.node
|
|
262
264
|
};
|
|
263
|
-
var TextInput$1 = TextInput;
|
|
264
265
|
|
|
265
|
-
export { TextInput
|
|
266
|
+
export { TextInput as default };
|
|
@@ -36,6 +36,14 @@ export interface TimePickerProps extends Omit<ReactAttr<HTMLInputElement>, Exclu
|
|
|
36
36
|
* Provide the text that is displayed when the control is in an invalid state
|
|
37
37
|
*/
|
|
38
38
|
invalidText?: React.ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* Specify a warning message
|
|
41
|
+
*/
|
|
42
|
+
warning?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Provide the text that is displayed when the control is in an warning state
|
|
45
|
+
*/
|
|
46
|
+
warningText?: React.ReactNode;
|
|
39
47
|
/**
|
|
40
48
|
* Provide the text that will be read by a screen reader when visiting this
|
|
41
49
|
* control
|
|
@@ -11,6 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import React__default from 'react';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import deprecate from '../../prop-types/deprecate.js';
|
|
14
|
+
import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
|
|
14
15
|
|
|
15
16
|
const TimePicker = /*#__PURE__*/React__default.forwardRef(function TimePicker(_ref, ref) {
|
|
16
17
|
let {
|
|
@@ -21,6 +22,8 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef(function TimePicker(_r
|
|
|
21
22
|
id,
|
|
22
23
|
invalidText = 'Invalid time format.',
|
|
23
24
|
invalid = false,
|
|
25
|
+
warningText = 'Warning message.',
|
|
26
|
+
warning = false,
|
|
24
27
|
labelText,
|
|
25
28
|
light = false,
|
|
26
29
|
maxLength = 5,
|
|
@@ -65,12 +68,14 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef(function TimePicker(_r
|
|
|
65
68
|
}
|
|
66
69
|
}
|
|
67
70
|
const timePickerInputClasses = cx(`${prefix}--time-picker__input-field`, `${prefix}--text-input`, [className], {
|
|
68
|
-
[`${prefix}--text-input--light`]: light
|
|
71
|
+
[`${prefix}--text-input--light`]: light,
|
|
72
|
+
[`${prefix}--time-picker__input-field-error`]: invalid || warning
|
|
69
73
|
});
|
|
70
74
|
const timePickerClasses = cx({
|
|
71
75
|
[`${prefix}--time-picker`]: true,
|
|
72
76
|
[`${prefix}--time-picker--light`]: light,
|
|
73
77
|
[`${prefix}--time-picker--invalid`]: invalid,
|
|
78
|
+
[`${prefix}--time-picker--warning`]: warning,
|
|
74
79
|
[`${prefix}--time-picker--readonly`]: readOnly,
|
|
75
80
|
[`${prefix}--time-picker--${size}`]: size,
|
|
76
81
|
...(className && {
|
|
@@ -85,9 +90,6 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef(function TimePicker(_r
|
|
|
85
90
|
htmlFor: id,
|
|
86
91
|
className: labelClasses
|
|
87
92
|
}, labelText) : null;
|
|
88
|
-
const error = invalid ? /*#__PURE__*/React__default.createElement("div", {
|
|
89
|
-
className: `${prefix}--form-requirement`
|
|
90
|
-
}, invalidText) : null;
|
|
91
93
|
function getInternalPickerSelects() {
|
|
92
94
|
const readOnlyEventHandlers = {
|
|
93
95
|
onMouseDown: evt => {
|
|
@@ -140,7 +142,17 @@ const TimePicker = /*#__PURE__*/React__default.forwardRef(function TimePicker(_r
|
|
|
140
142
|
ref: ref,
|
|
141
143
|
type: type,
|
|
142
144
|
value: value
|
|
143
|
-
}, rest, readOnlyProps))
|
|
145
|
+
}, rest, readOnlyProps)), (invalid || warning) && /*#__PURE__*/React__default.createElement("div", {
|
|
146
|
+
className: `${prefix}--time-picker__error__icon`
|
|
147
|
+
}, invalid ? /*#__PURE__*/React__default.createElement(WarningFilled, {
|
|
148
|
+
className: `${prefix}--checkbox__invalid-icon`,
|
|
149
|
+
size: 16
|
|
150
|
+
}) : /*#__PURE__*/React__default.createElement(WarningAltFilled, {
|
|
151
|
+
className: `${prefix}--text-input__invalid-icon--warning`,
|
|
152
|
+
size: 16
|
|
153
|
+
}))), getInternalPickerSelects()), (invalid || warning) && /*#__PURE__*/React__default.createElement("div", {
|
|
154
|
+
className: `${prefix}--form-requirement`
|
|
155
|
+
}, invalid ? invalidText : warningText));
|
|
144
156
|
});
|
|
145
157
|
TimePicker.propTypes = {
|
|
146
158
|
/**
|
|
@@ -222,7 +234,15 @@ TimePicker.propTypes = {
|
|
|
222
234
|
/**
|
|
223
235
|
* Specify the value of the `<input>`
|
|
224
236
|
*/
|
|
225
|
-
value: PropTypes.string
|
|
237
|
+
value: PropTypes.string,
|
|
238
|
+
/**
|
|
239
|
+
* Specify a warning message
|
|
240
|
+
*/
|
|
241
|
+
warning: PropTypes.bool,
|
|
242
|
+
/**
|
|
243
|
+
* Provide the text that is displayed when the control is in an warning state
|
|
244
|
+
*/
|
|
245
|
+
warningText: PropTypes.node
|
|
226
246
|
};
|
|
227
247
|
var TimePicker$1 = TimePicker;
|
|
228
248
|
|
|
@@ -94,10 +94,12 @@ function Tooltip(_ref) {
|
|
|
94
94
|
onMouseLeave: onMouseLeave,
|
|
95
95
|
open: open,
|
|
96
96
|
ref: containerRef
|
|
97
|
-
}),
|
|
97
|
+
}), /*#__PURE__*/React__default.createElement("div", {
|
|
98
|
+
className: `${prefix}--tooltip-trigger__wrapper`
|
|
99
|
+
}, child !== undefined ? /*#__PURE__*/React__default.cloneElement(child, {
|
|
98
100
|
...triggerProps,
|
|
99
101
|
...getChildEventHandlers(child.props)
|
|
100
|
-
}) : null, /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
102
|
+
}) : null), /*#__PURE__*/React__default.createElement(PopoverContent, {
|
|
101
103
|
"aria-hidden": "true",
|
|
102
104
|
className: `${prefix}--tooltip-content`,
|
|
103
105
|
id: id,
|
|
@@ -18,6 +18,7 @@ interface SideNavProps extends ComponentProps<'nav'> {
|
|
|
18
18
|
addMouseListeners?: boolean | undefined;
|
|
19
19
|
onOverlayClick?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
20
20
|
onSideNavBlur?: () => void | undefined;
|
|
21
|
+
enterDelayMs?: number;
|
|
21
22
|
}
|
|
22
|
-
declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "className" | "slot" | "style" | "title" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "onToggle" | "key" | "id" | "onAnimationEnd" | "aria-controls" | "aria-expanded" | "onClick" | "onKeyDown" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "href" | "expanded" | "defaultExpanded" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addFocusListeners" | "addMouseListeners" | "onOverlayClick" | "onSideNavBlur"> & React.RefAttributes<HTMLElement>>;
|
|
23
|
+
declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "className" | "slot" | "style" | "title" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "onToggle" | "key" | "id" | "onAnimationEnd" | "aria-controls" | "aria-expanded" | "onClick" | "onKeyDown" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "href" | "enterDelayMs" | "expanded" | "defaultExpanded" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addFocusListeners" | "addMouseListeners" | "onOverlayClick" | "onSideNavBlur"> & React.RefAttributes<HTMLElement>>;
|
|
23
24
|
export default SideNav;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useRef,
|
|
9
|
+
import React__default, { useRef, isValidElement } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
@@ -14,6 +14,7 @@ import { CARBON_SIDENAV_ITEMS } from './_utils.js';
|
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
15
|
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
16
16
|
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
17
|
+
import { useDelayedState } from '../../internal/useDelayedState.js';
|
|
17
18
|
import { match } from '../../internal/keyboard/match.js';
|
|
18
19
|
import { Tab, Escape } from '../../internal/keyboard/keys.js';
|
|
19
20
|
|
|
@@ -39,27 +40,28 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
39
40
|
addMouseListeners = true,
|
|
40
41
|
onOverlayClick,
|
|
41
42
|
onSideNavBlur,
|
|
43
|
+
enterDelayMs = 100,
|
|
42
44
|
...other
|
|
43
45
|
} = _ref;
|
|
44
46
|
const prefix = usePrefix();
|
|
45
47
|
const {
|
|
46
48
|
current: controlled
|
|
47
49
|
} = useRef(expandedProp !== undefined);
|
|
48
|
-
const [expandedState, setExpandedState] =
|
|
49
|
-
const [expandedViaHoverState, setExpandedViaHoverState] =
|
|
50
|
+
const [expandedState, setExpandedState] = useDelayedState(defaultExpanded);
|
|
51
|
+
const [expandedViaHoverState, setExpandedViaHoverState] = useDelayedState(defaultExpanded);
|
|
50
52
|
const expanded = controlled ? expandedProp : expandedState;
|
|
51
53
|
const sideNavRef = useRef(null);
|
|
52
54
|
const navRef = useMergedRefs([sideNavRef, ref]);
|
|
53
55
|
const handleToggle = function (event) {
|
|
54
56
|
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !expanded;
|
|
55
57
|
if (!controlled) {
|
|
56
|
-
setExpandedState(value);
|
|
58
|
+
setExpandedState(value, enterDelayMs);
|
|
57
59
|
}
|
|
58
60
|
if (onToggle) {
|
|
59
61
|
onToggle(event, value);
|
|
60
62
|
}
|
|
61
63
|
if (controlled || isRail) {
|
|
62
|
-
setExpandedViaHoverState(value);
|
|
64
|
+
setExpandedViaHoverState(value, enterDelayMs);
|
|
63
65
|
}
|
|
64
66
|
};
|
|
65
67
|
const accessibilityLabel = {
|
|
@@ -130,8 +132,20 @@ function SideNavRenderFunction(_ref, ref) {
|
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
if (addMouseListeners && isRail) {
|
|
133
|
-
eventHandlers.onMouseEnter = () =>
|
|
134
|
-
|
|
135
|
+
eventHandlers.onMouseEnter = () => {
|
|
136
|
+
handleToggle(true, true);
|
|
137
|
+
};
|
|
138
|
+
eventHandlers.onMouseLeave = () => {
|
|
139
|
+
setExpandedState(false);
|
|
140
|
+
setExpandedViaHoverState(false);
|
|
141
|
+
handleToggle(false, false);
|
|
142
|
+
};
|
|
143
|
+
eventHandlers.onClick = () => {
|
|
144
|
+
//if delay is enabled, and user intentionally clicks it to see it expanded immediately
|
|
145
|
+
setExpandedState(true);
|
|
146
|
+
setExpandedViaHoverState(true);
|
|
147
|
+
handleToggle(true, true);
|
|
148
|
+
};
|
|
135
149
|
}
|
|
136
150
|
useWindowEvent('keydown', event => {
|
|
137
151
|
const focusedElement = document.activeElement;
|
|
@@ -174,6 +188,10 @@ SideNav.propTypes = {
|
|
|
174
188
|
* If `true`, the SideNav will be open on initial render.
|
|
175
189
|
*/
|
|
176
190
|
defaultExpanded: PropTypes.bool,
|
|
191
|
+
/**
|
|
192
|
+
* Specify the duration in milliseconds to delay before displaying the sidenavigation
|
|
193
|
+
*/
|
|
194
|
+
enterDelayMs: PropTypes.number,
|
|
177
195
|
/**
|
|
178
196
|
* If `true`, the SideNav will be expanded, otherwise it will be collapsed.
|
|
179
197
|
* Using this prop causes SideNav to become a controled component.
|
package/es/index.d.ts
CHANGED
|
@@ -16,30 +16,37 @@ export * from './components/CheckboxGroup';
|
|
|
16
16
|
export * from './components/ClassPrefix';
|
|
17
17
|
export * from './components/CodeSnippet';
|
|
18
18
|
export * from './components/ComboBox';
|
|
19
|
+
export * from './components/ComboButton';
|
|
19
20
|
export * from './components/ComposedModal';
|
|
20
21
|
export * from './components/ContainedList';
|
|
21
22
|
export * from './components/ContentSwitcher';
|
|
23
|
+
export * from './components/ContextMenu';
|
|
22
24
|
export * from './components/Copy';
|
|
23
25
|
export * from './components/CopyButton';
|
|
24
26
|
export * from './components/DangerButton';
|
|
25
27
|
export * from './components/DataTable';
|
|
28
|
+
export * from './components/DataTableSkeleton';
|
|
26
29
|
export * from './components/DatePicker';
|
|
27
30
|
export * from './components/DatePickerInput';
|
|
28
31
|
export * from './components/Dropdown';
|
|
29
32
|
export * from './components/ErrorBoundary';
|
|
33
|
+
export * from './components/ExpandableSearch';
|
|
30
34
|
export * from './components/FileUploader';
|
|
31
35
|
export * from './components/FilterableMultiSelect';
|
|
32
|
-
export * from './components/Form';
|
|
33
36
|
export * from './components/FluidForm';
|
|
37
|
+
export * from './components/Form';
|
|
34
38
|
export * from './components/FormGroup';
|
|
35
39
|
export * from './components/FormItem';
|
|
36
40
|
export * from './components/FormLabel';
|
|
37
41
|
export * from './components/Grid';
|
|
42
|
+
export * from './components/Icon/Icon.Skeleton';
|
|
38
43
|
export * from './components/IdPrefix';
|
|
39
44
|
export * from './components/InlineLoading';
|
|
40
45
|
export * from './components/Link';
|
|
41
46
|
export * from './components/ListItem';
|
|
42
47
|
export * from './components/Loading';
|
|
48
|
+
export * from './components/Menu';
|
|
49
|
+
export * from './components/MenuButton';
|
|
43
50
|
export * from './components/Modal';
|
|
44
51
|
export * from './components/ModalWrapper';
|
|
45
52
|
export * from './components/MultiSelect';
|
|
@@ -49,48 +56,44 @@ export * from './components/OrderedList';
|
|
|
49
56
|
export * from './components/OverflowMenu';
|
|
50
57
|
export * from './components/OverflowMenuItem';
|
|
51
58
|
export * from './components/Pagination';
|
|
59
|
+
export * from './components/Pagination/Pagination.Skeleton';
|
|
52
60
|
export * from './components/PaginationNav';
|
|
53
61
|
export * from './components/PasswordInput';
|
|
54
62
|
export * from './components/PrimaryButton';
|
|
55
63
|
export * from './components/ProgressIndicator';
|
|
56
64
|
export * from './components/RadioButton';
|
|
65
|
+
export * from './components/RadioButton/RadioButton.Skeleton';
|
|
57
66
|
export * from './components/RadioButtonGroup';
|
|
67
|
+
export * from './components/RadioTile';
|
|
58
68
|
export * from './components/Search';
|
|
59
|
-
export * from './components/ExpandableSearch';
|
|
60
69
|
export * from './components/SecondaryButton';
|
|
61
70
|
export * from './components/Select';
|
|
62
71
|
export * from './components/SelectItem';
|
|
63
72
|
export * from './components/SelectItemGroup';
|
|
64
|
-
export * from './components/
|
|
73
|
+
export * from './components/SkeletonIcon';
|
|
74
|
+
export * from './components/SkeletonPlaceholder';
|
|
75
|
+
export * from './components/SkeletonText';
|
|
65
76
|
export * from './components/Slider';
|
|
66
77
|
export * from './components/StructuredList';
|
|
78
|
+
export * from './components/Switch';
|
|
67
79
|
export * from './components/Tab';
|
|
68
80
|
export * from './components/TabContent';
|
|
69
81
|
export * from './components/Tabs';
|
|
70
82
|
export * from './components/Tag';
|
|
83
|
+
export * from './components/Tag/Tag.Skeleton';
|
|
71
84
|
export * from './components/TextArea';
|
|
72
85
|
export * from './components/TextInput';
|
|
73
86
|
export * from './components/Tile';
|
|
74
|
-
export * from './components/RadioTile';
|
|
75
87
|
export * from './components/TileGroup';
|
|
76
88
|
export * from './components/TimePicker';
|
|
77
89
|
export * from './components/TimePickerSelect';
|
|
78
90
|
export * from './components/Toggle';
|
|
79
|
-
export * from './components/Toggletip';
|
|
80
|
-
export * from './components/TreeView';
|
|
81
|
-
export * from './components/UnorderedList';
|
|
82
|
-
export * from './components/SkeletonText';
|
|
83
|
-
export * from './components/SkeletonPlaceholder';
|
|
84
|
-
export * from './components/SkeletonIcon';
|
|
85
|
-
export * from './components/DataTableSkeleton';
|
|
86
|
-
export * from './components/Pagination/Pagination.Skeleton';
|
|
87
|
-
export * from './components/RadioButton/RadioButton.Skeleton';
|
|
88
|
-
export * from './components/Tag/Tag.Skeleton';
|
|
89
91
|
export * from './components/Toggle/Toggle.Skeleton';
|
|
90
92
|
export * from './components/ToggleSmall/ToggleSmall.Skeleton';
|
|
91
|
-
export * from './components/
|
|
93
|
+
export * from './components/Toggletip';
|
|
94
|
+
export * from './components/TreeView';
|
|
92
95
|
export * from './components/UIShell';
|
|
93
|
-
export
|
|
96
|
+
export * from './components/UnorderedList';
|
|
94
97
|
export { FeatureFlags as unstable_FeatureFlags, useFeatureFlag as unstable_useFeatureFlag, useFeatureFlags as unstable_useFeatureFlags, } from './components/FeatureFlags';
|
|
95
98
|
export { FluidComboBox as unstable__FluidComboBox, FluidComboBoxSkeleton as unstable__FluidComboBoxSkeleton, } from './components/FluidComboBox';
|
|
96
99
|
export { FluidDatePicker as unstable__FluidDatePicker, FluidDatePickerSkeleton as unstable__FluidDatePickerSkeleton, } from './components/FluidDatePicker';
|
|
@@ -105,11 +108,9 @@ export { FluidTimePickerSelect as unstable__FluidTimePickerSelect } from './comp
|
|
|
105
108
|
export * from './components/Heading';
|
|
106
109
|
export * from './components/IconButton';
|
|
107
110
|
export * from './components/Layer';
|
|
108
|
-
export {
|
|
109
|
-
export {
|
|
111
|
+
export { Layout as unstable_Layout } from './components/Layout';
|
|
112
|
+
export { LayoutDirection as unstable_LayoutDirection, useLayoutDirection as unstable_useLayoutDirection, } from './components/LayoutDirection';
|
|
110
113
|
export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/OverflowMenuV2';
|
|
111
|
-
export { ComboButton as unstable_ComboButton } from './components/ComboButton';
|
|
112
|
-
export { MenuButton as unstable_MenuButton } from './components/MenuButton';
|
|
113
114
|
export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
|
|
114
115
|
export * from './components/Popover';
|
|
115
116
|
export * from './components/ProgressBar';
|