@carbon/react 1.31.3 → 1.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/es/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/es/components/Accordion/Accordion.Skeleton.js +3 -3
- package/es/components/Accordion/Accordion.d.ts +65 -0
- package/es/components/Accordion/Accordion.js +5 -6
- package/es/components/Accordion/AccordionItem.d.ts +105 -0
- package/es/components/Accordion/AccordionItem.js +12 -9
- package/es/components/Accordion/AccordionProvider.d.ts +20 -0
- package/es/components/Accordion/AccordionProvider.js +25 -0
- package/es/components/Accordion/index.d.ts +11 -0
- package/es/components/Button/Button.Skeleton.d.ts +28 -0
- package/es/components/Button/Button.Skeleton.js +5 -3
- package/es/components/Button/Button.d.ts +72 -0
- package/es/components/Button/Button.js +13 -10
- package/es/components/Button/index.d.ts +11 -0
- package/es/components/Button/index.js +2 -1
- package/es/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/es/components/ButtonSet/ButtonSet.js +1 -2
- package/es/components/ButtonSet/index.d.ts +9 -0
- package/es/components/CodeSnippet/CodeSnippet.js +1 -0
- package/es/components/ComboButton/index.js +1 -0
- package/es/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/es/components/ComposedModal/ComposedModal.js +58 -67
- package/es/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/es/components/ComposedModal/ModalFooter.js +22 -19
- package/es/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/es/components/ComposedModal/ModalHeader.js +8 -25
- package/es/components/ComposedModal/index.d.ts +9 -0
- package/es/components/ContainedList/ContainedList.js +12 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/es/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/es/components/DangerButton/DangerButton.d.ts +9 -0
- package/es/components/DangerButton/DangerButton.js +2 -2
- package/es/components/DangerButton/index.d.ts +9 -0
- package/es/components/DataTable/TableBatchAction.js +1 -0
- package/es/components/DataTable/TableBatchActions.js +1 -0
- package/es/components/DataTable/TableBody.d.ts +29 -0
- package/es/components/DataTable/TableBody.js +2 -3
- package/es/components/DataTable/TableContainer.d.ts +51 -0
- package/es/components/DataTable/TableContainer.js +3 -4
- package/es/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/es/components/DataTable/TableExpandHeader.js +4 -5
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/es/components/Dropdown/Dropdown.js +1 -0
- package/es/components/FluidTextInput/FluidTextInput.js +1 -0
- package/es/components/FormGroup/FormGroup.d.ts +80 -0
- package/es/components/IconButton/index.js +3 -2
- package/es/components/Layout/index.d.ts +74 -0
- package/es/components/Layout/index.js +14 -5
- package/es/components/Link/Link.d.ts +2 -2
- package/es/components/Link/Link.js +2 -1
- package/es/components/MenuButton/index.js +1 -0
- package/es/components/Modal/Modal.js +1 -0
- package/es/components/ModalWrapper/ModalWrapper.js +1 -0
- package/es/components/Notification/Notification.d.ts +531 -0
- package/es/components/Notification/Notification.js +40 -6
- package/es/components/Notification/index.d.ts +7 -0
- package/es/components/PrimaryButton/PrimaryButton.js +1 -0
- package/es/components/SecondaryButton/SecondaryButton.js +1 -0
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/es/components/SkeletonText/SkeletonText.js +15 -17
- package/es/components/SkeletonText/index.d.ts +9 -0
- package/es/components/Switch/Switch.d.ts +56 -0
- package/es/components/Switch/Switch.js +4 -4
- package/es/components/Tab/index.d.ts +9 -0
- package/es/components/TabContent/TabContent.d.ts +40 -0
- package/es/components/TabContent/TabContent.js +6 -12
- package/es/components/TabContent/index.d.ts +10 -0
- package/es/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/es/components/Tabs/Tabs.Skeleton.js +2 -2
- package/es/components/Tabs/Tabs.d.ts +311 -0
- package/es/components/Tabs/Tabs.js +151 -97
- package/es/components/Tabs/index.d.ts +10 -0
- package/es/components/Tabs/usePressable.js +11 -0
- package/es/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/es/components/TextInput/ControlledPasswordInput.js +5 -6
- package/es/components/Tile/Tile.d.ts +153 -0
- package/es/components/Tile/Tile.js +62 -74
- package/es/components/Tile/index.d.ts +7 -0
- package/es/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/es/components/Toggle/Toggle.Skeleton.js +24 -64
- package/es/components/Toggle/Toggle.js +1 -1
- package/es/components/UIShell/HeaderGlobalAction.js +1 -0
- package/es/components/UIShell/HeaderPanel.js +61 -5
- package/es/components/UIShell/SideNav.d.ts +1 -1
- package/es/components/UIShell/Switcher.js +45 -5
- package/es/components/UIShell/SwitcherItem.js +45 -6
- package/es/index.js +16 -16
- package/es/internal/keyboard/match.js +2 -2
- package/es/internal/useControllableState.js +2 -2
- package/es/internal/useMatchMedia.js +44 -0
- package/es/internal/wrapFocus.js +6 -6
- package/es/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/es/prop-types/types.js +3 -0
- package/lib/components/Accordion/Accordion.Skeleton.d.ts +64 -0
- package/lib/components/Accordion/Accordion.Skeleton.js +3 -3
- package/lib/components/Accordion/Accordion.d.ts +65 -0
- package/lib/components/Accordion/Accordion.js +5 -6
- package/lib/components/Accordion/AccordionItem.d.ts +105 -0
- package/lib/components/Accordion/AccordionItem.js +11 -8
- package/lib/components/Accordion/AccordionProvider.d.ts +20 -0
- package/lib/components/Accordion/AccordionProvider.js +34 -0
- package/lib/components/Accordion/index.d.ts +11 -0
- package/lib/components/Button/Button.Skeleton.d.ts +28 -0
- package/lib/components/Button/Button.Skeleton.js +5 -3
- package/lib/components/Button/Button.d.ts +72 -0
- package/lib/components/Button/Button.js +18 -11
- package/lib/components/Button/index.d.ts +11 -0
- package/lib/components/Button/index.js +6 -0
- package/lib/components/ButtonSet/ButtonSet.d.ts +17 -0
- package/lib/components/ButtonSet/ButtonSet.js +1 -2
- package/lib/components/ButtonSet/index.d.ts +9 -0
- package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
- package/lib/components/ComboButton/index.js +1 -0
- package/lib/components/ComposedModal/ComposedModal.d.ts +70 -0
- package/lib/components/ComposedModal/ComposedModal.js +58 -67
- package/lib/components/ComposedModal/ModalFooter.d.ts +71 -0
- package/lib/components/ComposedModal/ModalFooter.js +22 -19
- package/lib/components/ComposedModal/ModalHeader.d.ts +58 -0
- package/lib/components/ComposedModal/ModalHeader.js +8 -25
- package/lib/components/ComposedModal/index.d.ts +9 -0
- package/lib/components/ContainedList/ContainedList.js +12 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +109 -0
- package/lib/components/ContentSwitcher/ContentSwitcher.js +14 -6
- package/lib/components/DangerButton/DangerButton.d.ts +9 -0
- package/lib/components/DangerButton/DangerButton.js +2 -2
- package/lib/components/DangerButton/index.d.ts +9 -0
- package/lib/components/DataTable/TableBatchAction.js +1 -0
- package/lib/components/DataTable/TableBatchActions.js +1 -0
- package/lib/components/DataTable/TableBody.d.ts +29 -0
- package/lib/components/DataTable/TableBody.js +3 -4
- package/lib/components/DataTable/TableContainer.d.ts +51 -0
- package/lib/components/DataTable/TableContainer.js +3 -4
- package/lib/components/DataTable/TableExpandHeader.d.ts +86 -0
- package/lib/components/DataTable/TableExpandHeader.js +4 -5
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +12 -16
- package/lib/components/Dropdown/Dropdown.js +1 -0
- package/lib/components/FluidTextInput/FluidTextInput.js +1 -0
- package/lib/components/FormGroup/FormGroup.d.ts +80 -0
- package/lib/components/IconButton/index.js +3 -2
- package/lib/components/Layout/index.d.ts +74 -0
- package/lib/components/Layout/index.js +14 -5
- package/lib/components/Link/Link.d.ts +2 -2
- package/lib/components/Link/Link.js +2 -1
- package/lib/components/MenuButton/index.js +1 -0
- package/lib/components/Modal/Modal.js +1 -0
- package/lib/components/ModalWrapper/ModalWrapper.js +1 -0
- package/lib/components/Notification/Notification.d.ts +531 -0
- package/lib/components/Notification/Notification.js +40 -6
- package/lib/components/Notification/index.d.ts +7 -0
- package/lib/components/PrimaryButton/PrimaryButton.js +1 -0
- package/lib/components/SecondaryButton/SecondaryButton.js +1 -0
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/SkeletonText/SkeletonText.d.ts +61 -0
- package/lib/components/SkeletonText/SkeletonText.js +15 -17
- package/lib/components/SkeletonText/index.d.ts +9 -0
- package/lib/components/Switch/Switch.d.ts +56 -0
- package/lib/components/Switch/Switch.js +4 -4
- package/lib/components/Tab/index.d.ts +9 -0
- package/lib/components/TabContent/TabContent.d.ts +40 -0
- package/lib/components/TabContent/TabContent.js +6 -12
- package/lib/components/TabContent/index.d.ts +10 -0
- package/lib/components/Tabs/Tabs.Skeleton.d.ts +33 -0
- package/lib/components/Tabs/Tabs.Skeleton.js +2 -2
- package/lib/components/Tabs/Tabs.d.ts +311 -0
- package/lib/components/Tabs/Tabs.js +150 -96
- package/lib/components/Tabs/index.d.ts +10 -0
- package/lib/components/Tabs/usePressable.js +11 -0
- package/lib/components/TextInput/ControlledPasswordInput.d.ts +90 -0
- package/lib/components/TextInput/ControlledPasswordInput.js +5 -6
- package/lib/components/Tile/Tile.d.ts +153 -0
- package/lib/components/Tile/Tile.js +62 -74
- package/lib/components/Tile/index.d.ts +7 -0
- package/lib/components/Toggle/Toggle.Skeleton.d.ts +3 -47
- package/lib/components/Toggle/Toggle.Skeleton.js +22 -62
- package/lib/components/Toggle/Toggle.js +1 -1
- package/lib/components/UIShell/HeaderGlobalAction.js +1 -0
- package/lib/components/UIShell/HeaderPanel.js +60 -4
- package/lib/components/UIShell/SideNav.d.ts +1 -1
- package/lib/components/UIShell/Switcher.js +44 -4
- package/lib/components/UIShell/SwitcherItem.js +45 -6
- package/lib/index.js +51 -47
- package/lib/internal/keyboard/match.js +2 -2
- package/lib/internal/useControllableState.js +2 -2
- package/lib/internal/useMatchMedia.js +48 -0
- package/lib/internal/wrapFocus.js +6 -6
- package/lib/prop-types/requiredIfGivenPropIsTruthy.js +1 -1
- package/lib/prop-types/types.js +3 -0
- package/package.json +4 -3
|
@@ -6,29 +6,75 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { useRef, useState } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
|
+
import { useWindowEvent } from '../../internal/useEvent.js';
|
|
14
|
+
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Escape } from '../../internal/keyboard/keys.js';
|
|
13
17
|
|
|
14
18
|
const HeaderPanel = /*#__PURE__*/React__default.forwardRef(function HeaderPanel(_ref, ref) {
|
|
15
19
|
let {
|
|
16
20
|
children,
|
|
17
21
|
className: customClassName,
|
|
18
22
|
expanded,
|
|
23
|
+
addFocusListeners = true,
|
|
24
|
+
onHeaderPanelFocus,
|
|
25
|
+
href,
|
|
19
26
|
...other
|
|
20
27
|
} = _ref;
|
|
21
28
|
const prefix = usePrefix();
|
|
29
|
+
const headerPanelReference = useRef(null);
|
|
30
|
+
const headerPanelRef = useMergedRefs([headerPanelReference, ref]);
|
|
31
|
+
const controlled = useRef(expanded !== undefined).current;
|
|
32
|
+
const [expandedState, setExpandedState] = useState(expanded);
|
|
33
|
+
const expandedProp = controlled ? expanded : expandedState;
|
|
34
|
+
const [lastClickedElement, setLastClickedElement] = useState(null);
|
|
22
35
|
const className = cx(`${prefix}--header-panel`, {
|
|
23
|
-
[`${prefix}--header-panel--expanded`]:
|
|
36
|
+
[`${prefix}--header-panel--expanded`]: expandedProp,
|
|
24
37
|
[customClassName]: !!customClassName
|
|
25
38
|
});
|
|
39
|
+
const eventHandlers = {};
|
|
40
|
+
if (addFocusListeners) {
|
|
41
|
+
eventHandlers.onBlur = event => {
|
|
42
|
+
if (!event.currentTarget.contains(event.relatedTarget) && !lastClickedElement.classList.contains('cds--switcher__item-link')) {
|
|
43
|
+
setExpandedState(false);
|
|
44
|
+
setLastClickedElement(null);
|
|
45
|
+
if (expanded) {
|
|
46
|
+
onHeaderPanelFocus();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
eventHandlers.onKeyDown = event => {
|
|
51
|
+
if (match(event, Escape)) {
|
|
52
|
+
setExpandedState(false);
|
|
53
|
+
onHeaderPanelFocus();
|
|
54
|
+
if (href) {
|
|
55
|
+
window.location.href = href;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
useWindowEvent('click', () => {
|
|
61
|
+
const focusedElement = document.activeElement;
|
|
62
|
+
setLastClickedElement(focusedElement);
|
|
63
|
+
if (children.type.__docgenInfo.displayName === 'Switcher' && !focusedElement?.closest(`.${prefix}--header-panel--expanded`) && !focusedElement?.closest(`.${prefix}--header__action`) && !headerPanelRef?.current?.classList.contains(`${prefix}--switcher`) && expanded) {
|
|
64
|
+
setExpandedState(false);
|
|
65
|
+
onHeaderPanelFocus();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
26
68
|
return /*#__PURE__*/React__default.createElement("div", _extends({}, other, {
|
|
27
69
|
className: className,
|
|
28
|
-
ref:
|
|
29
|
-
}), children);
|
|
70
|
+
ref: headerPanelRef
|
|
71
|
+
}, eventHandlers), children);
|
|
30
72
|
});
|
|
31
73
|
HeaderPanel.propTypes = {
|
|
74
|
+
/**
|
|
75
|
+
* Specify whether focus and blur listeners are added. They are by default.
|
|
76
|
+
*/
|
|
77
|
+
addFocusListeners: PropTypes.bool,
|
|
32
78
|
/**
|
|
33
79
|
* The content that will render inside of the `HeaderPanel`
|
|
34
80
|
*/
|
|
@@ -40,7 +86,17 @@ HeaderPanel.propTypes = {
|
|
|
40
86
|
/**
|
|
41
87
|
* Specify whether the panel is expanded
|
|
42
88
|
*/
|
|
43
|
-
expanded: PropTypes.bool
|
|
89
|
+
expanded: PropTypes.bool,
|
|
90
|
+
/**
|
|
91
|
+
* Provide the `href` to the id of the element on your package that could
|
|
92
|
+
* be target.
|
|
93
|
+
*/
|
|
94
|
+
href: PropTypes.string,
|
|
95
|
+
/**
|
|
96
|
+
* An optional listener that is called a callback to collapse the HeaderPanel
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
onHeaderPanelFocus: PropTypes.func
|
|
44
100
|
};
|
|
45
101
|
HeaderPanel.displayName = 'HeaderPanel';
|
|
46
102
|
var HeaderPanel$1 = HeaderPanel;
|
|
@@ -20,5 +20,5 @@ interface SideNavProps extends ComponentProps<'nav'> {
|
|
|
20
20
|
onSideNavBlur?: () => void | undefined;
|
|
21
21
|
enterDelayMs?: number;
|
|
22
22
|
}
|
|
23
|
-
declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "
|
|
23
|
+
declare const SideNav: React.ForwardRefExoticComponent<Pick<SideNavProps, "children" | "slot" | "style" | "title" | "className" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "onToggle" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "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" | "enterDelayMs" | "defaultExpanded" | "addFocusListeners" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addMouseListeners" | "onOverlayClick" | "onSideNavBlur"> & React.RefAttributes<HTMLElement>>;
|
|
24
24
|
export default SideNav;
|
|
@@ -6,19 +6,23 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default from 'react';
|
|
9
|
+
import React__default, { useRef } from 'react';
|
|
10
10
|
import cx from 'classnames';
|
|
11
11
|
import PropTypes from 'prop-types';
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
13
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
14
|
+
import { useMergedRefs } from '../../internal/useMergedRefs.js';
|
|
14
15
|
|
|
15
|
-
const Switcher = /*#__PURE__*/React__default.forwardRef(function Switcher(props,
|
|
16
|
+
const Switcher = /*#__PURE__*/React__default.forwardRef(function Switcher(props, forwardRef) {
|
|
17
|
+
const switcherRef = useRef(null);
|
|
18
|
+
const ref = useMergedRefs([switcherRef, forwardRef]);
|
|
16
19
|
const prefix = usePrefix();
|
|
17
20
|
const {
|
|
18
21
|
'aria-label': ariaLabel,
|
|
19
22
|
'aria-labelledby': ariaLabelledBy,
|
|
20
23
|
className: customClassName,
|
|
21
|
-
children
|
|
24
|
+
children,
|
|
25
|
+
expanded
|
|
22
26
|
} = props;
|
|
23
27
|
const accessibilityLabel = {
|
|
24
28
|
'aria-label': ariaLabel,
|
|
@@ -27,10 +31,42 @@ const Switcher = /*#__PURE__*/React__default.forwardRef(function Switcher(props,
|
|
|
27
31
|
const className = cx(`${prefix}--switcher`, {
|
|
28
32
|
[customClassName]: !!customClassName
|
|
29
33
|
});
|
|
34
|
+
const handleSwitcherItemFocus = _ref => {
|
|
35
|
+
let {
|
|
36
|
+
currentIndex,
|
|
37
|
+
direction
|
|
38
|
+
} = _ref;
|
|
39
|
+
const enabledIndices = React__default.Children.toArray(children).reduce((acc, curr, i) => {
|
|
40
|
+
if (Object.keys(curr.props).length !== 0) {
|
|
41
|
+
acc.push(i);
|
|
42
|
+
}
|
|
43
|
+
return acc;
|
|
44
|
+
}, []);
|
|
45
|
+
const nextValidIndex = (() => {
|
|
46
|
+
const nextIndex = enabledIndices.indexOf(currentIndex) + direction;
|
|
47
|
+
switch (enabledIndices[nextIndex]) {
|
|
48
|
+
case undefined:
|
|
49
|
+
if (direction === -1) {
|
|
50
|
+
return enabledIndices[enabledIndices.length - 1];
|
|
51
|
+
}
|
|
52
|
+
return 0;
|
|
53
|
+
default:
|
|
54
|
+
return enabledIndices[nextIndex];
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
57
|
+
const switcherItem = switcherRef.current.children[nextValidIndex].children[0];
|
|
58
|
+
switcherItem?.focus();
|
|
59
|
+
};
|
|
60
|
+
const childrenWithProps = React__default.Children.toArray(children).map((child, index) => /*#__PURE__*/React__default.cloneElement(child, {
|
|
61
|
+
handleSwitcherItemFocus,
|
|
62
|
+
index,
|
|
63
|
+
key: index,
|
|
64
|
+
expanded
|
|
65
|
+
}));
|
|
30
66
|
return /*#__PURE__*/React__default.createElement("ul", _extends({
|
|
31
67
|
ref: ref,
|
|
32
68
|
className: className
|
|
33
|
-
}, accessibilityLabel),
|
|
69
|
+
}, accessibilityLabel), childrenWithProps);
|
|
34
70
|
});
|
|
35
71
|
Switcher.displayName = 'Switcher';
|
|
36
72
|
Switcher.propTypes = {
|
|
@@ -45,7 +81,11 @@ Switcher.propTypes = {
|
|
|
45
81
|
/**
|
|
46
82
|
* Optionally provide a custom class to apply to the underlying `<ul>` node
|
|
47
83
|
*/
|
|
48
|
-
className: PropTypes.string
|
|
84
|
+
className: PropTypes.string,
|
|
85
|
+
/**
|
|
86
|
+
* Specify whether the panel is expanded
|
|
87
|
+
*/
|
|
88
|
+
expanded: PropTypes.bool
|
|
49
89
|
};
|
|
50
90
|
var Switcher$1 = Switcher;
|
|
51
91
|
|
|
@@ -12,18 +12,24 @@ import PropTypes from 'prop-types';
|
|
|
12
12
|
import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
|
|
13
13
|
import Link from './Link.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { ArrowDown, ArrowUp } from '../../internal/keyboard/keys.js';
|
|
15
17
|
|
|
16
|
-
const SwitcherItem = /*#__PURE__*/React__default.forwardRef(function SwitcherItem(
|
|
17
|
-
|
|
18
|
-
const {
|
|
18
|
+
const SwitcherItem = /*#__PURE__*/React__default.forwardRef(function SwitcherItem(_ref, ref) {
|
|
19
|
+
let {
|
|
19
20
|
'aria-label': ariaLabel,
|
|
20
21
|
'aria-labelledby': ariaLabelledBy,
|
|
21
22
|
className: customClassName,
|
|
22
23
|
children,
|
|
23
24
|
isSelected,
|
|
24
|
-
|
|
25
|
+
expanded,
|
|
26
|
+
tabIndex = expanded ? 0 : -1,
|
|
27
|
+
index,
|
|
28
|
+
handleSwitcherItemFocus,
|
|
29
|
+
onKeyDown = () => {},
|
|
25
30
|
...rest
|
|
26
|
-
} =
|
|
31
|
+
} = _ref;
|
|
32
|
+
const prefix = usePrefix();
|
|
27
33
|
const className = cx(`${prefix}--switcher__item`, {
|
|
28
34
|
[customClassName]: !!customClassName
|
|
29
35
|
});
|
|
@@ -34,9 +40,30 @@ const SwitcherItem = /*#__PURE__*/React__default.forwardRef(function SwitcherIte
|
|
|
34
40
|
const linkClassName = cx(`${prefix}--switcher__item-link`, {
|
|
35
41
|
[`${prefix}--switcher__item-link--selected`]: isSelected
|
|
36
42
|
});
|
|
43
|
+
function setTabFocus(evt) {
|
|
44
|
+
if (match(evt, ArrowDown)) {
|
|
45
|
+
evt.preventDefault();
|
|
46
|
+
handleSwitcherItemFocus?.({
|
|
47
|
+
currentIndex: index,
|
|
48
|
+
direction: 1
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (match(evt, ArrowUp)) {
|
|
52
|
+
evt.preventDefault();
|
|
53
|
+
handleSwitcherItemFocus?.({
|
|
54
|
+
currentIndex: index,
|
|
55
|
+
direction: -1
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
37
59
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
38
60
|
className: className
|
|
39
|
-
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
61
|
+
}, /*#__PURE__*/React__default.createElement(Link, _extends({
|
|
62
|
+
onKeyDown: evt => {
|
|
63
|
+
setTabFocus(evt);
|
|
64
|
+
onKeyDown(evt);
|
|
65
|
+
}
|
|
66
|
+
}, rest, {
|
|
40
67
|
ref: ref,
|
|
41
68
|
className: linkClassName,
|
|
42
69
|
tabIndex: tabIndex
|
|
@@ -56,6 +83,18 @@ SwitcherItem.propTypes = {
|
|
|
56
83
|
* Optionally provide a custom class to apply to the underlying `<li>` node
|
|
57
84
|
*/
|
|
58
85
|
className: PropTypes.string,
|
|
86
|
+
/**
|
|
87
|
+
* event handlers
|
|
88
|
+
*/
|
|
89
|
+
handleSwitcherItemFocus: PropTypes.func,
|
|
90
|
+
/**
|
|
91
|
+
* Specify the index of the SwitcherItem
|
|
92
|
+
*/
|
|
93
|
+
index: PropTypes.number,
|
|
94
|
+
/**
|
|
95
|
+
* event handlers
|
|
96
|
+
*/
|
|
97
|
+
onKeyDown: PropTypes.func,
|
|
59
98
|
/**
|
|
60
99
|
* Specify the tab index of the Link
|
|
61
100
|
*/
|
package/es/index.js
CHANGED
|
@@ -6,12 +6,22 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import './feature-flags.js';
|
|
9
|
+
export { default as Accordion } from './components/Accordion/Accordion.js';
|
|
10
|
+
export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
|
|
11
|
+
export { default as AccordionSkeleton } from './components/Accordion/Accordion.Skeleton.js';
|
|
9
12
|
export { default as AspectRatio } from './components/AspectRatio/AspectRatio.js';
|
|
13
|
+
export { default as Button, ButtonKinds, ButtonSizes, ButtonTooltipAlignments, ButtonTooltipPositions } from './components/Button/Button.js';
|
|
14
|
+
export { default as ButtonSkeleton } from './components/Button/Button.Skeleton.js';
|
|
15
|
+
export { default as ButtonSet } from './components/ButtonSet/ButtonSet.js';
|
|
10
16
|
export { default as Checkbox } from './components/Checkbox/Checkbox.js';
|
|
11
17
|
export { default as CheckboxSkeleton } from './components/Checkbox/Checkbox.Skeleton.js';
|
|
12
18
|
export { ClassPrefix } from './components/ClassPrefix/index.js';
|
|
13
19
|
export { ComboButton } from './components/ComboButton/index.js';
|
|
20
|
+
export { default as ComposedModal, ModalBody } from './components/ComposedModal/ComposedModal.js';
|
|
21
|
+
export { ModalHeader } from './components/ComposedModal/ModalHeader.js';
|
|
22
|
+
export { ModalFooter } from './components/ComposedModal/ModalFooter.js';
|
|
14
23
|
export { default as ContentSwitcher } from './components/ContentSwitcher/index.js';
|
|
24
|
+
export { default as DangerButton } from './components/DangerButton/DangerButton.js';
|
|
15
25
|
import './components/DataTable/index.js';
|
|
16
26
|
export { default as DataTableSkeleton } from './components/DataTableSkeleton/DataTableSkeleton.js';
|
|
17
27
|
export { default as DatePicker } from './components/DatePicker/DatePicker.js';
|
|
@@ -31,17 +41,23 @@ export { IdPrefix } from './components/IdPrefix/index.js';
|
|
|
31
41
|
export { default as Link } from './components/Link/Link.js';
|
|
32
42
|
export { default as ListItem } from './components/ListItem/ListItem.js';
|
|
33
43
|
export { MenuButton } from './components/MenuButton/index.js';
|
|
44
|
+
export { ActionableNotification, InlineNotification, NotificationActionButton, NotificationButton, ToastNotification } from './components/Notification/Notification.js';
|
|
34
45
|
export { default as OrderedList } from './components/OrderedList/OrderedList.js';
|
|
35
46
|
export { default as OverflowMenu } from './components/OverflowMenu/index.js';
|
|
36
47
|
export { default as PaginationSkeleton } from './components/Pagination/Pagination.Skeleton.js';
|
|
37
48
|
export { default as RadioButtonSkeleton } from './components/RadioButton/RadioButton.Skeleton.js';
|
|
38
49
|
export { default as Search } from './components/Search/Search.js';
|
|
39
50
|
export { default as SearchSkeleton } from './components/Search/Search.Skeleton.js';
|
|
51
|
+
export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
|
|
40
52
|
export { default as Slider } from './components/Slider/index.js';
|
|
53
|
+
export { IconTab, Tab, TabList, TabPanel, TabPanels, Tabs } from './components/Tabs/Tabs.js';
|
|
54
|
+
export { default as TabContent } from './components/TabContent/TabContent.js';
|
|
55
|
+
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
41
56
|
export { default as TagSkeleton } from './components/Tag/Tag.Skeleton.js';
|
|
42
57
|
export { default as TextArea } from './components/TextArea/TextArea.js';
|
|
43
58
|
export { default as TextAreaSkeleton } from './components/TextArea/TextArea.Skeleton.js';
|
|
44
59
|
import './components/TextInput/index.js';
|
|
60
|
+
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent } from './components/Tile/Tile.js';
|
|
45
61
|
export { default as TileGroup } from './components/TileGroup/index.js';
|
|
46
62
|
export { default as ToggleSkeleton } from './components/Toggle/Toggle.Skeleton.js';
|
|
47
63
|
export { default as ToggleSmallSkeleton } from './components/ToggleSmall/ToggleSmall.Skeleton.js';
|
|
@@ -68,9 +84,6 @@ export { default as unstable__FluidTextInput } from './components/FluidTextInput
|
|
|
68
84
|
export { default as unstable__FluidTextInputSkeleton } from './components/FluidTextInput/FluidTextInput.Skeleton.js';
|
|
69
85
|
export { default as unstable_PageSelector } from './components/Pagination/experimental/PageSelector.js';
|
|
70
86
|
export { default as unstable_Pagination } from './components/Pagination/experimental/Pagination.js';
|
|
71
|
-
export { default as AccordionItem } from './components/Accordion/AccordionItem.js';
|
|
72
|
-
export { default as AccordionSkeleton } from './components/Accordion/Accordion.Skeleton.js';
|
|
73
|
-
export { default as Accordion } from './components/Accordion/Accordion.js';
|
|
74
87
|
export { default as BreadcrumbSkeleton } from './components/Breadcrumb/Breadcrumb.Skeleton.js';
|
|
75
88
|
export { default as CheckboxGroup } from './components/CheckboxGroup/CheckboxGroup.js';
|
|
76
89
|
export { default as CodeSnippetSkeleton } from './components/CodeSnippet/CodeSnippet.Skeleton.js';
|
|
@@ -95,7 +108,6 @@ export { default as Loading } from './components/Loading/Loading.js';
|
|
|
95
108
|
export { default as ModalWrapper } from './components/ModalWrapper/ModalWrapper.js';
|
|
96
109
|
export { default as NumberInputSkeleton } from './components/NumberInput/NumberInput.Skeleton.js';
|
|
97
110
|
export { default as ProgressIndicatorSkeleton } from './components/ProgressIndicator/ProgressIndicator.Skeleton.js';
|
|
98
|
-
export { default as TabsSkeleton } from './components/Tabs/Tabs.Skeleton.js';
|
|
99
111
|
export { default as TextInputSkeleton } from './components/TextInput/TextInput.Skeleton.js';
|
|
100
112
|
export { default as TextInput } from './components/TextInput/TextInput.js';
|
|
101
113
|
export { Toggle } from './components/Toggle/Toggle.js';
|
|
@@ -132,14 +144,7 @@ export { Text as unstable_Text } from './components/Text/Text.js';
|
|
|
132
144
|
export { TextDirection as unstable_TextDirection } from './components/Text/TextDirection.js';
|
|
133
145
|
export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
|
|
134
146
|
export { default as BreadcrumbItem } from './components/Breadcrumb/BreadcrumbItem.js';
|
|
135
|
-
export { default as ButtonSkeleton } from './components/Button/Button.Skeleton.js';
|
|
136
|
-
export { default as Button } from './components/Button/Button.js';
|
|
137
|
-
export { default as ButtonSet } from './components/ButtonSet/ButtonSet.js';
|
|
138
147
|
export { default as ComboBox } from './components/ComboBox/ComboBox.js';
|
|
139
|
-
export { default as ComposedModal, ModalBody } from './components/ComposedModal/ComposedModal.js';
|
|
140
|
-
export { ModalFooter } from './components/ComposedModal/ModalFooter.js';
|
|
141
|
-
export { ModalHeader } from './components/ComposedModal/ModalHeader.js';
|
|
142
|
-
export { default as DangerButton } from './components/DangerButton/DangerButton.js';
|
|
143
148
|
export { default as DataTable } from './components/DataTable/DataTable.js';
|
|
144
149
|
export { Table } from './components/DataTable/Table.js';
|
|
145
150
|
export { default as TableActionList } from './components/DataTable/TableActionList.js';
|
|
@@ -169,7 +174,6 @@ export { Menu } from './components/Menu/Menu.js';
|
|
|
169
174
|
export { MenuItem, MenuItemDivider, MenuItemGroup, MenuItemRadioGroup, MenuItemSelectable } from './components/Menu/MenuItem.js';
|
|
170
175
|
export { default as Modal } from './components/Modal/Modal.js';
|
|
171
176
|
export { default as MultiSelect } from './components/MultiSelect/MultiSelect.js';
|
|
172
|
-
export { ActionableNotification, InlineNotification, NotificationActionButton, NotificationButton, ToastNotification } from './components/Notification/Notification.js';
|
|
173
177
|
export { NumberInput } from './components/NumberInput/NumberInput.js';
|
|
174
178
|
export { default as OverflowMenuItem } from './components/OverflowMenuItem/OverflowMenuItem.js';
|
|
175
179
|
export { default as Pagination } from './components/Pagination/Pagination.js';
|
|
@@ -188,16 +192,12 @@ export { default as SelectItem } from './components/SelectItem/SelectItem.js';
|
|
|
188
192
|
export { default as SelectItemGroup } from './components/SelectItemGroup/SelectItemGroup.js';
|
|
189
193
|
export { default as SkeletonIcon } from './components/SkeletonIcon/SkeletonIcon.js';
|
|
190
194
|
export { default as SkeletonPlaceholder } from './components/SkeletonPlaceholder/SkeletonPlaceholder.js';
|
|
191
|
-
export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
|
|
192
195
|
export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.js';
|
|
193
196
|
export { default as StructuredListSkeleton } from './components/StructuredList/StructuredList.Skeleton.js';
|
|
194
197
|
export { StructuredListBody, StructuredListCell, StructuredListHead, StructuredListInput, StructuredListRow, StructuredListWrapper } from './components/StructuredList/StructuredList.js';
|
|
195
198
|
export { default as Switch } from './components/Switch/Switch.js';
|
|
196
199
|
export { default as IconSwitch } from './components/Switch/IconSwitch.js';
|
|
197
|
-
export { IconTab, Tab, TabList, TabPanel, TabPanels, Tabs } from './components/Tabs/Tabs.js';
|
|
198
|
-
export { default as TabContent } from './components/TabContent/TabContent.js';
|
|
199
200
|
export { default as Tag, types } from './components/Tag/Tag.js';
|
|
200
|
-
export { ClickableTile, ExpandableTile, SelectableTile, Tile, TileAboveTheFoldContent, TileBelowTheFoldContent } from './components/Tile/Tile.js';
|
|
201
201
|
export { default as TimePicker } from './components/TimePicker/TimePicker.js';
|
|
202
202
|
export { default as TimePickerSelect } from './components/TimePickerSelect/TimePickerSelect.js';
|
|
203
203
|
export { default as Content } from './components/UIShell/Content.js';
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* }
|
|
27
27
|
* }
|
|
28
28
|
*
|
|
29
|
-
* @param {Event} event
|
|
29
|
+
* @param {Event|React.SyntheticEvent} event
|
|
30
30
|
* @param {Array<Key>} keysToMatch
|
|
31
31
|
* @returns {boolean}
|
|
32
32
|
*/
|
|
@@ -53,7 +53,7 @@ function matches(event, keysToMatch) {
|
|
|
53
53
|
* }
|
|
54
54
|
* }
|
|
55
55
|
*
|
|
56
|
-
* @param {React.
|
|
56
|
+
* @param {React.SyntheticEvent|Event|number|string} eventOrCode
|
|
57
57
|
* @param {Key} key
|
|
58
58
|
* @returns {boolean}
|
|
59
59
|
*/
|
|
@@ -19,7 +19,7 @@ import { warning } from './warning.js';
|
|
|
19
19
|
* uncontrolled, or vice-versa.
|
|
20
20
|
*
|
|
21
21
|
* @param {object} config
|
|
22
|
-
* @param {string} config.name - the name of the custom component
|
|
22
|
+
* @param {string} [config.name] - the name of the custom component
|
|
23
23
|
* @param {any} config.defaultValue - the default value used for the state. This will be
|
|
24
24
|
* the fallback value used if `value` is not defined.
|
|
25
25
|
* @param {Function} config.onChange - an optional function that is called when
|
|
@@ -27,7 +27,7 @@ import { warning } from './warning.js';
|
|
|
27
27
|
* controlled components that the value is requesting to be changed.
|
|
28
28
|
* @param {any} config.value - a controlled value. Omitting this means that the state is
|
|
29
29
|
* uncontrolled
|
|
30
|
-
* @returns {[any,
|
|
30
|
+
* @returns {[any, (v: any) => void]}
|
|
31
31
|
*/
|
|
32
32
|
function useControllableState(_ref) {
|
|
33
33
|
let {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useState, useEffect } from 'react';
|
|
9
|
+
import { canUseDOM } from './environment.js';
|
|
10
|
+
|
|
11
|
+
function useMatchMedia(mediaQueryString) {
|
|
12
|
+
const [matches, setMatches] = useState(() => {
|
|
13
|
+
if (canUseDOM) {
|
|
14
|
+
const mediaQueryList = window.matchMedia(mediaQueryString);
|
|
15
|
+
return mediaQueryList.matches;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
});
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
function listener(event) {
|
|
21
|
+
setMatches(event.matches);
|
|
22
|
+
}
|
|
23
|
+
const mediaQueryList = window.matchMedia(mediaQueryString);
|
|
24
|
+
// Support fallback to `addListener` for broader browser support
|
|
25
|
+
if (mediaQueryList.addEventListener) {
|
|
26
|
+
mediaQueryList.addEventListener('change', listener);
|
|
27
|
+
} else {
|
|
28
|
+
mediaQueryList.addListener(listener);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Make sure the media query list is in sync with the matches state
|
|
32
|
+
setMatches(mediaQueryList.matches);
|
|
33
|
+
return () => {
|
|
34
|
+
if (mediaQueryList.addEventListener) {
|
|
35
|
+
mediaQueryList.removeEventListener('change', listener);
|
|
36
|
+
} else {
|
|
37
|
+
mediaQueryList.removeListener(listener);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
}, [mediaQueryString]);
|
|
41
|
+
return matches;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { useMatchMedia };
|
package/es/internal/wrapFocus.js
CHANGED
|
@@ -24,12 +24,12 @@ function elementOrParentIsFloatingMenu(node) {
|
|
|
24
24
|
/**
|
|
25
25
|
* Ensures the focus is kept in the given `modalNode`, implementing "focus-wrap" behavior.
|
|
26
26
|
* @param {object} options The options.
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
27
|
+
* @param {HTMLElement|null} options.bodyNode
|
|
28
|
+
* @param {HTMLElement|null} options.startTrapNode The DOM node of the focus sentinel the is placed earlier next to `modalNode`.
|
|
29
|
+
* @param {HTMLElement|null} options.endTrapNode The DOM node of the focus sentinel the is placed next to `modalNode`.
|
|
30
|
+
* @param {HTMLElement} options.currentActiveNode The DOM node that has focus.
|
|
31
|
+
* @param {HTMLElement} options.oldActiveNode The DOM node that previously had focus.
|
|
32
|
+
* @param {string[]} [options.selectorsFloatingMenus] The CSS selectors that matches floating menus.
|
|
33
33
|
*/
|
|
34
34
|
function wrapFocus(_ref) {
|
|
35
35
|
let {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @param {
|
|
9
|
+
* @param {string} name The name of the prop that must exist to validate
|
|
10
10
|
* the current prop.
|
|
11
11
|
* @param {Function} propType The original prop type checker.
|
|
12
12
|
* @returns {Function} The new prop type checker for the current prop that
|
package/es/prop-types/types.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use ButtonKinds export from Button component instead
|
|
10
|
+
*/
|
|
8
11
|
const ButtonKinds = ['primary', 'secondary', 'danger', 'ghost', 'danger--primary', 'danger--ghost', 'danger--tertiary', 'tertiary'];
|
|
9
12
|
|
|
10
13
|
export { ButtonKinds };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
/// <reference types="react" />
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
interface AccordionSkeletonProps {
|
|
10
|
+
/**
|
|
11
|
+
* Specify the alignment of the accordion heading
|
|
12
|
+
* title and chevron.
|
|
13
|
+
*/
|
|
14
|
+
align?: 'start' | 'end';
|
|
15
|
+
/**
|
|
16
|
+
* Specify an optional className to add.
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Set number of items to render.
|
|
21
|
+
*/
|
|
22
|
+
count?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Specify whether an individual AccordionItem should
|
|
25
|
+
* be flush, default is false.
|
|
26
|
+
*/
|
|
27
|
+
isFlush?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* `false` to not display the first item opened.
|
|
30
|
+
*/
|
|
31
|
+
open?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare function AccordionSkeleton({ align, className, count, isFlush, open, ...rest }: AccordionSkeletonProps): JSX.Element;
|
|
34
|
+
declare namespace AccordionSkeleton {
|
|
35
|
+
var propTypes: {
|
|
36
|
+
/**
|
|
37
|
+
* Specify the alignment of the accordion heading title and chevron.
|
|
38
|
+
*/
|
|
39
|
+
align: PropTypes.Requireable<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Specify an optional className to add.
|
|
42
|
+
*/
|
|
43
|
+
className: PropTypes.Requireable<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Set number of items to render
|
|
46
|
+
*/
|
|
47
|
+
count: PropTypes.Requireable<number>;
|
|
48
|
+
/**
|
|
49
|
+
* Specify whether an individual AccordionItem should be flush, default is false
|
|
50
|
+
*/
|
|
51
|
+
isFlush: PropTypes.Requireable<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* `false` to not display the first item opened
|
|
54
|
+
*/
|
|
55
|
+
open: PropTypes.Requireable<boolean>;
|
|
56
|
+
};
|
|
57
|
+
var defaultProps: {
|
|
58
|
+
open: boolean;
|
|
59
|
+
count: number;
|
|
60
|
+
align: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export default AccordionSkeleton;
|
|
64
|
+
export { AccordionSkeleton };
|
|
@@ -26,11 +26,11 @@ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
|
|
|
26
26
|
var _SkeletonText, _SkeletonText2, _SkeletonText3;
|
|
27
27
|
function AccordionSkeleton(_ref) {
|
|
28
28
|
let {
|
|
29
|
-
align,
|
|
29
|
+
align = 'end',
|
|
30
30
|
className,
|
|
31
|
-
count,
|
|
31
|
+
count = 4,
|
|
32
32
|
isFlush,
|
|
33
|
-
open,
|
|
33
|
+
open = true,
|
|
34
34
|
...rest
|
|
35
35
|
} = _ref;
|
|
36
36
|
const prefix = usePrefix.usePrefix();
|