carbon-react 151.2.3 → 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/__internal__/dom/globals.d.ts +51 -0
- package/esm/__internal__/dom/globals.js +59 -0
- package/esm/__spec_helper__/mock-element-scrollto.js +3 -0
- package/esm/__spec_helper__/mock-match-media.js +1 -1
- package/esm/__spec_helper__/mock-resize-observer.js +1 -1
- 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/flat-table/flat-table-row/flat-table-row.style.js +4 -1
- package/esm/components/icon/icon.style.js +6 -4
- package/esm/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
- package/esm/components/modal/__internal__/modal-manager.js +18 -7
- package/esm/components/modal/modal.component.js +3 -1
- package/esm/components/sidebar/sidebar.component.d.ts +6 -0
- package/esm/components/sidebar/sidebar.component.js +3 -1
- package/esm/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +3 -1
- package/esm/hooks/__internal__/useScrollBlock/scroll-block-manager.js +11 -4
- package/lib/__internal__/dom/globals.d.ts +51 -0
- package/lib/__internal__/dom/globals.js +67 -0
- package/lib/__spec_helper__/mock-element-scrollto.js +3 -0
- package/lib/__spec_helper__/mock-match-media.js +1 -1
- package/lib/__spec_helper__/mock-resize-observer.js +1 -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/flat-table/flat-table-row/flat-table-row.style.js +4 -1
- package/lib/components/icon/icon.style.js +6 -4
- package/lib/components/menu/menu-full-screen/menu-full-screen.component.js +2 -1
- package/lib/components/modal/__internal__/modal-manager.js +18 -7
- package/lib/components/modal/modal.component.js +3 -1
- package/lib/components/sidebar/sidebar.component.d.ts +6 -0
- package/lib/components/sidebar/sidebar.component.js +3 -1
- package/lib/components/vertical-menu/vertical-menu-full-screen/vertical-menu-full-screen.component.js +3 -1
- package/lib/hooks/__internal__/useScrollBlock/scroll-block-manager.js +12 -6
- package/package.json +4 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDocument = getDocument;
|
|
7
|
+
exports.getNavigator = getNavigator;
|
|
8
|
+
exports.getWindow = getWindow;
|
|
9
|
+
/**
|
|
10
|
+
* Returns the global `window` object in a way that is friendly to SSR.
|
|
11
|
+
* This check can be avoided if you are sure that the code will only run in the browser.
|
|
12
|
+
* Some examples where you can ignore this:
|
|
13
|
+
* - `useEffect` hooks
|
|
14
|
+
* - `useLayoutEffect` hooks
|
|
15
|
+
* - Callbacks for event listeners
|
|
16
|
+
* - Files with the `"use-client"` directive
|
|
17
|
+
*
|
|
18
|
+
* Primarily, this is necessary when attempting to access the `window` object during rendering of components.
|
|
19
|
+
* However, even still, where possible, it is recommended to avoid accessing the `window` object during rendering
|
|
20
|
+
* because it can lead to hydration mismatches. This happens when the server-rendered HTML differs from what the
|
|
21
|
+
* client renders due to missing environment-specific data (e.g., `window.innerWidth` being undefined on the server).
|
|
22
|
+
*
|
|
23
|
+
* @returns The global `window` object, if it exists.
|
|
24
|
+
*/
|
|
25
|
+
function getWindow() {
|
|
26
|
+
return typeof window !== "undefined" ? window : undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Returns the global `document` object in a way that is friendly to SSR.
|
|
31
|
+
* This check can be avoided if you are sure that the code will only run in the browser.
|
|
32
|
+
* Some examples where you can ignore this:
|
|
33
|
+
* - `useEffect` hooks
|
|
34
|
+
* - `useLayoutEffect` hooks
|
|
35
|
+
* - Callbacks for event listeners
|
|
36
|
+
* - Files with the `"use-client"` directive
|
|
37
|
+
*
|
|
38
|
+
* Primarily, this is necessary when attempting to access the `document` object during rendering of components.
|
|
39
|
+
* However, even still, where possible, it is recommended to avoid accessing the `document` object during rendering
|
|
40
|
+
* because it can lead to hydration mismatches. This happens when the server-rendered HTML differs from what the
|
|
41
|
+
* client renders due to missing environment-specific data (e.g., `document.children` being undefined on the server).
|
|
42
|
+
*
|
|
43
|
+
* @returns The global `document` object, if it exists.
|
|
44
|
+
*/
|
|
45
|
+
function getDocument() {
|
|
46
|
+
return typeof document !== "undefined" ? document : undefined;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns the global `navigator` object in a way that is friendly to SSR.
|
|
51
|
+
* This check can be avoided if you are sure that the code will only run in the browser.
|
|
52
|
+
* Some examples where you can ignore this:
|
|
53
|
+
* - `useEffect` hooks
|
|
54
|
+
* - `useLayoutEffect` hooks
|
|
55
|
+
* - Callbacks for event listeners
|
|
56
|
+
* - Files with the `"use-client"` directive
|
|
57
|
+
*
|
|
58
|
+
* Primarily, this is necessary when attempting to access the `navigator` object during rendering of components.
|
|
59
|
+
* However, even still, where possible, it is recommended to avoid accessing the `navigator` object during rendering
|
|
60
|
+
* because it can lead to hydration mismatches. This happens when the server-rendered HTML differs from what the
|
|
61
|
+
* client renders due to missing environment-specific data (e.g., `navigator.userAgent` being undefined on the server).
|
|
62
|
+
*
|
|
63
|
+
* @returns The global `navigator` object, if it exists.
|
|
64
|
+
*/
|
|
65
|
+
function getNavigator() {
|
|
66
|
+
return typeof navigator !== "undefined" ? navigator : undefined;
|
|
67
|
+
}
|
|
@@ -7,6 +7,9 @@ exports.default = void 0;
|
|
|
7
7
|
const setupScrollToMock = () => {
|
|
8
8
|
// need to mock the `scrollTo` method, which is undefined in JSDOM. As we're not actually testing this behaviour, just make it
|
|
9
9
|
// do nothing.
|
|
10
|
+
if (typeof window === "undefined") {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
10
13
|
HTMLElement.prototype.scrollTo = () => {};
|
|
11
14
|
};
|
|
12
15
|
var _default = exports.default = setupScrollToMock;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
const setupResizeObserverMock = () => {
|
|
8
|
-
if (
|
|
8
|
+
if (typeof window === "undefined") {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
window.ResizeObserver = window.ResizeObserver || jest.fn().mockImplementation(callback => {
|
|
@@ -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";
|
|
@@ -13,6 +13,7 @@ var _flatTableHeader = _interopRequireDefault(require("../flat-table-header/flat
|
|
|
13
13
|
var _icon = _interopRequireDefault(require("../../icon/icon.style"));
|
|
14
14
|
var _color = require("../../../style/utils/color");
|
|
15
15
|
var _addFocusStyling = _interopRequireDefault(require("../../../style/utils/add-focus-styling"));
|
|
16
|
+
var _globals = require("../../../__internal__/dom/globals");
|
|
16
17
|
var _browserTypeCheck = require("../../../__internal__/utils/helpers/browser-type-check");
|
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
19
|
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); }
|
|
@@ -110,6 +111,7 @@ const StyledFlatTableRow = _styledComponents.default.tr`
|
|
|
110
111
|
draggable,
|
|
111
112
|
rowHeight
|
|
112
113
|
}) => {
|
|
114
|
+
const nav = (0, _globals.getNavigator)();
|
|
113
115
|
const backgroundColor = bgColor ? (0, _color.toColor)(theme, bgColor) : undefined;
|
|
114
116
|
const customBorderColor = horizontalBorderColor ? (0, _color.toColor)(theme, horizontalBorderColor) : undefined;
|
|
115
117
|
const colorOfSelected = isInSidebar ? "var(--colorsUtilityMajor150)" : "var(--colorsUtilityMajor075)";
|
|
@@ -218,7 +220,8 @@ const StyledFlatTableRow = _styledComponents.default.tr`
|
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
/* Styling for safari. Position relative does not work on tr elements on Safari */
|
|
221
|
-
|
|
223
|
+
// FIXME: this can cause hydration mismatches during SSR.
|
|
224
|
+
${nav && (0, _browserTypeCheck.isSafari)(nav) && (0, _styledComponents.css)`
|
|
222
225
|
position: -webkit-sticky;
|
|
223
226
|
:after {
|
|
224
227
|
border: none;
|
|
@@ -11,6 +11,7 @@ var _base = _interopRequireDefault(require("../../style/themes/base"));
|
|
|
11
11
|
var _addFocusStyling = _interopRequireDefault(require("../../style/utils/add-focus-styling"));
|
|
12
12
|
var _color = _interopRequireDefault(require("../../style/utils/color"));
|
|
13
13
|
var _getColorValue = _interopRequireDefault(require("../../style/utils/get-color-value"));
|
|
14
|
+
var _globals = require("../../__internal__/dom/globals");
|
|
14
15
|
var _browserTypeCheck = _interopRequireWildcard(require("../../__internal__/utils/helpers/browser-type-check"));
|
|
15
16
|
var _iconConfig = _interopRequireDefault(require("./icon-config"));
|
|
16
17
|
var _iconUnicodes = _interopRequireDefault(require("./icon-unicodes"));
|
|
@@ -57,6 +58,8 @@ const StyledIcon = _styledComponents.default.span`
|
|
|
57
58
|
let finalHoverColor;
|
|
58
59
|
let bgColor;
|
|
59
60
|
let bgHoverColor;
|
|
61
|
+
const win = (0, _globals.getWindow)();
|
|
62
|
+
const nav = (0, _globals.getNavigator)();
|
|
60
63
|
const adjustedBgSize = adjustIconBgSize(fontSize, bgSize);
|
|
61
64
|
try {
|
|
62
65
|
if (disabled) {
|
|
@@ -125,12 +128,11 @@ const StyledIcon = _styledComponents.default.span`
|
|
|
125
128
|
font-size: ${_iconConfig.default.iconSize[fontSize]};
|
|
126
129
|
line-height: ${_iconConfig.default.iconSize[fontSize]};
|
|
127
130
|
`}
|
|
128
|
-
|
|
129
|
-
${type === "services" && (0, _browserTypeCheck.default)(
|
|
131
|
+
// FIXME: this can cause hydration mismatches during SSR.
|
|
132
|
+
${win && type === "services" && (0, _browserTypeCheck.default)(win) && (0, _styledComponents.css)`
|
|
130
133
|
margin-top: ${fontSize === "small" ? "-7px" : "-8px"};
|
|
131
134
|
`}
|
|
132
|
-
|
|
133
|
-
${type === "services" && (0, _browserTypeCheck.isSafari)(navigator) && !(0, _browserTypeCheck.default)(window) && (0, _styledComponents.css)`
|
|
135
|
+
${nav && win && type === "services" && (0, _browserTypeCheck.isSafari)(nav) && !(0, _browserTypeCheck.default)(win) && (0, _styledComponents.css)`
|
|
134
136
|
margin-top: -6px;
|
|
135
137
|
`}
|
|
136
138
|
|
|
@@ -16,6 +16,7 @@ var _icon = _interopRequireDefault(require("../../icon"));
|
|
|
16
16
|
var _portal = _interopRequireDefault(require("../../portal"));
|
|
17
17
|
var _focusTrap = _interopRequireDefault(require("../../../__internal__/focus-trap"));
|
|
18
18
|
var _menuDivider = _interopRequireDefault(require("../menu-divider/menu-divider.component"));
|
|
19
|
+
var _globals = require("../../../__internal__/dom/globals");
|
|
19
20
|
var _useLocale = _interopRequireDefault(require("../../../hooks/__internal__/useLocale"));
|
|
20
21
|
var _useModalAria = _interopRequireDefault(require("../../../hooks/__internal__/useModalAria"));
|
|
21
22
|
var _useModalManager = _interopRequireDefault(require("../../../hooks/__internal__/useModalManager"));
|
|
@@ -63,7 +64,7 @@ const MenuFullscreen = ({
|
|
|
63
64
|
closeModal,
|
|
64
65
|
modalRef: menuRef,
|
|
65
66
|
topModalOverride,
|
|
66
|
-
focusCallToActionElement:
|
|
67
|
+
focusCallToActionElement: (0, _globals.getDocument)()?.activeElement
|
|
67
68
|
});
|
|
68
69
|
return /*#__PURE__*/_react.default.createElement("li", null, /*#__PURE__*/_react.default.createElement(_portal.default, null, /*#__PURE__*/_react.default.createElement(_reactTransitionGroup.CSSTransition, {
|
|
69
70
|
nodeRef: menuRef,
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.ModalManagerInstance = void 0;
|
|
7
|
+
var _globals = require("../../../__internal__/dom/globals");
|
|
7
8
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
8
9
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
10
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -33,12 +34,17 @@ let ModalManagerInstance = exports.ModalManagerInstance = /*#__PURE__*/function
|
|
|
33
34
|
});
|
|
34
35
|
this.callTopModalSetters();
|
|
35
36
|
});
|
|
37
|
+
const safeWindow = (0, _globals.getWindow)();
|
|
38
|
+
if (!safeWindow) {
|
|
39
|
+
this.modalList = [];
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
36
42
|
// Due to possibility of multiple carbon versions using it
|
|
37
43
|
// it is necessary to maintain same structure in this global variable
|
|
38
|
-
if (!
|
|
39
|
-
|
|
44
|
+
if (!safeWindow.__CARBON_INTERNALS_MODAL_LIST) {
|
|
45
|
+
safeWindow.__CARBON_INTERNALS_MODAL_LIST = [];
|
|
40
46
|
}
|
|
41
|
-
this.modalList =
|
|
47
|
+
this.modalList = safeWindow.__CARBON_INTERNALS_MODAL_LIST;
|
|
42
48
|
}
|
|
43
49
|
return _createClass(ModalManagerInstance, [{
|
|
44
50
|
key: "getTopModal",
|
|
@@ -84,16 +90,21 @@ let ModalManagerInstance = exports.ModalManagerInstance = /*#__PURE__*/function
|
|
|
84
90
|
}, {
|
|
85
91
|
key: "clearList",
|
|
86
92
|
value: function clearList() {
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
const safeWindow = (0, _globals.getWindow)();
|
|
94
|
+
const cleared = [];
|
|
95
|
+
if (safeWindow) {
|
|
96
|
+
safeWindow.__CARBON_INTERNALS_MODAL_LIST = cleared;
|
|
97
|
+
}
|
|
98
|
+
this.modalList = cleared;
|
|
89
99
|
this.callTopModalSetters();
|
|
90
100
|
}
|
|
91
101
|
}, {
|
|
92
102
|
key: "callTopModalSetters",
|
|
93
103
|
value: function callTopModalSetters() {
|
|
94
|
-
|
|
104
|
+
const safeWindow = (0, _globals.getWindow)();
|
|
105
|
+
if (safeWindow?.__CARBON_INTERNALS_MODAL_SETTER_LIST) {
|
|
95
106
|
const topModal = this.getTopModal()?.modal || null;
|
|
96
|
-
for (const setTopModal of
|
|
107
|
+
for (const setTopModal of safeWindow.__CARBON_INTERNALS_MODAL_SETTER_LIST) {
|
|
97
108
|
setTopModal(topModal);
|
|
98
109
|
}
|
|
99
110
|
}
|
|
@@ -8,6 +8,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _reactTransitionGroup = require("react-transition-group");
|
|
9
9
|
var _useScrollBlock = _interopRequireDefault(require("../../hooks/__internal__/useScrollBlock"));
|
|
10
10
|
var _portal = _interopRequireDefault(require("../portal"));
|
|
11
|
+
var _globals = require("../../__internal__/dom/globals");
|
|
11
12
|
var _events = _interopRequireDefault(require("../../__internal__/utils/helpers/events"));
|
|
12
13
|
var _useModalManager = _interopRequireDefault(require("../../hooks/__internal__/useModalManager"));
|
|
13
14
|
var _modal = require("./modal.style");
|
|
@@ -62,13 +63,14 @@ const Modal = ({
|
|
|
62
63
|
onCancel(ev);
|
|
63
64
|
}
|
|
64
65
|
}, [disableClose, disableEscKey, onCancel]);
|
|
66
|
+
const safeDocument = (0, _globals.getDocument)();
|
|
65
67
|
(0, _useModalManager.default)({
|
|
66
68
|
open,
|
|
67
69
|
closeModal,
|
|
68
70
|
modalRef: ref,
|
|
69
71
|
setTriggerRefocusFlag,
|
|
70
72
|
topModalOverride,
|
|
71
|
-
focusCallToActionElement: restoreFocusOnClose ?
|
|
73
|
+
focusCallToActionElement: restoreFocusOnClose && safeDocument ? safeDocument.activeElement : undefined
|
|
72
74
|
});
|
|
73
75
|
let background;
|
|
74
76
|
let content;
|
|
@@ -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, {
|
|
@@ -14,6 +14,7 @@ var _icon = _interopRequireDefault(require("../../icon"));
|
|
|
14
14
|
var _box = _interopRequireDefault(require("../../box"));
|
|
15
15
|
var _verticalMenu = require("../vertical-menu.style");
|
|
16
16
|
var _verticalMenuFullScreen = _interopRequireDefault(require("./__internal__/vertical-menu-full-screen.context"));
|
|
17
|
+
var _globals = require("../../../__internal__/dom/globals");
|
|
17
18
|
var _events = _interopRequireDefault(require("../../../__internal__/utils/helpers/events/events"));
|
|
18
19
|
var _useModalManager = _interopRequireDefault(require("../../../hooks/__internal__/useModalManager"));
|
|
19
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -36,12 +37,13 @@ const VerticalMenuFullScreen = ({
|
|
|
36
37
|
onClose(ev);
|
|
37
38
|
}
|
|
38
39
|
}, [onClose]);
|
|
40
|
+
const safeDocument = (0, _globals.getDocument)();
|
|
39
41
|
(0, _useModalManager.default)({
|
|
40
42
|
open: isOpen,
|
|
41
43
|
closeModal: handleKeyDown,
|
|
42
44
|
modalRef: menuWrapperRef,
|
|
43
45
|
topModalOverride: true,
|
|
44
|
-
focusCallToActionElement:
|
|
46
|
+
focusCallToActionElement: safeDocument?.activeElement
|
|
45
47
|
});
|
|
46
48
|
|
|
47
49
|
// TODO remove this as part of FE-5650
|
|
@@ -4,32 +4,38 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _globals = require("../../../__internal__/dom/globals");
|
|
7
8
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
8
9
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
10
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
10
11
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
-
// TODO: This component can be refactored to remove redundant code
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // TODO: This component can be refactored to remove redundant code
|
|
14
14
|
// once we can confirm that all Sage products use version 105.0.0^
|
|
15
15
|
let ScrollBlockManager = /*#__PURE__*/function () {
|
|
16
16
|
function ScrollBlockManager() {
|
|
17
17
|
_classCallCheck(this, ScrollBlockManager);
|
|
18
18
|
_defineProperty(this, "components", void 0);
|
|
19
19
|
_defineProperty(this, "originalValues", void 0);
|
|
20
|
+
const safeWindow = (0, _globals.getWindow)();
|
|
21
|
+
if (!safeWindow) {
|
|
22
|
+
this.components = {};
|
|
23
|
+
this.originalValues = [];
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
20
26
|
// Due to possibility of multiple carbon versions using it
|
|
21
27
|
// it is necessary to maintain same structure in this global variable
|
|
22
|
-
if (!
|
|
23
|
-
|
|
28
|
+
if (!safeWindow.__CARBON_INTERNALS_SCROLL_BLOCKERS) {
|
|
29
|
+
safeWindow.__CARBON_INTERNALS_SCROLL_BLOCKERS = {
|
|
24
30
|
components: {},
|
|
25
31
|
// originalValues can be removed
|
|
26
32
|
originalValues: [],
|
|
27
33
|
restoreValues: null
|
|
28
34
|
};
|
|
29
35
|
}
|
|
30
|
-
this.components =
|
|
36
|
+
this.components = safeWindow.__CARBON_INTERNALS_SCROLL_BLOCKERS.components;
|
|
31
37
|
// TODO: originalValues can be removed
|
|
32
|
-
this.originalValues =
|
|
38
|
+
this.originalValues = safeWindow.__CARBON_INTERNALS_SCROLL_BLOCKERS.originalValues;
|
|
33
39
|
}
|
|
34
40
|
return _createClass(ScrollBlockManager, [{
|
|
35
41
|
key: "registerComponent",
|
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",
|
|
@@ -131,6 +131,7 @@
|
|
|
131
131
|
"eslint-plugin-playwright": "^1.6.0",
|
|
132
132
|
"eslint-plugin-react": "^7.33.2",
|
|
133
133
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
134
|
+
"eslint-plugin-ssr-friendly": "^1.3.0",
|
|
134
135
|
"eslint-plugin-testing-library": "^6.2.2",
|
|
135
136
|
"events": "~1.1.1",
|
|
136
137
|
"fast-glob": "^3.3.2",
|
|
@@ -147,8 +148,10 @@
|
|
|
147
148
|
"jsdom-testing-mocks": "^1.11.0",
|
|
148
149
|
"lint-staged": "^11.2.6",
|
|
149
150
|
"mockdate": "^2.0.5",
|
|
151
|
+
"monocart-coverage-reports": "^2.12.2",
|
|
150
152
|
"nock": "^13.3.8",
|
|
151
153
|
"node-fetch": "^3.3.2",
|
|
154
|
+
"nyc": "^17.1.0",
|
|
152
155
|
"prettier": "~3.3.3",
|
|
153
156
|
"raf": "^3.4.1",
|
|
154
157
|
"react": "^18.3.1",
|
|
@@ -184,8 +187,6 @@
|
|
|
184
187
|
"invariant": "^2.2.4",
|
|
185
188
|
"lexical": "^0.21.0",
|
|
186
189
|
"lodash": "^4.17.21",
|
|
187
|
-
"monocart-coverage-reports": "^2.11.4",
|
|
188
|
-
"nyc": "^17.1.0",
|
|
189
190
|
"polished": "^4.2.2",
|
|
190
191
|
"prop-types": "^15.8.1",
|
|
191
192
|
"react-day-picker": "^9.3.2",
|