carbon-react 151.3.0 → 151.4.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/esm/components/adaptive-sidebar/__internal__/utils.d.ts +6 -0
- package/esm/components/adaptive-sidebar/__internal__/utils.js +23 -0
- package/esm/components/adaptive-sidebar/adaptive-sidebar.component.d.ts +25 -0
- package/esm/components/adaptive-sidebar/adaptive-sidebar.component.js +56 -0
- package/esm/components/adaptive-sidebar/adaptive-sidebar.style.d.ts +12 -0
- package/esm/components/adaptive-sidebar/adaptive-sidebar.style.js +35 -0
- package/esm/components/adaptive-sidebar/index.d.ts +2 -0
- package/esm/components/adaptive-sidebar/index.js +1 -0
- package/esm/components/box/box.component.d.ts +2 -0
- package/esm/components/box/box.component.js +3 -1
- package/esm/components/sidebar/sidebar.component.d.ts +6 -0
- package/esm/components/sidebar/sidebar.component.js +3 -1
- package/lib/components/adaptive-sidebar/__internal__/utils.d.ts +6 -0
- package/lib/components/adaptive-sidebar/__internal__/utils.js +31 -0
- package/lib/components/adaptive-sidebar/adaptive-sidebar.component.d.ts +25 -0
- package/lib/components/adaptive-sidebar/adaptive-sidebar.component.js +66 -0
- package/lib/components/adaptive-sidebar/adaptive-sidebar.style.d.ts +12 -0
- package/lib/components/adaptive-sidebar/adaptive-sidebar.style.js +43 -0
- package/lib/components/adaptive-sidebar/index.d.ts +2 -0
- package/lib/components/adaptive-sidebar/index.js +13 -0
- package/lib/components/adaptive-sidebar/package.json +6 -0
- package/lib/components/box/box.component.d.ts +2 -0
- package/lib/components/box/box.component.js +3 -1
- package/lib/components/sidebar/sidebar.component.d.ts +6 -0
- package/lib/components/sidebar/sidebar.component.js +3 -1
- package/package.json +3 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdaptiveSidebarProps } from "../adaptive-sidebar.component";
|
|
2
|
+
export declare const getColors: (backgroundColor: AdaptiveSidebarProps["backgroundColor"]) => {
|
|
3
|
+
"background-color": string;
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const kebabToCamelCase: (str: string) => string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const getColors = backgroundColor => {
|
|
2
|
+
switch (backgroundColor) {
|
|
3
|
+
case "app":
|
|
4
|
+
return {
|
|
5
|
+
"background-color": "var(--colorsUtilityMajor025)",
|
|
6
|
+
color: "var(--colorsUtilityYin090)"
|
|
7
|
+
};
|
|
8
|
+
case "black":
|
|
9
|
+
return {
|
|
10
|
+
"background-color": "var(--colorsUtilityYin100)",
|
|
11
|
+
color: "var(--colorsUtilityYang100)"
|
|
12
|
+
};
|
|
13
|
+
case "white":
|
|
14
|
+
default:
|
|
15
|
+
return {
|
|
16
|
+
"background-color": "var(--colorsUtilityYang100)",
|
|
17
|
+
color: "var(--colorsUtilityYin090)"
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const kebabToCamelCase = str => {
|
|
22
|
+
return str.replace(/-./g, match => match.charAt(1).toUpperCase());
|
|
23
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps, MarginProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
+
export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component"> {
|
|
5
|
+
/** The breakpoint (in pixels) at which the sidebar will convert to a dialog-based sidebar */
|
|
6
|
+
adaptiveBreakpoint?: number;
|
|
7
|
+
/** The time in milliseconds for the sidebar to animate */
|
|
8
|
+
animationTimeout?: number;
|
|
9
|
+
/** The background color of the sidebar */
|
|
10
|
+
backgroundColor?: "white" | "black" | "app";
|
|
11
|
+
/** The color to use for the left-hand border of the sidebar. Should be a design token e.g. `--colorsUtilityYang100` */
|
|
12
|
+
borderColor?: string | "none";
|
|
13
|
+
/** The content of the sidebar */
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/** The height of the sidebar, relative to the wrapping component */
|
|
16
|
+
height?: string;
|
|
17
|
+
/** Whether the sidebar is open or closed */
|
|
18
|
+
open: boolean;
|
|
19
|
+
/** Whether to render the sidebar as a modal component instead of as an inline sidebar */
|
|
20
|
+
renderAsModal?: boolean;
|
|
21
|
+
/** The width of the sidebar */
|
|
22
|
+
width?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, open, renderAsModal, width, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
|
|
25
|
+
export default AdaptiveSidebar;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
|
+
import React, { useEffect, useRef } from "react";
|
|
3
|
+
import { getColors, kebabToCamelCase } from "./__internal__/utils";
|
|
4
|
+
import Box from "../box";
|
|
5
|
+
import { filterStyledSystemMarginProps, filterStyledSystemPaddingProps } from "../../style/utils";
|
|
6
|
+
import useIsAboveBreakpoint from "../../hooks/__internal__/useIsAboveBreakpoint";
|
|
7
|
+
import { StyledAdaptiveSidebar, StyledSidebar } from "./adaptive-sidebar.style";
|
|
8
|
+
export const AdaptiveSidebar = ({
|
|
9
|
+
adaptiveBreakpoint = 768,
|
|
10
|
+
backgroundColor = "white",
|
|
11
|
+
borderColor = "none",
|
|
12
|
+
children,
|
|
13
|
+
height = "100%",
|
|
14
|
+
open,
|
|
15
|
+
renderAsModal = false,
|
|
16
|
+
width = "320px",
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const largeScreen = useIsAboveBreakpoint(adaptiveBreakpoint);
|
|
20
|
+
const adaptiveSidebarRef = useRef(null);
|
|
21
|
+
const colours = Object.entries(getColors(backgroundColor)).reduce((acc, [key, value]) => {
|
|
22
|
+
acc[kebabToCamelCase(key)] = value;
|
|
23
|
+
return acc;
|
|
24
|
+
}, {});
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
if (adaptiveSidebarRef.current) {
|
|
28
|
+
adaptiveSidebarRef.current.focus();
|
|
29
|
+
}
|
|
30
|
+
}, [open]);
|
|
31
|
+
if (renderAsModal || !largeScreen) {
|
|
32
|
+
return /*#__PURE__*/React.createElement(StyledSidebar, {
|
|
33
|
+
backgroundColor: backgroundColor,
|
|
34
|
+
open: open,
|
|
35
|
+
p: 0,
|
|
36
|
+
ref: adaptiveSidebarRef
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Box, _extends({
|
|
38
|
+
height: "100%",
|
|
39
|
+
"data-role": "adaptive-sidebar-content-wrapper"
|
|
40
|
+
}, colours), children));
|
|
41
|
+
}
|
|
42
|
+
return open ? /*#__PURE__*/React.createElement(StyledAdaptiveSidebar, _extends({
|
|
43
|
+
backgroundColor: backgroundColor,
|
|
44
|
+
borderColor: borderColor === "none" ? undefined : borderColor,
|
|
45
|
+
"data-element": "adaptive-sidebar",
|
|
46
|
+
"data-role": "adaptive-sidebar",
|
|
47
|
+
height: height,
|
|
48
|
+
ref: adaptiveSidebarRef,
|
|
49
|
+
role: "region",
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
width: width
|
|
52
|
+
}, filterStyledSystemMarginProps(props), filterStyledSystemPaddingProps(props)), /*#__PURE__*/React.createElement(Box, {
|
|
53
|
+
"data-role": "adaptive-sidebar-content-wrapper"
|
|
54
|
+
}, children)) : null;
|
|
55
|
+
};
|
|
56
|
+
export default AdaptiveSidebar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MarginProps, PaddingProps } from "styled-system";
|
|
3
|
+
import { SidebarProps } from "../sidebar";
|
|
4
|
+
import { AdaptiveSidebarProps } from "./adaptive-sidebar.component";
|
|
5
|
+
declare const StyledAdaptiveSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, Pick<AdaptiveSidebarProps, "width" | "backgroundColor" | "height" | "borderColor"> & MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
6
|
+
tabIndex: number;
|
|
7
|
+
}, never>;
|
|
8
|
+
interface StyledSidebarProps extends SidebarProps {
|
|
9
|
+
backgroundColor: "app" | "black" | "white";
|
|
10
|
+
}
|
|
11
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<SidebarProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledSidebarProps, never>;
|
|
12
|
+
export { StyledAdaptiveSidebar, StyledSidebar };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
import { margin, padding } from "styled-system";
|
|
3
|
+
import Box from "../box";
|
|
4
|
+
import Sidebar from "../sidebar";
|
|
5
|
+
import { getColors } from "./__internal__/utils";
|
|
6
|
+
const StyledAdaptiveSidebar = styled(Box)`
|
|
7
|
+
${({
|
|
8
|
+
backgroundColor,
|
|
9
|
+
borderColor,
|
|
10
|
+
height,
|
|
11
|
+
width
|
|
12
|
+
}) => css`
|
|
13
|
+
${getColors(backgroundColor)}
|
|
14
|
+
${borderColor && css`
|
|
15
|
+
border-left: 1px solid var(${borderColor});
|
|
16
|
+
`}
|
|
17
|
+
max-height: ${height};
|
|
18
|
+
max-width: ${width};
|
|
19
|
+
min-width: ${width};
|
|
20
|
+
overflow-y: auto;
|
|
21
|
+
|
|
22
|
+
${margin}
|
|
23
|
+
${padding}
|
|
24
|
+
`};
|
|
25
|
+
`;
|
|
26
|
+
const StyledSidebar = styled(Sidebar)`
|
|
27
|
+
${({
|
|
28
|
+
backgroundColor
|
|
29
|
+
}) => css`
|
|
30
|
+
div[data-element="sidebar-content"] {
|
|
31
|
+
${getColors(backgroundColor)}
|
|
32
|
+
}
|
|
33
|
+
`}
|
|
34
|
+
`;
|
|
35
|
+
export { StyledAdaptiveSidebar, StyledSidebar };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./adaptive-sidebar.component";
|
|
@@ -51,6 +51,8 @@ export interface BoxProps extends FlexboxProps, Omit<GridProps, "gridGap" | "gri
|
|
|
51
51
|
"aria-hidden"?: "true" | "false";
|
|
52
52
|
/** @private @internal @ignore */
|
|
53
53
|
"data-component"?: string;
|
|
54
|
+
/** @private @internal @ignore */
|
|
55
|
+
tabIndex?: number;
|
|
54
56
|
}
|
|
55
57
|
export declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
56
58
|
export default Box;
|
|
@@ -5,6 +5,7 @@ import StyledBox from "./box.style";
|
|
|
5
5
|
import tagComponent from "../../__internal__/utils/helpers/tags";
|
|
6
6
|
export const Box = /*#__PURE__*/React.forwardRef(({
|
|
7
7
|
"data-component": dataComponent,
|
|
8
|
+
tabIndex,
|
|
8
9
|
as,
|
|
9
10
|
id,
|
|
10
11
|
role,
|
|
@@ -63,7 +64,8 @@ export const Box = /*#__PURE__*/React.forwardRef(({
|
|
|
63
64
|
borderRadius: borderRadius,
|
|
64
65
|
"aria-hidden": ariaHidden
|
|
65
66
|
}, tagComponent(dataComponent, rest), filterStyledSystemMarginProps(rest), filterStyledSystemPaddingProps(rest), filterStyledSystemFlexboxProps(rest), filterStyledSystemGridProps(rest), filterStyledSystemLayoutProps(rest), {
|
|
66
|
-
cssProps: cssProps
|
|
67
|
+
cssProps: cssProps,
|
|
68
|
+
tabIndex: tabIndex
|
|
67
69
|
}), children);
|
|
68
70
|
});
|
|
69
71
|
Box.displayName = "Box";
|
|
@@ -52,6 +52,12 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<M
|
|
|
52
52
|
focusableSelectors?: string;
|
|
53
53
|
/** Padding to be set on the Sidebar header */
|
|
54
54
|
headerPadding?: PaddingProps;
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @ignore
|
|
58
|
+
* @internal
|
|
59
|
+
* Sets className for component. INTERNAL USE ONLY. */
|
|
60
|
+
className?: string;
|
|
55
61
|
}
|
|
56
62
|
export declare const Sidebar: React.ForwardRefExoticComponent<SidebarProps & React.RefAttributes<HTMLDivElement>>;
|
|
57
63
|
export default Sidebar;
|
|
@@ -38,6 +38,7 @@ export const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
38
38
|
headerPadding = {},
|
|
39
39
|
topModalOverride,
|
|
40
40
|
restoreFocusOnClose = true,
|
|
41
|
+
className,
|
|
41
42
|
...rest
|
|
42
43
|
}, ref) => {
|
|
43
44
|
const locale = useLocale();
|
|
@@ -75,7 +76,8 @@ export const Sidebar = /*#__PURE__*/React.forwardRef(({
|
|
|
75
76
|
size: size,
|
|
76
77
|
onCancel: onCancel,
|
|
77
78
|
role: role,
|
|
78
|
-
width: width
|
|
79
|
+
width: width,
|
|
80
|
+
className: className
|
|
79
81
|
}, header && /*#__PURE__*/React.createElement(SidebarHeader, _extends({
|
|
80
82
|
closeIcon: closeIcon()
|
|
81
83
|
}, headerPadding, {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AdaptiveSidebarProps } from "../adaptive-sidebar.component";
|
|
2
|
+
export declare const getColors: (backgroundColor: AdaptiveSidebarProps["backgroundColor"]) => {
|
|
3
|
+
"background-color": string;
|
|
4
|
+
color: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const kebabToCamelCase: (str: string) => string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.kebabToCamelCase = exports.getColors = void 0;
|
|
7
|
+
const getColors = backgroundColor => {
|
|
8
|
+
switch (backgroundColor) {
|
|
9
|
+
case "app":
|
|
10
|
+
return {
|
|
11
|
+
"background-color": "var(--colorsUtilityMajor025)",
|
|
12
|
+
color: "var(--colorsUtilityYin090)"
|
|
13
|
+
};
|
|
14
|
+
case "black":
|
|
15
|
+
return {
|
|
16
|
+
"background-color": "var(--colorsUtilityYin100)",
|
|
17
|
+
color: "var(--colorsUtilityYang100)"
|
|
18
|
+
};
|
|
19
|
+
case "white":
|
|
20
|
+
default:
|
|
21
|
+
return {
|
|
22
|
+
"background-color": "var(--colorsUtilityYang100)",
|
|
23
|
+
color: "var(--colorsUtilityYin090)"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.getColors = getColors;
|
|
28
|
+
const kebabToCamelCase = str => {
|
|
29
|
+
return str.replace(/-./g, match => match.charAt(1).toUpperCase());
|
|
30
|
+
};
|
|
31
|
+
exports.kebabToCamelCase = kebabToCamelCase;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { PaddingProps, MarginProps } from "styled-system";
|
|
3
|
+
import { TagProps } from "../../__internal__/utils/helpers/tags";
|
|
4
|
+
export interface AdaptiveSidebarProps extends MarginProps, PaddingProps, Omit<TagProps, "data-component"> {
|
|
5
|
+
/** The breakpoint (in pixels) at which the sidebar will convert to a dialog-based sidebar */
|
|
6
|
+
adaptiveBreakpoint?: number;
|
|
7
|
+
/** The time in milliseconds for the sidebar to animate */
|
|
8
|
+
animationTimeout?: number;
|
|
9
|
+
/** The background color of the sidebar */
|
|
10
|
+
backgroundColor?: "white" | "black" | "app";
|
|
11
|
+
/** The color to use for the left-hand border of the sidebar. Should be a design token e.g. `--colorsUtilityYang100` */
|
|
12
|
+
borderColor?: string | "none";
|
|
13
|
+
/** The content of the sidebar */
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
/** The height of the sidebar, relative to the wrapping component */
|
|
16
|
+
height?: string;
|
|
17
|
+
/** Whether the sidebar is open or closed */
|
|
18
|
+
open: boolean;
|
|
19
|
+
/** Whether to render the sidebar as a modal component instead of as an inline sidebar */
|
|
20
|
+
renderAsModal?: boolean;
|
|
21
|
+
/** The width of the sidebar */
|
|
22
|
+
width?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare const AdaptiveSidebar: ({ adaptiveBreakpoint, backgroundColor, borderColor, children, height, open, renderAsModal, width, ...props }: AdaptiveSidebarProps) => React.JSX.Element | null;
|
|
25
|
+
export default AdaptiveSidebar;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.AdaptiveSidebar = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _utils = require("./__internal__/utils");
|
|
9
|
+
var _box = _interopRequireDefault(require("../box"));
|
|
10
|
+
var _utils2 = require("../../style/utils");
|
|
11
|
+
var _useIsAboveBreakpoint = _interopRequireDefault(require("../../hooks/__internal__/useIsAboveBreakpoint"));
|
|
12
|
+
var _adaptiveSidebar = require("./adaptive-sidebar.style");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
17
|
+
const AdaptiveSidebar = ({
|
|
18
|
+
adaptiveBreakpoint = 768,
|
|
19
|
+
backgroundColor = "white",
|
|
20
|
+
borderColor = "none",
|
|
21
|
+
children,
|
|
22
|
+
height = "100%",
|
|
23
|
+
open,
|
|
24
|
+
renderAsModal = false,
|
|
25
|
+
width = "320px",
|
|
26
|
+
...props
|
|
27
|
+
}) => {
|
|
28
|
+
const largeScreen = (0, _useIsAboveBreakpoint.default)(adaptiveBreakpoint);
|
|
29
|
+
const adaptiveSidebarRef = (0, _react.useRef)(null);
|
|
30
|
+
const colours = Object.entries((0, _utils.getColors)(backgroundColor)).reduce((acc, [key, value]) => {
|
|
31
|
+
acc[(0, _utils.kebabToCamelCase)(key)] = value;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
(0, _react.useEffect)(() => {
|
|
35
|
+
/* istanbul ignore next */
|
|
36
|
+
if (adaptiveSidebarRef.current) {
|
|
37
|
+
adaptiveSidebarRef.current.focus();
|
|
38
|
+
}
|
|
39
|
+
}, [open]);
|
|
40
|
+
if (renderAsModal || !largeScreen) {
|
|
41
|
+
return /*#__PURE__*/_react.default.createElement(_adaptiveSidebar.StyledSidebar, {
|
|
42
|
+
backgroundColor: backgroundColor,
|
|
43
|
+
open: open,
|
|
44
|
+
p: 0,
|
|
45
|
+
ref: adaptiveSidebarRef
|
|
46
|
+
}, /*#__PURE__*/_react.default.createElement(_box.default, _extends({
|
|
47
|
+
height: "100%",
|
|
48
|
+
"data-role": "adaptive-sidebar-content-wrapper"
|
|
49
|
+
}, colours), children));
|
|
50
|
+
}
|
|
51
|
+
return open ? /*#__PURE__*/_react.default.createElement(_adaptiveSidebar.StyledAdaptiveSidebar, _extends({
|
|
52
|
+
backgroundColor: backgroundColor,
|
|
53
|
+
borderColor: borderColor === "none" ? undefined : borderColor,
|
|
54
|
+
"data-element": "adaptive-sidebar",
|
|
55
|
+
"data-role": "adaptive-sidebar",
|
|
56
|
+
height: height,
|
|
57
|
+
ref: adaptiveSidebarRef,
|
|
58
|
+
role: "region",
|
|
59
|
+
tabIndex: -1,
|
|
60
|
+
width: width
|
|
61
|
+
}, (0, _utils2.filterStyledSystemMarginProps)(props), (0, _utils2.filterStyledSystemPaddingProps)(props)), /*#__PURE__*/_react.default.createElement(_box.default, {
|
|
62
|
+
"data-role": "adaptive-sidebar-content-wrapper"
|
|
63
|
+
}, children)) : null;
|
|
64
|
+
};
|
|
65
|
+
exports.AdaptiveSidebar = AdaptiveSidebar;
|
|
66
|
+
var _default = exports.default = AdaptiveSidebar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { MarginProps, PaddingProps } from "styled-system";
|
|
3
|
+
import { SidebarProps } from "../sidebar";
|
|
4
|
+
import { AdaptiveSidebarProps } from "./adaptive-sidebar.component";
|
|
5
|
+
declare const StyledAdaptiveSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../box").BoxProps & import("react").RefAttributes<HTMLDivElement>>, any, Pick<AdaptiveSidebarProps, "width" | "backgroundColor" | "height" | "borderColor"> & MarginProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & PaddingProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
6
|
+
tabIndex: number;
|
|
7
|
+
}, never>;
|
|
8
|
+
interface StyledSidebarProps extends SidebarProps {
|
|
9
|
+
backgroundColor: "app" | "black" | "white";
|
|
10
|
+
}
|
|
11
|
+
declare const StyledSidebar: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<SidebarProps & import("react").RefAttributes<HTMLDivElement>>, any, StyledSidebarProps, never>;
|
|
12
|
+
export { StyledAdaptiveSidebar, StyledSidebar };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyledSidebar = exports.StyledAdaptiveSidebar = void 0;
|
|
7
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
8
|
+
var _styledSystem = require("styled-system");
|
|
9
|
+
var _box = _interopRequireDefault(require("../box"));
|
|
10
|
+
var _sidebar = _interopRequireDefault(require("../sidebar"));
|
|
11
|
+
var _utils = require("./__internal__/utils");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
const StyledAdaptiveSidebar = exports.StyledAdaptiveSidebar = (0, _styledComponents.default)(_box.default)`
|
|
16
|
+
${({
|
|
17
|
+
backgroundColor,
|
|
18
|
+
borderColor,
|
|
19
|
+
height,
|
|
20
|
+
width
|
|
21
|
+
}) => (0, _styledComponents.css)`
|
|
22
|
+
${(0, _utils.getColors)(backgroundColor)}
|
|
23
|
+
${borderColor && (0, _styledComponents.css)`
|
|
24
|
+
border-left: 1px solid var(${borderColor});
|
|
25
|
+
`}
|
|
26
|
+
max-height: ${height};
|
|
27
|
+
max-width: ${width};
|
|
28
|
+
min-width: ${width};
|
|
29
|
+
overflow-y: auto;
|
|
30
|
+
|
|
31
|
+
${_styledSystem.margin}
|
|
32
|
+
${_styledSystem.padding}
|
|
33
|
+
`};
|
|
34
|
+
`;
|
|
35
|
+
const StyledSidebar = exports.StyledSidebar = (0, _styledComponents.default)(_sidebar.default)`
|
|
36
|
+
${({
|
|
37
|
+
backgroundColor
|
|
38
|
+
}) => (0, _styledComponents.css)`
|
|
39
|
+
div[data-element="sidebar-content"] {
|
|
40
|
+
${(0, _utils.getColors)(backgroundColor)}
|
|
41
|
+
}
|
|
42
|
+
`}
|
|
43
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _adaptiveSidebar.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _adaptiveSidebar = _interopRequireDefault(require("./adaptive-sidebar.component"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -51,6 +51,8 @@ export interface BoxProps extends FlexboxProps, Omit<GridProps, "gridGap" | "gri
|
|
|
51
51
|
"aria-hidden"?: "true" | "false";
|
|
52
52
|
/** @private @internal @ignore */
|
|
53
53
|
"data-component"?: string;
|
|
54
|
+
/** @private @internal @ignore */
|
|
55
|
+
tabIndex?: number;
|
|
54
56
|
}
|
|
55
57
|
export declare const Box: React.ForwardRefExoticComponent<BoxProps & React.RefAttributes<HTMLDivElement>>;
|
|
56
58
|
export default Box;
|
|
@@ -12,6 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
13
13
|
const Box = exports.Box = /*#__PURE__*/_react.default.forwardRef(({
|
|
14
14
|
"data-component": dataComponent,
|
|
15
|
+
tabIndex,
|
|
15
16
|
as,
|
|
16
17
|
id,
|
|
17
18
|
role,
|
|
@@ -70,7 +71,8 @@ const Box = exports.Box = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
70
71
|
borderRadius: borderRadius,
|
|
71
72
|
"aria-hidden": ariaHidden
|
|
72
73
|
}, (0, _tags.default)(dataComponent, rest), (0, _utils.filterStyledSystemMarginProps)(rest), (0, _utils.filterStyledSystemPaddingProps)(rest), (0, _utils.filterStyledSystemFlexboxProps)(rest), (0, _utils.filterStyledSystemGridProps)(rest), (0, _utils.filterStyledSystemLayoutProps)(rest), {
|
|
73
|
-
cssProps: cssProps
|
|
74
|
+
cssProps: cssProps,
|
|
75
|
+
tabIndex: tabIndex
|
|
74
76
|
}), children);
|
|
75
77
|
});
|
|
76
78
|
Box.displayName = "Box";
|
|
@@ -52,6 +52,12 @@ export interface SidebarProps extends PaddingProps, TagProps, WidthProps, Pick<M
|
|
|
52
52
|
focusableSelectors?: string;
|
|
53
53
|
/** Padding to be set on the Sidebar header */
|
|
54
54
|
headerPadding?: PaddingProps;
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
* @ignore
|
|
58
|
+
* @internal
|
|
59
|
+
* Sets className for component. INTERNAL USE ONLY. */
|
|
60
|
+
className?: string;
|
|
55
61
|
}
|
|
56
62
|
export declare const Sidebar: React.ForwardRefExoticComponent<SidebarProps & React.RefAttributes<HTMLDivElement>>;
|
|
57
63
|
export default Sidebar;
|
|
@@ -46,6 +46,7 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
46
46
|
headerPadding = {},
|
|
47
47
|
topModalOverride,
|
|
48
48
|
restoreFocusOnClose = true,
|
|
49
|
+
className,
|
|
49
50
|
...rest
|
|
50
51
|
}, ref) => {
|
|
51
52
|
const locale = (0, _useLocale.default)();
|
|
@@ -83,7 +84,8 @@ const Sidebar = exports.Sidebar = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
83
84
|
size: size,
|
|
84
85
|
onCancel: onCancel,
|
|
85
86
|
role: role,
|
|
86
|
-
width: width
|
|
87
|
+
width: width,
|
|
88
|
+
className: className
|
|
87
89
|
}, header && /*#__PURE__*/_react.default.createElement(_sidebarHeader.default, _extends({
|
|
88
90
|
closeIcon: closeIcon()
|
|
89
91
|
}, headerPadding, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carbon-react",
|
|
3
|
-
"version": "151.
|
|
3
|
+
"version": "151.4.0",
|
|
4
4
|
"description": "A library of reusable React components for easily building user interfaces.",
|
|
5
5
|
"files": [
|
|
6
6
|
"lib",
|
|
@@ -148,8 +148,10 @@
|
|
|
148
148
|
"jsdom-testing-mocks": "^1.11.0",
|
|
149
149
|
"lint-staged": "^11.2.6",
|
|
150
150
|
"mockdate": "^2.0.5",
|
|
151
|
+
"monocart-coverage-reports": "^2.12.2",
|
|
151
152
|
"nock": "^13.3.8",
|
|
152
153
|
"node-fetch": "^3.3.2",
|
|
154
|
+
"nyc": "^17.1.0",
|
|
153
155
|
"prettier": "~3.3.3",
|
|
154
156
|
"raf": "^3.4.1",
|
|
155
157
|
"react": "^18.3.1",
|
|
@@ -185,8 +187,6 @@
|
|
|
185
187
|
"invariant": "^2.2.4",
|
|
186
188
|
"lexical": "^0.21.0",
|
|
187
189
|
"lodash": "^4.17.21",
|
|
188
|
-
"monocart-coverage-reports": "^2.11.4",
|
|
189
|
-
"nyc": "^17.1.0",
|
|
190
190
|
"polished": "^4.2.2",
|
|
191
191
|
"prop-types": "^15.8.1",
|
|
192
192
|
"react-day-picker": "^9.3.2",
|