@carbon/react 1.28.0 → 1.29.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/Checkbox/Checkbox.d.ts +2 -2
- package/es/components/Heading/index.d.ts +51 -0
- package/es/components/Heading/index.js +5 -9
- package/es/components/Slider/Slider.d.ts +26 -2
- package/es/components/Slider/Slider.js +36 -8
- package/es/components/StructuredList/StructuredList.Skeleton.js +2 -10
- package/es/components/StructuredList/StructuredList.js +2 -2
- package/es/components/Theme/index.d.ts +62 -0
- package/es/components/Theme/index.js +4 -4
- package/es/components/UIShell/HeaderContainer.js +8 -0
- package/es/components/UIShell/HeaderMenuButton.d.ts +38 -0
- package/es/components/UIShell/HeaderMenuButton.js +7 -12
- package/es/components/UIShell/HeaderNavigation.d.ts +24 -0
- package/es/components/UIShell/HeaderNavigation.js +8 -13
- package/es/components/UIShell/HeaderSideNavItems.d.ts +33 -0
- package/es/components/UIShell/HeaderSideNavItems.js +4 -9
- package/es/components/UIShell/SideNav.d.ts +21 -0
- package/es/components/UIShell/SideNav.js +37 -38
- package/es/index.js +1 -1
- package/es/types/common.d.ts +11 -0
- package/lib/components/Checkbox/Checkbox.d.ts +2 -2
- package/lib/components/Heading/index.d.ts +51 -0
- package/lib/components/Heading/index.js +5 -9
- package/lib/components/Slider/Slider.d.ts +26 -2
- package/lib/components/Slider/Slider.js +36 -8
- package/lib/components/StructuredList/StructuredList.Skeleton.js +2 -10
- package/lib/components/StructuredList/StructuredList.js +2 -2
- package/lib/components/Theme/index.d.ts +62 -0
- package/lib/components/Theme/index.js +4 -4
- package/lib/components/UIShell/HeaderContainer.js +8 -0
- package/lib/components/UIShell/HeaderMenuButton.d.ts +38 -0
- package/lib/components/UIShell/HeaderMenuButton.js +7 -12
- package/lib/components/UIShell/HeaderNavigation.d.ts +24 -0
- package/lib/components/UIShell/HeaderNavigation.js +7 -13
- package/lib/components/UIShell/HeaderSideNavItems.d.ts +33 -0
- package/lib/components/UIShell/HeaderSideNavItems.js +4 -9
- package/lib/components/UIShell/SideNav.d.ts +21 -0
- package/lib/components/UIShell/SideNav.js +36 -37
- package/lib/index.js +2 -2
- package/lib/types/common.d.ts +11 -0
- package/package.json +4 -4
|
@@ -0,0 +1,21 @@
|
|
|
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, { type ComponentProps, type FocusEvent, type KeyboardEvent, type MouseEventHandler } from 'react';
|
|
8
|
+
interface SideNavProps extends ComponentProps<'nav'> {
|
|
9
|
+
expanded?: boolean | undefined;
|
|
10
|
+
defaultExpanded?: boolean | undefined;
|
|
11
|
+
isChildOfHeader?: boolean | undefined;
|
|
12
|
+
onToggle?: (event: FocusEvent<HTMLElement> | KeyboardEvent<HTMLElement> | boolean, value: boolean) => void | undefined;
|
|
13
|
+
isFixedNav?: boolean | undefined;
|
|
14
|
+
isRail?: boolean | undefined;
|
|
15
|
+
isPersistent?: boolean | undefined;
|
|
16
|
+
addFocusListeners?: boolean | undefined;
|
|
17
|
+
addMouseListeners?: boolean | undefined;
|
|
18
|
+
onOverlayClick?: MouseEventHandler<HTMLDivElement> | undefined;
|
|
19
|
+
}
|
|
20
|
+
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" | "expanded" | "defaultExpanded" | "isChildOfHeader" | "isFixedNav" | "isRail" | "isPersistent" | "addFocusListeners" | "addMouseListeners" | "onOverlayClick"> & React.RefAttributes<HTMLElement>>;
|
|
21
|
+
export default SideNav;
|
|
@@ -6,35 +6,37 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
9
|
-
import React__default, { useRef, useState } from 'react';
|
|
9
|
+
import React__default, { useRef, useState, 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';
|
|
13
13
|
import { CARBON_SIDENAV_ITEMS } from './_utils.js';
|
|
14
14
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
15
|
+
import { match } from '../../internal/keyboard/match.js';
|
|
16
|
+
import { Escape } from '../../internal/keyboard/keys.js';
|
|
15
17
|
|
|
16
18
|
// import SideNavFooter from './SideNavFooter';
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
function SideNavRenderFunction(_ref, ref) {
|
|
21
|
+
let {
|
|
20
22
|
expanded: expandedProp,
|
|
21
|
-
defaultExpanded,
|
|
22
|
-
isChildOfHeader,
|
|
23
|
+
defaultExpanded = false,
|
|
24
|
+
isChildOfHeader = true,
|
|
23
25
|
'aria-label': ariaLabel,
|
|
24
26
|
'aria-labelledby': ariaLabelledBy,
|
|
25
27
|
children,
|
|
26
28
|
onToggle,
|
|
27
29
|
className: customClassName,
|
|
28
30
|
// TO-DO: comment back in when footer is added for rails
|
|
29
|
-
// translateById: t,
|
|
30
|
-
isFixedNav,
|
|
31
|
+
// translateById: t = (id) => translations[id],
|
|
32
|
+
isFixedNav = false,
|
|
31
33
|
isRail,
|
|
32
|
-
isPersistent,
|
|
33
|
-
addFocusListeners,
|
|
34
|
-
addMouseListeners,
|
|
34
|
+
isPersistent = true,
|
|
35
|
+
addFocusListeners = true,
|
|
36
|
+
addMouseListeners = true,
|
|
35
37
|
onOverlayClick,
|
|
36
38
|
...other
|
|
37
|
-
} =
|
|
39
|
+
} = _ref;
|
|
38
40
|
const prefix = usePrefix();
|
|
39
41
|
const {
|
|
40
42
|
current: controlled
|
|
@@ -67,12 +69,11 @@ const SideNav = /*#__PURE__*/React__default.forwardRef(function SideNav(props, r
|
|
|
67
69
|
// ? t('carbon.sidenav.state.open')
|
|
68
70
|
// : t('carbon.sidenav.state.closed');
|
|
69
71
|
|
|
70
|
-
const className = cx({
|
|
72
|
+
const className = cx(customClassName, {
|
|
71
73
|
[`${prefix}--side-nav`]: true,
|
|
72
74
|
[`${prefix}--side-nav--expanded`]: expanded || expandedViaHoverState,
|
|
73
75
|
[`${prefix}--side-nav--collapsed`]: !expanded && isFixedNav,
|
|
74
76
|
[`${prefix}--side-nav--rail`]: isRail,
|
|
75
|
-
[customClassName]: !!customClassName,
|
|
76
77
|
[`${prefix}--side-nav--ux`]: isChildOfHeader,
|
|
77
78
|
[`${prefix}--side-nav--hidden`]: !isPersistent
|
|
78
79
|
});
|
|
@@ -84,19 +85,25 @@ const SideNav = /*#__PURE__*/React__default.forwardRef(function SideNav(props, r
|
|
|
84
85
|
|
|
85
86
|
if (isRail) {
|
|
86
87
|
childrenToRender = React__default.Children.map(children, child => {
|
|
87
|
-
var _child$type, _child$type2;
|
|
88
|
-
|
|
89
88
|
// if we are controlled, check for if we have hovered over or the expanded state, else just use the expanded state (uncontrolled)
|
|
90
|
-
|
|
89
|
+
const currentExpansionState = controlled ? expandedViaHoverState || expanded : expanded;
|
|
90
|
+
|
|
91
|
+
if ( /*#__PURE__*/isValidElement(child)) {
|
|
92
|
+
var _childJsxElement$type, _childJsxElement$type2;
|
|
93
|
+
|
|
94
|
+
const childJsxElement = child; // avoid spreading `isSideNavExpanded` to non-Carbon UI Shell children
|
|
95
|
+
|
|
96
|
+
return /*#__PURE__*/React__default.cloneElement(childJsxElement, { ...(CARBON_SIDENAV_ITEMS.includes(((_childJsxElement$type = childJsxElement.type) === null || _childJsxElement$type === void 0 ? void 0 : _childJsxElement$type.displayName) ?? ((_childJsxElement$type2 = childJsxElement.type) === null || _childJsxElement$type2 === void 0 ? void 0 : _childJsxElement$type2.name)) ? {
|
|
97
|
+
isSideNavExpanded: currentExpansionState
|
|
98
|
+
} : {})
|
|
99
|
+
});
|
|
100
|
+
}
|
|
91
101
|
|
|
92
|
-
return
|
|
93
|
-
isSideNavExpanded: currentExpansionState
|
|
94
|
-
} : {})
|
|
95
|
-
});
|
|
102
|
+
return child;
|
|
96
103
|
});
|
|
97
104
|
}
|
|
98
105
|
|
|
99
|
-
|
|
106
|
+
const eventHandlers = {};
|
|
100
107
|
|
|
101
108
|
if (addFocusListeners) {
|
|
102
109
|
eventHandlers.onFocus = event => {
|
|
@@ -110,6 +117,12 @@ const SideNav = /*#__PURE__*/React__default.forwardRef(function SideNav(props, r
|
|
|
110
117
|
handleToggle(event, false);
|
|
111
118
|
}
|
|
112
119
|
};
|
|
120
|
+
|
|
121
|
+
eventHandlers.onKeyDown = event => {
|
|
122
|
+
if (match(event, Escape)) {
|
|
123
|
+
handleToggle(event, false);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
113
126
|
}
|
|
114
127
|
|
|
115
128
|
if (addMouseListeners && isRail) {
|
|
@@ -128,24 +141,10 @@ const SideNav = /*#__PURE__*/React__default.forwardRef(function SideNav(props, r
|
|
|
128
141
|
ref: ref,
|
|
129
142
|
className: `${prefix}--side-nav__navigation ${className}`
|
|
130
143
|
}, accessibilityLabel, eventHandlers, other), childrenToRender));
|
|
131
|
-
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const SideNav = /*#__PURE__*/React__default.forwardRef(SideNavRenderFunction);
|
|
132
147
|
SideNav.displayName = 'SideNav';
|
|
133
|
-
SideNav.defaultProps = {
|
|
134
|
-
// TO-DO: comment back in when footer is added for rails
|
|
135
|
-
// translateById: (id) => {
|
|
136
|
-
// const translations = {
|
|
137
|
-
// 'carbon.sidenav.state.open': 'Close',
|
|
138
|
-
// 'carbon.sidenav.state.closed': 'Open',
|
|
139
|
-
// };
|
|
140
|
-
// return translations[id];
|
|
141
|
-
// },
|
|
142
|
-
defaultExpanded: false,
|
|
143
|
-
isChildOfHeader: true,
|
|
144
|
-
isFixedNav: false,
|
|
145
|
-
isPersistent: true,
|
|
146
|
-
addFocusListeners: true,
|
|
147
|
-
addMouseListeners: true
|
|
148
|
-
};
|
|
149
148
|
SideNav.propTypes = {
|
|
150
149
|
/**
|
|
151
150
|
* Required props for accessibility label on the underlying menu
|
package/es/index.js
CHANGED
|
@@ -94,6 +94,7 @@ export { default as TreeView } from './components/TreeView/TreeView.js';
|
|
|
94
94
|
export { default as HeaderMenuButton } from './components/UIShell/HeaderMenuButton.js';
|
|
95
95
|
export { default as HeaderName } from './components/UIShell/HeaderName.js';
|
|
96
96
|
export { default as HeaderNavigation } from './components/UIShell/HeaderNavigation.js';
|
|
97
|
+
export { default as HeaderSideNavItems } from './components/UIShell/HeaderSideNavItems.js';
|
|
97
98
|
export { default as SkipToContent } from './components/UIShell/SkipToContent.js';
|
|
98
99
|
export { default as SideNavDivider } from './components/UIShell/SideNavDivider.js';
|
|
99
100
|
export { default as SideNavFooter } from './components/UIShell/SideNavFooter.js';
|
|
@@ -205,7 +206,6 @@ export { default as HeaderGlobalBar } from './components/UIShell/HeaderGlobalBar
|
|
|
205
206
|
export { default as HeaderMenu } from './components/UIShell/HeaderMenu.js';
|
|
206
207
|
export { default as HeaderMenuItem } from './components/UIShell/HeaderMenuItem.js';
|
|
207
208
|
export { default as HeaderPanel } from './components/UIShell/HeaderPanel.js';
|
|
208
|
-
export { default as HeaderSideNavItems } from './components/UIShell/HeaderSideNavItems.js';
|
|
209
209
|
export { default as Switcher } from './components/UIShell/Switcher.js';
|
|
210
210
|
export { default as SwitcherItem } from './components/UIShell/SwitcherItem.js';
|
|
211
211
|
export { default as SwitcherDivider } from './components/UIShell/SwitcherDivider.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ReactAttr<T = HTMLElement> = React.HTMLAttributes<T>;
|
|
3
|
+
export type ForwardRefProps<T, P = unknown> = React.PropsWithoutRef<React.PropsWithChildren<P>> & React.RefAttributes<T>;
|
|
4
|
+
export type ForwardRefReturn<T, P = unknown> = React.ForwardRefExoticComponent<ForwardRefProps<T, P>>;
|
|
5
|
+
/**
|
|
6
|
+
* For "as" props. Creates an "as" property that supports native html tags such as 'span', 'a', 'button' as well as custom functional components
|
|
7
|
+
* All native props for the supplied html tag/component are inferred as part of the base component props, allowing us to use props like `href` on an 'a' element ect
|
|
8
|
+
*/
|
|
9
|
+
export type PolymorphicProps<Element extends React.ElementType, Props> = Props & Omit<React.ComponentProps<Element>, 'as'> & {
|
|
10
|
+
as?: Element;
|
|
11
|
+
};
|
|
@@ -44,7 +44,7 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
44
44
|
/**
|
|
45
45
|
* Provide the text that is displayed when the Checkbox is in an invalid state
|
|
46
46
|
*/
|
|
47
|
-
invalidText
|
|
47
|
+
invalidText?: React.ReactNode;
|
|
48
48
|
/**
|
|
49
49
|
* Specify whether the Checkbox is currently invalid
|
|
50
50
|
*/
|
|
@@ -52,7 +52,7 @@ export interface CheckboxProps extends Omit<React.InputHTMLAttributes<HTMLInputE
|
|
|
52
52
|
/**
|
|
53
53
|
* Provide the text that is displayed when the Checkbox is in an invalid state
|
|
54
54
|
*/
|
|
55
|
-
warnText
|
|
55
|
+
warnText?: React.ReactNode;
|
|
56
56
|
/**
|
|
57
57
|
* Provide an optional handler that is called when the internal state of
|
|
58
58
|
* Checkbox changes. This handler is called with event and state info.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { type ElementType } from 'react';
|
|
9
|
+
import type { PolymorphicProps } from '../../types/common';
|
|
10
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
+
type SectionBaseProps = {
|
|
12
|
+
level?: HeadingLevel;
|
|
13
|
+
};
|
|
14
|
+
type SectionProps<E extends ElementType> = PolymorphicProps<E, SectionBaseProps>;
|
|
15
|
+
export declare function Section<E extends ElementType = 'section'>({ as: BaseComponent, level: levelOverride, ...rest }: SectionProps<E>): JSX.Element;
|
|
16
|
+
export declare namespace Section {
|
|
17
|
+
var propTypes: {
|
|
18
|
+
/**
|
|
19
|
+
* Provide an alternative tag or component to use instead of the default
|
|
20
|
+
* <section> element
|
|
21
|
+
*/
|
|
22
|
+
as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
|
|
23
|
+
/**
|
|
24
|
+
* Specify the content that will be placed in the component
|
|
25
|
+
*/
|
|
26
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
27
|
+
/**
|
|
28
|
+
* Specify a class name for the outermost node of the component
|
|
29
|
+
*/
|
|
30
|
+
className: PropTypes.Requireable<string>;
|
|
31
|
+
/**
|
|
32
|
+
* Overrides the level of the section
|
|
33
|
+
*/
|
|
34
|
+
level: PropTypes.Requireable<number>;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
type HeadingProps = JSX.IntrinsicElements[`h${HeadingLevel}`];
|
|
38
|
+
export declare function Heading(props: HeadingProps): JSX.Element;
|
|
39
|
+
export declare namespace Heading {
|
|
40
|
+
var propTypes: {
|
|
41
|
+
/**
|
|
42
|
+
* Specify the content that will be placed in the component
|
|
43
|
+
*/
|
|
44
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
45
|
+
/**
|
|
46
|
+
* Specify a class name for the outermost node of the component
|
|
47
|
+
*/
|
|
48
|
+
className: PropTypes.Requireable<string>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -18,21 +18,19 @@ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
|
18
18
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
19
19
|
|
|
20
20
|
const HeadingContext = /*#__PURE__*/React__default["default"].createContext(1);
|
|
21
|
-
|
|
22
21
|
function Section(_ref) {
|
|
23
22
|
let {
|
|
24
23
|
as: BaseComponent = 'section',
|
|
25
24
|
level: levelOverride,
|
|
26
|
-
children,
|
|
27
25
|
...rest
|
|
28
26
|
} = _ref;
|
|
29
27
|
const parentLevel = React__default["default"].useContext(HeadingContext);
|
|
30
|
-
const level =
|
|
28
|
+
const level = levelOverride ?? parentLevel + 1;
|
|
29
|
+
const BaseComponentAsAny = BaseComponent;
|
|
31
30
|
return /*#__PURE__*/React__default["default"].createElement(HeadingContext.Provider, {
|
|
32
31
|
value: Math.min(level, 6)
|
|
33
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
32
|
+
}, /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, rest));
|
|
34
33
|
}
|
|
35
|
-
|
|
36
34
|
Section.propTypes = {
|
|
37
35
|
/**
|
|
38
36
|
* Provide an alternative tag or component to use instead of the default
|
|
@@ -55,12 +53,10 @@ Section.propTypes = {
|
|
|
55
53
|
*/
|
|
56
54
|
level: PropTypes__default["default"].number
|
|
57
55
|
};
|
|
58
|
-
|
|
59
56
|
function Heading(props) {
|
|
60
|
-
const
|
|
61
|
-
return /*#__PURE__*/React__default["default"].createElement(
|
|
57
|
+
const HeadingIntrinsic = `h${React__default["default"].useContext(HeadingContext)}`;
|
|
58
|
+
return /*#__PURE__*/React__default["default"].createElement(HeadingIntrinsic, props);
|
|
62
59
|
}
|
|
63
|
-
|
|
64
60
|
Heading.propTypes = {
|
|
65
61
|
/**
|
|
66
62
|
* Specify the content that will be placed in the component
|
|
@@ -41,9 +41,13 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
41
41
|
*/
|
|
42
42
|
inputType?: string;
|
|
43
43
|
/**
|
|
44
|
-
* `
|
|
44
|
+
* `Specify whether the Slider is currently invalid
|
|
45
45
|
*/
|
|
46
46
|
invalid?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Provide the text that is displayed when the Slider is in an invalid state
|
|
49
|
+
*/
|
|
50
|
+
invalidText?: React.ReactNode;
|
|
47
51
|
/**
|
|
48
52
|
* The label for the slider.
|
|
49
53
|
*/
|
|
@@ -119,6 +123,14 @@ export interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
119
123
|
* The value.
|
|
120
124
|
*/
|
|
121
125
|
value: number;
|
|
126
|
+
/**
|
|
127
|
+
* Specify whether the control is currently in warning state
|
|
128
|
+
*/
|
|
129
|
+
warn?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Provide the text that is displayed when the control is in warning state
|
|
132
|
+
*/
|
|
133
|
+
warnText?: React.ReactNode;
|
|
122
134
|
}
|
|
123
135
|
interface CalcValueProps {
|
|
124
136
|
clientX?: number;
|
|
@@ -160,9 +172,13 @@ export default class Slider extends PureComponent<SliderProps> {
|
|
|
160
172
|
*/
|
|
161
173
|
inputType: PropTypes.Requireable<string>;
|
|
162
174
|
/**
|
|
163
|
-
* `
|
|
175
|
+
* `Specify whether the Slider is currently invalid
|
|
164
176
|
*/
|
|
165
177
|
invalid: PropTypes.Requireable<boolean>;
|
|
178
|
+
/**
|
|
179
|
+
* Provide the text that is displayed when the Slider is in an invalid state
|
|
180
|
+
*/
|
|
181
|
+
invalidText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
166
182
|
/**
|
|
167
183
|
* The label for the slider.
|
|
168
184
|
*/
|
|
@@ -229,6 +245,14 @@ export default class Slider extends PureComponent<SliderProps> {
|
|
|
229
245
|
* The value.
|
|
230
246
|
*/
|
|
231
247
|
value: PropTypes.Validator<number>;
|
|
248
|
+
/**
|
|
249
|
+
* `Specify whether the Slider is in a warn state
|
|
250
|
+
*/
|
|
251
|
+
warn: PropTypes.Requireable<boolean>;
|
|
252
|
+
/**
|
|
253
|
+
* Provide the text that is displayed when the Slider is in an warn state
|
|
254
|
+
*/
|
|
255
|
+
warnText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
232
256
|
};
|
|
233
257
|
static defaultProps: {
|
|
234
258
|
hideTextInput: boolean;
|
|
@@ -20,6 +20,7 @@ var match = require('../../internal/keyboard/match.js');
|
|
|
20
20
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
21
21
|
var deprecate = require('../../prop-types/deprecate.js');
|
|
22
22
|
var index = require('../FeatureFlags/index.js');
|
|
23
|
+
var iconsReact = require('@carbon/icons-react');
|
|
23
24
|
|
|
24
25
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
25
26
|
|
|
@@ -444,11 +445,14 @@ class Slider extends React.PureComponent {
|
|
|
444
445
|
step,
|
|
445
446
|
stepMultiplier: _stepMultiplier,
|
|
446
447
|
inputType,
|
|
448
|
+
invalidText,
|
|
447
449
|
required,
|
|
448
450
|
disabled,
|
|
449
451
|
name,
|
|
450
452
|
light,
|
|
451
453
|
readOnly,
|
|
454
|
+
warn,
|
|
455
|
+
warnText,
|
|
452
456
|
...other
|
|
453
457
|
} = this.props;
|
|
454
458
|
delete other.onRelease;
|
|
@@ -476,8 +480,9 @@ class Slider extends React.PureComponent {
|
|
|
476
480
|
}, [enabled ? null : className]);
|
|
477
481
|
const inputClasses = cx__default["default"](`${prefix}--text-input`, `${prefix}--slider-text-input`, {
|
|
478
482
|
[`${prefix}--text-input--light`]: light,
|
|
479
|
-
[`${prefix}--text-input--invalid`]: isValid === false,
|
|
480
|
-
[`${prefix}--slider-text-input--hidden`]: hideTextInput
|
|
483
|
+
[`${prefix}--text-input--invalid`]: !readOnly && isValid === false,
|
|
484
|
+
[`${prefix}--slider-text-input--hidden`]: hideTextInput,
|
|
485
|
+
[`${prefix}--slider-text-input--warn`]: !readOnly && warn
|
|
481
486
|
});
|
|
482
487
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
483
488
|
className: enabled ? cx__default["default"](`${prefix}--form-item`, className) : `${prefix}--form-item`
|
|
@@ -499,7 +504,7 @@ class Slider extends React.PureComponent {
|
|
|
499
504
|
onKeyDown: this.onKeyDown,
|
|
500
505
|
role: "presentation",
|
|
501
506
|
tabIndex: -1,
|
|
502
|
-
"data-invalid": isValid ?
|
|
507
|
+
"data-invalid": !isValid && !readOnly ? true : null
|
|
503
508
|
}, other), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
504
509
|
className: `${prefix}--slider__thumb`,
|
|
505
510
|
role: "slider",
|
|
@@ -536,10 +541,18 @@ class Slider extends React.PureComponent {
|
|
|
536
541
|
onChange: this.onChange,
|
|
537
542
|
onBlur: this.onBlur,
|
|
538
543
|
onKeyUp: this.props.onInputKeyUp,
|
|
539
|
-
"data-invalid": isValid ?
|
|
540
|
-
"aria-invalid": isValid ?
|
|
544
|
+
"data-invalid": !isValid && !readOnly ? true : null,
|
|
545
|
+
"aria-invalid": !isValid && !readOnly ? true : undefined,
|
|
541
546
|
readOnly: readOnly
|
|
542
|
-
})
|
|
547
|
+
}), !readOnly && isValid === false && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
|
|
548
|
+
className: `${prefix}--slider__invalid-icon`
|
|
549
|
+
}), !readOnly && warn && isValid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
|
|
550
|
+
className: `${prefix}--slider__invalid-icon ${prefix}--slider__invalid-icon--warning`
|
|
551
|
+
})), !readOnly && isValid === false && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
552
|
+
className: cx__default["default"](`${prefix}--slider__validation-msg`, `${prefix}--slider__validation-msg--invalid`, `${prefix}--form-requirement`)
|
|
553
|
+
}, invalidText), !readOnly && warn && isValid && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
554
|
+
className: cx__default["default"](`${prefix}--slider__validation-msg`, `${prefix}--form-requirement`)
|
|
555
|
+
}, warnText));
|
|
543
556
|
});
|
|
544
557
|
}
|
|
545
558
|
|
|
@@ -587,10 +600,15 @@ _rollupPluginBabelHelpers.defineProperty(Slider, "propTypes", {
|
|
|
587
600
|
inputType: PropTypes__default["default"].string,
|
|
588
601
|
|
|
589
602
|
/**
|
|
590
|
-
* `
|
|
603
|
+
* `Specify whether the Slider is currently invalid
|
|
591
604
|
*/
|
|
592
605
|
invalid: PropTypes__default["default"].bool,
|
|
593
606
|
|
|
607
|
+
/**
|
|
608
|
+
* Provide the text that is displayed when the Slider is in an invalid state
|
|
609
|
+
*/
|
|
610
|
+
invalidText: PropTypes__default["default"].node,
|
|
611
|
+
|
|
594
612
|
/**
|
|
595
613
|
* The label for the slider.
|
|
596
614
|
*/
|
|
@@ -671,7 +689,17 @@ _rollupPluginBabelHelpers.defineProperty(Slider, "propTypes", {
|
|
|
671
689
|
/**
|
|
672
690
|
* The value.
|
|
673
691
|
*/
|
|
674
|
-
value: PropTypes__default["default"].number.isRequired
|
|
692
|
+
value: PropTypes__default["default"].number.isRequired,
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* `Specify whether the Slider is in a warn state
|
|
696
|
+
*/
|
|
697
|
+
warn: PropTypes__default["default"].bool,
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Provide the text that is displayed when the Slider is in an warn state
|
|
701
|
+
*/
|
|
702
|
+
warnText: PropTypes__default["default"].node
|
|
675
703
|
});
|
|
676
704
|
|
|
677
705
|
_rollupPluginBabelHelpers.defineProperty(Slider, "defaultProps", {
|
|
@@ -26,15 +26,13 @@ var _span, _span2, _span3;
|
|
|
26
26
|
const StructuredListSkeleton = _ref => {
|
|
27
27
|
let {
|
|
28
28
|
rowCount,
|
|
29
|
-
border,
|
|
30
29
|
className,
|
|
31
30
|
...rest
|
|
32
31
|
} = _ref;
|
|
33
32
|
const prefix = usePrefix.usePrefix();
|
|
34
33
|
const StructuredListSkeletonClasses = cx__default["default"](className, {
|
|
35
34
|
[`${prefix}--skeleton`]: true,
|
|
36
|
-
[`${prefix}--structured-list`]: true
|
|
37
|
-
[`${prefix}--structured-list--border`]: border
|
|
35
|
+
[`${prefix}--structured-list`]: true
|
|
38
36
|
});
|
|
39
37
|
const rows = [];
|
|
40
38
|
|
|
@@ -69,11 +67,6 @@ const StructuredListSkeleton = _ref => {
|
|
|
69
67
|
};
|
|
70
68
|
|
|
71
69
|
StructuredListSkeleton.propTypes = {
|
|
72
|
-
/**
|
|
73
|
-
* Specify whether a border should be added to your StructuredListSkeleton
|
|
74
|
-
*/
|
|
75
|
-
border: PropTypes__default["default"].bool,
|
|
76
|
-
|
|
77
70
|
/**
|
|
78
71
|
* Specify an optional className to add.
|
|
79
72
|
*/
|
|
@@ -85,8 +78,7 @@ StructuredListSkeleton.propTypes = {
|
|
|
85
78
|
rowCount: PropTypes__default["default"].number
|
|
86
79
|
};
|
|
87
80
|
StructuredListSkeleton.defaultProps = {
|
|
88
|
-
rowCount: 5
|
|
89
|
-
border: false
|
|
81
|
+
rowCount: 5
|
|
90
82
|
};
|
|
91
83
|
var StructuredListSkeleton$1 = StructuredListSkeleton;
|
|
92
84
|
|
|
@@ -40,7 +40,7 @@ function StructuredListWrapper(props) {
|
|
|
40
40
|
const classes = cx__default["default"](`${prefix}--structured-list`, className, {
|
|
41
41
|
[`${prefix}--structured-list--selection`]: selection,
|
|
42
42
|
[`${prefix}--structured-list--condensed`]: isCondensed,
|
|
43
|
-
[`${prefix}--structured-list--flush`]: isFlush
|
|
43
|
+
[`${prefix}--structured-list--flush`]: isFlush && !selection
|
|
44
44
|
});
|
|
45
45
|
const [selectedRow, setSelectedRow] = React__default["default"].useState(null);
|
|
46
46
|
return /*#__PURE__*/React__default["default"].createElement(GridSelectedRowStateContext.Provider, {
|
|
@@ -82,7 +82,7 @@ StructuredListWrapper.propTypes = {
|
|
|
82
82
|
isCondensed: PropTypes__default["default"].bool,
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* Specify if structured list is flush, default is false
|
|
85
|
+
* Specify if structured list is flush, not valid for selection variant, default is false
|
|
86
86
|
*/
|
|
87
87
|
isFlush: PropTypes__default["default"].bool,
|
|
88
88
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2016, 2023
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import React, { ElementType, type PropsWithChildren } from 'react';
|
|
9
|
+
import { PolymorphicProps } from '../../types/common';
|
|
10
|
+
interface GlobalThemeProps {
|
|
11
|
+
theme?: 'white' | 'g10' | 'g90' | 'g100';
|
|
12
|
+
}
|
|
13
|
+
export declare const ThemeContext: React.Context<GlobalThemeProps>;
|
|
14
|
+
export declare function GlobalTheme({ children, theme, }: PropsWithChildren<GlobalThemeProps>): JSX.Element;
|
|
15
|
+
export declare namespace GlobalTheme {
|
|
16
|
+
var propTypes: {
|
|
17
|
+
/**
|
|
18
|
+
* Provide child elements to be rendered inside of `GlobalTheme`, this is
|
|
19
|
+
* typically the root of your app
|
|
20
|
+
*/
|
|
21
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
22
|
+
/**
|
|
23
|
+
* Specify the global theme for your app
|
|
24
|
+
*/
|
|
25
|
+
theme: PropTypes.Requireable<string>;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
type ThemeBaseProps = GlobalThemeProps & {
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
type ThemeProps<E extends ElementType> = PolymorphicProps<E, ThemeBaseProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Specify the theme to be applied to a page, or a region in a page
|
|
34
|
+
*/
|
|
35
|
+
export declare function Theme<E extends ElementType = 'div'>({ as: BaseComponent, className: customClassName, theme, ...rest }: ThemeProps<E>): JSX.Element;
|
|
36
|
+
export declare namespace Theme {
|
|
37
|
+
var propTypes: {
|
|
38
|
+
/**
|
|
39
|
+
* Specify a custom component or element to be rendered as the top-level
|
|
40
|
+
* element in the component
|
|
41
|
+
*/
|
|
42
|
+
as: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactComponentLike | null | undefined>>;
|
|
43
|
+
/**
|
|
44
|
+
* Provide child elements to be rendered inside of `Theme`
|
|
45
|
+
*/
|
|
46
|
+
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
47
|
+
/**
|
|
48
|
+
* Provide a custom class name to be used on the outermost element rendered by
|
|
49
|
+
* the component
|
|
50
|
+
*/
|
|
51
|
+
className: PropTypes.Requireable<string>;
|
|
52
|
+
/**
|
|
53
|
+
* Specify the theme
|
|
54
|
+
*/
|
|
55
|
+
theme: PropTypes.Requireable<string>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get access to the current theme
|
|
60
|
+
*/
|
|
61
|
+
export declare function useTheme(): GlobalThemeProps;
|
|
62
|
+
export {};
|
|
@@ -51,14 +51,13 @@ GlobalTheme.propTypes = {
|
|
|
51
51
|
*/
|
|
52
52
|
theme: PropTypes__default["default"].oneOf(['white', 'g10', 'g90', 'g100'])
|
|
53
53
|
};
|
|
54
|
+
|
|
54
55
|
/**
|
|
55
56
|
* Specify the theme to be applied to a page, or a region in a page
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
58
|
function Theme(_ref2) {
|
|
59
59
|
let {
|
|
60
60
|
as: BaseComponent = 'div',
|
|
61
|
-
children,
|
|
62
61
|
className: customClassName,
|
|
63
62
|
theme,
|
|
64
63
|
...rest
|
|
@@ -76,13 +75,14 @@ function Theme(_ref2) {
|
|
|
76
75
|
theme
|
|
77
76
|
};
|
|
78
77
|
}, [theme]);
|
|
78
|
+
const BaseComponentAsAny = BaseComponent;
|
|
79
79
|
return /*#__PURE__*/React__default["default"].createElement(ThemeContext.Provider, {
|
|
80
80
|
value: value
|
|
81
81
|
}, /*#__PURE__*/React__default["default"].createElement(LayerContext.LayerContext.Provider, {
|
|
82
82
|
value: 1
|
|
83
|
-
}, /*#__PURE__*/React__default["default"].createElement(
|
|
83
|
+
}, /*#__PURE__*/React__default["default"].createElement(BaseComponentAsAny, _rollupPluginBabelHelpers["extends"]({}, rest, {
|
|
84
84
|
className: className
|
|
85
|
-
})
|
|
85
|
+
}))));
|
|
86
86
|
}
|
|
87
87
|
Theme.propTypes = {
|
|
88
88
|
/**
|
|
@@ -11,6 +11,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
11
11
|
|
|
12
12
|
var PropTypes = require('prop-types');
|
|
13
13
|
var React = require('react');
|
|
14
|
+
var useEvent = require('../../internal/useEvent.js');
|
|
15
|
+
var match = require('../../internal/keyboard/match.js');
|
|
16
|
+
var keys = require('../../internal/keyboard/keys.js');
|
|
14
17
|
|
|
15
18
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
19
|
|
|
@@ -24,6 +27,11 @@ const HeaderContainer = _ref => {
|
|
|
24
27
|
} = _ref;
|
|
25
28
|
//state for expandable sidenav
|
|
26
29
|
const [isSideNavExpandedState, setIsSideNavExpandedState] = React.useState(isSideNavExpanded);
|
|
30
|
+
useEvent.useWindowEvent('keydown', event => {
|
|
31
|
+
if (match.match(event, keys.Escape)) {
|
|
32
|
+
setIsSideNavExpandedState(false);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
27
35
|
const handleHeaderMenuButtonClick = React.useCallback(() => {
|
|
28
36
|
setIsSideNavExpandedState(prevIsSideNavExpanded => !prevIsSideNavExpanded);
|
|
29
37
|
}, [setIsSideNavExpandedState]);
|